diff mbox series

[u-boot-mvebu,v3,07/18] arm: mvebu: turris_omnia: Disable Atmel SHA node if not present

Message ID 20240327162355.24584-8-kabel@kernel.org
State Superseded
Delegated to: Stefan Roese
Headers show
Series Turris Omnia - New board revision support | expand

Commit Message

Marek Behún March 27, 2024, 4:23 p.m. UTC
If the FEAT_CRYPTO feature bit is present in MCU features, the board
crypto is implemented by MCU and the Atmel SHA chip is not present.
Disable Atmel SHA device-tree node in that case.

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Stefan Roese March 28, 2024, 9:56 a.m. UTC | #1
On 3/27/24 17:23, Marek Behún wrote:
> If the FEAT_CRYPTO feature bit is present in MCU features, the board
> crypto is implemented by MCU and the Atmel SHA chip is not present.
> Disable Atmel SHA device-tree node in that case.
> 
> Signed-off-by: Marek Behún <kabel@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_omnia/turris_omnia.c | 23 +++++++++++++++++++++++
>   1 file changed, 23 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index b2f0088e5e..3b7a71bdad 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -1007,6 +1007,25 @@ static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
>   	return 0;
>   }
>   
> +static void fixup_atsha_node(void *blob)
> +{
> +	int node;
> +
> +	if (!omnia_mcu_has_feature(FEAT_CRYPTO))
> +		return;
> +
> +	node = fdt_node_offset_by_compatible(blob, -1, "atmel,atsha204a");
> +	if (node < 0) {
> +		printf("Cannot find ATSHA204A node!\n");
> +		return;
> +	}
> +
> +	if (fdt_status_disabled(blob, node) < 0)
> +		printf("Cannot disable ATSHA204A node!\n");
> +	else
> +		debug("Disabled ATSHA204A node\n");
> +}
> +
>   #endif
>   
>   #if IS_ENABLED(CONFIG_OF_BOARD_FIXUP)
> @@ -1020,6 +1039,8 @@ int board_fix_fdt(void *blob)
>   	fixup_msata_port_nodes(blob);
>   	fixup_wwan_port_nodes(blob);
>   
> +	fixup_atsha_node(blob);
> +
>   	return 0;
>   }
>   #endif
> @@ -1211,6 +1232,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
>   	fixup_msata_port_nodes(blob);
>   	fixup_wwan_port_nodes(blob);
>   
> +	fixup_atsha_node(blob);
> +
>   	return 0;
>   }
>   #endif

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index b2f0088e5e..3b7a71bdad 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -1007,6 +1007,25 @@  static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
 	return 0;
 }
 
+static void fixup_atsha_node(void *blob)
+{
+	int node;
+
+	if (!omnia_mcu_has_feature(FEAT_CRYPTO))
+		return;
+
+	node = fdt_node_offset_by_compatible(blob, -1, "atmel,atsha204a");
+	if (node < 0) {
+		printf("Cannot find ATSHA204A node!\n");
+		return;
+	}
+
+	if (fdt_status_disabled(blob, node) < 0)
+		printf("Cannot disable ATSHA204A node!\n");
+	else
+		debug("Disabled ATSHA204A node\n");
+}
+
 #endif
 
 #if IS_ENABLED(CONFIG_OF_BOARD_FIXUP)
@@ -1020,6 +1039,8 @@  int board_fix_fdt(void *blob)
 	fixup_msata_port_nodes(blob);
 	fixup_wwan_port_nodes(blob);
 
+	fixup_atsha_node(blob);
+
 	return 0;
 }
 #endif
@@ -1211,6 +1232,8 @@  int ft_board_setup(void *blob, struct bd_info *bd)
 	fixup_msata_port_nodes(blob);
 	fixup_wwan_port_nodes(blob);
 
+	fixup_atsha_node(blob);
+
 	return 0;
 }
 #endif