]> git.sur5r.net Git - u-boot/blobdiff - board/amazon/kc1/kc1.c
env: Rename getenv/_f() to env_get()
[u-boot] / board / amazon / kc1 / kc1.c
index a189bb2c0841692310e4a65e7a7c5d4706a98917..eead98b24eb39aabf732f096fba3a44987007292 100644 (file)
@@ -8,12 +8,16 @@
 
 #include <config.h>
 #include <common.h>
+#include <linux/ctype.h>
+#include <linux/usb/musb.h>
+#include <asm/omap_musb.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/gpio.h>
 #include <asm/emif.h>
 #include <twl6030.h>
 #include "kc1.h"
+#include <asm/mach-types.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -21,6 +25,26 @@ const struct omap_sysinfo sysinfo = {
        .board_string = "kc1"
 };
 
+static struct musb_hdrc_config musb_config = {
+       .multipoint = 1,
+       .dyn_fifo = 1,
+       .num_eps = 16,
+       .ram_bits = 12
+};
+
+static struct omap_musb_board_data musb_board_data = {
+       .interface_type = MUSB_INTERFACE_UTMI,
+};
+
+static struct musb_hdrc_platform_data musb_platform_data = {
+       .mode = MUSB_PERIPHERAL,
+       .config = &musb_config,
+       .power = 100,
+       .platform_ops = &omap2430_ops,
+       .board_data = &musb_board_data,
+};
+
+
 void set_muxconf_regs(void)
 {
        do_set_mux((*ctrl)->control_padconf_core_base, core_padconf_array,
@@ -62,10 +86,52 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+       char reboot_mode[2] = { 0 };
+       u32 data = 0;
+       u32 value;
+       int rc;
+
+       /* Reboot mode */
+
+       rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
+
+       /* USB ID pin pull-up indicates factory (fastboot) cable detection. */
+       gpio_request(KC1_GPIO_USB_ID, "USB_ID");
+       gpio_direction_input(KC1_GPIO_USB_ID);
+       value = gpio_get_value(KC1_GPIO_USB_ID);
+
+       if (value)
+               reboot_mode[0] = 'b';
+
+       if (rc < 0 || reboot_mode[0] == 'o') {
+               /*
+                * When not rebooting, valid power on reasons are either the
+                * power button, charger plug or USB plug.
+                */
+
+               data |= twl6030_input_power_button();
+               data |= twl6030_input_charger();
+               data |= twl6030_input_usb();
+
+               if (!data)
+                       twl6030_power_off();
+       }
+
+       if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
+               if (!env_get("reboot-mode"))
+                       env_set("reboot-mode", (char *)reboot_mode);
+       }
+
+       omap_reboot_mode_clear();
+
        /* Serial number */
 
        omap_die_id_serial();
 
+       /* MUSB */
+
+       musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
+
        return 0;
 }
 
@@ -96,12 +162,15 @@ void get_board_serial(struct tag_serialnr *serialnr)
        omap_die_id_get_board_serial(serialnr);
 }
 
-#ifndef CONFIG_SPL_BUILD
+int fb_set_reboot_flag(void)
+{
+       return omap_reboot_mode_store("b");
+}
+
 int board_mmc_init(bd_t *bis)
 {
        return omap_mmc_init(1, 0, 0, -1, -1);
 }
-#endif
 
 void board_mmc_power_init(void)
 {