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/cm_t3517/cm_t3517.c | |
parent | 011f5c13f8b6734b0e34b016842a8b93b6902d30 (diff) |
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/cm_t3517/cm_t3517.c')
-rw-r--r-- | board/compulab/cm_t3517/cm_t3517.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/board/compulab/cm_t3517/cm_t3517.c b/board/compulab/cm_t3517/cm_t3517.c index 6abecc20af..cac1ad9ef1 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, |