DistroKit Mailinglist
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: distrokit@pengutronix.de
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [DistroKit] [PATCH 2/2] v7a: barebox: cherry-pick CPSW/Linux reboot fixes from master
Date: Sat,  8 Jan 2022 08:57:23 +0100	[thread overview]
Message-ID: <20220108075723.432333-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220108075723.432333-1-a.fatoum@pengutronix.de>

The upstream device tree change addressed by the previous commit
also made it into barebox and broke Beaglebone networking there.
This is fixed in master, so import the patch.

It was also reported that bumping bumping up core clock frequency for
faster boot times broke reboot from within Linux.

This might be brown out resulting from Linux scaling down the
voltage and Linux system reset not affecting the PMIC. Until that's
resolved, barebox master reverts the overclocking, so import that patch
as well. Both patches are scheduled to appear in v2022.01.0.

Fixes: 949c5ef2 ("v7a: barebox: version bump v2021.08.0 → v2021.11.0") # CPSW
Fixes: afdae878 ("v7a: barebox: version bump v2021.05.0 → v2021.07.0") # reset
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 ...port-for-new-binding-in-Linux-v5.15-.patch | 210 ++++++++++++++++++
 ...-beaglebone-init-MPU-speed-to-800Mhz.patch |  45 ++++
 .../patches/barebox-2021.11.0/series          |   2 +
 3 files changed, 257 insertions(+)
 create mode 100644 configs/platform-v7a/patches/barebox-2021.11.0/0001-net-cpsw-add-support-for-new-binding-in-Linux-v5.15-.patch
 create mode 100644 configs/platform-v7a/patches/barebox-2021.11.0/0002-Revert-ARM-beaglebone-init-MPU-speed-to-800Mhz.patch
 create mode 100644 configs/platform-v7a/patches/barebox-2021.11.0/series

diff --git a/configs/platform-v7a/patches/barebox-2021.11.0/0001-net-cpsw-add-support-for-new-binding-in-Linux-v5.15-.patch b/configs/platform-v7a/patches/barebox-2021.11.0/0001-net-cpsw-add-support-for-new-binding-in-Linux-v5.15-.patch
new file mode 100644
index 000000000000..287f052d5fd2
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2021.11.0/0001-net-cpsw-add-support-for-new-binding-in-Linux-v5.15-.patch
@@ -0,0 +1,210 @@
+From ed7f3fd5b5e2088f04d2f5d615d71cf6e6507509 Mon Sep 17 00:00:00 2001
+From: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Date: Fri, 3 Dec 2021 21:50:35 +0100
+Subject: [PATCH 1/2] net: cpsw: add support for new binding in Linux v5.15-rc1
+ DTs
+
+As is customary, upstream OMAP DTs have yet again added a new binding
+breaking compatibility with a barebox driver. This time, the old Ethernet
+node was disabled in favor of a new node that is matched by the new Linux
+cpsw driver introduced with Linux commit ed3525eda4c4 ("net: ethernet:
+ti: introduce cpsw switchdev based driver part 1 - dual-emac").
+
+Add support for the new binding to restore working Beaglebone Black
+networking. These changes have been tested against both the old and new
+bindings.
+
+Fixes: 618948e4e5b3 ("dts: update to v5.15-rc1")
+Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Link: https://lore.barebox.org/20211203205035.555285-1-a.fatoum@pengutronix.de
+Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
+---
+ drivers/net/cpsw.c | 120 +++++++++++++++++++++++++++++++++------------
+ 1 file changed, 89 insertions(+), 31 deletions(-)
+
+diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
+index 4a8f9e67d6f0..6725c7b9bdb4 100644
+--- a/drivers/net/cpsw.c
++++ b/drivers/net/cpsw.c
+@@ -592,7 +592,12 @@ static int cpsw_mdio_probe(struct device_d *dev)
+ 
+ 	priv = xzalloc(sizeof(*priv));
+ 
++	/* If we can't request I/O memory region, we'll assume parent did
++	 * it for us
++	 */
+ 	iores = dev_request_mem_resource(dev, 0);
++	if (IS_ERR(iores) && PTR_ERR(iores) == -EBUSY)
++		iores = dev_get_resource(dev, IORESOURCE_MEM, 0);
+ 	if (IS_ERR(iores))
+ 		return PTR_ERR(iores);
+ 	priv->mdio_regs = IOMEM(iores->start);
+@@ -1214,11 +1219,27 @@ static void cpsw_gmii_sel_am335x(struct cpsw_slave *slave)
+ 	writel(reg, phy_sel_addr);
+ }
+ 
+-static int cpsw_probe_dt(struct cpsw_priv *priv)
++static void cpsw_add_slave(struct cpsw_slave *slave, struct device_node *child, int i)
++{
++	uint32_t phy_id[2] = {-1, -1};
++	int ret;
++
++	if (!of_find_node_by_name(child, "fixed-link")) {
++		ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
++		if (!ret)
++			dev_warn(slave->cpsw->dev, "phy_id is deprecated, use phy-handle\n");
++	}
++
++	slave->dev.device_node = child;
++	slave->phy_id = phy_id[1];
++	slave->phy_if = of_get_phy_mode(child);
++	slave->slave_num = i;
++}
++
++static int cpsw_legacy_probe_dt(struct cpsw_priv *priv)
+ {
+ 	struct device_d *dev = priv->dev;
+ 	struct device_node *np = dev->device_node, *child;
+-	struct device_node *physel;
+ 	int ret, i = 0;
+ 
+ 	ret = of_property_read_u32(np, "slaves", &priv->num_slaves);
+@@ -1227,15 +1248,6 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
+ 
+ 	priv->slaves = xzalloc(sizeof(struct cpsw_slave) * priv->num_slaves);
+ 
+-	physel = of_find_compatible_node(NULL, NULL, "ti,am3352-phy-gmii-sel");
+-	if (!physel) {
+-		dev_err(dev, "Cannot find ti,am3352-phy-gmii-sel node\n");
+-		return -EINVAL;
+-	}
+-	ret = cpsw_phy_sel_init(priv, physel);
+-	if (ret)
+-		return ret;
+-
+ 	for_each_child_of_node(np, child) {
+ 		if (of_device_is_compatible(child, "ti,davinci_mdio")) {
+ 			ret = of_pinctrl_select_state_default(child);
+@@ -1244,29 +1256,73 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
+ 		}
+ 
+ 		if (i < priv->num_slaves && !strncmp(child->name, "slave", 5)) {
+-			struct cpsw_slave *slave = &priv->slaves[i];
+-			uint32_t phy_id[2] = {-1, -1};
++			cpsw_add_slave(&priv->slaves[i], child, i);
++			i++;
++		}
++	}
+ 
+-			if (!of_find_node_by_name(child, "fixed-link")) {
+-				ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
+-				if (!ret)
+-					dev_warn(dev, "phy_id is deprecated, use phy-handle\n");
+-			}
++	return 0;
++}
++
++static int cpsw_switch_probe_dt(struct cpsw_priv *priv)
++{
++	struct device_d *dev = priv->dev;
++	struct device_node *np = dev->device_node, *child;
++	struct device_node *ports = NULL;
++	int ret, i = 0;
+ 
+-			slave->dev.device_node = child;
+-			slave->phy_id = phy_id[1];
+-			slave->phy_if = of_get_phy_mode(child);
+-			slave->slave_num = i;
++	for_each_child_of_node(np, child) {
++		if (of_device_is_compatible(child, "ti,davinci_mdio")) {
++			ret = of_pinctrl_select_state_default(child);
++			if (ret)
++				return ret;
++		}
+ 
+-			i++;
++		if (!strcmp(child->name, "ethernet-ports")) {
++			ports = child;
++			priv->num_slaves = of_get_available_child_count(ports);
+ 		}
+ 	}
+ 
+-	for (i = 0; i < priv->num_slaves; i++) {
+-		struct cpsw_slave *slave = &priv->slaves[i];
++	if (!ports)
++		return -EINVAL;
++
++	priv->slaves = xzalloc(sizeof(struct cpsw_slave) * priv->num_slaves);
++
++	for_each_available_child_of_node(ports, child) {
++		cpsw_add_slave(&priv->slaves[i], child, i);
++		i++;
++	}
++
++	return 0;
++}
+ 
+-		cpsw_gmii_sel_am335x(slave);
++static int cpsw_probe_dt(struct cpsw_priv *priv)
++{
++	struct device_d *dev = priv->dev;
++	struct device_node *physel;
++	int (*probe_slaves_dt)(struct cpsw_priv *priv);
++	int ret, i = 0;
++
++	physel = of_find_compatible_node(NULL, NULL, "ti,am3352-phy-gmii-sel");
++	if (!physel) {
++		dev_err(dev, "Cannot find ti,am3352-phy-gmii-sel node\n");
++		return -EINVAL;
+ 	}
++	ret = cpsw_phy_sel_init(priv, physel);
++	if (ret)
++		return ret;
++
++	probe_slaves_dt = device_get_match_data(dev);
++	if (!probe_slaves_dt)
++		return -EINVAL;
++
++	ret = probe_slaves_dt(priv);
++	if (ret < 0)
++		return ret;
++
++	for (i = 0; i < priv->num_slaves; i++)
++		cpsw_gmii_sel_am335x(&priv->slaves[i]);
+ 
+ 	return 0;
+ }
+@@ -1282,15 +1338,15 @@ static int cpsw_probe(struct device_d *dev)
+ 
+ 	dev_dbg(dev, "* %s\n", __func__);
+ 
+-	ret = of_platform_populate(dev->device_node, NULL, dev);
+-	if (ret)
+-		return ret;
+-
+ 	iores = dev_request_mem_resource(dev, 0);
+ 	if (IS_ERR(iores))
+ 		return PTR_ERR(iores);
+ 	regs = IOMEM(iores->start);
+ 
++	ret = of_platform_populate(dev->device_node, NULL, dev);
++	if (ret)
++		return ret;
++
+ 	priv = xzalloc(sizeof(*priv));
+ 	priv->dev = dev;
+ 
+@@ -1371,7 +1427,9 @@ static void cpsw_remove(struct device_d *dev)
+ 
+ static __maybe_unused struct of_device_id cpsw_dt_ids[] = {
+ 	{
+-		.compatible = "ti,cpsw",
++		.compatible = "ti,cpsw", .data = cpsw_legacy_probe_dt
++	}, {
++		.compatible = "ti,cpsw-switch", .data = cpsw_switch_probe_dt
+ 	}, {
+ 		/* sentinel */
+ 	}
+-- 
+2.30.2
+
diff --git a/configs/platform-v7a/patches/barebox-2021.11.0/0002-Revert-ARM-beaglebone-init-MPU-speed-to-800Mhz.patch b/configs/platform-v7a/patches/barebox-2021.11.0/0002-Revert-ARM-beaglebone-init-MPU-speed-to-800Mhz.patch
new file mode 100644
index 000000000000..10bfb837d61f
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2021.11.0/0002-Revert-ARM-beaglebone-init-MPU-speed-to-800Mhz.patch
@@ -0,0 +1,45 @@
+From 9c1a78f959dd751c9b8ceb31e44926afc89d7769 Mon Sep 17 00:00:00 2001
+From: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Date: Fri, 3 Dec 2021 19:51:54 +0100
+Subject: [PATCH 2/2] Revert "ARM: beaglebone: init MPU speed to 800Mhz"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Commit 130c7d6715e9 ("ARM: beaglebone: init MPU speed to 800Mhz") causes
+warm reboot from within Linux v5.14.0 to no longer succeed.
+barebox MLO is entered, but hangs. Reset from within barebox is
+unaffected.
+This can be reproduced using DistroKit 949c5ef2b9a6 ("v7a: barebox:
+version bump v2021.08.0 → v2021.11.0") on a Beaglebone Black.
+Until that's figured out, revert the commit; functional reboot is more
+important than the quicker boot up.
+
+This reverts commit 130c7d6715e932a1e0b3e026fea97f700ab33ea9.
+
+Fixes: 130c7d6715e9 ("ARM: beaglebone: init MPU speed to 800Mhz")
+Reported-by: arwie # IRC
+Cc: Marc Reilly <marc@cpdesign.com.au>
+Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Link: https://lore.barebox.org/20211203185154.388145-1-a.fatoum@pengutronix.de
+Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
+---
+ arch/arm/boards/beaglebone/lowlevel.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boards/beaglebone/lowlevel.c b/arch/arm/boards/beaglebone/lowlevel.c
+index 31211448f5e8..91d143e4150b 100644
+--- a/arch/arm/boards/beaglebone/lowlevel.c
++++ b/arch/arm/boards/beaglebone/lowlevel.c
+@@ -126,7 +126,7 @@ static noinline int beaglebone_sram_init(void)
+ 
+ 	/* Setup the PLLs and the clocks for the peripherals */
+ 	if (is_beaglebone_black()) {
+-		am33xx_pll_init(MPUPLL_M_800, DDRPLL_M_400);
++		am33xx_pll_init(MPUPLL_M_500, DDRPLL_M_400);
+ 		am335x_sdram_init(0x18B, &ddr3_cmd_ctrl, &ddr3_regs,
+ 				&ddr3_data);
+ 	} else {
+-- 
+2.30.2
+
diff --git a/configs/platform-v7a/patches/barebox-2021.11.0/series b/configs/platform-v7a/patches/barebox-2021.11.0/series
new file mode 100644
index 000000000000..ba7c27d1e5e6
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2021.11.0/series
@@ -0,0 +1,2 @@
+0001-net-cpsw-add-support-for-new-binding-in-Linux-v5.15-.patch
+0002-Revert-ARM-beaglebone-init-MPU-speed-to-800Mhz.patch
-- 
2.30.2


_______________________________________________
DistroKit mailing list
DistroKit@pengutronix.de

  parent reply	other threads:[~2022-01-08  7:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08  7:57 [DistroKit] [PATCH 0/2] v7a: fix beaglebone networking Ahmad Fatoum
2022-01-08  7:57 ` [DistroKit] [PATCH 1/2] v7a: kernel: enable new TI CPSW switchdev driver Ahmad Fatoum
2022-01-08  8:01   ` Ahmad Fatoum
2022-01-08  7:57 ` Ahmad Fatoum [this message]
2022-01-08  9:37 ` [DistroKit] [PATCH 0/2] v7a: fix beaglebone networking Robert Schwebel
2022-01-09  5:45 ` Sohaib Mohamed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220108075723.432333-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=distrokit@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox