2 * Copyright (C) 2011-2013 Lothar Waßmann <LW@KARO-electronics.de>
3 * based on: board/freescale/mx28_evk.c (C) 2010 Freescale Semiconductor, Inc.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
22 #include <fdt_support.h>
28 #include <linux/list.h>
32 #include <asm/arch/iomux-mx28.h>
33 #include <asm/arch/clock.h>
34 #include <asm/arch/imx-regs.h>
35 #include <asm/arch/sys_proto.h>
37 #include "../common/karo.h"
39 DECLARE_GLOBAL_DATA_PTR;
41 #define MXS_GPIO_NR(p, o) (((p) << 5) | (o))
43 #define TX28_LCD_PWR_GPIO MX28_PAD_LCD_ENABLE__GPIO_1_31
44 #define TX28_LCD_RST_GPIO MX28_PAD_LCD_RESET__GPIO_3_30
45 #define TX28_LCD_BACKLIGHT_GPIO MX28_PAD_PWM0__GPIO_3_16
47 #define TX28_USBH_VBUSEN_GPIO MX28_PAD_SPDIF__GPIO_3_27
48 #define TX28_USBH_OC_GPIO MX28_PAD_JTAG_RTCK__GPIO_4_20
49 #define TX28_USBOTG_VBUSEN_GPIO MX28_PAD_GPMI_CE2N__GPIO_0_18
50 #define TX28_USBOTG_OC_GPIO MX28_PAD_GPMI_CE3N__GPIO_0_19
51 #define TX28_USBOTG_ID_GPIO MX28_PAD_PWM2__GPIO_3_18
53 #define TX28_LED_GPIO MX28_PAD_ENET0_RXD3__GPIO_4_10
55 #define STK5_CAN_XCVR_GPIO MX28_PAD_LCD_D00__GPIO_1_0
57 #define ENET_PAD_CTRL (MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP)
58 #define GPIO_PAD_CTRL (MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP)
59 #define I2C_PAD_CTRL (MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_PULLUP)
61 #ifndef CONFIG_CONS_INDEX
62 struct serial_device *default_serial_console(void)
68 static const struct gpio tx28_gpios[] = {
69 { TX28_USBH_VBUSEN_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "USBH VBUSEN", },
70 { TX28_USBH_OC_GPIO, GPIOFLAG_INPUT, "USBH OC", },
71 { TX28_USBOTG_VBUSEN_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "USBOTG VBUSEN", },
72 { TX28_USBOTG_OC_GPIO, GPIOFLAG_INPUT, "USBOTG OC", },
73 { TX28_USBOTG_ID_GPIO, GPIOFLAG_INPUT, "USBOTG ID", },
76 static const iomux_cfg_t tx28_pads[] = {
77 /* I2C bus for internal DS1339, PCA9554 and on DIMM pins 40/41 */
78 MX28_PAD_I2C0_SCL__I2C0_SCL | I2C_PAD_CTRL,
79 MX28_PAD_I2C0_SDA__I2C0_SDA | I2C_PAD_CTRL,
82 MX28_PAD_SPDIF__GPIO_3_27,
83 MX28_PAD_JTAG_RTCK__GPIO_4_20,
85 /* USBOTG VBUSEN, OC, ID */
86 MX28_PAD_GPMI_CE2N__GPIO_0_18,
87 MX28_PAD_GPMI_CE3N__GPIO_0_19,
88 MX28_PAD_PWM2__GPIO_3_18,
95 /* provide at least _some_ sort of randomness */
98 static u32 random __attribute__((section("data")));
100 static inline void random_init(void)
102 struct mxs_digctl_regs *digctl_regs = (void *)MXS_DIGCTL_BASE;
106 for (i = 0; i < MAX_LOOPS; i++) {
107 u32 hclk = readl(&digctl_regs->hw_digctl_hclkcount);
108 u32 entropy = readl(&digctl_regs->hw_digctl_entropy);
109 u32 usec = readl(&digctl_regs->hw_digctl_microseconds);
111 seed = get_timer(hclk ^ entropy ^ usec ^ random ^ seed);
117 #define RTC_PERSISTENT0_CLK32_MASK (RTC_PERSISTENT0_CLOCKSOURCE | \
118 RTC_PERSISTENT0_XTAL32KHZ_PWRUP)
119 static u32 boot_cause __attribute__((section("data")));
121 int board_early_init_f(void)
123 struct mxs_rtc_regs *rtc_regs = (void *)MXS_RTC_BASE;
129 /* IO0 clock at 480MHz */
130 mxs_set_ioclk(MXC_IOCLK0, 480000);
131 /* IO1 clock at 480MHz */
132 mxs_set_ioclk(MXC_IOCLK1, 480000);
134 /* SSP0 clock at 96MHz */
135 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
136 /* SSP2 clock at 96MHz */
137 mxs_set_sspclk(MXC_SSPCLK2, 96000, 0);
139 gpio_request_array(tx28_gpios, ARRAY_SIZE(tx28_gpios));
140 mxs_iomux_setup_multiple_pads(tx28_pads, ARRAY_SIZE(tx28_pads));
142 while ((rtc_stat = readl(&rtc_regs->hw_rtc_stat)) &
143 RTC_STAT_STALE_REGS_PERSISTENT0) {
148 boot_cause = readl(&rtc_regs->hw_rtc_persistent0);
149 if ((boot_cause & RTC_PERSISTENT0_CLK32_MASK) !=
150 RTC_PERSISTENT0_CLK32_MASK) {
151 if (boot_cause & RTC_PERSISTENT0_CLOCKSOURCE)
153 writel(RTC_PERSISTENT0_CLK32_MASK,
154 &rtc_regs->hw_rtc_persistent0_set);
159 serial_puts("Inconsistent value in RTC_PERSISTENT0 register; power-on-reset required\n");
166 printf("CTRL-C detected; safeboot enabled\n");
168 /* Address of boot parameters */
169 #ifdef CONFIG_OF_LIBFDT
170 gd->bd->bi_arch_number = -1;
172 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x1000;
178 return mxs_dram_init();
181 #ifdef CONFIG_CMD_MMC
182 static int tx28_mmc_wp(int dev_no)
187 int board_mmc_init(bd_t *bis)
189 return mxsmmc_initialize(bis, 0, tx28_mmc_wp, NULL);
191 #endif /* CONFIG_CMD_MMC */
193 #ifdef CONFIG_FEC_MXC
194 #ifdef CONFIG_GET_FEC_MAC_ADDR_FROM_IIM
196 #ifndef CONFIG_TX28_S
197 #define FEC_MAX_IDX 1
199 #define FEC_MAX_IDX 0
205 static int fec_get_mac_addr(int index)
208 struct mxs_ocotp_regs *ocotp_regs =
209 (struct mxs_ocotp_regs *)MXS_OCOTP_BASE;
210 u32 *cust = &ocotp_regs->hw_ocotp_cust0;
212 char env_name[] = "eth.addr";
216 if (index < 0 || index > FEC_MAX_IDX)
219 /* set this bit to open the OTP banks for reading */
220 writel(OCOTP_CTRL_RD_BANK_OPEN,
221 &ocotp_regs->hw_ocotp_ctrl_set);
223 /* wait until OTP contents are readable */
224 while (OCOTP_CTRL_BUSY & readl(&ocotp_regs->hw_ocotp_ctrl)) {
230 for (i = 0; i < sizeof(mac); i++) {
231 int shift = 24 - i % 4 * 8;
234 val = readl(&cust[index * 8 + i]);
235 mac[i] = val >> shift;
237 if (!is_valid_ethaddr(mac)) {
239 printf("No valid MAC address programmed\n");
244 printf("MAC addr from fuse: %pM\n", mac);
245 snprintf(env_name, sizeof(env_name), "ethaddr");
247 snprintf(env_name, sizeof(env_name), "eth%daddr", index);
249 eth_setenv_enetaddr(env_name, mac);
253 static inline int tx28_fec1_enabled(void)
261 off = fdt_path_offset(gd->fdt_blob, "ethernet1");
265 status = fdt_getprop(gd->fdt_blob, off, "status", NULL);
266 return status && (strcmp(status, "okay") == 0);
269 static void tx28_init_mac(void)
273 ret = fec_get_mac_addr(0);
275 printf("Failed to read FEC0 MAC address from OCOTP\n");
279 if (tx28_fec1_enabled()) {
280 ret = fec_get_mac_addr(1);
282 printf("Failed to read FEC1 MAC address from OCOTP\n");
289 static inline void tx28_init_mac(void)
292 #endif /* CONFIG_GET_FEC_MAC_ADDR_FROM_IIM */
294 static const iomux_cfg_t tx28_fec_pads[] = {
295 MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | ENET_PAD_CTRL,
296 MX28_PAD_ENET0_RXD0__ENET0_RXD0 | ENET_PAD_CTRL,
297 MX28_PAD_ENET0_RXD1__ENET0_RXD1 | ENET_PAD_CTRL,
300 int board_eth_init(bd_t *bis)
304 /* Reset the external phy */
305 gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
307 /* Power on the external phy */
308 gpio_direction_output(MX28_PAD_PWM4__GPIO_3_29, 1);
310 /* Pull strap pins to high */
311 gpio_direction_output(MX28_PAD_ENET0_RX_EN__GPIO_4_2, 1);
312 gpio_direction_output(MX28_PAD_ENET0_RXD0__GPIO_4_3, 1);
313 gpio_direction_output(MX28_PAD_ENET0_RXD1__GPIO_4_4, 1);
314 gpio_direction_input(MX28_PAD_ENET0_TX_CLK__GPIO_4_5);
317 gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
320 mxs_iomux_setup_multiple_pads(tx28_fec_pads, ARRAY_SIZE(tx28_fec_pads));
322 ret = cpu_eth_init(bis);
324 printf("cpu_eth_init() failed: %d\n", ret);
328 #ifndef CONFIG_TX28_S
329 if (getenv("ethaddr")) {
330 ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
332 printf("FEC MXS: Unable to init FEC0\n");
337 if (getenv("eth1addr")) {
338 ret = fecmxc_initialize_multi(bis, 1, 1, MXS_ENET1_BASE);
340 printf("FEC MXS: Unable to init FEC1\n");
345 if (getenv("ethaddr")) {
346 ret = fecmxc_initialize(bis);
348 printf("FEC MXS: Unable to init FEC\n");
356 static inline void tx28_init_mac(void)
359 #endif /* CONFIG_FEC_MXC */
368 static int led_state = LED_STATE_DISABLED;
370 void show_activity(int arg)
375 if (led_state == LED_STATE_DISABLED) {
377 } else if (led_state == LED_STATE_INIT) {
379 ret = gpio_request_one(TX28_LED_GPIO,
380 GPIOFLAG_OUTPUT_INIT_HIGH, "Activity");
382 led_state = LED_STATE_ON;
384 led_state = LED_STATE_DISABLED;
386 if (get_timer(last) > CONFIG_SYS_HZ) {
388 if (led_state == LED_STATE_ON) {
389 gpio_set_value(TX28_LED_GPIO, 0);
390 led_state = LED_STATE_OFF;
392 gpio_set_value(TX28_LED_GPIO, 1);
393 led_state = LED_STATE_ON;
399 static const iomux_cfg_t stk5_pads[] = {
400 /* SW controlled LED on STK5 baseboard */
401 MX28_PAD_ENET0_RXD3__GPIO_4_10 | GPIO_PAD_CTRL,
404 static const struct gpio stk5_gpios[] = {
408 vidinfo_t panel_info = {
409 /* set to max. size supported by SoC */
413 .vl_bpix = LCD_COLOR32, /* Bits per pixel, 0: 1bpp, 1: 2bpp, 2: 4bpp, 3: 8bpp ... */
416 static struct fb_videomode tx28_fb_modes[] = {
418 /* Standard VGA timing */
423 .pixclock = KHZ2PICOS(25175),
430 .vmode = FB_VMODE_NONINTERLACED,
433 /* Emerging ETV570 640 x 480 display. Syncs low active,
434 * DE high active, 115.2 mm x 86.4 mm display area
435 * VGA compatible timing
441 .pixclock = KHZ2PICOS(25175),
448 .vmode = FB_VMODE_NONINTERLACED,
451 /* Emerging ET0350G0DH6 320 x 240 display.
452 * 70.08 mm x 52.56 mm display area.
458 .pixclock = KHZ2PICOS(6500),
459 .left_margin = 68 - 34,
462 .upper_margin = 18 - 3,
465 .vmode = FB_VMODE_NONINTERLACED,
468 /* Emerging ET0430G0DH6 480 x 272 display.
469 * 95.04 mm x 53.856 mm display area.
475 .pixclock = KHZ2PICOS(9000),
482 .sync = FB_SYNC_CLK_LAT_FALL,
483 .vmode = FB_VMODE_NONINTERLACED,
486 /* Emerging ET0500G0DH6 800 x 480 display.
487 * 109.6 mm x 66.4 mm display area.
493 .pixclock = KHZ2PICOS(33260),
494 .left_margin = 216 - 128,
496 .right_margin = 1056 - 800 - 216,
497 .upper_margin = 35 - 2,
499 .lower_margin = 525 - 480 - 35,
500 .vmode = FB_VMODE_NONINTERLACED,
503 /* Emerging ETQ570G0DH6 320 x 240 display.
504 * 115.2 mm x 86.4 mm display area.
510 .pixclock = KHZ2PICOS(6400),
514 .upper_margin = 16, /* 15 according to datasheet */
515 .vsync_len = 3, /* TVP -> 1>x>5 */
516 .lower_margin = 4, /* 4.5 according to datasheet */
517 .vmode = FB_VMODE_NONINTERLACED,
520 /* Emerging ET0700G0DH6 800 x 480 display.
521 * 152.4 mm x 91.44 mm display area.
527 .pixclock = KHZ2PICOS(33260),
528 .left_margin = 216 - 128,
530 .right_margin = 1056 - 800 - 216,
531 .upper_margin = 35 - 2,
533 .lower_margin = 525 - 480 - 35,
534 .vmode = FB_VMODE_NONINTERLACED,
537 /* unnamed entry for assigning parameters parsed from 'video_mode' string */
538 .vmode = FB_VMODE_NONINTERLACED,
542 static int lcd_enabled = 1;
543 static int lcd_bl_polarity;
545 static int lcd_backlight_polarity(void)
547 return lcd_bl_polarity;
550 void lcd_enable(void)
553 * global variable from common/lcd.c
554 * Set to 0 here to prevent messages from going to LCD
555 * rather than serial console
559 karo_load_splashimage(1);
561 debug("Switching LCD on\n");
562 gpio_set_value(TX28_LCD_PWR_GPIO, 1);
564 gpio_set_value(TX28_LCD_RST_GPIO, 1);
566 gpio_set_value(TX28_LCD_BACKLIGHT_GPIO,
567 lcd_backlight_polarity());
571 void lcd_disable(void)
575 void lcd_panel_disable(void)
578 debug("Switching LCD off\n");
579 gpio_set_value(TX28_LCD_BACKLIGHT_GPIO,
580 !lcd_backlight_polarity());
581 gpio_set_value(TX28_LCD_RST_GPIO, 0);
582 gpio_set_value(TX28_LCD_PWR_GPIO, 0);
586 static const iomux_cfg_t stk5_lcd_pads[] = {
588 MX28_PAD_LCD_RESET__GPIO_3_30 | MXS_PAD_CTRL,
589 /* LCD POWER_ENABLE */
590 MX28_PAD_LCD_ENABLE__GPIO_1_31 | MXS_PAD_CTRL,
591 /* LCD Backlight (PWM) */
592 MX28_PAD_PWM0__GPIO_3_16 | MXS_PAD_CTRL,
595 MX28_PAD_LCD_D00__LCD_D0 | MXS_PAD_CTRL,
596 MX28_PAD_LCD_D01__LCD_D1 | MXS_PAD_CTRL,
597 MX28_PAD_LCD_D02__LCD_D2 | MXS_PAD_CTRL,
598 MX28_PAD_LCD_D03__LCD_D3 | MXS_PAD_CTRL,
599 MX28_PAD_LCD_D04__LCD_D4 | MXS_PAD_CTRL,
600 MX28_PAD_LCD_D05__LCD_D5 | MXS_PAD_CTRL,
601 MX28_PAD_LCD_D06__LCD_D6 | MXS_PAD_CTRL,
602 MX28_PAD_LCD_D07__LCD_D7 | MXS_PAD_CTRL,
603 MX28_PAD_LCD_D08__LCD_D8 | MXS_PAD_CTRL,
604 MX28_PAD_LCD_D09__LCD_D9 | MXS_PAD_CTRL,
605 MX28_PAD_LCD_D10__LCD_D10 | MXS_PAD_CTRL,
606 MX28_PAD_LCD_D11__LCD_D11 | MXS_PAD_CTRL,
607 MX28_PAD_LCD_D12__LCD_D12 | MXS_PAD_CTRL,
608 MX28_PAD_LCD_D13__LCD_D13 | MXS_PAD_CTRL,
609 MX28_PAD_LCD_D14__LCD_D14 | MXS_PAD_CTRL,
610 MX28_PAD_LCD_D15__LCD_D15 | MXS_PAD_CTRL,
611 MX28_PAD_LCD_D16__LCD_D16 | MXS_PAD_CTRL,
612 MX28_PAD_LCD_D17__LCD_D17 | MXS_PAD_CTRL,
613 MX28_PAD_LCD_D18__LCD_D18 | MXS_PAD_CTRL,
614 MX28_PAD_LCD_D19__LCD_D19 | MXS_PAD_CTRL,
615 MX28_PAD_LCD_D20__LCD_D20 | MXS_PAD_CTRL,
616 MX28_PAD_LCD_D21__LCD_D21 | MXS_PAD_CTRL,
617 MX28_PAD_LCD_D22__LCD_D22 | MXS_PAD_CTRL,
618 MX28_PAD_LCD_D23__LCD_D23 | MXS_PAD_CTRL,
619 MX28_PAD_LCD_RD_E__LCD_VSYNC | MXS_PAD_CTRL,
620 MX28_PAD_LCD_WR_RWN__LCD_HSYNC | MXS_PAD_CTRL,
621 MX28_PAD_LCD_RS__LCD_DOTCLK | MXS_PAD_CTRL,
622 MX28_PAD_LCD_CS__LCD_CS | MXS_PAD_CTRL,
625 static const struct gpio stk5_lcd_gpios[] = {
626 { TX28_LCD_RST_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "LCD RESET", },
627 { TX28_LCD_PWR_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "LCD POWER", },
628 { TX28_LCD_BACKLIGHT_GPIO, GPIOFLAG_OUTPUT_INIT_HIGH, "LCD BACKLIGHT", },
631 void lcd_ctrl_init(void *lcdbase)
633 int color_depth = 24;
634 const char *video_mode = karo_get_vmode(getenv("video_mode"));
638 struct fb_videomode *p = tx28_fb_modes;
639 struct fb_videomode fb_mode;
640 int xres_set = 0, yres_set = 0, bpp_set = 0, refresh_set = 0;
643 debug("LCD disabled\n");
648 debug("Disabling LCD\n");
650 setenv("splashimage", NULL);
655 lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
657 if (video_mode == NULL) {
658 debug("Disabling LCD\n");
663 if (karo_fdt_get_fb_mode(working_fdt, video_mode, &fb_mode) == 0) {
665 debug("Using video mode from FDT\n");
667 if (fb_mode.xres > panel_info.vl_col ||
668 fb_mode.yres > panel_info.vl_row) {
669 printf("video resolution from DT: %dx%d exceeds hardware limits: %dx%d\n",
670 fb_mode.xres, fb_mode.yres,
671 panel_info.vl_col, panel_info.vl_row);
677 debug("Trying compiled-in video modes\n");
678 while (p->name != NULL) {
679 if (strcmp(p->name, vm) == 0) {
680 debug("Using video mode: '%s'\n", p->name);
687 debug("Trying to decode video_mode: '%s'\n", vm);
688 while (*vm != '\0') {
689 if (*vm >= '0' && *vm <= '9') {
692 val = simple_strtoul(vm, &end, 0);
695 if (val > panel_info.vl_col)
696 val = panel_info.vl_col;
698 panel_info.vl_col = val;
700 } else if (!yres_set) {
701 if (val > panel_info.vl_row)
702 val = panel_info.vl_row;
704 panel_info.vl_row = val;
706 } else if (!bpp_set) {
716 printf("Invalid color depth: '%.*s' in video_mode; using default: '%u'\n",
717 end - vm, vm, color_depth);
720 } else if (!refresh_set) {
747 if (p->xres == 0 || p->yres == 0) {
748 printf("Invalid video mode: %s\n", getenv("video_mode"));
750 printf("Supported video modes are:");
751 for (p = &tx28_fb_modes[0]; p->name != NULL; p++) {
752 printf(" %s", p->name);
757 if (p->xres > panel_info.vl_col || p->yres > panel_info.vl_row) {
758 printf("video resolution: %dx%d exceeds hardware limits: %dx%d\n",
759 p->xres, p->yres, panel_info.vl_col, panel_info.vl_row);
763 panel_info.vl_col = p->xres;
764 panel_info.vl_row = p->yres;
766 switch (color_depth) {
768 panel_info.vl_bpix = LCD_COLOR8;
771 panel_info.vl_bpix = LCD_COLOR16;
774 panel_info.vl_bpix = LCD_COLOR32;
777 p->pixclock = KHZ2PICOS(refresh *
778 (p->xres + p->left_margin + p->right_margin + p->hsync_len) *
779 (p->yres + p->upper_margin + p->lower_margin + p->vsync_len) /
781 debug("Pixel clock set to %lu.%03lu MHz\n",
782 PICOS2KHZ(p->pixclock) / 1000, PICOS2KHZ(p->pixclock) % 1000);
787 debug("Creating new display-timing node from '%s'\n",
789 ret = karo_fdt_create_fb_mode(working_fdt, video_mode, p);
791 printf("Failed to create new display-timing node from '%s': %d\n",
795 gpio_request_array(stk5_lcd_gpios, ARRAY_SIZE(stk5_lcd_gpios));
796 mxs_iomux_setup_multiple_pads(stk5_lcd_pads,
797 ARRAY_SIZE(stk5_lcd_pads));
799 debug("video format: %ux%u-%u@%u\n", p->xres, p->yres,
800 color_depth, refresh);
802 if (karo_load_splashimage(0) == 0) {
805 /* setup env variable for mxsfb display driver */
806 snprintf(vmode, sizeof(vmode),
807 "x:%d,y:%d,le:%d,ri:%d,up:%d,lo:%d,hs:%d,vs:%d,sync:%d,pclk:%d,depth:%d",
808 p->xres, p->yres, p->left_margin, p->right_margin,
809 p->upper_margin, p->lower_margin, p->hsync_len,
810 p->vsync_len, p->sync, p->pixclock, color_depth);
811 setenv("videomode", vmode);
813 debug("Initializing LCD controller\n");
815 setenv("videomode", NULL);
817 debug("Skipping initialization of LCD controller\n");
821 #define lcd_enabled 0
822 #endif /* CONFIG_LCD */
824 static void stk5_board_init(void)
826 gpio_request_array(stk5_gpios, ARRAY_SIZE(stk5_gpios));
827 mxs_iomux_setup_multiple_pads(stk5_pads, ARRAY_SIZE(stk5_pads));
830 static void stk5v3_board_init(void)
832 led_state = LED_STATE_INIT;
836 static void stk5v5_board_init(void)
840 /* init flexcan transceiver enable GPIO */
841 gpio_request_one(STK5_CAN_XCVR_GPIO, GPIOFLAG_OUTPUT_INIT_HIGH,
842 "Flexcan Transceiver");
843 mxs_iomux_setup_pad(STK5_CAN_XCVR_GPIO);
846 int board_late_init(void)
849 const char *baseboard;
854 setenv_ulong("safeboot", 1);
858 baseboard = getenv("baseboard");
862 printf("Baseboard: %s\n", baseboard);
864 if (strncmp(baseboard, "stk5", 4) == 0) {
865 if ((strlen(baseboard) == 4) ||
866 strcmp(baseboard, "stk5-v3") == 0) {
868 } else if (strcmp(baseboard, "stk5-v5") == 0) {
869 const char *otg_mode = getenv("otg_mode");
871 if (otg_mode && strcmp(otg_mode, "host") == 0) {
872 printf("otg_mode='%s' is incompatible with baseboard %s; setting to 'none'\n",
873 otg_mode, baseboard);
874 setenv("otg_mode", "none");
878 printf("WARNING: Unsupported STK5 board rev.: %s\n",
882 printf("WARNING: Unsupported baseboard: '%s'\n",
894 #define BOOT_CAUSE_MASK (RTC_PERSISTENT0_EXTERNAL_RESET | \
895 RTC_PERSISTENT0_ALARM_WAKE | \
896 RTC_PERSISTENT0_THERMAL_RESET)
898 static void thermal_init(void)
900 struct mxs_power_regs *power_regs = (void *)MXS_POWER_BASE;
901 struct mxs_clkctrl_regs *clkctrl_regs = (void *)MXS_CLKCTRL_BASE;
903 writel(POWER_THERMAL_LOW_POWER | POWER_THERMAL_OFFSET_ADJ_ENABLE |
904 POWER_THERMAL_OFFSET_ADJ_OFFSET(3),
905 &power_regs->hw_power_thermal);
907 writel(CLKCTRL_RESET_EXTERNAL_RESET_ENABLE |
908 CLKCTRL_RESET_THERMAL_RESET_ENABLE,
909 &clkctrl_regs->hw_clkctrl_reset);
914 struct mxs_power_regs *power_regs = (void *)MXS_POWER_BASE;
915 u32 pwr_sts = readl(&power_regs->hw_power_sts);
916 u32 pwrup_src = (pwr_sts >> 24) & 0x3f;
917 const char *dlm = "";
919 printf("Board: Ka-Ro TX28-4%sx%d\n", TX28_MOD_SUFFIX,
920 CONFIG_SYS_SDRAM_SIZE / SZ_128M +
921 CONFIG_SYS_NAND_BLOCKS / 2048 * 2);
923 printf("POWERUP Source: ");
924 if (pwrup_src & (3 << 0)) {
925 printf("%sPSWITCH %s voltage", dlm,
926 pwrup_src & (1 << 1) ? "HIGH" : "MID");
929 if (pwrup_src & (1 << 4)) {
930 printf("%sRTC", dlm);
933 if (pwrup_src & (1 << 5)) {
939 if (boot_cause & BOOT_CAUSE_MASK) {
941 printf("Last boot cause: ");
942 if (boot_cause & RTC_PERSISTENT0_EXTERNAL_RESET) {
943 printf("%sEXTERNAL", dlm);
946 if (boot_cause & RTC_PERSISTENT0_THERMAL_RESET) {
947 printf("%sTHERMAL", dlm);
952 if (boot_cause & RTC_PERSISTENT0_ALARM_WAKE) {
953 printf("%sALARM WAKE", dlm);
959 while (pwr_sts & POWER_STS_THERMAL_WARNING) {
960 static int first = 1;
963 printf("CPU too hot to boot\n");
968 pwr_sts = readl(&power_regs->hw_power_sts);
971 if (!(boot_cause & RTC_PERSISTENT0_THERMAL_RESET))
977 #if defined(CONFIG_OF_BOARD_SETUP)
978 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
979 #include <jffs2/jffs2.h>
980 #include <mtd_node.h>
981 static struct node_info tx28_nand_nodes[] = {
982 { "fsl,imx28-gpmi-nand", MTD_DEV_TYPE_NAND, },
985 #define fdt_fixup_mtdparts(b,n,c) do { } while (0)
988 static const char *tx28_touchpanels[] = {
994 int ft_board_setup(void *blob, bd_t *bd)
996 const char *baseboard = getenv("baseboard");
997 int stk5_v5 = baseboard != NULL && (strcmp(baseboard, "stk5-v5") == 0);
998 const char *video_mode = karo_get_vmode(getenv("video_mode"));
1001 ret = fdt_increase_size(blob, 4096);
1003 printf("Failed to increase FDT size: %s\n", fdt_strerror(ret));
1006 #ifdef CONFIG_TX28_S
1007 /* TX28-41xx (aka TX28S) has no external RTC
1008 * and no I2C GPIO extender
1010 karo_fdt_remove_node(blob, "ds1339");
1011 karo_fdt_remove_node(blob, "gpio5");
1014 karo_fdt_enable_node(blob, "stk5led", 0);
1016 fdt_fixup_mtdparts(blob, tx28_nand_nodes, ARRAY_SIZE(tx28_nand_nodes));
1018 karo_fdt_fixup_touchpanel(blob, tx28_touchpanels,
1019 ARRAY_SIZE(tx28_touchpanels));
1020 karo_fdt_fixup_usb_otg(blob, "usbotg", "fsl,usbphy", "vbus-supply");
1021 karo_fdt_fixup_flexcan(blob, stk5_v5);
1022 karo_fdt_update_fb_mode(blob, video_mode);
1026 #endif /* CONFIG_OF_BOARD_SETUP */