From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D86D0C433F5 for ; Thu, 12 May 2022 07:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xSdaeUFPJ4iTjFMgrelw3UQyAebvgweOLtv/UaBL77E=; b=SZRHsfB81Z1bjL zZKbTOf6gprkV0P/MEQjyCgKxROP/3C1igPMR9fXL1qD7dJGTusfbTH9TxAehJ4QaUDoq28t3umvU /tIQn+TKo0FbaXxf8WIXPwLdyc1oMTEFtiUzRiA4rVHGlhg/gMDmgRIzRl5X+ZWTMs5ppb3jLCV56 PQPLUja2jm8XwRLX23hZHRZFD+7KYCdiEVMVHo/a70F4ESR6LJJE9Aby26OJ8ye062qsf+AGx7sz0 eUHx9wGHxucqv2Hfo2uMCLjNX5Pdy+6yQk04mLaSwhlOetmKLWvSnV+z/iKDGpSMjjkanosihXXoM brVI594+GfU4QQMV4ztQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1np3eI-00ApZh-5l; Thu, 12 May 2022 07:54:14 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1np3eF-00ApYz-Bs for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2022 07:54:12 +0000 Received: by mail-ej1-x62b.google.com with SMTP id n10so8541976ejk.5 for ; Thu, 12 May 2022 00:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=xHJnnT01z1m5/aS07o3xcwpyjm9ng8j7p+h8cghz0mg=; b=A/SBKtUr3KfywtKWmieS20zAHGuZFnDIpJbiOl8aFAoL4TK0+DjjJ2fxYk1rGmB6ZK ub1rbkQft+iCWKy4ygN/kwmCKlgGIp5Ks4CVAzNf6gtgDd7Ih4oRrpeSlVnqPsvRLO0/ Uy24pj8IOZ4lIMr1FQzTcBQJtndvDBSpYU1bvfmbNZxpFFC3/gGwIquh1qGTgEf8CQtj duWUm4a2OBbc8pPMC5ViPPghhWvDNAr1FkMoO5+yTnCjzbD/nRv2cKEGR8OBfm0Bf0kh M3op9yni3ODEvrTX14yYbJQjoyy7G0FFHNakiO2K9pEkTJjIIHuz3HzfMV0vgVRzpyQn wtFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=xHJnnT01z1m5/aS07o3xcwpyjm9ng8j7p+h8cghz0mg=; b=LVoa/YwEV+hDETDH9LC6THqSOGMqiZNgaRjSF6s8X9cVuAG+wkUodYzqAGHFvJ6Epy fW2RjCJ4U+t8MsL4YFv1pH2+SS/07e3Xdl8X7gNpFA8pCqh5DTcy/Pt2pvLgIujwY5i/ 6sIugMsvd6DwmpAEgY9hZaJ135uCJfVrUgqcFwEswimGqpMONeQZD07gIM6PdesEE1gK 0cl78X0KwH01pfLJgwU4x2mFdA4E/A76b8KF+PbVflvRUBssz1njDaD6UqxiTIV06OF9 QC6VzKtC7qVR845XH7cu3KDKpPf8Nq6wArr5v9D08a+crxQ7KyF+heuEbJB88YygqGtG ptRA== X-Gm-Message-State: AOAM530y8uNjrfyzQJ0m0wHF4vMr6c8gD5qO4ZBBWay2cHzCAu/evaWV AdOE5RDvzUQrk7sCiWZUipXkLQ== X-Google-Smtp-Source: ABdhPJxoSxUbbatzMqng37xCHJror9sIbQPy+9nCPXyfbJ+QGbiKsRtJNf0mmfRO7Uf5x69zPreAnw== X-Received: by 2002:a17:907:3f26:b0:6f4:dc59:3cfe with SMTP id hq38-20020a1709073f2600b006f4dc593cfemr28828663ejc.528.1652342045468; Thu, 12 May 2022 00:54:05 -0700 (PDT) Received: from [192.168.0.156] (xdsl-188-155-176-92.adslplus.ch. [188.155.176.92]) by smtp.gmail.com with ESMTPSA id j29-20020a508a9d000000b0042617ba63d1sm2205862edj.91.2022.05.12.00.54.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 May 2022 00:54:05 -0700 (PDT) Message-ID: Date: Thu, 12 May 2022 09:54:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 1/2] dt-bindings: microchip-otpc: document Microchip OTPC Content-Language: en-US To: Claudiu.Beznea@microchip.com, srinivas.kandagatla@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220510094457.4070764-1-claudiu.beznea@microchip.com> <20220510094457.4070764-2-claudiu.beznea@microchip.com> <75ce6291-77c7-c932-e8bb-a8bbae02431d@linaro.org> From: Krzysztof Kozlowski In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220512_005411_433744_7800CAFC X-CRM114-Status: GOOD ( 32.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12/05/2022 09:17, Claudiu.Beznea@microchip.com wrote: >> >>> + >>> +#ifndef _DT_BINDINGS_NVMEM_MICROCHIP_OTPC_H >>> +#define _DT_BINDINGS_NVMEM_MICROCHIP_OTPC_H >>> + >>> +/* >>> + * Need to have it as a multiple of 4 as NVMEM memory is registered with >>> + * stride = 4. >>> + */ >>> +#define OTP_PKT(id) ((id) * 4) >> >> Do I get it correctly - the offset or register address is now part of a >> binding? You write here "id", however you use it as part of "reg", so >> it's confusing. > > I agree that reg should describe the offset in OTP memory and its the > length for a cell. > > However this OTP memory is organized into packets (this is how hardware is > designed), the 1st one being the boot configuration packet, the 2nd one > being temperature calibration data. At the moment Microchip provides only > these 2 packets in OTP memory. Boot configuration packet may vary in length > thus it may change the offset the temperature calibration packet resides > to. If this happen and we use offset based addressing in device trees then > the solution will not work all the time. > > OTP hardware is designed to work with packets. For a packet being in memory > at offset 0x0E as follows: > > offset OTP Memory layout > > . . > . ... . > . . > 0x0E +-----------+ <--- packet X > | header X | > 0x12 +-----------+ > | payload X | > 0x16 | | > | | > 0x1A | | > +-----------+ > . . > . ... . > . . > > requesting from software data at address 0x16 (through OTP control > registers) will return the whole packet starting at offset 0x0E. Same > things happens when requesting data at offset 0x0E, 0x12, 0x1A. > > Thus, as underlying hardware returns to software chunks of 4 bytes though > data registers the driver has been registered with stride = 4. The > OTP_PKT() macro expects packet identifier (starting from 0), multiplies it > by 4 to be able to pass the NVMEM subsystem accordingly, then the driver > which manages a list of the available packets divides this value by 4 and > gets the packet ID and the proper offset in memory for the requested packet ID. > > The intention was to have the OTP_PKT() macro here to be used in device > trees for simpler way of describing different cells in this OTP memory. > Also, using OTP_PKT() abstraction looked to me closer to the reality > (although the computed value is not reflecting this, it is only an > abstraction to be able to pass the NVMEM subsystem). > > Would you prefer to have raw values instead of using this macro? Macro is a nice idea if it can be stable. I understood that length of packets depends on hardware, so this part could be stable. But what about number of packets, so the OTP_PKT_SAMA7G5_TEMP_CALIB_LEN below? You wrote "Boot configuration packet may vary in length", so it could be changed by Microchip? Once this value is stored in the bindings, it is not supposed to change. > > Adapting the subsystem for this kind of devices is also an option if > Srinivas thinks like this. > >> >>> + >>> +/* >>> + * Temperature calibration packet length for SAMA7G5: 1 words header, >>> + * 18 words payload. >>> + */ >>> +#define OTP_PKT_SAMA7G5_TEMP_CALIB_LEN (19 * 4) >> >> Length of some memory region also does not look like job for bindings. > > I added it here to be able to have the same macro in DT and consumer > drivers taking as example iio drivers that uses this approach to describe > IIO channel identifiers. I can remove it and use necessary macros in the > consumer drivers, if it's better this way. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel