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 /* WMG160 - GPH3[0:4] = 0x00 */
556 if (board == MACH_TICKERTAPE) {
559 for (i = 0; i < 4; i++) {
560 if (gpio_get_value(&gpio->gpio_h3, i) != 0) {
571 /* C110 Geminus for rev0.0 */
572 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
573 gpio_direction_input(&gpio->gpio_j1, 2);
574 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
575 board = MACH_GEMINUS;
576 if ((board_rev & ~BOARD_MASK) == 3)
579 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
580 gpio_direction_output(&gpio->gpio_j1, 2, 0);
582 /* C110 Geminus for rev0.1 ~ */
583 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
584 gpio_direction_input(&gpio->gpio_j0, 6);
585 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
586 board = MACH_GEMINUS;
589 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
591 /* Aquila - Aries MP0_5[6] == 1 */
592 gpio_direction_input(&gpio->gpio_mp0_5, 6);
593 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
594 /* Cypress: Do this for cypress */
595 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
596 gpio_direction_input(&gpio->gpio_j2, 2);
597 if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
598 board = MACH_CYPRESS;
599 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
602 board_rev |= ARIES_BOARD;
603 #ifdef USE_NEPTUNE_BOARD
604 board_rev &= ~ARIES_BOARD;
605 board_rev |= NEPTUNE_BOARD;
608 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
611 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
613 board_rev |= get_hw_revision(&gpio->gpio_j0, hwrev3);
617 if (cpu_is_s5pc110())
618 gd->bd->bi_arch_number = C110_MACH_START + board;
620 gd->bd->bi_arch_number = C100_MACH_START + board;
622 /* Architecture Common settings */
623 if (cpu_is_s5pc110()) {
624 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
626 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
628 setenv("updatek", "onenand erase 0x60000 0x300000; "
629 "onenand write 0x31008000 0x60000 0x300000");
633 static void show_hw_revision(void)
638 * Workaround for Rev 0.3 + CP Ver ES 3.1
641 if (board_is_limo_real()) {
643 /* default is Rev 0.4 */
649 if (cpu_is_s5pc110())
650 board = gd->bd->bi_arch_number - C110_MACH_START;
652 board = gd->bd->bi_arch_number - C100_MACH_START;
654 check_board_revision(board, board_rev);
656 /* Set CPU Revision */
657 if (machine_is_aquila()) {
658 if (board_is_limo_real()) {
659 if ((board_rev & 0xf) < 8)
660 s5pc1xx_set_cpu_rev(0);
662 } else if (machine_is_geminus()) {
663 if ((board_rev & 0xf) < 1)
664 s5pc1xx_set_cpu_rev(0);
666 s5pc1xx_set_cpu_rev(0);
669 dprintf("HW Revision:\t%x (%s%s) %s\n",
670 board_rev, get_board_name(board),
671 display_features(board, board_rev),
672 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
675 static void check_auto_burn(void)
677 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
678 unsigned int count = 0;
681 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
682 printf("Auto burning bootloader\n");
683 count += sprintf(buf + count, "run updateb; ");
685 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
686 printf("Auto burning kernel\n");
687 count += sprintf(buf + count, "run updatek; ");
691 count += sprintf(buf + count, "reset");
692 setenv("bootcmd", buf);
695 /* Clear the magic value */
696 writel(0xa5a55a5a, magic_base);
697 writel(0xa5a55a5a, magic_base + 0x4);
700 static void pmic_pin_init(void)
702 unsigned int reg, value;
704 if (cpu_is_s5pc100())
707 /* AP_PS_HOLD: XEINT_0: GPH0[0]
708 * Note: Don't use GPIO PS_HOLD it doesn't work
710 reg = S5PC110_PS_HOLD_CONTROL;
712 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
713 S5PC110_PS_HOLD_DATA_HIGH |
714 S5PC110_PS_HOLD_OUT_EN;
717 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
718 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
719 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
722 static void enable_ldos(void)
724 if (cpu_is_s5pc100())
727 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
728 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
731 static void enable_t_flash(void)
733 if (!(board_is_limo_universal() || board_is_limo_real()))
736 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
737 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
740 static void setup_limo_real_gpios(void)
742 if (!board_is_limo_real())
746 * Note: Please write GPIO alphabet order
748 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
749 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
752 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
753 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
755 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
756 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
758 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
759 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
760 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
763 static void setup_media_gpios(void)
765 if (!board_is_media())
769 * Note: Please write GPIO alphabet order
771 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
772 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
774 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
775 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
776 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
779 #define KBR3 (1 << 3)
780 #define KBR2 (1 << 2)
781 #define KBR1 (1 << 1)
782 #define KBR0 (1 << 0)
784 static void check_keypad(void)
786 unsigned int reg, value;
787 unsigned int col_num, row_num;
788 unsigned int col_mask;
789 unsigned int col_mask_shift;
790 unsigned int row_state[4];
792 unsigned int auto_download = 0;
794 if (machine_is_wmg160())
797 if (cpu_is_s5pc100()) {
798 struct s5pc100_gpio *gpio =
799 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
804 /* Set GPH2[2:0] to KP_COL[2:0] */
805 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
806 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
807 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
809 /* Set GPH3[2:0] to KP_ROW[2:0] */
810 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
811 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
812 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
814 reg = S5PC100_KEYPAD_BASE;
815 col_mask = S5PC1XX_KEYIFCOL_MASK;
818 if (board_is_limo_real() || board_is_limo_universal()) {
826 for (i = 0; i < row_num; i++) {
827 /* Set GPH3[3:0] to KP_ROW[3:0] */
828 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
829 gpio_set_pull(&s5pc110_gpio->gpio_h3, i, GPIO_PULL_UP);
832 for (i = 0; i < col_num; i++)
833 /* Set GPH2[3:0] to KP_COL[3:0] */
834 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
836 reg = S5PC110_KEYPAD_BASE;
837 col_mask = S5PC110_KEYIFCOLEN_MASK;
841 /* KEYIFCOL reg clear */
842 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
845 for (i = 0; i < col_num; i++) {
847 value &= ~(1 << i) << col_mask_shift;
849 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
852 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
853 row_state[i] = ~value & ((1 << row_num) - 1);
854 printf("[%d col] row_state: 0x%x\n", i, row_state[i]);
857 /* KEYIFCOL reg clear */
858 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
860 if (machine_is_aquila) {
861 /* cam full shot & volume down */
862 if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
865 else if ((row_state[1] & 0x2))
867 } else if (machine_is_geminus())
868 /* volume down & home */
869 if ((row_state[1] & 0x2) && (row_state[2] & 0x1))
873 setenv("bootcmd", "usbdown");
876 static void enable_battery(void)
878 unsigned char val[2];
879 unsigned char addr = 0x36; /* max17040 fuel gauge */
881 i2c_set_bus_num(I2C_GPIO3);
883 if (machine_is_aquila()) {
884 if (board_is_aries() || board_is_neptune())
885 i2c_set_bus_num(I2C_GPIO7);
886 else if (board_is_j1b2())
888 } else if (machine_is_tickertape()) {
890 } else if (machine_is_cypress()) {
891 i2c_set_bus_num(I2C_GPIO7);
892 } else if (machine_is_geminus()) {
894 i2c_set_bus_num(I2C_GPIO7);
897 if (i2c_probe(addr)) {
898 printf("Can't found max17040 fuel gauge\n");
904 i2c_write(addr, 0xfe, 1, val, 2);
907 static void check_battery(void)
909 unsigned char val[2];
910 unsigned char addr = 0x36; /* max17040 fuel gauge */
912 i2c_set_bus_num(I2C_GPIO3);
914 if (machine_is_aquila()) {
915 if (board_is_aries() || board_is_neptune())
916 i2c_set_bus_num(I2C_GPIO7);
917 else if (board_is_j1b2())
919 } else if (machine_is_cypress()) {
920 i2c_set_bus_num(I2C_GPIO7);
921 } else if (machine_is_geminus()) {
923 i2c_set_bus_num(I2C_GPIO7);
927 if (i2c_probe(addr)) {
928 printf("Can't found max17040 fuel gauge\n");
932 i2c_read(addr, 0x04, 1, val, 1);
934 dprintf("battery:\t%d%%\n", val[0]);
936 battery_soc = val[0];
939 static void check_mhl(void)
941 unsigned char val[2];
942 unsigned char addr = 0x39; /* SIL9230 */
944 /* MHL Power enable */
945 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
946 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
948 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
949 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
951 /* 10ms required after reset */
955 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
957 i2c_set_bus_num(I2C_GPIO5);
960 if (i2c_probe(addr)) {
961 printf("Can't found MHL Chip\n");
967 * set to Normal operation
970 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
971 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
976 * 00 = MHL termination ON
977 * 11 = MHL termination OFF
980 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
981 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
984 #define CHARGER_ANIMATION_FRAME 6
985 static int max8998_power_key(void)
987 unsigned char addr, val[2];
988 i2c_set_bus_num(I2C_PMIC);
990 if (i2c_probe(addr)) {
991 printf("Can't found max8998\n");
995 /* Accessing IRQ1 register */
996 i2c_read(addr, 0x00, 1, val, 1);
997 if (val[0] & (1 << 6))
1003 extern void lcd_display_clear(void);
1004 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
1006 static void into_charge_mode(void)
1008 unsigned char addr = 0xCC >> 1; /* max8998 */;
1009 unsigned char val[2];
1014 ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1016 i2c_set_bus_num(I2C_PMIC);
1018 if (i2c_probe(addr)) {
1019 printf("Can't found max8998\n");
1023 printf("Charge Mode\n");
1025 i2c_read(addr, 0x0C, 1, val, 1);
1026 val[0] &= ~(0x7 << 0);
1027 val[0] |= 5; /* 600mA */
1028 i2c_write(addr, 0x0C, 1, val, 1);
1030 #ifdef CONFIG_S5PC1XXFB
1033 /* TODO: write the image-text for the charger */
1035 level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1036 if (level >= CHARGER_ANIMATION_FRAME)
1037 level = CHARGER_ANIMATION_FRAME - 1;
1039 for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1040 bmp_addr[i] = (ulong)battery_charging_animation[i];
1042 lcd_display_clear();
1043 for (i = 0; i < 3; i++) {
1044 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1047 bmp = gunzip_bmp(bmp_addr[j], &len);
1048 lcd_display_bitmap((ulong) bmp, 140, 202);
1051 for (k = 0; k < 10; k++)
1052 if (max8998_power_key()) {
1053 lcd_display_clear();
1054 /* FIXME don't use static function */
1055 /* draw_samsung_logo(lcd_base); */
1064 /* EVT0: sleep 1, EVT1: sleep */
1065 if (s5pc1xx_get_cpu_rev() == 0) {
1066 run_command("sleep 1", 0);
1070 run_command("sleep", 0);
1073 static void check_micro_usb(int intr)
1076 unsigned char val[2];
1077 static int started_charging_once = 0;
1080 if (cpu_is_s5pc100())
1083 if (board_is_limo_real()) {
1084 if (hwrevision(0) || hwrevision(1))
1088 i2c_set_bus_num(I2C_PMIC);
1090 if (machine_is_aquila()) {
1091 if (board_is_aries() || board_is_neptune())
1092 i2c_set_bus_num(I2C_GPIO6);
1093 } else if (machine_is_cypress()) {
1094 i2c_set_bus_num(I2C_GPIO6);
1095 } else if (machine_is_geminus()) {
1097 i2c_set_bus_num(I2C_GPIO6);
1098 } else if (machine_is_wmg160())
1099 i2c_set_bus_num(I2C_GPIO6);
1101 addr = 0x25; /* fsa9480 */
1102 if (i2c_probe(addr)) {
1103 printf("Can't found fsa9480\n");
1107 /* Clear Interrupt */
1109 i2c_read(addr, 0x03, 1, val, 2);
1113 /* Read Device Type 1 */
1114 i2c_read(addr, 0x0a, 1, val, 1);
1116 #define FSA_DEDICATED_CHARGER (1 << 6)
1117 #define FSA_UART (1 << 3)
1118 #define FSA_USB (1 << 2)
1121 * If USB, use default 475mA
1122 * If Charger, use 600mA and go to charge mode
1124 if ((val[0] & FSA_DEDICATED_CHARGER) && !started_charging_once) {
1125 started_charging_once = 1;
1129 /* If Factory Mode is Boot ON-USB, go to download mode */
1130 i2c_read(addr, 0x07, 1, val, 1);
1132 #define FSA_ADC_FAC_USB 0x19
1133 #define FSA_ADC_FAC_UART 0x1d
1135 if (val[0] == FSA_ADC_FAC_USB)
1136 setenv("bootcmd", "usbdown");
1138 path = getenv("usb");
1140 if (!strncmp(path, "cp", 2))
1141 run_command("microusb cp", 0);
1144 static void micro_usb_switch(int path)
1147 unsigned char val[2];
1149 i2c_set_bus_num(I2C_PMIC);
1151 if (machine_is_aquila()) {
1152 if (board_is_aries() || board_is_neptune())
1153 i2c_set_bus_num(I2C_GPIO6);
1154 } else if (machine_is_cypress()) {
1155 i2c_set_bus_num(I2C_GPIO6);
1156 } else if (machine_is_geminus()) {
1158 i2c_set_bus_num(I2C_GPIO6);
1159 } else if (machine_is_wmg160()) {
1160 i2c_set_bus_num(I2C_GPIO6);
1164 addr = 0x25; /* fsa9480 */
1165 if (i2c_probe(addr)) {
1166 printf("Can't found fsa9480\n");
1171 val[0] = 0x90; /* VAUDIO */
1173 val[0] = (1 << 5) | (1 << 2); /* DHOST */
1175 i2c_write(addr, 0x13, 1, val, 1); /* MANSW1 */
1177 i2c_read(addr, 0x2, 1, val, 1);
1178 val[0] &= ~(1 << 2); /* Manual switching */
1179 i2c_write(addr, 0x2, 1, val, 1);
1182 #define MAX8998_REG_ONOFF1 0x11
1183 #define MAX8998_REG_ONOFF2 0x12
1184 #define MAX8998_REG_ONOFF3 0x13
1185 #define MAX8998_REG_LDO7 0x21
1186 #define MAX8998_REG_LDO17 0x29
1188 #define MAX8998_LDO3 (1 << 2)
1190 #define MAX8998_LDO6 (1 << 7)
1191 #define MAX8998_LDO7 (1 << 6)
1192 #define MAX8998_LDO8 (1 << 5)
1193 #define MAX8998_LDO9 (1 << 4)
1194 #define MAX8998_LDO10 (1 << 3)
1195 #define MAX8998_LDO11 (1 << 2)
1196 #define MAX8998_LDO12 (1 << 1)
1197 #define MAX8998_LDO13 (1 << 0)
1199 #define MAX8998_LDO14 (1 << 7)
1200 #define MAX8998_LDO15 (1 << 6)
1201 #define MAX8998_LDO16 (1 << 5)
1202 #define MAX8998_LDO17 (1 << 4)
1205 static void init_pmic(void)
1208 unsigned char val[2];
1210 if (cpu_is_s5pc100())
1213 i2c_set_bus_num(I2C_PMIC);
1215 addr = 0xCC >> 1; /* max8998 */
1216 if (i2c_probe(addr)) {
1217 if (i2c_probe(addr)) {
1218 printf("Can't found max8998\n");
1224 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1225 val[0] &= ~MAX8998_LDO3;
1226 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1229 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1231 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1232 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1234 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1235 MAX8998_LDO12 | MAX8998_LDO13);
1237 if (board_is_aries() || board_is_neptune())
1238 val[0] |= MAX8998_LDO7; /* LDO7: VLCD_1.8V */
1240 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1241 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1243 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1245 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1246 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1248 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1249 MAX8998_LDO16 | MAX8998_LDO17);
1251 if (board_is_aries() || board_is_neptune())
1252 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1254 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1255 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1258 static void setup_power_down_mode_registers(void)
1260 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1261 struct s5pc1xx_gpio_bank *bank;
1262 struct gpio_powermode *p;
1264 struct gpio_external *ge;
1266 struct s5pc1xx_gpio_item *mr;
1270 if (cpu_is_s5pc100())
1273 /* Only Limo real and aries supports worked for sleep currnet */
1274 if (machine_is_aquila()) {
1275 if (board_is_limo_real())
1277 else if (board_is_aries() || board_is_neptune())
1281 } else if (machine_is_geminus()) {
1286 if (machine_is_aquila()) {
1287 if (board_is_aries() || board_is_neptune()) {
1288 /* Aquila rev 0.9 */
1289 p = aries_powerdown_modes;
1290 ge = aries_external_powerdown_modes;
1291 mr = aries_mirror_powerdown_mode;
1292 n_p = ARRAY_SIZE(aries_powerdown_modes);
1293 n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1294 n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1296 /* Aquila rev 0.8 or lower */
1297 p = aquila_powerdown_modes;
1298 ge = aquila_external_powerdown_modes;
1299 mr = aquila_mirror_powerdown_mode;
1300 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1301 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1302 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1304 } else if (machine_is_geminus()) {
1305 if (hwrevision(1)) {
1306 /* Same as Aquila rev 0.9 */
1308 p = aries_powerdown_modes;
1309 ge = aries_external_powerdown_modes;
1310 mr = aries_mirror_powerdown_mode;
1311 n_p = ARRAY_SIZE(aries_powerdown_modes);
1312 n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1313 n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1315 p = aquila_powerdown_modes;
1316 ge = aquila_external_powerdown_modes;
1317 mr = aquila_mirror_powerdown_mode;
1318 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1319 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1320 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1322 } else if (hwrevision(0)) {
1323 /* Same as Aquila rev 0.8 or lower */
1324 p = aquila_powerdown_modes;
1325 ge = aquila_external_powerdown_modes;
1326 mr = aquila_mirror_powerdown_mode;
1327 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1328 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1329 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1331 return; /* Not supported */
1335 bank = &gpio->gpio_a0;
1337 for (i = 0; i < n_p; i++, p++, bank++) {
1338 writel(p->conpdn, &bank->pdn_con);
1339 writel(p->pudpdn, &bank->pdn_pull);
1342 writel(0xff0022b0, (unsigned int *)0xF0000000);
1343 writel(0xff0022b0, (unsigned int *)0xF1400000);
1345 bank = &gpio->gpio_h0;
1347 for (i = 0; i < n_ge; i++) {
1348 writel(ge->con, &bank->con);
1349 writel(ge->dat, &bank->dat);
1350 writel(ge->pud, &bank->pull);
1356 for (i = 0; i < n_mr; i++) {
1357 unsigned int reg = readl(&mr->bank->pdn_con);
1358 reg &= ~(1 << mr->number);
1359 if (readl(&mr->bank->dat) & (1 << mr->number))
1360 reg |= 1 << mr->number;
1361 writel(reg, &mr->bank->pdn_con);
1363 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1370 struct spi_platform_data {
1371 struct s5pc1xx_gpio_bank *cs_bank;
1372 struct s5pc1xx_gpio_bank *clk_bank;
1373 struct s5pc1xx_gpio_bank *si_bank;
1374 struct s5pc1xx_gpio_bank *so_bank;
1376 unsigned int cs_num;
1377 unsigned int clk_num;
1378 unsigned int si_num;
1379 unsigned int so_num;
1381 unsigned int board_is_media;
1384 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1385 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1387 struct spi_platform_data spi_pd;
1389 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1391 void lcd_cfg_gpio(void)
1393 unsigned int i, f3_end = 4;
1395 for (i = 0; i < 8; i++) {
1396 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1397 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1398 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1399 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1400 /* pull-up/down disable */
1401 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1402 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1403 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1405 /* drive strength to max (24bit) */
1406 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1407 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1408 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1409 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1410 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1411 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1414 /* set DISPLAY_DE_B pin for dual rgb mode. */
1415 if (board_is_media())
1418 for (i = 0; i < f3_end; i++) {
1419 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1420 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1421 /* pull-up/down disable */
1422 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1423 /* drive strength to max (24bit) */
1424 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1425 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1427 /* display output path selection (only [1:0] valid) */
1428 writel(0x2, 0xE0107008);
1430 /* gpio pad configuration for LCD reset. */
1431 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1433 /* gpio pad configuration for LCD ON. */
1434 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1436 /* LCD_BACKLIGHT_EN */
1437 if (machine_is_geminus())
1438 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1441 * gpio pad configuration for
1442 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1444 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1445 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1446 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1447 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1449 if (machine_is_aquila()) {
1450 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1452 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1454 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1456 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1459 if (board_is_neptune())
1460 s6d16a0x_set_platform_data(&spi_pd);
1462 s6e63m0_set_platform_data(&spi_pd);
1463 if (board_is_media())
1464 spi_pd.board_is_media = 1;
1468 if (machine_is_cypress()) {
1469 #if 0 /* universal cypress */
1471 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1474 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1476 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1478 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1480 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1482 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1483 #if 0 /* universal cypress */
1484 pd_cs.bank = &gpio_base->gpio_mp0_1;
1487 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1489 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1491 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1494 /* these data would be sent to s6e63m0 lcd panel driver. */
1495 s6e63m0_set_platform_data(&spi_pd);
1501 void backlight_on(unsigned int onoff)
1503 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1506 if (machine_is_geminus())
1507 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1509 if (machine_is_geminus())
1510 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1514 void reset_lcd(void)
1516 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1518 if (machine_is_aquila() || machine_is_geminus())
1519 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1520 if (machine_is_cypress())
1521 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1524 void lcd_power_on(unsigned int onoff)
1526 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1529 if (machine_is_aquila() || machine_is_geminus())
1530 gpio_set_value(&gpio->gpio_j1, 3, 1);
1532 if (machine_is_cypress())
1533 gpio_set_value(&gpio->gpio_g2, 2, 1);
1535 if (board_is_aries() || board_is_neptune()) {
1537 unsigned char val[2];
1538 unsigned char val2[2];
1540 i2c_set_bus_num(I2C_PMIC);
1541 addr = 0xCC >> 1; /* max8998 */
1542 if (i2c_probe(addr)) {
1543 printf("Can't found max8998\n");
1546 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1547 val[0] &= ~(MAX8998_LDO17);
1548 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1549 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1551 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1552 val[0] |= MAX8998_LDO17;
1554 i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1555 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1557 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1558 val[0] |= MAX8998_LDO7;
1560 i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1561 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1564 if (machine_is_aquila() || machine_is_geminus())
1565 gpio_set_value(&gpio->gpio_j1, 3, 0);
1567 if (machine_is_cypress())
1568 gpio_set_value(&gpio->gpio_g2, 2, 0);
1570 if (board_is_aries() || board_is_neptune()) {
1572 unsigned char val[2];
1574 i2c_set_bus_num(I2C_PMIC);
1575 addr = 0xCC >> 1; /* max8998 */
1576 if (i2c_probe(addr)) {
1577 printf("Can't found max8998\n");
1581 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1582 val[0] &= ~(1 << 7);
1583 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1584 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1586 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1587 val[0] &= ~MAX8998_LDO17;
1588 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1589 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1594 extern void s6e63m0_cfg_ldo(void);
1595 extern void s6e63m0_enable_ldo(unsigned int onoff);
1596 extern void s6d16a0x_cfg_ldo(void);
1597 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1599 int s5p_no_lcd_support(void)
1601 if (machine_is_wmg160())
1606 void init_panel_info(vidinfo_t *vid)
1608 vid->cfg_gpio = NULL;
1609 vid->reset_lcd = NULL;
1610 vid->backlight_on = NULL;
1611 vid->lcd_power_on = NULL;
1613 vid->cfg_ldo = NULL;
1614 vid->enable_ldo = NULL;
1616 vid->init_delay = 0;
1617 vid->reset_delay = 0;
1618 vid->power_on_delay = 0;
1623 vid->vl_width = 480;
1624 vid->vl_height = 800;
1626 vid->dual_lcd_enabled = 0;
1628 if (board_is_media()) {
1631 vid->vl_width = 960;
1632 vid->vl_height = 800;
1634 /* enable dual lcd mode. */
1635 vid->dual_lcd_enabled = 1;
1638 vid->vl_clkp = CONFIG_SYS_HIGH;
1639 vid->vl_hsp = CONFIG_SYS_LOW;
1640 vid->vl_vsp = CONFIG_SYS_LOW;
1641 vid->vl_dp = CONFIG_SYS_HIGH;
1644 /* S6E63M0 LCD Panel */
1653 if (machine_is_aquila() || machine_is_cypress()) {
1654 vid->cfg_gpio = lcd_cfg_gpio;
1655 vid->reset_lcd = reset_lcd;
1656 vid->backlight_on = backlight_on;
1657 vid->lcd_power_on = lcd_power_on;
1658 vid->cfg_ldo = s6e63m0_cfg_ldo;
1659 vid->enable_ldo = s6e63m0_enable_ldo;
1661 vid->init_delay = 25000;
1662 vid->reset_delay = 120000;
1665 if (board_is_neptune()) {
1669 vid->vl_width = 320;
1670 vid->vl_height = 480;
1672 vid->vl_clkp = CONFIG_SYS_HIGH;
1673 vid->vl_hsp = CONFIG_SYS_HIGH;
1674 vid->vl_vsp = CONFIG_SYS_HIGH;
1675 vid->vl_dp = CONFIG_SYS_LOW;
1678 /* disable dual lcd mode. */
1679 vid->dual_lcd_enabled = 0;
1681 /* S6D16A0X LCD Panel */
1690 vid->cfg_gpio = lcd_cfg_gpio;
1691 vid->backlight_on = NULL;
1692 vid->lcd_power_on = lcd_power_on;
1693 vid->reset_lcd = reset_lcd;
1694 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1695 vid->enable_ldo = s6d16a0x_enable_ldo;
1697 vid->init_delay = 10000;
1698 vid->power_on_delay = 10000;
1699 vid->reset_delay = 1000;
1703 if (machine_is_geminus()) {
1707 vid->vl_width = 1024,
1708 vid->vl_height = 600,
1709 vid->vl_clkp = CONFIG_SYS_LOW,
1710 vid->vl_hsp = CONFIG_SYS_HIGH,
1711 vid->vl_vsp = CONFIG_SYS_HIGH,
1712 vid->vl_dp = CONFIG_SYS_LOW,
1723 vid->cfg_gpio = lcd_cfg_gpio;
1724 vid->reset_lcd = reset_lcd;
1725 vid->backlight_on = backlight_on;
1726 vid->lcd_power_on = lcd_power_on;
1732 vid->vl_width = 480,
1733 vid->vl_height = 800,
1734 vid->vl_clkp = CONFIG_SYS_HIGH,
1735 vid->vl_hsp = CONFIG_SYS_LOW,
1736 vid->vl_vsp = CONFIG_SYS_LOW,
1737 vid->vl_dp = CONFIG_SYS_HIGH,
1753 vid->vl_width = 1024,
1754 vid->vl_height = 600,
1755 vid->vl_clkp = CONFIG_SYS_HIGH,
1756 vid->vl_hsp = CONFIG_SYS_HIGH,
1757 vid->vl_vsp = CONFIG_SYS_HIGH,
1758 vid->vl_dp = CONFIG_SYS_LOW,
1761 /* AMS701KA AMOLED Panel. */
1773 static void setup_meminfo(void)
1775 char meminfo[64] = {0, };
1776 int count = 0, size, real;
1778 size = gd->bd->bi_dram[0].size >> 20;
1779 count += sprintf(meminfo + count, "mem=%dM", size);
1781 /* Each Chip Select can't exceed the 256MiB */
1782 size = gd->bd->bi_dram[1].size >> 20;
1783 real = min(size, 256);
1784 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1785 real, (unsigned int)gd->bd->bi_dram[1].start);
1789 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1790 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1793 setenv("meminfo", meminfo);
1797 * CSA partition Migration
1798 * It will be deleted
1800 static void csa_migration(void)
1802 unsigned int *ubi_id;
1805 run_command("onenand read 0x40000000 0x400000 0x400000", 0);
1807 for (i = 0; i < 10; i++) {
1808 ubi_id = (void *) (0x40000000 + 0x40000 * i);
1809 if (*ubi_id == 0x23494255) /* 0x23494255 = UBI */ {
1810 printf("CSA Migration is already done....\n");
1814 run_command("onenand erase 0x400000 0x800000", 0);
1817 int misc_init_r(void)
1820 /* It should be located at first */
1823 if (board_is_neptune())
1824 setenv("lcdinfo", "lcd=s6d16a0x");
1825 else if ((board_is_limo_real() ||
1826 board_is_limo_universal() ||
1828 setenv("lcdinfo", "lcd=s6e63m0");
1829 /* it can't classify tl2796 with single-lcd and dual-lcd.
1831 setenv("lcdinfo", "lcd=tl2796-dual");
1835 * env values below should be added in case that lcd panel of geminus.
1836 * setenv means that lcd panel has been turned on at u-boot.
1838 if (machine_is_geminus())
1839 setenv("lcdinfo", "lcd=lms480jc01");
1840 if (board_is_media())
1841 setenv("lcdinfo", "lcd=media");
1847 /* Set proper PMIC pins */
1850 /* Check auto burning */
1853 /* To power up I2C2 */
1856 /* Enable T-Flash at Limo Real or Limo Universal */
1859 /* Setup Limo Real board GPIOs */
1860 setup_limo_real_gpios();
1862 /* Setup Media board GPIOs */
1863 setup_media_gpios();
1865 /* To usbdown automatically */
1871 #ifdef CONFIG_S5PC1XXFB
1872 display_device_info();
1875 setup_power_down_mode_registers();
1877 /* check max17040 */
1883 /* csa migration (temporary) */
1890 int board_init(void)
1892 /* Set Initial global variables */
1893 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1895 gd->bd->bi_arch_number = MACH_TYPE;
1896 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1898 /* Check H/W Revision */
1899 check_hw_revision();
1906 unsigned int base, memconfig0, size;
1907 unsigned int memconfig1, sz = 0;
1909 if (cpu_is_s5pc100()) {
1910 /* In mem setup, we swap the bank. So below size is correct */
1911 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1912 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1913 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1916 /* In S5PC110, we can't swap the DMC0/1 */
1917 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1918 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1920 base = S5PC110_DMC1_BASE;
1921 /* DMC configuration */
1922 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1923 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1925 size = (memconfig0 >> 16) & 0xFF;
1926 size = ((unsigned char) ~size) + 1;
1929 * (0x07 + 1) * 16 = 128 MiB
1930 * (0x0f + 1) * 16 = 256 MiB
1935 * Aquila Rev0.5 4G3G1G
1936 * Aquila Rev0.8 4G3G1G
1937 * Aquila Rev0.9 4G3G1G
1939 if (machine_is_aquila() &&
1940 (hwrevision(5) || hwrevision(8) || hwrevision(9))) {
1941 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1943 sz = (memconfig1 >> 16) & 0xFF;
1944 sz = ((unsigned char) ~sz) + 1;
1950 * bi_dram[1].size contains all DMC1 memory size
1952 gd->bd->bi_dram[1].size = (size + sz) << 20;
1957 /* Used for sleep test */
1958 static unsigned char saved_val[4][2];
1959 void board_sleep_init_late(void)
1961 /* CODEC_LDO_EN: GPF3[4] */
1962 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1963 /* CODEC_XTAL_EN: GPH3[2] */
1964 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1966 /* MMC T_FLASH off */
1967 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1969 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1970 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1971 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1975 void board_sleep_init(void)
1978 unsigned char val[2];
1980 i2c_set_bus_num(I2C_PMIC);
1982 if (i2c_probe(addr)) {
1983 printf("Can't find max8998\n");
1988 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1989 saved_val[0][0] = val[0];
1990 saved_val[0][1] = val[1];
1991 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1992 (1 << 1) | (1 << 0));
1993 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1994 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1996 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1997 saved_val[1][0] = val[0];
1998 saved_val[1][1] = val[1];
1999 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
2000 (1 << 2) | (1 << 1) | (1 << 0));
2002 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2003 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2005 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2006 saved_val[2][0] = val[0];
2007 saved_val[2][1] = val[1];
2008 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
2009 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2010 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2012 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2013 saved_val[3][0] = val[0];
2014 saved_val[3][1] = val[1];
2015 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2016 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2017 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2018 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2019 __FILE__, __LINE__);
2022 void board_sleep_resume(void)
2025 unsigned char val[2];
2029 i2c_set_bus_num(I2C_PMIC);
2031 if (i2c_probe(addr)) {
2032 printf("Can't find max8998\n");
2037 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2038 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2040 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2041 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2043 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2044 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2046 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2047 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2048 printf("Waked up.\n");
2050 /* check max17040 */
2057 #ifdef CONFIG_CMD_USBDOWN
2058 int usb_board_init(void)
2060 #ifdef CONFIG_CMD_PMIC
2061 run_command("pmic ldo 3 on", 0);
2064 if (cpu_is_s5pc100()) {
2065 #ifdef CONFIG_HARD_I2C
2066 uchar val[2] = {0,};
2069 if (i2c_read(0x66, 0, 1, val, 2)) {
2070 printf("i2c_read error\n");
2077 if (i2c_write(0x66, 0, 1, val, 2)) {
2078 printf("i2c_write error\n");
2081 i2c_read(0x66, 0, 1, val, 2);
2087 if (board_is_limo_universal() ||
2088 board_is_limo_real() ||
2090 /* check usb path */
2091 if (board_is_limo_real() && !hwrevision(6))
2095 if (machine_is_tickertape())
2096 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2097 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2099 /* USB Path to AP */
2100 micro_usb_switch(0);
2106 #ifdef CONFIG_GENERIC_MMC
2107 int s5p_no_mmc_support(void)
2109 if (machine_is_wmg160())
2114 int board_mmc_init(bd_t *bis)
2118 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2121 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2122 if (machine_is_aquila() && (board_is_aries() || board_is_neptune()))
2123 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2125 if (machine_is_wmg160())
2128 /* MMC0 Clock source = SCLKMPLL */
2129 reg = readl(&clk->src4);
2132 writel(reg, &clk->src4);
2134 reg = readl(&clk->div4);
2137 /* set div value near 50MHz */
2138 clock = get_pll_clk(MPLL) / 1000000;
2139 for (i = 0; i < 0xf; i++) {
2140 if ((clock / (i + 1)) <= 50) {
2146 writel(reg, &clk->div4);
2152 * GPG0[2] SD_0_CDn -> Not used
2153 * GPG0[3:6] SD_0_DATA[0:3]
2155 for (i = 0; i < 7; i++) {
2158 /* GPG0[0:6] special function 2 */
2159 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2160 /* GPG0[0:6] pull disable */
2161 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2162 /* GPG0[0:6] drv 4x */
2163 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4x);
2166 return s5pc1xx_mmc_init(0);
2170 #ifdef CONFIG_CMD_PMIC
2171 static int pmic_status(void)
2173 unsigned char addr, val[2];
2176 i2c_set_bus_num(I2C_PMIC);
2178 if (i2c_probe(addr)) {
2179 printf("Can't found max8998\n");
2184 i2c_read(addr, reg, 1, val, 1);
2185 for (i = 7; i >= 4; i--)
2186 printf("BUCK%d %s\n", 7 - i + 1,
2187 val[0] & (1 << i) ? "on" : "off");
2189 printf("LDO%d %s\n", 5 - i,
2190 val[0] & (1 << i) ? "on" : "off");
2192 i2c_read(addr, reg, 1, val, 1);
2193 for (i = 7; i >= 0; i--)
2194 printf("LDO%d %s\n", 7 - i + 6,
2195 val[0] & (1 << i) ? "on" : "off");
2197 i2c_read(addr, reg, 1, val, 1);
2198 for (i = 7; i >= 4; i--)
2199 printf("LDO%d %s\n", 7 - i + 14,
2200 val[0] & (1 << i) ? "on" : "off");
2203 i2c_read(addr, reg, 1, val, 1);
2204 for (i = 7; i >= 6; i--)
2205 printf("SAFEOUT%d %s\n", 7 - i + 1,
2206 val[0] & (1 << i) ? "on" : "off");
2210 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2212 unsigned char addr, val[2];
2213 unsigned int reg, shift;
2221 } else if (ldo <= 13) {
2224 } else if (ldo <= 17) {
2226 shift = 17 - ldo + 4;
2233 shift = 4 - buck + 4;
2234 } else if (safeout) {
2238 shift = 8 - safeout;
2242 i2c_set_bus_num(I2C_PMIC);
2244 if (i2c_probe(addr)) {
2245 printf("Can't found max8998\n");
2249 i2c_read(addr, reg, 1, val, 1);
2251 val[0] |= (1 << shift);
2253 val[0] &= ~(1 << shift);
2254 i2c_write(addr, reg, 1, val, 1);
2255 i2c_read(addr, reg, 1, val, 1);
2258 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2259 val[0] & (1 << shift) ? "on" : "off");
2261 printf("buck %d value 0x%x, %s\n", buck, val[0],
2262 val[0] & (1 << shift) ? "on" : "off");
2264 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2265 val[0] & (1 << shift) ? "on" : "off");
2270 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2272 int buck = 0, ldo = 0, safeout = 0, on = -1;
2276 if (strncmp(argv[1], "status", 6) == 0)
2277 return pmic_status();
2280 if (strncmp(argv[1], "ldo", 3) == 0)
2281 ldo = simple_strtoul(argv[2], NULL, 10);
2282 else if (strncmp(argv[1], "buck", 4) == 0)
2283 buck = simple_strtoul(argv[2], NULL, 10);
2284 else if (strncmp(argv[1], "safeout", 7) == 0)
2285 safeout = simple_strtoul(argv[2], NULL, 10);
2289 if (strncmp(argv[3], "on", 2) == 0)
2291 else if (strncmp(argv[3], "off", 3) == 0)
2296 return pmic_ldo_control(buck, ldo, safeout, on);
2307 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2308 "PMIC LDO & BUCK control",
2309 "status - Display PMIC LDO & BUCK status\n"
2310 "pmic ldo num on/off - Turn on/off the LDO\n"
2311 "pmic buck num on/off - Turn on/off the BUCK\n"
2312 "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2316 #ifdef CONFIG_CMD_DEVICE_POWER
2330 static void power_display_devices(void)
2332 printf("devices:\n");
2333 printf("\t%d - touch\n", POWER_TOUCH);
2334 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2335 printf("\t%d - LCD\n", POWER_LCD);
2336 printf("\t%d - Haptic\n", POWER_HAPTIC);
2337 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2338 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2339 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2340 printf("\t%d - HDMI\n", POWER_HDMI);
2343 static int power_hdmi(int on)
2345 /* HDMI_EN1: GPJ2[2] */
2346 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2347 /* MHL_ON: GPJ2[3] */
2348 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2352 static int power_bt_wifi(int on)
2354 /* WLAN_BT_EN: GPB[5] */
2355 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2359 static int power_fm_radio(int on)
2361 /* FM_BUS_nRST: GPJ2[5] */
2362 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2366 static int power_audio_codec(int on)
2368 /* CODEC_LDO_EN: GPF3[4] */
2369 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2370 /* CODEC_XTAL_EN: GPH3[2] */
2371 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2375 static int power_haptic(int on)
2377 /* HAPTIC_ON: GPJ1[1] */
2378 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2382 static int power_lcd(int on)
2384 /* MLCD_ON: GPJ1[3] */
2385 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2389 static int power_touch(int on)
2391 /* TOUCH_EN: GPG3[6] */
2392 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2396 static int power_3_touchkey(int on)
2399 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2400 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2401 if (board_rev & J1_B2_BOARD)
2402 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2404 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2406 /* 3_TOUCH_CE - GPJ2[6] */
2407 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2409 /* 3_TOUCH_CE - GPJ2[6] */
2410 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2415 unsigned char val[2];
2416 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2422 i2c_set_bus_num(I2C_GPIO10);
2424 /* Workaround to probe */
2425 if (i2c_probe(addr)) {
2426 if (i2c_probe(addr)) {
2427 printf("Can't found 3 touchkey\n");
2432 #define MCS5000_TK_HW_VERSION 0x06
2433 #define MCS5000_TK_FW_VERSION 0x0A
2434 #define MCS5000_TK_MI_VERSION 0x0B
2436 reg = MCS5000_TK_MI_VERSION;
2437 i2c_read(addr, reg, 1, val, 1);
2438 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2439 reg = MCS5000_TK_HW_VERSION;
2440 i2c_read(addr, reg, 1, val, 1);
2441 printf("H/W 0x%x, ", val[0]);
2442 reg = MCS5000_TK_FW_VERSION;
2443 i2c_read(addr, reg, 1, val, 1);
2444 printf("F/W 0x%x\n", val[0]);
2449 static int power_control(int device, int on)
2453 return power_touch(on);
2454 case POWER_3_TOUCHKEY:
2455 return power_3_touchkey(on);
2457 return power_lcd(on);
2459 return power_haptic(on);
2460 case POWER_AUDIO_CODEC:
2461 return power_audio_codec(on);
2462 case POWER_FM_RADIO:
2463 return power_fm_radio(on);
2465 return power_bt_wifi(on);
2467 return power_hdmi(on);
2469 printf("I don't know device %d\n", device);
2475 static int power_on(int on)
2478 power_3_touchkey(on);
2481 power_audio_codec(on);
2489 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2493 if (!machine_is_aquila())
2498 if (strncmp(argv[1], "on", 2) == 0)
2500 if (strncmp(argv[1], "off", 3) == 0)
2504 device = simple_strtoul(argv[1], NULL, 10);
2508 if (strncmp(argv[2], "on", 2) == 0)
2510 else if (strncmp(argv[2], "off", 3) == 0)
2514 return power_control(device, on);
2520 power_display_devices();
2525 power, CONFIG_SYS_MAXARGS, 1, do_power,
2526 "Device Power Management control",
2527 "device on/off - Turn on/off the device\n"
2530 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2534 if (strncmp(argv[1], "cp", 2) == 0) {
2535 micro_usb_switch(1);
2536 pmic_ldo_control(0, 0, 2, 1);
2537 setenv("usb", "cp");
2538 } else if (strncmp(argv[1], "ap", 2) == 0) {
2539 micro_usb_switch(0);
2540 pmic_ldo_control(0, 0, 2, 0);
2541 setenv("usb", "ap");
2551 printf("USB Path is set to %s\n", getenv("usb"));
2557 microusb, CONFIG_SYS_MAXARGS, 1, do_microusb,
2559 "cp - switch to CP\n"
2560 "microusb ap - switch to AP\n"