2 * Copyright (C) 2009 Samsung Electronics
3 * Kyungmin Park <kyungmin.park@samsung.com>
4 * Minkyu Kang <mk7.kang@samsung.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <asm/arch/clk.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/keypad.h>
33 #include <asm/arch/mmc.h>
34 #include <asm/arch/power.h>
35 #include <asm/arch/mem.h>
36 #include <asm/errno.h>
39 #include <bmp_layout.h>
41 #include "animation_frames.h"
42 #include "gpio_setting.h"
44 DECLARE_GLOBAL_DATA_PTR;
46 #define C100_MACH_START 3000
47 #define C110_MACH_START 3100
49 /* FIXME Neptune workaround */
50 #define USE_NEPTUNE_BOARD
51 #undef USE_NEPTUNE_BOARD
53 static unsigned int board_rev;
54 static unsigned int battery_soc;
55 static struct s5pc110_gpio *s5pc110_gpio;
72 static struct i2c_gpio_bus_data i2c_2 = {
82 static struct i2c_gpio_bus_data i2c_gpio3 = {
92 static struct i2c_gpio_bus_data i2c_pmic = {
102 static struct i2c_gpio_bus_data i2c_gpio5 = {
112 static struct i2c_gpio_bus_data i2c_gpio6 = {
122 static struct i2c_gpio_bus_data i2c_gpio7 = {
128 * i2c gpio7 - cypress
132 static struct i2c_gpio_bus_data i2c_cypress_gpio7 = {
142 static struct i2c_gpio_bus_data i2c_gpio10 = {
148 static struct i2c_gpio_bus i2c_gpio[] = {
166 u32 get_board_rev(void)
171 static int hwrevision(int rev)
173 return (board_rev & 0xf) == rev;
180 MACH_P1P2, /* Don't remove it */
187 #define SPLIT_SCREEN_FEATURE 0x100
189 /* board is MACH_AQUILA and board is like below. */
190 #define J1_B2_BOARD 0x0200
191 #define LIMO_UNIVERSAL_BOARD 0x0400
192 #define LIMO_REAL_BOARD 0x0800
193 #define MEDIA_BOARD 0x1000
194 #define BAMBOO_BOARD 0x2000
195 #define ARIES_BOARD 0x4000
196 #define NEPTUNE_BOARD 0x8000
198 #define BOARD_MASK 0xFF00
200 static int c110_machine_id(void)
202 return gd->bd->bi_arch_number - C110_MACH_START;
205 static int machine_is_aquila(void)
207 return c110_machine_id() == MACH_AQUILA;
210 static int machine_is_tickertape(void)
212 return c110_machine_id() == MACH_TICKERTAPE;
215 static int machine_is_geminus(void)
217 return c110_machine_id() == MACH_GEMINUS;
220 static int machine_is_cypress(void)
222 return c110_machine_id() == MACH_CYPRESS;
225 static int board_is_limo_universal(void)
227 return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
230 static int board_is_limo_real(void)
232 return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
235 static int board_is_media(void)
237 return machine_is_aquila() && (board_rev & MEDIA_BOARD);
240 static int board_is_bamboo(void)
242 return machine_is_aquila() && (board_rev & BAMBOO_BOARD);
245 static int board_is_j1b2(void)
247 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
250 static int board_is_aries(void)
252 return machine_is_aquila() && (board_rev & ARIES_BOARD);
255 static int board_is_neptune(void)
257 return machine_is_aquila() && (board_rev & NEPTUNE_BOARD);
261 static int machine_is_wmg160(void)
263 return c110_machine_id() == MACH_WMG160;
266 static void enable_battery(void);
268 void i2c_init_board(void)
270 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
273 if (cpu_is_s5pc100())
276 num_bus = ARRAY_SIZE(i2c_gpio);
278 if (machine_is_aquila()) {
279 if (board_is_aries()) {
280 i2c_gpio[I2C_GPIO7].bus->gpio_base =
281 (unsigned int)&gpio->gpio_mp0_5;
283 i2c_gpio[I2C_GPIO6].bus->gpio_base = 0;
284 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
286 } else if (machine_is_cypress()) {
287 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
288 i2c_gpio[I2C_GPIO7].bus->gpio_base =
289 (unsigned int)&gpio->gpio_mp0_5;
291 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
294 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
295 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
296 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
297 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
298 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
300 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
302 /* Reset on max17040 early */
303 if (battery_soc == 0)
307 #ifdef CONFIG_MISC_INIT_R
308 #define DEV_INFO_LEN 512
309 static char device_info[DEV_INFO_LEN];
310 static int display_info;
312 static void dprintf(const char *fmt, ...)
319 i = vsprintf(buf, fmt, args);
324 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
325 puts("Flushing device info...\n");
329 strcat(device_info, buf);
333 #ifdef CONFIG_S5PC1XXFB
334 static void display_device_info(void)
341 set_font_color(FONT_WHITE);
342 fb_printf(device_info);
345 memset(device_info, 0x0, DEV_INFO_LEN);
347 udelay(5 * 1000 * 1000);
351 static const char *board_name[] = {
355 "P1P2", /* Don't remove it */
368 static char feature_buffer[32];
370 static char *display_features(int board, int board_rev)
373 char *buf = feature_buffer;
376 if (board == MACH_AQUILA) {
377 if (board_rev & SPLIT_SCREEN_FEATURE)
378 name = "SplitScreen";
379 if (board_rev & J1_B2_BOARD)
381 /* Limo Real or Universal */
382 if (board_rev & LIMO_REAL_BOARD)
384 else if (board_rev & LIMO_UNIVERSAL_BOARD)
385 name = "Limo Universal";
386 if (board_rev & MEDIA_BOARD)
388 if (board_rev & BAMBOO_BOARD)
390 if (board_rev & ARIES_BOARD)
392 if (board_rev & NEPTUNE_BOARD)
396 count += sprintf(buf + count, " - %s", name);
402 static char *get_board_name(int board)
404 if (board == MACH_WMG160)
406 return (char *) board_name[board];
409 static void check_board_revision(int board, int rev)
413 /* Limo Real or Universal */
414 if (rev & LIMO_UNIVERSAL_BOARD)
415 board_rev &= ~J1_B2_BOARD;
416 if (rev & LIMO_REAL_BOARD)
417 board_rev &= ~(J1_B2_BOARD |
418 LIMO_UNIVERSAL_BOARD);
419 if (rev & MEDIA_BOARD)
420 board_rev &= ~(J1_B2_BOARD |
421 LIMO_UNIVERSAL_BOARD);
422 if (rev & BAMBOO_BOARD)
423 board_rev &= ~(J1_B2_BOARD |
424 LIMO_UNIVERSAL_BOARD |
427 if (rev & ARIES_BOARD)
428 board_rev &= ~(J1_B2_BOARD |
429 LIMO_UNIVERSAL_BOARD);
430 if (rev & NEPTUNE_BOARD)
431 board_rev &= ~(J1_B2_BOARD |
432 LIMO_UNIVERSAL_BOARD);
435 case MACH_TICKERTAPE:
438 board_rev &= ~BOARD_MASK;
445 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank, int hwrev3)
453 gpio_direction_input(bank, 2);
454 gpio_direction_input(bank, 3);
455 gpio_direction_input(bank, 4);
456 gpio_direction_input(bank, mode3);
458 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
459 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
460 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
461 gpio_set_pull(bank, mode3, GPIO_PULL_NONE); /* HWREV_MODE3 */
463 rev = gpio_get_value(bank, 2);
464 rev |= (gpio_get_value(bank, 3) << 1);
465 rev |= (gpio_get_value(bank, 4) << 2);
466 rev |= (gpio_get_value(bank, mode3) << 3);
471 static void check_hw_revision(void)
473 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
475 if (cpu_is_s5pc100()) {
476 struct s5pc100_gpio *gpio =
477 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
479 board_rev = get_hw_revision(&gpio->gpio_j0, 0);
481 /* C100 TickerTape */
483 board = MACH_TICKERTAPE;
485 struct s5pc110_gpio *gpio =
486 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
492 * Note Check 'Aquila' board first
496 * LRA: Limo Real Aquila
497 * LUA: Limo Universal Aquila
502 * ADDR = 0xE0200000 + OFF
504 * OFF Universal BB LRA LUA OA TT SS CYP
505 * J1: 0x0264 0x10 0x10 0x00 0x00 0x00 0x00 0x00
506 * J2: 0x0284 0x01 0x10 0x00
507 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x0F
508 * H3: 0x0C64 0x03 0x07 0x0F
509 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
510 * I: 0x0224 0x02 0x00 0x08
511 * MP03: 0x0324 0x9x 0xbx 0x9x
512 * MP05: 0x0364 0x80 0x88
516 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
518 board_rev |= J1_B2_BOARD;
520 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
521 gpio_direction_input(&gpio->gpio_j2, 6);
524 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
525 board_rev |= LIMO_UNIVERSAL_BOARD;
527 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
528 board_rev |= LIMO_REAL_BOARD;
530 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
531 board_rev |= MEDIA_BOARD;
533 /* set gpio to default value. */
534 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
535 gpio_direction_output(&gpio->gpio_j2, 6, 0);
538 /* Workaround: C110 Aquila Rev0.6 */
539 if (board_rev == 6) {
541 board_rev |= LIMO_REAL_BOARD;
544 /* C110 Aquila Bamboo */
545 if (gpio_get_value(&gpio->gpio_j2, 0) == 1) {
547 board_rev |= BAMBOO_BOARD;
550 /* C110 TickerTape */
551 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
552 gpio_get_value(&gpio->gpio_d1, 1) == 0)
553 board = MACH_TICKERTAPE;
555 /* C110 Geminus for rev0.0 */
556 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
557 gpio_direction_input(&gpio->gpio_j1, 2);
558 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
559 board = MACH_GEMINUS;
560 if ((board_rev & ~BOARD_MASK) == 3)
563 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
564 gpio_direction_output(&gpio->gpio_j1, 2, 0);
566 /* C110 Geminus for rev0.1 ~ */
567 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
568 gpio_direction_input(&gpio->gpio_j0, 6);
569 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
570 board = MACH_GEMINUS;
573 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
575 /* Aquila - Aries MP0_5[6] == 1 */
576 gpio_direction_input(&gpio->gpio_mp0_5, 6);
577 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
578 /* Cypress: Do this for cypress */
579 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
580 gpio_direction_input(&gpio->gpio_j2, 2);
581 if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
582 board = MACH_CYPRESS;
583 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
586 board_rev |= ARIES_BOARD;
587 #ifdef USE_NEPTUNE_BOARD
588 board_rev &= ~ARIES_BOARD;
589 board_rev |= NEPTUNE_BOARD;
592 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
595 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
602 for (i = 0; i < 8; i++) {
603 if (gpio_get_value(&gpio->gpio_h1, i) != 0) {
615 board_rev |= get_hw_revision(&gpio->gpio_j0, hwrev3);
619 if (cpu_is_s5pc110())
620 gd->bd->bi_arch_number = C110_MACH_START + board;
622 gd->bd->bi_arch_number = C100_MACH_START + board;
624 /* Architecture Common settings */
625 if (cpu_is_s5pc110()) {
626 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
628 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
630 setenv("updatek", "onenand erase 0x60000 0x300000; "
631 "onenand write 0x31008000 0x60000 0x300000");
635 static void show_hw_revision(void)
640 * Workaround for Rev 0.3 + CP Ver ES 3.1
643 if (board_is_limo_real()) {
645 /* default is Rev 0.4 */
651 if (cpu_is_s5pc110())
652 board = gd->bd->bi_arch_number - C110_MACH_START;
654 board = gd->bd->bi_arch_number - C100_MACH_START;
656 check_board_revision(board, board_rev);
658 /* Set CPU Revision */
659 if (machine_is_aquila()) {
660 if (board_is_limo_real()) {
661 if ((board_rev & 0xf) < 8)
662 s5pc1xx_set_cpu_rev(0);
664 } else if (machine_is_geminus()) {
665 if ((board_rev & 0xf) < 1)
666 s5pc1xx_set_cpu_rev(0);
668 s5pc1xx_set_cpu_rev(0);
671 dprintf("HW Revision:\t%x (%s%s) %s\n",
672 board_rev, get_board_name(board),
673 display_features(board, board_rev),
674 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
677 static void check_auto_burn(void)
679 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
680 unsigned int count = 0;
683 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
684 printf("Auto burning bootloader\n");
685 count += sprintf(buf + count, "run updateb; ");
687 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
688 printf("Auto burning kernel\n");
689 count += sprintf(buf + count, "run updatek; ");
693 count += sprintf(buf + count, "reset");
694 setenv("bootcmd", buf);
697 /* Clear the magic value */
698 writel(0xa5a55a5a, magic_base);
699 writel(0xa5a55a5a, magic_base + 0x4);
702 static void pmic_pin_init(void)
704 unsigned int reg, value;
706 if (cpu_is_s5pc100())
709 /* AP_PS_HOLD: XEINT_0: GPH0[0]
710 * Note: Don't use GPIO PS_HOLD it doesn't work
712 reg = S5PC110_PS_HOLD_CONTROL;
714 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
715 S5PC110_PS_HOLD_DATA_HIGH |
716 S5PC110_PS_HOLD_OUT_EN;
719 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
720 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
721 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
724 static void enable_ldos(void)
726 if (cpu_is_s5pc100())
729 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
730 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
733 static void enable_t_flash(void)
735 if (!(board_is_limo_universal() || board_is_limo_real()))
738 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
739 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
742 static void setup_limo_real_gpios(void)
744 if (!board_is_limo_real())
748 * Note: Please write GPIO alphabet order
750 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
751 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
754 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
755 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
757 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
758 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
760 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
761 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
762 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
765 static void setup_media_gpios(void)
767 if (!board_is_media())
771 * Note: Please write GPIO alphabet order
773 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
774 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
776 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
777 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
778 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
781 #define KBR3 (1 << 3)
782 #define KBR2 (1 << 2)
783 #define KBR1 (1 << 1)
784 #define KBR0 (1 << 0)
786 static void check_keypad(void)
788 unsigned int reg, value;
789 unsigned int col_mask, row_mask;
790 unsigned int auto_download = 0;
791 unsigned int col_value[4], i;
793 if (machine_is_wmg160())
796 if (cpu_is_s5pc100()) {
797 struct s5pc100_gpio *gpio =
798 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
800 /* Set GPH2[2:0] to KP_COL[2:0] */
801 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
802 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
803 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
805 /* Set GPH3[2:0] to KP_ROW[2:0] */
806 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
807 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
808 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
810 reg = S5PC100_KEYPAD_BASE;
812 if (board_is_limo_real() || board_is_limo_universal()) {
820 for (i = 0; i < 4; i++) {
821 /* Set GPH3[3:0] to KP_ROW[3:0] */
822 if (row_mask & (0xF << (i << 2))) {
823 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
824 gpio_set_pull(&s5pc110_gpio->gpio_h3, i,
828 /* Set GPH2[3:0] to KP_COL[3:0] */
829 if (col_mask & (0xF << (i << 2)))
830 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
833 reg = S5PC110_KEYPAD_BASE;
837 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
838 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
839 /* VOLUMEDOWN and CAM(Half shot) Button */
840 if ((value & KBR1) == 0) {
843 value = readl(reg + S5PC1XX_KEYIFCOL_OFFSET);
846 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
848 col_value[i++] = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
850 writel(0x00, reg + S5PC1XX_KEYIFCOL_OFFSET);
852 /* expected value is row_value[0] = 0x00 row_value[1] = 0x01 */
854 if (col_value[1] == 0xd && col_value[2] == 0xe && machine_is_geminus())
857 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) == 0x3)
860 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) != 0x3)
865 setenv("bootcmd", "usbdown");
868 static void enable_battery(void)
870 unsigned char val[2];
871 unsigned char addr = 0x36; /* max17040 fuel gauge */
873 i2c_set_bus_num(I2C_GPIO3);
875 if (machine_is_aquila()) {
876 if (board_is_aries() || board_is_neptune())
877 i2c_set_bus_num(I2C_GPIO7);
878 else if (board_is_j1b2())
880 } else if (machine_is_tickertape()) {
882 } else if (machine_is_cypress()) {
883 i2c_set_bus_num(I2C_GPIO7);
884 } else if (machine_is_geminus()) {
886 i2c_set_bus_num(I2C_GPIO7);
889 if (i2c_probe(addr)) {
890 printf("Can't found max17040 fuel gauge\n");
896 i2c_write(addr, 0xfe, 1, val, 2);
899 static void check_battery(void)
901 unsigned char val[2];
902 unsigned char addr = 0x36; /* max17040 fuel gauge */
904 i2c_set_bus_num(I2C_GPIO3);
906 if (machine_is_aquila()) {
907 if (board_is_aries() || board_is_neptune())
908 i2c_set_bus_num(I2C_GPIO7);
909 else if (board_is_j1b2())
911 } else if (machine_is_cypress()) {
912 i2c_set_bus_num(I2C_GPIO7);
913 } else if (machine_is_geminus()) {
915 i2c_set_bus_num(I2C_GPIO7);
919 if (i2c_probe(addr)) {
920 printf("Can't found max17040 fuel gauge\n");
924 i2c_read(addr, 0x04, 1, val, 1);
926 dprintf("battery:\t%d%%\n", val[0]);
928 battery_soc = val[0];
931 static void check_mhl(void)
933 unsigned char val[2];
934 unsigned char addr = 0x39; /* SIL9230 */
936 /* MHL Power enable */
937 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
938 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
940 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
941 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
943 /* 10ms required after reset */
947 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
949 i2c_set_bus_num(I2C_GPIO5);
952 if (i2c_probe(addr)) {
953 printf("Can't found MHL Chip\n");
959 * set to Normal operation
962 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
963 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
968 * 00 = MHL termination ON
969 * 11 = MHL termination OFF
972 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
973 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
976 #define CHARGER_ANIMATION_FRAME 6
977 static int max8998_power_key(void)
979 unsigned char addr, val[2];
980 i2c_set_bus_num(I2C_PMIC);
982 if (i2c_probe(addr)) {
983 printf("Can't found max8998\n");
987 /* Accessing IRQ1 register */
988 i2c_read(addr, 0x00, 1, val, 1);
989 if (val[0] & (1 << 6))
995 extern void lcd_display_clear(void);
996 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
998 static void into_charge_mode(void)
1000 unsigned char addr = 0xCC >> 1; /* max8998 */;
1001 unsigned char val[2];
1006 ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1008 i2c_set_bus_num(I2C_PMIC);
1010 if (i2c_probe(addr)) {
1011 printf("Can't found max8998\n");
1015 printf("Charge Mode\n");
1017 i2c_read(addr, 0x0C, 1, val, 1);
1018 val[0] &= ~(0x7 << 0);
1019 val[0] |= 5; /* 600mA */
1020 i2c_write(addr, 0x0C, 1, val, 1);
1022 #ifdef CONFIG_S5PC1XXFB
1025 /* TODO: write the image-text for the charger */
1027 level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1028 if (level >= CHARGER_ANIMATION_FRAME)
1029 level = CHARGER_ANIMATION_FRAME - 1;
1031 for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1032 bmp_addr[i] = (ulong)battery_charging_animation[i];
1034 lcd_display_clear();
1035 for (i = 0; i < 3; i++) {
1036 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1039 bmp = gunzip_bmp(bmp_addr[j], &len);
1040 lcd_display_bitmap((ulong) bmp, 140, 202);
1043 for (k = 0; k < 10; k++)
1044 if (max8998_power_key()) {
1045 lcd_display_clear();
1046 /* FIXME don't use static function */
1047 /* draw_samsung_logo(lcd_base); */
1056 /* EVT0: sleep 1, EVT1: sleep */
1057 if (s5pc1xx_get_cpu_rev() == 0) {
1058 run_command("sleep 1", 0);
1062 run_command("sleep", 0);
1065 static void check_micro_usb(int intr)
1068 unsigned char val[2];
1069 static int started_charging_once = 0;
1072 if (cpu_is_s5pc100())
1075 if (board_is_limo_real()) {
1076 if (hwrevision(0) || hwrevision(1))
1080 i2c_set_bus_num(I2C_PMIC);
1082 if (machine_is_aquila()) {
1083 if (board_is_aries() || board_is_neptune())
1084 i2c_set_bus_num(I2C_GPIO6);
1085 } else if (machine_is_cypress()) {
1086 i2c_set_bus_num(I2C_GPIO6);
1087 } else if (machine_is_geminus()) {
1089 i2c_set_bus_num(I2C_GPIO6);
1090 } else if (machine_is_wmg160())
1091 i2c_set_bus_num(I2C_GPIO6);
1093 addr = 0x25; /* fsa9480 */
1094 if (i2c_probe(addr)) {
1095 printf("Can't found fsa9480\n");
1099 /* Clear Interrupt */
1101 i2c_read(addr, 0x03, 1, val, 2);
1105 /* Read Device Type 1 */
1106 i2c_read(addr, 0x0a, 1, val, 1);
1108 #define FSA_DEDICATED_CHARGER (1 << 6)
1109 #define FSA_UART (1 << 3)
1110 #define FSA_USB (1 << 2)
1113 * If USB, use default 475mA
1114 * If Charger, use 600mA and go to charge mode
1116 if ((val[0] & FSA_DEDICATED_CHARGER) && !started_charging_once) {
1117 started_charging_once = 1;
1121 /* If Factory Mode is Boot ON-USB, go to download mode */
1122 i2c_read(addr, 0x07, 1, val, 1);
1124 #define FSA_ADC_FAC_USB 0x19
1125 #define FSA_ADC_FAC_UART 0x1d
1127 if (val[0] == FSA_ADC_FAC_USB)
1128 setenv("bootcmd", "usbdown");
1130 path = getenv("usb");
1132 if (!strncmp(path, "cp", 2))
1133 run_command("microusb cp", 0);
1136 static void micro_usb_switch(int path)
1139 unsigned char val[2];
1141 i2c_set_bus_num(I2C_PMIC);
1143 if (machine_is_aquila()) {
1144 if (board_is_aries() || board_is_neptune())
1145 i2c_set_bus_num(I2C_GPIO6);
1146 } else if (machine_is_cypress()) {
1147 i2c_set_bus_num(I2C_GPIO6);
1148 } else if (machine_is_geminus()) {
1150 i2c_set_bus_num(I2C_GPIO6);
1151 } else if (machine_is_wmg160())
1152 i2c_set_bus_num(I2C_GPIO6);
1154 addr = 0x25; /* fsa9480 */
1155 if (i2c_probe(addr)) {
1156 printf("Can't found fsa9480\n");
1161 val[0] = 0x90; /* VAUDIO */
1163 val[0] = 0x24; /* DHOST */
1165 i2c_write(addr, 0x13, 1, val, 1); /* MANSW1 */
1167 i2c_read(addr, 0x2, 1, val, 1);
1168 val[0] &= ~(1 << 2);
1169 i2c_write(addr, 0x2, 1, val, 1);
1172 #define MAX8998_REG_ONOFF1 0x11
1173 #define MAX8998_REG_ONOFF2 0x12
1174 #define MAX8998_REG_ONOFF3 0x13
1175 #define MAX8998_REG_LDO7 0x21
1176 #define MAX8998_REG_LDO17 0x29
1178 #define MAX8998_LDO3 (1 << 2)
1180 #define MAX8998_LDO6 (1 << 7)
1181 #define MAX8998_LDO7 (1 << 6)
1182 #define MAX8998_LDO8 (1 << 5)
1183 #define MAX8998_LDO9 (1 << 4)
1184 #define MAX8998_LDO10 (1 << 3)
1185 #define MAX8998_LDO11 (1 << 2)
1186 #define MAX8998_LDO12 (1 << 1)
1187 #define MAX8998_LDO13 (1 << 0)
1189 #define MAX8998_LDO14 (1 << 7)
1190 #define MAX8998_LDO15 (1 << 6)
1191 #define MAX8998_LDO16 (1 << 5)
1192 #define MAX8998_LDO17 (1 << 4)
1195 static void init_pmic(void)
1198 unsigned char val[2];
1200 if (cpu_is_s5pc100())
1203 i2c_set_bus_num(I2C_PMIC);
1205 addr = 0xCC >> 1; /* max8998 */
1206 if (i2c_probe(addr)) {
1207 if (i2c_probe(addr)) {
1208 printf("Can't found max8998\n");
1214 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1215 val[0] &= ~MAX8998_LDO3;
1216 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1219 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1221 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1222 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1224 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1225 MAX8998_LDO12 | MAX8998_LDO13);
1227 if (board_is_aries() || board_is_neptune())
1228 val[0] |= MAX8998_LDO7; /* LDO7: VLCD_1.8V */
1230 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1231 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1233 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1235 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1236 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1238 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1239 MAX8998_LDO16 | MAX8998_LDO17);
1241 if (board_is_aries() || board_is_neptune())
1242 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1244 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1245 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1248 static void setup_power_down_mode_registers(void)
1250 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1251 struct s5pc1xx_gpio_bank *bank;
1252 struct gpio_powermode *p;
1254 struct gpio_external *ge;
1256 struct s5pc1xx_gpio_item *mr;
1260 if (cpu_is_s5pc100())
1263 /* Only Limo real and aries supports worked for sleep currnet */
1264 if (machine_is_aquila()) {
1265 if (board_is_limo_real())
1267 else if (board_is_aries() || board_is_neptune())
1271 } else if (machine_is_geminus()) {
1276 if (machine_is_aquila()) {
1277 if (board_is_aries() || board_is_neptune()) {
1278 /* Aquila rev 0.9 */
1279 p = aries_powerdown_modes;
1280 ge = aries_external_powerdown_modes;
1281 mr = aries_mirror_powerdown_mode;
1282 n_p = ARRAY_SIZE(aries_powerdown_modes);
1283 n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1284 n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1286 /* Aquila rev 0.8 or lower */
1287 p = aquila_powerdown_modes;
1288 ge = aquila_external_powerdown_modes;
1289 mr = aquila_mirror_powerdown_mode;
1290 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1291 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1292 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1294 } else if (machine_is_geminus()) {
1295 if (hwrevision(1)) {
1296 /* Same as Aquila rev 0.9 */
1298 p = aries_powerdown_modes;
1299 ge = aries_external_powerdown_modes;
1300 mr = aries_mirror_powerdown_mode;
1301 n_p = ARRAY_SIZE(aries_powerdown_modes);
1302 n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1303 n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1305 p = aquila_powerdown_modes;
1306 ge = aquila_external_powerdown_modes;
1307 mr = aquila_mirror_powerdown_mode;
1308 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1309 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1310 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1312 } else if (hwrevision(0)) {
1313 /* Same as Aquila rev 0.8 or lower */
1314 p = aquila_powerdown_modes;
1315 ge = aquila_external_powerdown_modes;
1316 mr = aquila_mirror_powerdown_mode;
1317 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1318 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1319 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1321 return; /* Not supported */
1325 bank = &gpio->gpio_a0;
1327 for (i = 0; i < n_p; i++, p++, bank++) {
1328 writel(p->conpdn, &bank->pdn_con);
1329 writel(p->pudpdn, &bank->pdn_pull);
1332 writel(0xff0022b0, (unsigned int *)0xF0000000);
1333 writel(0xff0022b0, (unsigned int *)0xF1400000);
1335 bank = &gpio->gpio_h0;
1337 for (i = 0; i < n_ge; i++) {
1338 writel(ge->con, &bank->con);
1339 writel(ge->dat, &bank->dat);
1340 writel(ge->pud, &bank->pull);
1346 for (i = 0; i < n_mr; i++) {
1347 unsigned int reg = readl(&mr->bank->pdn_con);
1348 reg &= ~(1 << mr->number);
1349 if (readl(&mr->bank->dat) & (1 << mr->number))
1350 reg |= 1 << mr->number;
1351 writel(reg, &mr->bank->pdn_con);
1353 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1360 struct spi_platform_data {
1361 struct s5pc1xx_gpio_bank *cs_bank;
1362 struct s5pc1xx_gpio_bank *clk_bank;
1363 struct s5pc1xx_gpio_bank *si_bank;
1364 struct s5pc1xx_gpio_bank *so_bank;
1366 unsigned int cs_num;
1367 unsigned int clk_num;
1368 unsigned int si_num;
1369 unsigned int so_num;
1371 unsigned int board_is_media;
1374 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1375 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1377 struct spi_platform_data spi_pd;
1379 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1381 void lcd_cfg_gpio(void)
1383 unsigned int i, f3_end = 4;
1385 for (i = 0; i < 8; i++) {
1386 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1387 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1388 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1389 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1390 /* pull-up/down disable */
1391 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1392 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1393 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1395 /* drive strength to max (24bit) */
1396 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1397 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1398 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1399 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1400 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1401 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1404 /* set DISPLAY_DE_B pin for dual rgb mode. */
1405 if (board_is_media())
1408 for (i = 0; i < f3_end; i++) {
1409 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1410 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1411 /* pull-up/down disable */
1412 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1413 /* drive strength to max (24bit) */
1414 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1415 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1417 /* display output path selection (only [1:0] valid) */
1418 writel(0x2, 0xE0107008);
1420 /* gpio pad configuration for LCD reset. */
1421 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1423 /* gpio pad configuration for LCD ON. */
1424 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1426 /* LCD_BACKLIGHT_EN */
1427 if (machine_is_geminus())
1428 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1431 * gpio pad configuration for
1432 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1434 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1435 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1436 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1437 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1439 if (machine_is_aquila()) {
1440 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1442 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1444 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1446 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1449 if (board_is_neptune())
1450 s6d16a0x_set_platform_data(&spi_pd);
1452 s6e63m0_set_platform_data(&spi_pd);
1453 if (board_is_media())
1454 spi_pd.board_is_media = 1;
1458 if (machine_is_cypress()) {
1459 #if 0 /* universal cypress */
1461 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1464 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1466 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1468 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1470 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1472 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1473 #if 0 /* universal cypress */
1474 pd_cs.bank = &gpio_base->gpio_mp0_1;
1477 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1479 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1481 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1484 /* these data would be sent to s6e63m0 lcd panel driver. */
1485 s6e63m0_set_platform_data(&spi_pd);
1491 void backlight_on(unsigned int onoff)
1493 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1496 if (machine_is_geminus())
1497 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1499 if (machine_is_geminus())
1500 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1504 void reset_lcd(void)
1506 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1508 if (machine_is_aquila() || machine_is_geminus())
1509 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1510 if (machine_is_cypress())
1511 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1514 void lcd_power_on(unsigned int onoff)
1516 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1519 if (machine_is_aquila() || machine_is_geminus())
1520 gpio_set_value(&gpio->gpio_j1, 3, 1);
1522 if (machine_is_cypress())
1523 gpio_set_value(&gpio->gpio_g2, 2, 1);
1525 if (board_is_aries() || board_is_neptune()) {
1527 unsigned char val[2];
1528 unsigned char val2[2];
1530 i2c_set_bus_num(I2C_PMIC);
1531 addr = 0xCC >> 1; /* max8998 */
1532 if (i2c_probe(addr)) {
1533 printf("Can't found max8998\n");
1536 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1537 val[0] &= ~(MAX8998_LDO17);
1538 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1539 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1541 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1542 val[0] |= MAX8998_LDO17;
1544 i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1545 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1547 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1548 val[0] |= MAX8998_LDO7;
1550 i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1551 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1554 if (machine_is_aquila() || machine_is_geminus())
1555 gpio_set_value(&gpio->gpio_j1, 3, 0);
1557 if (machine_is_cypress())
1558 gpio_set_value(&gpio->gpio_g2, 2, 0);
1560 if (board_is_aries() || board_is_neptune()) {
1562 unsigned char val[2];
1564 i2c_set_bus_num(I2C_PMIC);
1565 addr = 0xCC >> 1; /* max8998 */
1566 if (i2c_probe(addr)) {
1567 printf("Can't found max8998\n");
1571 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1572 val[0] &= ~(1 << 7);
1573 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1574 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1576 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1577 val[0] &= ~MAX8998_LDO17;
1578 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1579 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1584 extern void s6e63m0_cfg_ldo(void);
1585 extern void s6e63m0_enable_ldo(unsigned int onoff);
1586 extern void s6d16a0x_cfg_ldo(void);
1587 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1589 int s5p_no_lcd_support(void)
1591 if (machine_is_wmg160())
1596 void init_panel_info(vidinfo_t *vid)
1598 vid->cfg_gpio = NULL;
1599 vid->reset_lcd = NULL;
1600 vid->backlight_on = NULL;
1601 vid->lcd_power_on = NULL;
1603 vid->cfg_ldo = NULL;
1604 vid->enable_ldo = NULL;
1606 vid->init_delay = 0;
1607 vid->reset_delay = 0;
1608 vid->power_on_delay = 0;
1613 vid->vl_width = 480;
1614 vid->vl_height = 800;
1616 vid->dual_lcd_enabled = 0;
1618 if (board_is_media()) {
1621 vid->vl_width = 960;
1622 vid->vl_height = 800;
1624 /* enable dual lcd mode. */
1625 vid->dual_lcd_enabled = 1;
1628 vid->vl_clkp = CONFIG_SYS_HIGH;
1629 vid->vl_hsp = CONFIG_SYS_LOW;
1630 vid->vl_vsp = CONFIG_SYS_LOW;
1631 vid->vl_dp = CONFIG_SYS_HIGH;
1634 /* S6E63M0 LCD Panel */
1643 if (machine_is_aquila() || machine_is_cypress()) {
1644 vid->cfg_gpio = lcd_cfg_gpio;
1645 vid->reset_lcd = reset_lcd;
1646 vid->backlight_on = backlight_on;
1647 vid->lcd_power_on = lcd_power_on;
1648 vid->cfg_ldo = s6e63m0_cfg_ldo;
1649 vid->enable_ldo = s6e63m0_enable_ldo;
1651 vid->init_delay = 25000;
1652 vid->reset_delay = 120000;
1655 if (board_is_neptune()) {
1659 vid->vl_width = 320;
1660 vid->vl_height = 480;
1662 vid->vl_clkp = CONFIG_SYS_HIGH;
1663 vid->vl_hsp = CONFIG_SYS_HIGH;
1664 vid->vl_vsp = CONFIG_SYS_HIGH;
1665 vid->vl_dp = CONFIG_SYS_LOW;
1668 /* disable dual lcd mode. */
1669 vid->dual_lcd_enabled = 0;
1671 /* S6D16A0X LCD Panel */
1680 vid->cfg_gpio = lcd_cfg_gpio;
1681 vid->backlight_on = NULL;
1682 vid->lcd_power_on = lcd_power_on;
1683 vid->reset_lcd = reset_lcd;
1684 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1685 vid->enable_ldo = s6d16a0x_enable_ldo;
1687 vid->init_delay = 10000;
1688 vid->power_on_delay = 10000;
1689 vid->reset_delay = 1000;
1693 if (machine_is_geminus()) {
1697 vid->vl_width = 1024,
1698 vid->vl_height = 600,
1699 vid->vl_clkp = CONFIG_SYS_LOW,
1700 vid->vl_hsp = CONFIG_SYS_HIGH,
1701 vid->vl_vsp = CONFIG_SYS_HIGH,
1702 vid->vl_dp = CONFIG_SYS_LOW,
1713 vid->cfg_gpio = lcd_cfg_gpio;
1714 vid->reset_lcd = reset_lcd;
1715 vid->backlight_on = backlight_on;
1716 vid->lcd_power_on = lcd_power_on;
1722 vid->vl_width = 480,
1723 vid->vl_height = 800,
1724 vid->vl_clkp = CONFIG_SYS_HIGH,
1725 vid->vl_hsp = CONFIG_SYS_LOW,
1726 vid->vl_vsp = CONFIG_SYS_LOW,
1727 vid->vl_dp = CONFIG_SYS_HIGH,
1743 vid->vl_width = 1024,
1744 vid->vl_height = 600,
1745 vid->vl_clkp = CONFIG_SYS_HIGH,
1746 vid->vl_hsp = CONFIG_SYS_HIGH,
1747 vid->vl_vsp = CONFIG_SYS_HIGH,
1748 vid->vl_dp = CONFIG_SYS_LOW,
1751 /* AMS701KA AMOLED Panel. */
1763 static void setup_meminfo(void)
1765 char meminfo[64] = {0, };
1766 int count = 0, size, real;
1768 size = gd->bd->bi_dram[0].size >> 20;
1769 count += sprintf(meminfo + count, "mem=%dM", size);
1771 /* Each Chip Select can't exceed the 256MiB */
1772 size = gd->bd->bi_dram[1].size >> 20;
1773 real = min(size, 256);
1774 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1775 real, (unsigned int)gd->bd->bi_dram[1].start);
1779 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1780 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1783 setenv("meminfo", meminfo);
1787 * CSA partition Migration
1788 * It will be deleted
1790 static void csa_migration(void)
1792 unsigned int *ubi_id;
1795 run_command("onenand read 0x40000000 0x400000 0x400000", 0);
1797 for (i = 0; i < 10; i++) {
1798 ubi_id = (void *) (0x40000000 + 0x40000 * i);
1799 if (*ubi_id == 0x23494255) /* 0x23494255 = UBI */ {
1800 printf("CSA Migration is already done....\n");
1804 run_command("onenand erase 0x400000 0x800000", 0);
1807 int misc_init_r(void)
1810 /* It should be located at first */
1813 if (board_is_neptune())
1814 setenv("lcdinfo", "lcd=s6d16a0x");
1815 else if ((board_is_limo_real() ||
1816 board_is_limo_universal() ||
1818 setenv("lcdinfo", "lcd=s6e63m0");
1819 /* it can't classify tl2796 with single-lcd and dual-lcd.
1821 setenv("lcdinfo", "lcd=tl2796-dual");
1825 * env values below should be added in case that lcd panel of geminus.
1826 * setenv means that lcd panel has been turned on at u-boot.
1828 if (machine_is_geminus())
1829 setenv("lcdinfo", "lcd=lms480jc01");
1830 if (board_is_media())
1831 setenv("lcdinfo", "lcd=media");
1837 /* Set proper PMIC pins */
1840 /* Check auto burning */
1843 /* To power up I2C2 */
1846 /* Enable T-Flash at Limo Real or Limo Universal */
1849 /* Setup Limo Real board GPIOs */
1850 setup_limo_real_gpios();
1852 /* Setup Media board GPIOs */
1853 setup_media_gpios();
1855 /* To usbdown automatically */
1861 #ifdef CONFIG_S5PC1XXFB
1862 display_device_info();
1865 setup_power_down_mode_registers();
1867 /* check max17040 */
1873 /* csa migration (temporary) */
1880 int board_init(void)
1882 /* Set Initial global variables */
1883 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1885 gd->bd->bi_arch_number = MACH_TYPE;
1886 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1888 /* Check H/W Revision */
1889 check_hw_revision();
1896 unsigned int base, memconfig0, size;
1897 unsigned int memconfig1, sz = 0;
1899 if (cpu_is_s5pc100()) {
1900 /* In mem setup, we swap the bank. So below size is correct */
1901 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1902 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1903 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1906 /* In S5PC110, we can't swap the DMC0/1 */
1907 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1908 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1910 base = S5PC110_DMC1_BASE;
1911 /* DMC configuration */
1912 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1913 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1915 size = (memconfig0 >> 16) & 0xFF;
1916 size = ((unsigned char) ~size) + 1;
1919 * (0x07 + 1) * 16 = 128 MiB
1920 * (0x0f + 1) * 16 = 256 MiB
1925 * Aquila Rev0.5 4G3G1G
1926 * Aquila Rev0.8 4G3G1G
1927 * Aquila Rev0.9 4G3G1G
1929 if (machine_is_aquila() &&
1930 (hwrevision(5) || hwrevision(8) || hwrevision(9))) {
1931 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1933 sz = (memconfig1 >> 16) & 0xFF;
1934 sz = ((unsigned char) ~sz) + 1;
1940 * bi_dram[1].size contains all DMC1 memory size
1942 gd->bd->bi_dram[1].size = (size + sz) << 20;
1947 /* Used for sleep test */
1948 static unsigned char saved_val[4][2];
1949 void board_sleep_init_late(void)
1951 /* CODEC_LDO_EN: GPF3[4] */
1952 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1953 /* CODEC_XTAL_EN: GPH3[2] */
1954 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1956 /* MMC T_FLASH off */
1957 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1959 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1960 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1961 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1965 void board_sleep_init(void)
1968 unsigned char val[2];
1970 i2c_set_bus_num(I2C_PMIC);
1972 if (i2c_probe(addr)) {
1973 printf("Can't find max8998\n");
1978 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1979 saved_val[0][0] = val[0];
1980 saved_val[0][1] = val[1];
1981 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1982 (1 << 1) | (1 << 0));
1983 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1984 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1986 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1987 saved_val[1][0] = val[0];
1988 saved_val[1][1] = val[1];
1989 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1990 (1 << 2) | (1 << 1) | (1 << 0));
1992 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1993 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1995 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1996 saved_val[2][0] = val[0];
1997 saved_val[2][1] = val[1];
1998 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
1999 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2000 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2002 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2003 saved_val[3][0] = val[0];
2004 saved_val[3][1] = val[1];
2005 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2006 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2007 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2008 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2009 __FILE__, __LINE__);
2012 void board_sleep_resume(void)
2015 unsigned char val[2];
2019 i2c_set_bus_num(I2C_PMIC);
2021 if (i2c_probe(addr)) {
2022 printf("Can't find max8998\n");
2027 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2028 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2030 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2031 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2033 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2034 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2036 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2037 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2038 printf("Waked up.\n");
2040 /* check max17040 */
2047 #ifdef CONFIG_CMD_USBDOWN
2048 int usb_board_init(void)
2050 #ifdef CONFIG_CMD_PMIC
2051 run_command("pmic ldo 3 on", 0);
2054 if (cpu_is_s5pc100()) {
2055 #ifdef CONFIG_HARD_I2C
2056 uchar val[2] = {0,};
2059 if (i2c_read(0x66, 0, 1, val, 2)) {
2060 printf("i2c_read error\n");
2067 if (i2c_write(0x66, 0, 1, val, 2)) {
2068 printf("i2c_write error\n");
2071 i2c_read(0x66, 0, 1, val, 2);
2077 if (board_is_limo_universal() ||
2078 board_is_limo_real() ||
2080 /* check usb path */
2081 if (board_is_limo_real() && !hwrevision(6))
2085 if (machine_is_tickertape())
2086 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2087 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2089 /* USB Path to AP */
2090 micro_usb_switch(0);
2096 #ifdef CONFIG_GENERIC_MMC
2097 int board_mmc_init(bd_t *bis)
2101 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2104 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2105 if (machine_is_aquila() && (board_is_aries() || board_is_neptune()))
2106 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2108 if (machine_is_wmg160())
2111 /* MMC0 Clock source = SCLKMPLL */
2112 reg = readl(&clk->src4);
2115 writel(reg, &clk->src4);
2117 reg = readl(&clk->div4);
2120 /* set div value near 50MHz */
2121 clock = get_pll_clk(MPLL) / 1000000;
2122 for (i = 0; i < 0xf; i++) {
2123 if ((clock / (i + 1)) <= 50) {
2129 writel(reg, &clk->div4);
2135 * GPG0[2] SD_0_CDn -> Not used
2136 * GPG0[3:6] SD_0_DATA[0:3]
2138 for (i = 0; i < 7; i++) {
2141 /* GPG0[0:6] special function 2 */
2142 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2143 /* GPG0[0:6] pull disable */
2144 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2145 /* GPG0[0:6] drv 4x */
2146 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4x);
2149 return s5pc1xx_mmc_init(0);
2153 #ifdef CONFIG_CMD_PMIC
2154 static int pmic_status(void)
2156 unsigned char addr, val[2];
2159 i2c_set_bus_num(I2C_PMIC);
2161 if (i2c_probe(addr)) {
2162 printf("Can't found max8998\n");
2167 i2c_read(addr, reg, 1, val, 1);
2168 for (i = 7; i >= 4; i--)
2169 printf("BUCK%d %s\n", 7 - i + 1,
2170 val[0] & (1 << i) ? "on" : "off");
2172 printf("LDO%d %s\n", 5 - i,
2173 val[0] & (1 << i) ? "on" : "off");
2175 i2c_read(addr, reg, 1, val, 1);
2176 for (i = 7; i >= 0; i--)
2177 printf("LDO%d %s\n", 7 - i + 6,
2178 val[0] & (1 << i) ? "on" : "off");
2180 i2c_read(addr, reg, 1, val, 1);
2181 for (i = 7; i >= 4; i--)
2182 printf("LDO%d %s\n", 7 - i + 14,
2183 val[0] & (1 << i) ? "on" : "off");
2186 i2c_read(addr, reg, 1, val, 1);
2187 for (i = 7; i >= 6; i--)
2188 printf("SAFEOUT%d %s\n", 7 - i + 1,
2189 val[0] & (1 << i) ? "on" : "off");
2193 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2195 unsigned char addr, val[2];
2196 unsigned int reg, shift;
2204 } else if (ldo <= 13) {
2207 } else if (ldo <= 17) {
2209 shift = 17 - ldo + 4;
2216 shift = 4 - buck + 4;
2217 } else if (safeout) {
2221 shift = 8 - safeout;
2225 i2c_set_bus_num(I2C_PMIC);
2227 if (i2c_probe(addr)) {
2228 printf("Can't found max8998\n");
2232 i2c_read(addr, reg, 1, val, 1);
2234 val[0] |= (1 << shift);
2236 val[0] &= ~(1 << shift);
2237 i2c_write(addr, reg, 1, val, 1);
2238 i2c_read(addr, reg, 1, val, 1);
2241 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2242 val[0] & (1 << shift) ? "on" : "off");
2244 printf("buck %d value 0x%x, %s\n", buck, val[0],
2245 val[0] & (1 << shift) ? "on" : "off");
2247 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2248 val[0] & (1 << shift) ? "on" : "off");
2253 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2255 int buck = 0, ldo = 0, safeout = 0, on = -1;
2259 if (strncmp(argv[1], "status", 6) == 0)
2260 return pmic_status();
2263 if (strncmp(argv[1], "ldo", 3) == 0)
2264 ldo = simple_strtoul(argv[2], NULL, 10);
2265 else if (strncmp(argv[1], "buck", 4) == 0)
2266 buck = simple_strtoul(argv[2], NULL, 10);
2267 else if (strncmp(argv[1], "safeout", 7) == 0)
2268 safeout = simple_strtoul(argv[2], NULL, 10);
2272 if (strncmp(argv[3], "on", 2) == 0)
2274 else if (strncmp(argv[3], "off", 3) == 0)
2279 return pmic_ldo_control(buck, ldo, safeout, on);
2290 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2291 "PMIC LDO & BUCK control",
2292 "status - Display PMIC LDO & BUCK status\n"
2293 "pmic ldo num on/off - Turn on/off the LDO\n"
2294 "pmic buck num on/off - Turn on/off the BUCK\n"
2295 "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2299 #ifdef CONFIG_CMD_DEVICE_POWER
2313 static void power_display_devices(void)
2315 printf("devices:\n");
2316 printf("\t%d - touch\n", POWER_TOUCH);
2317 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2318 printf("\t%d - LCD\n", POWER_LCD);
2319 printf("\t%d - Haptic\n", POWER_HAPTIC);
2320 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2321 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2322 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2323 printf("\t%d - HDMI\n", POWER_HDMI);
2326 static int power_hdmi(int on)
2328 /* HDMI_EN1: GPJ2[2] */
2329 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2330 /* MHL_ON: GPJ2[3] */
2331 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2335 static int power_bt_wifi(int on)
2337 /* WLAN_BT_EN: GPB[5] */
2338 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2342 static int power_fm_radio(int on)
2344 /* FM_BUS_nRST: GPJ2[5] */
2345 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2349 static int power_audio_codec(int on)
2351 /* CODEC_LDO_EN: GPF3[4] */
2352 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2353 /* CODEC_XTAL_EN: GPH3[2] */
2354 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2358 static int power_haptic(int on)
2360 /* HAPTIC_ON: GPJ1[1] */
2361 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2365 static int power_lcd(int on)
2367 /* MLCD_ON: GPJ1[3] */
2368 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2372 static int power_touch(int on)
2374 /* TOUCH_EN: GPG3[6] */
2375 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2379 static int power_3_touchkey(int on)
2382 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2383 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2384 if (board_rev & J1_B2_BOARD)
2385 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2387 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2389 /* 3_TOUCH_CE - GPJ2[6] */
2390 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2392 /* 3_TOUCH_CE - GPJ2[6] */
2393 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2398 unsigned char val[2];
2399 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2405 i2c_set_bus_num(I2C_GPIO10);
2407 /* Workaround to probe */
2408 if (i2c_probe(addr)) {
2409 if (i2c_probe(addr)) {
2410 printf("Can't found 3 touchkey\n");
2415 #define MCS5000_TK_HW_VERSION 0x06
2416 #define MCS5000_TK_FW_VERSION 0x0A
2417 #define MCS5000_TK_MI_VERSION 0x0B
2419 reg = MCS5000_TK_MI_VERSION;
2420 i2c_read(addr, reg, 1, val, 1);
2421 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2422 reg = MCS5000_TK_HW_VERSION;
2423 i2c_read(addr, reg, 1, val, 1);
2424 printf("H/W 0x%x, ", val[0]);
2425 reg = MCS5000_TK_FW_VERSION;
2426 i2c_read(addr, reg, 1, val, 1);
2427 printf("F/W 0x%x\n", val[0]);
2432 static int power_control(int device, int on)
2436 return power_touch(on);
2437 case POWER_3_TOUCHKEY:
2438 return power_3_touchkey(on);
2440 return power_lcd(on);
2442 return power_haptic(on);
2443 case POWER_AUDIO_CODEC:
2444 return power_audio_codec(on);
2445 case POWER_FM_RADIO:
2446 return power_fm_radio(on);
2448 return power_bt_wifi(on);
2450 return power_hdmi(on);
2452 printf("I don't know device %d\n", device);
2458 static int power_on(int on)
2461 power_3_touchkey(on);
2464 power_audio_codec(on);
2472 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2476 if (!machine_is_aquila())
2481 if (strncmp(argv[1], "on", 2) == 0)
2483 if (strncmp(argv[1], "off", 3) == 0)
2487 device = simple_strtoul(argv[1], NULL, 10);
2491 if (strncmp(argv[2], "on", 2) == 0)
2493 else if (strncmp(argv[2], "off", 3) == 0)
2497 return power_control(device, on);
2503 power_display_devices();
2508 power, CONFIG_SYS_MAXARGS, 1, do_power,
2509 "Device Power Management control",
2510 "device on/off - Turn on/off the device\n"
2513 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2517 if (strncmp(argv[1], "cp", 2) == 0) {
2518 micro_usb_switch(1);
2519 pmic_ldo_control(0, 0, 2, 1);
2520 setenv("usb", "cp");
2521 } else if (strncmp(argv[1], "ap", 2) == 0) {
2522 micro_usb_switch(0);
2523 pmic_ldo_control(0, 0, 2, 0);
2524 setenv("usb", "ap");
2534 printf("USB Path is set to %s\n", getenv("usb"));
2540 microusb, CONFIG_SYS_MAXARGS, 1, do_microusb,
2542 "cp - switch to CP\n"
2543 "microusb ap - switch to AP\n"