[U-Boot] [PATCH 10/11] omap3: cm-t3517: add Ethernet support

Igor Grinberg grinberg at compulab.co.il
Mon Nov 3 10:32:26 CET 2014


Add both EMAC and SMC911x support.

Signed-off-by: Igor Grinberg <grinberg at compulab.co.il>
---
 board/compulab/cm_t3517/cm_t3517.c | 89 ++++++++++++++++++++++++++++++++++++++
 board/compulab/cm_t3517/mux.c      | 19 ++++++++
 include/configs/cm_t3517.h         | 11 +++++
 3 files changed, 119 insertions(+)

diff --git a/board/compulab/cm_t3517/cm_t3517.c b/board/compulab/cm_t3517/cm_t3517.c
index 6abecc2..cac1ad9 100644
--- a/board/compulab/cm_t3517/cm_t3517.c
+++ b/board/compulab/cm_t3517/cm_t3517.c
@@ -8,6 +8,8 @@
 
 #include <common.h>
 #include <status_led.h>
+#include <net.h>
+#include <netdev.h>
 #include <usb.h>
 #include <mmc.h>
 #include <linux/compiler.h>
@@ -23,6 +25,7 @@
 #include <asm/ehci-omap.h>
 
 #include "../common/common.h"
+#include "../common/eeprom.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -113,6 +116,92 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#ifdef CONFIG_DRIVER_TI_EMAC
+#define CONTROL_EFUSE_EMAC_LSB  0x48002380
+#define CONTROL_EFUSE_EMAC_MSB  0x48002384
+
+static int am3517_get_efuse_enetaddr(u8 *enetaddr)
+{
+	u32 lsb = __raw_readl(CONTROL_EFUSE_EMAC_LSB);
+	u32 msb = __raw_readl(CONTROL_EFUSE_EMAC_MSB);
+
+	enetaddr[0] = (u8)((msb >> 16) & 0xff);
+	enetaddr[1] = (u8)((msb >> 8)  & 0xff);
+	enetaddr[2] = (u8)(msb & 0xff);
+	enetaddr[3] = (u8)((lsb >> 16) & 0xff);
+	enetaddr[4] = (u8)((lsb >> 8)  & 0xff);
+	enetaddr[5] = (u8)(lsb & 0xff);
+
+	return is_valid_ether_addr(enetaddr);
+}
+
+static inline int cm_t3517_init_emac(bd_t *bis)
+{
+	int ret = cpu_eth_init(bis);
+
+	if (ret > 0)
+		return ret;
+
+	printf("Failed initializing EMAC! ");
+	return 0;
+}
+#else /* !CONFIG_DRIVER_TI_EMAC */
+static inline int am3517_get_efuse_enetaddr(u8 *enetaddr) { return 1; }
+static inline int cm_t3517_init_emac(bd_t *bis) { return 0; }
+#endif /* CONFIG_DRIVER_TI_EMAC */
+
+/*
+ * Routine: handle_mac_address
+ * Description: prepare MAC address for on-board Ethernet.
+ */
+static int cm_t3517_handle_mac_address(void)
+{
+	unsigned char enetaddr[6];
+	int ret;
+
+	ret = eth_getenv_enetaddr("ethaddr", enetaddr);
+	if (ret)
+		return 0;
+
+	ret = cl_eeprom_read_mac_addr(enetaddr);
+	if (ret) {
+		ret = am3517_get_efuse_enetaddr(enetaddr);
+		if (ret)
+			return ret;
+	}
+
+	if (!is_valid_ether_addr(enetaddr))
+		return -1;
+
+	return eth_setenv_enetaddr("ethaddr", enetaddr);
+}
+
+#define SB_T35_ETH_RST_GPIO 164
+
+/*
+ * Routine: board_eth_init
+ * Description: initialize module and base-board Ethernet chips
+ */
+int board_eth_init(bd_t *bis)
+{
+	int rc = 0, rc1 = 0;
+
+	rc1 = cm_t3517_handle_mac_address();
+	if (rc1)
+		printf("No MAC address found! ");
+
+	rc1 = cm_t3517_init_emac(bis);
+	if (rc1 > 0)
+		rc++;
+
+	rc1 = cl_omap3_smc911x_init(0, 4, CONFIG_SMC911X_BASE,
+				    NULL, SB_T35_ETH_RST_GPIO);
+	if (rc1 > 0)
+		rc++;
+
+	return rc;
+}
+
 #ifdef CONFIG_USB_EHCI_OMAP
 static struct omap_usbhs_board_data cm_t3517_usbhs_bdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/board/compulab/cm_t3517/mux.c b/board/compulab/cm_t3517/mux.c
index e1575a6..cb54c2c 100644
--- a/board/compulab/cm_t3517/mux.c
+++ b/board/compulab/cm_t3517/mux.c
@@ -83,6 +83,9 @@ void set_muxconf_regs(void)
 	MUX_VAL(CP(GPMC_D15),		(IEN  | PTU | EN  | M0));
 	MUX_VAL(CP(GPMC_NCS0),		(IDIS | PTU | EN  | M0));
 
+	/* SB-T35 Ethernet */
+	MUX_VAL(CP(GPMC_NCS4),		(IEN  | PTU | EN  | M0));
+
 	/* SB-T35 SD/MMC WP GPIO59 */
 	MUX_VAL(CP(GPMC_CLK),		(IEN  | PTU | EN  | M4)); /*GPIO_59*/
 	MUX_VAL(CP(GPMC_NWE),		(IDIS | PTD | DIS | M0));
@@ -93,12 +96,16 @@ void set_muxconf_regs(void)
 	MUX_VAL(CP(GPMC_NBE1),		(IDIS | PTU | EN  | M4)); /*GPIO_61*/
 	MUX_VAL(CP(GPMC_NWP),		(IEN  | PTD | DIS | M0));
 	MUX_VAL(CP(GPMC_WAIT0),		(IEN  | PTU | EN  | M0));
+	/* SB-T35 Ethernet IRQ GPIO65 */
+	MUX_VAL(CP(GPMC_WAIT3),		(IEN  | PTU | EN  | M4)); /*GPIO_65*/
 
 	/* UART3 Console */
 	MUX_VAL(CP(UART3_RX_IRRX),	(IEN  | PTD | DIS | M0));
 	MUX_VAL(CP(UART3_TX_IRTX),	(IDIS | PTD | DIS | M0));
 	/* RTC V3020 nCS GPIO163 */
 	MUX_VAL(CP(UART3_CTS_RCTX),	(IEN  | PTU | EN  | M4)); /*GPIO_163*/
+	/* SB-T35 Ethernet nRESET GPIO164 */
+	MUX_VAL(CP(UART3_RTS_SD),	(IDIS | PTU | EN  | M4)); /*GPIO_164*/
 
 	/* SB-T35 SD/MMC CD GPIO144 */
 	MUX_VAL(CP(UART2_CTS),		(IEN  | PTU | EN  | M4)); /*GPIO_144*/
@@ -128,6 +135,18 @@ void set_muxconf_regs(void)
 	/* CM-T3517 USB HUB Reset GPIO152 */
 	MUX_VAL(CP(MCBSP4_CLKX),	(IDIS | PTD | DIS | M4)); /*GPIO_152*/
 
+	/* RMII */
+	MUX_VAL(CP(RMII_MDIO_DATA),	(IEN  | PTU | EN  | M0));
+	MUX_VAL(CP(RMII_MDIO_CLK),	(M0));
+	MUX_VAL(CP(RMII_RXD0),		(IEN  | PTD | DIS | M0));
+	MUX_VAL(CP(RMII_RXD1),		(IEN  | PTD | DIS | M0));
+	MUX_VAL(CP(RMII_CRS_DV),	(IEN  | PTD | DIS | M0));
+	MUX_VAL(CP(RMII_RXER),		(IEN  | PTD | DIS | M0));
+	MUX_VAL(CP(RMII_TXD0),		(IDIS | M0));
+	MUX_VAL(CP(RMII_TXD1),		(IDIS | M0));
+	MUX_VAL(CP(RMII_TXEN),		(IDIS | M0));
+	MUX_VAL(CP(RMII_50MHZ_CLK),	(IEN  | PTU | DIS | M0));
+
 	/* Green LED GPIO186 */
 	MUX_VAL(CP(SYS_CLKOUT2),	(IDIS | PTU | DIS | M4)); /*GPIO_186*/
 
diff --git a/include/configs/cm_t3517.h b/include/configs/cm_t3517.h
index 1c2d1f4..1d35df9 100644
--- a/include/configs/cm_t3517.h
+++ b/include/configs/cm_t3517.h
@@ -132,6 +132,8 @@
 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
 #define CONFIG_CMD_NAND		/* NAND support			*/
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PING
 #define CONFIG_CMD_GPIO
 
 #undef CONFIG_CMD_FLASH		/* flinfo, erase, protect	*/
@@ -272,6 +274,15 @@
 #define CONFIG_ENV_OFFSET		SMNAND_ENV_OFFSET
 #define CONFIG_ENV_ADDR			SMNAND_ENV_OFFSET
 
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_DRIVER_TI_EMAC
+#define CONFIG_DRIVER_TI_EMAC_USE_RMII
+#define CONFIG_MII
+#define CONFIG_SMC911X
+#define CONFIG_SMC911X_32_BIT
+#define CONFIG_SMC911X_BASE	(0x2C000000 + (16 << 20))
+#endif /* CONFIG_CMD_NET */
+
 /* additions for new relocation code, must be added to all boards */
 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
 #define CONFIG_SYS_INIT_RAM_ADDR	0x4020f800
-- 
2.0.4



More information about the U-Boot mailing list