mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v4 0/8] add noswitch support for skov boards
@ 2021-10-06  8:43 Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

changes v4:
- rename skov_no_switch to skov_have_switch
- use xasprintf instead of xzallox + snprintf
- use alias for ethernet0 node detection and make it compatible with the
  old DTs versions.

changes v3:
- add missing byte in the switch path generation
- make sure it work with old devicetrees

Oleksij Rempel (8):
  ARM: dts: skov-imx6: add USB nodes
  ARM: boards: skov-imx6: fixup_machine_compatible() add optional root
    node
  ARM: boards: skov-imx6: add switch detection
  ARM: boards: skov-imx6: disable eth0 for barebox if no switch is
    detected
  ARM: boards: skov-imx6: fixup different DTS variants
  ARM: boards: skov-imx6: start using deep-probe
  ARM: boards: skov-imx6: add defaultenv with eth1-discover script
  ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant

 arch/arm/boards/skov-imx6/Makefile            |   1 +
 arch/arm/boards/skov-imx6/board.c             | 228 +++++++++++++++---
 .../network/eth1-discover                     |   8 +
 arch/arm/boards/skov-imx6/lowlevel.c          |   6 +-
 arch/arm/dts/Makefile                         |   2 +-
 arch/arm/dts/imx6qdl-skov-imx6.dtsi           |  20 ++
 arch/arm/dts/imx6s-skov-imx6.dts              |  22 ++
 7 files changed, 253 insertions(+), 34 deletions(-)
 create mode 100644 arch/arm/boards/skov-imx6/defaultenv-skov-imx6/network/eth1-discover
 create mode 100644 arch/arm/dts/imx6s-skov-imx6.dts

-- 
2.30.2


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


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

* [PATCH v4 1/8] ARM: dts: skov-imx6: add USB nodes
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node Oleksij Rempel
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

We need USB working to make use of USB ethernet adapters.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/dts/imx6qdl-skov-imx6.dtsi | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/dts/imx6qdl-skov-imx6.dtsi b/arch/arm/dts/imx6qdl-skov-imx6.dtsi
index 03f3cb02fc..371a931e53 100644
--- a/arch/arm/dts/imx6qdl-skov-imx6.dtsi
+++ b/arch/arm/dts/imx6qdl-skov-imx6.dtsi
@@ -273,6 +273,26 @@
 	remote-endpoint = <&display0_in>;
 };
 
+&usbh1 {
+	disable-over-current;
+	status = "okay";
+};
+
+/* no usbh2 */
+&usbphynop1 {
+	status = "disabled";
+};
+
+/* no usbh3 */
+&usbphynop2 {
+	status = "disabled";
+};
+
+&usbotg {
+	disable-over-current;
+	status = "okay";
+};
+
 &iomuxc {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_hog>;
-- 
2.30.2


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


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

* [PATCH v4 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 3/8] ARM: boards: skov-imx6: add switch detection Oleksij Rempel
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

This will be needed by the next patch

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

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index a58172b2b1..030ac62c52 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -432,16 +432,18 @@ static void skov_init_board(const struct board_description *variant)
 	}
 }
 
-static void fixup_machine_compatible(const char *compat)
+static void fixup_machine_compatible(const char *compat,
+				     struct device_node *root)
 {
 	const char *curcompat;
-	struct device_node *root;
 	int cclen = 0, clen = strlen(compat) + 1;
 	void *buf;
 
-	root = of_get_root_node();
-	if (!root)
-		return;
+	if (!root) {
+		root = of_get_root_node();
+		if (!root)
+			return;
+	}
 
 	curcompat = of_get_property(root, "compatible", &cclen);
 
@@ -487,7 +489,7 @@ static int skov_imx6_probe(struct device_d *dev)
 	globalvar_add_simple("board.dts", variant->dts_compatible);
 	globalvar_add_simple("board.display", variant->display ?: NULL);
 
-	fixup_machine_compatible(variant->dts_compatible);
+	fixup_machine_compatible(variant->dts_compatible, NULL);
 
 	skov_init_board(variant);
 
-- 
2.30.2


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


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

* [PATCH v4 3/8] ARM: boards: skov-imx6: add switch detection
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected Oleksij Rempel
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

There are board variants with same board ID but not switch. Detect this
variants.

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

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 030ac62c52..1fa691945e 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <of_gpio.h>
 #include <gpio.h>
+#include <linux/micrel_phy.h>
 
 #include "version.h"
 
@@ -130,6 +131,9 @@ copy_mac_from_eth0:
 	return eth_of_fixup_node_from_eth_device(root, node_path, ethname);
 }
 
+#define SKOV_GPIO_MDIO_BUS	0
+#define SKOV_LAN1_PHY_ADDR	1
+
 #define MAX_V_GPIO 8
 
 struct board_description {
@@ -303,20 +307,110 @@ static const struct board_description imx6_variants[] = {
 };
 
 static int skov_board_no = -1;
+static bool skov_have_switch = true;
+static const char *no_switch_suffix = "-noswitch";
 
-static int skov_imx6_fixup(struct device_node *root, void *unused)
+static void fixup_machine_compatible(const char *compat,
+				     struct device_node *root)
 {
-	int ret;
-	const char *val;
-	uint32_t brightness;
+	int cclen = 0, clen = strlen(compat) + 1;
+	const char *curcompat;
+	void *buf;
+
+	if (!root) {
+		root = of_get_root_node();
+		if (!root)
+			return;
+	}
+
+	curcompat = of_get_property(root, "compatible", &cclen);
+
+	buf = xzalloc(cclen + clen);
+
+	memcpy(buf, compat, clen);
+	memcpy(buf + clen, curcompat, cclen);
+
+	/*
+	 * Prepend the compatible from board entry to the machine compatible.
+	 * Used to match bootspec entries against it.
+	 */
+	of_set_property(root, "compatible", buf, cclen + clen, true);
+
+	free(buf);
+}
+
+static void fixup_noswitch_machine_compatible(struct device_node *root)
+{
+	const char *compat = imx6_variants[skov_board_no].dts_compatible;
+	const char *generic = "skov,imx6";
+	size_t size, size_generic;
+	char *buf;
+
+	size = strlen(compat) + strlen(no_switch_suffix) + 1;
+	size_generic = strlen(generic) + strlen(no_switch_suffix) + 1;
+	size = max(size, size_generic);
+
+	/* add generic compatible, so systemd&co can make right decisions */
+	buf = xasprintf("%s%s", generic, no_switch_suffix);
+	fixup_machine_compatible(buf, root);
+
+	/* add specific compatible as fallback, in case this board has new
+	 * challenges.
+	 */
+	buf = xasprintf("%s%s", compat, no_switch_suffix);
+	fixup_machine_compatible(buf, root);
+
+	free(buf);
+}
+
+static void skov_imx6_no_switch(struct device_node *root)
+{
+	const char *fec_alias = "ethernet0";
 	struct device_node *node;
-	struct device_node *chosen = of_create_node(root, "/chosen");
+	int ret;
+
+	fixup_noswitch_machine_compatible(root);
 
+	node = of_find_node_by_alias(root, fec_alias);
+	if (node) {
+		ret = of_device_disable(node);
+		if (ret)
+			pr_warn("Can't disable %s\n", fec_alias);
+	} else {
+		pr_warn("Can't find node by alias: %s\n", fec_alias);
+	}
+
+	node = of_find_node_by_alias(root, "mdio-gpio0");
+	if (node) {
+		ret = of_device_disable(node);
+		if (ret)
+			pr_warn("Can't disable mdio-gpio0 node\n");
+	} else {
+		pr_warn("Can't find mdio-gpio0 node\n");
+	}
+}
+
+static void skov_imx6_switch(struct device_node *root)
+{
 	eth_of_fixup_node_from_eth_device(root,
 			"/mdio-gpio/ksz8873@3/ports/ports@0", "eth0");
 	eth2_of_fixup_node_individually(root,
 		"/mdio-gpio/ksz8873@3/ports/ports@1", "eth0",
 		"state.ethaddr.eth2", "/state/ethaddr/eth2");
+}
+
+static int skov_imx6_fixup(struct device_node *root, void *unused)
+{
+	struct device_node *chosen = of_create_node(root, "/chosen");
+	struct device_node *node;
+	uint32_t brightness;
+	const char *val;
+	int ret;
+
+	if (skov_have_switch)
+		skov_imx6_switch(root);
+	else
+		skov_imx6_no_switch(root);
 
 	switch (bootsource_get()) {
 	case BOOTSOURCE_MMC:
@@ -432,34 +526,39 @@ static void skov_init_board(const struct board_description *variant)
 	}
 }
 
-static void fixup_machine_compatible(const char *compat,
-				     struct device_node *root)
+static int skov_switch_test(void)
 {
-	const char *curcompat;
-	int cclen = 0, clen = strlen(compat) + 1;
-	void *buf;
+	struct phy_device *phydev;
+	struct mii_bus *mii;
+	int ret;
 
-	if (!root) {
-		root = of_get_root_node();
-		if (!root)
-			return;
-	}
+	if (skov_board_no < 0)
+		return 0;
 
-	curcompat = of_get_property(root, "compatible", &cclen);
+	/* On this boards, we have only one MDIO bus. So, it is enough to take
+	 * the first one.
+	 */
+	mii = mdiobus_get_bus(SKOV_GPIO_MDIO_BUS);
+	/* We can't read the switch ID, but we get get ID of the first PHY,
+	 * which is enough to test if the switch is attached.
+	 */
+	phydev = get_phy_device(mii, SKOV_LAN1_PHY_ADDR);
+	if (IS_ERR(phydev))
+		goto no_switch;
 
-	buf = xzalloc(cclen + clen);
+	if (phydev->phy_id != PHY_ID_KSZ886X)
+		goto no_switch;
 
-	memcpy(buf, compat, clen);
-	memcpy(buf + clen, curcompat, cclen);
+	return 0;
 
-	/*
-	 * Prepend the compatible from board entry to the machine compatible.
-	 * Used to match bootspec entries against it.
-	 */
-	of_set_property(root, "compatible", buf, cclen + clen, true);
+no_switch:
+	skov_have_switch = false;
 
-	free(buf);
+	pr_notice("No-switch variant is detected\n");
+
+	return 0;
 }
+late_initcall(skov_switch_test);
 
 static int skov_imx6_probe(struct device_d *dev)
 {
-- 
2.30.2


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


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

* [PATCH v4 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
                   ` (2 preceding siblings ...)
  2021-10-06  8:43 ` [PATCH v4 3/8] ARM: boards: skov-imx6: add switch detection Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 5/8] ARM: boards: skov-imx6: fixup different DTS variants Oleksij Rempel
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

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

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 1fa691945e..f42a0cad00 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -529,6 +529,7 @@ static void skov_init_board(const struct board_description *variant)
 static int skov_switch_test(void)
 {
 	struct phy_device *phydev;
+	struct device_d *eth0;
 	struct mii_bus *mii;
 	int ret;
 
@@ -556,6 +557,15 @@ no_switch:
 
 	pr_notice("No-switch variant is detected\n");
 
+	eth0 = get_device_by_name("eth0");
+	if (eth0) {
+		ret = dev_set_param(eth0, "mode", "disabled");
+		if (ret)
+			pr_warn("Can't set eth0 mode\n");
+	} else {
+		pr_warn("Can't disable eth0\n");
+	}
+
 	return 0;
 }
 late_initcall(skov_switch_test);
-- 
2.30.2


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


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

* [PATCH v4 5/8] ARM: boards: skov-imx6: fixup different DTS variants
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
                   ` (3 preceding siblings ...)
  2021-10-06  8:43 ` [PATCH v4 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

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

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index f42a0cad00..c09a2cd898 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -390,13 +390,51 @@ static void skov_imx6_no_switch(struct device_node *root)
 	}
 }
 
+static int skov_imx6_switch_port(struct device_node *root, const char *path)
+{
+	size_t size;
+	char *buf;
+	int ret;
+
+	/* size is, string + '\0' + port number */
+	size = strlen(path) + 2;
+	buf = xzalloc(size);
+	if (!buf)
+		return -ENOMEM;
+
+	ret = snprintf(buf, size, "%s0", path);
+	if (ret < 0)
+		return ret;
+
+	ret = eth_of_fixup_node_from_eth_device(root, buf, "eth0");
+	if (ret)
+		return ret;
+
+	ret = snprintf(buf, size, "%s1", path);
+	if (ret < 0)
+		return ret;
+
+	ret = eth2_of_fixup_node_individually(root, buf, "eth0",
+					      "state.ethaddr.eth2",
+					      "/state/ethaddr/eth2");
+	return ret;
+}
+
 static void skov_imx6_switch(struct device_node *root)
 {
-	eth_of_fixup_node_from_eth_device(root,
-			"/mdio-gpio/ksz8873@3/ports/ports@0", "eth0");
-	eth2_of_fixup_node_individually(root,
-		"/mdio-gpio/ksz8873@3/ports/ports@1", "eth0",
-		"state.ethaddr.eth2", "/state/ethaddr/eth2");
+	const char *old = "/mdio-gpio/ksz8873@3/ports/ports@";
+	const char *new = "/mdio/switch@0/ports/ports@";
+	int ret;
+
+	/* Old DTS variants (pre kernel mainline) use different path. Try first
+	 * the new variant, then fall back to the old one.
+	 */
+	ret = skov_imx6_switch_port(root, new);
+	if (ret) {
+		ret = skov_imx6_switch_port(root, old);
+		if (ret)
+			pr_err("Filed to set mac address\n");
+	}
 }
 
 static int skov_imx6_fixup(struct device_node *root, void *unused)
-- 
2.30.2


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


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

* [PATCH v4 6/8] ARM: boards: skov-imx6: start using deep-probe
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
                   ` (4 preceding siblings ...)
  2021-10-06  8:43 ` [PATCH v4 5/8] ARM: boards: skov-imx6: fixup different DTS variants Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 7/8] ARM: boards: skov-imx6: add defaultenv with eth1-discover script Oleksij Rempel
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Port Skov boards to the deep-propbe and reduce boot time by 100msec.

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

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index c09a2cd898..b91033afc1 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -2,16 +2,17 @@
 
 #define pr_fmt(fmt) "skov-imx6: " fmt
 
+#include <bootsource.h>
 #include <common.h>
-#include <init.h>
-#include <mach/bbu.h>
+#include <deep-probe.h>
 #include <environment.h>
-#include <bootsource.h>
 #include <globalvar.h>
-#include <net.h>
-#include <of_gpio.h>
 #include <gpio.h>
+#include <init.h>
 #include <linux/micrel_phy.h>
+#include <mach/bbu.h>
+#include <net.h>
+#include <of_gpio.h>
 
 #include "version.h"
 
@@ -489,10 +490,20 @@ static int skov_imx6_fixup(struct device_node *root, void *unused)
  */
 static void skov_init_board(const struct board_description *variant)
 {
+	struct device_node *gpio_np = NULL;
 	struct device_node *np;
 	char *environment_path, *envdev;
 	int ret;
 
+	gpio_np = of_find_node_by_name(NULL, "gpio@20b4000");
+	if (gpio_np) {
+		ret = of_device_ensure_probed(gpio_np);
+		if (ret)
+			pr_warn("Can't probe GPIO node\n");
+	} else {
+		pr_warn("Can't get GPIO node\n");
+	}
+
 	imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox",
 		BBU_HANDLER_FLAG_DEFAULT);
 
@@ -650,6 +661,7 @@ static __maybe_unused struct of_device_id skov_version_ids[] = {
 		/* sentinel */
 	}
 };
+BAREBOX_DEEP_PROBE_ENABLE(skov_version_ids);
 
 static struct driver_d skov_version_driver = {
 	.name = "skov-imx6",
-- 
2.30.2


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


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

* [PATCH v4 7/8] ARM: boards: skov-imx6: add defaultenv with eth1-discover script
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
                   ` (5 preceding siblings ...)
  2021-10-06  8:43 ` [PATCH v4 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-06  8:43 ` [PATCH v4 8/8] ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant Oleksij Rempel
  2021-10-11  9:36 ` [PATCH v4 0/8] add noswitch support for skov boards Sascha Hauer
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Add eth1-discover script to run USB detection if eth0 is disabled. The
eth0 will be automatically disabled if the no on-board switch is
detected.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/Makefile                        | 1 +
 arch/arm/boards/skov-imx6/board.c                         | 3 +++
 .../skov-imx6/defaultenv-skov-imx6/network/eth1-discover  | 8 ++++++++
 3 files changed, 12 insertions(+)
 create mode 100644 arch/arm/boards/skov-imx6/defaultenv-skov-imx6/network/eth1-discover

diff --git a/arch/arm/boards/skov-imx6/Makefile b/arch/arm/boards/skov-imx6/Makefile
index a5e85bc1e1..07b87ff11d 100644
--- a/arch/arm/boards/skov-imx6/Makefile
+++ b/arch/arm/boards/skov-imx6/Makefile
@@ -1,3 +1,4 @@
 obj-y += board.o
 lwl-y += lowlevel.o
 obj-pbl-y += version.o
+bbenv-y += defaultenv-skov-imx6
diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index b91033afc1..cd7b8e208d 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -5,6 +5,7 @@
 #include <bootsource.h>
 #include <common.h>
 #include <deep-probe.h>
+#include <envfs.h>
 #include <environment.h>
 #include <globalvar.h>
 #include <gpio.h>
@@ -651,6 +652,8 @@ static int skov_imx6_probe(struct device_d *dev)
 
 	skov_init_board(variant);
 
+	defaultenv_append_directory(defaultenv_skov_imx6);
+
 	return 0;
 }
 
diff --git a/arch/arm/boards/skov-imx6/defaultenv-skov-imx6/network/eth1-discover b/arch/arm/boards/skov-imx6/defaultenv-skov-imx6/network/eth1-discover
new file mode 100644
index 0000000000..e11a3f9006
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/defaultenv-skov-imx6/network/eth1-discover
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Some boards doesn't have a ETH port, but may have USB network attached
+if [ "$eth0.mode" != "disabled" ]; then
+	exit 0;
+fi
+
+usb
-- 
2.30.2


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


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

* [PATCH v4 8/8] ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
                   ` (6 preceding siblings ...)
  2021-10-06  8:43 ` [PATCH v4 7/8] ARM: boards: skov-imx6: add defaultenv with eth1-discover script Oleksij Rempel
@ 2021-10-06  8:43 ` Oleksij Rempel
  2021-10-11  9:36 ` [PATCH v4 0/8] add noswitch support for skov boards Sascha Hauer
  8 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2021-10-06  8:43 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

iMX6 Solo boards do not have HDMI so remove it to avoid time spending on
probing.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/lowlevel.c |  6 +++++-
 arch/arm/dts/Makefile                |  2 +-
 arch/arm/dts/imx6s-skov-imx6.dts     | 22 ++++++++++++++++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/imx6s-skov-imx6.dts

diff --git a/arch/arm/boards/skov-imx6/lowlevel.c b/arch/arm/boards/skov-imx6/lowlevel.c
index eab797faa1..ea6de36a36 100644
--- a/arch/arm/boards/skov-imx6/lowlevel.c
+++ b/arch/arm/boards/skov-imx6/lowlevel.c
@@ -618,6 +618,7 @@ static void skov_imx6_init(int cpu_type, unsigned board_variant)
 
 extern char __dtb_z_imx6q_skov_imx6_start[];
 extern char __dtb_z_imx6dl_skov_imx6_start[];
+extern char __dtb_z_imx6s_skov_imx6_start[];
 
 /* called twice: once for SDRAM setup only, second for devicetree setup */
 static noinline void skov_imx6_start(void)
@@ -640,8 +641,11 @@ static noinline void skov_imx6_start(void)
 	/* boot this platform (second call) */
 	switch (cpu_type) {
 	case IMX6_CPUTYPE_IMX6S:
+		pr_debug("Startup i.MX6S based system...\n");
+		imx6q_barebox_entry(__dtb_z_imx6s_skov_imx6_start);
+		break;
 	case IMX6_CPUTYPE_IMX6DL:
-		pr_debug("Startup i.MX6S/DL based system...\n");
+		pr_debug("Startup i.MX6DL based system...\n");
 		imx6q_barebox_entry(__dtb_z_imx6dl_skov_imx6_start);
 		break;
 	case IMX6_CPUTYPE_IMX6D:
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index ffa9fe88c1..23b668dcdd 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -114,7 +114,7 @@ lwl-$(CONFIG_MACH_SOLIDRUN_CUBOX) += dove-cubox-bb.dtb.o
 lwl-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += imx6dl-hummingboard.dtb.o imx6q-hummingboard.dtb.o \
 				imx6dl-hummingboard2.dtb.o imx6q-hummingboard2.dtb.o \
 				imx6q-h100.dtb.o
-lwl-$(CONFIG_MACH_SKOV_IMX6) += imx6dl-skov-imx6.dtb.o imx6q-skov-imx6.dtb.o
+lwl-$(CONFIG_MACH_SKOV_IMX6) += imx6s-skov-imx6.dtb.o imx6dl-skov-imx6.dtb.o imx6q-skov-imx6.dtb.o
 lwl-$(CONFIG_MACH_SKOV_ARM9CPU) += at91-skov-arm9cpu.dtb.o
 lwl-$(CONFIG_MACH_SEEED_ODYSSEY) += stm32mp157c-odyssey.dtb.o
 lwl-$(CONFIG_MACH_STM32MP15XX_DKX) += stm32mp157c-dk2.dtb.o stm32mp157a-dk1.dtb.o
diff --git a/arch/arm/dts/imx6s-skov-imx6.dts b/arch/arm/dts/imx6s-skov-imx6.dts
new file mode 100644
index 0000000000..9061563e45
--- /dev/null
+++ b/arch/arm/dts/imx6s-skov-imx6.dts
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2015 Juergen Borleis, Pengutronix <kernel@pengutronix.de>
+ */
+
+/dts-v1/;
+#include <arm/imx6dl.dtsi>
+#include "imx6dl.dtsi"
+#include "imx6qdl-skov-imx6.dtsi"
+
+/ {
+	model = "Skov IMX6";
+	compatible = "skov,imx6", "fsl,imx6dl";
+
+	chosen {
+		stdout-path = &uart2;
+	};
+};
+
+&hdmi {
+	status = "disabled";
+};
-- 
2.30.2


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


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

* Re: [PATCH v4 0/8] add noswitch support for skov boards
  2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
                   ` (7 preceding siblings ...)
  2021-10-06  8:43 ` [PATCH v4 8/8] ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant Oleksij Rempel
@ 2021-10-11  9:36 ` Sascha Hauer
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2021-10-11  9:36 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Wed, Oct 06, 2021 at 10:43:15AM +0200, Oleksij Rempel wrote:
> changes v4:
> - rename skov_no_switch to skov_have_switch
> - use xasprintf instead of xzallox + snprintf
> - use alias for ethernet0 node detection and make it compatible with the
>   old DTs versions.
> 
> changes v3:
> - add missing byte in the switch path generation
> - make sure it work with old devicetrees
> 
> Oleksij Rempel (8):
>   ARM: dts: skov-imx6: add USB nodes
>   ARM: boards: skov-imx6: fixup_machine_compatible() add optional root
>     node
>   ARM: boards: skov-imx6: add switch detection
>   ARM: boards: skov-imx6: disable eth0 for barebox if no switch is
>     detected
>   ARM: boards: skov-imx6: fixup different DTS variants
>   ARM: boards: skov-imx6: start using deep-probe
>   ARM: boards: skov-imx6: add defaultenv with eth1-discover script
>   ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant

Applied, thanks

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 |

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


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

end of thread, other threads:[~2021-10-11  9:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06  8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 3/8] ARM: boards: skov-imx6: add switch detection Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 5/8] ARM: boards: skov-imx6: fixup different DTS variants Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 7/8] ARM: boards: skov-imx6: add defaultenv with eth1-discover script Oleksij Rempel
2021-10-06  8:43 ` [PATCH v4 8/8] ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant Oleksij Rempel
2021-10-11  9:36 ` [PATCH v4 0/8] add noswitch support for skov boards Sascha Hauer

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