From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de, "Marek Behún" <kabel@kernel.org>
Subject: [PATCH u-boot-marvell 07/16] arm: mvebu: turris_omnia: Fix ethernet PHY reset gpio FDT fixup
Date: Tue, 18 Jun 2024 17:34:30 +0200 [thread overview]
Message-ID: <20240618153439.9518-8-kabel@kernel.org> (raw)
In-Reply-To: <20240618153439.9518-1-kabel@kernel.org>
For board revisions where the WAN ethernet PHY reset GPIO is controllable
via MCU we currently insert a phy-reset-gpios property into the ethernet
controller node. The mvneta driver parses this property and uses the
GPIO to reset the PHY.
But this phy-reset-gpios property is not a valid DT binding in upstream
kernel. Instead, a reset-gpios property should be inserted into the
ethernet PHY node. This correct DT binding is supported by the DM ETH PHY
U-Boot driver.
Insert the reset-gpios property into the WAN PHY node instead the
phy-reset-gpios property in WAN ETH node so that Linux will correctly use
the reset GPIO.
Enable the CONFIG_DM_ETH_PHY config option so that U-Boot will also use
the correct DT property.
Note: currently there are 4 ethernet controller drivers parsing the
wrong DT property: dwc_eth_qos, fex_mxc, mvneta and mvpp2. We should
convert all relevant device-trees to use reset-gpios so that we can get
rid of these drivers parsing this property.
Fixes: 1da53ae26afc ("arm: mvebu: turris_omnia: Add support for design with SW reset signals")
Signed-off-by: Marek Behún <kabel@kernel.org>
---
board/CZ.NIC/turris_omnia/turris_omnia.c | 44 ++++++++++++++----------
configs/turris_omnia_defconfig | 1 +
2 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 4ee1a394b0..100a991406 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -978,11 +978,21 @@ static int fixup_mcu_gpio_in_pcie_nodes(void *blob)
return 0;
}
-static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
+static int get_phy_wan_node_offset(const void *blob)
+{
+ u32 phy_wan_phandle;
+
+ phy_wan_phandle = fdt_getprop_u32_default(blob, "ethernet2", "phy-handle", 0);
+ if (!phy_wan_phandle)
+ return -FDT_ERR_NOTFOUND;
+
+ return fdt_node_offset_by_phandle(blob, phy_wan_phandle);
+}
+
+static int fixup_mcu_gpio_in_phy_wan_node(void *blob)
{
unsigned int mcu_phandle;
- int eth_wan_node;
- int ret;
+ int phy_wan_node, ret;
ret = fdt_increase_size(blob, 64);
if (ret < 0) {
@@ -990,21 +1000,17 @@ static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
return ret;
}
- eth_wan_node = fdt_path_offset(blob, "ethernet2");
- if (eth_wan_node < 0)
- return eth_wan_node;
+ phy_wan_node = get_phy_wan_node_offset(blob);
+ if (phy_wan_node < 0)
+ return phy_wan_node;
mcu_phandle = fdt_create_phandle_by_compatible(blob, "cznic,turris-omnia-mcu");
if (!mcu_phandle)
return -FDT_ERR_NOPHANDLES;
- /* insert: phy-reset-gpios = <&mcu 2 gpio GPIO_ACTIVE_LOW>; */
- ret = insert_mcu_gpio_prop(blob, eth_wan_node, "phy-reset-gpios",
- mcu_phandle, 2, ilog2(EXT_CTL_nRES_PHY), GPIO_ACTIVE_LOW);
- if (ret < 0)
- return ret;
-
- return 0;
+ /* insert: reset-gpios = <&mcu 2 gpio GPIO_ACTIVE_LOW>; */
+ return insert_mcu_gpio_prop(blob, phy_wan_node, "reset-gpios",
+ mcu_phandle, 2, ilog2(EXT_CTL_nRES_PHY), GPIO_ACTIVE_LOW);
}
static void fixup_atsha_node(void *blob)
@@ -1033,7 +1039,7 @@ int board_fix_fdt(void *blob)
{
if (omnia_mcu_has_feature(FEAT_PERIPH_MCU)) {
fixup_mcu_gpio_in_pcie_nodes(blob);
- fixup_mcu_gpio_in_eth_wan_node(blob);
+ fixup_mcu_gpio_in_phy_wan_node(blob);
}
fixup_msata_port_nodes(blob);
@@ -1218,14 +1224,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
int node;
/*
- * U-Boot's FDT blob contains phy-reset-gpios in ethernet2
- * node when MCU controls all peripherals resets.
+ * U-Boot's FDT blob contains reset-gpios in ethernet2 PHY node when MCU
+ * controls all peripherals resets.
* Fixup MCU GPIO nodes in PCIe and eth wan nodes in this case.
*/
- node = fdt_path_offset(gd->fdt_blob, "ethernet2");
- if (node >= 0 && fdt_getprop(gd->fdt_blob, node, "phy-reset-gpios", NULL)) {
+ node = get_phy_wan_node_offset(gd->fdt_blob);
+ if (node >= 0 && fdt_getprop(gd->fdt_blob, node, "reset-gpios", NULL)) {
fixup_mcu_gpio_in_pcie_nodes(blob);
- fixup_mcu_gpio_in_eth_wan_node(blob);
+ fixup_mcu_gpio_in_phy_wan_node(blob);
}
fixup_spi_nor_partitions(blob);
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 938ad88ae5..08e3e21215 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -101,6 +101,7 @@ CONFIG_PHY_ANEG_TIMEOUT=8000
CONFIG_PHY_MARVELL=y
CONFIG_PHY_FIXED=y
CONFIG_DM_DSA=y
+CONFIG_DM_ETH_PHY=y
CONFIG_PHY_GIGE=y
CONFIG_MV88E6XXX=y
CONFIG_MVNETA=y
--
2.44.2
next prev parent reply other threads:[~2024-06-18 15:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 15:34 [PATCH u-boot-marvell 00/16] Turris Omnia DDR training changes Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 01/16] arm: mvebu: turris_omnia: Disable ext4 write support in defconfig Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 02/16] ddr: marvell: a38x: debug: return from ddr3_tip_print_log() early if we won't print anything Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 03/16] ddr: marvell: a38x: debug: Remove unused variables Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 04/16] ddr: marvell: a38x: debug: Define DDR_VIEWER_TOOL variables only if needed, and make them static Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 05/16] ddr: marvell: a38x: debug: Allow compiling with immutable debug settings to reduce binary size Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 06/16] arm: mvebu: turris_omnia: Enable immutable debug settings in DDR3 training by default Marek Behún
2024-06-18 15:34 ` Marek Behún [this message]
2024-06-18 15:34 ` [PATCH u-boot-marvell 08/16] arm: mvebu: turris_omnia: Implement EEPROM layout for the 'eeprom' command Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 09/16] arm: mvebu: turris_omnia: Enable " Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 10/16] arm: mvebu: turris_omnia: Extend EEPROM info structure Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 11/16] arm: mvebu: turris_omnia: Read DDR speed from EEPROM Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 12/16] ddr: marvell: a38x: Import old DDR training code from 2017 version of U-Boot Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 13/16] ddr: marvell: a38x: old: Fix some compiler warning of the old code Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 14/16] ddr: marvell: a38x: old: Backport immutable debug settings Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 15/16] arm: mvebu: a38x: Add optional support for using old DDR3 training code Marek Behún
2024-06-18 15:34 ` [PATCH u-boot-marvell 16/16] arm: mvebu: turris_omnia: Support old DDR3 training Marek Behún
2024-07-08 14:16 ` [PATCH u-boot-marvell 00/16] Turris Omnia DDR training changes Stefan Roese
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=20240618153439.9518-8-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.