]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/ti/dra7xx/evm.c
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
[karo-tx-uboot.git] / board / ti / dra7xx / evm.c
index 1b60b8f672eaa4ca7116365730996acad389d51c..65222419ebbdb9b0e3a2c120fa27b56a9138a779 100644 (file)
  */
 #include <common.h>
 #include <palmas.h>
+#include <sata.h>
+#include <asm/gpio.h>
+#include <asm/arch/gpio.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sata.h>
+#include <environment.h>
 
 #include "mux_data.h"
 
@@ -24,6 +28,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/* GPIO 7_11 */
+#define GPIO_DDR_VTT_EN 203
+
 const struct omap_sysinfo sysinfo = {
        "Board: DRA7xx\n"
 };
@@ -80,19 +87,12 @@ int board_init(void)
 
 int board_late_init(void)
 {
-       omap_sata_init();
-       return 0;
-}
-
-/**
- * @brief misc_init_r - Configure EVM board specific configurations
- * such as power configurations, ethernet initialization as phase2 of
- * boot sequence
- *
- * @return 0
- */
-int misc_init_r(void)
-{
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       if (omap_revision() == DRA722_ES1_0)
+               setenv("board_name", "dra72x");
+       else
+               setenv("board_name", "dra7xx");
+#endif
        return 0;
 }
 
@@ -123,6 +123,24 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
+int spl_start_uboot(void)
+{
+       /* break into full u-boot on 'c' */
+       if (serial_tstc() && serial_getc() == 'c')
+               return 1;
+
+#ifdef CONFIG_SPL_ENV_SUPPORT
+       env_init();
+       env_relocate_spec();
+       if (getenv_yesno("boot_os") != 1)
+               return 1;
+#endif
+
+       return 0;
+}
+#endif
+
 #ifdef CONFIG_DRIVER_TI_CPSW
 
 /* Delay value to add to calibrated value */
@@ -137,6 +155,8 @@ int board_mmc_init(bd_t *bis)
 #define VIN2A_D15_DLY_VAL              ((0x4 << 5) + 0x0)
 #define VIN2A_D14_DLY_VAL              ((0x4 << 5) + 0x0)
 
+extern u32 *const omap_si_rev;
+
 static void cpsw_control(int enabled)
 {
        /* VTP can be added here */
@@ -148,12 +168,12 @@ static struct cpsw_slave_data cpsw_slaves[] = {
        {
                .slave_reg_ofs  = 0x208,
                .sliver_reg_ofs = 0xd80,
-               .phy_id         = 0,
+               .phy_addr       = 2,
        },
        {
                .slave_reg_ofs  = 0x308,
                .sliver_reg_ofs = 0xdc0,
-               .phy_id         = 1,
+               .phy_addr       = 3,
        },
 };
 
@@ -163,7 +183,7 @@ static struct cpsw_platform_data cpsw_data = {
        .mdio_div               = 0xff,
        .channels               = 8,
        .cpdma_reg_ofs          = 0x800,
-       .slaves                 = 1,
+       .slaves                 = 2,
        .slave_data             = cpsw_slaves,
        .ale_reg_ofs            = 0xd00,
        .ale_entries            = 1024,
@@ -215,10 +235,28 @@ int board_eth_init(bd_t *bis)
                if (is_valid_ether_addr(mac_addr))
                        eth_setenv_enetaddr("ethaddr", mac_addr);
        }
+
+       mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
+       mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
+       mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
+       mac_addr[1] = (mac_hi & 0xFF00) >> 8;
+       mac_addr[2] = mac_hi & 0xFF;
+       mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
+       mac_addr[4] = (mac_lo & 0xFF00) >> 8;
+       mac_addr[5] = mac_lo & 0xFF;
+
+       if (!getenv("eth1addr")) {
+               if (is_valid_ether_addr(mac_addr))
+                       eth_setenv_enetaddr("eth1addr", mac_addr);
+       }
+
        ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
        ctrl_val |= 0x22;
        writel(ctrl_val, (*ctrl)->control_core_control_io1);
 
+       if (*omap_si_rev == DRA722_ES1_0)
+               cpsw_data.active_slave = 1;
+
        ret = cpsw_register(&cpsw_data);
        if (ret < 0)
                printf("Error %d registering CPSW switch\n", ret);
@@ -226,3 +264,29 @@ int board_eth_init(bd_t *bis)
        return ret;
 }
 #endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+/* VTT regulator enable */
+static inline void vtt_regulator_enable(void)
+{
+       if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
+               return;
+
+       /* Do not enable VTT for DRA722 */
+       if (omap_revision() == DRA722_ES1_0)
+               return;
+
+       /*
+        * EVM Rev G and later use gpio7_11 for DDR3 termination.
+        * This is safe enough to do on older revs.
+        */
+       gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
+       gpio_direction_output(GPIO_DDR_VTT_EN, 1);
+}
+
+int board_early_init_f(void)
+{
+       vtt_regulator_enable();
+       return 0;
+}
+#endif