All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Varshini Rajendran <varshini.rajendran@microchip.com>
Cc: ehristev@kernel.org, jic23@kernel.org, dlechner@baylibre.com,
	nuno.sa@analog.com, andy@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
	claudiu.beznea@tuxon.dev, srini@kernel.org,
	marcelo.schmitt@analog.com, radu.sabau@analog.com,
	joshua.crofts1@gmail.com, jorge.marques@analog.com,
	Jonathan.Santos@analog.com, jishnu.prakash@oss.qualcomm.com,
	antoniu.miclaus@analog.com, duje@dujemihanovic.xyz,
	mazziesaccount@gmail.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 09/17] nvmem: microchip-otpc: nvmem: microchip-otpc: add tag-based packet lookup
Date: Sat, 8 Aug 2026 23:52:16 +0300	[thread overview]
Message-ID: <aneXAPGifAS2PG9G@ashevche-desk.local> (raw)
In-Reply-To: <20260806074024.531259-10-varshini.rajendran@microchip.com>

On Thu, Aug 06, 2026 at 01:10:16PM +0530, Varshini Rajendran wrote:
> Add support for accessing OTP packets by their tag which is a FourCC
> while preserving backward compatibility with the existing ID-based
> lookup.
> 
> The OTP memory layout can vary across devices and may change over time,
> making the packet ID approach unreliable when the memory map is not
> known in advance. The packet tag provides a reliable way to identify
> and access packets without prior knowledge of the OTP memory layout.
> 
> Two offset encodings are now supported:
>   1. Legacy ID-based: offset = OTP_PKT(id) = id * 4
>      Used in DT as: reg = <OTP_PKT(1) 76>;
>   2. TAG-based: offset = 4-byte ASCII packet tag (FourCC)
>      Used in DT as: reg = <0x41435354 0x4c>; (tag "ACST")
> 
> The driver resolves offsets matching valid legacy selectors (multiples
> of 4 within the packet count) through ID lookup, falling back to tag
> lookup for other valid values. This ensures existing device trees
> continue to work while enabling new tag-based access. During probe,
> packet meta data including the tag is read and cached.
> 
> The stride of the nvmem memory is set to 1 in order to support tag based
> offsets, comment in the header file is updated accordingly.

...

> +static bool mchp_otpc_is_valid_fourcc(u32 tag)
> +{
> +	int i;
> +	u8 c;
> +
> +	for (i = 0; i < 4; i++) {

	for (unsigned int i = 0; i < sizeof(tag); i++) {

> +		c = (tag >> (i * 8)) & 0xff;
> +		if (c < 0x20 || c > 0x7e)
> +			return false;
> +	}
> +
> +	return true;
> +}

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2026-08-08 20:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  7:40 [PATCH v6 00/17] Add thermal management support for sama7d65 Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 01/17] dt-bindings: iio: adc: at91-sama5d2: document sama7d65 Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 02/17] nvmem: add DEFINE_FREE for nvmem_cell_put cleanup Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 03/17] iio: adc: at91-sama5d2_adc: use cleanup.h for NVMEM buffer Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 04/17] iio: adc: at91-sama5d2_adc: rework temp calibration layout handling Varshini Rajendran
2026-08-06  9:07   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 05/17] iio: adc: at91-sama5d2_adc: add condition to validate calibration data Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 06/17] iio: adc: at91-sama5d2_adc: remove unnecessary casts in of_device_id Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 07/17] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65 Varshini Rajendran
2026-08-06  9:09   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 08/17] dt-bindings: nvmem: microchip,sama7g5-otpc: add sama7d65 and dt node example Varshini Rajendran
2026-08-06  9:07   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 09/17] nvmem: microchip-otpc: nvmem: microchip-otpc: add tag-based packet lookup Varshini Rajendran
2026-08-06  9:10   ` sashiko-bot
2026-08-08 20:52   ` Andy Shevchenko [this message]
2026-08-06  7:40 ` [PATCH v6 10/17] nvmem: microchip-otpc: nvmem: add emulation mode and OTP access validation Varshini Rajendran
2026-08-06  9:08   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 11/17] ARM: dts: microchip: sama7d65: add cpu opps Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 12/17] ARM: dts: microchip: sama7d65: Add ADC node Varshini Rajendran
2026-08-06  9:12   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 13/17] ARM: dts: microchip: sama7d65_curiosity: Enable ADC, DVFS Varshini Rajendran
2026-08-06  7:40 ` [PATCH v6 14/17] ARM: dts: microchip: sama7d65: add otpc node Varshini Rajendran
2026-08-06  9:23   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 15/17] ARM: dts: microchip: sama7d65: add cells for temperature calibration Varshini Rajendran
2026-08-06  9:19   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 16/17] ARM: dts: microchip: sama7d65: add temperature sensor Varshini Rajendran
2026-08-06  9:18   ` sashiko-bot
2026-08-06  7:40 ` [PATCH v6 17/17] ARM: dts: microchip: sama7d65: add thermal zones node Varshini Rajendran

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=aneXAPGifAS2PG9G@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Jonathan.Santos@analog.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=duje@dujemihanovic.xyz \
    --cc=ehristev@kernel.org \
    --cc=jic23@kernel.org \
    --cc=jishnu.prakash@oss.qualcomm.com \
    --cc=jorge.marques@analog.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=mazziesaccount@gmail.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=radu.sabau@analog.com \
    --cc=robh@kernel.org \
    --cc=srini@kernel.org \
    --cc=varshini.rajendran@microchip.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.