1 From 83c00ee665b8dde813458b2b07cf97ce8409248d Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robert.marko@sartura.hr>
3 Date: Fri, 4 Aug 2023 22:39:06 +0200
4 Subject: [PATCH 3/3] arm: mvebu: eDPU: support new board revision
6 There is a new eDPU revision that uses Marvell 88E6361 switch onboard.
7 We can rely on detecting the switch to enable and fixup the Linux DTS
8 so a single DTS can be used.
10 There is currently no support for the 88E6361 switch and thus no working
11 networking in U-Boot, so we disable both ports.
13 Signed-off-by: Robert Marko <robert.marko@sartura.hr>
15 arch/arm/dts/armada-3720-eDPU-u-boot.dtsi | 13 ++-
16 arch/arm/dts/armada-3720-eDPU.dts | 47 ++++++++
17 board/Marvell/mvebu_armada-37xx/board.c | 125 ++++++++++++++++++++++
18 configs/eDPU_defconfig | 2 +
19 4 files changed, 182 insertions(+), 5 deletions(-)
21 --- a/arch/arm/dts/armada-3720-eDPU-u-boot.dtsi
22 +++ b/arch/arm/dts/armada-3720-eDPU-u-boot.dtsi
28 - /* G.hn does not work without additional configuration */
29 - status = "disabled";
40 + * eDPU v2 has a MV88E6361 switch on the MDIO bus and U-boot is used
41 + * to patch the Linux DTS if its found so enable MDIO by default.
46 --- a/arch/arm/dts/armada-3720-eDPU.dts
47 +++ b/arch/arm/dts/armada-3720-eDPU.dts
50 phy-mode = "2500base-x";
54 + * External MV88E6361 switch is only available on v2 of the board.
55 + * U-Boot will enable the MDIO bus and switch nodes.
58 + status = "disabled";
59 + pinctrl-names = "default";
60 + pinctrl-0 = <&smi_pins>;
62 + /* Actual device is MV88E6361 */
64 + compatible = "marvell,mv88e6190";
65 + #address-cells = <1>;
68 + status = "disabled";
71 + #address-cells = <1>;
77 + phy-mode = "2500base-x";
78 + managed = "in-band-status";
85 + phy-mode = "2500base-x";
86 + managed = "in-band-status";
92 + phy-mode = "2500base-x";
93 + managed = "in-band-status";
99 --- a/board/Marvell/mvebu_armada-37xx/board.c
100 +++ b/board/Marvell/mvebu_armada-37xx/board.c
105 +#include <fdt_support.h>
106 #include <asm/global_data.h>
108 #include <asm/arch/cpu.h>
109 @@ -49,6 +50,7 @@ DECLARE_GLOBAL_DATA_PTR;
110 /* Single-chip mode */
111 /* Switch Port Registers */
112 #define MVEBU_SW_LINK_CTRL_REG (1)
113 +#define MVEBU_SW_PORT_SWITCH_ID (3)
114 #define MVEBU_SW_PORT_CTRL_REG (4)
115 #define MVEBU_SW_PORT_BASE_VLAN (6)
117 @@ -56,6 +58,8 @@ DECLARE_GLOBAL_DATA_PTR;
118 #define MVEBU_G2_SMI_PHY_CMD_REG (24)
119 #define MVEBU_G2_SMI_PHY_DATA_REG (25)
121 +#define SWITCH_88E6361_PRODUCT_NUMBER 0x2610
124 * Memory Controller Registers
126 @@ -72,6 +76,27 @@ DECLARE_GLOBAL_DATA_PTR;
127 #define A3700_MC_CTRL2_SDRAM_TYPE_DDR3 2
128 #define A3700_MC_CTRL2_SDRAM_TYPE_DDR4 3
130 +static bool is_edpu_plus(void)
132 + struct udevice *bus;
136 + node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
137 + if (!ofnode_valid(node) ||
138 + uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus) ||
139 + device_probe(bus)) {
140 + printf("Cannot find MDIO bus\n");
144 + val = dm_mdio_read(bus, 0x0, MDIO_DEVAD_NONE, MVEBU_SW_PORT_SWITCH_ID);
145 + if (val == SWITCH_88E6361_PRODUCT_NUMBER)
151 int board_early_init_f(void)
154 @@ -353,6 +378,41 @@ static int espressobin_last_stage_init(v
158 +static int edpu_plus_last_stage_init(void)
160 + struct udevice *dev;
163 + if (is_edpu_plus()) {
164 + ret = uclass_get_device_by_name(UCLASS_ETH,
168 + device_remove(dev, DM_REMOVE_NORMAL);
169 + device_unbind(dev);
172 + /* Currently no networking support on the eDPU+ board */
173 + ret = uclass_get_device_by_name(UCLASS_ETH,
177 + device_remove(dev, DM_REMOVE_NORMAL);
178 + device_unbind(dev);
181 + ret = uclass_get_device_by_name(UCLASS_ETH,
185 + device_remove(dev, DM_REMOVE_NORMAL);
186 + device_unbind(dev);
193 /* Bring-up board-specific network stuff */
194 int last_stage_init(void)
196 @@ -360,6 +420,9 @@ int last_stage_init(void)
197 if (of_machine_is_compatible("globalscale,espressobin"))
198 return espressobin_last_stage_init();
200 + if (of_machine_is_compatible("methode,edpu"))
201 + return edpu_plus_last_stage_init();
206 @@ -460,12 +523,74 @@ static int espressobin_fdt_setup(void *b
210 +static int edpu_plus_fdt_setup(void *blob)
212 + const char *ports[] = { "downlink", "uplink" };
213 + uint8_t mac[ETH_ALEN];
217 + if (is_edpu_plus()) {
218 + ret = fdt_set_status_by_compatible(blob,
219 + "marvell,orion-mdio",
222 + printf("Failed to enable MDIO!\n");
224 + ret = fdt_set_status_by_alias(blob,
226 + FDT_STATUS_DISABLED);
228 + printf("Failed to disable ethernet1!\n");
230 + path = fdt_get_alias(blob, "ethernet0");
232 + do_fixup_by_path_string(blob, path, "phy-mode", "2500base-x");
234 + printf("Failed to update ethernet0 phy-mode to 2500base-x!\n");
236 + ret = fdt_set_status_by_compatible(blob,
237 + "marvell,mv88e6190",
240 + printf("Failed to enable MV88E6361!\n");
243 + * MAC-s for Uplink and Downlink ports are stored under
244 + * non standard variable names, so lets manually fixup the
245 + * switch port nodes to have the desired MAC-s.
247 + for (i = 0; i < 2; i++) {
248 + if (eth_env_get_enetaddr(ports[i], mac)) {
249 + do_fixup_by_prop(blob,
252 + strlen(ports[i]) + 1,
256 + do_fixup_by_prop(blob,
259 + strlen(ports[i]) + 1,
260 + "local-mac-address",
269 int ft_board_setup(void *blob, struct bd_info *bd)
271 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
272 if (of_machine_is_compatible("globalscale,espressobin"))
273 return espressobin_fdt_setup(blob);
275 + if (of_machine_is_compatible("methode,edpu"))
276 + return edpu_plus_fdt_setup(blob);
281 --- a/configs/eDPU_defconfig
282 +++ b/configs/eDPU_defconfig
283 @@ -17,12 +17,14 @@ CONFIG_DEBUG_UART=y
284 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
287 +CONFIG_OF_BOARD_SETUP=y
288 CONFIG_DISTRO_DEFAULTS=y
290 # CONFIG_DISPLAY_CPUINFO is not set
291 # CONFIG_DISPLAY_BOARDINFO is not set
292 CONFIG_DISPLAY_BOARDINFO_LATE=y
293 CONFIG_BOARD_EARLY_INIT_F=y
294 +CONFIG_LAST_STAGE_INIT=y
295 CONFIG_SYS_MAXARGS=32
296 CONFIG_SYS_PBSIZE=1048
297 # CONFIG_CMD_ELF is not set