Merge branch 'u-boot-ti/master' into 'u-boot-arm/master'
[platform/kernel/u-boot.git] / board / ti / am335x / board.c
index 013ad88..ed4229e 100644 (file)
@@ -44,7 +44,7 @@ static struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
 
 /* MII mode defines */
 #define MII_MODE_ENABLE                0x0
-#define RGMII_MODE_ENABLE      0xA
+#define RGMII_MODE_ENABLE      0x3A
 
 /* GPIO that controls power to DDR on EVM-SK */
 #define GPIO_DDR_VTT_EN                7
@@ -68,6 +68,11 @@ static inline int board_is_evm_sk(void)
        return !strncmp("A335X_SK", header.name, HDR_NAME_LEN);
 }
 
+static inline int board_is_idk(void)
+{
+       return !strncmp(header.config, "SKU#02", 6);
+}
+
 /*
  * Read header information from EEPROM into global structure.
  */
@@ -313,9 +318,31 @@ int board_init(void)
 
        gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
 
+       gpmc_init();
+
        return 0;
 }
 
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       char safe_string[HDR_NAME_LEN + 1];
+
+       /* Now set variables based on the header. */
+       strncpy(safe_string, (char *)header.name, sizeof(header.name));
+       safe_string[sizeof(header.name)] = 0;
+       setenv("board_name", safe_string);
+
+       strncpy(safe_string, (char *)header.version, sizeof(header.version));
+       safe_string[sizeof(header.version)] = 0;
+       setenv("board_rev", safe_string);
+#endif
+
+       return 0;
+}
+#endif
+
 #ifdef CONFIG_DRIVER_TI_CPSW
 static void cpsw_control(int enabled)
 {
@@ -354,9 +381,14 @@ static struct cpsw_platform_data cpsw_data = {
        .host_port_num          = 0,
        .version                = CPSW_CTRL_VERSION_2,
 };
+#endif
 
+#if defined(CONFIG_DRIVER_TI_CPSW) || \
+       (defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET))
 int board_eth_init(bd_t *bis)
 {
+       int rv, n = 0;
+#ifdef CONFIG_DRIVER_TI_CPSW
        uint8_t mac_addr[6];
        uint32_t mac_hi, mac_lo;
 
@@ -375,10 +407,10 @@ int board_eth_init(bd_t *bis)
                if (is_valid_ether_addr(mac_addr))
                        eth_setenv_enetaddr("ethaddr", mac_addr);
                else
-                       return -1;
+                       goto try_usbether;
        }
 
-       if (board_is_bone() || board_is_bone_lt()) {
+       if (board_is_bone() || board_is_bone_lt() || board_is_idk()) {
                writel(MII_MODE_ENABLE, &cdev->miisel);
                cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
                                PHY_INTERFACE_MODE_MII;
@@ -388,6 +420,20 @@ int board_eth_init(bd_t *bis)
                                PHY_INTERFACE_MODE_RGMII;
        }
 
-       return cpsw_register(&cpsw_data);
+       rv = cpsw_register(&cpsw_data);
+       if (rv < 0)
+               printf("Error %d registering CPSW switch\n", rv);
+       else
+               n += rv;
+#endif
+try_usbether:
+#if defined(CONFIG_USB_ETHER) && !defined(CONFIG_SPL_BUILD)
+       rv = usb_eth_initialize(bis);
+       if (rv < 0)
+               printf("Error %d registering USB_ETHER\n", rv);
+       else
+               n += rv;
+#endif
+       return n;
 }
 #endif