mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default
@ 2019-12-17 11:18 Lucas Stach
  2019-12-17 11:18 ` [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups Lucas Stach
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Lucas Stach @ 2019-12-17 11:18 UTC (permalink / raw)
  To: barebox

We only have a single update target, so make it the default.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/boards/zii-imx8mq-dev/board.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
index 144adb9cef18..dcf945db495a 100644
--- a/arch/arm/boards/zii-imx8mq-dev/board.c
+++ b/arch/arm/boards/zii-imx8mq-dev/board.c
@@ -19,7 +19,8 @@ static int zii_imx8mq_dev_init(void)
 
 	barebox_set_hostname("imx8mq-zii-rdu3");
 
-	imx8mq_bbu_internal_mmcboot_register_handler("eMMC", "/dev/mmc0", 0);
+	imx8mq_bbu_internal_mmcboot_register_handler("eMMC", "/dev/mmc0",
+						     BBU_HANDLER_FLAG_DEFAULT);
 
 	if (bootsource_get_instance() == 0)
 		of_device_enable_path("/chosen/environment-emmc");
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups
  2019-12-17 11:18 [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Lucas Stach
@ 2019-12-17 11:18 ` Lucas Stach
  2019-12-18 13:54   ` Andrey Smirnov
  2019-12-17 11:18 ` [PATCH 3/3] ARM: zii-imx8mq-dev: fixup touchscreen and ethernet switch alias Lucas Stach
  2019-12-18  7:29 ` [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Sascha Hauer
  2 siblings, 1 reply; 9+ messages in thread
From: Lucas Stach @ 2019-12-17 11:18 UTC (permalink / raw)
  To: barebox

There are only two fixups we need to apply at the moment:
- The 27" RMB3 based unit has a eGalax Touchscreen instead of Synaptics.
- The 10.1" SCU/CCU unit has no DEB and thus no switch, but instead the
  i210 ethernet is routed to the external connector directly.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/boards/zii-imx8mq-dev/board.c | 138 +++++++++++++++++++++++++
 arch/arm/dts/imx8mq-zii-ultra.dtsi     |  10 ++
 2 files changed, 148 insertions(+)

diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
index dcf945db495a..0be68423d9bf 100644
--- a/arch/arm/boards/zii-imx8mq-dev/board.c
+++ b/arch/arm/boards/zii-imx8mq-dev/board.c
@@ -11,6 +11,15 @@
 #include <asm/memory.h>
 #include <linux/sizes.h>
 #include <mach/bbu.h>
+#include "../zii-common/pn-fixup.h"
+
+#define LRU_FLAG_EGALAX		BIT(0)
+#define LRU_FLAG_NO_DEB		BIT(1)
+
+struct zii_imx8mq_dev_lru_fixup {
+	struct zii_pn_fixup fixup;
+	unsigned int flags;
+};
 
 static int zii_imx8mq_dev_init(void)
 {
@@ -32,3 +41,132 @@ static int zii_imx8mq_dev_init(void)
 	return 0;
 }
 device_initcall(zii_imx8mq_dev_init);
+
+static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
+{
+	struct device_node *np;
+
+	/*
+	 * The 27" unit has a EETI eGalax touchscreen instead of the
+	 * Synaptics RMI4 found on other units.
+	 */
+	pr_info("Enabling eGalax touchscreen instead of RMI4\n");
+
+	np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
+	if (!np)
+		return -ENODEV;
+
+	of_device_disable(np);
+
+	np = of_find_compatible_node(root, NULL, "eeti,exc3000");
+	if (!np)
+		return -ENODEV;
+
+	of_device_enable(np);
+
+	return 0;
+}
+
+static int zii_imx8mq_dev_fixup_deb_internal(void)
+{
+	struct device_node *np, *aliases;
+	struct device_d *dev;
+
+	/*
+	 * In the internal DT remove the complete FEC hierarchy and move the
+	 * i210 to be the eth0 interface to allow network boot to work without
+	 * rewriting all the boot scripts.
+	 */
+	aliases = of_find_node_by_path("/aliases");
+	if (!aliases)
+		return -ENODEV;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-fec");
+	if (!np)
+		return -ENODEV;
+
+	of_device_disable(np);
+
+	of_property_write_string(aliases, "ethernet1", np->full_name);
+
+	dev = get_device_by_device_node(np);
+	if (!dev)
+		return -ENODEV;
+
+	unregister_device(dev);
+
+	np = of_find_node_by_name(NULL, "i210@0");
+	if (!np)
+		return -ENODEV;
+
+	of_property_write_string(aliases, "ethernet0", np->full_name);
+
+	/* Refresh the internal aliases list from the patched DT */
+	of_alias_scan();
+
+	return 0;
+}
+
+static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
+{
+	struct device_node *np;
+
+	/*
+	 * In the kernel DT remove all devices from the DEB, which isn't
+	 * present on this system.
+	 */
+	np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
+	if (!np)
+		return -ENODEV;
+
+	of_device_disable(np);
+
+	np = of_find_compatible_node(root, NULL, "zii,rave-wdt");
+	if (!np)
+		return -ENODEV;
+
+	of_device_disable(np);
+
+	return 0;
+}
+
+static void zii_imx8mq_dev_lru_fixup(const struct zii_pn_fixup *context)
+{
+	const struct zii_imx8mq_dev_lru_fixup *fixup =
+		container_of(context, struct zii_imx8mq_dev_lru_fixup, fixup);
+
+	if (fixup->flags & LRU_FLAG_EGALAX)
+		of_register_fixup(zii_imx8mq_dev_fixup_egalax_ts, NULL);
+
+	if (fixup->flags & LRU_FLAG_NO_DEB) {
+		zii_imx8mq_dev_fixup_deb_internal();
+		of_register_fixup(zii_imx8mq_dev_fixup_deb, NULL);
+	}
+}
+
+#define ZII_IMX8MQ_DEV_LRU_FIXUP(__pn, __flags)		\
+	{						\
+		{ __pn, zii_imx8mq_dev_lru_fixup },	\
+		__flags					\
+	}
+
+static const struct zii_imx8mq_dev_lru_fixup zii_imx8mq_dev_lru_fixups[] = {
+	ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-02", LRU_FLAG_EGALAX),
+	ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-03", LRU_FLAG_EGALAX),
+	ZII_IMX8MQ_DEV_LRU_FIXUP("00-5170-01", LRU_FLAG_NO_DEB),
+};
+
+/*
+ * This initcall needs to be executed before coredevices, so we have a chance
+ * to fix up the devices with the correct information.
+ */
+static int zii_imx8mq_dev_process_fixups(void)
+{
+	if (!of_machine_is_compatible("zii,imx8mq-ultra"))
+		return 0;
+
+	zii_process_lru_fixups(zii_imx8mq_dev_lru_fixups);
+
+	return 0;
+}
+postmmu_initcall(zii_imx8mq_dev_process_fixups);
diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
index 6180f21ab0a4..50bad9b1a27e 100644
--- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
+++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
@@ -22,6 +22,11 @@
 		};
 	};
 
+	device-info {
+		nvmem-cells = <&lru_part_number>;
+		nvmem-cell-names = "lru-part-number";
+	};
+
 	aliases {
 		ethernet0 = &fec1;
 		ethernet1 = &i210;
@@ -64,6 +69,11 @@
 &uart2 {
 	rave-sp {
 		eeprom@a4 {
+			lru_part_number: lru-part-number@21 {
+				reg = <0x21 15>;
+				read-only;
+			};
+
 			mac_address_0: mac-address@180 {
 				reg = <0x180 6>;
 			};
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] ARM: zii-imx8mq-dev: fixup touchscreen and ethernet switch alias
  2019-12-17 11:18 [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Lucas Stach
  2019-12-17 11:18 ` [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups Lucas Stach
@ 2019-12-17 11:18 ` Lucas Stach
  2019-12-18  7:29 ` [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Sascha Hauer
  2 siblings, 0 replies; 9+ messages in thread
From: Lucas Stach @ 2019-12-17 11:18 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/boards/zii-imx8mq-dev/board.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
index 0be68423d9bf..76d499a37094 100644
--- a/arch/arm/boards/zii-imx8mq-dev/board.c
+++ b/arch/arm/boards/zii-imx8mq-dev/board.c
@@ -44,7 +44,7 @@ device_initcall(zii_imx8mq_dev_init);
 
 static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
 {
-	struct device_node *np;
+	struct device_node *np, * aliases;
 
 	/*
 	 * The 27" unit has a EETI eGalax touchscreen instead of the
@@ -64,6 +64,12 @@ static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
 
 	of_device_enable(np);
 
+	aliases = of_find_node_by_path_from(root, "/aliases");
+	if (!aliases)
+		return -ENODEV;
+
+	of_property_write_string(aliases, "touchscreen0", np->full_name);
+
 	return 0;
 }
 
@@ -109,7 +115,8 @@ static int zii_imx8mq_dev_fixup_deb_internal(void)
 
 static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
 {
-	struct device_node *np;
+	struct device_node *np, *aliases;
+	struct property *pp;
 
 	/*
 	 * In the kernel DT remove all devices from the DEB, which isn't
@@ -127,6 +134,16 @@ static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
 
 	of_device_disable(np);
 
+	aliases = of_find_node_by_path_from(root, "/aliases");
+	if (!aliases)
+		return -ENODEV;
+
+	pp = of_find_property(aliases, "ethernet-switch0", NULL);
+	if (!pp)
+		return -ENODEV;
+
+	of_delete_property(pp);
+
 	return 0;
 }
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default
  2019-12-17 11:18 [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Lucas Stach
  2019-12-17 11:18 ` [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups Lucas Stach
  2019-12-17 11:18 ` [PATCH 3/3] ARM: zii-imx8mq-dev: fixup touchscreen and ethernet switch alias Lucas Stach
@ 2019-12-18  7:29 ` Sascha Hauer
  2 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2019-12-18  7:29 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Tue, Dec 17, 2019 at 12:18:52PM +0100, Lucas Stach wrote:
> We only have a single update target, so make it the default.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  arch/arm/boards/zii-imx8mq-dev/board.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
> index 144adb9cef18..dcf945db495a 100644
> --- a/arch/arm/boards/zii-imx8mq-dev/board.c
> +++ b/arch/arm/boards/zii-imx8mq-dev/board.c
> @@ -19,7 +19,8 @@ static int zii_imx8mq_dev_init(void)
>  
>  	barebox_set_hostname("imx8mq-zii-rdu3");
>  
> -	imx8mq_bbu_internal_mmcboot_register_handler("eMMC", "/dev/mmc0", 0);
> +	imx8mq_bbu_internal_mmcboot_register_handler("eMMC", "/dev/mmc0",
> +						     BBU_HANDLER_FLAG_DEFAULT);
>  
>  	if (bootsource_get_instance() == 0)
>  		of_device_enable_path("/chosen/environment-emmc");
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups
  2019-12-17 11:18 ` [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups Lucas Stach
@ 2019-12-18 13:54   ` Andrey Smirnov
  2019-12-18 13:56     ` Lucas Stach
  0 siblings, 1 reply; 9+ messages in thread
From: Andrey Smirnov @ 2019-12-18 13:54 UTC (permalink / raw)
  To: Lucas Stach; +Cc: Barebox List

On Tue, Dec 17, 2019 at 3:19 AM Lucas Stach <l.stach@pengutronix.de> wrote:
>
> There are only two fixups we need to apply at the moment:
> - The 27" RMB3 based unit has a eGalax Touchscreen instead of Synaptics.
> - The 10.1" SCU/CCU unit has no DEB and thus no switch, but instead the
>   i210 ethernet is routed to the external connector directly.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  arch/arm/boards/zii-imx8mq-dev/board.c | 138 +++++++++++++++++++++++++
>  arch/arm/dts/imx8mq-zii-ultra.dtsi     |  10 ++
>  2 files changed, 148 insertions(+)
>
> diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
> index dcf945db495a..0be68423d9bf 100644
> --- a/arch/arm/boards/zii-imx8mq-dev/board.c
> +++ b/arch/arm/boards/zii-imx8mq-dev/board.c
> @@ -11,6 +11,15 @@
>  #include <asm/memory.h>
>  #include <linux/sizes.h>
>  #include <mach/bbu.h>
> +#include "../zii-common/pn-fixup.h"
> +
> +#define LRU_FLAG_EGALAX                BIT(0)
> +#define LRU_FLAG_NO_DEB                BIT(1)
> +
> +struct zii_imx8mq_dev_lru_fixup {
> +       struct zii_pn_fixup fixup;
> +       unsigned int flags;
> +};
>
>  static int zii_imx8mq_dev_init(void)
>  {
> @@ -32,3 +41,132 @@ static int zii_imx8mq_dev_init(void)
>         return 0;
>  }
>  device_initcall(zii_imx8mq_dev_init);
> +
> +static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
> +{
> +       struct device_node *np;
> +
> +       /*
> +        * The 27" unit has a EETI eGalax touchscreen instead of the
> +        * Synaptics RMI4 found on other units.
> +        */
> +       pr_info("Enabling eGalax touchscreen instead of RMI4\n");
> +
> +       np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
> +       if (!np)
> +               return -ENODEV;
> +
> +       of_device_disable(np);
> +
> +       np = of_find_compatible_node(root, NULL, "eeti,exc3000");
> +       if (!np)
> +               return -ENODEV;
> +
> +       of_device_enable(np);
> +
> +       return 0;
> +}
> +
> +static int zii_imx8mq_dev_fixup_deb_internal(void)
> +{
> +       struct device_node *np, *aliases;
> +       struct device_d *dev;
> +
> +       /*
> +        * In the internal DT remove the complete FEC hierarchy and move the
> +        * i210 to be the eth0 interface to allow network boot to work without
> +        * rewriting all the boot scripts.
> +        */
> +       aliases = of_find_node_by_path("/aliases");
> +       if (!aliases)
> +               return -ENODEV;
> +
> +       np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-fec");
> +       if (!np)
> +               return -ENODEV;
> +
> +       of_device_disable(np);
> +
> +       of_property_write_string(aliases, "ethernet1", np->full_name);
> +
> +       dev = get_device_by_device_node(np);

The patch adding this function might be missing from the series. Or
did I miss it going in earlier?

> +       if (!dev)
> +               return -ENODEV;
> +
> +       unregister_device(dev);
> +
> +       np = of_find_node_by_name(NULL, "i210@0");
> +       if (!np)
> +               return -ENODEV;
> +
> +       of_property_write_string(aliases, "ethernet0", np->full_name);
> +
> +       /* Refresh the internal aliases list from the patched DT */
> +       of_alias_scan();
> +
> +       return 0;
> +}
> +
> +static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
> +{
> +       struct device_node *np;
> +
> +       /*
> +        * In the kernel DT remove all devices from the DEB, which isn't
> +        * present on this system.
> +        */
> +       np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
> +       if (!np)
> +               return -ENODEV;
> +
> +       of_device_disable(np);
> +
> +       np = of_find_compatible_node(root, NULL, "zii,rave-wdt");
> +       if (!np)
> +               return -ENODEV;
> +
> +       of_device_disable(np);
> +
> +       return 0;
> +}
> +
> +static void zii_imx8mq_dev_lru_fixup(const struct zii_pn_fixup *context)
> +{
> +       const struct zii_imx8mq_dev_lru_fixup *fixup =
> +               container_of(context, struct zii_imx8mq_dev_lru_fixup, fixup);
> +
> +       if (fixup->flags & LRU_FLAG_EGALAX)
> +               of_register_fixup(zii_imx8mq_dev_fixup_egalax_ts, NULL);
> +
> +       if (fixup->flags & LRU_FLAG_NO_DEB) {
> +               zii_imx8mq_dev_fixup_deb_internal();
> +               of_register_fixup(zii_imx8mq_dev_fixup_deb, NULL);
> +       }
> +}
> +
> +#define ZII_IMX8MQ_DEV_LRU_FIXUP(__pn, __flags)                \
> +       {                                               \
> +               { __pn, zii_imx8mq_dev_lru_fixup },     \
> +               __flags                                 \
> +       }
> +
> +static const struct zii_imx8mq_dev_lru_fixup zii_imx8mq_dev_lru_fixups[] = {
> +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-02", LRU_FLAG_EGALAX),
> +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-03", LRU_FLAG_EGALAX),
> +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5170-01", LRU_FLAG_NO_DEB),
> +};
> +
> +/*
> + * This initcall needs to be executed before coredevices, so we have a chance
> + * to fix up the devices with the correct information.
> + */
> +static int zii_imx8mq_dev_process_fixups(void)
> +{
> +       if (!of_machine_is_compatible("zii,imx8mq-ultra"))
> +               return 0;
> +
> +       zii_process_lru_fixups(zii_imx8mq_dev_lru_fixups);
> +
> +       return 0;
> +}
> +postmmu_initcall(zii_imx8mq_dev_process_fixups);
> diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> index 6180f21ab0a4..50bad9b1a27e 100644
> --- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
> +++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> @@ -22,6 +22,11 @@
>                 };
>         };
>
> +       device-info {
> +               nvmem-cells = <&lru_part_number>;
> +               nvmem-cell-names = "lru-part-number";
> +       };
> +
>         aliases {
>                 ethernet0 = &fec1;
>                 ethernet1 = &i210;
> @@ -64,6 +69,11 @@
>  &uart2 {
>         rave-sp {
>                 eeprom@a4 {
> +                       lru_part_number: lru-part-number@21 {
> +                               reg = <0x21 15>;
> +                               read-only;
> +                       };
> +
>                         mac_address_0: mac-address@180 {
>                                 reg = <0x180 6>;
>                         };
> --
> 2.20.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups
  2019-12-18 13:54   ` Andrey Smirnov
@ 2019-12-18 13:56     ` Lucas Stach
  2019-12-18 14:37       ` Andrey Smirnov
  0 siblings, 1 reply; 9+ messages in thread
From: Lucas Stach @ 2019-12-18 13:56 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

On Mi, 2019-12-18 at 05:54 -0800, Andrey Smirnov wrote:
> On Tue, Dec 17, 2019 at 3:19 AM Lucas Stach <l.stach@pengutronix.de> wrote:
> > There are only two fixups we need to apply at the moment:
> > - The 27" RMB3 based unit has a eGalax Touchscreen instead of Synaptics.
> > - The 10.1" SCU/CCU unit has no DEB and thus no switch, but instead the
> >   i210 ethernet is routed to the external connector directly.
> > 
> > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > ---
> >  arch/arm/boards/zii-imx8mq-dev/board.c | 138 +++++++++++++++++++++++++
> >  arch/arm/dts/imx8mq-zii-ultra.dtsi     |  10 ++
> >  2 files changed, 148 insertions(+)
> > 
> > diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
> > index dcf945db495a..0be68423d9bf 100644
> > --- a/arch/arm/boards/zii-imx8mq-dev/board.c
> > +++ b/arch/arm/boards/zii-imx8mq-dev/board.c
> > @@ -11,6 +11,15 @@
> >  #include <asm/memory.h>
> >  #include <linux/sizes.h>
> >  #include <mach/bbu.h>
> > +#include "../zii-common/pn-fixup.h"
> > +
> > +#define LRU_FLAG_EGALAX                BIT(0)
> > +#define LRU_FLAG_NO_DEB                BIT(1)
> > +
> > +struct zii_imx8mq_dev_lru_fixup {
> > +       struct zii_pn_fixup fixup;
> > +       unsigned int flags;
> > +};
> > 
> >  static int zii_imx8mq_dev_init(void)
> >  {
> > @@ -32,3 +41,132 @@ static int zii_imx8mq_dev_init(void)
> >         return 0;
> >  }
> >  device_initcall(zii_imx8mq_dev_init);
> > +
> > +static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
> > +{
> > +       struct device_node *np;
> > +
> > +       /*
> > +        * The 27" unit has a EETI eGalax touchscreen instead of the
> > +        * Synaptics RMI4 found on other units.
> > +        */
> > +       pr_info("Enabling eGalax touchscreen instead of RMI4\n");
> > +
> > +       np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
> > +       if (!np)
> > +               return -ENODEV;
> > +
> > +       of_device_disable(np);
> > +
> > +       np = of_find_compatible_node(root, NULL, "eeti,exc3000");
> > +       if (!np)
> > +               return -ENODEV;
> > +
> > +       of_device_enable(np);
> > +
> > +       return 0;
> > +}
> > +
> > +static int zii_imx8mq_dev_fixup_deb_internal(void)
> > +{
> > +       struct device_node *np, *aliases;
> > +       struct device_d *dev;
> > +
> > +       /*
> > +        * In the internal DT remove the complete FEC hierarchy and move the
> > +        * i210 to be the eth0 interface to allow network boot to work without
> > +        * rewriting all the boot scripts.
> > +        */
> > +       aliases = of_find_node_by_path("/aliases");
> > +       if (!aliases)
> > +               return -ENODEV;
> > +
> > +       np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-fec");
> > +       if (!np)
> > +               return -ENODEV;
> > +
> > +       of_device_disable(np);
> > +
> > +       of_property_write_string(aliases, "ethernet1", np->full_name);
> > +
> > +       dev = get_device_by_device_node(np);
> 
> The patch adding this function might be missing from the series. Or
> did I miss it going in earlier?

Urgh, yes. Sorry about that, I missed this one when preparing the stuff
t send out. I'll send it as soon as my Barebox tree isn't messed up
anymore.

Regards,
Lucas

> > +       if (!dev)
> > +               return -ENODEV;
> > +
> > +       unregister_device(dev);
> > +
> > +       np = of_find_node_by_name(NULL, "i210@0");
> > +       if (!np)
> > +               return -ENODEV;
> > +
> > +       of_property_write_string(aliases, "ethernet0", np->full_name);
> > +
> > +       /* Refresh the internal aliases list from the patched DT */
> > +       of_alias_scan();
> > +
> > +       return 0;
> > +}
> > +
> > +static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
> > +{
> > +       struct device_node *np;
> > +
> > +       /*
> > +        * In the kernel DT remove all devices from the DEB, which isn't
> > +        * present on this system.
> > +        */
> > +       np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
> > +       if (!np)
> > +               return -ENODEV;
> > +
> > +       of_device_disable(np);
> > +
> > +       np = of_find_compatible_node(root, NULL, "zii,rave-wdt");
> > +       if (!np)
> > +               return -ENODEV;
> > +
> > +       of_device_disable(np);
> > +
> > +       return 0;
> > +}
> > +
> > +static void zii_imx8mq_dev_lru_fixup(const struct zii_pn_fixup *context)
> > +{
> > +       const struct zii_imx8mq_dev_lru_fixup *fixup =
> > +               container_of(context, struct zii_imx8mq_dev_lru_fixup, fixup);
> > +
> > +       if (fixup->flags & LRU_FLAG_EGALAX)
> > +               of_register_fixup(zii_imx8mq_dev_fixup_egalax_ts, NULL);
> > +
> > +       if (fixup->flags & LRU_FLAG_NO_DEB) {
> > +               zii_imx8mq_dev_fixup_deb_internal();
> > +               of_register_fixup(zii_imx8mq_dev_fixup_deb, NULL);
> > +       }
> > +}
> > +
> > +#define ZII_IMX8MQ_DEV_LRU_FIXUP(__pn, __flags)                \
> > +       {                                               \
> > +               { __pn, zii_imx8mq_dev_lru_fixup },     \
> > +               __flags                                 \
> > +       }
> > +
> > +static const struct zii_imx8mq_dev_lru_fixup zii_imx8mq_dev_lru_fixups[] = {
> > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-02", LRU_FLAG_EGALAX),
> > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-03", LRU_FLAG_EGALAX),
> > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5170-01", LRU_FLAG_NO_DEB),
> > +};
> > +
> > +/*
> > + * This initcall needs to be executed before coredevices, so we have a chance
> > + * to fix up the devices with the correct information.
> > + */
> > +static int zii_imx8mq_dev_process_fixups(void)
> > +{
> > +       if (!of_machine_is_compatible("zii,imx8mq-ultra"))
> > +               return 0;
> > +
> > +       zii_process_lru_fixups(zii_imx8mq_dev_lru_fixups);
> > +
> > +       return 0;
> > +}
> > +postmmu_initcall(zii_imx8mq_dev_process_fixups);
> > diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > index 6180f21ab0a4..50bad9b1a27e 100644
> > --- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > +++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > @@ -22,6 +22,11 @@
> >                 };
> >         };
> > 
> > +       device-info {
> > +               nvmem-cells = <&lru_part_number>;
> > +               nvmem-cell-names = "lru-part-number";
> > +       };
> > +
> >         aliases {
> >                 ethernet0 = &fec1;
> >                 ethernet1 = &i210;
> > @@ -64,6 +69,11 @@
> >  &uart2 {
> >         rave-sp {
> >                 eeprom@a4 {
> > +                       lru_part_number: lru-part-number@21 {
> > +                               reg = <0x21 15>;
> > +                               read-only;
> > +                       };
> > +
> >                         mac_address_0: mac-address@180 {
> >                                 reg = <0x180 6>;
> >                         };
> > --
> > 2.20.1
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups
  2019-12-18 13:56     ` Lucas Stach
@ 2019-12-18 14:37       ` Andrey Smirnov
  2019-12-18 15:05         ` Lucas Stach
  0 siblings, 1 reply; 9+ messages in thread
From: Andrey Smirnov @ 2019-12-18 14:37 UTC (permalink / raw)
  To: Lucas Stach; +Cc: Barebox List

On Wed, Dec 18, 2019 at 5:56 AM Lucas Stach <l.stach@pengutronix.de> wrote:
>
> On Mi, 2019-12-18 at 05:54 -0800, Andrey Smirnov wrote:
> > On Tue, Dec 17, 2019 at 3:19 AM Lucas Stach <l.stach@pengutronix.de> wrote:
> > > There are only two fixups we need to apply at the moment:
> > > - The 27" RMB3 based unit has a eGalax Touchscreen instead of Synaptics.
> > > - The 10.1" SCU/CCU unit has no DEB and thus no switch, but instead the
> > >   i210 ethernet is routed to the external connector directly.
> > >
> > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > ---
> > >  arch/arm/boards/zii-imx8mq-dev/board.c | 138 +++++++++++++++++++++++++
> > >  arch/arm/dts/imx8mq-zii-ultra.dtsi     |  10 ++
> > >  2 files changed, 148 insertions(+)
> > >
> > > diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
> > > index dcf945db495a..0be68423d9bf 100644
> > > --- a/arch/arm/boards/zii-imx8mq-dev/board.c
> > > +++ b/arch/arm/boards/zii-imx8mq-dev/board.c
> > > @@ -11,6 +11,15 @@
> > >  #include <asm/memory.h>
> > >  #include <linux/sizes.h>
> > >  #include <mach/bbu.h>
> > > +#include "../zii-common/pn-fixup.h"
> > > +
> > > +#define LRU_FLAG_EGALAX                BIT(0)
> > > +#define LRU_FLAG_NO_DEB                BIT(1)
> > > +
> > > +struct zii_imx8mq_dev_lru_fixup {
> > > +       struct zii_pn_fixup fixup;
> > > +       unsigned int flags;
> > > +};
> > >
> > >  static int zii_imx8mq_dev_init(void)
> > >  {
> > > @@ -32,3 +41,132 @@ static int zii_imx8mq_dev_init(void)
> > >         return 0;
> > >  }
> > >  device_initcall(zii_imx8mq_dev_init);
> > > +
> > > +static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
> > > +{
> > > +       struct device_node *np;
> > > +
> > > +       /*
> > > +        * The 27" unit has a EETI eGalax touchscreen instead of the
> > > +        * Synaptics RMI4 found on other units.
> > > +        */
> > > +       pr_info("Enabling eGalax touchscreen instead of RMI4\n");
> > > +
> > > +       np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
> > > +       if (!np)
> > > +               return -ENODEV;
> > > +
> > > +       of_device_disable(np);
> > > +
> > > +       np = of_find_compatible_node(root, NULL, "eeti,exc3000");
> > > +       if (!np)
> > > +               return -ENODEV;
> > > +
> > > +       of_device_enable(np);
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +static int zii_imx8mq_dev_fixup_deb_internal(void)
> > > +{
> > > +       struct device_node *np, *aliases;
> > > +       struct device_d *dev;
> > > +
> > > +       /*
> > > +        * In the internal DT remove the complete FEC hierarchy and move the
> > > +        * i210 to be the eth0 interface to allow network boot to work without
> > > +        * rewriting all the boot scripts.
> > > +        */
> > > +       aliases = of_find_node_by_path("/aliases");
> > > +       if (!aliases)
> > > +               return -ENODEV;
> > > +
> > > +       np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-fec");
> > > +       if (!np)
> > > +               return -ENODEV;
> > > +
> > > +       of_device_disable(np);
> > > +
> > > +       of_property_write_string(aliases, "ethernet1", np->full_name);
> > > +
> > > +       dev = get_device_by_device_node(np);
> >
> > The patch adding this function might be missing from the series. Or
> > did I miss it going in earlier?
>
> Urgh, yes. Sorry about that, I missed this one when preparing the stuff
> t send out. I'll send it as soon as my Barebox tree isn't messed up
> anymore.
>

No worries. One other thing that I noticed is that I don't think that
"watchdog@38" on "i2c3" node has trickled down from upstream to our
copy of imx8mq-zii-ultra.dtsi, so the line doing

of_find_compatible_node(root, NULL, "zii,rave-wdt");

might not find what it is looking for. I might have missed something
here too, but I think it is worth double checking.



> Regards,
> Lucas
>
> > > +       if (!dev)
> > > +               return -ENODEV;
> > > +
> > > +       unregister_device(dev);
> > > +
> > > +       np = of_find_node_by_name(NULL, "i210@0");
> > > +       if (!np)
> > > +               return -ENODEV;
> > > +
> > > +       of_property_write_string(aliases, "ethernet0", np->full_name);
> > > +
> > > +       /* Refresh the internal aliases list from the patched DT */
> > > +       of_alias_scan();
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
> > > +{
> > > +       struct device_node *np;
> > > +
> > > +       /*
> > > +        * In the kernel DT remove all devices from the DEB, which isn't
> > > +        * present on this system.
> > > +        */
> > > +       np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
> > > +       if (!np)
> > > +               return -ENODEV;
> > > +
> > > +       of_device_disable(np);
> > > +
> > > +       np = of_find_compatible_node(root, NULL, "zii,rave-wdt");
> > > +       if (!np)
> > > +               return -ENODEV;
> > > +
> > > +       of_device_disable(np);
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +static void zii_imx8mq_dev_lru_fixup(const struct zii_pn_fixup *context)
> > > +{
> > > +       const struct zii_imx8mq_dev_lru_fixup *fixup =
> > > +               container_of(context, struct zii_imx8mq_dev_lru_fixup, fixup);
> > > +
> > > +       if (fixup->flags & LRU_FLAG_EGALAX)
> > > +               of_register_fixup(zii_imx8mq_dev_fixup_egalax_ts, NULL);
> > > +
> > > +       if (fixup->flags & LRU_FLAG_NO_DEB) {
> > > +               zii_imx8mq_dev_fixup_deb_internal();
> > > +               of_register_fixup(zii_imx8mq_dev_fixup_deb, NULL);
> > > +       }
> > > +}
> > > +
> > > +#define ZII_IMX8MQ_DEV_LRU_FIXUP(__pn, __flags)                \
> > > +       {                                               \
> > > +               { __pn, zii_imx8mq_dev_lru_fixup },     \
> > > +               __flags                                 \
> > > +       }
> > > +
> > > +static const struct zii_imx8mq_dev_lru_fixup zii_imx8mq_dev_lru_fixups[] = {
> > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-02", LRU_FLAG_EGALAX),
> > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-03", LRU_FLAG_EGALAX),
> > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5170-01", LRU_FLAG_NO_DEB),
> > > +};
> > > +
> > > +/*
> > > + * This initcall needs to be executed before coredevices, so we have a chance
> > > + * to fix up the devices with the correct information.
> > > + */
> > > +static int zii_imx8mq_dev_process_fixups(void)
> > > +{
> > > +       if (!of_machine_is_compatible("zii,imx8mq-ultra"))
> > > +               return 0;
> > > +
> > > +       zii_process_lru_fixups(zii_imx8mq_dev_lru_fixups);
> > > +
> > > +       return 0;
> > > +}
> > > +postmmu_initcall(zii_imx8mq_dev_process_fixups);
> > > diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > index 6180f21ab0a4..50bad9b1a27e 100644
> > > --- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > +++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > @@ -22,6 +22,11 @@
> > >                 };
> > >         };
> > >
> > > +       device-info {
> > > +               nvmem-cells = <&lru_part_number>;
> > > +               nvmem-cell-names = "lru-part-number";
> > > +       };
> > > +
> > >         aliases {
> > >                 ethernet0 = &fec1;
> > >                 ethernet1 = &i210;
> > > @@ -64,6 +69,11 @@
> > >  &uart2 {
> > >         rave-sp {
> > >                 eeprom@a4 {
> > > +                       lru_part_number: lru-part-number@21 {
> > > +                               reg = <0x21 15>;
> > > +                               read-only;
> > > +                       };
> > > +
> > >                         mac_address_0: mac-address@180 {
> > >                                 reg = <0x180 6>;
> > >                         };
> > > --
> > > 2.20.1
> > >
> > >
> > > _______________________________________________
> > > barebox mailing list
> > > barebox@lists.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/barebox
>

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups
  2019-12-18 14:37       ` Andrey Smirnov
@ 2019-12-18 15:05         ` Lucas Stach
  2019-12-18 15:13           ` Andrey Smirnov
  0 siblings, 1 reply; 9+ messages in thread
From: Lucas Stach @ 2019-12-18 15:05 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

On Mi, 2019-12-18 at 06:37 -0800, Andrey Smirnov wrote:
> On Wed, Dec 18, 2019 at 5:56 AM Lucas Stach <l.stach@pengutronix.de> wrote:
> > On Mi, 2019-12-18 at 05:54 -0800, Andrey Smirnov wrote:
> > > On Tue, Dec 17, 2019 at 3:19 AM Lucas Stach <l.stach@pengutronix.de> wrote:
> > > > There are only two fixups we need to apply at the moment:
> > > > - The 27" RMB3 based unit has a eGalax Touchscreen instead of Synaptics.
> > > > - The 10.1" SCU/CCU unit has no DEB and thus no switch, but instead the
> > > >   i210 ethernet is routed to the external connector directly.
> > > > 
> > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > > ---
> > > >  arch/arm/boards/zii-imx8mq-dev/board.c | 138 +++++++++++++++++++++++++
> > > >  arch/arm/dts/imx8mq-zii-ultra.dtsi     |  10 ++
> > > >  2 files changed, 148 insertions(+)
> > > > 
> > > > diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
> > > > index dcf945db495a..0be68423d9bf 100644
> > > > --- a/arch/arm/boards/zii-imx8mq-dev/board.c
> > > > +++ b/arch/arm/boards/zii-imx8mq-dev/board.c
> > > > @@ -11,6 +11,15 @@
> > > >  #include <asm/memory.h>
> > > >  #include <linux/sizes.h>
> > > >  #include <mach/bbu.h>
> > > > +#include "../zii-common/pn-fixup.h"
> > > > +
> > > > +#define LRU_FLAG_EGALAX                BIT(0)
> > > > +#define LRU_FLAG_NO_DEB                BIT(1)
> > > > +
> > > > +struct zii_imx8mq_dev_lru_fixup {
> > > > +       struct zii_pn_fixup fixup;
> > > > +       unsigned int flags;
> > > > +};
> > > > 
> > > >  static int zii_imx8mq_dev_init(void)
> > > >  {
> > > > @@ -32,3 +41,132 @@ static int zii_imx8mq_dev_init(void)
> > > >         return 0;
> > > >  }
> > > >  device_initcall(zii_imx8mq_dev_init);
> > > > +
> > > > +static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
> > > > +{
> > > > +       struct device_node *np;
> > > > +
> > > > +       /*
> > > > +        * The 27" unit has a EETI eGalax touchscreen instead of the
> > > > +        * Synaptics RMI4 found on other units.
> > > > +        */
> > > > +       pr_info("Enabling eGalax touchscreen instead of RMI4\n");
> > > > +
> > > > +       np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
> > > > +       if (!np)
> > > > +               return -ENODEV;
> > > > +
> > > > +       of_device_disable(np);
> > > > +
> > > > +       np = of_find_compatible_node(root, NULL, "eeti,exc3000");
> > > > +       if (!np)
> > > > +               return -ENODEV;
> > > > +
> > > > +       of_device_enable(np);
> > > > +
> > > > +       return 0;
> > > > +}
> > > > +
> > > > +static int zii_imx8mq_dev_fixup_deb_internal(void)
> > > > +{
> > > > +       struct device_node *np, *aliases;
> > > > +       struct device_d *dev;
> > > > +
> > > > +       /*
> > > > +        * In the internal DT remove the complete FEC hierarchy and move the
> > > > +        * i210 to be the eth0 interface to allow network boot to work without
> > > > +        * rewriting all the boot scripts.
> > > > +        */
> > > > +       aliases = of_find_node_by_path("/aliases");
> > > > +       if (!aliases)
> > > > +               return -ENODEV;
> > > > +
> > > > +       np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-fec");
> > > > +       if (!np)
> > > > +               return -ENODEV;
> > > > +
> > > > +       of_device_disable(np);
> > > > +
> > > > +       of_property_write_string(aliases, "ethernet1", np->full_name);
> > > > +
> > > > +       dev = get_device_by_device_node(np);
> > > 
> > > The patch adding this function might be missing from the series. Or
> > > did I miss it going in earlier?
> > 
> > Urgh, yes. Sorry about that, I missed this one when preparing the stuff
> > t send out. I'll send it as soon as my Barebox tree isn't messed up
> > anymore.
> > 
> 
> No worries. One other thing that I noticed is that I don't think that
> "watchdog@38" on "i2c3" node has trickled down from upstream to our
> copy of imx8mq-zii-ultra.dtsi, so the line doing
> 
> of_find_compatible_node(root, NULL, "zii,rave-wdt");
> 
> might not find what it is looking for. I might have missed something
> here too, but I think it is worth double checking.

Your are talking about the line in zii_imx8mq_dev_fixup_deb() below,
right? This fixup is only run on the DT passed to the Linux kernel, not
the internal DT, so it's not an issue that this node isn't present in
the Barebox DT yet.

Regards,
Lucas

> > > > +       if (!dev)
> > > > +               return -ENODEV;
> > > > +
> > > > +       unregister_device(dev);
> > > > +
> > > > +       np = of_find_node_by_name(NULL, "i210@0");
> > > > +       if (!np)
> > > > +               return -ENODEV;
> > > > +
> > > > +       of_property_write_string(aliases, "ethernet0", np->full_name);
> > > > +
> > > > +       /* Refresh the internal aliases list from the patched DT */
> > > > +       of_alias_scan();
> > > > +
> > > > +       return 0;
> > > > +}
> > > > +
> > > > +static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
> > > > +{
> > > > +       struct device_node *np;
> > > > +
> > > > +       /*
> > > > +        * In the kernel DT remove all devices from the DEB, which isn't
> > > > +        * present on this system.
> > > > +        */
> > > > +       np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
> > > > +       if (!np)
> > > > +               return -ENODEV;
> > > > +
> > > > +       of_device_disable(np);
> > > > +
> > > > +       np = of_find_compatible_node(root, NULL, "zii,rave-wdt");
> > > > +       if (!np)
> > > > +               return -ENODEV;
> > > > +
> > > > +       of_device_disable(np);
> > > > +
> > > > +       return 0;
> > > > +}
> > > > +
> > > > +static void zii_imx8mq_dev_lru_fixup(const struct zii_pn_fixup *context)
> > > > +{
> > > > +       const struct zii_imx8mq_dev_lru_fixup *fixup =
> > > > +               container_of(context, struct zii_imx8mq_dev_lru_fixup, fixup);
> > > > +
> > > > +       if (fixup->flags & LRU_FLAG_EGALAX)
> > > > +               of_register_fixup(zii_imx8mq_dev_fixup_egalax_ts, NULL);
> > > > +
> > > > +       if (fixup->flags & LRU_FLAG_NO_DEB) {
> > > > +               zii_imx8mq_dev_fixup_deb_internal();
> > > > +               of_register_fixup(zii_imx8mq_dev_fixup_deb, NULL);
> > > > +       }
> > > > +}
> > > > +
> > > > +#define ZII_IMX8MQ_DEV_LRU_FIXUP(__pn, __flags)                \
> > > > +       {                                               \
> > > > +               { __pn, zii_imx8mq_dev_lru_fixup },     \
> > > > +               __flags                                 \
> > > > +       }
> > > > +
> > > > +static const struct zii_imx8mq_dev_lru_fixup zii_imx8mq_dev_lru_fixups[] = {
> > > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-02", LRU_FLAG_EGALAX),
> > > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-03", LRU_FLAG_EGALAX),
> > > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5170-01", LRU_FLAG_NO_DEB),
> > > > +};
> > > > +
> > > > +/*
> > > > + * This initcall needs to be executed before coredevices, so we have a chance
> > > > + * to fix up the devices with the correct information.
> > > > + */
> > > > +static int zii_imx8mq_dev_process_fixups(void)
> > > > +{
> > > > +       if (!of_machine_is_compatible("zii,imx8mq-ultra"))
> > > > +               return 0;
> > > > +
> > > > +       zii_process_lru_fixups(zii_imx8mq_dev_lru_fixups);
> > > > +
> > > > +       return 0;
> > > > +}
> > > > +postmmu_initcall(zii_imx8mq_dev_process_fixups);
> > > > diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > > index 6180f21ab0a4..50bad9b1a27e 100644
> > > > --- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > > +++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > > @@ -22,6 +22,11 @@
> > > >                 };
> > > >         };
> > > > 
> > > > +       device-info {
> > > > +               nvmem-cells = <&lru_part_number>;
> > > > +               nvmem-cell-names = "lru-part-number";
> > > > +       };
> > > > +
> > > >         aliases {
> > > >                 ethernet0 = &fec1;
> > > >                 ethernet1 = &i210;
> > > > @@ -64,6 +69,11 @@
> > > >  &uart2 {
> > > >         rave-sp {
> > > >                 eeprom@a4 {
> > > > +                       lru_part_number: lru-part-number@21 {
> > > > +                               reg = <0x21 15>;
> > > > +                               read-only;
> > > > +                       };
> > > > +
> > > >                         mac_address_0: mac-address@180 {
> > > >                                 reg = <0x180 6>;
> > > >                         };
> > > > --
> > > > 2.20.1
> > > > 
> > > > 
> > > > _______________________________________________
> > > > barebox mailing list
> > > > barebox@lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/barebox


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups
  2019-12-18 15:05         ` Lucas Stach
@ 2019-12-18 15:13           ` Andrey Smirnov
  0 siblings, 0 replies; 9+ messages in thread
From: Andrey Smirnov @ 2019-12-18 15:13 UTC (permalink / raw)
  To: Lucas Stach; +Cc: Barebox List

On Wed, Dec 18, 2019 at 7:05 AM Lucas Stach <l.stach@pengutronix.de> wrote:
>
> On Mi, 2019-12-18 at 06:37 -0800, Andrey Smirnov wrote:
> > On Wed, Dec 18, 2019 at 5:56 AM Lucas Stach <l.stach@pengutronix.de> wrote:
> > > On Mi, 2019-12-18 at 05:54 -0800, Andrey Smirnov wrote:
> > > > On Tue, Dec 17, 2019 at 3:19 AM Lucas Stach <l.stach@pengutronix.de> wrote:
> > > > > There are only two fixups we need to apply at the moment:
> > > > > - The 27" RMB3 based unit has a eGalax Touchscreen instead of Synaptics.
> > > > > - The 10.1" SCU/CCU unit has no DEB and thus no switch, but instead the
> > > > >   i210 ethernet is routed to the external connector directly.
> > > > >
> > > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > > > ---
> > > > >  arch/arm/boards/zii-imx8mq-dev/board.c | 138 +++++++++++++++++++++++++
> > > > >  arch/arm/dts/imx8mq-zii-ultra.dtsi     |  10 ++
> > > > >  2 files changed, 148 insertions(+)
> > > > >
> > > > > diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
> > > > > index dcf945db495a..0be68423d9bf 100644
> > > > > --- a/arch/arm/boards/zii-imx8mq-dev/board.c
> > > > > +++ b/arch/arm/boards/zii-imx8mq-dev/board.c
> > > > > @@ -11,6 +11,15 @@
> > > > >  #include <asm/memory.h>
> > > > >  #include <linux/sizes.h>
> > > > >  #include <mach/bbu.h>
> > > > > +#include "../zii-common/pn-fixup.h"
> > > > > +
> > > > > +#define LRU_FLAG_EGALAX                BIT(0)
> > > > > +#define LRU_FLAG_NO_DEB                BIT(1)
> > > > > +
> > > > > +struct zii_imx8mq_dev_lru_fixup {
> > > > > +       struct zii_pn_fixup fixup;
> > > > > +       unsigned int flags;
> > > > > +};
> > > > >
> > > > >  static int zii_imx8mq_dev_init(void)
> > > > >  {
> > > > > @@ -32,3 +41,132 @@ static int zii_imx8mq_dev_init(void)
> > > > >         return 0;
> > > > >  }
> > > > >  device_initcall(zii_imx8mq_dev_init);
> > > > > +
> > > > > +static int zii_imx8mq_dev_fixup_egalax_ts(struct device_node *root, void *ctx)
> > > > > +{
> > > > > +       struct device_node *np;
> > > > > +
> > > > > +       /*
> > > > > +        * The 27" unit has a EETI eGalax touchscreen instead of the
> > > > > +        * Synaptics RMI4 found on other units.
> > > > > +        */
> > > > > +       pr_info("Enabling eGalax touchscreen instead of RMI4\n");
> > > > > +
> > > > > +       np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
> > > > > +       if (!np)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       of_device_disable(np);
> > > > > +
> > > > > +       np = of_find_compatible_node(root, NULL, "eeti,exc3000");
> > > > > +       if (!np)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       of_device_enable(np);
> > > > > +
> > > > > +       return 0;
> > > > > +}
> > > > > +
> > > > > +static int zii_imx8mq_dev_fixup_deb_internal(void)
> > > > > +{
> > > > > +       struct device_node *np, *aliases;
> > > > > +       struct device_d *dev;
> > > > > +
> > > > > +       /*
> > > > > +        * In the internal DT remove the complete FEC hierarchy and move the
> > > > > +        * i210 to be the eth0 interface to allow network boot to work without
> > > > > +        * rewriting all the boot scripts.
> > > > > +        */
> > > > > +       aliases = of_find_node_by_path("/aliases");
> > > > > +       if (!aliases)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-fec");
> > > > > +       if (!np)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       of_device_disable(np);
> > > > > +
> > > > > +       of_property_write_string(aliases, "ethernet1", np->full_name);
> > > > > +
> > > > > +       dev = get_device_by_device_node(np);
> > > >
> > > > The patch adding this function might be missing from the series. Or
> > > > did I miss it going in earlier?
> > >
> > > Urgh, yes. Sorry about that, I missed this one when preparing the stuff
> > > t send out. I'll send it as soon as my Barebox tree isn't messed up
> > > anymore.
> > >
> >
> > No worries. One other thing that I noticed is that I don't think that
> > "watchdog@38" on "i2c3" node has trickled down from upstream to our
> > copy of imx8mq-zii-ultra.dtsi, so the line doing
> >
> > of_find_compatible_node(root, NULL, "zii,rave-wdt");
> >
> > might not find what it is looking for. I might have missed something
> > here too, but I think it is worth double checking.
>
> Your are talking about the line in zii_imx8mq_dev_fixup_deb() below,
> right? This fixup is only run on the DT passed to the Linux kernel, not
> the internal DT, so it's not an issue that this node isn't present in
> the Barebox DT yet.

Ah, that's what I was missing. Make sense, then. Disregard my comment.

>
> Regards,
> Lucas
>
> > > > > +       if (!dev)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       unregister_device(dev);
> > > > > +
> > > > > +       np = of_find_node_by_name(NULL, "i210@0");
> > > > > +       if (!np)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       of_property_write_string(aliases, "ethernet0", np->full_name);
> > > > > +
> > > > > +       /* Refresh the internal aliases list from the patched DT */
> > > > > +       of_alias_scan();
> > > > > +
> > > > > +       return 0;
> > > > > +}
> > > > > +
> > > > > +static int zii_imx8mq_dev_fixup_deb(struct device_node *root, void *ctx)
> > > > > +{
> > > > > +       struct device_node *np;
> > > > > +
> > > > > +       /*
> > > > > +        * In the kernel DT remove all devices from the DEB, which isn't
> > > > > +        * present on this system.
> > > > > +        */
> > > > > +       np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
> > > > > +       if (!np)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       of_device_disable(np);
> > > > > +
> > > > > +       np = of_find_compatible_node(root, NULL, "zii,rave-wdt");
> > > > > +       if (!np)
> > > > > +               return -ENODEV;
> > > > > +
> > > > > +       of_device_disable(np);
> > > > > +
> > > > > +       return 0;
> > > > > +}
> > > > > +
> > > > > +static void zii_imx8mq_dev_lru_fixup(const struct zii_pn_fixup *context)
> > > > > +{
> > > > > +       const struct zii_imx8mq_dev_lru_fixup *fixup =
> > > > > +               container_of(context, struct zii_imx8mq_dev_lru_fixup, fixup);
> > > > > +
> > > > > +       if (fixup->flags & LRU_FLAG_EGALAX)
> > > > > +               of_register_fixup(zii_imx8mq_dev_fixup_egalax_ts, NULL);
> > > > > +
> > > > > +       if (fixup->flags & LRU_FLAG_NO_DEB) {
> > > > > +               zii_imx8mq_dev_fixup_deb_internal();
> > > > > +               of_register_fixup(zii_imx8mq_dev_fixup_deb, NULL);
> > > > > +       }
> > > > > +}
> > > > > +
> > > > > +#define ZII_IMX8MQ_DEV_LRU_FIXUP(__pn, __flags)                \
> > > > > +       {                                               \
> > > > > +               { __pn, zii_imx8mq_dev_lru_fixup },     \
> > > > > +               __flags                                 \
> > > > > +       }
> > > > > +
> > > > > +static const struct zii_imx8mq_dev_lru_fixup zii_imx8mq_dev_lru_fixups[] = {
> > > > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-02", LRU_FLAG_EGALAX),
> > > > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5131-03", LRU_FLAG_EGALAX),
> > > > > +       ZII_IMX8MQ_DEV_LRU_FIXUP("00-5170-01", LRU_FLAG_NO_DEB),
> > > > > +};
> > > > > +
> > > > > +/*
> > > > > + * This initcall needs to be executed before coredevices, so we have a chance
> > > > > + * to fix up the devices with the correct information.
> > > > > + */
> > > > > +static int zii_imx8mq_dev_process_fixups(void)
> > > > > +{
> > > > > +       if (!of_machine_is_compatible("zii,imx8mq-ultra"))
> > > > > +               return 0;
> > > > > +
> > > > > +       zii_process_lru_fixups(zii_imx8mq_dev_lru_fixups);
> > > > > +
> > > > > +       return 0;
> > > > > +}
> > > > > +postmmu_initcall(zii_imx8mq_dev_process_fixups);
> > > > > diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > > > index 6180f21ab0a4..50bad9b1a27e 100644
> > > > > --- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > > > +++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
> > > > > @@ -22,6 +22,11 @@
> > > > >                 };
> > > > >         };
> > > > >
> > > > > +       device-info {
> > > > > +               nvmem-cells = <&lru_part_number>;
> > > > > +               nvmem-cell-names = "lru-part-number";
> > > > > +       };
> > > > > +
> > > > >         aliases {
> > > > >                 ethernet0 = &fec1;
> > > > >                 ethernet1 = &i210;
> > > > > @@ -64,6 +69,11 @@
> > > > >  &uart2 {
> > > > >         rave-sp {
> > > > >                 eeprom@a4 {
> > > > > +                       lru_part_number: lru-part-number@21 {
> > > > > +                               reg = <0x21 15>;
> > > > > +                               read-only;
> > > > > +                       };
> > > > > +
> > > > >                         mac_address_0: mac-address@180 {
> > > > >                                 reg = <0x180 6>;
> > > > >                         };
> > > > > --
> > > > > 2.20.1
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > barebox mailing list
> > > > > barebox@lists.infradead.org
> > > > > http://lists.infradead.org/mailman/listinfo/barebox
>

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2019-12-18 15:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 11:18 [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Lucas Stach
2019-12-17 11:18 ` [PATCH 2/3] ARM: zii-imx8mq-dev: add DT fixups Lucas Stach
2019-12-18 13:54   ` Andrey Smirnov
2019-12-18 13:56     ` Lucas Stach
2019-12-18 14:37       ` Andrey Smirnov
2019-12-18 15:05         ` Lucas Stach
2019-12-18 15:13           ` Andrey Smirnov
2019-12-17 11:18 ` [PATCH 3/3] ARM: zii-imx8mq-dev: fixup touchscreen and ethernet switch alias Lucas Stach
2019-12-18  7:29 ` [PATCH 1/3] ARM: zii-imx8mq-dev: make eMMC update target the default Sascha Hauer

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