X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=blobdiff_plain;f=board%2Fkaro%2Ftx28%2Ftx28.c;h=c5c4788a58962bc354af97f33368a99839da7445;hp=46f7dbfb5ebd71f6388988b42d7e99a28f8ea5f3;hb=0e6985443278fc193c90fc2daeeefce853012d54;hpb=4cf72669d1d11f29c0c1797ee725a896e6ba07e1 diff --git a/board/karo/tx28/tx28.c b/board/karo/tx28/tx28.c index 46f7dbfb5e..c5c4788a58 100644 --- a/board/karo/tx28/tx28.c +++ b/board/karo/tx28/tx28.c @@ -51,12 +51,14 @@ DECLARE_GLOBAL_DATA_PTR; #define TX28_LED_GPIO MX28_PAD_ENET0_RXD3__GPIO_4_10 +#define STK5_CAN_XCVR_GPIO MX28_PAD_LCD_D00__GPIO_1_0 + static const struct gpio tx28_gpios[] = { - { TX28_USBH_VBUSEN_GPIO, GPIOF_OUTPUT_INIT_LOW, "USBH VBUSEN", }, - { TX28_USBH_OC_GPIO, GPIOF_INPUT, "USBH OC", }, - { TX28_USBOTG_VBUSEN_GPIO, GPIOF_OUTPUT_INIT_LOW, "USBOTG VBUSEN", }, - { TX28_USBOTG_OC_GPIO, GPIOF_INPUT, "USBOTG OC", }, - { TX28_USBOTG_ID_GPIO, GPIOF_INPUT, "USBOTG ID", }, + { TX28_USBH_VBUSEN_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "USBH VBUSEN", }, + { TX28_USBH_OC_GPIO, GPIOFLAG_INPUT, "USBH OC", }, + { TX28_USBOTG_VBUSEN_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "USBOTG VBUSEN", }, + { TX28_USBOTG_OC_GPIO, GPIOFLAG_INPUT, "USBOTG OC", }, + { TX28_USBOTG_ID_GPIO, GPIOFLAG_INPUT, "USBOTG ID", }, }; static const iomux_cfg_t tx28_pads[] = { @@ -98,7 +100,7 @@ static const iomux_cfg_t tx28_pads[] = { /* provide at least _some_ sort of randomness */ #define MAX_LOOPS 100 -static u32 random; +static u32 random __attribute__((section("data"))); static inline void random_init(void) { @@ -107,9 +109,11 @@ static inline void random_init(void) int i; for (i = 0; i < MAX_LOOPS; i++) { - unsigned int usec = readl(&digctl_regs->hw_digctl_microseconds); + u32 hclk = readl(&digctl_regs->hw_digctl_hclkcount); + u32 entropy = readl(&digctl_regs->hw_digctl_entropy); + u32 usec = readl(&digctl_regs->hw_digctl_microseconds); - seed = get_timer(usec + random + seed); + seed = get_timer(hclk ^ entropy ^ usec ^ random ^ seed); srand(seed); random = rand(); } @@ -143,7 +147,7 @@ int board_early_init_f(void) while ((rtc_stat = readl(&rtc_regs->hw_rtc_stat)) & RTC_STAT_STALE_REGS_PERSISTENT0) { if (timeout-- < 0) - return 0; + return 1; udelay(1); } boot_cause = readl(&rtc_regs->hw_rtc_persistent0); @@ -158,11 +162,14 @@ int board_early_init_f(void) rtc_err: serial_puts("Inconsistent value in RTC_PERSISTENT0 register; power-on-reset required\n"); - return 0; + return 1; } int board_init(void) { + if (ctrlc()) + printf("CTRL-C detected; safeboot enabled\n"); + /* Address of boot parameters */ #ifdef CONFIG_OF_LIBFDT gd->bd->bi_arch_number = -1; @@ -191,7 +198,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 @@ -232,7 +239,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; @@ -247,6 +254,46 @@ 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[] = { @@ -283,7 +330,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) { @@ -310,6 +357,10 @@ int board_eth_init(bd_t *bis) #endif return 0; } +#else +static inline void tx28_init_mac(void) +{ +} #endif /* CONFIG_FEC_MXC */ enum { @@ -355,7 +406,7 @@ vidinfo_t panel_info = { .vl_col = 1600, .vl_row = 1200, - .vl_bpix = LCD_COLOR24, /* Bits per pixel, 0: 1bpp, 1: 2bpp, 2: 4bpp, 3: 8bpp ... */ + .vl_bpix = LCD_COLOR32, /* Bits per pixel, 0: 1bpp, 1: 2bpp, 2: 4bpp, 3: 8bpp ... */ .cmap = tx28_cmap, }; @@ -566,15 +617,12 @@ static const iomux_cfg_t stk5_lcd_pads[] = { MX28_PAD_LCD_WR_RWN__LCD_HSYNC | MXS_PAD_CTRL, MX28_PAD_LCD_RS__LCD_DOTCLK | MXS_PAD_CTRL, MX28_PAD_LCD_CS__LCD_CS | MXS_PAD_CTRL, - MX28_PAD_LCD_VSYNC__LCD_VSYNC | MXS_PAD_CTRL, - MX28_PAD_LCD_HSYNC__LCD_HSYNC | MXS_PAD_CTRL, - MX28_PAD_LCD_DOTCLK__LCD_DOTCLK | MXS_PAD_CTRL, }; static const struct gpio stk5_lcd_gpios[] = { - { TX28_LCD_RST_GPIO, GPIOF_OUTPUT_INIT_LOW, "LCD RESET", }, - { TX28_LCD_PWR_GPIO, GPIOF_OUTPUT_INIT_LOW, "LCD POWER", }, - { TX28_LCD_BACKLIGHT_GPIO, GPIOF_OUTPUT_INIT_HIGH, "LCD BACKLIGHT", }, + { TX28_LCD_RST_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "LCD RESET", }, + { TX28_LCD_PWR_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "LCD POWER", }, + { TX28_LCD_BACKLIGHT_GPIO, GPIOFLAG_OUTPUT_INIT_HIGH, "LCD BACKLIGHT", }, }; extern void video_hw_init(void *lcdbase); @@ -722,7 +770,7 @@ void lcd_ctrl_init(void *lcdbase) panel_info.vl_bpix = LCD_COLOR16; break; default: - panel_info.vl_bpix = LCD_COLOR24; + panel_info.vl_bpix = LCD_COLOR32; } p->pixclock = KHZ2PICOS(refresh * @@ -788,45 +836,9 @@ static void stk5v5_board_init(void) stk5_board_init(); /* init flexcan transceiver enable GPIO */ - gpio_request_one(MXS_GPIO_NR(0, 1), GPIOF_OUTPUT_INIT_HIGH, + gpio_request_one(STK5_CAN_XCVR_GPIO, GPIOFLAG_OUTPUT_INIT_HIGH, "Flexcan Transceiver"); - mxs_iomux_setup_pad(MX28_PAD_LCD_D00__GPIO_1_0); -} - -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 + mxs_iomux_setup_pad(STK5_CAN_XCVR_GPIO); } int board_late_init(void) @@ -834,7 +846,12 @@ int board_late_init(void) int ret = 0; const char *baseboard; - karo_fdt_move_fdt(); + env_cleanup(); + + if (had_ctrlc()) + setenv_ulong("safeboot", 1); + else + karo_fdt_move_fdt(); baseboard = getenv("baseboard"); if (!baseboard) @@ -862,7 +879,8 @@ int board_late_init(void) } else { printf("WARNING: Unsupported baseboard: '%s'\n", baseboard); - ret = -EINVAL; + if (!had_ctrlc()) + ret = -EINVAL; } exit: @@ -897,7 +915,8 @@ 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: "); if (pwrup_src & (3 << 0)) { @@ -970,7 +989,7 @@ static const char *tx28_touchpanels[] = { "fsl,imx28-lradc", }; -void ft_board_setup(void *blob, bd_t *bd) +int ft_board_setup(void *blob, bd_t *bd) { const char *baseboard = getenv("baseboard"); int stk5_v5 = baseboard != NULL && (strcmp(baseboard, "stk5-v5") == 0); @@ -978,9 +997,10 @@ void ft_board_setup(void *blob, bd_t *bd) int ret; ret = fdt_increase_size(blob, 4096); - if (ret) + if (ret) { printf("Failed to increase FDT size: %s\n", fdt_strerror(ret)); - + return ret; + } #ifdef CONFIG_TX28_S /* TX28-41xx (aka TX28S) has no external RTC * and no I2C GPIO extender @@ -992,12 +1012,13 @@ void 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)); - karo_fdt_fixup_usb_otg(blob, "usbotg", "fsl,usbphy"); + karo_fdt_fixup_usb_otg(blob, "usbotg", "fsl,usbphy", "vbus-supply"); karo_fdt_fixup_flexcan(blob, stk5_v5); karo_fdt_update_fb_mode(blob, video_mode); + + return 0; } #endif /* CONFIG_OF_BOARD_SETUP */