]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/karo/tx6/tx6ul.c
karo: tx6ul: reorder functions to better follow which ones are called with the defaul...
[karo-tx-uboot.git] / board / karo / tx6 / tx6ul.c
index b8e29be67229b7a8f8a10cc22f4db74d11aceccc..062b1610bf3aba375f032f0eab1c03d17de801c7 100644 (file)
@@ -148,8 +148,10 @@ static const iomux_v3_cfg_t const tx6ul_enet1_pads[] = {
 
 static const iomux_v3_cfg_t const tx6_i2c_gpio_pads[] = {
        /* internal I2C */
-       MX6_PAD_SNVS_TAMPER1__GPIO5_IO01 | MUX_CFG_SION | MUX_PAD_CTRL(TX6_I2C_PAD_CTRL),
-       MX6_PAD_SNVS_TAMPER0__GPIO5_IO00 | MUX_CFG_SION | MUX_PAD_CTRL(TX6_I2C_PAD_CTRL),
+       MX6_PAD_SNVS_TAMPER1__GPIO5_IO01 | MUX_CFG_SION |
+                       MUX_PAD_CTRL(TX6_I2C_PAD_CTRL),
+       MX6_PAD_SNVS_TAMPER0__GPIO5_IO00 | MUX_CFG_SION |
+                       MUX_PAD_CTRL(TX6_I2C_PAD_CTRL),
 };
 
 static const struct gpio const tx6ul_gpios[] = {
@@ -166,6 +168,7 @@ static const struct gpio const tx6ul_gpios[] = {
 #define GPIO_DIR 4
 #define GPIO_PSR 8
 
+/* run with default environment */
 static void tx6_i2c_recover(void)
 {
        int i;
@@ -673,6 +676,7 @@ enum {
        LED_STATE_INIT = -1,
        LED_STATE_OFF,
        LED_STATE_ON,
+       LED_STATE_ERR,
 };
 
 static inline int calc_blink_rate(void)
@@ -690,13 +694,24 @@ void show_activity(int arg)
        static int led_state = LED_STATE_INIT;
        static int blink_rate;
        static ulong last;
+       int ret;
+
+       switch (led_state) {
+       case LED_STATE_ERR:
+               return;
 
-       if (led_state == LED_STATE_INIT) {
+       case LED_STATE_INIT:
                last = get_timer(0);
-               gpio_set_value(TX6UL_LED_GPIO, 1);
-               led_state = LED_STATE_ON;
+               ret = gpio_set_value(TX6UL_LED_GPIO, 1);
+               if (ret)
+                       led_state = LED_STATE_ERR;
+               else
+                       led_state = LED_STATE_ON;
                blink_rate = calc_blink_rate();
-       } else {
+               break;
+
+       case LED_STATE_ON:
+       case LED_STATE_OFF:
                if (get_timer(last) > blink_rate) {
                        blink_rate = calc_blink_rate();
                        last = get_timer_masked();
@@ -707,6 +722,7 @@ void show_activity(int arg)
                        }
                        led_state = 1 - led_state;
                }
+               break;
        }
 }
 
@@ -933,47 +949,14 @@ static int lcd_backlight_polarity(void)
        return lcd_bl_polarity;
 }
 
-void lcd_enable(void)
-{
-       /* HACK ALERT:
-        * global variable from common/lcd.c
-        * Set to 0 here to prevent messages from going to LCD
-        * rather than serial console
-        */
-       lcd_is_enabled = 0;
-
-       if (lcd_enabled) {
-               karo_load_splashimage(1);
-
-               debug("Switching LCD on\n");
-               gpio_set_value(TX6UL_LCD_PWR_GPIO, 1);
-               udelay(100);
-               gpio_set_value(TX6UL_LCD_RST_GPIO, 1);
-               udelay(300000);
-               gpio_set_value(TX6UL_LCD_BACKLIGHT_GPIO,
-                       lcd_backlight_polarity());
-       }
-}
-
-void lcd_disable(void)
-{
-       if (lcd_enabled) {
-               printf("Disabling LCD\n");
-               panel_info.vl_row = 0;
-               lcd_enabled = 0;
-       }
-}
-
 static const iomux_v3_cfg_t stk5_lcd_pads[] = {
-#if 1
+#ifdef CONFIG_LCD
        /* LCD RESET */
-       MX6_PAD_LCD_RESET__LCDIF_RESET,
+       MX6_PAD_LCD_RESET__GPIO3_IO04 | MUX_PAD_CTRL(TX6_GPIO_OUT_PAD_CTRL),
        /* LCD POWER_ENABLE */
        MX6_PAD_SNVS_TAMPER4__GPIO5_IO04 | MUX_PAD_CTRL(TX6_GPIO_OUT_PAD_CTRL),
        /* LCD Backlight (PWM) */
        MX6_PAD_NAND_DQS__GPIO4_IO16 | MUX_PAD_CTRL(TX6_GPIO_OUT_PAD_CTRL),
-#endif
-#ifdef CONFIG_LCD
        /* Display */
        MX6_PAD_LCD_DATA00__LCDIF_DATA00,
        MX6_PAD_LCD_DATA01__LCDIF_DATA01,
@@ -1012,6 +995,38 @@ static const struct gpio stk5_lcd_gpios[] = {
        { TX6UL_LCD_BACKLIGHT_GPIO, GPIOFLAG_OUTPUT_INIT_HIGH, "LCD BACKLIGHT", },
 };
 
+/* run with valid env from NAND/eMMC */
+void lcd_enable(void)
+{
+       /* HACK ALERT:
+        * global variable from common/lcd.c
+        * Set to 0 here to prevent messages from going to LCD
+        * rather than serial console
+        */
+       lcd_is_enabled = 0;
+
+       if (lcd_enabled) {
+               karo_load_splashimage(1);
+
+               debug("Switching LCD on\n");
+               gpio_set_value(TX6UL_LCD_PWR_GPIO, 1);
+               udelay(100);
+               gpio_set_value(TX6UL_LCD_RST_GPIO, 1);
+               udelay(300000);
+               gpio_set_value(TX6UL_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
+       }
+}
+
+static void lcd_disable(void)
+{
+       if (lcd_enabled) {
+               printf("Disabling LCD\n");
+               panel_info.vl_row = 0;
+               lcd_enabled = 0;
+       }
+}
+
 void lcd_ctrl_init(void *lcdbase)
 {
        int color_depth = 24;
@@ -1215,14 +1230,14 @@ static void stk5_board_init(void)
                return;
        }
        imx_iomux_v3_setup_multiple_pads(stk5_pads, ARRAY_SIZE(stk5_pads));
-debug("%s@%d: \n", __func__, __LINE__);
+       debug("%s@%d: \n", __func__, __LINE__);
 }
 
 static void stk5v3_board_init(void)
 {
-debug("%s@%d: \n", __func__, __LINE__);
+       debug("%s@%d: \n", __func__, __LINE__);
        stk5_board_init();
-debug("%s@%d: \n", __func__, __LINE__);
+       debug("%s@%d: \n", __func__, __LINE__);
 }
 
 static void stk5v5_board_init(void)
@@ -1265,7 +1280,6 @@ static void tx6ul_set_cpu_clock(void)
 
 int board_late_init(void)
 {
-       int ret = 0;
        const char *baseboard;
 
        debug("%s@%d: \n", __func__, __LINE__);
@@ -1310,16 +1324,17 @@ int board_late_init(void)
        } else {
                printf("WARNING: Unsupported baseboard: '%s'\n",
                        baseboard);
-               ret = -EINVAL;
+               if (!had_ctrlc())
+                       return -EINVAL;
        }
 
 exit:
-debug("%s@%d: \n", __func__, __LINE__);
+       debug("%s@%d: \n", __func__, __LINE__);
        tx6_init_mac();
-debug("%s@%d: \n", __func__, __LINE__);
+       debug("%s@%d: \n", __func__, __LINE__);
 
        clear_ctrlc();
-       return ret;
+       return 0;
 }
 
 #ifdef CONFIG_SERIAL_TAG