aboutsummaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorAmjad Ouled-Ameur <aouledameur@baylibre.com>2021-10-29 16:08:17 +0200
committerTom Rini <trini@konsulko.com>2022-01-16 08:31:03 -0500
commit609983e981a0a7f053ee6f9f6cd2772226a33000 (patch)
tree747941ffda575cae26db20d7fa043c118a45d5bd /board
parentf44bcb9f0d73c13738b8f3e437bda75fda642ad7 (diff)
downloadu-boot-609983e981a0a7f053ee6f9f6cd2772226a33000.zip
u-boot-609983e981a0a7f053ee6f9f6cd2772226a33000.tar.gz
u-boot-609983e981a0a7f053ee6f9f6cd2772226a33000.tar.bz2
board: ti: am335x: Choose CPSW or PRUSS configuration based on jumper setting
The am335x-ice-v2 board's Ethernet ports can be configured in 'MII' or 'RMII' mode to be connected to 'PRUSS' or 'CPSW' Ethernet subsystems. This patch sets the environment variable 'ice_mii' to 'mii' or 'rmii' accordingly. Based on that we choose the appropriate board devicetree i.e. 'am335x-ice-v2.dtb' or 'am335x-ice-v2-prueth.dtb'. Since there are 2 Ethernet ports with 2 modes, there can be 4 configurations but for now we consider both ports in different modes to be an invalid configuration and prevent boot in that case. Signed-off-by: Roger Quadros <rogerq@ti.com> [Amjad: use overlay instead of using new am335x-ice-v2-prueth.dtb] Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com> Reviewed-by: Tom Rini <trini@konsulko.com> [trini: Make prueth_is_mii be marked __maybe_unused] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'board')
-rw-r--r--board/ti/am335x/board.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index e8555de..9b70670 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -11,6 +11,7 @@
#include <dm.h>
#include <env.h>
#include <errno.h>
+#include <hang.h>
#include <image.h>
#include <init.h>
#include <malloc.h>
@@ -38,6 +39,7 @@
#include <miiphy.h>
#include <cpsw.h>
#include <linux/bitops.h>
+#include <linux/compiler.h>
#include <linux/delay.h>
#include <power/tps65217.h>
#include <power/tps65910.h>
@@ -691,6 +693,8 @@ done:
}
#endif
+static bool __maybe_unused prueth_is_mii = true;
+
/*
* Basic board specific setup. Pinmux has been handled already.
*/
@@ -710,6 +714,8 @@ int board_init(void)
if (board_is_icev2()) {
int rv;
u32 reg;
+ bool eth0_is_mii = true;
+ bool eth1_is_mii = true;
REQUEST_AND_SET_GPIO(GPIO_PR1_MII_CTRL);
/* Make J19 status available on GPIO1_26 */
@@ -740,6 +746,7 @@ int board_init(void)
writel(reg, GPIO0_IRQSTATUS1); /* clear irq */
/* RMII mode */
printf("ETH0, CPSW\n");
+ eth0_is_mii = false;
} else {
/* MII mode */
printf("ETH0, PRU\n");
@@ -752,12 +759,21 @@ int board_init(void)
/* RMII mode */
printf("ETH1, CPSW\n");
gpio_set_value(GPIO_MUX_MII_CTRL, 1);
+ eth1_is_mii = false;
} else {
/* MII mode */
printf("ETH1, PRU\n");
cdce913_data.pdiv2 = 4; /* 25MHz PHY clk */
}
+ if (eth0_is_mii != eth1_is_mii) {
+ printf("Unsupported Ethernet port configuration\n");
+ printf("Both ports must be set as RMII or MII\n");
+ hang();
+ }
+
+ prueth_is_mii = eth0_is_mii;
+
/* disable rising edge IRQs */
reg = readl(GPIO0_RISINGDETECT) & ~BIT(11);
writel(reg, GPIO0_RISINGDETECT);
@@ -852,6 +868,8 @@ int board_late_init(void)
if (is_valid_ethaddr(mac_addr))
eth_env_set_enetaddr("eth1addr", mac_addr);
}
+
+ env_set("ice_mii", prueth_is_mii ? "mii" : "rmii");
#endif
if (!env_get("serial#")) {