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_j1b2(void)
242 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
245 static int board_is_aries(void)
247 return machine_is_aquila() && (board_rev & ARIES_BOARD);
250 static int board_is_neptune(void)
252 return machine_is_aquila() && (board_rev & NEPTUNE_BOARD);
256 static int machine_is_wmg160(void)
258 return c110_machine_id() == MACH_WMG160;
261 static void enable_battery(void);
263 void i2c_init_board(void)
265 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
268 if (cpu_is_s5pc100())
271 num_bus = ARRAY_SIZE(i2c_gpio);
273 if (machine_is_aquila()) {
274 if (board_is_aries()) {
275 i2c_gpio[I2C_GPIO7].bus->gpio_base =
276 (unsigned int)&gpio->gpio_mp0_5;
278 i2c_gpio[I2C_GPIO6].bus->gpio_base = 0;
279 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
281 } else if (machine_is_cypress()) {
282 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
283 i2c_gpio[I2C_GPIO7].bus->gpio_base =
284 (unsigned int)&gpio->gpio_mp0_5;
286 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
289 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
290 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
291 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
292 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
293 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
295 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
297 /* Reset on max17040 early */
298 if (battery_soc == 0)
302 #ifdef CONFIG_MISC_INIT_R
303 #define DEV_INFO_LEN 512
304 static char device_info[DEV_INFO_LEN];
305 static int display_info;
307 static void dprintf(const char *fmt, ...)
314 i = vsprintf(buf, fmt, args);
319 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
320 puts("Flushing device info...\n");
324 strcat(device_info, buf);
328 #ifdef CONFIG_S5PC1XXFB
329 static void display_device_info(void)
336 set_font_color(FONT_WHITE);
337 fb_printf(device_info);
340 memset(device_info, 0x0, DEV_INFO_LEN);
342 udelay(5 * 1000 * 1000);
346 static const char *board_name[] = {
350 "P1P2", /* Don't remove it */
363 static char feature_buffer[32];
365 static char *display_features(int board, int board_rev)
368 char *buf = feature_buffer;
371 if (board == MACH_AQUILA) {
372 if (board_rev & SPLIT_SCREEN_FEATURE)
373 name = "SplitScreen";
374 if (board_rev & J1_B2_BOARD)
376 /* Limo Real or Universal */
377 if (board_rev & LIMO_REAL_BOARD)
379 else if (board_rev & LIMO_UNIVERSAL_BOARD)
380 name = "Limo Universal";
381 if (board_rev & MEDIA_BOARD)
383 if (board_rev & BAMBOO_BOARD)
385 if (board_rev & ARIES_BOARD)
387 if (board_rev & NEPTUNE_BOARD)
391 count += sprintf(buf + count, " - %s", name);
397 static char *get_board_name(int board)
399 if (board == MACH_WMG160)
401 return (char *) board_name[board];
404 static void check_board_revision(int board, int rev)
408 /* Limo Real or Universal */
409 if (rev & LIMO_UNIVERSAL_BOARD)
410 board_rev &= ~J1_B2_BOARD;
411 if (rev & LIMO_REAL_BOARD)
412 board_rev &= ~(J1_B2_BOARD |
413 LIMO_UNIVERSAL_BOARD);
414 if (rev & MEDIA_BOARD)
415 board_rev &= ~(J1_B2_BOARD |
416 LIMO_UNIVERSAL_BOARD);
417 if (rev & BAMBOO_BOARD)
418 board_rev &= ~(J1_B2_BOARD |
419 LIMO_UNIVERSAL_BOARD |
422 if (rev & ARIES_BOARD)
423 board_rev &= ~(J1_B2_BOARD |
424 LIMO_UNIVERSAL_BOARD);
425 if (rev & NEPTUNE_BOARD)
426 board_rev &= ~(J1_B2_BOARD |
427 LIMO_UNIVERSAL_BOARD);
430 case MACH_TICKERTAPE:
433 board_rev &= ~BOARD_MASK;
440 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank, int hwrev3)
448 gpio_direction_input(bank, 2);
449 gpio_direction_input(bank, 3);
450 gpio_direction_input(bank, 4);
451 gpio_direction_input(bank, mode3);
453 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
454 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
455 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
456 gpio_set_pull(bank, mode3, GPIO_PULL_NONE); /* HWREV_MODE3 */
458 rev = gpio_get_value(bank, 2);
459 rev |= (gpio_get_value(bank, 3) << 1);
460 rev |= (gpio_get_value(bank, 4) << 2);
461 rev |= (gpio_get_value(bank, mode3) << 3);
466 static void check_hw_revision(void)
468 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
470 if (cpu_is_s5pc100()) {
471 struct s5pc100_gpio *gpio =
472 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
474 board_rev = get_hw_revision(&gpio->gpio_j0, 0);
476 /* C100 TickerTape */
478 board = MACH_TICKERTAPE;
480 struct s5pc110_gpio *gpio =
481 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
487 * Note Check 'Aquila' board first
491 * LRA: Limo Real Aquila
492 * LUA: Limo Universal Aquila
497 * ADDR = 0xE0200000 + OFF
499 * OFF Universal BB LRA LUA OA TT SS CYP
500 * J1: 0x0264 0x10 0x10 0x00 0x00 0x00 0x00 0x00
501 * J2: 0x0284 0x01 0x10 0x00
502 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x0F
503 * H3: 0x0C64 0x03 0x07 0x0F
504 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
505 * I: 0x0224 0x02 0x00 0x08
506 * MP03: 0x0324 0x9x 0xbx 0x9x
507 * MP05: 0x0364 0x80 0x88
511 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
513 board_rev |= J1_B2_BOARD;
515 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
516 gpio_direction_input(&gpio->gpio_j2, 6);
519 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
520 board_rev |= LIMO_UNIVERSAL_BOARD;
522 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
523 board_rev |= LIMO_REAL_BOARD;
525 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
526 board_rev |= MEDIA_BOARD;
528 /* set gpio to default value. */
529 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
530 gpio_direction_output(&gpio->gpio_j2, 6, 0);
533 /* Workaround: C110 Aquila Rev0.6 */
534 if (board_rev == 6) {
536 board_rev |= LIMO_REAL_BOARD;
539 /* C110 Aquila Bamboo */
540 if (gpio_get_value(&gpio->gpio_j2, 0) == 1) {
542 board_rev |= BAMBOO_BOARD;
545 /* C110 TickerTape */
546 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
547 gpio_get_value(&gpio->gpio_d1, 1) == 0)
548 board = MACH_TICKERTAPE;
550 /* WMG160 - GPH3[0:4] = 0x00 */
551 if (board == MACH_TICKERTAPE) {
554 for (i = 0; i < 4; i++) {
555 if (gpio_get_value(&gpio->gpio_h3, i) != 0) {
566 /* C110 Geminus for rev0.0 */
567 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
568 gpio_direction_input(&gpio->gpio_j1, 2);
569 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
570 board = MACH_GEMINUS;
571 if ((board_rev & ~BOARD_MASK) == 3)
574 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
575 gpio_direction_output(&gpio->gpio_j1, 2, 0);
577 /* C110 Geminus for rev0.1 ~ */
578 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
579 gpio_direction_input(&gpio->gpio_j0, 6);
580 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
581 board = MACH_GEMINUS;
584 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
586 /* Aquila - Aries MP0_5[6] == 1 */
587 gpio_direction_input(&gpio->gpio_mp0_5, 6);
588 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
589 /* Cypress: Do this for cypress */
590 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
591 gpio_direction_input(&gpio->gpio_j2, 2);
592 if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
593 board = MACH_CYPRESS;
594 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
597 board_rev |= ARIES_BOARD;
598 #ifdef USE_NEPTUNE_BOARD
599 board_rev &= ~ARIES_BOARD;
600 board_rev |= NEPTUNE_BOARD;
603 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
606 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
608 board_rev |= get_hw_revision(&gpio->gpio_j0, hwrev3);
612 if (cpu_is_s5pc110())
613 gd->bd->bi_arch_number = C110_MACH_START + board;
615 gd->bd->bi_arch_number = C100_MACH_START + board;
617 /* Architecture Common settings */
618 if (cpu_is_s5pc110()) {
619 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
621 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
623 setenv("updatek", "onenand erase 0x60000 0x300000; "
624 "onenand write 0x31008000 0x60000 0x300000");
628 static void show_hw_revision(void)
633 * Workaround for Rev 0.3 + CP Ver ES 3.1
636 if (board_is_limo_real()) {
638 /* default is Rev 0.4 */
644 if (cpu_is_s5pc110())
645 board = gd->bd->bi_arch_number - C110_MACH_START;
647 board = gd->bd->bi_arch_number - C100_MACH_START;
649 check_board_revision(board, board_rev);
651 /* Set CPU Revision */
652 if (machine_is_aquila()) {
653 if (board_is_limo_real()) {
654 if ((board_rev & 0xf) < 8)
655 s5pc1xx_set_cpu_rev(0);
657 } else if (machine_is_geminus()) {
658 if ((board_rev & 0xf) < 1)
659 s5pc1xx_set_cpu_rev(0);
660 } else if (machine_is_cypress()) {
661 s5pc1xx_set_cpu_rev(1);
663 s5pc1xx_set_cpu_rev(0);
666 dprintf("HW Revision:\t%x (%s%s) %s\n",
667 board_rev, get_board_name(board),
668 display_features(board, board_rev),
669 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
672 static void check_auto_burn(void)
674 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
675 unsigned int count = 0;
678 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
679 printf("Auto burning bootloader\n");
680 count += sprintf(buf + count, "run updateb; ");
682 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
683 printf("Auto burning kernel\n");
684 count += sprintf(buf + count, "run updatek; ");
688 count += sprintf(buf + count, "reset");
689 setenv("bootcmd", buf);
692 /* Clear the magic value */
693 writel(0xa5a55a5a, magic_base);
694 writel(0xa5a55a5a, magic_base + 0x4);
697 static void pmic_pin_init(void)
699 unsigned int reg, value;
701 if (cpu_is_s5pc100())
704 /* AP_PS_HOLD: XEINT_0: GPH0[0]
705 * Note: Don't use GPIO PS_HOLD it doesn't work
707 reg = S5PC110_PS_HOLD_CONTROL;
709 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
710 S5PC110_PS_HOLD_DATA_HIGH |
711 S5PC110_PS_HOLD_OUT_EN;
714 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
715 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
716 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
719 static void enable_ldos(void)
721 if (cpu_is_s5pc100())
724 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
725 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
728 static void enable_t_flash(void)
730 if (!(board_is_limo_universal() || board_is_limo_real()))
733 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
734 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
737 static void setup_limo_real_gpios(void)
739 if (!board_is_limo_real())
743 * Note: Please write GPIO alphabet order
745 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
746 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
749 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
750 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
752 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
753 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
755 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
756 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
757 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
760 static void setup_media_gpios(void)
762 if (!board_is_media())
766 * Note: Please write GPIO alphabet order
768 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
769 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
771 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
772 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
773 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
776 #define KBR3 (1 << 3)
777 #define KBR2 (1 << 2)
778 #define KBR1 (1 << 1)
779 #define KBR0 (1 << 0)
781 static void check_keypad(void)
783 unsigned int reg, value;
784 unsigned int col_num, row_num;
785 unsigned int col_mask;
786 unsigned int col_mask_shift;
787 unsigned int row_state[4];
789 unsigned int auto_download = 0;
791 if (machine_is_wmg160())
794 if (cpu_is_s5pc100()) {
795 struct s5pc100_gpio *gpio =
796 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
801 /* Set GPH2[2:0] to KP_COL[2:0] */
802 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
803 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
804 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
806 /* Set GPH3[2:0] to KP_ROW[2:0] */
807 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
808 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
809 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
811 reg = S5PC100_KEYPAD_BASE;
812 col_mask = S5PC1XX_KEYIFCOL_MASK;
815 if (board_is_limo_real() || board_is_limo_universal()) {
823 for (i = 0; i < row_num; i++) {
824 /* Set GPH3[3:0] to KP_ROW[3:0] */
825 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
826 gpio_set_pull(&s5pc110_gpio->gpio_h3, i, GPIO_PULL_UP);
829 for (i = 0; i < col_num; i++)
830 /* Set GPH2[3:0] to KP_COL[3:0] */
831 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
833 reg = S5PC110_KEYPAD_BASE;
834 col_mask = S5PC110_KEYIFCOLEN_MASK;
838 /* KEYIFCOL reg clear */
839 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
842 for (i = 0; i < col_num; i++) {
844 value &= ~(1 << i) << col_mask_shift;
846 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
849 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
850 row_state[i] = ~value & ((1 << row_num) - 1);
851 printf("[%d col] row_state: 0x%x\n", i, row_state[i]);
854 /* KEYIFCOL reg clear */
855 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
857 if (machine_is_aquila()) {
858 /* cam full shot & volume down */
859 if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
862 else if ((row_state[1] & 0x2))
864 } else if (machine_is_geminus())
865 /* volume down & home */
866 if ((row_state[1] & 0x2) && (row_state[2] & 0x1))
870 setenv("bootcmd", "usbdown");
873 static void enable_battery(void)
875 unsigned char val[2];
876 unsigned char addr = 0x36; /* max17040 fuel gauge */
878 i2c_set_bus_num(I2C_GPIO3);
880 if (machine_is_aquila()) {
881 if (board_is_aries() || board_is_neptune())
882 i2c_set_bus_num(I2C_GPIO7);
883 else if (board_is_j1b2())
885 } else if (machine_is_tickertape()) {
887 } else if (machine_is_cypress()) {
888 i2c_set_bus_num(I2C_GPIO7);
889 } else if (machine_is_geminus()) {
891 i2c_set_bus_num(I2C_GPIO7);
894 if (i2c_probe(addr)) {
895 printf("Can't found max17040 fuel gauge\n");
901 i2c_write(addr, 0xfe, 1, val, 2);
904 static void check_battery(void)
906 unsigned char val[2];
907 unsigned char addr = 0x36; /* max17040 fuel gauge */
909 i2c_set_bus_num(I2C_GPIO3);
911 if (machine_is_aquila()) {
912 if (board_is_aries() || board_is_neptune())
913 i2c_set_bus_num(I2C_GPIO7);
914 else if (board_is_j1b2())
916 } else if (machine_is_cypress()) {
917 i2c_set_bus_num(I2C_GPIO7);
918 } else if (machine_is_geminus()) {
920 i2c_set_bus_num(I2C_GPIO7);
924 if (i2c_probe(addr)) {
925 printf("Can't found max17040 fuel gauge\n");
929 i2c_read(addr, 0x04, 1, val, 1);
931 dprintf("battery:\t%d%%\n", val[0]);
933 battery_soc = val[0];
936 static void check_mhl(void)
938 unsigned char val[2];
939 unsigned char addr = 0x39; /* SIL9230 */
941 /* MHL Power enable */
942 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
943 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
945 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
946 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
948 /* 10ms required after reset */
952 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
954 i2c_set_bus_num(I2C_GPIO5);
957 if (i2c_probe(addr)) {
958 printf("Can't found MHL Chip\n");
964 * set to Normal operation
967 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
968 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
973 * 00 = MHL termination ON
974 * 11 = MHL termination OFF
977 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
978 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
981 #define CHARGER_ANIMATION_FRAME 6
982 static int max8998_power_key(void)
984 unsigned char addr, val[2];
985 i2c_set_bus_num(I2C_PMIC);
987 if (i2c_probe(addr)) {
988 printf("Can't found max8998\n");
992 /* Accessing IRQ1 register */
993 i2c_read(addr, 0x00, 1, val, 1);
994 if (val[0] & (1 << 6))
1000 static int max8998_has_ext_power_source(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 STATUS2 register */
1011 i2c_read(addr, 0x09, 1, val, 1);
1012 if (val[0] & (1 << 5))
1018 extern void lcd_display_clear(void);
1019 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
1021 static void into_charge_mode(void)
1023 unsigned char addr = 0xCC >> 1; /* max8998 */;
1024 unsigned char val[2];
1029 ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1031 i2c_set_bus_num(I2C_PMIC);
1033 if (i2c_probe(addr)) {
1034 printf("Can't found max8998\n");
1038 printf("Charge Mode\n");
1040 i2c_read(addr, 0x0C, 1, val, 1);
1041 val[0] &= ~(0x7 << 0);
1042 val[0] &= ~(0x7 << 5);
1043 val[0] |= 5; /* 600mA */
1044 val[0] |= (3 << 5); /* Stop at 150mA(25%) */
1045 i2c_write(addr, 0x0C, 1, val, 1);
1047 #ifdef CONFIG_S5PC1XXFB
1050 /* TODO: write the image-text for the charger */
1052 level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1053 if (level >= CHARGER_ANIMATION_FRAME)
1054 level = CHARGER_ANIMATION_FRAME - 1;
1056 for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1057 bmp_addr[i] = (ulong)battery_charging_animation[i];
1059 lcd_display_clear();
1060 for (i = 0; i < 3; i++) {
1061 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1064 bmp = gunzip_bmp(bmp_addr[j], &len);
1065 lcd_display_bitmap((ulong) bmp, 140, 202);
1068 for (k = 0; k < 10; k++)
1069 if (max8998_power_key()) {
1070 lcd_display_clear();
1072 } else if (!max8998_has_ext_power_source()) {
1073 lcd_display_clear();
1082 /* EVT0: sleep 1, EVT1: sleep */
1083 if (s5pc1xx_get_cpu_rev() == 0) {
1084 run_command("sleep 1", 0);
1088 run_command("sleep", 0);
1091 static void check_micro_usb(int intr)
1094 unsigned char val[2];
1095 static int started_charging_once = 0;
1098 if (cpu_is_s5pc100())
1101 if (board_is_limo_real()) {
1102 if (hwrevision(0) || hwrevision(1))
1106 i2c_set_bus_num(I2C_PMIC);
1108 if (machine_is_aquila()) {
1109 if (board_is_aries() || board_is_neptune())
1110 i2c_set_bus_num(I2C_GPIO6);
1111 } else if (machine_is_cypress()) {
1112 i2c_set_bus_num(I2C_GPIO6);
1113 } else if (machine_is_geminus()) {
1115 i2c_set_bus_num(I2C_GPIO6);
1116 } else if (machine_is_wmg160())
1117 i2c_set_bus_num(I2C_GPIO6);
1119 addr = 0x25; /* fsa9480 */
1120 if (i2c_probe(addr)) {
1121 printf("Can't found fsa9480\n");
1125 /* Clear Interrupt */
1127 i2c_read(addr, 0x03, 1, val, 2);
1131 /* Read Device Type 1 */
1132 i2c_read(addr, 0x0a, 1, val, 1);
1134 #define FSA_DEV1_CHARGER (1 << 6)
1135 #define FSA_DEV1_UART (1 << 3)
1136 #define FSA_DEV1_USB (1 << 2)
1137 #define FSA_DEV2_JIG_USB_OFF (1 << 1)
1138 #define FSA_DEV2_JIG_USB_ON (1 << 0)
1141 * If USB, use default 475mA
1142 * If Charger, use 600mA and go to charge mode
1144 if ((val[0] & FSA_DEV1_CHARGER) && !started_charging_once) {
1145 started_charging_once = 1;
1149 /* If Factory Mode is Boot ON-USB, go to download mode */
1150 i2c_read(addr, 0x07, 1, val, 1);
1152 #define FSA_ADC_FAC_USB_OFF 0x18
1153 #define FSA_ADC_FAC_USB_ON 0x19
1154 #define FSA_ADC_FAC_UART 0x1d
1156 if (val[0] == FSA_ADC_FAC_USB_ON || val[0] == FSA_ADC_FAC_USB_OFF)
1157 setenv("bootcmd", "usbdown");
1159 path = getenv("usb");
1161 if (!strncmp(path, "cp", 2))
1162 run_command("microusb cp", 0);
1165 static void micro_usb_switch(int path)
1168 unsigned char val[2];
1170 i2c_set_bus_num(I2C_PMIC);
1172 if (machine_is_aquila()) {
1173 if (board_is_aries() || board_is_neptune())
1174 i2c_set_bus_num(I2C_GPIO6);
1175 } else if (machine_is_cypress()) {
1176 i2c_set_bus_num(I2C_GPIO6);
1177 } else if (machine_is_geminus()) {
1179 i2c_set_bus_num(I2C_GPIO6);
1180 } else if (machine_is_wmg160()) {
1181 i2c_set_bus_num(I2C_GPIO6);
1185 addr = 0x25; /* fsa9480 */
1186 if (i2c_probe(addr)) {
1187 printf("Can't found fsa9480\n");
1192 val[0] = 0x90; /* VAUDIO */
1194 val[0] = (1 << 5) | (1 << 2); /* DHOST */
1196 i2c_write(addr, 0x13, 1, val, 1); /* MANSW1 */
1198 i2c_read(addr, 0x2, 1, val, 1);
1199 val[0] &= ~(1 << 2); /* Manual switching */
1200 i2c_write(addr, 0x2, 1, val, 1);
1203 #define MAX8998_REG_ONOFF1 0x11
1204 #define MAX8998_REG_ONOFF2 0x12
1205 #define MAX8998_REG_ONOFF3 0x13
1206 #define MAX8998_REG_LDO7 0x21
1207 #define MAX8998_REG_LDO17 0x29
1209 #define MAX8998_LDO3 (1 << 2)
1211 #define MAX8998_LDO6 (1 << 7)
1212 #define MAX8998_LDO7 (1 << 6)
1213 #define MAX8998_LDO8 (1 << 5)
1214 #define MAX8998_LDO9 (1 << 4)
1215 #define MAX8998_LDO10 (1 << 3)
1216 #define MAX8998_LDO11 (1 << 2)
1217 #define MAX8998_LDO12 (1 << 1)
1218 #define MAX8998_LDO13 (1 << 0)
1220 #define MAX8998_LDO14 (1 << 7)
1221 #define MAX8998_LDO15 (1 << 6)
1222 #define MAX8998_LDO16 (1 << 5)
1223 #define MAX8998_LDO17 (1 << 4)
1226 static void init_pmic(void)
1229 unsigned char val[2];
1231 if (cpu_is_s5pc100())
1234 i2c_set_bus_num(I2C_PMIC);
1236 addr = 0xCC >> 1; /* max8998 */
1237 if (i2c_probe(addr)) {
1238 if (i2c_probe(addr)) {
1239 printf("Can't found max8998\n");
1245 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1246 val[0] &= ~MAX8998_LDO3;
1247 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1250 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1252 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1253 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1255 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1256 MAX8998_LDO12 | MAX8998_LDO13);
1258 if (board_is_aries() || board_is_neptune())
1259 val[0] |= MAX8998_LDO7; /* LDO7: VLCD_1.8V */
1261 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1262 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1264 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1266 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1267 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1269 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1270 MAX8998_LDO16 | MAX8998_LDO17);
1272 if (board_is_aries() || board_is_neptune())
1273 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1275 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1276 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1279 static void setup_power_down_mode_registers(void)
1281 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1282 struct s5pc1xx_gpio_bank *bank;
1283 struct gpio_powermode *p;
1285 struct gpio_external *ge;
1287 struct s5pc1xx_gpio_item *mr;
1291 if (cpu_is_s5pc100())
1294 /* Only Limo real and aries supports worked for sleep currnet */
1295 if (machine_is_aquila()) {
1296 if (board_is_limo_real())
1298 else if (board_is_aries() || board_is_neptune())
1302 } else if (machine_is_geminus()) {
1307 if (machine_is_aquila()) {
1308 if (board_is_aries() || board_is_neptune()) {
1309 /* Aquila rev 0.9 */
1310 p = aries_powerdown_modes;
1311 ge = aries_external_powerdown_modes;
1312 mr = aries_mirror_powerdown_mode;
1313 n_p = ARRAY_SIZE(aries_powerdown_modes);
1314 n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1315 n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1317 /* Aquila rev 0.8 or lower */
1318 p = aquila_powerdown_modes;
1319 ge = aquila_external_powerdown_modes;
1320 mr = aquila_mirror_powerdown_mode;
1321 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1322 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1323 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1325 } else if (machine_is_geminus()) {
1326 if (hwrevision(1)) {
1327 /* Same as Aquila rev 0.9 */
1329 p = aries_powerdown_modes;
1330 ge = aries_external_powerdown_modes;
1331 mr = aries_mirror_powerdown_mode;
1332 n_p = ARRAY_SIZE(aries_powerdown_modes);
1333 n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1334 n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1336 p = aquila_powerdown_modes;
1337 ge = aquila_external_powerdown_modes;
1338 mr = aquila_mirror_powerdown_mode;
1339 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1340 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1341 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1343 } else if (hwrevision(0)) {
1344 /* Same as Aquila rev 0.8 or lower */
1345 p = aquila_powerdown_modes;
1346 ge = aquila_external_powerdown_modes;
1347 mr = aquila_mirror_powerdown_mode;
1348 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1349 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1350 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1352 return; /* Not supported */
1356 bank = &gpio->gpio_a0;
1358 for (i = 0; i < n_p; i++, p++, bank++) {
1359 writel(p->conpdn, &bank->pdn_con);
1360 writel(p->pudpdn, &bank->pdn_pull);
1363 writel(0xff0022b0, (unsigned int *)0xF0000000);
1364 writel(0xff0022b0, (unsigned int *)0xF1400000);
1366 bank = &gpio->gpio_h0;
1368 for (i = 0; i < n_ge; i++) {
1369 writel(ge->con, &bank->con);
1370 writel(ge->dat, &bank->dat);
1371 writel(ge->pud, &bank->pull);
1377 for (i = 0; i < n_mr; i++) {
1378 unsigned int reg = readl(&mr->bank->pdn_con);
1379 reg &= ~(1 << mr->number);
1380 if (readl(&mr->bank->dat) & (1 << mr->number))
1381 reg |= 1 << mr->number;
1382 writel(reg, &mr->bank->pdn_con);
1384 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1391 #include "../../../drivers/video/s5p-spi.h"
1393 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1394 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1396 struct spi_platform_data spi_pd;
1398 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1400 void lcd_cfg_gpio(void)
1402 unsigned int i, f3_end = 4;
1404 for (i = 0; i < 8; i++) {
1405 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1406 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1407 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1408 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1409 /* pull-up/down disable */
1410 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1411 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1412 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1414 /* drive strength to max (24bit) */
1415 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1416 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1417 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1418 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1419 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1420 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1423 /* set DISPLAY_DE_B pin for dual rgb mode. */
1424 if (board_is_media())
1427 for (i = 0; i < f3_end; i++) {
1428 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1429 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1430 /* pull-up/down disable */
1431 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1432 /* drive strength to max (24bit) */
1433 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1434 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1436 /* display output path selection (only [1:0] valid) */
1437 writel(0x2, 0xE0107008);
1439 /* gpio pad configuration for LCD reset. */
1440 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1442 /* gpio pad configuration for LCD ON. */
1443 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1445 /* LCD_BACKLIGHT_EN */
1446 if (machine_is_geminus())
1447 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1450 * gpio pad configuration for
1451 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1453 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1454 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1455 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1456 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1458 if (machine_is_aquila()) {
1459 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1461 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1463 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1465 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1468 if (board_is_neptune())
1469 s6d16a0x_set_platform_data(&spi_pd);
1471 s6e63m0_set_platform_data(&spi_pd);
1472 if (board_is_media())
1477 if (machine_is_cypress()) {
1478 #if 0 /* universal cypress */
1480 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1483 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1485 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1487 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1489 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1491 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1492 #if 0 /* universal cypress */
1493 pd_cs.bank = &gpio_base->gpio_mp0_1;
1496 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1498 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1500 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1505 /* these data would be sent to s6e63m0 lcd panel driver. */
1506 s6e63m0_set_platform_data(&spi_pd);
1512 void backlight_on(unsigned int onoff)
1514 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1517 if (machine_is_geminus())
1518 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1520 if (machine_is_geminus())
1521 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1525 void reset_lcd(void)
1527 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1529 if (machine_is_aquila() || machine_is_geminus())
1530 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1531 if (machine_is_cypress())
1532 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1535 void lcd_power_on(unsigned int onoff)
1537 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1540 if (machine_is_aquila() || machine_is_geminus())
1541 gpio_set_value(&gpio->gpio_j1, 3, 1);
1543 if (machine_is_cypress())
1544 gpio_set_value(&gpio->gpio_g2, 2, 1);
1546 if (board_is_aries() || board_is_neptune()) {
1548 unsigned char val[2];
1549 unsigned char val2[2];
1551 i2c_set_bus_num(I2C_PMIC);
1552 addr = 0xCC >> 1; /* max8998 */
1553 if (i2c_probe(addr)) {
1554 printf("Can't found max8998\n");
1557 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1558 val[0] &= ~(MAX8998_LDO17);
1559 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1560 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1562 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1563 val[0] |= MAX8998_LDO17;
1565 i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1566 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1568 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1569 val[0] |= MAX8998_LDO7;
1571 i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1572 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1575 if (machine_is_aquila() || machine_is_geminus())
1576 gpio_set_value(&gpio->gpio_j1, 3, 0);
1578 if (machine_is_cypress())
1579 gpio_set_value(&gpio->gpio_g2, 2, 0);
1581 if (board_is_aries() || board_is_neptune()) {
1583 unsigned char val[2];
1585 i2c_set_bus_num(I2C_PMIC);
1586 addr = 0xCC >> 1; /* max8998 */
1587 if (i2c_probe(addr)) {
1588 printf("Can't found max8998\n");
1592 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1593 val[0] &= ~(1 << 7);
1594 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1595 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1597 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1598 val[0] &= ~MAX8998_LDO17;
1599 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1600 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1605 extern void s6e63m0_cfg_ldo(void);
1606 extern void s6e63m0_enable_ldo(unsigned int onoff);
1607 extern void s6d16a0x_cfg_ldo(void);
1608 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1610 int s5p_no_lcd_support(void)
1612 if (machine_is_wmg160())
1617 void init_panel_info(vidinfo_t *vid)
1619 vid->cfg_gpio = NULL;
1620 vid->reset_lcd = NULL;
1621 vid->backlight_on = NULL;
1622 vid->lcd_power_on = NULL;
1624 vid->cfg_ldo = NULL;
1625 vid->enable_ldo = NULL;
1627 vid->init_delay = 0;
1628 vid->reset_delay = 0;
1629 vid->power_on_delay = 0;
1634 vid->vl_width = 480;
1635 vid->vl_height = 800;
1637 vid->dual_lcd_enabled = 0;
1639 if (board_is_media()) {
1642 vid->vl_width = 960;
1643 vid->vl_height = 800;
1645 /* enable dual lcd mode. */
1646 vid->dual_lcd_enabled = 1;
1649 vid->vl_clkp = CONFIG_SYS_HIGH;
1650 vid->vl_hsp = CONFIG_SYS_LOW;
1651 vid->vl_vsp = CONFIG_SYS_LOW;
1652 vid->vl_dp = CONFIG_SYS_HIGH;
1655 /* S6E63M0 LCD Panel */
1664 if (machine_is_aquila() || machine_is_cypress()) {
1665 vid->cfg_gpio = lcd_cfg_gpio;
1666 vid->reset_lcd = reset_lcd;
1667 vid->backlight_on = backlight_on;
1668 vid->lcd_power_on = lcd_power_on;
1669 vid->cfg_ldo = s6e63m0_cfg_ldo;
1670 vid->enable_ldo = s6e63m0_enable_ldo;
1672 vid->init_delay = 25000;
1673 vid->reset_delay = 120000;
1676 if (board_is_neptune()) {
1680 vid->vl_width = 320;
1681 vid->vl_height = 480;
1683 vid->vl_clkp = CONFIG_SYS_HIGH;
1684 vid->vl_hsp = CONFIG_SYS_HIGH;
1685 vid->vl_vsp = CONFIG_SYS_HIGH;
1686 vid->vl_dp = CONFIG_SYS_LOW;
1689 /* disable dual lcd mode. */
1690 vid->dual_lcd_enabled = 0;
1692 /* S6D16A0X LCD Panel */
1701 vid->cfg_gpio = lcd_cfg_gpio;
1702 vid->backlight_on = NULL;
1703 vid->lcd_power_on = lcd_power_on;
1704 vid->reset_lcd = reset_lcd;
1705 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1706 vid->enable_ldo = s6d16a0x_enable_ldo;
1708 vid->init_delay = 10000;
1709 vid->power_on_delay = 10000;
1710 vid->reset_delay = 1000;
1714 if (machine_is_geminus()) {
1718 vid->vl_width = 1024,
1719 vid->vl_height = 600,
1720 vid->vl_clkp = CONFIG_SYS_LOW,
1721 vid->vl_hsp = CONFIG_SYS_HIGH,
1722 vid->vl_vsp = CONFIG_SYS_HIGH,
1723 vid->vl_dp = CONFIG_SYS_LOW,
1734 vid->cfg_gpio = lcd_cfg_gpio;
1735 vid->reset_lcd = reset_lcd;
1736 vid->backlight_on = backlight_on;
1737 vid->lcd_power_on = lcd_power_on;
1743 vid->vl_width = 480,
1744 vid->vl_height = 800,
1745 vid->vl_clkp = CONFIG_SYS_HIGH,
1746 vid->vl_hsp = CONFIG_SYS_LOW,
1747 vid->vl_vsp = CONFIG_SYS_LOW,
1748 vid->vl_dp = CONFIG_SYS_HIGH,
1764 vid->vl_width = 1024,
1765 vid->vl_height = 600,
1766 vid->vl_clkp = CONFIG_SYS_HIGH,
1767 vid->vl_hsp = CONFIG_SYS_HIGH,
1768 vid->vl_vsp = CONFIG_SYS_HIGH,
1769 vid->vl_dp = CONFIG_SYS_LOW,
1772 /* AMS701KA AMOLED Panel. */
1784 static void setup_meminfo(void)
1786 char meminfo[64] = {0, };
1787 int count = 0, size, real;
1789 size = gd->bd->bi_dram[0].size >> 20;
1790 count += sprintf(meminfo + count, "mem=%dM", size);
1792 /* Each Chip Select can't exceed the 256MiB */
1793 size = gd->bd->bi_dram[1].size >> 20;
1794 real = min(size, 256);
1795 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1796 real, (unsigned int)gd->bd->bi_dram[1].start);
1800 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1801 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1804 setenv("meminfo", meminfo);
1808 * CSA partition Migration
1809 * It will be deleted
1811 static void csa_migration(void)
1813 unsigned int *ubi_id;
1816 run_command("onenand read 0x40000000 0x400000 0x400000", 0);
1818 for (i = 0; i < 10; i++) {
1819 ubi_id = (void *) (0x40000000 + 0x40000 * i);
1820 if (*ubi_id == 0x23494255) /* 0x23494255 = UBI */ {
1821 printf("CSA Migration is already done....\n");
1825 run_command("onenand erase 0x400000 0x800000", 0);
1828 int misc_init_r(void)
1831 /* It should be located at first */
1834 if (machine_is_aquila()) {
1835 if (board_is_neptune())
1836 setenv("lcdinfo", "lcd=s6d16a0x");
1837 else if (board_is_media())
1838 setenv("lcdinfo", "lcd=s6e63m0");
1840 setenv("lcdinfo", "lcd=s6e63m0");
1842 if (machine_is_geminus())
1843 setenv("lcdinfo", "lcd=lms480jc01");
1844 if (machine_is_cypress())
1845 setenv("lcdinfo", "lcd=s6e63m0");
1851 /* Set proper PMIC pins */
1854 /* Check auto burning */
1857 /* To power up I2C2 */
1860 /* Enable T-Flash at Limo Real or Limo Universal */
1863 /* Setup Limo Real board GPIOs */
1864 setup_limo_real_gpios();
1866 /* Setup Media board GPIOs */
1867 setup_media_gpios();
1869 /* To usbdown automatically */
1875 #ifdef CONFIG_S5PC1XXFB
1876 display_device_info();
1879 setup_power_down_mode_registers();
1881 /* check max17040 */
1887 /* csa migration (temporary) */
1894 int board_init(void)
1896 /* Set Initial global variables */
1897 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1899 gd->bd->bi_arch_number = MACH_TYPE;
1900 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1902 /* Check H/W Revision */
1903 check_hw_revision();
1910 unsigned int base, memconfig0, size;
1911 unsigned int memconfig1, sz = 0;
1913 if (cpu_is_s5pc100()) {
1914 /* In mem setup, we swap the bank. So below size is correct */
1915 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1916 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1917 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1920 /* In S5PC110, we can't swap the DMC0/1 */
1921 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1922 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1924 base = S5PC110_DMC1_BASE;
1925 /* DMC configuration */
1926 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1927 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1929 size = (memconfig0 >> 16) & 0xFF;
1930 size = ((unsigned char) ~size) + 1;
1933 * (0x07 + 1) * 16 = 128 MiB
1934 * (0x0f + 1) * 16 = 256 MiB
1939 * Aquila Rev0.5 4G3G1G
1940 * Aquila Rev0.8 4G3G1G
1941 * Aquila Rev0.9 4G3G1G
1943 if (machine_is_aquila() &&
1944 (hwrevision(5) || hwrevision(8) || hwrevision(9))) {
1945 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1947 sz = (memconfig1 >> 16) & 0xFF;
1948 sz = ((unsigned char) ~sz) + 1;
1954 * bi_dram[1].size contains all DMC1 memory size
1956 gd->bd->bi_dram[1].size = (size + sz) << 20;
1961 /* Used for sleep test */
1962 static unsigned char saved_val[4][2];
1963 void board_sleep_init_late(void)
1965 /* CODEC_LDO_EN: GPF3[4] */
1966 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1967 /* CODEC_XTAL_EN: GPH3[2] */
1968 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1970 /* MMC T_FLASH off */
1971 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1973 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1974 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1975 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1979 void board_sleep_init(void)
1982 unsigned char val[2];
1984 i2c_set_bus_num(I2C_PMIC);
1986 if (i2c_probe(addr)) {
1987 printf("Can't find max8998\n");
1992 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1993 saved_val[0][0] = val[0];
1994 saved_val[0][1] = val[1];
1995 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1996 (1 << 1) | (1 << 0));
1997 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1998 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2000 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2001 saved_val[1][0] = val[0];
2002 saved_val[1][1] = val[1];
2003 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
2004 (1 << 2) | (1 << 1) | (1 << 0));
2006 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2007 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2009 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2010 saved_val[2][0] = val[0];
2011 saved_val[2][1] = val[1];
2012 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
2013 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2014 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2016 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2017 saved_val[3][0] = val[0];
2018 saved_val[3][1] = val[1];
2019 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2020 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2021 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2022 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2023 __FILE__, __LINE__);
2026 void board_sleep_resume(void)
2029 unsigned char val[2];
2033 i2c_set_bus_num(I2C_PMIC);
2035 if (i2c_probe(addr)) {
2036 printf("Can't find max8998\n");
2041 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2042 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2044 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2045 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2047 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2048 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2050 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2051 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2052 printf("Waked up.\n");
2054 /* check max17040 */
2061 #ifdef CONFIG_CMD_USBDOWN
2062 int usb_board_init(void)
2064 #ifdef CONFIG_CMD_PMIC
2065 run_command("pmic ldo 3 on", 0);
2068 if (cpu_is_s5pc100()) {
2069 #ifdef CONFIG_HARD_I2C
2070 uchar val[2] = {0,};
2073 if (i2c_read(0x66, 0, 1, val, 2)) {
2074 printf("i2c_read error\n");
2081 if (i2c_write(0x66, 0, 1, val, 2)) {
2082 printf("i2c_write error\n");
2085 i2c_read(0x66, 0, 1, val, 2);
2091 if (board_is_limo_universal() ||
2092 board_is_limo_real() ||
2094 /* check usb path */
2095 if (board_is_limo_real() && !hwrevision(6))
2099 if (machine_is_tickertape())
2100 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2101 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2103 /* USB Path to AP */
2104 micro_usb_switch(0);
2110 #ifdef CONFIG_GENERIC_MMC
2111 int s5p_no_mmc_support(void)
2113 if (machine_is_wmg160())
2118 int board_mmc_init(bd_t *bis)
2122 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2125 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2126 if (machine_is_aquila() && (board_is_aries() || board_is_neptune()))
2127 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2129 if (machine_is_wmg160())
2132 /* MMC0 Clock source = SCLKMPLL */
2133 reg = readl(&clk->src4);
2136 writel(reg, &clk->src4);
2138 reg = readl(&clk->div4);
2141 /* set div value near 50MHz */
2142 clock = get_pll_clk(MPLL) / 1000000;
2143 for (i = 0; i < 0xf; i++) {
2144 if ((clock / (i + 1)) <= 50) {
2150 writel(reg, &clk->div4);
2156 * GPG0[2] SD_0_CDn -> Not used
2157 * GPG0[3:6] SD_0_DATA[0:3]
2159 for (i = 0; i < 7; i++) {
2162 /* GPG0[0:6] special function 2 */
2163 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2164 /* GPG0[0:6] pull disable */
2165 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2166 /* GPG0[0:6] drv 4x */
2167 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4x);
2170 return s5pc1xx_mmc_init(0);
2174 #ifdef CONFIG_CMD_PMIC
2175 static int pmic_status(void)
2177 unsigned char addr, val[2];
2180 i2c_set_bus_num(I2C_PMIC);
2182 if (i2c_probe(addr)) {
2183 printf("Can't found max8998\n");
2188 i2c_read(addr, reg, 1, val, 1);
2189 for (i = 7; i >= 4; i--)
2190 printf("BUCK%d %s\n", 7 - i + 1,
2191 val[0] & (1 << i) ? "on" : "off");
2193 printf("LDO%d %s\n", 5 - i,
2194 val[0] & (1 << i) ? "on" : "off");
2196 i2c_read(addr, reg, 1, val, 1);
2197 for (i = 7; i >= 0; i--)
2198 printf("LDO%d %s\n", 7 - i + 6,
2199 val[0] & (1 << i) ? "on" : "off");
2201 i2c_read(addr, reg, 1, val, 1);
2202 for (i = 7; i >= 4; i--)
2203 printf("LDO%d %s\n", 7 - i + 14,
2204 val[0] & (1 << i) ? "on" : "off");
2207 i2c_read(addr, reg, 1, val, 1);
2208 for (i = 7; i >= 6; i--)
2209 printf("SAFEOUT%d %s\n", 7 - i + 1,
2210 val[0] & (1 << i) ? "on" : "off");
2214 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2216 unsigned char addr, val[2];
2217 unsigned int reg, shift;
2225 } else if (ldo <= 13) {
2228 } else if (ldo <= 17) {
2230 shift = 17 - ldo + 4;
2237 shift = 4 - buck + 4;
2238 } else if (safeout) {
2242 shift = 8 - safeout;
2246 i2c_set_bus_num(I2C_PMIC);
2248 if (i2c_probe(addr)) {
2249 printf("Can't found max8998\n");
2253 i2c_read(addr, reg, 1, val, 1);
2255 val[0] |= (1 << shift);
2257 val[0] &= ~(1 << shift);
2258 i2c_write(addr, reg, 1, val, 1);
2259 i2c_read(addr, reg, 1, val, 1);
2262 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2263 val[0] & (1 << shift) ? "on" : "off");
2265 printf("buck %d value 0x%x, %s\n", buck, val[0],
2266 val[0] & (1 << shift) ? "on" : "off");
2268 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2269 val[0] & (1 << shift) ? "on" : "off");
2274 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2276 int buck = 0, ldo = 0, safeout = 0, on = -1;
2280 if (strncmp(argv[1], "status", 6) == 0)
2281 return pmic_status();
2284 if (strncmp(argv[1], "ldo", 3) == 0)
2285 ldo = simple_strtoul(argv[2], NULL, 10);
2286 else if (strncmp(argv[1], "buck", 4) == 0)
2287 buck = simple_strtoul(argv[2], NULL, 10);
2288 else if (strncmp(argv[1], "safeout", 7) == 0)
2289 safeout = simple_strtoul(argv[2], NULL, 10);
2293 if (strncmp(argv[3], "on", 2) == 0)
2295 else if (strncmp(argv[3], "off", 3) == 0)
2300 return pmic_ldo_control(buck, ldo, safeout, on);
2311 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2312 "PMIC LDO & BUCK control",
2313 "status - Display PMIC LDO & BUCK status\n"
2314 "pmic ldo num on/off - Turn on/off the LDO\n"
2315 "pmic buck num on/off - Turn on/off the BUCK\n"
2316 "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2320 #ifdef CONFIG_CMD_DEVICE_POWER
2334 static void power_display_devices(void)
2336 printf("devices:\n");
2337 printf("\t%d - touch\n", POWER_TOUCH);
2338 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2339 printf("\t%d - LCD\n", POWER_LCD);
2340 printf("\t%d - Haptic\n", POWER_HAPTIC);
2341 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2342 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2343 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2344 printf("\t%d - HDMI\n", POWER_HDMI);
2347 static int power_hdmi(int on)
2349 /* HDMI_EN1: GPJ2[2] */
2350 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2351 /* MHL_ON: GPJ2[3] */
2352 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2356 static int power_bt_wifi(int on)
2358 /* WLAN_BT_EN: GPB[5] */
2359 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2363 static int power_fm_radio(int on)
2365 /* FM_BUS_nRST: GPJ2[5] */
2366 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2370 static int power_audio_codec(int on)
2372 /* CODEC_LDO_EN: GPF3[4] */
2373 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2374 /* CODEC_XTAL_EN: GPH3[2] */
2375 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2379 static int power_haptic(int on)
2381 /* HAPTIC_ON: GPJ1[1] */
2382 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2386 static int power_lcd(int on)
2388 /* MLCD_ON: GPJ1[3] */
2389 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2393 static int power_touch(int on)
2395 /* TOUCH_EN: GPG3[6] */
2396 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2400 static int power_3_touchkey(int on)
2403 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2404 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2405 if (board_rev & J1_B2_BOARD)
2406 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2408 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2410 /* 3_TOUCH_CE - GPJ2[6] */
2411 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2413 /* 3_TOUCH_CE - GPJ2[6] */
2414 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2419 unsigned char val[2];
2420 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2426 i2c_set_bus_num(I2C_GPIO10);
2428 /* Workaround to probe */
2429 if (i2c_probe(addr)) {
2430 if (i2c_probe(addr)) {
2431 printf("Can't found 3 touchkey\n");
2436 #define MCS5000_TK_HW_VERSION 0x06
2437 #define MCS5000_TK_FW_VERSION 0x0A
2438 #define MCS5000_TK_MI_VERSION 0x0B
2440 reg = MCS5000_TK_MI_VERSION;
2441 i2c_read(addr, reg, 1, val, 1);
2442 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2443 reg = MCS5000_TK_HW_VERSION;
2444 i2c_read(addr, reg, 1, val, 1);
2445 printf("H/W 0x%x, ", val[0]);
2446 reg = MCS5000_TK_FW_VERSION;
2447 i2c_read(addr, reg, 1, val, 1);
2448 printf("F/W 0x%x\n", val[0]);
2453 static int power_control(int device, int on)
2457 return power_touch(on);
2458 case POWER_3_TOUCHKEY:
2459 return power_3_touchkey(on);
2461 return power_lcd(on);
2463 return power_haptic(on);
2464 case POWER_AUDIO_CODEC:
2465 return power_audio_codec(on);
2466 case POWER_FM_RADIO:
2467 return power_fm_radio(on);
2469 return power_bt_wifi(on);
2471 return power_hdmi(on);
2473 printf("I don't know device %d\n", device);
2479 static int power_on(int on)
2482 power_3_touchkey(on);
2485 power_audio_codec(on);
2493 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2497 if (!machine_is_aquila())
2502 if (strncmp(argv[1], "on", 2) == 0)
2504 if (strncmp(argv[1], "off", 3) == 0)
2508 device = simple_strtoul(argv[1], NULL, 10);
2512 if (strncmp(argv[2], "on", 2) == 0)
2514 else if (strncmp(argv[2], "off", 3) == 0)
2518 return power_control(device, on);
2524 power_display_devices();
2529 power, CONFIG_SYS_MAXARGS, 1, do_power,
2530 "Device Power Management control",
2531 "device on/off - Turn on/off the device\n"
2534 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2538 if (strncmp(argv[1], "cp", 2) == 0) {
2539 micro_usb_switch(1);
2540 pmic_ldo_control(0, 0, 2, 1);
2541 setenv("usb", "cp");
2542 } else if (strncmp(argv[1], "ap", 2) == 0) {
2543 micro_usb_switch(0);
2544 pmic_ldo_control(0, 0, 2, 0);
2545 setenv("usb", "ap");
2555 printf("USB Path is set to %s\n", getenv("usb"));
2561 microusb, CONFIG_SYS_MAXARGS, 1, do_microusb,
2563 "cp - switch to CP\n"
2564 "microusb ap - switch to AP\n"