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,
28 #include <asm/arch/clk.h>
29 #include <asm/arch/clock.h>
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/keypad.h>
32 #include <asm/arch/mmc.h>
33 #include <asm/arch/power.h>
34 #include <asm/arch/mem.h>
38 DECLARE_GLOBAL_DATA_PTR;
40 #define C100_MACH_START 3000
41 #define C110_MACH_START 3100
43 static unsigned int board_rev;
44 static unsigned int battery_soc;
60 static struct i2c_gpio_bus_data i2c_2 = {
70 static struct i2c_gpio_bus_data i2c_gpio3 = {
80 static struct i2c_gpio_bus_data i2c_pmic = {
90 static struct i2c_gpio_bus_data i2c_gpio5 = {
100 static struct i2c_gpio_bus_data i2c_gpio6 = {
106 * i2c gpio6 - cypress
110 static struct i2c_gpio_bus_data i2c_cypress_gpio6 = {
116 * i2c gpio7 - cypress
120 static struct i2c_gpio_bus_data i2c_cypress_gpio7 = {
125 static struct i2c_gpio_bus i2c_gpio[] = {
141 u32 get_board_rev(void)
146 static int hwrevision(int rev)
148 return (board_rev & 0xf) == rev;
160 #define SPLIT_SCREEN_FEATURE 0x100
162 /* board is MACH_AQUILA and board is like below. */
163 #define J1_B2_BOARD 0x200
164 #define LIMO_UNIVERSAL_BOARD 0x400
165 #define LIMO_REAL_BOARD 0x800
166 #define MEDIA_BOARD 0x1000
167 /* board is MACH_P1P2 and board is like below. */
168 #define P1_REAL_BOARD 0x200
169 #define P2_REAL_BOARD 0x400
171 #define BOARD_MASK 0xF00
173 static int c110_machine_id(void)
175 return gd->bd->bi_arch_number - C110_MACH_START;
178 static int machine_is_aquila(void)
180 return c110_machine_id() == MACH_AQUILA;
183 static int machine_is_p1p2(void)
185 return c110_machine_id() == MACH_P1P2;
188 static int machine_is_tickertape(void)
190 return c110_machine_id() == MACH_TICKERTAPE;
193 static int machine_is_geminus(void)
195 return c110_machine_id() == MACH_GEMINUS;
198 static int machine_is_cypress(void)
200 return c110_machine_id() == MACH_CYPRESS;
203 static int board_is_limo_universal(void)
205 return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
208 static int board_is_limo_real(void)
210 return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
213 static int board_is_media(void)
215 return machine_is_aquila() && (board_rev & MEDIA_BOARD);
218 static int board_is_j1b2(void)
220 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
223 static int board_is_p2_real(void)
225 return machine_is_p1p2() && (board_rev & P2_REAL_BOARD);
228 static void enable_touchkey(void);
229 static void enable_battery(void);
231 void i2c_init_board(void)
233 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
236 if (cpu_is_s5pc100())
239 num_bus = ARRAY_SIZE(i2c_gpio);
241 if (machine_is_cypress()) {
242 i2c_gpio[I2C_GPIO6].bus = &i2c_cypress_gpio6;
243 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
244 i2c_gpio[I2C_GPIO7].bus->gpio_base =
245 (unsigned int)&gpio->gpio_mp0_5;
250 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
251 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
252 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
253 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
254 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
256 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
258 /* XXX Power on Touckey early (it requires 100 msec power up time) */
261 /* Reset on max17040 early */
262 if (battery_soc == 0)
266 #ifdef CONFIG_MISC_INIT_R
267 #define DEV_INFO_LEN 512
268 static char device_info[DEV_INFO_LEN];
269 static int display_info = 0;
271 static void dprintf(const char *fmt, ...)
278 i = vsprintf(buf, fmt, args);
283 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
284 puts("Flushing device info...\n");
288 strcat(device_info, buf);
292 #ifdef CONFIG_S5PC1XXFB
293 static void display_device_info(void)
300 set_font_color(FONT_WHITE);
301 fb_printf(device_info);
304 memset(device_info, 0x0, DEV_INFO_LEN);
306 udelay(5 * 1000 * 1000);
310 static const char *board_name[] = {
325 static char feature_buffer[32];
327 static char *display_features(int board, int board_rev)
330 char *buf = feature_buffer;
332 if (board == MACH_AQUILA) {
333 if (board_rev & SPLIT_SCREEN_FEATURE)
334 count += sprintf(buf + count, " - SplitScreen");
335 if (board_rev & J1_B2_BOARD)
336 count += sprintf(buf + count, " - J1 B2 board");
337 /* Limo Real or Universal */
338 if (board_rev & LIMO_REAL_BOARD)
339 count += sprintf(buf + count, " - Limo Real");
340 else if (board_rev & LIMO_UNIVERSAL_BOARD)
341 count += sprintf(buf + count, " - Limo Universal");
342 if (board_rev & MEDIA_BOARD)
343 count += sprintf(buf + count, " - Media");
344 } else if (board == MACH_P1P2) {
346 if (board_rev & P1_REAL_BOARD)
347 count += sprintf(buf + count, " - P1 Real");
348 else if (board_rev & P2_REAL_BOARD)
349 count += sprintf(buf + count, " - P2 Real");
351 count += sprintf(buf + count, " - Universal");
357 static void check_board_revision(int board, int rev)
361 /* Limo Real or Universal */
362 if (rev & LIMO_UNIVERSAL_BOARD)
363 board_rev &= ~J1_B2_BOARD;
364 if (rev & LIMO_REAL_BOARD) {
365 board_rev &= ~(J1_B2_BOARD |
366 LIMO_UNIVERSAL_BOARD);
368 if (rev & MEDIA_BOARD)
369 board_rev &= ~(J1_B2_BOARD |
370 LIMO_UNIVERSAL_BOARD);
375 /* There's no HWREV_MODE3 */
376 board_rev &= ~(1 << 3);
378 case MACH_TICKERTAPE:
380 board_rev &= ~BOARD_MASK;
387 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank)
391 gpio_direction_input(bank, 1);
392 gpio_direction_input(bank, 2);
393 gpio_direction_input(bank, 3);
394 gpio_direction_input(bank, 4);
396 gpio_set_pull(bank, 1, GPIO_PULL_NONE); /* HWREV_MODE3 */
397 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
398 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
399 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
401 rev = gpio_get_value(bank, 2);
402 rev |= (gpio_get_value(bank, 3) << 1);
403 rev |= (gpio_get_value(bank, 4) << 2);
404 rev |= (gpio_get_value(bank, 1) << 3);
409 static void check_hw_revision(void)
411 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
413 if (cpu_is_s5pc100()) {
414 struct s5pc100_gpio *gpio =
415 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
417 board_rev = get_hw_revision(&gpio->gpio_j0);
419 /* C100 TickerTape */
421 board = MACH_TICKERTAPE;
423 struct s5pc110_gpio *gpio =
424 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
426 board_rev = get_hw_revision(&gpio->gpio_j0);
429 * Note Check 'Aquila' board first
433 * LRA: Limo Real Aquila
434 * LUA: Limo Universal Aquila
439 * ADDR = 0xE0200000 + OFF
441 * OFF Universal LRA LUA OA TT SS P1P2 CYP
442 * J1: 0x0264 0x10 0x00 0x00 0x00 0x00 0x00 0x00
443 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x18 0x0F
444 * H3: 0x0C64 0x03 0x07 0x0F 0xff
445 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
446 * I: 0x0224 0x02 0x00 0x08
447 * MP03: 0x0324 0x9x 0xbx 0x9x
448 * MP05: 0x0364 0x80 0x88
452 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
454 board_rev |= J1_B2_BOARD;
456 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
457 gpio_direction_input(&gpio->gpio_j2, 6);
460 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
461 board_rev |= LIMO_UNIVERSAL_BOARD;
463 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
464 board_rev |= LIMO_REAL_BOARD;
466 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
467 board_rev |= MEDIA_BOARD;
469 /* set gpio to default value. */
470 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
471 gpio_direction_output(&gpio->gpio_j2, 6, 0);
473 /* C110 Aquila SplitScreen */
474 if (gpio_get_value(&gpio->gpio_mp0_3, 5))
475 board_rev |= SPLIT_SCREEN_FEATURE;
477 if (gpio_get_value(&gpio->gpio_i, 3))
478 board_rev |= SPLIT_SCREEN_FEATURE;
482 /* Workaround: C110 Aquila Rev0.6 */
483 if (board_rev == 6) {
485 board_rev |= LIMO_REAL_BOARD;
488 /* C110 TickerTape */
489 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
490 gpio_get_value(&gpio->gpio_d1, 1) == 0)
491 board = MACH_TICKERTAPE;
493 /* C110 Cypress: Do first this than P1P2 */
494 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
495 gpio_direction_input(&gpio->gpio_j2, 2);
496 if (gpio_get_value(&gpio->gpio_j2, 2) == 1)
497 board = MACH_CYPRESS;
498 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
501 if (gpio_get_value(&gpio->gpio_h3, 7) == 1) {
503 board_rev &= ~BOARD_MASK;
506 /* set gpio configuration for P1P2. */
507 gpio_direction_input(&gpio->gpio_j0, 6);
508 gpio_direction_input(&gpio->gpio_j0, 7);
510 /* do not change order below because it needs delay to get gpio value. */
511 gpio_set_pull(&gpio->gpio_j0, 7, GPIO_PULL_NONE); /* HWREV_MODE5 */
512 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE); /* HWREV_MODE4 */
514 if (gpio_get_value(&gpio->gpio_j0, 7) == 1) {
516 board_rev &= ~BOARD_MASK;
517 if (gpio_get_value(&gpio->gpio_j0, 6) == 1)
518 board_rev |= P1_REAL_BOARD;
519 if (gpio_get_value(&gpio->gpio_j0, 6) == 0)
520 board_rev |= P2_REAL_BOARD;
523 /* set gpio to default value. */
524 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN); /* HWREV_MODE4 */
525 gpio_set_pull(&gpio->gpio_j0, 7, GPIO_PULL_DOWN); /* HWREV_MODE5 */
528 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
529 gpio_direction_input(&gpio->gpio_j1, 2);
530 if (gpio_get_value(&gpio->gpio_j1, 2) == 1)
531 board = MACH_GEMINUS;
532 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
533 gpio_direction_output(&gpio->gpio_j1, 2, 0);
537 if (cpu_is_s5pc110())
538 gd->bd->bi_arch_number = C110_MACH_START + board;
540 gd->bd->bi_arch_number = C100_MACH_START + board;
542 /* Architecture Common settings */
543 if (cpu_is_s5pc110()) {
544 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
546 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; bootm 0x30007FC0");
547 setenv("updatek", "onenand erase 0x60000 0x300000; onenand write 0x31008000 0x60000 0x300000");
551 static void show_hw_revision(void)
556 * Workaround for Rev 0.3 + CP Ver ES 3.1
559 if (board_is_limo_real()) {
561 /* default is Rev 0.4 */
567 if (cpu_is_s5pc110())
568 board = gd->bd->bi_arch_number - C110_MACH_START;
570 board = gd->bd->bi_arch_number - C100_MACH_START;
572 check_board_revision(board, board_rev);
573 dprintf("HW Revision:\t%x (%s%s)\n", board_rev, board_name[board],
574 display_features(board, board_rev));
577 static void check_auto_burn(void)
579 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
580 unsigned int count = 0;
583 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
584 printf("Auto burning bootloader\n");
585 count += sprintf(buf + count, "run updateb; ");
587 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
588 printf("Auto burning kernel\n");
589 count += sprintf(buf + count, "run updatek; ");
593 count += sprintf(buf + count, "reset");
594 setenv("bootcmd", buf);
597 /* Clear the magic value */
598 writel(0xa5a55a5a, magic_base);
599 writel(0xa5a55a5a, magic_base + 0x4);
602 static void pmic_pin_init(void)
604 unsigned int reg, value;
605 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
607 if (cpu_is_s5pc100())
610 /* AP_PS_HOLD: XEINT_0: GPH0[0]
611 * Note: Don't use GPIO PS_HOLD it doesn't work
613 reg = S5PC110_PS_HOLD_CONTROL;
615 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
616 S5PC110_PS_HOLD_DATA_HIGH |
617 S5PC110_PS_HOLD_OUT_EN;
620 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
621 gpio_cfg_pin(&gpio->gpio_h2, 6, GPIO_IRQ);
622 gpio_set_pull(&gpio->gpio_h2, 6, GPIO_PULL_UP);
625 static void enable_ldos(void)
627 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
629 if (cpu_is_s5pc100())
632 if (machine_is_p1p2())
635 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
636 gpio_direction_output(&gpio->gpio_g3, 6, 1);
639 static void enable_t_flash(void)
641 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
643 if (!(board_is_limo_universal() || board_is_limo_real()))
646 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
647 gpio_direction_output(&gpio->gpio_mp0_5, 4, 1);
650 static void setup_limo_real_gpios(void)
652 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
654 if (!board_is_limo_real())
658 * Note: Please write GPIO alphabet order
660 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
661 gpio_direction_output(&gpio->gpio_f3, 4, 1);
664 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
665 gpio_direction_output(&gpio->gpio_mp0_2, 1, 1);
667 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
668 gpio_direction_output(&gpio->gpio_mp0_1, 2, 1);
670 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
671 gpio_cfg_pin(&gpio->gpio_h3, 4, GPIO_IRQ);
672 gpio_set_pull(&gpio->gpio_h3, 4, GPIO_PULL_UP);
675 static void setup_media_gpios(void)
677 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
679 if (!board_is_media())
683 * Note: Please write GPIO alphabet order
685 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
686 gpio_direction_output(&gpio->gpio_mp0_1, 2, 1);
688 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
689 gpio_cfg_pin(&gpio->gpio_h3, 4, GPIO_IRQ);
690 gpio_set_pull(&gpio->gpio_h3, 4, GPIO_PULL_UP);
693 static void setup_p1p2_gpios(void)
695 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
697 if (!machine_is_p1p2())
701 * Note: Please write GPIO alphabet order
703 /* RESET_REQ_N: XM0FRnB[1]: MP0_3[5] output high */
704 gpio_direction_output(&gpio->gpio_mp0_3, 5, 1);
705 /* CODEC_LDO_EN: XM0FRnB[2]: MP0_3[6] output high */
706 gpio_direction_output(&gpio->gpio_mp0_3, 6, 1);
709 #define KBR3 (1 << 3)
710 #define KBR2 (1 << 2)
711 #define KBR1 (1 << 1)
712 #define KBR0 (1 << 0)
714 static void enable_touchkey(void)
716 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
718 /* TOUCH_EN - GPIO_J3(0) : (J1B2) */
719 /* TOUCH_EN - GPIO_J3(5) : (not J1B2) */
720 if (board_rev & J1_B2_BOARD)
721 gpio_direction_output(&gpio->gpio_j3, 0, 1);
723 gpio_direction_output(&gpio->gpio_j3, 5, 1);
725 /* TOUCH_CE - GPIO_J2(6) */
726 gpio_direction_output(&gpio->gpio_j2, 6, 1); /* TOUCH_CE */
729 static void check_p2_keypad(void)
731 unsigned int auto_download = 0;
732 unsigned char addr = 0x34, val[2]; /* adp5587 key controller */
734 i2c_set_bus_num(I2C_2);
736 if (i2c_probe(addr)) {
737 printf("Can't found adp5587 key controller\n");
740 /* Row 8, Column 10 */
742 ret = i2c_write(addr, 0x1D, 1, val, 1); /* Set KP_GPIO1 */
744 ret |= i2c_write(addr, 0x1E, 1, val, 1); /* Set KP_GPIO2 */
746 ret |= i2c_write(addr, 0x1F, 1, val, 1); /* Set KP_GPIO3 */
747 val[0] = 0x3f; /*CMP2_INT | CMP1_INT | OVR_FLOW_INT | K_LCK_INT | GPI_INT | KE_INT */
748 ret |= i2c_write(addr, 0x02, 1, val, 1); /* Status is W1C */
749 val[0] = 0x19; /* INT_CFG | OVR_FLOW_IEN | KE_IEN */
750 ret |= i2c_write(addr, 0x01, 1, val, 1);
751 for (i = 0; i < 10; i++) {
752 udelay(1000); /* FIXME */
753 i2c_read(addr, 0x04 + i, 1, val, 1);
758 if (auto_download == 1)
759 setenv("bootcmd", "usbdown");
762 static void check_keypad(void)
764 unsigned int reg, value;
765 unsigned int col_mask, row_mask;
766 unsigned int auto_download = 0;
767 unsigned int col_value[4], i;
768 unsigned char val[2];
769 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
770 if (cpu_is_s5pc100()) {
771 struct s5pc100_gpio *gpio =
772 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
774 /* Set GPH2[2:0] to KP_COL[2:0] */
775 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
776 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
777 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
779 /* Set GPH3[2:0] to KP_ROW[2:0] */
780 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
781 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
782 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
784 reg = S5PC100_KEYPAD_BASE;
786 struct s5pc110_gpio *gpio =
787 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
789 if (board_is_limo_real() || board_is_limo_universal()) {
797 for (i = 0; i < 4; i++) {
798 /* Set GPH3[3:0] to KP_ROW[3:0] */
799 if (row_mask & (0xF << (i << 2))) {
800 gpio_cfg_pin(&gpio->gpio_h3, i, 0x3);
801 if (!machine_is_p1p2())
802 gpio_set_pull(&gpio->gpio_h3, i, GPIO_PULL_UP);
805 /* Set GPH2[3:0] to KP_COL[3:0] */
806 if (col_mask & (0xF << (i << 2)))
807 gpio_cfg_pin(&gpio->gpio_h2, i, 0x3);
808 if (machine_is_p1p2())
809 gpio_set_pull(&gpio->gpio_h2, i, GPIO_PULL_UP);
812 reg = S5PC110_KEYPAD_BASE;
816 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
817 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
818 /* VOLUMEDOWN and CAM(Half shot) Button */
819 if ((value & KBR1) == 0) {
822 value = readl(reg + S5PC1XX_KEYIFCOL_OFFSET);
825 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
827 col_value[i++] = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
829 writel(0x00, reg + S5PC1XX_KEYIFCOL_OFFSET);
831 /* expected value is row_value[0] = 0x00 row_value[1] = 0x01 */
833 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) == 0x3)
836 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) != 0x3)
838 if (machine_is_p1p2()) {
839 if ((col_value[0] & 0xd) == 0xd)
845 setenv("bootcmd", "usbdown");
847 if (machine_is_aquila()) {
849 i2c_set_bus_num(I2C_GPIO6);
851 if (i2c_probe(addr)) {
852 printf("Can't found 3 touchkey\n");
856 #define MCS5000_TK_HW_VERSION 0x06
857 #define MCS5000_TK_FW_VERSION 0x0A
858 #define MCS5000_TK_MI_VERSION 0x0B
860 reg = MCS5000_TK_MI_VERSION;
861 i2c_read(addr, reg, 1, val, 1);
862 dprintf("3-touchkey M/I 0x%x, ", val[0]);
863 reg = MCS5000_TK_HW_VERSION;
864 i2c_read(addr, reg, 1, val, 1);
865 dprintf("H/W 0x%x, ", val[0]);
866 reg = MCS5000_TK_FW_VERSION;
867 i2c_read(addr, reg, 1, val, 1);
868 dprintf("F/W 0x%x\n", val[0]);
872 static void enable_battery(void)
874 unsigned char val[2];
875 unsigned char addr = 0x36; /* max17040 fuel gauge */
877 if (machine_is_aquila()) {
882 if (machine_is_tickertape())
885 if (machine_is_cypress())
886 i2c_set_bus_num(I2C_GPIO7);
888 i2c_set_bus_num(I2C_GPIO3);
890 if (i2c_probe(addr)) {
891 printf("Can't found max17040 fuel gauge\n");
897 i2c_write(addr, 0xfe, 1, val, 2);
900 static void check_battery(void)
902 unsigned char val[2];
903 unsigned char addr = 0x36; /* max17040 fuel gauge */
905 if (machine_is_aquila()) {
910 if (machine_is_tickertape())
913 if (machine_is_cypress())
914 i2c_set_bus_num(I2C_GPIO7);
916 i2c_set_bus_num(I2C_GPIO3);
918 if (i2c_probe(addr)) {
919 printf("Can't found max17040 fuel gauge\n");
923 i2c_read(addr, 0x04, 1, val, 1);
925 dprintf("battery:\t%d%%\n", val[0]);
927 battery_soc = val[0];
930 static void check_mhl(void)
932 unsigned char val[2];
933 unsigned char addr = 0x39; /* SIL9230 */
934 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
936 /* MHL Power enable */
937 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
938 gpio_direction_output(&gpio->gpio_j2, 2, 1);
940 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
941 gpio_direction_output(&gpio->gpio_mp0_4, 7, 0);
943 /* 10ms required after reset */
947 gpio_set_value(&gpio->gpio_mp0_4, 7, 1);
949 i2c_set_bus_num(I2C_GPIO5);
952 if (i2c_probe(addr)) {
953 printf("Can't found MHL Chip\n");
959 * set to Normal operation
962 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
963 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
968 * 00 = MHL termination ON
969 * 11 = MHL termination OFF
972 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
973 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
976 static void into_charge_mode(void)
978 unsigned char addr = 0xCC >> 1; /* max8998 */;
979 unsigned char val[2];
983 i2c_set_bus_num(I2C_PMIC);
985 if (i2c_probe(addr)) {
986 printf("Can't found max8998\n");
990 printf("Charge Mode\n");
992 i2c_read(addr, 0x0C, 1, val, 1);
993 val[0] &= ~(0x7 << 0);
994 val[0] |= 5; /* 600mA */
995 i2c_write(addr, 0x0C, 1, val, 1);
997 #ifdef CONFIG_S5PC1XXFB
998 /* TODO: change to Image animation */
1001 set_font_color(FONT_WHITE);
1002 fb_printf("charging");
1004 level = battery_soc / 25;
1006 for (i = 0; i < 3; i++) {
1008 udelay(1 * 1000 * 1000);
1010 for (j = 0; j < 4; j++) {
1014 udelay(1 * 1000 * 1000);
1018 udelay(1 * 1000 * 1000);
1021 set_font_color(FONT_XOR);
1022 fb_printf("charging........");
1025 set_font_color(FONT_WHITE);
1026 fb_printf("charging");
1032 run_command("sleep 1", 0);
1035 static void check_micro_usb(int intr)
1038 unsigned char val[2];
1040 if (cpu_is_s5pc100())
1043 if (board_is_limo_real()) {
1044 if (hwrevision(0) || hwrevision(1))
1048 if (machine_is_cypress())
1049 i2c_set_bus_num(I2C_GPIO6);
1051 i2c_set_bus_num(I2C_PMIC);
1053 addr = 0x25; /* fsa9480 */
1054 if (i2c_probe(addr)) {
1055 printf("Can't found fsa9480\n");
1059 /* Clear Interrupt */
1061 i2c_read(addr, 0x03, 1, val, 2);
1065 /* Read Device Type 1 */
1066 i2c_read(addr, 0x0a, 1, val, 1);
1068 #define FSA_DEDICATED_CHARGER (1 << 6)
1069 #define FSA_UART (1 << 3)
1070 #define FSA_USB (1 << 2)
1073 * If USB, use default 475mA
1074 * If Charger, use 600mA and go to charge mode
1076 if (val[0] & FSA_DEDICATED_CHARGER)
1079 /* If Factory Mode is Boot ON-USB, go to download mode */
1080 i2c_read(addr, 0x07, 1, val, 1);
1082 #define FSA_ADC_FAC_USB 0x19
1083 #define FSA_ADC_FAC_UART 0x1d
1085 if (val[0] == FSA_ADC_FAC_USB)
1086 setenv("bootcmd", "usbdown");
1089 #define MAX8998_REG_ONOFF1 0x11
1090 #define MAX8998_REG_ONOFF2 0x12
1091 #define MAX8998_REG_ONOFF3 0x13
1092 #define MAX8998_LDO10 (1 << 3)
1093 #define MAX8998_LDO11 (1 << 2)
1094 #define MAX8998_LDO12 (1 << 1)
1095 #define MAX8998_LDO13 (1 << 0)
1096 #define MAX8998_LDO14 (1 << 7)
1097 #define MAX8998_LDO15 (1 << 6)
1098 #define MAX8998_LDO16 (1 << 5)
1099 #define MAX8998_LDO17 (1 << 4)
1101 static void init_pmic(void)
1104 unsigned char val[2];
1106 if (cpu_is_s5pc100())
1109 i2c_set_bus_num(I2C_PMIC);
1111 addr = 0xCC >> 1; /* max8998 */
1112 if (i2c_probe(addr)) {
1113 printf("Can't found max8998\n");
1119 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1121 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1122 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1124 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1125 MAX8998_LDO12 | MAX8998_LDO13);
1127 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1128 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1130 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1132 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1133 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1135 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1136 MAX8998_LDO16 | MAX8998_LDO17);
1137 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1138 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1141 #define PDN_MASK(x) (0x3 << ((x) << 1))
1143 #define CON_INPUT(x) (0x0 << ((x) << 2))
1144 #define CON_OUTPUT(x) (0x1 << ((x) << 2))
1145 #define CON_IRQ(x) (0xf << ((x) << 2))
1147 #define DAT_SET(x) (0x1 << (x))
1148 #define DAT_CLEAR(x) (0x0 << (x))
1150 #define OUTPUT0(x) (0x0 << ((x) << 1))
1151 #define OUTPUT1(x) (0x1 << ((x) << 1))
1152 #define INPUT(x) (0x2 << ((x) << 1))
1154 #define PULL_DIS(x) (0x0 << ((x) << 1))
1155 #define PULL_DOWN(x) (0x1 << ((x) << 1))
1156 #define PULL_UP(x) (0x2 << ((x) << 1))
1158 #define PREVIOUS(x) (0x3 << ((x) << 1))
1160 #define R225_229_755_756_NOT_REMOVED
1161 #undef R225_229_755_756_NOT_REMOVED
1163 struct gpio_powermode {
1164 unsigned int conpdn;
1165 unsigned int pudpdn;
1168 struct gpio_external {
1174 static struct gpio_powermode powerdown_modes[] = {
1175 { /* S5PC110_GPIO_A0_OFFSET */
1176 INPUT(0) | OUTPUT0(1) | INPUT(2) | OUTPUT0(3) |
1177 INPUT(4) | OUTPUT0(5) | INPUT(6) | OUTPUT0(7),
1178 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1179 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1180 }, { /* S5PC110_GPIO_A1_OFFSET */
1181 INPUT(0) | OUTPUT0(1) | INPUT(2) | OUTPUT0(3),
1182 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3),
1183 }, { /* S5PC110_GPIO_B_OFFSET */
1184 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1185 INPUT(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1186 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1187 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1188 }, { /* S5PC110_GPIO_C0_OFFSET */
1189 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1191 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1193 }, { /* S5PC110_GPIO_C1_OFFSET */
1194 /* OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1196 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1198 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1200 }, { /* S5PC110_GPIO_D0_OFFSET */
1201 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3),
1202 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3),
1203 }, { /* S5PC110_GPIO_D1_OFFSET */
1204 #ifdef R225_229_755_756_NOT_REMOVED
1206 INPUT(0) | INPUT(1) | INPUT(2) | INPUT(3) |
1207 OUTPUT0(4) | OUTPUT0(5),
1208 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1209 PULL_DIS(4) | PULL_DIS(5),
1211 /* For current test board only with R225-229 / R755-756 removed */
1212 INPUT(0) | INPUT(1) | INPUT(2) | INPUT(3) |
1213 INPUT(4) | INPUT(5),
1214 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1215 PULL_DIS(4) | PULL_DIS(5),
1217 }, { /* S5PC110_GPIO_E0_OFFSET */
1218 INPUT(0) | INPUT(1) | INPUT(2) | INPUT(3) |
1219 INPUT(4) | INPUT(5) | INPUT(6) | INPUT(7),
1220 PULL_DOWN(0) | PULL_DOWN(1) | PULL_DOWN(2) | PULL_DOWN(3) |
1221 PULL_DOWN(4) | PULL_DOWN(5) | PULL_DOWN(6) | PULL_DOWN(7),
1222 }, { /* S5PC110_GPIO_E1_OFFSET */
1223 INPUT(0) | INPUT(1) | INPUT(2) | OUTPUT0(3) |
1225 PULL_DOWN(0) | PULL_DOWN(1) | PULL_DOWN(2) | PULL_DIS(3) |
1227 }, { /* S5PC110_GPIO_F0_OFFSET */
1228 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1229 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1230 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1231 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1232 }, { /* S5PC110_GPIO_F1_OFFSET */
1233 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1234 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1235 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1236 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1237 }, { /* S5PC110_GPIO_F2_OFFSET */
1238 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1239 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1240 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1241 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1242 }, { /* S5PC110_GPIO_F3_OFFSET */
1243 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1244 OUTPUT0(4) | OUTPUT0(5),
1245 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1246 PULL_DIS(4) | PULL_DIS(5),
1247 }, { /* S5PC110_GPIO_G0_OFFSET */
1248 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1249 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1250 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1251 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1252 }, { /* S5PC110_GPIO_G1_OFFSET */
1253 #ifdef R225_229_755_756_NOT_REMOVED
1255 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1256 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1257 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1258 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1260 /* For the current test board */
1261 OUTPUT0(0) | INPUT(1) | OUTPUT0(2) | INPUT(3) |
1262 INPUT(4) | INPUT(5) | INPUT(6),
1263 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1264 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1266 }, { /* S5PC110_GPIO_G2_OFFSET */
1267 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1268 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1269 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1270 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1271 }, { /* S5PC110_GPIO_G3_OFFSET */
1272 OUTPUT0(0) | OUTPUT0(1) | OUTPUT1(2) | INPUT(3) |
1273 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1274 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1275 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1276 }, { /* S5PC110_GPIO_I_OFFSET */
1277 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1278 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1279 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1280 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1281 }, { /* S5PC110_GPIO_J0_OFFSET */
1282 OUTPUT1(0) | OUTPUT0(1) | INPUT(2) | INPUT(3) |
1283 INPUT(4) | INPUT(5) | OUTPUT0(6) | OUTPUT0(7),
1284 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1285 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1286 }, { /* S5PC110_GPIO_J1_OFFSET */
1287 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1288 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1289 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1290 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1291 }, { /* S5PC110_GPIO_J2_OFFSET */
1292 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1293 INPUT(4) | OUTPUT0(5) | OUTPUT0(6) | INPUT(7),
1294 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1295 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DOWN(7),
1296 }, { /* S5PC110_GPIO_J3_OFFSET */
1297 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1298 OUTPUT1(4) | OUTPUT0(5) | INPUT(6) | INPUT(7),
1299 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1300 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1301 }, { /* S5PC110_GPIO_J4_OFFSET */
1302 INPUT(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1304 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1309 static struct gpio_external external_powerdown_modes[] = {
1310 { /* S5PC110_GPIO_H0_OFFSET */
1311 CON_OUTPUT(0) | CON_INPUT(1) | CON_OUTPUT(2) | CON_OUTPUT(3) |
1312 CON_OUTPUT(4) | CON_OUTPUT(5) | CON_INPUT(6) | CON_INPUT(7),
1313 DAT_SET(0) | DAT_CLEAR(2) | DAT_CLEAR(3) |
1314 DAT_CLEAR(4) | DAT_CLEAR(5),
1315 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1316 PULL_DIS(4) | PULL_DIS(5),
1317 }, { /* S5PC110_GPIO_H1_OFFSET */
1318 /* CON_INPUT(0) | CON_INPUT(1) | CON_OUTPUT(2) | CON_IRQ(3) |
1319 CON_IRQ(4) | CON_INPUT(5) | CON_INPUT(6) | CON_INPUT(7),
1321 PULL_DOWN(0) | PULL_DOWN(1) |
1323 CON_INPUT(0) | CON_INPUT(1) | CON_OUTPUT(2) | CON_IRQ(3) |
1324 CON_INPUT(4) | CON_INPUT(5) | CON_OUTPUT(6) | CON_INPUT(7),
1326 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1328 }, { /* S5PC110_GPIO_H2_OFFSET */
1329 CON_OUTPUT(0) | CON_OUTPUT(1) | CON_OUTPUT(2) | CON_OUTPUT(3) |
1330 CON_IRQ(4) | CON_IRQ(5) | CON_IRQ(6) | CON_IRQ(7),
1331 DAT_CLEAR(0) | DAT_CLEAR(1) | DAT_CLEAR(2) | DAT_CLEAR(3),
1333 }, { /* S5PC110_GPIO_H3_OFFSET */
1334 CON_IRQ(0) | CON_IRQ(1) | CON_IRQ(2) | CON_OUTPUT(3) |
1335 CON_IRQ(4) | CON_INPUT(5) | CON_IRQ(6) | CON_OUTPUT(7),
1336 DAT_CLEAR(3) | DAT_CLEAR(7),
1341 static void setup_power_down_mode_registers(void)
1343 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1344 struct s5pc1xx_gpio_bank *bank;
1345 struct gpio_powermode *p;
1346 struct gpio_external *ge;
1349 if (cpu_is_s5pc100())
1352 if (!(machine_is_aquila() && board_is_limo_real()))
1355 bank = &gpio->gpio_a0;
1356 p = powerdown_modes;
1358 for (i = 0; i < ARRAY_SIZE(powerdown_modes); i++, p++, bank++) {
1359 writel(p->conpdn, &bank->pdn_con);
1360 writel(p->pudpdn, &bank->pdn_pull);
1362 bank = &gpio->gpio_i;
1363 writel(0x0008, &bank->dat);
1364 bank = &gpio->gpio_mp0_1;
1365 writel(0x5100, &bank->pdn_con);
1366 writel(0x0000, &bank->pdn_pull);
1367 bank = &gpio->gpio_mp0_2;
1368 writel(0x0020, &bank->pdn_con);
1369 writel(0x0000, &bank->pdn_pull);
1370 bank = &gpio->gpio_mp0_3;
1371 writel(0x0210, &bank->pdn_con);
1372 writel(0x0000, &bank->pdn_pull);
1373 bank = &gpio->gpio_mp0_4;
1374 writel(0x2280, &bank->pdn_con);
1375 writel(0x1140, &bank->pdn_pull);
1376 bank = &gpio->gpio_mp0_5;
1377 writel(0x00a2, &bank->pdn_con);
1378 writel(0x0001, &bank->pdn_pull);
1379 bank = &gpio->gpio_mp0_6;
1380 writel(0x0000, &bank->pdn_con);
1381 writel(0x0000, &bank->pdn_pull);
1382 bank = &gpio->gpio_mp0_7;
1383 writel(0x0000, &bank->pdn_con);
1384 writel(0x0000, &bank->pdn_pull);
1387 writel(0xff0022b0, (unsigned int *)0xF0000000);
1388 writel(0xff0022b0, (unsigned int *)0xF1400000);
1391 bank = &gpio->gpio_h0;
1392 ge = external_powerdown_modes;
1394 for (i = 0; i < ARRAY_SIZE(external_powerdown_modes); i++) {
1395 writel(ge->con, &bank->con);
1396 writel(ge->dat, &bank->dat);
1397 writel(ge->pud, &bank->pull);
1405 struct s6e63m0_platform_data {
1406 struct s5pc1xx_gpio_bank *bank;
1410 extern void s6e63m0_set_spi_interface(struct s6e63m0_platform_data *cs,
1411 struct s6e63m0_platform_data *clk, struct s6e63m0_platform_data *si,
1412 struct s6e63m0_platform_data *so);
1414 struct s6e63m0_platform_data pd_cs, pd_clk, pd_si, pd_so;
1415 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1417 void lcd_cfg_gpio(void)
1419 unsigned int i, f3_end = 4;
1421 for (i = 0; i < 8; i++) {
1422 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1423 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1424 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1425 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1426 /* pull-up/down disable */
1427 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1428 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1429 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1431 /* drive strength to max (24bit) */
1432 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1433 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1434 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1435 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1436 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1437 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1440 /* set DISPLAY_DE_B pin for dual rgb mode. */
1441 if (board_is_media())
1444 for (i =0; i < f3_end; i++) {
1445 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1446 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1447 /* pull-up/down disable */
1448 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1449 /* drive strength to max (24bit) */
1450 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1451 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1453 /* display output path selection (only [1:0] valid) */
1454 writel(0x2, 0xE0107008);
1456 /* gpio pad configuration for LCD reset. */
1457 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1459 /* gpio pad configuration for LCD ON. */
1460 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1464 if (board_is_p2_real())
1465 gpio_cfg_pin(&gpio_base->gpio_j1, 4, GPIO_OUTPUT);
1468 /* LCD_BACKLIGHT_EN */
1469 if (machine_is_geminus())
1470 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1472 /* gpio pad configuration for DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI. */
1473 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1474 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1475 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1476 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1478 if (machine_is_aquila()) {
1479 pd_cs.bank = &gpio_base->gpio_mp0_1;
1481 pd_clk.bank = &gpio_base->gpio_mp0_4;
1483 pd_si.bank = &gpio_base->gpio_mp0_4;
1485 pd_so.bank = &gpio_base->gpio_mp0_4;
1488 /* these data would be sent to s6e63m0 lcd panel driver. */
1489 s6e63m0_set_spi_interface(&pd_cs, &pd_clk, &pd_si, &pd_so);
1492 if (machine_is_cypress()) {
1494 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1496 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1498 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1500 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1502 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1504 pd_cs.bank = &gpio_base->gpio_mp0_1;
1506 pd_clk.bank = &gpio_base->gpio_mp0_4;
1508 pd_si.bank = &gpio_base->gpio_mp0_4;
1511 /* these data would be sent to s6e63m0 lcd panel driver. */
1512 s6e63m0_set_spi_interface(&pd_cs, &pd_clk, &pd_si, NULL);
1518 void backlight_on(unsigned int onoff)
1520 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1523 if (machine_is_geminus())
1524 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1526 if (machine_is_geminus())
1527 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1531 void reset_lcd(void)
1533 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1535 if (machine_is_aquila() || machine_is_geminus()/* || board_is_p2_real() */)
1536 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1537 if (machine_is_cypress())
1538 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1541 void lcd_power_on(unsigned int onoff)
1543 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1546 if (machine_is_aquila() || machine_is_geminus())
1547 gpio_set_value(&gpio->gpio_j1, 3, 1);
1549 if (machine_is_cypress())
1550 gpio_set_value(&gpio->gpio_g2, 2, 1);
1553 if (board_is_p2_real())
1554 gpio_set_value(&gpio->gpio_j1, 4, 1);
1557 if (machine_is_aquila() || machine_is_geminus())
1558 gpio_set_value(&gpio->gpio_j1, 3, 0);
1560 if (machine_is_cypress())
1561 gpio_set_value(&gpio->gpio_g2, 2, 0);
1564 if (board_is_p2_real())
1565 gpio_set_value(&gpio->gpio_j1, 4, 0);
1570 extern void s6e63m0_cfg_ldo(void);
1571 extern void s6e63m0_enable_ldo(unsigned int onoff);
1573 void init_panel_info(vidinfo_t *vid)
1575 vid->cfg_gpio = NULL;
1576 vid->reset_lcd = NULL;
1577 vid->backlight_on = NULL;
1578 vid->lcd_power_on = NULL;
1580 vid->cfg_ldo = NULL;
1581 vid->enable_ldo = NULL;
1583 vid->init_delay = 0;
1584 vid->reset_delay = 0;
1585 vid->power_on_delay = 0;
1590 vid->vl_width = 480;
1591 vid->vl_height = 800;
1593 vid->dual_lcd_enabled = 0;
1595 if (board_is_media()) {
1598 vid->vl_width = 960;
1599 vid->vl_height = 800;
1601 /* enable dual lcd mode. */
1602 vid->dual_lcd_enabled = 1;
1605 vid->vl_clkp = CONFIG_SYS_HIGH;
1606 vid->vl_hsp = CONFIG_SYS_LOW;
1607 vid->vl_vsp = CONFIG_SYS_LOW;
1608 vid->vl_dp = CONFIG_SYS_HIGH;
1611 /* S6E63M0 LCD Panel */
1620 if (machine_is_aquila() || machine_is_cypress()) {
1621 vid->cfg_gpio = lcd_cfg_gpio;
1622 vid->reset_lcd = reset_lcd;
1623 vid->backlight_on = backlight_on;
1624 vid->lcd_power_on = lcd_power_on;
1626 vid->cfg_ldo = s6e63m0_cfg_ldo;
1627 vid->enable_ldo = s6e63m0_enable_ldo;
1629 vid->init_delay = 25000;
1630 vid->reset_delay = 120000;
1633 if (machine_is_geminus()) {
1637 vid->vl_width = 1024,
1638 vid->vl_height = 600,
1639 vid->vl_clkp = CONFIG_SYS_LOW,
1640 vid->vl_hsp = CONFIG_SYS_HIGH,
1641 vid->vl_vsp = CONFIG_SYS_HIGH,
1642 vid->vl_dp = CONFIG_SYS_LOW,
1653 vid->cfg_gpio = lcd_cfg_gpio;
1654 vid->reset_lcd = reset_lcd;
1655 vid->backlight_on = backlight_on;
1656 vid->lcd_power_on = lcd_power_on;
1662 vid->vl_width = 480,
1663 vid->vl_height = 800,
1664 vid->vl_clkp = CONFIG_SYS_HIGH,
1665 vid->vl_hsp = CONFIG_SYS_LOW,
1666 vid->vl_vsp = CONFIG_SYS_LOW,
1667 vid->vl_dp = CONFIG_SYS_HIGH,
1683 vid->vl_width = 1024,
1684 vid->vl_height = 600,
1685 vid->vl_clkp = CONFIG_SYS_HIGH,
1686 vid->vl_hsp = CONFIG_SYS_HIGH,
1687 vid->vl_vsp = CONFIG_SYS_HIGH,
1688 vid->vl_dp = CONFIG_SYS_LOW,
1691 /* AMS701KA AMOLED Panel. */
1703 static void setup_meminfo(void)
1705 char meminfo[64] = {0, };
1706 int count = 0, size, real;
1708 size = gd->bd->bi_dram[0].size >> 20;
1709 count += sprintf(meminfo + count, "mem=%dM", size);
1711 /* Each Chip Select can't exceed the 256MiB */
1712 size = gd->bd->bi_dram[1].size >> 20;
1713 real = min(size, 256);
1714 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1715 real, (unsigned int)gd->bd->bi_dram[1].start);
1719 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1720 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1723 setenv("meminfo", meminfo);
1726 int misc_init_r(void)
1729 /* It should be located at first */
1732 if (board_is_limo_real() ||
1733 board_is_limo_universal() ||
1735 setenv("lcdinfo", "lcd=s6e63m0");
1736 /* it can't classify tl2796 with single-lcd and dual-lcd.
1738 setenv("lcdinfo", "lcd=tl2796-dual");
1742 * env values below should be added in case that lcd panel of geminus,
1743 * p1 and p2 are enabled at u-boot.
1744 * setenv means that lcd panel has been turned on at u-boot.
1746 if (machine_is_geminus())
1747 setenv("lcdinfo", "lcd=lms480jc01");
1750 if (board_is_p2_real())
1751 setenv("lcdinfo", "lcd=ams701");
1758 /* Set proper PMIC pins */
1761 /* Check auto burning */
1764 /* To power up I2C2 */
1767 /* Enable T-Flash at Limo Real or Limo Universal */
1770 /* Setup Limo Real board GPIOs */
1771 setup_limo_real_gpios();
1773 /* Setup Media board GPIOs */
1774 setup_media_gpios();
1776 /* Setup P1P2 board GPIOS */
1779 /* To usbdown automatically */
1780 if (board_is_p2_real())
1788 /* check max17040 */
1791 #ifdef CONFIG_S5PC1XXFB
1792 display_device_info();
1795 setup_power_down_mode_registers();
1804 int board_init(void)
1806 gd->bd->bi_arch_number = MACH_TYPE;
1807 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1809 /* Check H/W Revision */
1810 check_hw_revision();
1817 unsigned int base, memconfig0, size;
1818 unsigned int memconfig1, sz = 0;
1820 if (cpu_is_s5pc100()) {
1821 /* In mem setup, we swap the bank. So below size is correct */
1822 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1823 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1824 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1827 /* In S5PC110, we can't swap the DMC0/1 */
1828 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1829 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1831 base = S5PC110_DMC1_BASE;
1832 /* DMC configuration */
1833 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1834 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1836 size = (memconfig0 >> 16) & 0xFF;
1837 size = ((unsigned char) ~size) + 1;
1840 * (0x07 + 1) * 16 = 128 MiB
1841 * (0x0f + 1) * 16 = 256 MiB
1846 * Aquila Rev0.5 4G3G1G
1847 * Aquila Rev0.7 4G3G1G
1849 if (machine_is_aquila() && (hwrevision(5) || hwrevision(7))) {
1850 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1852 sz = (memconfig1 >> 16) & 0xFF;
1853 sz = ((unsigned char) ~sz) + 1;
1859 * bi_dram[1].size contains all DMC1 memory size
1861 gd->bd->bi_dram[1].size = (size + sz) << 20;
1866 /* Used for sleep test */
1867 static unsigned char saved_val[4][2];
1868 static unsigned int gpio_CP;
1869 static unsigned int gpio_T_FLASH;
1870 void board_sleep_init(void)
1874 unsigned char val[2];
1875 struct s5pc110_gpio *gpio =
1876 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1878 /* Set wakeup mask register */
1880 value &= ~(1 << 4); /* Keypad */
1881 value &= ~(1 << 3); /* RTC */
1882 value &= ~(1 << 2); /* RTC Alarm */
1883 writel(value, S5PC110_WAKEUP_MASK);
1885 /* Set external wakeup mask register */
1887 value &= ~(1 << 18); /* T-Flash */
1888 writel(value, S5PC110_EINT_WAKEUP_MASK);
1890 i2c_set_bus_num(I2C_PMIC);
1892 if (i2c_probe(addr)) {
1893 printf("Can't find max8998\n");
1898 gpio_CP = gpio_get_value(&gpio->gpio_h3, 7);
1899 gpio_set_value(&gpio->gpio_h3, 7, 0);
1900 value = gpio_get_value(&gpio->gpio_h3, 7);
1901 /* MMC T_FLASH off */
1902 gpio_T_FLASH = gpio_get_value(&gpio->gpio_mp0_5, 4);
1903 gpio_set_value(&gpio->gpio_mp0_5, 4, 0);
1904 value = gpio_get_value(&gpio->gpio_mp0_5, 4);
1906 #define HDMI_EN1 &gpio->gpio_j2, 2
1907 #define MHL_RST &gpio->gpio_mp0_4, 7
1908 gpio_set_value(HDMI_EN1, 0);
1909 gpio_set_value(MHL_RST, 0);
1910 gpio_set_value(&gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1913 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1914 saved_val[0][0] = val[0];
1915 saved_val[0][1] = val[1];
1916 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1917 (1 << 1) | (1 << 0));
1918 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1919 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1921 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1922 saved_val[1][0] = val[0];
1923 saved_val[1][1] = val[1];
1924 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1925 (1 << 2) | (1 << 1) | (1 << 0));
1927 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1928 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1930 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1931 saved_val[2][0] = val[0];
1932 saved_val[2][1] = val[1];
1933 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
1934 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1935 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1937 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1938 saved_val[3][0] = val[0];
1939 saved_val[3][1] = val[1];
1940 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
1941 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1942 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1943 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
1944 __FILE__, __LINE__);
1947 void board_sleep_resume(void)
1951 unsigned char val[2];
1952 struct s5pc110_gpio *gpio =
1953 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1957 i2c_set_bus_num(I2C_PMIC);
1959 if (i2c_probe(addr)) {
1960 printf("Can't find max8998\n");
1965 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
1966 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1968 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
1969 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1971 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
1972 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1974 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
1975 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1976 printf("Waked up.\n");
1979 gpio_set_value(&gpio->gpio_h3, 7, gpio_CP);
1980 value = gpio_get_value(&gpio->gpio_h3, 7);
1982 gpio_set_value(&gpio->gpio_mp0_5, 4, gpio_T_FLASH);
1983 value = gpio_get_value(&gpio->gpio_mp0_5, 4);
1985 /* check max17040 */
1992 #ifdef CONFIG_CMD_USBDOWN
1993 int usb_board_init(void)
1995 if (cpu_is_s5pc100()) {
1996 #ifdef CONFIG_HARD_I2C
1997 uchar val[2] = {0,};
2000 if (i2c_read(0x66, 0, 1, val, 2)) {
2001 printf("i2c_read error\n");
2008 if (i2c_write(0x66, 0, 1, val, 2)) {
2009 printf("i2c_write error\n");
2012 i2c_read(0x66, 0, 1, val, 2);
2018 if (board_is_limo_universal() || board_is_limo_real() || board_is_media()) {
2019 /* check usb path */
2020 if (board_is_limo_real() && !hwrevision(6))
2024 if (machine_is_tickertape()) {
2025 struct s5pc110_gpio *gpio =
2026 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
2028 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2029 gpio_direction_output(&gpio->gpio_mp0_4, 0, 0);
2036 #ifdef CONFIG_GENERIC_MMC
2037 int board_mmc_init(bd_t *bis)
2041 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2042 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
2045 /* MMC0 Clock source = SCLKMPLL */
2046 reg = readl(&clk->src4);
2049 writel(reg, &clk->src4);
2051 reg = readl(&clk->div4);
2054 /* set div value near 50MHz */
2055 clock = get_pll_clk(MPLL) / 1000000;
2056 for (i = 0; i < 0xf; i++) {
2057 if ((clock / (i + 1)) <= 50) {
2063 writel(reg, &clk->div4);
2070 * GPG0[3:6] SD_0_DATA[0:3]
2072 for (i = 0; i < 7; i++) {
2073 /* GPG0[0:6] special function 2 */
2074 gpio_cfg_pin(&gpio->gpio_g0, i, 0x2);
2075 /* GPG0[0:6] pull up */
2076 gpio_set_pull(&gpio->gpio_g0, i, GPIO_PULL_UP);
2079 return s5pc1xx_mmc_init(0);
2083 static int pmic_status(void)
2085 unsigned char addr, val[2];
2088 i2c_set_bus_num(I2C_PMIC);
2090 if (i2c_probe(addr)) {
2091 printf("Can't found max8998\n");
2096 i2c_read(addr, reg, 1, val, 1);
2097 for (i = 7; i >= 4; i--)
2098 printf("BUCK%d %s\n", 7 - i + 1, val[0] & (1 << i) ? "on" : "off");
2100 printf("LDO%d %s\n", 5 - i, val[0] & (1 << i) ? "on" : "off");
2102 i2c_read(addr, reg, 1, val, 1);
2103 for (i = 7; i >= 0; i--)
2104 printf("LDO%d %s\n", 7 - i + 6, val[0] & (1 << i) ? "on" : "off");
2106 i2c_read(addr, reg, 1, val, 1);
2107 for (i = 7; i >= 4; i--)
2108 printf("LDO%d %s\n", 7 - i + 14, val[0] & (1 << i) ? "on" : "off");
2112 static int pmic_ldo_control(int buck, int ldo, int on)
2114 unsigned char addr, val[2];
2115 unsigned int reg, shift;
2123 } else if (ldo <= 13) {
2126 } else if (ldo <= 17) {
2128 shift = 17 - ldo + 4;
2135 shift = 4 - buck + 4;
2139 i2c_set_bus_num(I2C_PMIC);
2141 if (i2c_probe(addr)) {
2142 printf("Can't found max8998\n");
2146 i2c_read(addr, reg, 1, val, 1);
2148 val[0] |= (1 << shift);
2150 val[0] &= ~(1 << shift);
2151 i2c_write(addr, reg, 1, val, 1);
2152 i2c_read(addr, reg, 1, val, 1);
2153 printf("%s %d value 0x%x, %s\n", buck ? "buck" : "ldo", buck ? : ldo,
2154 val[0], val[0] & (1 << shift) ? "on" : "off");
2159 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2161 int buck = 0, ldo = 0, on = -1;
2165 if (strncmp(argv[1], "status", 6) == 0)
2166 return pmic_status();
2169 if (strncmp(argv[1], "ldo", 3) == 0) {
2170 ldo = simple_strtoul(argv[2], NULL, 10);
2171 if (strncmp(argv[3], "on", 2) == 0)
2173 else if (strncmp(argv[3], "off", 3) == 0)
2177 return pmic_ldo_control(buck, ldo, on);
2179 if (strncmp(argv[1], "buck", 4) == 0) {
2180 buck = simple_strtoul(argv[2], NULL, 10);
2181 if (strncmp(argv[3], "on", 2) == 0)
2183 else if (strncmp(argv[3], "off", 3) == 0)
2187 return pmic_ldo_control(buck, ldo, on);
2199 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2200 "PMIC LDO & BUCK control",
2201 "status - Display PMIC LDO & BUCK status\n"
2202 "pmic ldo num on/off - Turn on/off the LDO\n"
2203 "pmic buck num on/off - Turn on/off the BUCK\n"