diff options
author | Igor Grinberg <grinberg@compulab.co.il> | 2014-11-03 11:32:26 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-11-06 11:04:41 -0500 |
commit | a8a78c74506454cc4a82493776e8b82eec56a755 (patch) | |
tree | 01a3bd3f77d9e2d794b10963426fb9de5547aa21 /board/compulab | |
parent | 011f5c13f8b6734b0e34b016842a8b93b6902d30 (diff) | |
download | u-boot-imx-a8a78c74506454cc4a82493776e8b82eec56a755.zip u-boot-imx-a8a78c74506454cc4a82493776e8b82eec56a755.tar.gz u-boot-imx-a8a78c74506454cc4a82493776e8b82eec56a755.tar.bz2 |
omap3: cm-t3517: add Ethernet support
Add both EMAC and SMC911x support.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Reviewed-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'board/compulab')
-rw-r--r-- | board/compulab/cm_t3517/cm_t3517.c | 89 | ||||
-rw-r--r-- | board/compulab/cm_t3517/mux.c | 19 |
2 files changed, 108 insertions, 0 deletions
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*/ |