On 23/11/2021 13:44, Michael Walle wrote:
This is my second attempt to solve the use case where there is only the
base MAC address stored in an EEPROM or similar storage provider. This
is the case for the Kontron sl28 board and multiple openwrt supported
boards.
The first proposal [1] didn't find much appreciation and there wasn't
any reply to my question or new proposal [2]. So here we are with my new
proposal, that is more flexible and doesn't fix the ethernet mac only.
This is just an RFC for the device tree representation for now to see if
this is the correct way to tackle this.
I'm also aware of the latest post process hook support [3]. This doesn't
fix the base mac address issue, but I think it also doesn't solve the
case with swapped ethernet addresses in the general case. That hook will
involve the driver to do the swapping, but how would the driver know
if that swapping is actually required. Usually the interpretation of the
content is opaque to the driver, after all it is the user/board
But this is the path for any post processing hook, which ever
direction we endup with(using core helpers or provider specific
post-processing).
manufacturer who does program the storage device. We might be lucky in
the imx-ocotp case because the IMX reference manual actually states
where and in which format the mac address is programmed.
Introduce a transformation property. This is intended to be just an
enumeration of operations. If there will be a new operation, support for
it has to be added to the nvmem core.
A transformation might have multiple output values, like in the base mac
address case. It reads the mac address from the nvmem storage and
generates multiple individual addresses, i.e. on our board we reserve 8
consecutive addresses. These addresses then can be assigned to different
network interfaces. To make it possible to reference different values we
need to introduce an argument to the phandle. This additional argument
is then an index into a list of values.
Example:
mac_addresses: base-mac-address@10 {
#nvmem-cell-cells = <1>;
reg = <10 6>;
transformation = <NVMEM_T_ETH_OFFSET 0 1 7>;
IMO, this is totally redundant. we could probably encode this info
directly in the cell specifiers, something like:
}
ð0 {
nvmem-cells = <&mac_addresses 0>;
nvmem-cells = <&base_mac_addresses NVMEM_T_ETH_OFFSET 0>;
And value of #nvmem-cell-cells is dependent on the first cell specifier.
I understand that these 3 bits of info is required for this type of
post processing and this can only come from DT and its not possible to
determine this at runtime.
Would this address other usecases?
Are you in a position to test few of them?
Lets wait for Rob's opinion on adding #nvmem-cell-cells property with
cell specifiers describing the encoding information?