mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "John Thomson" <john@johnthomson.fastmail.com.au>
To: "Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>,
	"Vadym Kochan" <vadym.kochan@plvision.eu>
Cc: "Rob Herring" <robh+dt@kernel.org>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	"Robert Marko" <robert.marko@sartura.hr>
Subject: Re: [PATCH v2 1/3] nvmem: core: introduce cells parser
Date: Tue, 21 Sep 2021 05:50:36 +0000	[thread overview]
Message-ID: <77b11bf7-3003-483f-b91e-bd93576eaae1@www.fastmail.com> (raw)
In-Reply-To: <169d3f36-4297-32a3-3d23-824989625b26@linaro.org>

On Mon, 20 Sep 2021, at 13:40, Srinivas Kandagatla wrote:
> On 20/09/2021 14:29, Vadym Kochan wrote:
>> 
>> Srinivas Kandagatla <srinivas.kandagatla@linaro.org> writes:
>> 
>>> On 20/09/2021 13:29, Vadym Kochan wrote:
>>>>
>>>> Srinivas Kandagatla <srinivas.kandagatla@linaro.org> writes:
>>>>
>>>>> On 20/09/2021 12:25, Vadym Kochan wrote:
>>>>>>>> Or, treat cells with length "0" in a special way and allow to update
>>>>>>>> cell info later.you can update irrespective of the length, as long as this is done
>>>>>>> before register.
>>>>>>>
>>>>>>>
>>>>>>>>> };
>>>>>>>>>
>>>>>>>>> some_dev_node {
>>>>>>>>> 	compatible = "xxx";
>>>>>>>>> 	nvmem-cells = <&mac_address>;
>>>>>>>>> 	nvmem-cell-names = "mac-address";
>>>>>>>>> };
>>>>>>>>>
>>>>>>>>> == CODE ==
>>>>>>>>> ret = of_get_mac_address(dev->of_node, base_mac);
>>>>>>>>> ==========
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> If you notice the mac_address node reg is 0.
>>>>>>>>> This node "reg" property should be updated ( using of_update_property())
>>>>>>>>> by nvmem-provider driver while tlv parsing and by matching the node name
>>>>>>>>> with tlv name.
>>>>>>>>>
>>>>>>>> I assume parser driver can just invoke add_cell_table (with may be
>>>>>>>> by adding 'bool update' field to the cell_info struct) and core.c will just
>>>>>>>> update existing cells parsed from OF.
>>>>>>>>
>>>>>>> Lets keep the core code clean for now, I would expect the provider
>>>>>>> driver along with parser function to do update the nodes.
>>>>>>>
>>>>>>> --srini
>>>>>>>
>>>>>> core.c sequence:
>>>>>>
>>>>>> 1) after cells parsed from OF:
>>>>>>
>>>>>> 2) lookup the parser
>>>>>>
>>>>>> 3) parser->cells_parse(ctx, table)
>>>>>>
>>>>>> 3.a) update existing cells matched by name from table
>>>>>>
>>>>>> 4) parser->cells_clean(ctx, table)
>>>>>> /* to free cell's_info allocated by the parser driver */
>>>>>>
>>>>>> as alternative way, I think it would be more generic to
>>>>>> provide nvmem-provider.h API to update the existing cell info,
>>>>>> however it makes sense only when cells were parsed
>>>>>> by the cell parser, in the other situations the
>>>>>> cell should be well defined.
>>>>>>
>>>>>> with this approach the parser driver will be just called
>>>>>> via parser->cells_parse(ctx) and will call nvmem_cell_info_update()
>>>>>> for each parsed cells.
>>>>>
>>>>> TBH, This is an over kill.
>>>>>
>>>>> In nvmem provider driver probe you can parse the tlv data and update the
>>>>> dt nodes before nvmem register.
>>>>>
>>>>> rest of the code should just work as it is.
>>>>>
>>>>> --srini
>>>>
>>>> You mean to parse TLV in the particular nvmem provider driver (for
>>>> example in at24 driver) ? If so, then it will not allow to parse
>>>> this TLV format from the other kinds of nvmem.
>>>
>>> Why not?
>>>
>> 
>> Well, I think that nvmem driver and TLV parsing should somehow be
>> de-coupled from each other like block devices and FS does. BUT,
>> in case this TLV data will be used only on at24 devices then
>> may be it is OK.
>> 
>
> It has to be decoupled yes, which could be at any level with simple 
> library function to a infrastructure level..
>
> In this case with few or single users, doing with an additional 
> infrastructure is a bit of over kill IMO.
>
>
> --srini
>>> Can you also tell us which other nvmem providers are you going to test
>>> this on?
>>>
>> 
>> Currently I can test only on at24 devices. From the:
>> 
>> https://opencomputeproject.github.io/onie/design-spec/hw_requirements.html
>> 
>> "
>> Each ONIE system must include non-volatile storage which contains vital
>> product data assigned by the manufacturer. The non-volatile storage
>> could take the form of an EEPROM, a NOR-flash sector, a NAND-flash
>> sector or any other non-volatile storage medium.
>> "
>> 
>> I am not aware about other nvmem devices which are used for existing
>> ONIE supported boards.
>> 
>>> As long as you represent this parsing function as some library function,
>>> I do not see any issue.
>>> If any exported symbol is available for this then any nvmem provider
>>> could use it.
>>>
>>> --srini
>>>

Hi Srinivas,

Can I note here that I would like to parse
TLV data from an SPI-NOR device to NVMEM cells.
The same general use case (getting mac-address from OEM data).

Was planning to base my work on this series, as well as
https://lore.kernel.org/all/20210908100257.17833-1-qiangqing.zhang@nxp.com/
(thanks for pointing that out Srinivas)

Cheers,
-- 
  John Thomson

  reply	other threads:[~2021-09-21  5:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 19:03 [PATCH v2 0/3] nvmem: add ONIE NVMEM " Vadym Kochan
2021-06-08 19:03 ` [PATCH v2 1/3] nvmem: core: introduce " Vadym Kochan
2021-06-08 22:49   ` kernel test robot
2021-06-09  3:05   ` kernel test robot
2021-06-14 10:44   ` Srinivas Kandagatla
2021-06-16 12:33     ` Vadym Kochan
2021-06-21 11:00       ` Srinivas Kandagatla
2021-09-08  9:38         ` Vadym Kochan
2021-09-13 14:19           ` Srinivas Kandagatla
2021-09-20 10:24             ` Vadym Kochan
2021-09-20 10:36               ` Srinivas Kandagatla
2021-09-20 11:25                 ` Vadym Kochan
2021-09-20 11:32                   ` Srinivas Kandagatla
2021-09-20 12:29                     ` Vadym Kochan
2021-09-20 12:34                       ` Srinivas Kandagatla
2021-09-20 13:29                         ` Vadym Kochan
2021-09-20 13:40                           ` Srinivas Kandagatla
2021-09-21  5:50                             ` John Thomson [this message]
2021-09-27  7:50                               ` Vadym Kochan
2021-09-27 10:12                                 ` Srinivas Kandagatla
2021-09-28 13:31                                   ` Vadym Kochan
2021-09-28 13:51                                     ` Srinivas Kandagatla
2021-09-28 14:11                                       ` Vadym Kochan
2021-09-28 14:39                                         ` Srinivas Kandagatla
2021-09-27 10:12                               ` Srinivas Kandagatla
2021-09-27 12:38                                 ` John Thomson
2021-09-08  9:44     ` Vadym Kochan
2021-06-08 19:03 ` [PATCH v2 2/3] dt-bindings: nvmem: document nvmem-cells-parser-name property Vadym Kochan
2021-06-18 20:59   ` Rob Herring
2021-06-08 19:03 ` [PATCH v2 3/3] nvmem: add ONIE nvmem cells parser Vadym Kochan
2021-08-06 15:39   ` Jan Lübbe
2021-09-08  9:56     ` Vadym Kochan
2021-09-12 21:06       ` John Thomson
2021-09-13 14:20         ` Srinivas Kandagatla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77b11bf7-3003-483f-b91e-bd93576eaae1@www.fastmail.com \
    --to=john@johnthomson.fastmail.com.au \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robert.marko@sartura.hr \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=vadym.kochan@plvision.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®