mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW
@ 2024-03-18  9:45 Oleksij Rempel
  2024-03-18  9:45 ` [PATCH v1 2/2] ARM: i.MX8MP: skov: add new bd500 variant support Oleksij Rempel
  2024-03-18 12:39 ` [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Oleksij Rempel @ 2024-03-18  9:45 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Add fallback support for currently not supported HW. Instead of
completely fail, it is better to use some kind of basic devicetree with
reduced functionality.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx8mp/board.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boards/skov-imx8mp/board.c b/arch/arm/boards/skov-imx8mp/board.c
index 5424c3b9ab..a45fe8517f 100644
--- a/arch/arm/boards/skov-imx8mp/board.c
+++ b/arch/arm/boards/skov-imx8mp/board.c
@@ -83,6 +83,12 @@ static const struct board_description imx8mp_variants[] = {
 		.dts_compatible_hdmi = "skov,imx8mp-skov-revb-hdmi",
 		.flags = SKOV_IMX8MP_HAS_HDMI,
 	},
+	/* Keep this entry always on the last place. It will be used
+	 * as fallback variant if not supported variant is detected.
+	 */
+	{
+		.dts_compatible = "skov,imx8mp-skov-basic",
+	},
 };
 
 static int skov_imx8mp_fixup(struct device_node *root, void *data)
@@ -168,13 +174,14 @@ static int skov_imx8mp_init_variant(struct skov_imx8mp_priv *priv)
 	if (ret)
 		return ret;
 
-	priv->variant_id = v;
 
 	if (v >= ARRAY_SIZE(imx8mp_variants)) {
-		dev_err(dev, "Invalid variant %u\n", v);
-		return -EINVAL;
+		dev_warn(dev, "Unsuported variant %u. Fall back to basic variant\n", v);
+		v = ARRAY_SIZE(imx8mp_variants) - 1;
 	}
 
+	priv->variant_id = v;
+
 	variant = &imx8mp_variants[v];
 
 	if (variant->flags & SKOV_IMX8MP_HAS_HDMI) {
-- 
2.39.2




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

* [PATCH v1 2/2] ARM: i.MX8MP: skov: add new bd500 variant support
  2024-03-18  9:45 [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW Oleksij Rempel
@ 2024-03-18  9:45 ` Oleksij Rempel
  2024-03-18 12:39 ` [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Oleksij Rempel @ 2024-03-18  9:45 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Add bd500 board variant.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx8mp/board.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boards/skov-imx8mp/board.c b/arch/arm/boards/skov-imx8mp/board.c
index a45fe8517f..b4dd83a8cf 100644
--- a/arch/arm/boards/skov-imx8mp/board.c
+++ b/arch/arm/boards/skov-imx8mp/board.c
@@ -83,6 +83,9 @@ static const struct board_description imx8mp_variants[] = {
 		.dts_compatible_hdmi = "skov,imx8mp-skov-revb-hdmi",
 		.flags = SKOV_IMX8MP_HAS_HDMI,
 	},
+	[2] = {
+		.dts_compatible = "skov,imx8mp-skov-revc-bd500",
+	},
 	/* Keep this entry always on the last place. It will be used
 	 * as fallback variant if not supported variant is detected.
 	 */
-- 
2.39.2




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

* Re: [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW
  2024-03-18  9:45 [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW Oleksij Rempel
  2024-03-18  9:45 ` [PATCH v1 2/2] ARM: i.MX8MP: skov: add new bd500 variant support Oleksij Rempel
@ 2024-03-18 12:39 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-03-18 12:39 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Mon, Mar 18, 2024 at 10:45:32AM +0100, Oleksij Rempel wrote:
> Add fallback support for currently not supported HW. Instead of
> completely fail, it is better to use some kind of basic devicetree with
> reduced functionality.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  arch/arm/boards/skov-imx8mp/board.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boards/skov-imx8mp/board.c b/arch/arm/boards/skov-imx8mp/board.c
> index 5424c3b9ab..a45fe8517f 100644
> --- a/arch/arm/boards/skov-imx8mp/board.c
> +++ b/arch/arm/boards/skov-imx8mp/board.c
> @@ -83,6 +83,12 @@ static const struct board_description imx8mp_variants[] = {
>  		.dts_compatible_hdmi = "skov,imx8mp-skov-revb-hdmi",
>  		.flags = SKOV_IMX8MP_HAS_HDMI,
>  	},
> +	/* Keep this entry always on the last place. It will be used
> +	 * as fallback variant if not supported variant is detected.
> +	 */
> +	{
> +		.dts_compatible = "skov,imx8mp-skov-basic",
> +	},

This increases ARRAY_SIZE(imx8mp_variants) to 3...
>  };
>  
>  static int skov_imx8mp_fixup(struct device_node *root, void *data)
> @@ -168,13 +174,14 @@ static int skov_imx8mp_init_variant(struct skov_imx8mp_priv *priv)
>  	if (ret)
>  		return ret;
>  
> -	priv->variant_id = v;
>  
>  	if (v >= ARRAY_SIZE(imx8mp_variants)) {

... so this doesn't trigger anymore for the still invalid variant 2.

Better make the basic variant a separate initializer outside of the
imx8mp_variants array. That also gets you rid of the "keep last" comment
above.

variant_id is written to the /chosen/skov,imx8mp-board-version property.
This looks wrong for the "basic" variant as this is not a fixed number
but instead depends on the highest number the bootloader knows (which
might be different from the last variant_id userspace knows).

> -		dev_err(dev, "Invalid variant %u\n", v);
> -		return -EINVAL;
> +		dev_warn(dev, "Unsuported variant %u. Fall back to basic variant\n", v);
> +		v = ARRAY_SIZE(imx8mp_variants) - 1;
>  	}

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] 3+ messages in thread

end of thread, other threads:[~2024-03-18 12:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18  9:45 [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW Oleksij Rempel
2024-03-18  9:45 ` [PATCH v1 2/2] ARM: i.MX8MP: skov: add new bd500 variant support Oleksij Rempel
2024-03-18 12:39 ` [PATCH v1 1/2] ARM: i.MX8MP: skov: add fallback for unsupported HW Sascha Hauer

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