LC15: preliminary code for boot switch (not tested)
authorH. Nikolaus Schaller <hns@goldelico.com>
Sat, 9 Jan 2016 18:56:59 +0000 (19:56 +0100)
committernotaz <notasas@gmail.com>
Sun, 14 Aug 2016 13:09:05 +0000 (16:09 +0300)
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
board/goldelico/letux-cortex15/lc15.c

index ffbd9f6..c1ebd4c 100644 (file)
@@ -34,11 +34,12 @@ const struct omap_sysinfo sysinfo = {
 
 int board_mmc_init(bd_t *bis)
 {
-       int uSD = 0;    // ask GPIO3_82 value
+       int uSD = 0;    // could ask GPIO3_82 state
        debug("special board_mmc_init for LC15\n");
        omap_mmc_init(0, uSD?MMC_MODE_4BIT:0, 0, -1, -1);
        omap_mmc_init(1, MMC_MODE_4BIT, 0, -1, -1);
 /* FIXME: we might need to modify the HSMMC3_BASE in omap_hsmmc.c to make this work */
+/* here we need an interface called SDIO4 with controller base address 480d1000 */
        omap_mmc_init(2, MMC_MODE_4BIT, 0, -1, -1);
        return 0;
 }
@@ -51,19 +52,43 @@ int board_mmc_init(bd_t *bis)
 /*
  * add eMMC/uSD switch logic here
  * so that we can boot from the internal uSD
- * and release the boot button.
- * Should be done only in SPL!
+ * and release/press the boot button without
+ * throwing the eMMC/uSD switch.
  */
 
+const struct pad_conf_entry wkupconf_mmcmux_pyra[] = {
+       {DRM_EMU0, (IEN | M6)}, /* gpio 1_wk7 */
+};
+
+const struct pad_conf_entry padconf_mmcmux_pyra[] = {
+       {HSI2_ACFLAG, (IDIS | M6)}, /* gpio 3_82 */
+};
+
 int set_mmc_switch(void)
 {
+       int val;
        printf("set_mmc_switch for LC15 called\n");
-// maybe check if GPIO3_82 is already output -> ignore
-/*
-       read GPIO1_WK7
-       set GPIO3_82 from high Z to output mode
-       set GPIO3_82 value to !GPIO1_WK7 value - i.e. make initial button setting persist
-*/
+       /* make gpio1_wk7 an input */
+       do_set_mux((*ctrl)->control_padconf_wkup_base,
+                  wkupconf_mmcmux_pyra,
+                  sizeof(wkupconf_mmcmux_pyra) /
+                  sizeof(struct pad_conf_entry));
+       gpio_request(7, "gpio1_wk7");   /* BOOTSEL button */
+       gpio_request(82, "gpio3_82");   /* MMC switch control */
+       val = gpio_get_value(7);        /* BOOTSEL pressed? */
+       printk("  gpio7 = %d\n", val);
+       gpio_direction_output(82, !val);        /* pass button setting to output */
+       /* go from High-Z to low L to make it really an output
+        * overriding the hardware defined state from the BOOTSEL button
+        */
+       do_set_mux((*ctrl)->control_padconf_core_base,
+                  padconf_mmcmux_pyra,
+                  sizeof(padconf_mmcmux_pyra) /
+                  sizeof(struct pad_conf_entry));
+       /* read back */
+       printk("  gpio82 = %d\n", gpio_get_value(82));
+       gpio_free(7);
+       gpio_free(82);
        return 0;
 }