]> git.sur5r.net Git - u-boot/blobdiff - board/sunxi/board.c
libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>
[u-boot] / board / sunxi / board.c
index f9224360d75867fa8c00b10dce950aab44b0e9ef..e08e22f30c0ade2256f69a15e3b7f1db01159677 100644 (file)
 #include <asm/io.h>
 #include <crc.h>
 #include <environment.h>
-#include <libfdt.h>
+#include <linux/libfdt.h>
 #include <nand.h>
 #include <net.h>
+#include <spl.h>
 #include <sy8106a.h>
 #include <asm/setup.h>
 
@@ -172,6 +173,22 @@ void i2c_init_board(void)
 #endif
 }
 
+#if defined(CONFIG_ENV_IS_IN_MMC) && defined(CONFIG_ENV_IS_IN_FAT)
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+       switch (prio) {
+       case 0:
+               return ENVL_FAT;
+
+       case 1:
+               return ENVL_MMC;
+
+       default:
+               return ENVL_UNKNOWN;
+       }
+}
+#endif
+
 /* add board specific code here */
 int board_init(void)
 {
@@ -216,6 +233,8 @@ int board_init(void)
        satapwr_pin = sunxi_name_to_gpio(CONFIG_SATAPWR);
        gpio_request(satapwr_pin, "satapwr");
        gpio_direction_output(satapwr_pin, 1);
+       /* Give attached sata device time to power-up to avoid link timeouts */
+       mdelay(500);
 #endif
 #ifdef CONFIG_MACPWR
        macpwr_pin = sunxi_name_to_gpio(CONFIG_MACPWR);
@@ -491,20 +510,6 @@ int board_mmc_init(bd_t *bis)
                return -1;
 #endif
 
-#if !defined(CONFIG_SPL_BUILD) && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
-       /*
-        * On systems with an emmc (mmc2), figure out if we are booting from
-        * the emmc and if we are make it "mmc dev 0" so that boot.scr, etc.
-        * are searched there first. Note we only do this for u-boot proper,
-        * not for the SPL, see spl_boot_device().
-        */
-       if (readb(SPL_ADDR + 0x28) == SUNXI_BOOTED_FROM_MMC2) {
-               /* Booting from emmc / mmc2, swap */
-               mmc0->block_dev.devnum = 1;
-               mmc1->block_dev.devnum = 0;
-       }
-#endif
-
        return 0;
 }
 #endif
@@ -720,13 +725,22 @@ static void setup_environment(const void *fdt)
 int misc_init_r(void)
 {
        __maybe_unused int ret;
+       uint boot;
 
        env_set("fel_booted", NULL);
        env_set("fel_scriptaddr", NULL);
+       env_set("mmc_bootdev", NULL);
+
+       boot = sunxi_get_boot_device();
        /* determine if we are running in FEL mode */
-       if (!is_boot0_magic(SPL_ADDR + 4)) { /* eGON.BT0 */
+       if (boot == BOOT_DEVICE_BOARD) {
                env_set("fel_booted", "1");
                parse_spl_header(SPL_ADDR);
+       /* or if we booted from MMC, and which one */
+       } else if (boot == BOOT_DEVICE_MMC1) {
+               env_set("mmc_bootdev", "0");
+       } else if (boot == BOOT_DEVICE_MMC2) {
+               env_set("mmc_bootdev", "1");
        }
 
        setup_environment(gd->fdt_blob);
@@ -737,6 +751,10 @@ int misc_init_r(void)
                return ret;
 #endif
 
+#ifdef CONFIG_USB_ETHER
+       usb_ether_init();
+#endif
+
        return 0;
 }