Skip to content

Commit 391b06e

Browse files
saschahauergregkh
authored andcommitted
nvmem: imx-ocotp-ele: fix MAC address byte order
According to the i.MX93 Fusemap the two MAC addresses are stored in words 315 to 317 like this: 315 MAC1_ADDR_31_0[31:0] 316 MAC1_ADDR_47_32[47:32] MAC2_ADDR_15_0[15:0] 317 MAC2_ADDR_47_16[31:0] This means the MAC addresses are stored in reverse byte order. We have to swap the bytes before passing them to the upper layers. The storage format is consistent to the one used on i.MX6 using imx-ocotp driver which does the same byte swapping as introduced here. With this patch the MAC address on my i.MX93 TQ board correctly reads as 00:d0:93:6b:27:b8 instead of b8:27:6b:93:d0:00. Fixes: 22e9e6f ("nvmem: imx: support i.MX93 OCOTP") Signed-off-by: Sascha Hauer <[email protected]> Cc: stable <[email protected]> Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3c9e2cb commit 391b06e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/nvmem/imx-ocotp-ele.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,26 @@ static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, siz
111111
return 0;
112112
};
113113

114+
static int imx_ocotp_cell_pp(void *context, const char *id, int index,
115+
unsigned int offset, void *data, size_t bytes)
116+
{
117+
u8 *buf = data;
118+
int i;
119+
120+
/* Deal with some post processing of nvmem cell data */
121+
if (id && !strcmp(id, "mac-address"))
122+
for (i = 0; i < bytes / 2; i++)
123+
swap(buf[i], buf[bytes - i - 1]);
124+
125+
return 0;
126+
}
127+
128+
static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
129+
struct nvmem_cell_info *cell)
130+
{
131+
cell->read_post_process = imx_ocotp_cell_pp;
132+
}
133+
114134
static int imx_ele_ocotp_probe(struct platform_device *pdev)
115135
{
116136
struct device *dev = &pdev->dev;
@@ -137,6 +157,8 @@ static int imx_ele_ocotp_probe(struct platform_device *pdev)
137157
priv->config.stride = 1;
138158
priv->config.priv = priv;
139159
priv->config.read_only = true;
160+
priv->config.add_legacy_fixed_of_cells = true;
161+
priv->config.fixup_dt_cell_info = imx_ocotp_fixup_dt_cell_info;
140162
mutex_init(&priv->lock);
141163

142164
nvmem = devm_nvmem_register(dev, &priv->config);

0 commit comments

Comments
 (0)