linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmem: imx: scu: correct the fuse word index
@ 2019-12-04  5:52 Peng Fan
  2019-12-05  1:27 ` Andy Duan
  2019-12-19 10:52 ` Srinivas Kandagatla
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2019-12-04  5:52 UTC (permalink / raw)
  To: srinivas.kandagatla, shawnguo, s.hauer
  Cc: kernel, festevam, dl-linux-imx, linux-arm-kernel, linux-kernel,
	Aisheng Dong, Andy Duan, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

i.MX8 fuse word row index represented as one 4-bytes word.
Exp:
- MAC0 address layout in fuse:
offset 708: MAC[3] MAC[2] MAC[1] MAC[0]
offset 709: XX     xx     MAC[5] MAC[4]

The original code takes row index * 4 as the offset, this
not exactly match i.MX8 fuse map documentation.

So update code the reflect the truth.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/nvmem/imx-ocotp-scu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/nvmem/imx-ocotp-scu.c b/drivers/nvmem/imx-ocotp-scu.c
index 455675dd8efe..399e1eb8b4c1 100644
--- a/drivers/nvmem/imx-ocotp-scu.c
+++ b/drivers/nvmem/imx-ocotp-scu.c
@@ -138,8 +138,8 @@ static int imx_scu_ocotp_read(void *context, unsigned int offset,
 	void *p;
 	int i, ret;
 
-	index = offset >> 2;
-	num_bytes = round_up((offset % 4) + bytes, 4);
+	index = offset;
+	num_bytes = round_up(bytes, 4);
 	count = num_bytes >> 2;
 
 	if (count > (priv->data->nregs - index))
@@ -168,7 +168,7 @@ static int imx_scu_ocotp_read(void *context, unsigned int offset,
 		buf++;
 	}
 
-	memcpy(val, (u8 *)p + offset % 4, bytes);
+	memcpy(val, (u8 *)p, bytes);
 
 	mutex_unlock(&scu_ocotp_mutex);
 
@@ -188,10 +188,10 @@ static int imx_scu_ocotp_write(void *context, unsigned int offset,
 	int ret;
 
 	/* allow only writing one complete OTP word at a time */
-	if ((bytes != 4) || (offset % 4))
+	if (bytes != 4)
 		return -EINVAL;
 
-	index = offset >> 2;
+	index = offset;
 
 	if (in_hole(context, index))
 		return -EINVAL;
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] nvmem: imx: scu: correct the fuse word index
  2019-12-04  5:52 [PATCH] nvmem: imx: scu: correct the fuse word index Peng Fan
@ 2019-12-05  1:27 ` Andy Duan
  2019-12-19 10:52 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Duan @ 2019-12-05  1:27 UTC (permalink / raw)
  To: Peng Fan, srinivas.kandagatla, shawnguo, s.hauer
  Cc: kernel, festevam, dl-linux-imx, linux-arm-kernel, linux-kernel,
	Aisheng Dong

From: Peng Fan <peng.fan@nxp.com> Sent: Wednesday, December 4, 2019 1:52 PM
> From: Peng Fan <peng.fan@nxp.com>
> 
> i.MX8 fuse word row index represented as one 4-bytes word.
> Exp:
> - MAC0 address layout in fuse:
> offset 708: MAC[3] MAC[2] MAC[1] MAC[0]
> offset 709: XX     xx     MAC[5] MAC[4]
> 
> The original code takes row index * 4 as the offset, this not exactly match
> i.MX8 fuse map documentation.
> 
> So update code the reflect the truth.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
> ---
>  drivers/nvmem/imx-ocotp-scu.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/nvmem/imx-ocotp-scu.c b/drivers/nvmem/imx-ocotp-scu.c
> index 455675dd8efe..399e1eb8b4c1 100644
> --- a/drivers/nvmem/imx-ocotp-scu.c
> +++ b/drivers/nvmem/imx-ocotp-scu.c
> @@ -138,8 +138,8 @@ static int imx_scu_ocotp_read(void *context,
> unsigned int offset,
>  	void *p;
>  	int i, ret;
> 
> -	index = offset >> 2;
> -	num_bytes = round_up((offset % 4) + bytes, 4);
> +	index = offset;
> +	num_bytes = round_up(bytes, 4);
>  	count = num_bytes >> 2;
> 
>  	if (count > (priv->data->nregs - index)) @@ -168,7 +168,7 @@ static int
> imx_scu_ocotp_read(void *context, unsigned int offset,
>  		buf++;
>  	}
> 
> -	memcpy(val, (u8 *)p + offset % 4, bytes);
> +	memcpy(val, (u8 *)p, bytes);
> 
>  	mutex_unlock(&scu_ocotp_mutex);
> 
> @@ -188,10 +188,10 @@ static int imx_scu_ocotp_write(void *context,
> unsigned int offset,
>  	int ret;
> 
>  	/* allow only writing one complete OTP word at a time */
> -	if ((bytes != 4) || (offset % 4))
> +	if (bytes != 4)
>  		return -EINVAL;
> 
> -	index = offset >> 2;
> +	index = offset;
> 
>  	if (in_hole(context, index))
>  		return -EINVAL;
> --
> 2.16.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmem: imx: scu: correct the fuse word index
  2019-12-04  5:52 [PATCH] nvmem: imx: scu: correct the fuse word index Peng Fan
  2019-12-05  1:27 ` Andy Duan
@ 2019-12-19 10:52 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2019-12-19 10:52 UTC (permalink / raw)
  To: Peng Fan, shawnguo, s.hauer
  Cc: kernel, festevam, dl-linux-imx, linux-arm-kernel, linux-kernel,
	Aisheng Dong, Andy Duan



On 04/12/2019 05:52, Peng Fan wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> i.MX8 fuse word row index represented as one 4-bytes word.
> Exp:
> - MAC0 address layout in fuse:
> offset 708: MAC[3] MAC[2] MAC[1] MAC[0]
> offset 709: XX     xx     MAC[5] MAC[4]
> 
> The original code takes row index * 4 as the offset, this
> not exactly match i.MX8 fuse map documentation.
> 
> So update code the reflect the truth.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>   drivers/nvmem/imx-ocotp-scu.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
Applied Thanks,
srini

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-19 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04  5:52 [PATCH] nvmem: imx: scu: correct the fuse word index Peng Fan
2019-12-05  1:27 ` Andy Duan
2019-12-19 10:52 ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).