]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
omap3: cm-t3517: add Ethernet support
authorIgor Grinberg <grinberg@compulab.co.il>
Mon, 3 Nov 2014 09:32:26 +0000 (11:32 +0200)
committerTom Rini <trini@ti.com>
Thu, 6 Nov 2014 16:04:41 +0000 (11:04 -0500)
Add both EMAC and SMC911x support.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Reviewed-by: Tom Rini <trini@ti.com>
board/compulab/cm_t3517/cm_t3517.c
board/compulab/cm_t3517/mux.c
include/configs/cm_t3517.h

index 6abecc20afbbe1f3de6153905a2c37c05fd86d22..cac1ad9ef11d1ca5be5c100c6677a4795bac0b5e 100644 (file)
@@ -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,
index e1575a61bdfb60a313ef8d4f7734c1a2b30b721b..cb54c2c6bcf7b0081c0db22e5509a3c7ef5a378a 100644 (file)
@@ -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*/
 
index 046649db975989c9860fc71ceb978d11d109a71d..e623aac7f5c1bec104cc4aa2b7223cb56ec3ab44 100644 (file)
 #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       */
 #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