]> 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 0c707b8ae31021a56677e4233b8ef8f3561b1574..273463efcfea927eeef54fab3897d0b804a1024e 100644 (file)
@@ -24,6 +24,7 @@
 #include <netdev.h>
 #include <mmc.h>
 #include <mxcfb.h>
+#include <video_fb.h>
 #include <linux/list.h>
 #include <linux/fb.h>
 #include <asm/io.h>
@@ -53,6 +54,17 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define STK5_CAN_XCVR_GPIO     MX28_PAD_LCD_D00__GPIO_1_0
 
+#define ENET_PAD_CTRL          (MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP)
+#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", },
@@ -62,26 +74,9 @@ 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,
-       MX28_PAD_I2C0_SDA__I2C0_SDA,
+       MX28_PAD_I2C0_SCL__I2C0_SCL | I2C_PAD_CTRL,
+       MX28_PAD_I2C0_SDA__I2C0_SDA | I2C_PAD_CTRL,
 
        /* USBH VBUSEN, OC */
        MX28_PAD_SPDIF__GPIO_3_27,
@@ -167,10 +162,8 @@ rtc_err:
 
 int board_init(void)
 {
-       if (ctrlc()) {
+       if (ctrlc())
                printf("CTRL-C detected; safeboot enabled\n");
-               return 1;
-       }
 
        /* Address of boot parameters */
 #ifdef CONFIG_OF_LIBFDT
@@ -200,7 +193,7 @@ int board_mmc_init(bd_t *bis)
 #ifdef CONFIG_FEC_MXC
 #ifdef CONFIG_GET_FEC_MAC_ADDR_FROM_IIM
 
-#ifdef CONFIG_FEC_MXC_MULTI
+#ifndef CONFIG_TX28_S
 #define FEC_MAX_IDX                    1
 #else
 #define FEC_MAX_IDX                    0
@@ -241,7 +234,7 @@ static int fec_get_mac_addr(int index)
                        val = readl(&cust[index * 8 + i]);
                mac[i] = val >> shift;
        }
-       if (!is_valid_ether_addr(mac)) {
+       if (!is_valid_ethaddr(mac)) {
                if (index == 0)
                        printf("No valid MAC address programmed\n");
                return 0;
@@ -256,12 +249,52 @@ static int fec_get_mac_addr(int index)
        eth_setenv_enetaddr(env_name, mac);
        return 0;
 }
+
+static inline int tx28_fec1_enabled(void)
+{
+       const char *status;
+       int off;
+
+       if (!gd->fdt_blob)
+               return 0;
+
+       off = fdt_path_offset(gd->fdt_blob, "ethernet1");
+       if (off < 0)
+               return 0;
+
+       status = fdt_getprop(gd->fdt_blob, off, "status", NULL);
+       return status && (strcmp(status, "okay") == 0);
+}
+
+static void tx28_init_mac(void)
+{
+       int ret;
+
+       ret = fec_get_mac_addr(0);
+       if (ret < 0) {
+               printf("Failed to read FEC0 MAC address from OCOTP\n");
+               return;
+       }
+#ifdef CONFIG_TX28_S
+       if (tx28_fec1_enabled()) {
+               ret = fec_get_mac_addr(1);
+               if (ret < 0) {
+                       printf("Failed to read FEC1 MAC address from OCOTP\n");
+                       return;
+               }
+       }
+#endif
+}
+#else
+static inline void tx28_init_mac(void)
+{
+}
 #endif /* CONFIG_GET_FEC_MAC_ADDR_FROM_IIM */
 
 static const iomux_cfg_t tx28_fec_pads[] = {
-       MX28_PAD_ENET0_RX_EN__ENET0_RX_EN,
-       MX28_PAD_ENET0_RXD0__ENET0_RXD0,
-       MX28_PAD_ENET0_RXD1__ENET0_RXD1,
+       MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | ENET_PAD_CTRL,
+       MX28_PAD_ENET0_RXD0__ENET0_RXD0 | ENET_PAD_CTRL,
+       MX28_PAD_ENET0_RXD1__ENET0_RXD1 | ENET_PAD_CTRL,
 };
 
 int board_eth_init(bd_t *bis)
@@ -292,7 +325,7 @@ int board_eth_init(bd_t *bis)
                return ret;
        }
 
-#ifdef CONFIG_FEC_MXC_MULTI
+#ifndef CONFIG_TX28_S
        if (getenv("ethaddr")) {
                ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
                if (ret) {
@@ -319,53 +352,65 @@ int board_eth_init(bd_t *bis)
 #endif
        return 0;
 }
+#else
+static inline void tx28_init_mac(void)
+{
+}
 #endif /* CONFIG_FEC_MXC */
 
 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;
                }
        }
 }
 
 static const iomux_cfg_t stk5_pads[] = {
        /* SW controlled LED on STK5 baseboard */
-       MX28_PAD_ENET0_RXD3__GPIO_4_10,
+       MX28_PAD_ENET0_RXD3__GPIO_4_10 | GPIO_PAD_CTRL,
 };
 
 static const struct gpio stk5_gpios[] = {
 };
 
 #ifdef CONFIG_LCD
-static ushort tx28_cmap[256];
 vidinfo_t panel_info = {
        /* set to max. size supported by SoC */
        .vl_col = 1600,
        .vl_row = 1200,
 
        .vl_bpix = LCD_COLOR32,    /* Bits per pixel, 0: 1bpp, 1: 2bpp, 2: 4bpp, 3: 8bpp ... */
-       .cmap = tx28_cmap,
 };
 
 static struct fb_videomode tx28_fb_modes[] = {
@@ -583,8 +628,6 @@ static const struct gpio stk5_lcd_gpios[] = {
        { TX28_LCD_BACKLIGHT_GPIO, GPIOFLAG_OUTPUT_INIT_HIGH, "LCD BACKLIGHT", },
 };
 
-extern void video_hw_init(void *lcdbase);
-
 void lcd_ctrl_init(void *lcdbase)
 {
        int color_depth = 24;
@@ -768,7 +811,7 @@ void lcd_ctrl_init(void *lcdbase)
                setenv("videomode", vmode);
 
                debug("Initializing LCD controller\n");
-               video_hw_init(lcdbase);
+               video_hw_init();
                setenv("videomode", NULL);
        } else {
                debug("Skipping initialization of LCD controller\n");
@@ -786,6 +829,7 @@ static void stk5_board_init(void)
 
 static void stk5v3_board_init(void)
 {
+       led_state = LED_STATE_INIT;
        stk5_board_init();
 }
 
@@ -799,42 +843,6 @@ static void stk5v5_board_init(void)
        mxs_iomux_setup_pad(STK5_CAN_XCVR_GPIO);
 }
 
-int tx28_fec1_enabled(void)
-{
-       const char *status;
-       int off;
-
-       if (!gd->fdt_blob)
-               return 0;
-
-       off = fdt_path_offset(gd->fdt_blob, "ethernet1");
-       if (off < 0)
-               return 0;
-
-       status = fdt_getprop(gd->fdt_blob, off, "status", NULL);
-       return status && (strcmp(status, "okay") == 0);
-}
-
-static void tx28_init_mac(void)
-{
-       int ret;
-
-       ret = fec_get_mac_addr(0);
-       if (ret < 0) {
-               printf("Failed to read FEC0 MAC address from OCOTP\n");
-               return;
-       }
-#ifdef CONFIG_FEC_MXC_MULTI
-       if (tx28_fec1_enabled()) {
-               ret = fec_get_mac_addr(1);
-               if (ret < 0) {
-                       printf("Failed to read FEC1 MAC address from OCOTP\n");
-                       return;
-               }
-       }
-#endif
-}
-
 int board_late_init(void)
 {
        int ret = 0;
@@ -873,7 +881,8 @@ int board_late_init(void)
        } else {
                printf("WARNING: Unsupported baseboard: '%s'\n",
                        baseboard);
-               ret = -EINVAL;
+               if (!had_ctrlc())
+                       ret = -EINVAL;
        }
 
 exit:
@@ -908,7 +917,7 @@ int checkboard(void)
        const char *dlm = "";
 
        printf("Board: Ka-Ro TX28-4%sx%d\n", TX28_MOD_SUFFIX,
-               CONFIG_SDRAM_SIZE / SZ_128M +
+               CONFIG_SYS_SDRAM_SIZE / SZ_128M +
                CONFIG_SYS_NAND_BLOCKS / 2048 * 2);
 
        printf("POWERUP Source: ");
@@ -1005,7 +1014,6 @@ int ft_board_setup(void *blob, bd_t *bd)
                karo_fdt_enable_node(blob, "stk5led", 0);
 
        fdt_fixup_mtdparts(blob, tx28_nand_nodes, ARRAY_SIZE(tx28_nand_nodes));
-       fdt_fixup_ethernet(blob);
 
        karo_fdt_fixup_touchpanel(blob, tx28_touchpanels,
                                ARRAY_SIZE(tx28_touchpanels));