[PATCH 2/3] nvmem: Add read-only SpacemiT K3 eFuse support

Jiayu Du duge1256 at gmail.com
Fri Nov 13 05:49:04 PST 2026


On Fri, Nov 06, 2026 at 12:15:54PM +0000, Troy Mitchell wrote:
> On Fri, 6 Nov 2026 14:05:24 +0800, Jiayu Du wrote:
> > Add read-only NVMEM access to bank 0 and bank 7 of the SpacemiT K3
> > eFuse controller. These banks contain temperature calibration
> > parameters and other configuration data.
> The rest of the window holds the root key and the SSK, which is why
> only these two banks are exposed. Please say so here and in a comment
> above k3_efuse_keepouts.

I will add this explanation to the commit message and above
k3_efuse_keepouts.

> 
> > Snapshot the shadow registers with aligned 32-bit reads and expose the
> > data in little-endian order at controller-relative offsets. Serve
> > reads from the snapshot and use keepouts for the remaining register
> > ranges. Keep the AES_WTM clock enabled and its shared reset deasserted
> > while the provider is registered.
> Why keep the clock on? Reads are served from the snapshot and nothing
> touches the hardware after probe.
> 
> Tested on CoM260:
> - clock on only around the snapshot: probe and unbind/bind work, the
>   clock stays off (AES_CLK_RES_CTRL 0x00c30050), same bank 0/7 data.
> - this patch: unbind gates the clock and asserts the reset
>   (0x00c30070 -> 0x00c30040), rebind reads the same data.
> - this patch: 3s of WTM_RST or of clock gating leaves the shadow
>   values and FUSE_READY unchanged.

I will disable the clock after taking the snapshot, before registering
NVMEM. It only needs to be enabled while accessing the hardware in probe.

> 
> [...]
> >
> > +	depends on COMMON_CLK && RESET_CONTROLLER
> Not needed, both APIs have stubs.

I will remove these dependencies.

> 
> [...]
> >
> > +#define K3_EFUSE_REG_SIZE		0x400
> > +#define K3_EFUSE_BANK_SIZE		0x20
> > +#define K3_EFUSE_BANK0_OFFSET	0x104
> > +#define K3_EFUSE_BANK7_OFFSET	0x190
> Nit: the last two are not aligned with the others.

I will align them with the other definitions.

> 
> [...]
> >
> > +	if (resource_size(res) != K3_EFUSE_REG_SIZE ||
> > +	    res->start % sizeof(u32))
> No need to validate DT here. Drop it and use
> devm_platform_ioremap_resource().

I will drop the resource checks and use devm_platform_ioremap_resource().

> 
> [...]
> >
> > +	reset = devm_reset_control_get_shared_deasserted(dev, NULL);
> This asserts the reset on unbind, rmmod and probe failure. The fuse
> data survives, but WTM_RST resets the whole GEU (FUSE_SCLK_DIV_CNTR
> went back to its boot value). The driver does not need the block after
> the snapshot, so use devm_reset_control_get_shared() and only
> deassert it.

I will use devm_reset_control_get_shared() followed by an explicit
reset_control_deassert(), leaving the shared reset deasserted on teardown.

> 
> [...]
> >
> > +		for (i = 0; i < K3_EFUSE_BANK_SIZE; i += sizeof(u32)) {
> [...]
> > +			put_unaligned_le32(val, efuse->data[bank] + i);
> Please poll FUSE_READY (GEU_FUSE_STATUS bit 1, offset 0x184) before
> taking the snapshot, and fail the probe if it never sets.

As you clarified, the automatic shadow load at power-on does not set
FUSE_READY; it is only set after a software-triggered reload. I will
trigger a reload through GEU_CONFIG bit 22 before polling READY, and
fail probe if the poll times out.

I tested this sequence on my COM260 Kit: probe succeeds and both banks
match the data read with v1.

Thanks,
Jiayu Du





More information about the linux-riscv mailing list