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 static unsigned int board_rev;
50 static unsigned int battery_soc;
51 static struct s5pc110_gpio *s5pc110_gpio;
68 static struct i2c_gpio_bus_data i2c_2 = {
78 static struct i2c_gpio_bus_data i2c_gpio3 = {
88 static struct i2c_gpio_bus_data i2c_pmic = {
98 static struct i2c_gpio_bus_data i2c_gpio5 = {
108 static struct i2c_gpio_bus_data i2c_gpio6 = {
114 * i2c gpio7 - kessler
118 static struct i2c_gpio_bus_data i2c_gpio7 = {
124 * i2c gpio7 - cypress
128 static struct i2c_gpio_bus_data i2c_cypress_gpio7 = {
138 static struct i2c_gpio_bus_data i2c_gpio10 = {
144 static struct i2c_gpio_bus i2c_gpio[] = {
162 u32 get_board_rev(void)
167 static int hwrevision(int rev)
169 return (board_rev & 0xf) == rev;
176 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
196 /* board is MACH_KESSLER and board is like below */
197 #define ARIES_BOARD 0x4000
198 #define NEPTUNE_BOARD 0x8000
200 #define BOARD_MASK 0xFF00
202 static int c110_machine_id(void)
204 return gd->bd->bi_arch_number - C110_MACH_START;
207 static int machine_is_aquila(void)
209 return (gd->bd->bi_arch_number == MACH_AQUILA);
212 static int machine_is_tickertape(void)
214 return c110_machine_id() == MACH_TICKERTAPE;
217 static int machine_is_geminus(void)
219 return c110_machine_id() == MACH_GEMINUS;
222 static int machine_is_cypress(void)
224 return c110_machine_id() == MACH_CYPRESS;
227 static int board_is_limo_universal(void)
229 return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
232 static int board_is_limo_real(void)
234 return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
237 static int board_is_media(void)
239 return machine_is_aquila() && (board_rev & MEDIA_BOARD);
242 static int board_is_j1b2(void)
244 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
248 static int machine_is_kessler(void)
250 return gd->bd->bi_arch_number == MACH_KESSLER;
253 static int board_is_neptune(void)
255 return machine_is_kessler() && (board_rev & NEPTUNE_BOARD);
259 static int machine_is_wmg160(void)
261 return c110_machine_id() == MACH_WMG160;
264 static void enable_battery(void);
266 void i2c_init_board(void)
268 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
271 if (cpu_is_s5pc100())
274 num_bus = ARRAY_SIZE(i2c_gpio);
276 if (machine_is_aquila()) {
277 i2c_gpio[I2C_GPIO6].bus->gpio_base = 0;
278 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
279 } else if (machine_is_kessler()) {
280 i2c_gpio[I2C_GPIO7].bus->gpio_base =
281 (unsigned int)&gpio->gpio_mp0_5;
282 } else if (machine_is_cypress()) {
283 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
284 i2c_gpio[I2C_GPIO7].bus->gpio_base =
285 (unsigned int)&gpio->gpio_mp0_5;
287 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
290 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
291 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
292 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
293 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
294 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
296 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
298 /* Reset on max17040 early */
299 if (battery_soc == 0)
303 #ifdef CONFIG_MISC_INIT_R
304 #define DEV_INFO_LEN 512
305 static char device_info[DEV_INFO_LEN];
306 static int display_info;
308 static void dprintf(const char *fmt, ...)
315 i = vsprintf(buf, fmt, args);
320 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
321 puts("Flushing device info...\n");
325 strcat(device_info, buf);
329 #ifdef CONFIG_S5PC1XXFB
330 static void display_device_info(void)
337 set_font_color(FONT_WHITE);
338 fb_printf(device_info);
341 memset(device_info, 0x0, DEV_INFO_LEN);
343 udelay(5 * 1000 * 1000);
347 static const char *board_name[] = {
351 "P1P2", /* Don't remove it */
364 static char feature_buffer[32];
366 static char *display_features(int board, int board_rev)
369 char *buf = feature_buffer;
372 if (board == MACH_AQUILA) {
373 if (board_rev & SPLIT_SCREEN_FEATURE)
374 name = "SplitScreen";
375 if (board_rev & J1_B2_BOARD)
377 /* Limo Real or Universal */
378 if (board_rev & LIMO_REAL_BOARD)
380 else if (board_rev & LIMO_UNIVERSAL_BOARD)
381 name = "Limo Universal";
382 if (board_rev & MEDIA_BOARD)
384 if (board_rev & BAMBOO_BOARD)
386 } else if (board == MACH_KESSLER) {
387 if (board_rev & ARIES_BOARD)
389 if (board_rev & NEPTUNE_BOARD)
393 count += sprintf(buf + count, " - %s", name);
398 static char *get_board_name(int board)
400 if (board == MACH_AQUILA)
402 else if (board == MACH_KESSLER)
404 else if (board == MACH_WMG160)
406 return (char *) board_name[board];
409 static void check_board_revision(int board, int rev)
411 if (board == MACH_AQUILA) {
412 /* Limo Real or Universal */
413 if (rev & LIMO_UNIVERSAL_BOARD)
414 board_rev &= ~J1_B2_BOARD;
415 if (rev & LIMO_REAL_BOARD)
416 board_rev &= ~(J1_B2_BOARD |
417 LIMO_UNIVERSAL_BOARD);
418 if (rev & MEDIA_BOARD)
419 board_rev &= ~(J1_B2_BOARD |
420 LIMO_UNIVERSAL_BOARD);
421 if (rev & BAMBOO_BOARD)
422 board_rev &= ~(J1_B2_BOARD |
423 LIMO_UNIVERSAL_BOARD |
426 } else if (board == MACH_KESSLER) {
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);
434 board_rev &= ~BOARD_MASK;
437 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank, int hwrev3)
445 gpio_direction_input(bank, 2);
446 gpio_direction_input(bank, 3);
447 gpio_direction_input(bank, 4);
448 gpio_direction_input(bank, mode3);
450 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
451 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
452 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
453 gpio_set_pull(bank, mode3, GPIO_PULL_NONE); /* HWREV_MODE3 */
455 rev = gpio_get_value(bank, 2);
456 rev |= (gpio_get_value(bank, 3) << 1);
457 rev |= (gpio_get_value(bank, 4) << 2);
458 rev |= (gpio_get_value(bank, mode3) << 3);
463 static void check_hw_revision(void)
465 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
467 if (cpu_is_s5pc100()) {
468 struct s5pc100_gpio *gpio =
469 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
471 board_rev = get_hw_revision(&gpio->gpio_j0, 0);
473 /* C100 TickerTape */
475 board = MACH_TICKERTAPE;
477 struct s5pc110_gpio *gpio =
478 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
484 * Note Check 'Aquila' board first
488 * LRA: Limo Real Aquila
489 * LUA: Limo Universal Aquila
494 * ADDR = 0xE0200000 + OFF
496 * OFF Universal BB LRA LUA OA TT SS CYP
497 * J1: 0x0264 0x10 0x10 0x00 0x00 0x00 0x00 0x00
498 * J2: 0x0284 0x01 0x10 0x00
499 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x0F
500 * H3: 0x0C64 0x03 0x07 0x0F
501 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
502 * I: 0x0224 0x02 0x00 0x08
503 * MP03: 0x0324 0x9x 0xbx 0x9x
504 * MP05: 0x0364 0x80 0x88
508 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
510 board_rev |= J1_B2_BOARD;
512 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
513 gpio_direction_input(&gpio->gpio_j2, 6);
516 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
517 board_rev |= LIMO_UNIVERSAL_BOARD;
519 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
520 board_rev |= LIMO_REAL_BOARD;
522 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
523 board_rev |= MEDIA_BOARD;
525 /* set gpio to default value. */
526 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
527 gpio_direction_output(&gpio->gpio_j2, 6, 0);
530 /* Workaround: C110 Aquila Rev0.6 */
531 if (board_rev == 6) {
533 board_rev |= LIMO_REAL_BOARD;
536 /* C110 Aquila Bamboo */
537 if (gpio_get_value(&gpio->gpio_j2, 0) == 1) {
539 board_rev |= BAMBOO_BOARD;
542 /* C110 TickerTape */
543 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
544 gpio_get_value(&gpio->gpio_d1, 1) == 0)
545 board = MACH_TICKERTAPE;
547 /* WMG160 - GPH3[0:4] = 0x00 */
548 if (board == MACH_TICKERTAPE) {
551 for (i = 0; i < 4; i++) {
552 if (gpio_get_value(&gpio->gpio_h3, i) != 0) {
563 /* C110 Geminus for rev0.0 */
564 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
565 gpio_direction_input(&gpio->gpio_j1, 2);
566 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
567 board = MACH_GEMINUS;
568 if ((board_rev & ~BOARD_MASK) == 3)
571 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
572 gpio_direction_output(&gpio->gpio_j1, 2, 0);
574 /* C110 Geminus for rev0.1 ~ */
575 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
576 gpio_direction_input(&gpio->gpio_j0, 6);
577 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
578 board = MACH_GEMINUS;
581 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
583 /* Kessler MP0_5[6] == 1 */
584 gpio_direction_input(&gpio->gpio_mp0_5, 6);
585 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
586 /* Cypress: Do this for cypress */
587 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
588 gpio_direction_input(&gpio->gpio_j2, 2);
589 if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
590 board = MACH_CYPRESS;
591 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
593 board = MACH_KESSLER;
594 board_rev |= ARIES_BOARD;
596 /* Neptune MP0_5[4] == 1 */
597 gpio_direction_input(&gpio->gpio_mp0_5, 4);
598 if (gpio_get_value(&gpio->gpio_mp0_5, 4) == 1) {
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 (board == MACH_AQUILA)
613 gd->bd->bi_arch_number = MACH_AQUILA;
614 else if (board == MACH_KESSLER)
615 gd->bd->bi_arch_number = MACH_KESSLER;
616 else if (cpu_is_s5pc110())
617 gd->bd->bi_arch_number = C110_MACH_START + board;
619 gd->bd->bi_arch_number = C100_MACH_START + board;
621 /* Architecture Common settings */
622 if (cpu_is_s5pc110()) {
623 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
625 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
627 setenv("updatek", "onenand erase 0x60000 0x300000; "
628 "onenand write 0x31008000 0x60000 0x300000");
632 static void show_hw_revision(void)
637 * Workaround for Rev 0.3 + CP Ver ES 3.1
640 if (board_is_limo_real()) {
642 /* default is Rev 0.4 */
648 if (machine_is_aquila())
650 else if (machine_is_kessler())
651 board = MACH_KESSLER;
652 else if (cpu_is_s5pc110())
653 board = gd->bd->bi_arch_number - C110_MACH_START;
655 board = gd->bd->bi_arch_number - C100_MACH_START;
657 check_board_revision(board, board_rev);
659 /* Set CPU Revision */
660 if (machine_is_aquila()) {
661 if (board_is_limo_real()) {
662 if ((board_rev & 0xf) < 8)
663 s5pc1xx_set_cpu_rev(0);
665 } else if (machine_is_kessler())
666 s5pc1xx_set_cpu_rev(1);
667 else if (machine_is_geminus()) {
668 if ((board_rev & 0xf) < 1)
669 s5pc1xx_set_cpu_rev(0);
670 } else if (machine_is_cypress()) {
671 s5pc1xx_set_cpu_rev(1);
673 s5pc1xx_set_cpu_rev(0);
676 dprintf("HW Revision:\t%x (%s%s) %s\n",
677 board_rev, get_board_name(board),
678 display_features(board, board_rev),
679 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
682 static void check_auto_burn(void)
684 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
685 unsigned int count = 0;
688 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
689 printf("Auto burning bootloader\n");
690 count += sprintf(buf + count, "run updateb; ");
692 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
693 printf("Auto burning kernel\n");
694 count += sprintf(buf + count, "run updatek; ");
698 count += sprintf(buf + count, "reset");
699 setenv("bootcmd", buf);
702 /* Clear the magic value */
703 writel(0xa5a55a5a, magic_base);
704 writel(0xa5a55a5a, magic_base + 0x4);
707 static void pmic_pin_init(void)
709 unsigned int reg, value;
711 if (cpu_is_s5pc100())
714 /* AP_PS_HOLD: XEINT_0: GPH0[0]
715 * Note: Don't use GPIO PS_HOLD it doesn't work
717 reg = S5PC110_PS_HOLD_CONTROL;
719 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
720 S5PC110_PS_HOLD_DATA_HIGH |
721 S5PC110_PS_HOLD_OUT_EN;
724 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
725 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
726 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
729 static void enable_ldos(void)
731 if (cpu_is_s5pc100())
734 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
735 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
738 static void enable_t_flash(void)
740 if (!(board_is_limo_universal() || board_is_limo_real()))
743 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
744 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
747 static void setup_limo_real_gpios(void)
749 if (!board_is_limo_real())
753 * Note: Please write GPIO alphabet order
755 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
756 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
759 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
760 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
762 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
763 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
765 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
766 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
767 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
770 static void setup_media_gpios(void)
772 if (!board_is_media())
776 * Note: Please write GPIO alphabet order
778 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
779 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
781 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
782 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
783 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
786 #define KBR3 (1 << 3)
787 #define KBR2 (1 << 2)
788 #define KBR1 (1 << 1)
789 #define KBR0 (1 << 0)
791 static void check_keypad(void)
793 unsigned int reg, value;
794 unsigned int col_num, row_num;
795 unsigned int col_mask;
796 unsigned int col_mask_shift;
797 unsigned int row_state[4];
799 unsigned int auto_download = 0;
801 if (machine_is_wmg160())
804 if (cpu_is_s5pc100()) {
805 struct s5pc100_gpio *gpio =
806 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
811 /* Set GPH2[2:0] to KP_COL[2:0] */
812 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
813 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
814 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
816 /* Set GPH3[2:0] to KP_ROW[2:0] */
817 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
818 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
819 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
821 reg = S5PC100_KEYPAD_BASE;
822 col_mask = S5PC1XX_KEYIFCOL_MASK;
825 if (board_is_limo_real() || board_is_limo_universal()) {
833 for (i = 0; i < row_num; i++) {
834 /* Set GPH3[3:0] to KP_ROW[3:0] */
835 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
836 gpio_set_pull(&s5pc110_gpio->gpio_h3, i, GPIO_PULL_UP);
839 for (i = 0; i < col_num; i++)
840 /* Set GPH2[3:0] to KP_COL[3:0] */
841 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
843 reg = S5PC110_KEYPAD_BASE;
844 col_mask = S5PC110_KEYIFCOLEN_MASK;
848 /* KEYIFCOL reg clear */
849 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
852 for (i = 0; i < col_num; i++) {
854 value &= ~(1 << i) << col_mask_shift;
856 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
859 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
860 row_state[i] = ~value & ((1 << row_num) - 1);
862 printf("[%d col] row_state: 0x%x\n", i, row_state[i]);
865 /* KEYIFCOL reg clear */
866 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
868 if (machine_is_aquila() || machine_is_kessler()) {
869 /* cam full shot & volume down */
870 if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
873 else if ((row_state[1] & 0x2))
875 } else if (machine_is_geminus())
876 /* volume down & home */
877 if ((row_state[1] & 0x2) && (row_state[2] & 0x1))
881 setenv("bootcmd", "usbdown");
884 static void enable_battery(void)
886 unsigned char val[2];
887 unsigned char addr = 0x36; /* max17040 fuel gauge */
889 i2c_set_bus_num(I2C_GPIO3);
891 if (machine_is_aquila()) {
894 } else if (machine_is_kessler())
895 i2c_set_bus_num(I2C_GPIO7);
896 else if (machine_is_tickertape()) {
898 } else if (machine_is_cypress()) {
899 i2c_set_bus_num(I2C_GPIO7);
900 } else if (machine_is_geminus()) {
902 i2c_set_bus_num(I2C_GPIO7);
905 if (i2c_probe(addr)) {
906 printf("Can't found max17040 fuel gauge\n");
912 i2c_write(addr, 0xfe, 1, val, 2);
915 static void check_battery(void)
917 unsigned char val[2];
918 unsigned char addr = 0x36; /* max17040 fuel gauge */
920 i2c_set_bus_num(I2C_GPIO3);
922 if (machine_is_aquila()) {
925 } else if (machine_is_kessler())
926 i2c_set_bus_num(I2C_GPIO7);
927 else if (machine_is_cypress()) {
928 i2c_set_bus_num(I2C_GPIO7);
929 } else if (machine_is_geminus()) {
931 i2c_set_bus_num(I2C_GPIO7);
935 if (i2c_probe(addr)) {
936 printf("Can't found max17040 fuel gauge\n");
940 i2c_read(addr, 0x04, 1, val, 1);
942 dprintf("battery:\t%d%%\n", val[0]);
944 battery_soc = val[0];
947 static void check_mhl(void)
949 unsigned char val[2];
950 unsigned char addr = 0x39; /* SIL9230 */
952 /* MHL Power enable */
953 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
954 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
956 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
957 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
959 /* 10ms required after reset */
963 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
965 i2c_set_bus_num(I2C_GPIO5);
968 if (i2c_probe(addr)) {
969 printf("Can't found MHL Chip\n");
975 * set to Normal operation
978 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
979 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
984 * 00 = MHL termination ON
985 * 11 = MHL termination OFF
988 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
989 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
992 #define CHARGER_ANIMATION_FRAME 6
993 static int max8998_power_key(void)
995 unsigned char addr, val[2];
996 i2c_set_bus_num(I2C_PMIC);
998 if (i2c_probe(addr)) {
999 printf("Can't found max8998\n");
1003 /* Accessing IRQ1 register */
1004 i2c_read(addr, 0x00, 1, val, 1);
1005 if (val[0] & (1 << 6))
1011 static int max8998_has_ext_power_source(void)
1013 unsigned char addr, val[2];
1014 i2c_set_bus_num(I2C_PMIC);
1016 if (i2c_probe(addr)) {
1017 printf("Can't found max8998\n");
1021 /* Accessing STATUS2 register */
1022 i2c_read(addr, 0x09, 1, val, 1);
1023 if (val[0] & (1 << 5))
1029 extern void lcd_display_clear(void);
1030 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
1032 static void into_charge_mode(void)
1034 unsigned char addr = 0xCC >> 1; /* max8998 */;
1035 unsigned char val[2];
1040 ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1042 i2c_set_bus_num(I2C_PMIC);
1044 if (i2c_probe(addr)) {
1045 printf("Can't found max8998\n");
1049 printf("Charge Mode\n");
1051 i2c_read(addr, 0x0C, 1, val, 1);
1052 val[0] &= ~(0x7 << 0);
1053 val[0] &= ~(0x7 << 5);
1054 val[0] |= 5; /* 600mA */
1055 val[0] |= (3 << 5); /* Stop at 150mA(25%) */
1056 i2c_write(addr, 0x0C, 1, val, 1);
1058 #ifdef CONFIG_S5PC1XXFB
1061 /* TODO: write the image-text for the charger */
1063 level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1064 if (level >= CHARGER_ANIMATION_FRAME)
1065 level = CHARGER_ANIMATION_FRAME - 1;
1067 for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1068 bmp_addr[i] = (ulong)battery_charging_animation[i];
1070 lcd_display_clear();
1071 for (i = 0; i < 3; i++) {
1072 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1075 bmp = gunzip_bmp(bmp_addr[j], &len);
1076 lcd_display_bitmap((ulong) bmp, 140, 202);
1079 for (k = 0; k < 10; k++)
1080 if (max8998_power_key()) {
1081 lcd_display_clear();
1083 } else if (!max8998_has_ext_power_source()) {
1084 lcd_display_clear();
1093 /* EVT0: sleep 1, EVT1: sleep */
1094 if (s5pc1xx_get_cpu_rev() == 0) {
1095 run_command("sleep 1", 0);
1099 run_command("sleep", 0);
1102 static void check_micro_usb(int intr)
1105 unsigned char val[2];
1106 static int started_charging_once = 0;
1109 if (cpu_is_s5pc100())
1112 if (board_is_limo_real()) {
1113 if (hwrevision(0) || hwrevision(1))
1117 i2c_set_bus_num(I2C_PMIC);
1119 if (machine_is_kessler())
1120 i2c_set_bus_num(I2C_GPIO6);
1121 else if (machine_is_cypress()) {
1122 i2c_set_bus_num(I2C_GPIO6);
1123 } else if (machine_is_geminus()) {
1125 i2c_set_bus_num(I2C_GPIO6);
1126 } else if (machine_is_wmg160())
1127 i2c_set_bus_num(I2C_GPIO6);
1129 addr = 0x25; /* fsa9480 */
1130 if (i2c_probe(addr)) {
1131 printf("Can't found fsa9480\n");
1135 /* Clear Interrupt */
1137 i2c_read(addr, 0x03, 1, val, 2);
1141 /* Read Device Type 1 */
1142 i2c_read(addr, 0x0a, 1, val, 1);
1144 #define FSA_DEV1_CHARGER (1 << 6)
1145 #define FSA_DEV1_UART (1 << 3)
1146 #define FSA_DEV1_USB (1 << 2)
1147 #define FSA_DEV2_JIG_USB_OFF (1 << 1)
1148 #define FSA_DEV2_JIG_USB_ON (1 << 0)
1151 * If USB, use default 475mA
1152 * If Charger, use 600mA and go to charge mode
1154 if ((val[0] & FSA_DEV1_CHARGER) && !started_charging_once) {
1155 started_charging_once = 1;
1159 /* If Factory Mode is Boot ON-USB, go to download mode */
1160 i2c_read(addr, 0x07, 1, val, 1);
1162 #define FSA_ADC_FAC_USB_OFF 0x18
1163 #define FSA_ADC_FAC_USB_ON 0x19
1164 #define FSA_ADC_FAC_UART 0x1d
1166 if (val[0] == FSA_ADC_FAC_USB_ON || val[0] == FSA_ADC_FAC_USB_OFF)
1167 setenv("bootcmd", "usbdown");
1169 path = getenv("usb");
1171 if (!strncmp(path, "cp", 2))
1172 run_command("microusb cp", 0);
1175 static void micro_usb_switch(int path)
1178 unsigned char val[2];
1180 i2c_set_bus_num(I2C_PMIC);
1182 if (machine_is_kessler())
1183 i2c_set_bus_num(I2C_GPIO6);
1184 else if (machine_is_cypress()) {
1185 i2c_set_bus_num(I2C_GPIO6);
1186 } else if (machine_is_geminus()) {
1188 i2c_set_bus_num(I2C_GPIO6);
1189 } else if (machine_is_wmg160()) {
1190 i2c_set_bus_num(I2C_GPIO6);
1194 addr = 0x25; /* fsa9480 */
1195 if (i2c_probe(addr)) {
1196 printf("Can't found fsa9480\n");
1201 val[0] = 0x90; /* VAUDIO */
1203 val[0] = (1 << 5) | (1 << 2); /* DHOST */
1205 i2c_write(addr, 0x13, 1, val, 1); /* MANSW1 */
1207 i2c_read(addr, 0x2, 1, val, 1);
1208 val[0] &= ~(1 << 2); /* Manual switching */
1209 i2c_write(addr, 0x2, 1, val, 1);
1212 #define MAX8998_REG_ONOFF1 0x11
1213 #define MAX8998_REG_ONOFF2 0x12
1214 #define MAX8998_REG_ONOFF3 0x13
1215 #define MAX8998_REG_LDO7 0x21
1216 #define MAX8998_REG_LDO17 0x29
1218 #define MAX8998_LDO3 (1 << 2)
1220 #define MAX8998_LDO6 (1 << 7)
1221 #define MAX8998_LDO7 (1 << 6)
1222 #define MAX8998_LDO8 (1 << 5)
1223 #define MAX8998_LDO9 (1 << 4)
1224 #define MAX8998_LDO10 (1 << 3)
1225 #define MAX8998_LDO11 (1 << 2)
1226 #define MAX8998_LDO12 (1 << 1)
1227 #define MAX8998_LDO13 (1 << 0)
1229 #define MAX8998_LDO14 (1 << 7)
1230 #define MAX8998_LDO15 (1 << 6)
1231 #define MAX8998_LDO16 (1 << 5)
1232 #define MAX8998_LDO17 (1 << 4)
1235 static void init_pmic(void)
1238 unsigned char val[2];
1240 if (cpu_is_s5pc100())
1243 i2c_set_bus_num(I2C_PMIC);
1245 addr = 0xCC >> 1; /* max8998 */
1246 if (i2c_probe(addr)) {
1247 if (i2c_probe(addr)) {
1248 printf("Can't found max8998\n");
1254 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1255 val[0] &= ~MAX8998_LDO3;
1256 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1259 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1261 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1262 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1264 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1265 MAX8998_LDO12 | MAX8998_LDO13);
1267 if (machine_is_kessler())
1268 val[0] |= MAX8998_LDO7; /* LDO7: VLCD_1.8V */
1270 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1271 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1273 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1275 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1276 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1278 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1279 MAX8998_LDO16 | MAX8998_LDO17);
1281 if (machine_is_kessler())
1282 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1284 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1285 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1288 static void setup_power_down_mode_registers(void)
1290 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1291 struct s5pc1xx_gpio_bank *bank;
1292 struct gpio_powermode *p;
1294 struct gpio_external *ge;
1296 struct s5pc1xx_gpio_item *mr;
1300 if (cpu_is_s5pc100())
1303 /* Only Limo real and kessler supports worked for sleep currnet */
1304 if (machine_is_aquila()) {
1305 if (board_is_limo_real())
1309 } else if (machine_is_kessler()) {
1311 } else if (machine_is_geminus()) {
1316 if (machine_is_aquila()) {
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);
1324 } else if (machine_is_kessler()) {
1325 /* Aquila rev 0.9 */
1326 p = kessler_powerdown_modes;
1327 ge = kessler_external_powerdown_modes;
1328 mr = kessler_mirror_powerdown_mode;
1329 n_p = ARRAY_SIZE(kessler_powerdown_modes);
1330 n_ge = ARRAY_SIZE(kessler_external_powerdown_modes);
1331 n_mr = ARRAY_SIZE(kessler_mirror_powerdown_mode);
1332 } else if (machine_is_geminus()) {
1333 if (hwrevision(1)) {
1334 /* Same as Aquila rev 0.9 */
1336 p = kessler_powerdown_modes;
1337 ge = kessler_external_powerdown_modes;
1338 mr = kessler_mirror_powerdown_mode;
1339 n_p = ARRAY_SIZE(kessler_powerdown_modes);
1340 n_ge = ARRAY_SIZE(kessler_external_powerdown_modes);
1341 n_mr = ARRAY_SIZE(kessler_mirror_powerdown_mode);
1343 p = aquila_powerdown_modes;
1344 ge = aquila_external_powerdown_modes;
1345 mr = aquila_mirror_powerdown_mode;
1346 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1347 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1348 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1350 } else if (hwrevision(0)) {
1351 /* Same as Aquila rev 0.8 or lower */
1352 p = aquila_powerdown_modes;
1353 ge = aquila_external_powerdown_modes;
1354 mr = aquila_mirror_powerdown_mode;
1355 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1356 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1357 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1359 return; /* Not supported */
1363 bank = &gpio->gpio_a0;
1365 for (i = 0; i < n_p; i++, p++, bank++) {
1366 writel(p->conpdn, &bank->pdn_con);
1367 writel(p->pudpdn, &bank->pdn_pull);
1370 writel(0xff0022b0, (unsigned int *)0xF0000000);
1371 writel(0xff0022b0, (unsigned int *)0xF1400000);
1373 bank = &gpio->gpio_h0;
1375 for (i = 0; i < n_ge; i++) {
1376 writel(ge->con, &bank->con);
1377 writel(ge->dat, &bank->dat);
1378 writel(ge->pud, &bank->pull);
1384 for (i = 0; i < n_mr; i++) {
1385 unsigned int reg = readl(&mr->bank->pdn_con);
1386 reg &= ~(1 << mr->number);
1387 if (readl(&mr->bank->dat) & (1 << mr->number))
1388 reg |= 1 << mr->number;
1389 writel(reg, &mr->bank->pdn_con);
1391 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1398 #include "../../../drivers/video/s5p-spi.h"
1400 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1401 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1403 struct spi_platform_data spi_pd;
1405 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1407 void lcd_cfg_gpio(void)
1409 unsigned int i, f3_end = 4;
1411 for (i = 0; i < 8; i++) {
1412 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1413 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1414 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1415 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1416 /* pull-up/down disable */
1417 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1418 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1419 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1421 /* drive strength to max (24bit) */
1422 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1423 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1424 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1425 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1426 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1427 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1430 /* set DISPLAY_DE_B pin for dual rgb mode. */
1431 if (board_is_media())
1434 for (i = 0; i < f3_end; i++) {
1435 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1436 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1437 /* pull-up/down disable */
1438 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1439 /* drive strength to max (24bit) */
1440 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1441 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1443 /* display output path selection (only [1:0] valid) */
1444 writel(0x2, 0xE0107008);
1446 /* gpio pad configuration for LCD reset. */
1447 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1449 /* gpio pad configuration for LCD ON. */
1450 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1452 /* LCD_BACKLIGHT_EN */
1453 if (machine_is_geminus())
1454 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1457 * gpio pad configuration for
1458 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1460 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1461 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1462 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1463 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1465 if (machine_is_aquila() || machine_is_kessler()) {
1466 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1468 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1470 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1472 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1475 if (board_is_neptune())
1476 s6d16a0x_set_platform_data(&spi_pd);
1478 s6e63m0_set_platform_data(&spi_pd);
1479 if (board_is_media())
1484 if (machine_is_cypress()) {
1485 #if 0 /* universal cypress */
1487 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1490 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1492 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1494 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1496 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1498 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1499 #if 0 /* universal cypress */
1500 pd_cs.bank = &gpio_base->gpio_mp0_1;
1503 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1505 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1507 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1512 /* these data would be sent to s6e63m0 lcd panel driver. */
1513 s6e63m0_set_platform_data(&spi_pd);
1519 void backlight_on(unsigned int onoff)
1521 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1524 if (machine_is_geminus())
1525 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1527 if (machine_is_geminus())
1528 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1532 void reset_lcd(void)
1534 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1536 if (machine_is_aquila() || machine_is_kessler() || machine_is_geminus())
1537 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1538 if (machine_is_cypress())
1539 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1542 void lcd_power_on(unsigned int onoff)
1544 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1547 if (machine_is_aquila() || machine_is_geminus())
1548 gpio_set_value(&gpio->gpio_j1, 3, 1);
1550 if (machine_is_cypress())
1551 gpio_set_value(&gpio->gpio_g2, 2, 1);
1553 if (machine_is_kessler()) {
1555 unsigned char val[2];
1556 unsigned char val2[2];
1558 gpio_set_value(&gpio->gpio_j1, 3, 1);
1560 i2c_set_bus_num(I2C_PMIC);
1561 addr = 0xCC >> 1; /* max8998 */
1562 if (i2c_probe(addr)) {
1563 printf("Can't found max8998\n");
1566 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1567 val[0] &= ~(MAX8998_LDO17);
1568 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1569 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1571 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1572 val[0] |= MAX8998_LDO17;
1574 i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1575 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1577 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1578 val[0] |= MAX8998_LDO7;
1580 i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1581 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1584 if (machine_is_aquila() || machine_is_geminus())
1585 gpio_set_value(&gpio->gpio_j1, 3, 0);
1587 if (machine_is_cypress())
1588 gpio_set_value(&gpio->gpio_g2, 2, 0);
1590 if (machine_is_kessler()) {
1592 unsigned char val[2];
1594 i2c_set_bus_num(I2C_PMIC);
1595 addr = 0xCC >> 1; /* max8998 */
1596 if (i2c_probe(addr)) {
1597 printf("Can't found max8998\n");
1601 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1602 val[0] &= ~(1 << 7);
1603 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1604 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1606 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1607 val[0] &= ~MAX8998_LDO17;
1608 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1609 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1614 extern void s6e63m0_cfg_ldo(void);
1615 extern void s6e63m0_enable_ldo(unsigned int onoff);
1616 extern void s6d16a0x_cfg_ldo(void);
1617 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1619 int s5p_no_lcd_support(void)
1621 if (machine_is_wmg160())
1626 void init_panel_info(vidinfo_t *vid)
1628 vid->cfg_gpio = NULL;
1629 vid->reset_lcd = NULL;
1630 vid->backlight_on = NULL;
1631 vid->lcd_power_on = NULL;
1633 vid->cfg_ldo = NULL;
1634 vid->enable_ldo = NULL;
1636 vid->init_delay = 0;
1637 vid->reset_delay = 0;
1638 vid->power_on_delay = 0;
1643 vid->vl_width = 480;
1644 vid->vl_height = 800;
1646 vid->dual_lcd_enabled = 0;
1648 if (board_is_media()) {
1651 vid->vl_width = 960;
1652 vid->vl_height = 800;
1654 /* enable dual lcd mode. */
1655 vid->dual_lcd_enabled = 1;
1658 vid->vl_clkp = CONFIG_SYS_HIGH;
1659 vid->vl_hsp = CONFIG_SYS_LOW;
1660 vid->vl_vsp = CONFIG_SYS_LOW;
1661 vid->vl_dp = CONFIG_SYS_HIGH;
1664 /* S6E63M0 LCD Panel */
1673 if (machine_is_aquila() || machine_is_kessler() || machine_is_cypress()) {
1674 vid->cfg_gpio = lcd_cfg_gpio;
1675 vid->reset_lcd = reset_lcd;
1676 vid->backlight_on = backlight_on;
1677 vid->lcd_power_on = lcd_power_on;
1678 vid->cfg_ldo = s6e63m0_cfg_ldo;
1679 vid->enable_ldo = s6e63m0_enable_ldo;
1681 vid->init_delay = 25000;
1682 vid->reset_delay = 120000;
1685 if (board_is_neptune()) {
1689 vid->vl_width = 320;
1690 vid->vl_height = 480;
1692 vid->vl_clkp = CONFIG_SYS_HIGH;
1693 vid->vl_hsp = CONFIG_SYS_HIGH;
1694 vid->vl_vsp = CONFIG_SYS_HIGH;
1695 vid->vl_dp = CONFIG_SYS_LOW;
1698 /* disable dual lcd mode. */
1699 vid->dual_lcd_enabled = 0;
1701 /* S6D16A0X LCD Panel */
1710 vid->cfg_gpio = lcd_cfg_gpio;
1711 vid->backlight_on = NULL;
1712 vid->lcd_power_on = lcd_power_on;
1713 vid->reset_lcd = reset_lcd;
1714 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1715 vid->enable_ldo = s6d16a0x_enable_ldo;
1717 vid->init_delay = 10000;
1718 vid->power_on_delay = 10000;
1719 vid->reset_delay = 1000;
1723 if (machine_is_geminus()) {
1727 vid->vl_width = 1024,
1728 vid->vl_height = 600,
1729 vid->vl_clkp = CONFIG_SYS_LOW,
1730 vid->vl_hsp = CONFIG_SYS_HIGH,
1731 vid->vl_vsp = CONFIG_SYS_HIGH,
1732 vid->vl_dp = CONFIG_SYS_LOW,
1743 vid->cfg_gpio = lcd_cfg_gpio;
1744 vid->reset_lcd = reset_lcd;
1745 vid->backlight_on = backlight_on;
1746 vid->lcd_power_on = lcd_power_on;
1752 vid->vl_width = 480,
1753 vid->vl_height = 800,
1754 vid->vl_clkp = CONFIG_SYS_HIGH,
1755 vid->vl_hsp = CONFIG_SYS_LOW,
1756 vid->vl_vsp = CONFIG_SYS_LOW,
1757 vid->vl_dp = CONFIG_SYS_HIGH,
1773 vid->vl_width = 1024,
1774 vid->vl_height = 600,
1775 vid->vl_clkp = CONFIG_SYS_HIGH,
1776 vid->vl_hsp = CONFIG_SYS_HIGH,
1777 vid->vl_vsp = CONFIG_SYS_HIGH,
1778 vid->vl_dp = CONFIG_SYS_LOW,
1781 /* AMS701KA AMOLED Panel. */
1793 static void setup_meminfo(void)
1795 char meminfo[64] = {0, };
1796 int count = 0, size, real;
1798 size = gd->bd->bi_dram[0].size >> 20;
1799 count += sprintf(meminfo + count, "mem=%dM", size);
1801 /* Each Chip Select can't exceed the 256MiB */
1802 size = gd->bd->bi_dram[1].size >> 20;
1803 real = min(size, 256);
1804 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1805 real, (unsigned int)gd->bd->bi_dram[1].start);
1809 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1810 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1813 setenv("meminfo", meminfo);
1816 int misc_init_r(void)
1819 /* It should be located at first */
1822 if (machine_is_aquila() || machine_is_kessler()) {
1823 if (board_is_neptune())
1824 setenv("lcdinfo", "lcd=s6d16a0x");
1825 else if (board_is_media())
1826 setenv("lcdinfo", "lcd=s6e63m0");
1828 setenv("lcdinfo", "lcd=s6e63m0");
1830 if (machine_is_geminus())
1831 setenv("lcdinfo", "lcd=lms480jc01");
1832 if (machine_is_cypress())
1833 setenv("lcdinfo", "lcd=s6e63m0");
1839 /* Set proper PMIC pins */
1842 /* Check auto burning */
1845 /* To power up I2C2 */
1848 /* Enable T-Flash at Limo Real or Limo Universal */
1851 /* Setup Limo Real board GPIOs */
1852 setup_limo_real_gpios();
1854 /* Setup Media board GPIOs */
1855 setup_media_gpios();
1857 /* To usbdown automatically */
1863 #ifdef CONFIG_S5PC1XXFB
1864 display_device_info();
1867 setup_power_down_mode_registers();
1869 /* check max17040 */
1879 int board_init(void)
1881 /* Set Initial global variables */
1882 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1884 gd->bd->bi_arch_number = MACH_AQUILA;
1885 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1887 /* Check H/W Revision */
1888 check_hw_revision();
1895 unsigned int base, memconfig0, size;
1896 unsigned int memconfig1, sz = 0;
1898 if (cpu_is_s5pc100()) {
1899 /* In mem setup, we swap the bank. So below size is correct */
1900 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1901 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1902 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1905 /* In S5PC110, we can't swap the DMC0/1 */
1906 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1907 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1909 base = S5PC110_DMC1_BASE;
1910 /* DMC configuration */
1911 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1912 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1914 size = (memconfig0 >> 16) & 0xFF;
1915 size = ((unsigned char) ~size) + 1;
1918 * (0x07 + 1) * 16 = 128 MiB
1919 * (0x0f + 1) * 16 = 256 MiB
1924 * Aquila Rev0.5 4G3G1G
1925 * Aquila Rev0.8 4G3G1G
1926 * Aquila Rev0.9 4G3G1G
1928 if (machine_is_aquila() || machine_is_kessler())
1929 if (hwrevision(5) || hwrevision(8) || hwrevision(9)) {
1930 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1932 sz = (memconfig1 >> 16) & 0xFF;
1933 sz = ((unsigned char) ~sz) + 1;
1939 * bi_dram[1].size contains all DMC1 memory size
1941 gd->bd->bi_dram[1].size = (size + sz) << 20;
1946 /* Used for sleep test */
1947 static unsigned char saved_val[4][2];
1948 void board_sleep_init_late(void)
1950 /* CODEC_LDO_EN: GPF3[4] */
1951 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1952 /* CODEC_XTAL_EN: GPH3[2] */
1953 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1955 /* MMC T_FLASH off */
1956 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1958 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1959 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1960 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1964 void board_sleep_init(void)
1967 unsigned char val[2];
1969 i2c_set_bus_num(I2C_PMIC);
1971 if (i2c_probe(addr)) {
1972 printf("Can't find max8998\n");
1977 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1978 saved_val[0][0] = val[0];
1979 saved_val[0][1] = val[1];
1980 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1981 (1 << 1) | (1 << 0));
1982 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1983 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1985 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1986 saved_val[1][0] = val[0];
1987 saved_val[1][1] = val[1];
1988 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1989 (1 << 2) | (1 << 1) | (1 << 0));
1991 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1992 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1994 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1995 saved_val[2][0] = val[0];
1996 saved_val[2][1] = val[1];
1997 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
1998 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1999 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2001 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2002 saved_val[3][0] = val[0];
2003 saved_val[3][1] = val[1];
2004 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2005 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2006 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2007 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2008 __FILE__, __LINE__);
2011 void board_sleep_resume(void)
2014 unsigned char val[2];
2018 i2c_set_bus_num(I2C_PMIC);
2020 if (i2c_probe(addr)) {
2021 printf("Can't find max8998\n");
2026 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2027 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2029 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2030 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2032 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2033 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2035 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2036 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2037 printf("Waked up.\n");
2039 /* check max17040 */
2046 #ifdef CONFIG_CMD_USBDOWN
2047 int usb_board_init(void)
2049 #ifdef CONFIG_CMD_PMIC
2050 run_command("pmic ldo 3 on", 0);
2053 if (cpu_is_s5pc100()) {
2054 #ifdef CONFIG_HARD_I2C
2055 uchar val[2] = {0,};
2058 if (i2c_read(0x66, 0, 1, val, 2)) {
2059 printf("i2c_read error\n");
2066 if (i2c_write(0x66, 0, 1, val, 2)) {
2067 printf("i2c_write error\n");
2070 i2c_read(0x66, 0, 1, val, 2);
2076 if (board_is_limo_universal() ||
2077 board_is_limo_real() ||
2079 /* check usb path */
2080 if (board_is_limo_real() && !hwrevision(6))
2084 if (machine_is_tickertape())
2085 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2086 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2088 /* USB Path to AP */
2089 micro_usb_switch(0);
2095 #ifdef CONFIG_GENERIC_MMC
2096 int s5p_no_mmc_support(void)
2098 if (machine_is_wmg160())
2103 int board_mmc_init(bd_t *bis)
2107 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2110 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2111 if (machine_is_kessler())
2112 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2114 if (machine_is_wmg160())
2117 /* MMC0 Clock source = SCLKMPLL */
2118 reg = readl(&clk->src4);
2121 writel(reg, &clk->src4);
2123 reg = readl(&clk->div4);
2126 /* set div value near 50MHz */
2127 clock = get_pll_clk(MPLL) / 1000000;
2128 for (i = 0; i < 0xf; i++) {
2129 if ((clock / (i + 1)) <= 50) {
2135 writel(reg, &clk->div4);
2141 * GPG0[2] SD_0_CDn -> Not used
2142 * GPG0[3:6] SD_0_DATA[0:3]
2144 for (i = 0; i < 7; i++) {
2147 /* GPG0[0:6] special function 2 */
2148 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2149 /* GPG0[0:6] pull disable */
2150 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2151 /* GPG0[0:6] drv 4x */
2152 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4x);
2155 return s5pc1xx_mmc_init(0);
2159 #ifdef CONFIG_CMD_PMIC
2160 static int pmic_status(void)
2162 unsigned char addr, val[2];
2165 i2c_set_bus_num(I2C_PMIC);
2167 if (i2c_probe(addr)) {
2168 printf("Can't found max8998\n");
2173 i2c_read(addr, reg, 1, val, 1);
2174 for (i = 7; i >= 4; i--)
2175 printf("BUCK%d %s\n", 7 - i + 1,
2176 val[0] & (1 << i) ? "on" : "off");
2178 printf("LDO%d %s\n", 5 - i,
2179 val[0] & (1 << i) ? "on" : "off");
2181 i2c_read(addr, reg, 1, val, 1);
2182 for (i = 7; i >= 0; i--)
2183 printf("LDO%d %s\n", 7 - i + 6,
2184 val[0] & (1 << i) ? "on" : "off");
2186 i2c_read(addr, reg, 1, val, 1);
2187 for (i = 7; i >= 4; i--)
2188 printf("LDO%d %s\n", 7 - i + 14,
2189 val[0] & (1 << i) ? "on" : "off");
2192 i2c_read(addr, reg, 1, val, 1);
2193 for (i = 7; i >= 6; i--)
2194 printf("SAFEOUT%d %s\n", 7 - i + 1,
2195 val[0] & (1 << i) ? "on" : "off");
2199 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2201 unsigned char addr, val[2];
2202 unsigned int reg, shift;
2210 } else if (ldo <= 13) {
2213 } else if (ldo <= 17) {
2215 shift = 17 - ldo + 4;
2222 shift = 4 - buck + 4;
2223 } else if (safeout) {
2227 shift = 8 - safeout;
2231 i2c_set_bus_num(I2C_PMIC);
2233 if (i2c_probe(addr)) {
2234 printf("Can't found max8998\n");
2238 i2c_read(addr, reg, 1, val, 1);
2240 val[0] |= (1 << shift);
2242 val[0] &= ~(1 << shift);
2243 i2c_write(addr, reg, 1, val, 1);
2244 i2c_read(addr, reg, 1, val, 1);
2247 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2248 val[0] & (1 << shift) ? "on" : "off");
2250 printf("buck %d value 0x%x, %s\n", buck, val[0],
2251 val[0] & (1 << shift) ? "on" : "off");
2253 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2254 val[0] & (1 << shift) ? "on" : "off");
2259 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2261 int buck = 0, ldo = 0, safeout = 0, on = -1;
2265 if (strncmp(argv[1], "status", 6) == 0)
2266 return pmic_status();
2269 if (strncmp(argv[1], "ldo", 3) == 0)
2270 ldo = simple_strtoul(argv[2], NULL, 10);
2271 else if (strncmp(argv[1], "buck", 4) == 0)
2272 buck = simple_strtoul(argv[2], NULL, 10);
2273 else if (strncmp(argv[1], "safeout", 7) == 0)
2274 safeout = simple_strtoul(argv[2], NULL, 10);
2278 if (strncmp(argv[3], "on", 2) == 0)
2280 else if (strncmp(argv[3], "off", 3) == 0)
2285 return pmic_ldo_control(buck, ldo, safeout, on);
2296 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2297 "PMIC LDO & BUCK control",
2298 "status - Display PMIC LDO & BUCK status\n"
2299 "pmic ldo num on/off - Turn on/off the LDO\n"
2300 "pmic buck num on/off - Turn on/off the BUCK\n"
2301 "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2305 #ifdef CONFIG_CMD_DEVICE_POWER
2319 static void power_display_devices(void)
2321 printf("devices:\n");
2322 printf("\t%d - touch\n", POWER_TOUCH);
2323 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2324 printf("\t%d - LCD\n", POWER_LCD);
2325 printf("\t%d - Haptic\n", POWER_HAPTIC);
2326 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2327 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2328 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2329 printf("\t%d - HDMI\n", POWER_HDMI);
2332 static int power_hdmi(int on)
2334 /* HDMI_EN1: GPJ2[2] */
2335 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2336 /* MHL_ON: GPJ2[3] */
2337 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2341 static int power_bt_wifi(int on)
2343 /* WLAN_BT_EN: GPB[5] */
2344 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2348 static int power_fm_radio(int on)
2350 /* FM_BUS_nRST: GPJ2[5] */
2351 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2355 static int power_audio_codec(int on)
2357 /* CODEC_LDO_EN: GPF3[4] */
2358 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2359 /* CODEC_XTAL_EN: GPH3[2] */
2360 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2364 static int power_haptic(int on)
2366 /* HAPTIC_ON: GPJ1[1] */
2367 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2371 static int power_lcd(int on)
2373 /* MLCD_ON: GPJ1[3] */
2374 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2378 static int power_touch(int on)
2380 /* TOUCH_EN: GPG3[6] */
2381 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2385 static int power_3_touchkey(int on)
2388 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2389 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2390 if (board_rev & J1_B2_BOARD)
2391 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2393 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2395 /* 3_TOUCH_CE - GPJ2[6] */
2396 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2398 /* 3_TOUCH_CE - GPJ2[6] */
2399 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2404 unsigned char val[2];
2405 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2411 i2c_set_bus_num(I2C_GPIO10);
2413 /* Workaround to probe */
2414 if (i2c_probe(addr)) {
2415 if (i2c_probe(addr)) {
2416 printf("Can't found 3 touchkey\n");
2421 #define MCS5000_TK_HW_VERSION 0x06
2422 #define MCS5000_TK_FW_VERSION 0x0A
2423 #define MCS5000_TK_MI_VERSION 0x0B
2425 reg = MCS5000_TK_MI_VERSION;
2426 i2c_read(addr, reg, 1, val, 1);
2427 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2428 reg = MCS5000_TK_HW_VERSION;
2429 i2c_read(addr, reg, 1, val, 1);
2430 printf("H/W 0x%x, ", val[0]);
2431 reg = MCS5000_TK_FW_VERSION;
2432 i2c_read(addr, reg, 1, val, 1);
2433 printf("F/W 0x%x\n", val[0]);
2438 static int power_control(int device, int on)
2442 return power_touch(on);
2443 case POWER_3_TOUCHKEY:
2444 return power_3_touchkey(on);
2446 return power_lcd(on);
2448 return power_haptic(on);
2449 case POWER_AUDIO_CODEC:
2450 return power_audio_codec(on);
2451 case POWER_FM_RADIO:
2452 return power_fm_radio(on);
2454 return power_bt_wifi(on);
2456 return power_hdmi(on);
2458 printf("I don't know device %d\n", device);
2464 static int power_on(int on)
2467 power_3_touchkey(on);
2470 power_audio_codec(on);
2478 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2482 if (!machine_is_aquila() && !machine_is_kessler())
2487 if (strncmp(argv[1], "on", 2) == 0)
2489 if (strncmp(argv[1], "off", 3) == 0)
2493 device = simple_strtoul(argv[1], NULL, 10);
2497 if (strncmp(argv[2], "on", 2) == 0)
2499 else if (strncmp(argv[2], "off", 3) == 0)
2503 return power_control(device, on);
2509 power_display_devices();
2514 power, CONFIG_SYS_MAXARGS, 1, do_power,
2515 "Device Power Management control",
2516 "device on/off - Turn on/off the device\n"
2519 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2523 if (strncmp(argv[1], "cp", 2) == 0) {
2524 micro_usb_switch(1);
2525 pmic_ldo_control(0, 0, 2, 1);
2526 setenv("usb", "cp");
2527 } else if (strncmp(argv[1], "ap", 2) == 0) {
2528 micro_usb_switch(0);
2529 pmic_ldo_control(0, 0, 2, 0);
2530 setenv("usb", "ap");
2540 printf("USB Path is set to %s\n", getenv("usb"));
2546 microusb, CONFIG_SYS_MAXARGS, 1, do_microusb,
2548 "cp - switch to CP\n"
2549 "microusb ap - switch to AP\n"