mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] HAB: i.MX8M: fix fuse location
@ 2023-10-02  9:20 Ahmad Fatoum
  2023-10-02  9:20 ` [PATCH 1/2] ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M Ahmad Fatoum
  2023-10-02  9:20 ` [PATCH 2/2] HAB: extend fuse information with i.MX8M Ahmad Fatoum
  0 siblings, 2 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2023-10-02  9:20 UTC (permalink / raw)
  To: barebox

Fuse location for i.MX8M differs from i.MX6, which is fixed by this
series.

Tested on i.MX8MM. The rest of the patches for HAB on i.MX8MM are yet to
follow.

Rouven Czerwinski (2):
  ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M
  HAB: extend fuse information with i.MX8M

 drivers/hab/hab.c                | 32 +++++++++++++++++++++++++++-----
 include/mach/imx/ocotp-fusemap.h |  4 ++++
 2 files changed, 31 insertions(+), 5 deletions(-)

-- 
2.39.2




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

* [PATCH 1/2] ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M
  2023-10-02  9:20 [PATCH 0/2] HAB: i.MX8M: fix fuse location Ahmad Fatoum
@ 2023-10-02  9:20 ` Ahmad Fatoum
  2023-10-04  7:42   ` Sascha Hauer
  2023-10-02  9:20 ` [PATCH 2/2] HAB: extend fuse information with i.MX8M Ahmad Fatoum
  1 sibling, 1 reply; 6+ messages in thread
From: Ahmad Fatoum @ 2023-10-02  9:20 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Rouven Czerwinski <r.czerwinski@pengutronix.de>

For i.MX8M devices, the security config 1 fuse was moved to 0x470[25].
Additionally, all devices except the i.MX8MQ have the DIR_BT_DIS fused
within the factory, see [1].

[1]: https://community.nxp.com/t5/i-MX-Processors/DIR-BT-DIS-and-others/m-p/1220615/highlight/true#M168363

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/mach/imx/ocotp-fusemap.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/mach/imx/ocotp-fusemap.h b/include/mach/imx/ocotp-fusemap.h
index 6ba794c16619..02ac5d8e73bb 100644
--- a/include/mach/imx/ocotp-fusemap.h
+++ b/include/mach/imx/ocotp-fusemap.h
@@ -53,5 +53,9 @@
 #define OCOTP_GP1			(OCOTP_WORD(0x660) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
 #define OCOTP_GP2			(OCOTP_WORD(0x670) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
 #define OCOTP_PAD_SETTINGS		(OCOTP_WORD(0x6d0) | OCOTP_BIT(0) | OCOTP_WIDTH(6))
+/* i.MX8M moved the security related fuses */
+#define MX8M_OCOTP_SEC_CONFIG_1		(OCOTP_WORD(0x470) | OCOTP_BIT(25) | OCOTP_WIDTH(1))
+/* Only MX8MQ requires fusing of DIR_BT_DIS */
+#define MX8MQ_OCOTP_DIR_BT_DIS		(OCOTP_WORD(0x470) | OCOTP_BIT(27) | OCOTP_WIDTH(1))
 
 #endif /* __MACH_IMX_OCOTP_FUSEMAP_H */
-- 
2.39.2




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

* [PATCH 2/2] HAB: extend fuse information with i.MX8M
  2023-10-02  9:20 [PATCH 0/2] HAB: i.MX8M: fix fuse location Ahmad Fatoum
  2023-10-02  9:20 ` [PATCH 1/2] ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M Ahmad Fatoum
@ 2023-10-02  9:20 ` Ahmad Fatoum
  2023-10-04  4:56   ` Marco Felsch
  2023-10-04  7:35   ` Sascha Hauer
  1 sibling, 2 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2023-10-02  9:20 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Rouven Czerwinski <r.czerwinski@pengutronix.de>

The i.MX8M family of processors moved the SEC_CONFIG_1 fuse to a
different location. Extend the hab driver with the new location and take
care of the DIR_BT_DIS fuse which only needs to be burned on i.MX8MQ.

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/hab/hab.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/hab/hab.c b/drivers/hab/hab.c
index aa848979b467..ee402352f243 100644
--- a/drivers/hab/hab.c
+++ b/drivers/hab/hab.c
@@ -150,23 +150,45 @@ static int imx_hab_permanent_write_enable_ocotp(int enable)
 	return imx_ocotp_permanent_write(enable);
 }
 
+static uint32_t get_sec_config_fuse(void) {
+	if (cpu_is_mx6()) {
+		return OCOTP_SEC_CONFIG_1;
+	} else {
+		return MX8M_OCOTP_SEC_CONFIG_1;
+	}
+}
+
 static int imx_hab_lockdown_device_ocotp(void)
 {
 	int ret;
+	uint32_t dis_fuse;
+	uint32_t sec_fuse;
 
-	ret = imx_ocotp_write_field(OCOTP_DIR_BT_DIS, 1);
-	if (ret < 0)
-		return ret;
+	if (cpu_is_mx6() || cpu_is_mx8mq()) {
+		if (cpu_is_mx6()) {
+			dis_fuse = OCOTP_DIR_BT_DIS;
+		} else {
+			dis_fuse = MX8MQ_OCOTP_DIR_BT_DIS;
+		}
+		ret = imx_ocotp_write_field(dis_fuse, 1);
+		if (ret < 0)
+			return ret;
+	}
 
-	return imx_ocotp_write_field(OCOTP_SEC_CONFIG_1, 1);
+	sec_fuse = get_sec_config_fuse();
+
+	return imx_ocotp_write_field(sec_fuse, 1);
 }
 
 static int imx_hab_device_locked_down_ocotp(void)
 {
 	int ret;
+	uint32_t fuse;
 	unsigned int v;
 
-	ret = imx_ocotp_read_field(OCOTP_SEC_CONFIG_1, &v);
+	fuse = get_sec_config_fuse();
+
+	ret = imx_ocotp_read_field(fuse, &v);
 	if (ret < 0)
 		return ret;
 
-- 
2.39.2




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

* Re: [PATCH 2/2] HAB: extend fuse information with i.MX8M
  2023-10-02  9:20 ` [PATCH 2/2] HAB: extend fuse information with i.MX8M Ahmad Fatoum
@ 2023-10-04  4:56   ` Marco Felsch
  2023-10-04  7:35   ` Sascha Hauer
  1 sibling, 0 replies; 6+ messages in thread
From: Marco Felsch @ 2023-10-04  4:56 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

Hi Ahmad,

On 23-10-02, Ahmad Fatoum wrote:
> From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> 
> The i.MX8M family of processors moved the SEC_CONFIG_1 fuse to a
> different location. Extend the hab driver with the new location and take
> care of the DIR_BT_DIS fuse which only needs to be burned on i.MX8MQ.
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/hab/hab.c | 32 +++++++++++++++++++++++++++-----
>  1 file changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hab/hab.c b/drivers/hab/hab.c
> index aa848979b467..ee402352f243 100644
> --- a/drivers/hab/hab.c
> +++ b/drivers/hab/hab.c
> @@ -150,23 +150,45 @@ static int imx_hab_permanent_write_enable_ocotp(int enable)
>  	return imx_ocotp_permanent_write(enable);
>  }
>  
> +static uint32_t get_sec_config_fuse(void) {
> +	if (cpu_is_mx6()) {
> +		return OCOTP_SEC_CONFIG_1;
> +	} else {
> +		return MX8M_OCOTP_SEC_CONFIG_1;
> +	}

Small nit: remove the {} from the one-liner if-else, same...
         
> +}
> +
>  static int imx_hab_lockdown_device_ocotp(void)
>  {
>  	int ret;
> +	uint32_t dis_fuse;
> +	uint32_t sec_fuse;
>  
> -	ret = imx_ocotp_write_field(OCOTP_DIR_BT_DIS, 1);
> -	if (ret < 0)
> -		return ret;
> +	if (cpu_is_mx6() || cpu_is_mx8mq()) {
> +		if (cpu_is_mx6()) {
> +			dis_fuse = OCOTP_DIR_BT_DIS;
> +		} else {
> +			dis_fuse = MX8MQ_OCOTP_DIR_BT_DIS;
> +		}

here.

Regards,
  Marco

> +		ret = imx_ocotp_write_field(dis_fuse, 1);
> +		if (ret < 0)
> +			return ret;
> +	}
>  
> -	return imx_ocotp_write_field(OCOTP_SEC_CONFIG_1, 1);
> +	sec_fuse = get_sec_config_fuse();
> +
> +	return imx_ocotp_write_field(sec_fuse, 1);
>  }
>  
>  static int imx_hab_device_locked_down_ocotp(void)
>  {
>  	int ret;
> +	uint32_t fuse;
>  	unsigned int v;
>  
> -	ret = imx_ocotp_read_field(OCOTP_SEC_CONFIG_1, &v);
> +	fuse = get_sec_config_fuse();
> +
> +	ret = imx_ocotp_read_field(fuse, &v);
>  	if (ret < 0)
>  		return ret;
>  
> -- 
> 2.39.2
> 
> 
> 



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

* Re: [PATCH 2/2] HAB: extend fuse information with i.MX8M
  2023-10-02  9:20 ` [PATCH 2/2] HAB: extend fuse information with i.MX8M Ahmad Fatoum
  2023-10-04  4:56   ` Marco Felsch
@ 2023-10-04  7:35   ` Sascha Hauer
  1 sibling, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-10-04  7:35 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Oct 02, 2023 at 11:20:43AM +0200, Ahmad Fatoum wrote:
> From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> 
> The i.MX8M family of processors moved the SEC_CONFIG_1 fuse to a
> different location. Extend the hab driver with the new location and take
> care of the DIR_BT_DIS fuse which only needs to be burned on i.MX8MQ.
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/hab/hab.c | 32 +++++++++++++++++++++++++++-----
>  1 file changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hab/hab.c b/drivers/hab/hab.c
> index aa848979b467..ee402352f243 100644
> --- a/drivers/hab/hab.c
> +++ b/drivers/hab/hab.c
> @@ -150,23 +150,45 @@ static int imx_hab_permanent_write_enable_ocotp(int enable)
>  	return imx_ocotp_permanent_write(enable);
>  }
>  
> +static uint32_t get_sec_config_fuse(void) {

The opening brace should be on the next line.

> +	if (cpu_is_mx6()) {
> +		return OCOTP_SEC_CONFIG_1;
> +	} else {
> +		return MX8M_OCOTP_SEC_CONFIG_1;
> +	}
> +}

Given that the i.MX8M defines have a SoC prefix I would find it more
natural to test with if (cpu_is_mx8m()) instead of if (cpu_is_mx6()).

> +
>  static int imx_hab_lockdown_device_ocotp(void)
>  {
>  	int ret;
> +	uint32_t dis_fuse;
> +	uint32_t sec_fuse;
>  
> -	ret = imx_ocotp_write_field(OCOTP_DIR_BT_DIS, 1);
> -	if (ret < 0)
> -		return ret;
> +	if (cpu_is_mx6() || cpu_is_mx8mq()) {

Right now we only support i.MX6 and i.MX8MQ, so this is always true.

Have you considered creating a i.MX8MQ and a i.MX6 specific struct
imx_hab_ops {} entry? Given the amount of if(cpu_is_*()) expressions the
result may look cleaner.

BTW struct imx_hab_ops has a init() function pointer which seems unused.
Could you remove it along the way?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH 1/2] ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M
  2023-10-02  9:20 ` [PATCH 1/2] ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M Ahmad Fatoum
@ 2023-10-04  7:42   ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-10-04  7:42 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Oct 02, 2023 at 11:20:42AM +0200, Ahmad Fatoum wrote:
> From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> 
> For i.MX8M devices, the security config 1 fuse was moved to 0x470[25].
> Additionally, all devices except the i.MX8MQ have the DIR_BT_DIS fused
> within the factory, see [1].
> 
> [1]: https://community.nxp.com/t5/i-MX-Processors/DIR-BT-DIS-and-others/m-p/1220615/highlight/true#M168363
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  include/mach/imx/ocotp-fusemap.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/mach/imx/ocotp-fusemap.h b/include/mach/imx/ocotp-fusemap.h
> index 6ba794c16619..02ac5d8e73bb 100644
> --- a/include/mach/imx/ocotp-fusemap.h
> +++ b/include/mach/imx/ocotp-fusemap.h
> @@ -53,5 +53,9 @@
>  #define OCOTP_GP1			(OCOTP_WORD(0x660) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
>  #define OCOTP_GP2			(OCOTP_WORD(0x670) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
>  #define OCOTP_PAD_SETTINGS		(OCOTP_WORD(0x6d0) | OCOTP_BIT(0) | OCOTP_WIDTH(6))
> +/* i.MX8M moved the security related fuses */
> +#define MX8M_OCOTP_SEC_CONFIG_1		(OCOTP_WORD(0x470) | OCOTP_BIT(25) | OCOTP_WIDTH(1))
> +/* Only MX8MQ requires fusing of DIR_BT_DIS */
> +#define MX8MQ_OCOTP_DIR_BT_DIS		(OCOTP_WORD(0x470) | OCOTP_BIT(27) | OCOTP_WIDTH(1))

You can merge this into the patch using the defines.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-10-04  7:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-02  9:20 [PATCH 0/2] HAB: i.MX8M: fix fuse location Ahmad Fatoum
2023-10-02  9:20 ` [PATCH 1/2] ARM: i.MX: fusemap-ocotp: add sec fuses for i.MX8M Ahmad Fatoum
2023-10-04  7:42   ` Sascha Hauer
2023-10-02  9:20 ` [PATCH 2/2] HAB: extend fuse information with i.MX8M Ahmad Fatoum
2023-10-04  4:56   ` Marco Felsch
2023-10-04  7:35   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox