Skip to content

[WIP] wifi: mt76: add support for providing precal in nvmem cells - #765

Open
Ansuel wants to merge 2 commits into
openwrt:masterfrom
Ansuel:nvmem-support
Open

[WIP] wifi: mt76: add support for providing precal in nvmem cells#765
Ansuel wants to merge 2 commits into
openwrt:masterfrom
Ansuel:nvmem-support

Conversation

@Ansuel

@Ansuel Ansuel commented Mar 26, 2023

Copy link
Copy Markdown
Member

Add support for providing precal in nvmem cells by adding nvmem cell as
an alternative source for mt76_get_of_eeprom().

Nvmem cells will follow standard nvmem cell definition and needs to be
called 'precal' to be correctly identified.


@nbd168 Hi, i need to be quite honest... this is not tested as i lack any device currently...

But anyway I notice upstream we have mediatek,mtd-eeprom but i really can't see why we need it instead of using the standard way of using nvmem cells.

On openwrt we are widely using them for ath10k precal and mac-address for pretty much everything and even this driver use them to set the mac address... So why not add support for eeprom?

I reordered the function and added support for it. What do you think? Also I decided to use precal for the cell name but this is totally arbritrary and comes from offs = is_mt7915(&dev->mt76) ? MT_EE_PRECAL : MT_EE_PRECAL_V2;

Also maybe on second look the load precal should be a secondary cell so name should be cal?

If this is accepted the final idea is to migrate everyone to nvmem implementation and flag the custom binding as deprecated.

@rmilecki rmilecki left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ansuel: I'd suggest to:

  1. Drop all #if defined(CONFIG_OF) and #if defined(CONFIG_NVMEM)
  2. Make mt76_get_of_eeprom() try all methods one by one and don't return until the last one fails

Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c Outdated
Comment thread eeprom.c
if (IS_ERR(data))
return PTR_ERR(data);

if (retlen < len) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also fail for retlen > len. If NVMEM cell is bigger than expected EEPROM I'd say sth it just wrong there. I wouldn't advise copying just first N bytes of NVMEM cell as you do below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh this is almost a pattern... In theory this should never happen... Should we enforce and match always the requested len?

And use != ?

Comment thread eeprom.c Outdated
@rmilecki

rmilecki commented May 8, 2023

Copy link
Copy Markdown

I fixed compilation errors and verified NVMEM access works (provides the same data as MTD one).

Tested-by: Rafał Miłecki <rafal@milecki.pl>

In preparation for NVMEM support, split get_of_eeprom() in subfunction
to tidy the code and facilitate the addition of alternative method to
get eeprom data. No behaviour change intended.

While at it also drop OF ifdef checks as OF have stubs and calling
of_get_property would result in the same error returned.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
@Ansuel

Ansuel commented May 8, 2023

Copy link
Copy Markdown
Member Author

@rmilecki can you review another time? Think only the retlen is to understand aside from that that is ready...

And we need to understand for the name and the offset thing

@Ansuel

Ansuel commented May 23, 2023

Copy link
Copy Markdown
Member Author

@rmilecki @nbd168 any news with this? also should I submit this upstream?

@Ansuel

Ansuel commented Jun 14, 2023

Copy link
Copy Markdown
Member Author

@rmilecki @nbd168 sorry for retag but any news with this? maybe I should just propose upstream?

Add support for providing eeprom in nvmem cells by adding nvmem cell as
an alternative source for mt76_get_of_eeprom().

Nvmem cells will follow standard nvmem cell definition and needs to be
called eeprom' to be correctly identified.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
@dangowrt

dangowrt commented Jul 11, 2023

Copy link
Copy Markdown
Member

In case someone wants to test this on devices having the EEPROM stored inside a UBI volume or on a partition on the eMMC, I've written two simple read-only NVMEM providers for that:

dangowrt/linux@02ed591

dangowrt/linux@8229a57

@Ansuel

Ansuel commented Jul 11, 2023

Copy link
Copy Markdown
Member Author

@dangowrt btw I sent upstream a variant of this patch that has less patch delta, don't know if you notice it.

@dangowrt

Copy link
Copy Markdown
Member

@neheb

neheb commented Jul 26, 2023

Copy link
Copy Markdown
Contributor

@Ansuel this was merged.

@Ansuel

Ansuel commented Jul 26, 2023 via email

Copy link
Copy Markdown
Member Author

@neheb

neheb commented Jul 26, 2023

Copy link
Copy Markdown
Contributor

cd3dfe3

@Ansuel

Ansuel commented Jul 26, 2023 via email

Copy link
Copy Markdown
Member Author

@dangowrt

Copy link
Copy Markdown
Member

See torvalds/linux@5fdaeca
So actual upstream commit is here:
nbd168/wireless@5bef3a4

@Djfe

Djfe commented Jan 9, 2025

Copy link
Copy Markdown

shall this pr be closed? or is anything missing still?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants