Thread (24 messages) 24 messages, 3 authors, 2021-09-23

RE: [PATCH 1/6] dt-bindings: nvmem: add cell-type to nvmem cells

From: Joakim Zhang <hidden>
Date: 2021-09-23 02:51:27
Also in: lkml

Hi Ahmad,
-----Original Message-----
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
Sent: 2021年9月22日 19:34
To: Joakim Zhang <redacted>;
srinivas.kandagatla@linaro.org; robh+dt@kernel.org; shawnguo@kernel.org;
Jan Lübbe [off-list ref]
Cc: devicetree@vger.kernel.org; dl-linux-imx <redacted>;
kernel@pengutronix.de; linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] dt-bindings: nvmem: add cell-type to nvmem cells

Hi,

On 08.09.21 12:02, Joakim Zhang wrote:
quoted
From: Srinivas Kandagatla <redacted>

Some of the nvmem providers encode data for certain type of nvmem
cell, example mac-address is stored in ascii or with delimiter or in reverse
order.
quoted
This is much specific to vendor, so having a cell-type would allow
nvmem provider drivers to post-process this before using it.
I don't agree with this assessment. Users of the OCOTP so far used this specific
encoding. Bootloaders decode the OCOTP this way, but this encoding isn't
really an inherent attribute of the OCOTP. A new NXP SoC with a different OTP
IP will likely use the same format. Users may even use the same format on an
EEPROM to populate a second off-SoC interface, .. etc.

I'd thus prefer to not make this specific to the OCOTP as all:

  * #define NVMEM_CELL_ENCODING_MAC_ADDRESS_IMX	/* ... */

  * cell-type = <NVMEM_CELL_ENCODING_MAC_ADDRESS_IMX>;

  * and then the decoder is placed into some generic location, e.g.
   drivers/nvmem/encodings.c for Linux

That way, we can reuse this and future encodings across nvmem providers.
It's also more extendable: e.g. big endian fields on EEPROMs. Just stick the
cell-type in, document it in the binding and drivers supporting it will interpret
bytes appropriately.

It's still a good idea to record the type as well as the encoding, e.g. split the 32
bit encoding constant into two 16-bit values.
One is an enum of possible types (unknown, mac_address, IP address ... etc.)
and one is an enum of the available encodings.

What do you think?
Go through the thread you discussed with Srinivas, as we discussed before, we prefer to offload this decoding to
specific nvmem provider driver, instead of nvmem core. 

Best Regards,
Joakim Zhang
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help