]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/karo/tx28/tx28.c
karo: tx28: request gpio for acitivity LED and disable LED on failure
[karo-tx-uboot.git] / board / karo / tx28 / tx28.c
index 275965950ce8f9c8f863de3d812ebe5fd0210367..273463efcfea927eeef54fab3897d0b804a1024e 100644 (file)
@@ -58,6 +58,13 @@ DECLARE_GLOBAL_DATA_PTR;
 #define GPIO_PAD_CTRL          (MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP)
 #define I2C_PAD_CTRL           (MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_PULLUP)
 
+#ifndef CONFIG_CONS_INDEX
+struct serial_device *default_serial_console(void)
+{
+       return NULL;
+}
+#endif
+
 static const struct gpio tx28_gpios[] = {
        { TX28_USBH_VBUSEN_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "USBH VBUSEN", },
        { TX28_USBH_OC_GPIO, GPIOFLAG_INPUT, "USBH OC", },
@@ -67,23 +74,6 @@ static const struct gpio tx28_gpios[] = {
 };
 
 static const iomux_cfg_t tx28_pads[] = {
-       /* UART pads */
-#if CONFIG_CONS_INDEX == 0
-       MX28_PAD_AUART0_RX__DUART_CTS,
-       MX28_PAD_AUART0_TX__DUART_RTS,
-       MX28_PAD_AUART0_CTS__DUART_RX,
-       MX28_PAD_AUART0_RTS__DUART_TX,
-#elif CONFIG_CONS_INDEX == 1
-       MX28_PAD_AUART1_RX__AUART1_RX,
-       MX28_PAD_AUART1_TX__AUART1_TX,
-       MX28_PAD_AUART1_CTS__AUART1_CTS,
-       MX28_PAD_AUART1_RTS__AUART1_RTS,
-#elif CONFIG_CONS_INDEX == 2
-       MX28_PAD_AUART3_RX__AUART3_RX,
-       MX28_PAD_AUART3_TX__AUART3_TX,
-       MX28_PAD_AUART3_CTS__AUART3_CTS,
-       MX28_PAD_AUART3_RTS__AUART3_RTS,
-#endif
        /* I2C bus for internal DS1339, PCA9554 and on DIMM pins 40/41 */
        MX28_PAD_I2C0_SCL__I2C0_SCL | I2C_PAD_CTRL,
        MX28_PAD_I2C0_SDA__I2C0_SDA | I2C_PAD_CTRL,
@@ -372,26 +362,36 @@ enum {
        LED_STATE_INIT = -1,
        LED_STATE_OFF,
        LED_STATE_ON,
+       LED_STATE_DISABLED,
 };
 
+static int led_state = LED_STATE_DISABLED;
+
 void show_activity(int arg)
 {
-       static int led_state = LED_STATE_INIT;
        static ulong last;
+       int ret;
 
-       if (led_state == LED_STATE_INIT) {
+       if (led_state == LED_STATE_DISABLED) {
+               return;
+       } else if (led_state == LED_STATE_INIT) {
                last = get_timer(0);
-               gpio_set_value(TX28_LED_GPIO, 1);
-               led_state = LED_STATE_ON;
+               ret = gpio_request_one(TX28_LED_GPIO,
+                               GPIOFLAG_OUTPUT_INIT_HIGH, "Activity");
+               if (ret == 0)
+                       led_state = LED_STATE_ON;
+               else
+                       led_state = LED_STATE_DISABLED;
        } else {
                if (get_timer(last) > CONFIG_SYS_HZ) {
                        last = get_timer(0);
                        if (led_state == LED_STATE_ON) {
                                gpio_set_value(TX28_LED_GPIO, 0);
+                               led_state = LED_STATE_OFF;
                        } else {
                                gpio_set_value(TX28_LED_GPIO, 1);
+                               led_state = LED_STATE_ON;
                        }
-                       led_state = 1 - led_state;
                }
        }
 }
@@ -829,6 +829,7 @@ static void stk5_board_init(void)
 
 static void stk5v3_board_init(void)
 {
+       led_state = LED_STATE_INIT;
        stk5_board_init();
 }