Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2441731pxb; Mon, 20 Sep 2021 22:55:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmFwmfOvneXUD159OeKnrk/t3uGUqYqnehpe/o59rM3SO8duE8HeSzriBDcBgGjExfVUM1 X-Received: by 2002:a50:d80e:: with SMTP id o14mr1141523edj.49.1632203705091; Mon, 20 Sep 2021 22:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632203705; cv=none; d=google.com; s=arc-20160816; b=R3QJ8BCUkfrfcIYFqq31J5CL47TjLSJXK7efJ7uKVSPa3KFW6CSGi9h9g2DOqvlsc+ kXyXAZfuu5ESmKvRlMvDN8I/IKp7PrICqA9U2KwECoOHhZudh6QrD/YMIjthUXhDH8lY XogNmMnpjEL0DeN7MR+e8qawZ50/9bOQQLNw3g3MlQIgDT+Z5uI9pKCi5sv2eLzOc30E xZ0nIxIPnwrh8/jrBvPDF49zN4sgdYWQE4+KTV/NmMlYNXGQoYZ4ISSsLuFyNd/NuGaK dlnKsbTJOZskuTeGSpEz70yXKDSYfk+bqiA9eq09dPa9o/7S/gc388KA/7jjVYr1/bAJ 5/Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature:dkim-signature; bh=l2a30VSKC5LGozrAonmhRzd4StHFUs08tyB9C9xJV4c=; b=HPfZAoocdjv0vOUxsfJGnTqt5a+1BYuFWO4NpiPDoSKevMfv/HHfsVFvOL6F80rtNn t0rve32HichQSG4l85n5dfUjvLksXNEFDeCgIXD9+vs6MlCLzoI2X1R+V7Jl9uIyex/D fOaEeOsDWAf85ts18baOpbShNl1qEhnFnEH1hfps3rCywcoQ21olvZ1k28RNhzEgWcIi 8Z2vg/54rQIobNAa1/Wer7IPLYdkXlmjWkaoo0BX65X6yOb/PfaaK7kNoHkOFc4HoNYC Tu9cCasZGSwq3s9b1bnbWn8YZgAMSev2BYYCcN0R+9LR2SvwB/UP+SrSxf/hHrrS3R/r lLbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fastmail.com.au header.s=fm1 header.b=r2Tft5Sx; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=NP9eB8Rh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fastmail.com.au Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k25si6576475edj.78.2021.09.20.22.54.41; Mon, 20 Sep 2021 22:55:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fastmail.com.au header.s=fm1 header.b=r2Tft5Sx; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=NP9eB8Rh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fastmail.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbhIUFw0 (ORCPT + 99 others); Tue, 21 Sep 2021 01:52:26 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:47841 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhIUFwZ (ORCPT ); Tue, 21 Sep 2021 01:52:25 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4E11C5C0071; Tue, 21 Sep 2021 01:50:57 -0400 (EDT) Received: from imap46 ([10.202.2.96]) by compute4.internal (MEProxy); Tue, 21 Sep 2021 01:50:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com.au; h=mime-version:message-id:in-reply-to:references:date:from:to :cc:subject:content-type; s=fm1; bh=l2a30VSKC5LGozrAonmhRzd4StHF Us08tyB9C9xJV4c=; b=r2Tft5SxlSZ+nvTMpBXYdzCaj/7oNWMcCQz9oKLQPiNE J5mmzlJfHFoOtkZU8kTDbTw+pO0vq8gOVHZUj0ZVDvwiaNPXlyk2QpETMJ5XKQAV olcQZuvAce5s0j0zUdnSN+JB5TrfqcSq4RN92jUt1YOpfcQdmAf/PWrdhcw9OIsO ZDVuMroAZ9uNqw1lV6g1aksQcFKLwRxrxVaGksmT3i3c0yRWtNbQmB3LYWE4hkFj ezQYosb20qHqTNv0f/XLo8Nrbzv1E2lH0cd6DkVzKu3i90rWIcNgZ3Sc73xLrlas TT/s2tt4g1mLhu0xfF21rGEYoPIptP86Kyq0Gm8v5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=l2a30V SKC5LGozrAonmhRzd4StHFUs08tyB9C9xJV4c=; b=NP9eB8RhnSglE91aniL1CG WQCokYmK77cbU1DQQAwr+3EvSgmNjDkKMaVd9Ir7d0ge/Qnqe0u6UDM0FiHmvr3g Pxw3qX8ItEVE5kLZwI7dXgoqSaCdeJHcLyNeXkqxgKi3F4F58ia3m6Qez6RY5MBn sqLc7JaUS3GqAOTbhytFKDP5kVuIoPmWKczWPIz8IwDWXzIwRLPjMNW2b3cvBXz2 +rxeuHOQ7JbW1RHGrtQ69989gZcvPDCsmrAUZe3/cj7oBiuyp+tQ0xaaqhdA5L3B fCFUYQDfOiGDTqPJZgNE12hdF2Diocm+ZFJXmAE+KFnMBnJVJg1SAWhTo8ch1J6w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeifedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuuhhsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpefofgggkfgjfhffhffv ufgtsehttdertderredtnecuhfhrohhmpedflfhohhhnucfvhhhomhhsohhnfdcuoehjoh hhnhesjhhohhhnthhhohhmshhonhdrfhgrshhtmhgrihhlrdgtohhmrdgruheqnecuggft rfgrthhtvghrnhepueelvddugeefjeekueeitefhgefhkeetheduhffgvdfgudefvefgie evkeeljeelnecuffhomhgrihhnpehgihhthhhusgdrihhopdhkvghrnhgvlhdrohhrghen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjohhhnh esjhhohhhnthhhohhmshhonhdrfhgrshhtmhgrihhlrdgtohhmrdgruh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id EDA6F1EE0068; Tue, 21 Sep 2021 01:50:56 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1291-gc66fc0a3a2-fm-20210913.001-gc66fc0a3 Mime-Version: 1.0 Message-Id: <77b11bf7-3003-483f-b91e-bd93576eaae1@www.fastmail.com> In-Reply-To: <169d3f36-4297-32a3-3d23-824989625b26@linaro.org> References: <20210608190327.22071-1-vadym.kochan@plvision.eu> <20210608190327.22071-2-vadym.kochan@plvision.eu> <43023500-dd6a-5180-057e-cecc1f1b6500@linaro.org> <20210616123356.GA9951@plvision.eu> <7e6d75ed-cebc-597f-7062-34261d184968@linaro.org> <0e471789-fe29-b747-5153-75c9b4616c7f@linaro.org> <1da03714-8f23-1004-e89a-891e4599e04a@linaro.org> <1e146349-9fef-972b-9084-577f02d5168b@linaro.org> <169d3f36-4297-32a3-3d23-824989625b26@linaro.org> Date: Tue, 21 Sep 2021 05:50:36 +0000 From: "John Thomson" To: "Srinivas Kandagatla" , "Vadym Kochan" Cc: "Rob Herring" , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, "Robert Marko" Subject: Re: [PATCH v2 1/3] nvmem: core: introduce cells parser Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Sep 2021, at 13:40, Srinivas Kandagatla wrote: > On 20/09/2021 14:29, Vadym Kochan wrote: >> >> Srinivas Kandagatla writes: >> >>> On 20/09/2021 13:29, Vadym Kochan wrote: >>>> >>>> Srinivas Kandagatla 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