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 = {
118 * i2c gpio7 - kessler
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 */
190 #define SPLIT_SCREEN_FEATURE 0x100
192 /* board is MACH_AQUILA and board is like below. */
193 #define J1_B2_BOARD 0x0200
194 #define LIMO_UNIVERSAL_BOARD 0x0400
195 #define LIMO_REAL_BOARD 0x0800
196 #define MEDIA_BOARD 0x1000
197 #define BAMBOO_BOARD 0x2000
198 #define ARIES_BOARD 0x4000
199 #define NEPTUNE_BOARD 0x8000
201 #define BOARD_MASK 0xFF00
203 static int c110_machine_id(void)
205 return gd->bd->bi_arch_number - C110_MACH_START;
208 static int machine_is_aquila(void)
210 return (gd->bd->bi_arch_number == MACH_AQUILA);
213 static int machine_is_tickertape(void)
215 return c110_machine_id() == MACH_TICKERTAPE;
218 static int machine_is_geminus(void)
220 return c110_machine_id() == MACH_GEMINUS;
223 static int machine_is_cypress(void)
225 return c110_machine_id() == MACH_CYPRESS;
228 static int board_is_limo_universal(void)
230 return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
233 static int board_is_limo_real(void)
235 return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
238 static int board_is_media(void)
240 return machine_is_aquila() && (board_rev & MEDIA_BOARD);
243 static int board_is_j1b2(void)
245 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
249 static int machine_is_kessler(void)
251 return gd->bd->bi_arch_number == MACH_KESSLER;
254 static int board_is_neptune(void)
256 return machine_is_kessler() && (board_rev & NEPTUNE_BOARD);
260 static int machine_is_wmg160(void)
262 return c110_machine_id() == MACH_WMG160;
265 static void enable_battery(void);
267 void i2c_init_board(void)
269 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
272 if (cpu_is_s5pc100())
275 num_bus = ARRAY_SIZE(i2c_gpio);
277 if (machine_is_aquila()) {
278 i2c_gpio[I2C_GPIO6].bus->gpio_base = 0;
279 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
280 } else if (machine_is_kessler()) {
281 i2c_gpio[I2C_GPIO7].bus->gpio_base =
282 (unsigned int)&gpio->gpio_mp0_5;
283 } else if (machine_is_cypress()) {
284 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
285 i2c_gpio[I2C_GPIO7].bus->gpio_base =
286 (unsigned int)&gpio->gpio_mp0_5;
288 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
291 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
292 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
293 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
294 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
295 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
297 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
299 /* Reset on max17040 early */
300 if (battery_soc == 0)
304 #ifdef CONFIG_MISC_INIT_R
305 #define DEV_INFO_LEN 512
306 static char device_info[DEV_INFO_LEN];
307 static int display_info;
309 static void dprintf(const char *fmt, ...)
316 i = vsprintf(buf, fmt, args);
321 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
322 puts("Flushing device info...\n");
326 strcat(device_info, buf);
330 #ifdef CONFIG_S5PC1XXFB
331 static void display_device_info(void)
338 set_font_color(FONT_WHITE);
339 fb_printf(device_info);
342 memset(device_info, 0x0, DEV_INFO_LEN);
344 udelay(5 * 1000 * 1000);
348 static const char *board_name[] = {
352 "P1P2", /* Don't remove it */
365 static char feature_buffer[32];
367 static char *display_features(int board, int board_rev)
370 char *buf = feature_buffer;
373 if (board == MACH_AQUILA) {
374 if (board_rev & SPLIT_SCREEN_FEATURE)
375 name = "SplitScreen";
376 if (board_rev & J1_B2_BOARD)
378 /* Limo Real or Universal */
379 if (board_rev & LIMO_REAL_BOARD)
381 else if (board_rev & LIMO_UNIVERSAL_BOARD)
382 name = "Limo Universal";
383 if (board_rev & MEDIA_BOARD)
385 if (board_rev & BAMBOO_BOARD)
387 if (board_rev & ARIES_BOARD)
389 if (board_rev & NEPTUNE_BOARD)
393 count += sprintf(buf + count, " - %s", name);
399 static char *get_board_name(int board)
401 if (board == MACH_AQUILA)
403 else if (board == MACH_KESSLER)
405 else if (board == MACH_WMG160)
407 return (char *) board_name[board];
410 static void check_board_revision(int board, int rev)
414 /* Limo Real or Universal */
415 if (rev & LIMO_UNIVERSAL_BOARD)
416 board_rev &= ~J1_B2_BOARD;
417 if (rev & LIMO_REAL_BOARD)
418 board_rev &= ~(J1_B2_BOARD |
419 LIMO_UNIVERSAL_BOARD);
420 if (rev & MEDIA_BOARD)
421 board_rev &= ~(J1_B2_BOARD |
422 LIMO_UNIVERSAL_BOARD);
423 if (rev & BAMBOO_BOARD)
424 board_rev &= ~(J1_B2_BOARD |
425 LIMO_UNIVERSAL_BOARD |
430 if (rev & ARIES_BOARD)
431 board_rev &= ~(J1_B2_BOARD |
432 LIMO_UNIVERSAL_BOARD);
433 if (rev & NEPTUNE_BOARD)
434 board_rev &= ~(J1_B2_BOARD |
435 LIMO_UNIVERSAL_BOARD);
438 case MACH_TICKERTAPE:
441 board_rev &= ~BOARD_MASK;
448 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank, int hwrev3)
456 gpio_direction_input(bank, 2);
457 gpio_direction_input(bank, 3);
458 gpio_direction_input(bank, 4);
459 gpio_direction_input(bank, mode3);
461 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
462 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
463 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
464 gpio_set_pull(bank, mode3, GPIO_PULL_NONE); /* HWREV_MODE3 */
466 rev = gpio_get_value(bank, 2);
467 rev |= (gpio_get_value(bank, 3) << 1);
468 rev |= (gpio_get_value(bank, 4) << 2);
469 rev |= (gpio_get_value(bank, mode3) << 3);
474 static void check_hw_revision(void)
476 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
478 if (cpu_is_s5pc100()) {
479 struct s5pc100_gpio *gpio =
480 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
482 board_rev = get_hw_revision(&gpio->gpio_j0, 0);
484 /* C100 TickerTape */
486 board = MACH_TICKERTAPE;
488 struct s5pc110_gpio *gpio =
489 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
495 * Note Check 'Aquila' board first
499 * LRA: Limo Real Aquila
500 * LUA: Limo Universal Aquila
505 * ADDR = 0xE0200000 + OFF
507 * OFF Universal BB LRA LUA OA TT SS CYP
508 * J1: 0x0264 0x10 0x10 0x00 0x00 0x00 0x00 0x00
509 * J2: 0x0284 0x01 0x10 0x00
510 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x0F
511 * H3: 0x0C64 0x03 0x07 0x0F
512 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
513 * I: 0x0224 0x02 0x00 0x08
514 * MP03: 0x0324 0x9x 0xbx 0x9x
515 * MP05: 0x0364 0x80 0x88
519 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
521 board_rev |= J1_B2_BOARD;
523 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
524 gpio_direction_input(&gpio->gpio_j2, 6);
527 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
528 board_rev |= LIMO_UNIVERSAL_BOARD;
530 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
531 board_rev |= LIMO_REAL_BOARD;
533 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
534 board_rev |= MEDIA_BOARD;
536 /* set gpio to default value. */
537 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
538 gpio_direction_output(&gpio->gpio_j2, 6, 0);
541 /* Workaround: C110 Aquila Rev0.6 */
542 if (board_rev == 6) {
544 board_rev |= LIMO_REAL_BOARD;
547 /* C110 Aquila Bamboo */
548 if (gpio_get_value(&gpio->gpio_j2, 0) == 1) {
550 board_rev |= BAMBOO_BOARD;
553 /* C110 TickerTape */
554 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
555 gpio_get_value(&gpio->gpio_d1, 1) == 0)
556 board = MACH_TICKERTAPE;
558 /* WMG160 - GPH3[0:4] = 0x00 */
559 if (board == MACH_TICKERTAPE) {
562 for (i = 0; i < 4; i++) {
563 if (gpio_get_value(&gpio->gpio_h3, i) != 0) {
574 /* C110 Geminus for rev0.0 */
575 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
576 gpio_direction_input(&gpio->gpio_j1, 2);
577 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
578 board = MACH_GEMINUS;
579 if ((board_rev & ~BOARD_MASK) == 3)
582 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
583 gpio_direction_output(&gpio->gpio_j1, 2, 0);
585 /* C110 Geminus for rev0.1 ~ */
586 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
587 gpio_direction_input(&gpio->gpio_j0, 6);
588 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
589 board = MACH_GEMINUS;
592 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
594 /* Kessler MP0_5[6] == 1 */
595 gpio_direction_input(&gpio->gpio_mp0_5, 6);
596 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
597 /* Cypress: Do this for cypress */
598 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
599 gpio_direction_input(&gpio->gpio_j2, 2);
600 if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
601 board = MACH_CYPRESS;
602 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
604 board = MACH_KESSLER;
605 board_rev |= ARIES_BOARD;
606 #ifdef USE_NEPTUNE_BOARD
607 board_rev &= ~ARIES_BOARD;
608 board_rev |= NEPTUNE_BOARD;
611 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
614 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
616 board_rev |= get_hw_revision(&gpio->gpio_j0, hwrev3);
620 if (board == MACH_AQUILA)
621 gd->bd->bi_arch_number = MACH_AQUILA;
622 else if (board == MACH_KESSLER)
623 gd->bd->bi_arch_number = MACH_KESSLER;
624 else if (cpu_is_s5pc110())
625 gd->bd->bi_arch_number = C110_MACH_START + board;
627 gd->bd->bi_arch_number = C100_MACH_START + board;
629 /* Architecture Common settings */
630 if (cpu_is_s5pc110()) {
631 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
633 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
635 setenv("updatek", "onenand erase 0x60000 0x300000; "
636 "onenand write 0x31008000 0x60000 0x300000");
640 static void show_hw_revision(void)
645 * Workaround for Rev 0.3 + CP Ver ES 3.1
648 if (board_is_limo_real()) {
650 /* default is Rev 0.4 */
656 if (machine_is_aquila())
658 else if (machine_is_kessler())
659 board = MACH_KESSLER;
660 else if (cpu_is_s5pc110())
661 board = gd->bd->bi_arch_number - C110_MACH_START;
663 board = gd->bd->bi_arch_number - C100_MACH_START;
665 check_board_revision(board, board_rev);
667 /* Set CPU Revision */
668 if (machine_is_aquila()) {
669 if (board_is_limo_real()) {
670 if ((board_rev & 0xf) < 8)
671 s5pc1xx_set_cpu_rev(0);
673 } else if (machine_is_kessler())
674 s5pc1xx_set_cpu_rev(1);
675 else if (machine_is_geminus()) {
676 if ((board_rev & 0xf) < 1)
677 s5pc1xx_set_cpu_rev(0);
678 } else if (machine_is_cypress()) {
679 s5pc1xx_set_cpu_rev(1);
681 s5pc1xx_set_cpu_rev(0);
684 dprintf("HW Revision:\t%x (%s%s) %s\n",
685 board_rev, get_board_name(board),
686 display_features(board, board_rev),
687 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
690 static void check_auto_burn(void)
692 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
693 unsigned int count = 0;
696 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
697 printf("Auto burning bootloader\n");
698 count += sprintf(buf + count, "run updateb; ");
700 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
701 printf("Auto burning kernel\n");
702 count += sprintf(buf + count, "run updatek; ");
706 count += sprintf(buf + count, "reset");
707 setenv("bootcmd", buf);
710 /* Clear the magic value */
711 writel(0xa5a55a5a, magic_base);
712 writel(0xa5a55a5a, magic_base + 0x4);
715 static void pmic_pin_init(void)
717 unsigned int reg, value;
719 if (cpu_is_s5pc100())
722 /* AP_PS_HOLD: XEINT_0: GPH0[0]
723 * Note: Don't use GPIO PS_HOLD it doesn't work
725 reg = S5PC110_PS_HOLD_CONTROL;
727 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
728 S5PC110_PS_HOLD_DATA_HIGH |
729 S5PC110_PS_HOLD_OUT_EN;
732 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
733 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
734 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
737 static void enable_ldos(void)
739 if (cpu_is_s5pc100())
742 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
743 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
746 static void enable_t_flash(void)
748 if (!(board_is_limo_universal() || board_is_limo_real()))
751 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
752 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
755 static void setup_limo_real_gpios(void)
757 if (!board_is_limo_real())
761 * Note: Please write GPIO alphabet order
763 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
764 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
767 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
768 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
770 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
771 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
773 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
774 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
775 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
778 static void setup_media_gpios(void)
780 if (!board_is_media())
784 * Note: Please write GPIO alphabet order
786 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
787 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
789 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
790 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
791 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
794 #define KBR3 (1 << 3)
795 #define KBR2 (1 << 2)
796 #define KBR1 (1 << 1)
797 #define KBR0 (1 << 0)
799 static void check_keypad(void)
801 unsigned int reg, value;
802 unsigned int col_num, row_num;
803 unsigned int col_mask;
804 unsigned int col_mask_shift;
805 unsigned int row_state[4];
807 unsigned int auto_download = 0;
809 if (machine_is_wmg160())
812 if (cpu_is_s5pc100()) {
813 struct s5pc100_gpio *gpio =
814 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
819 /* Set GPH2[2:0] to KP_COL[2:0] */
820 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
821 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
822 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
824 /* Set GPH3[2:0] to KP_ROW[2:0] */
825 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
826 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
827 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
829 reg = S5PC100_KEYPAD_BASE;
830 col_mask = S5PC1XX_KEYIFCOL_MASK;
833 if (board_is_limo_real() || board_is_limo_universal()) {
841 for (i = 0; i < row_num; i++) {
842 /* Set GPH3[3:0] to KP_ROW[3:0] */
843 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
844 gpio_set_pull(&s5pc110_gpio->gpio_h3, i, GPIO_PULL_UP);
847 for (i = 0; i < col_num; i++)
848 /* Set GPH2[3:0] to KP_COL[3:0] */
849 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
851 reg = S5PC110_KEYPAD_BASE;
852 col_mask = S5PC110_KEYIFCOLEN_MASK;
856 /* KEYIFCOL reg clear */
857 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
860 for (i = 0; i < col_num; i++) {
862 value &= ~(1 << i) << col_mask_shift;
864 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
867 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
868 row_state[i] = ~value & ((1 << row_num) - 1);
869 printf("[%d col] row_state: 0x%x\n", i, row_state[i]);
872 /* KEYIFCOL reg clear */
873 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
875 if (machine_is_aquila()) {
876 /* cam full shot & volume down */
877 if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
880 else if ((row_state[1] & 0x2))
882 } else if (machine_is_geminus())
883 /* volume down & home */
884 if ((row_state[1] & 0x2) && (row_state[2] & 0x1))
888 setenv("bootcmd", "usbdown");
891 static void enable_battery(void)
893 unsigned char val[2];
894 unsigned char addr = 0x36; /* max17040 fuel gauge */
896 i2c_set_bus_num(I2C_GPIO3);
898 if (machine_is_aquila()) {
901 } else if (machine_is_kessler())
902 i2c_set_bus_num(I2C_GPIO7);
903 else if (machine_is_tickertape()) {
905 } else if (machine_is_cypress()) {
906 i2c_set_bus_num(I2C_GPIO7);
907 } else if (machine_is_geminus()) {
909 i2c_set_bus_num(I2C_GPIO7);
912 if (i2c_probe(addr)) {
913 printf("Can't found max17040 fuel gauge\n");
919 i2c_write(addr, 0xfe, 1, val, 2);
922 static void check_battery(void)
924 unsigned char val[2];
925 unsigned char addr = 0x36; /* max17040 fuel gauge */
927 i2c_set_bus_num(I2C_GPIO3);
929 if (machine_is_aquila()) {
932 } else if (machine_is_kessler())
933 i2c_set_bus_num(I2C_GPIO7);
934 else if (machine_is_cypress()) {
935 i2c_set_bus_num(I2C_GPIO7);
936 } else if (machine_is_geminus()) {
938 i2c_set_bus_num(I2C_GPIO7);
942 if (i2c_probe(addr)) {
943 printf("Can't found max17040 fuel gauge\n");
947 i2c_read(addr, 0x04, 1, val, 1);
949 dprintf("battery:\t%d%%\n", val[0]);
951 battery_soc = val[0];
954 static void check_mhl(void)
956 unsigned char val[2];
957 unsigned char addr = 0x39; /* SIL9230 */
959 /* MHL Power enable */
960 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
961 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
963 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
964 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
966 /* 10ms required after reset */
970 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
972 i2c_set_bus_num(I2C_GPIO5);
975 if (i2c_probe(addr)) {
976 printf("Can't found MHL Chip\n");
982 * set to Normal operation
985 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
986 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
991 * 00 = MHL termination ON
992 * 11 = MHL termination OFF
995 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
996 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
999 #define CHARGER_ANIMATION_FRAME 6
1000 static int max8998_power_key(void)
1002 unsigned char addr, val[2];
1003 i2c_set_bus_num(I2C_PMIC);
1005 if (i2c_probe(addr)) {
1006 printf("Can't found max8998\n");
1010 /* Accessing IRQ1 register */
1011 i2c_read(addr, 0x00, 1, val, 1);
1012 if (val[0] & (1 << 6))
1018 static int max8998_has_ext_power_source(void)
1020 unsigned char addr, val[2];
1021 i2c_set_bus_num(I2C_PMIC);
1023 if (i2c_probe(addr)) {
1024 printf("Can't found max8998\n");
1028 /* Accessing STATUS2 register */
1029 i2c_read(addr, 0x09, 1, val, 1);
1030 if (val[0] & (1 << 5))
1036 extern void lcd_display_clear(void);
1037 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
1039 static void into_charge_mode(void)
1041 unsigned char addr = 0xCC >> 1; /* max8998 */;
1042 unsigned char val[2];
1047 ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1049 i2c_set_bus_num(I2C_PMIC);
1051 if (i2c_probe(addr)) {
1052 printf("Can't found max8998\n");
1056 printf("Charge Mode\n");
1058 i2c_read(addr, 0x0C, 1, val, 1);
1059 val[0] &= ~(0x7 << 0);
1060 val[0] &= ~(0x7 << 5);
1061 val[0] |= 5; /* 600mA */
1062 val[0] |= (3 << 5); /* Stop at 150mA(25%) */
1063 i2c_write(addr, 0x0C, 1, val, 1);
1065 #ifdef CONFIG_S5PC1XXFB
1068 /* TODO: write the image-text for the charger */
1070 level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1071 if (level >= CHARGER_ANIMATION_FRAME)
1072 level = CHARGER_ANIMATION_FRAME - 1;
1074 for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1075 bmp_addr[i] = (ulong)battery_charging_animation[i];
1077 lcd_display_clear();
1078 for (i = 0; i < 3; i++) {
1079 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1082 bmp = gunzip_bmp(bmp_addr[j], &len);
1083 lcd_display_bitmap((ulong) bmp, 140, 202);
1086 for (k = 0; k < 10; k++)
1087 if (max8998_power_key()) {
1088 lcd_display_clear();
1090 } else if (!max8998_has_ext_power_source()) {
1091 lcd_display_clear();
1100 /* EVT0: sleep 1, EVT1: sleep */
1101 if (s5pc1xx_get_cpu_rev() == 0) {
1102 run_command("sleep 1", 0);
1106 run_command("sleep", 0);
1109 static void check_micro_usb(int intr)
1112 unsigned char val[2];
1113 static int started_charging_once = 0;
1116 if (cpu_is_s5pc100())
1119 if (board_is_limo_real()) {
1120 if (hwrevision(0) || hwrevision(1))
1124 i2c_set_bus_num(I2C_PMIC);
1126 if (machine_is_kessler())
1127 i2c_set_bus_num(I2C_GPIO6);
1128 else if (machine_is_cypress()) {
1129 i2c_set_bus_num(I2C_GPIO6);
1130 } else if (machine_is_geminus()) {
1132 i2c_set_bus_num(I2C_GPIO6);
1133 } else if (machine_is_wmg160())
1134 i2c_set_bus_num(I2C_GPIO6);
1136 addr = 0x25; /* fsa9480 */
1137 if (i2c_probe(addr)) {
1138 printf("Can't found fsa9480\n");
1142 /* Clear Interrupt */
1144 i2c_read(addr, 0x03, 1, val, 2);
1148 /* Read Device Type 1 */
1149 i2c_read(addr, 0x0a, 1, val, 1);
1151 #define FSA_DEV1_CHARGER (1 << 6)
1152 #define FSA_DEV1_UART (1 << 3)
1153 #define FSA_DEV1_USB (1 << 2)
1154 #define FSA_DEV2_JIG_USB_OFF (1 << 1)
1155 #define FSA_DEV2_JIG_USB_ON (1 << 0)
1158 * If USB, use default 475mA
1159 * If Charger, use 600mA and go to charge mode
1161 if ((val[0] & FSA_DEV1_CHARGER) && !started_charging_once) {
1162 started_charging_once = 1;
1166 /* If Factory Mode is Boot ON-USB, go to download mode */
1167 i2c_read(addr, 0x07, 1, val, 1);
1169 #define FSA_ADC_FAC_USB_OFF 0x18
1170 #define FSA_ADC_FAC_USB_ON 0x19
1171 #define FSA_ADC_FAC_UART 0x1d
1173 if (val[0] == FSA_ADC_FAC_USB_ON || val[0] == FSA_ADC_FAC_USB_OFF)
1174 setenv("bootcmd", "usbdown");
1176 path = getenv("usb");
1178 if (!strncmp(path, "cp", 2))
1179 run_command("microusb cp", 0);
1182 static void micro_usb_switch(int path)
1185 unsigned char val[2];
1187 i2c_set_bus_num(I2C_PMIC);
1189 if (machine_is_kessler())
1190 i2c_set_bus_num(I2C_GPIO6);
1191 else if (machine_is_cypress()) {
1192 i2c_set_bus_num(I2C_GPIO6);
1193 } else if (machine_is_geminus()) {
1195 i2c_set_bus_num(I2C_GPIO6);
1196 } else if (machine_is_wmg160()) {
1197 i2c_set_bus_num(I2C_GPIO6);
1201 addr = 0x25; /* fsa9480 */
1202 if (i2c_probe(addr)) {
1203 printf("Can't found fsa9480\n");
1208 val[0] = 0x90; /* VAUDIO */
1210 val[0] = (1 << 5) | (1 << 2); /* DHOST */
1212 i2c_write(addr, 0x13, 1, val, 1); /* MANSW1 */
1214 i2c_read(addr, 0x2, 1, val, 1);
1215 val[0] &= ~(1 << 2); /* Manual switching */
1216 i2c_write(addr, 0x2, 1, val, 1);
1219 #define MAX8998_REG_ONOFF1 0x11
1220 #define MAX8998_REG_ONOFF2 0x12
1221 #define MAX8998_REG_ONOFF3 0x13
1222 #define MAX8998_REG_LDO7 0x21
1223 #define MAX8998_REG_LDO17 0x29
1225 #define MAX8998_LDO3 (1 << 2)
1227 #define MAX8998_LDO6 (1 << 7)
1228 #define MAX8998_LDO7 (1 << 6)
1229 #define MAX8998_LDO8 (1 << 5)
1230 #define MAX8998_LDO9 (1 << 4)
1231 #define MAX8998_LDO10 (1 << 3)
1232 #define MAX8998_LDO11 (1 << 2)
1233 #define MAX8998_LDO12 (1 << 1)
1234 #define MAX8998_LDO13 (1 << 0)
1236 #define MAX8998_LDO14 (1 << 7)
1237 #define MAX8998_LDO15 (1 << 6)
1238 #define MAX8998_LDO16 (1 << 5)
1239 #define MAX8998_LDO17 (1 << 4)
1242 static void init_pmic(void)
1245 unsigned char val[2];
1247 if (cpu_is_s5pc100())
1250 i2c_set_bus_num(I2C_PMIC);
1252 addr = 0xCC >> 1; /* max8998 */
1253 if (i2c_probe(addr)) {
1254 if (i2c_probe(addr)) {
1255 printf("Can't found max8998\n");
1261 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1262 val[0] &= ~MAX8998_LDO3;
1263 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1266 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1268 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1269 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1271 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1272 MAX8998_LDO12 | MAX8998_LDO13);
1274 if (machine_is_kessler())
1275 val[0] |= MAX8998_LDO7; /* LDO7: VLCD_1.8V */
1277 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1278 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1280 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1282 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1283 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1285 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1286 MAX8998_LDO16 | MAX8998_LDO17);
1288 if (machine_is_kessler())
1289 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1291 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1292 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1295 static void setup_power_down_mode_registers(void)
1297 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1298 struct s5pc1xx_gpio_bank *bank;
1299 struct gpio_powermode *p;
1301 struct gpio_external *ge;
1303 struct s5pc1xx_gpio_item *mr;
1307 if (cpu_is_s5pc100())
1310 /* Only Limo real and kessler supports worked for sleep currnet */
1311 if (machine_is_aquila()) {
1312 if (board_is_limo_real())
1316 } else if (machine_is_kessler()) {
1318 } else if (machine_is_geminus()) {
1323 if (machine_is_aquila()) {
1324 /* Aquila rev 0.8 or lower */
1325 p = aquila_powerdown_modes;
1326 ge = aquila_external_powerdown_modes;
1327 mr = aquila_mirror_powerdown_mode;
1328 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1329 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1330 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1331 } else if (machine_is_kessler()) {
1332 /* Aquila rev 0.9 */
1333 p = kessler_powerdown_modes;
1334 ge = kessler_external_powerdown_modes;
1335 mr = kessler_mirror_powerdown_mode;
1336 n_p = ARRAY_SIZE(kessler_powerdown_modes);
1337 n_ge = ARRAY_SIZE(kessler_external_powerdown_modes);
1338 n_mr = ARRAY_SIZE(kessler_mirror_powerdown_mode);
1339 } else if (machine_is_geminus()) {
1340 if (hwrevision(1)) {
1341 /* Same as Aquila rev 0.9 */
1343 p = kessler_powerdown_modes;
1344 ge = kessler_external_powerdown_modes;
1345 mr = kessler_mirror_powerdown_mode;
1346 n_p = ARRAY_SIZE(kessler_powerdown_modes);
1347 n_ge = ARRAY_SIZE(kessler_external_powerdown_modes);
1348 n_mr = ARRAY_SIZE(kessler_mirror_powerdown_mode);
1350 p = aquila_powerdown_modes;
1351 ge = aquila_external_powerdown_modes;
1352 mr = aquila_mirror_powerdown_mode;
1353 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1354 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1355 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1357 } else if (hwrevision(0)) {
1358 /* Same as Aquila rev 0.8 or lower */
1359 p = aquila_powerdown_modes;
1360 ge = aquila_external_powerdown_modes;
1361 mr = aquila_mirror_powerdown_mode;
1362 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1363 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1364 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1366 return; /* Not supported */
1370 bank = &gpio->gpio_a0;
1372 for (i = 0; i < n_p; i++, p++, bank++) {
1373 writel(p->conpdn, &bank->pdn_con);
1374 writel(p->pudpdn, &bank->pdn_pull);
1377 writel(0xff0022b0, (unsigned int *)0xF0000000);
1378 writel(0xff0022b0, (unsigned int *)0xF1400000);
1380 bank = &gpio->gpio_h0;
1382 for (i = 0; i < n_ge; i++) {
1383 writel(ge->con, &bank->con);
1384 writel(ge->dat, &bank->dat);
1385 writel(ge->pud, &bank->pull);
1391 for (i = 0; i < n_mr; i++) {
1392 unsigned int reg = readl(&mr->bank->pdn_con);
1393 reg &= ~(1 << mr->number);
1394 if (readl(&mr->bank->dat) & (1 << mr->number))
1395 reg |= 1 << mr->number;
1396 writel(reg, &mr->bank->pdn_con);
1398 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1405 #include "../../../drivers/video/s5p-spi.h"
1407 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1408 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1410 struct spi_platform_data spi_pd;
1412 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1414 void lcd_cfg_gpio(void)
1416 unsigned int i, f3_end = 4;
1418 for (i = 0; i < 8; i++) {
1419 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1420 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1421 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1422 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1423 /* pull-up/down disable */
1424 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1425 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1426 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1428 /* drive strength to max (24bit) */
1429 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1430 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1431 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1432 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1433 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1434 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1437 /* set DISPLAY_DE_B pin for dual rgb mode. */
1438 if (board_is_media())
1441 for (i = 0; i < f3_end; i++) {
1442 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1443 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1444 /* pull-up/down disable */
1445 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1446 /* drive strength to max (24bit) */
1447 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1448 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1450 /* display output path selection (only [1:0] valid) */
1451 writel(0x2, 0xE0107008);
1453 /* gpio pad configuration for LCD reset. */
1454 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1456 /* gpio pad configuration for LCD ON. */
1457 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1459 /* LCD_BACKLIGHT_EN */
1460 if (machine_is_geminus())
1461 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1464 * gpio pad configuration for
1465 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1467 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1468 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1469 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1470 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1472 if (machine_is_aquila()) {
1473 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1475 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1477 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1479 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1482 if (board_is_neptune())
1483 s6d16a0x_set_platform_data(&spi_pd);
1485 s6e63m0_set_platform_data(&spi_pd);
1486 if (board_is_media())
1491 if (machine_is_cypress()) {
1492 #if 0 /* universal cypress */
1494 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1497 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1499 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1501 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1503 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1505 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1506 #if 0 /* universal cypress */
1507 pd_cs.bank = &gpio_base->gpio_mp0_1;
1510 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1512 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1514 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1519 /* these data would be sent to s6e63m0 lcd panel driver. */
1520 s6e63m0_set_platform_data(&spi_pd);
1526 void backlight_on(unsigned int onoff)
1528 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1531 if (machine_is_geminus())
1532 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1534 if (machine_is_geminus())
1535 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1539 void reset_lcd(void)
1541 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1543 if (machine_is_aquila() || machine_is_geminus())
1544 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1545 if (machine_is_cypress())
1546 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1549 void lcd_power_on(unsigned int onoff)
1551 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1554 if (machine_is_aquila() || machine_is_geminus())
1555 gpio_set_value(&gpio->gpio_j1, 3, 1);
1557 if (machine_is_cypress())
1558 gpio_set_value(&gpio->gpio_g2, 2, 1);
1560 if (machine_is_kessler()) {
1562 unsigned char val[2];
1563 unsigned char val2[2];
1565 i2c_set_bus_num(I2C_PMIC);
1566 addr = 0xCC >> 1; /* max8998 */
1567 if (i2c_probe(addr)) {
1568 printf("Can't found max8998\n");
1571 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1572 val[0] &= ~(MAX8998_LDO17);
1573 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1574 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1576 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1577 val[0] |= MAX8998_LDO17;
1579 i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1580 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1582 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1583 val[0] |= MAX8998_LDO7;
1585 i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1586 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1589 if (machine_is_aquila() || machine_is_geminus())
1590 gpio_set_value(&gpio->gpio_j1, 3, 0);
1592 if (machine_is_cypress())
1593 gpio_set_value(&gpio->gpio_g2, 2, 0);
1595 if (machine_is_kessler()) {
1597 unsigned char val[2];
1599 i2c_set_bus_num(I2C_PMIC);
1600 addr = 0xCC >> 1; /* max8998 */
1601 if (i2c_probe(addr)) {
1602 printf("Can't found max8998\n");
1606 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1607 val[0] &= ~(1 << 7);
1608 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1609 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1611 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1612 val[0] &= ~MAX8998_LDO17;
1613 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1614 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1619 extern void s6e63m0_cfg_ldo(void);
1620 extern void s6e63m0_enable_ldo(unsigned int onoff);
1621 extern void s6d16a0x_cfg_ldo(void);
1622 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1624 int s5p_no_lcd_support(void)
1626 if (machine_is_wmg160())
1631 void init_panel_info(vidinfo_t *vid)
1633 vid->cfg_gpio = NULL;
1634 vid->reset_lcd = NULL;
1635 vid->backlight_on = NULL;
1636 vid->lcd_power_on = NULL;
1638 vid->cfg_ldo = NULL;
1639 vid->enable_ldo = NULL;
1641 vid->init_delay = 0;
1642 vid->reset_delay = 0;
1643 vid->power_on_delay = 0;
1648 vid->vl_width = 480;
1649 vid->vl_height = 800;
1651 vid->dual_lcd_enabled = 0;
1653 if (board_is_media()) {
1656 vid->vl_width = 960;
1657 vid->vl_height = 800;
1659 /* enable dual lcd mode. */
1660 vid->dual_lcd_enabled = 1;
1663 vid->vl_clkp = CONFIG_SYS_HIGH;
1664 vid->vl_hsp = CONFIG_SYS_LOW;
1665 vid->vl_vsp = CONFIG_SYS_LOW;
1666 vid->vl_dp = CONFIG_SYS_HIGH;
1669 /* S6E63M0 LCD Panel */
1678 if (machine_is_aquila() || machine_is_cypress()) {
1679 vid->cfg_gpio = lcd_cfg_gpio;
1680 vid->reset_lcd = reset_lcd;
1681 vid->backlight_on = backlight_on;
1682 vid->lcd_power_on = lcd_power_on;
1683 vid->cfg_ldo = s6e63m0_cfg_ldo;
1684 vid->enable_ldo = s6e63m0_enable_ldo;
1686 vid->init_delay = 25000;
1687 vid->reset_delay = 120000;
1690 if (board_is_neptune()) {
1694 vid->vl_width = 320;
1695 vid->vl_height = 480;
1697 vid->vl_clkp = CONFIG_SYS_HIGH;
1698 vid->vl_hsp = CONFIG_SYS_HIGH;
1699 vid->vl_vsp = CONFIG_SYS_HIGH;
1700 vid->vl_dp = CONFIG_SYS_LOW;
1703 /* disable dual lcd mode. */
1704 vid->dual_lcd_enabled = 0;
1706 /* S6D16A0X LCD Panel */
1715 vid->cfg_gpio = lcd_cfg_gpio;
1716 vid->backlight_on = NULL;
1717 vid->lcd_power_on = lcd_power_on;
1718 vid->reset_lcd = reset_lcd;
1719 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1720 vid->enable_ldo = s6d16a0x_enable_ldo;
1722 vid->init_delay = 10000;
1723 vid->power_on_delay = 10000;
1724 vid->reset_delay = 1000;
1728 if (machine_is_geminus()) {
1732 vid->vl_width = 1024,
1733 vid->vl_height = 600,
1734 vid->vl_clkp = CONFIG_SYS_LOW,
1735 vid->vl_hsp = CONFIG_SYS_HIGH,
1736 vid->vl_vsp = CONFIG_SYS_HIGH,
1737 vid->vl_dp = CONFIG_SYS_LOW,
1748 vid->cfg_gpio = lcd_cfg_gpio;
1749 vid->reset_lcd = reset_lcd;
1750 vid->backlight_on = backlight_on;
1751 vid->lcd_power_on = lcd_power_on;
1757 vid->vl_width = 480,
1758 vid->vl_height = 800,
1759 vid->vl_clkp = CONFIG_SYS_HIGH,
1760 vid->vl_hsp = CONFIG_SYS_LOW,
1761 vid->vl_vsp = CONFIG_SYS_LOW,
1762 vid->vl_dp = CONFIG_SYS_HIGH,
1778 vid->vl_width = 1024,
1779 vid->vl_height = 600,
1780 vid->vl_clkp = CONFIG_SYS_HIGH,
1781 vid->vl_hsp = CONFIG_SYS_HIGH,
1782 vid->vl_vsp = CONFIG_SYS_HIGH,
1783 vid->vl_dp = CONFIG_SYS_LOW,
1786 /* AMS701KA AMOLED Panel. */
1798 static void setup_meminfo(void)
1800 char meminfo[64] = {0, };
1801 int count = 0, size, real;
1803 size = gd->bd->bi_dram[0].size >> 20;
1804 count += sprintf(meminfo + count, "mem=%dM", size);
1806 /* Each Chip Select can't exceed the 256MiB */
1807 size = gd->bd->bi_dram[1].size >> 20;
1808 real = min(size, 256);
1809 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1810 real, (unsigned int)gd->bd->bi_dram[1].start);
1814 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1815 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1818 setenv("meminfo", meminfo);
1821 int misc_init_r(void)
1824 /* It should be located at first */
1827 if (machine_is_aquila()) {
1828 if (board_is_neptune())
1829 setenv("lcdinfo", "lcd=s6d16a0x");
1830 else if (board_is_media())
1831 setenv("lcdinfo", "lcd=s6e63m0");
1833 setenv("lcdinfo", "lcd=s6e63m0");
1835 if (machine_is_geminus())
1836 setenv("lcdinfo", "lcd=lms480jc01");
1837 if (machine_is_cypress())
1838 setenv("lcdinfo", "lcd=s6e63m0");
1844 /* Set proper PMIC pins */
1847 /* Check auto burning */
1850 /* To power up I2C2 */
1853 /* Enable T-Flash at Limo Real or Limo Universal */
1856 /* Setup Limo Real board GPIOs */
1857 setup_limo_real_gpios();
1859 /* Setup Media board GPIOs */
1860 setup_media_gpios();
1862 /* To usbdown automatically */
1868 #ifdef CONFIG_S5PC1XXFB
1869 display_device_info();
1872 setup_power_down_mode_registers();
1874 /* check max17040 */
1884 int board_init(void)
1886 /* Set Initial global variables */
1887 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1889 gd->bd->bi_arch_number = MACH_AQUILA;
1890 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1892 /* Check H/W Revision */
1893 check_hw_revision();
1900 unsigned int base, memconfig0, size;
1901 unsigned int memconfig1, sz = 0;
1903 if (cpu_is_s5pc100()) {
1904 /* In mem setup, we swap the bank. So below size is correct */
1905 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1906 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1907 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1910 /* In S5PC110, we can't swap the DMC0/1 */
1911 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1912 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1914 base = S5PC110_DMC1_BASE;
1915 /* DMC configuration */
1916 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1917 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1919 size = (memconfig0 >> 16) & 0xFF;
1920 size = ((unsigned char) ~size) + 1;
1923 * (0x07 + 1) * 16 = 128 MiB
1924 * (0x0f + 1) * 16 = 256 MiB
1929 * Aquila Rev0.5 4G3G1G
1930 * Aquila Rev0.8 4G3G1G
1931 * Aquila Rev0.9 4G3G1G
1933 if (machine_is_aquila() &&
1934 (hwrevision(5) || hwrevision(8) || hwrevision(9))) {
1935 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1937 sz = (memconfig1 >> 16) & 0xFF;
1938 sz = ((unsigned char) ~sz) + 1;
1944 * bi_dram[1].size contains all DMC1 memory size
1946 gd->bd->bi_dram[1].size = (size + sz) << 20;
1951 /* Used for sleep test */
1952 static unsigned char saved_val[4][2];
1953 void board_sleep_init_late(void)
1955 /* CODEC_LDO_EN: GPF3[4] */
1956 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1957 /* CODEC_XTAL_EN: GPH3[2] */
1958 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1960 /* MMC T_FLASH off */
1961 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1963 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1964 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1965 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1969 void board_sleep_init(void)
1972 unsigned char val[2];
1974 i2c_set_bus_num(I2C_PMIC);
1976 if (i2c_probe(addr)) {
1977 printf("Can't find max8998\n");
1982 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1983 saved_val[0][0] = val[0];
1984 saved_val[0][1] = val[1];
1985 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1986 (1 << 1) | (1 << 0));
1987 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1988 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1990 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1991 saved_val[1][0] = val[0];
1992 saved_val[1][1] = val[1];
1993 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1994 (1 << 2) | (1 << 1) | (1 << 0));
1996 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1997 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1999 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2000 saved_val[2][0] = val[0];
2001 saved_val[2][1] = val[1];
2002 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
2003 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2004 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2006 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2007 saved_val[3][0] = val[0];
2008 saved_val[3][1] = val[1];
2009 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2010 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2011 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2012 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2013 __FILE__, __LINE__);
2016 void board_sleep_resume(void)
2019 unsigned char val[2];
2023 i2c_set_bus_num(I2C_PMIC);
2025 if (i2c_probe(addr)) {
2026 printf("Can't find max8998\n");
2031 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2032 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2034 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2035 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2037 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2038 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2040 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2041 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2042 printf("Waked up.\n");
2044 /* check max17040 */
2051 #ifdef CONFIG_CMD_USBDOWN
2052 int usb_board_init(void)
2054 #ifdef CONFIG_CMD_PMIC
2055 run_command("pmic ldo 3 on", 0);
2058 if (cpu_is_s5pc100()) {
2059 #ifdef CONFIG_HARD_I2C
2060 uchar val[2] = {0,};
2063 if (i2c_read(0x66, 0, 1, val, 2)) {
2064 printf("i2c_read error\n");
2071 if (i2c_write(0x66, 0, 1, val, 2)) {
2072 printf("i2c_write error\n");
2075 i2c_read(0x66, 0, 1, val, 2);
2081 if (board_is_limo_universal() ||
2082 board_is_limo_real() ||
2084 /* check usb path */
2085 if (board_is_limo_real() && !hwrevision(6))
2089 if (machine_is_tickertape())
2090 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2091 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2093 /* USB Path to AP */
2094 micro_usb_switch(0);
2100 #ifdef CONFIG_GENERIC_MMC
2101 int s5p_no_mmc_support(void)
2103 if (machine_is_wmg160())
2108 int board_mmc_init(bd_t *bis)
2112 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2115 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2116 if (machine_is_kessler())
2117 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2119 if (machine_is_wmg160())
2122 /* MMC0 Clock source = SCLKMPLL */
2123 reg = readl(&clk->src4);
2126 writel(reg, &clk->src4);
2128 reg = readl(&clk->div4);
2131 /* set div value near 50MHz */
2132 clock = get_pll_clk(MPLL) / 1000000;
2133 for (i = 0; i < 0xf; i++) {
2134 if ((clock / (i + 1)) <= 50) {
2140 writel(reg, &clk->div4);
2146 * GPG0[2] SD_0_CDn -> Not used
2147 * GPG0[3:6] SD_0_DATA[0:3]
2149 for (i = 0; i < 7; i++) {
2152 /* GPG0[0:6] special function 2 */
2153 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2154 /* GPG0[0:6] pull disable */
2155 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2156 /* GPG0[0:6] drv 4x */
2157 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4x);
2160 return s5pc1xx_mmc_init(0);
2164 #ifdef CONFIG_CMD_PMIC
2165 static int pmic_status(void)
2167 unsigned char addr, val[2];
2170 i2c_set_bus_num(I2C_PMIC);
2172 if (i2c_probe(addr)) {
2173 printf("Can't found max8998\n");
2178 i2c_read(addr, reg, 1, val, 1);
2179 for (i = 7; i >= 4; i--)
2180 printf("BUCK%d %s\n", 7 - i + 1,
2181 val[0] & (1 << i) ? "on" : "off");
2183 printf("LDO%d %s\n", 5 - i,
2184 val[0] & (1 << i) ? "on" : "off");
2186 i2c_read(addr, reg, 1, val, 1);
2187 for (i = 7; i >= 0; i--)
2188 printf("LDO%d %s\n", 7 - i + 6,
2189 val[0] & (1 << i) ? "on" : "off");
2191 i2c_read(addr, reg, 1, val, 1);
2192 for (i = 7; i >= 4; i--)
2193 printf("LDO%d %s\n", 7 - i + 14,
2194 val[0] & (1 << i) ? "on" : "off");
2197 i2c_read(addr, reg, 1, val, 1);
2198 for (i = 7; i >= 6; i--)
2199 printf("SAFEOUT%d %s\n", 7 - i + 1,
2200 val[0] & (1 << i) ? "on" : "off");
2204 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2206 unsigned char addr, val[2];
2207 unsigned int reg, shift;
2215 } else if (ldo <= 13) {
2218 } else if (ldo <= 17) {
2220 shift = 17 - ldo + 4;
2227 shift = 4 - buck + 4;
2228 } else if (safeout) {
2232 shift = 8 - safeout;
2236 i2c_set_bus_num(I2C_PMIC);
2238 if (i2c_probe(addr)) {
2239 printf("Can't found max8998\n");
2243 i2c_read(addr, reg, 1, val, 1);
2245 val[0] |= (1 << shift);
2247 val[0] &= ~(1 << shift);
2248 i2c_write(addr, reg, 1, val, 1);
2249 i2c_read(addr, reg, 1, val, 1);
2252 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2253 val[0] & (1 << shift) ? "on" : "off");
2255 printf("buck %d value 0x%x, %s\n", buck, val[0],
2256 val[0] & (1 << shift) ? "on" : "off");
2258 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2259 val[0] & (1 << shift) ? "on" : "off");
2264 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2266 int buck = 0, ldo = 0, safeout = 0, on = -1;
2270 if (strncmp(argv[1], "status", 6) == 0)
2271 return pmic_status();
2274 if (strncmp(argv[1], "ldo", 3) == 0)
2275 ldo = simple_strtoul(argv[2], NULL, 10);
2276 else if (strncmp(argv[1], "buck", 4) == 0)
2277 buck = simple_strtoul(argv[2], NULL, 10);
2278 else if (strncmp(argv[1], "safeout", 7) == 0)
2279 safeout = simple_strtoul(argv[2], NULL, 10);
2283 if (strncmp(argv[3], "on", 2) == 0)
2285 else if (strncmp(argv[3], "off", 3) == 0)
2290 return pmic_ldo_control(buck, ldo, safeout, on);
2301 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2302 "PMIC LDO & BUCK control",
2303 "status - Display PMIC LDO & BUCK status\n"
2304 "pmic ldo num on/off - Turn on/off the LDO\n"
2305 "pmic buck num on/off - Turn on/off the BUCK\n"
2306 "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2310 #ifdef CONFIG_CMD_DEVICE_POWER
2324 static void power_display_devices(void)
2326 printf("devices:\n");
2327 printf("\t%d - touch\n", POWER_TOUCH);
2328 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2329 printf("\t%d - LCD\n", POWER_LCD);
2330 printf("\t%d - Haptic\n", POWER_HAPTIC);
2331 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2332 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2333 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2334 printf("\t%d - HDMI\n", POWER_HDMI);
2337 static int power_hdmi(int on)
2339 /* HDMI_EN1: GPJ2[2] */
2340 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2341 /* MHL_ON: GPJ2[3] */
2342 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2346 static int power_bt_wifi(int on)
2348 /* WLAN_BT_EN: GPB[5] */
2349 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2353 static int power_fm_radio(int on)
2355 /* FM_BUS_nRST: GPJ2[5] */
2356 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2360 static int power_audio_codec(int on)
2362 /* CODEC_LDO_EN: GPF3[4] */
2363 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2364 /* CODEC_XTAL_EN: GPH3[2] */
2365 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2369 static int power_haptic(int on)
2371 /* HAPTIC_ON: GPJ1[1] */
2372 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2376 static int power_lcd(int on)
2378 /* MLCD_ON: GPJ1[3] */
2379 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2383 static int power_touch(int on)
2385 /* TOUCH_EN: GPG3[6] */
2386 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2390 static int power_3_touchkey(int on)
2393 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2394 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2395 if (board_rev & J1_B2_BOARD)
2396 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2398 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2400 /* 3_TOUCH_CE - GPJ2[6] */
2401 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2403 /* 3_TOUCH_CE - GPJ2[6] */
2404 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2409 unsigned char val[2];
2410 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2416 i2c_set_bus_num(I2C_GPIO10);
2418 /* Workaround to probe */
2419 if (i2c_probe(addr)) {
2420 if (i2c_probe(addr)) {
2421 printf("Can't found 3 touchkey\n");
2426 #define MCS5000_TK_HW_VERSION 0x06
2427 #define MCS5000_TK_FW_VERSION 0x0A
2428 #define MCS5000_TK_MI_VERSION 0x0B
2430 reg = MCS5000_TK_MI_VERSION;
2431 i2c_read(addr, reg, 1, val, 1);
2432 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2433 reg = MCS5000_TK_HW_VERSION;
2434 i2c_read(addr, reg, 1, val, 1);
2435 printf("H/W 0x%x, ", val[0]);
2436 reg = MCS5000_TK_FW_VERSION;
2437 i2c_read(addr, reg, 1, val, 1);
2438 printf("F/W 0x%x\n", val[0]);
2443 static int power_control(int device, int on)
2447 return power_touch(on);
2448 case POWER_3_TOUCHKEY:
2449 return power_3_touchkey(on);
2451 return power_lcd(on);
2453 return power_haptic(on);
2454 case POWER_AUDIO_CODEC:
2455 return power_audio_codec(on);
2456 case POWER_FM_RADIO:
2457 return power_fm_radio(on);
2459 return power_bt_wifi(on);
2461 return power_hdmi(on);
2463 printf("I don't know device %d\n", device);
2469 static int power_on(int on)
2472 power_3_touchkey(on);
2475 power_audio_codec(on);
2483 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2487 if (!machine_is_aquila())
2492 if (strncmp(argv[1], "on", 2) == 0)
2494 if (strncmp(argv[1], "off", 3) == 0)
2498 device = simple_strtoul(argv[1], NULL, 10);
2502 if (strncmp(argv[2], "on", 2) == 0)
2504 else if (strncmp(argv[2], "off", 3) == 0)
2508 return power_control(device, on);
2514 power_display_devices();
2519 power, CONFIG_SYS_MAXARGS, 1, do_power,
2520 "Device Power Management control",
2521 "device on/off - Turn on/off the device\n"
2524 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2528 if (strncmp(argv[1], "cp", 2) == 0) {
2529 micro_usb_switch(1);
2530 pmic_ldo_control(0, 0, 2, 1);
2531 setenv("usb", "cp");
2532 } else if (strncmp(argv[1], "ap", 2) == 0) {
2533 micro_usb_switch(0);
2534 pmic_ldo_control(0, 0, 2, 0);
2535 setenv("usb", "ap");
2545 printf("USB Path is set to %s\n", getenv("usb"));
2551 microusb, CONFIG_SYS_MAXARGS, 1, do_microusb,
2553 "cp - switch to CP\n"
2554 "microusb ap - switch to AP\n"