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>
35 #include <asm/errno.h>
39 DECLARE_GLOBAL_DATA_PTR;
41 #define C100_MACH_START 3000
42 #define C110_MACH_START 3100
44 static unsigned int board_rev;
45 static unsigned int battery_soc;
46 static struct s5pc110_gpio *s5pc110_gpio;
62 static struct i2c_gpio_bus_data i2c_2 = {
72 static struct i2c_gpio_bus_data i2c_gpio3 = {
82 static struct i2c_gpio_bus_data i2c_pmic = {
92 static struct i2c_gpio_bus_data i2c_gpio5 = {
102 static struct i2c_gpio_bus_data i2c_gpio6 = {
108 * i2c gpio6 - cypress
112 static struct i2c_gpio_bus_data i2c_cypress_gpio6 = {
118 * i2c gpio7 - cypress
122 static struct i2c_gpio_bus_data i2c_cypress_gpio7 = {
127 static struct i2c_gpio_bus i2c_gpio[] = {
143 u32 get_board_rev(void)
148 static int hwrevision(int rev)
150 return (board_rev & 0xf) == rev;
162 #define SPLIT_SCREEN_FEATURE 0x100
164 /* board is MACH_AQUILA and board is like below. */
165 #define J1_B2_BOARD 0x200
166 #define LIMO_UNIVERSAL_BOARD 0x400
167 #define LIMO_REAL_BOARD 0x800
168 #define MEDIA_BOARD 0x1000
169 /* board is MACH_P1P2 and board is like below. */
170 #define P1_REAL_BOARD 0x200
171 #define P2_REAL_BOARD 0x400
173 #define BOARD_MASK 0xF00
175 static int c110_machine_id(void)
177 return gd->bd->bi_arch_number - C110_MACH_START;
180 static int machine_is_aquila(void)
182 return c110_machine_id() == MACH_AQUILA;
185 static int machine_is_p1p2(void)
187 return c110_machine_id() == MACH_P1P2;
190 static int machine_is_tickertape(void)
192 return c110_machine_id() == MACH_TICKERTAPE;
195 static int machine_is_geminus(void)
197 return c110_machine_id() == MACH_GEMINUS;
200 static int machine_is_cypress(void)
202 return c110_machine_id() == MACH_CYPRESS;
205 static int board_is_limo_universal(void)
207 return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
210 static int board_is_limo_real(void)
212 return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
215 static int board_is_media(void)
217 return machine_is_aquila() && (board_rev & MEDIA_BOARD);
220 static int board_is_j1b2(void)
222 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
225 static int board_is_p2_real(void)
227 return machine_is_p1p2() && (board_rev & P2_REAL_BOARD);
230 static void enable_battery(void);
232 void i2c_init_board(void)
234 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
237 if (cpu_is_s5pc100())
240 num_bus = ARRAY_SIZE(i2c_gpio);
242 if (machine_is_cypress()) {
243 i2c_gpio[I2C_GPIO6].bus = &i2c_cypress_gpio6;
244 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
245 i2c_gpio[I2C_GPIO7].bus->gpio_base =
246 (unsigned int)&gpio->gpio_mp0_5;
251 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
252 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
253 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
254 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
255 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
257 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
259 /* Reset on max17040 early */
260 if (battery_soc == 0)
264 #ifdef CONFIG_MISC_INIT_R
265 #define DEV_INFO_LEN 512
266 static char device_info[DEV_INFO_LEN];
267 static int display_info;
269 static void dprintf(const char *fmt, ...)
276 i = vsprintf(buf, fmt, args);
281 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
282 puts("Flushing device info...\n");
286 strcat(device_info, buf);
290 #ifdef CONFIG_S5PC1XXFB
291 static void display_device_info(void)
298 set_font_color(FONT_WHITE);
299 fb_printf(device_info);
302 memset(device_info, 0x0, DEV_INFO_LEN);
304 udelay(5 * 1000 * 1000);
308 static const char *board_name[] = {
324 static char feature_buffer[32];
326 static char *display_features(int board, int board_rev)
329 char *buf = feature_buffer;
331 if (board == MACH_AQUILA) {
332 if (board_rev & SPLIT_SCREEN_FEATURE)
333 count += sprintf(buf + count, " - SplitScreen");
334 if (board_rev & J1_B2_BOARD)
335 count += sprintf(buf + count, " - J1 B2 board");
336 /* Limo Real or Universal */
337 if (board_rev & LIMO_REAL_BOARD)
338 count += sprintf(buf + count, " - Limo Real");
339 else if (board_rev & LIMO_UNIVERSAL_BOARD)
340 count += sprintf(buf + count, " - Limo Universal");
341 if (board_rev & MEDIA_BOARD)
342 count += sprintf(buf + count, " - Media");
343 } else if (board == MACH_P1P2) {
345 if (board_rev & P1_REAL_BOARD)
346 count += sprintf(buf + count, " - P1 Real");
347 else if (board_rev & P2_REAL_BOARD)
348 count += sprintf(buf + count, " - P2 Real");
350 count += sprintf(buf + count, " - Universal");
356 static void check_board_revision(int board, int rev)
360 /* Limo Real or Universal */
361 if (rev & LIMO_UNIVERSAL_BOARD)
362 board_rev &= ~J1_B2_BOARD;
363 if (rev & LIMO_REAL_BOARD) {
364 board_rev &= ~(J1_B2_BOARD |
365 LIMO_UNIVERSAL_BOARD);
367 if (rev & MEDIA_BOARD)
368 board_rev &= ~(J1_B2_BOARD |
369 LIMO_UNIVERSAL_BOARD);
374 /* There's no HWREV_MODE3 */
375 board_rev &= ~(1 << 3);
377 case MACH_TICKERTAPE:
379 board_rev &= ~BOARD_MASK;
386 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank)
390 gpio_direction_input(bank, 1);
391 gpio_direction_input(bank, 2);
392 gpio_direction_input(bank, 3);
393 gpio_direction_input(bank, 4);
395 gpio_set_pull(bank, 1, GPIO_PULL_NONE); /* HWREV_MODE3 */
396 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
397 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
398 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
400 rev = gpio_get_value(bank, 2);
401 rev |= (gpio_get_value(bank, 3) << 1);
402 rev |= (gpio_get_value(bank, 4) << 2);
403 rev |= (gpio_get_value(bank, 1) << 3);
408 static void check_hw_revision(void)
410 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
412 if (cpu_is_s5pc100()) {
413 struct s5pc100_gpio *gpio =
414 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
416 board_rev = get_hw_revision(&gpio->gpio_j0);
418 /* C100 TickerTape */
420 board = MACH_TICKERTAPE;
422 struct s5pc110_gpio *gpio =
423 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
425 board_rev = get_hw_revision(&gpio->gpio_j0);
428 * Note Check 'Aquila' board first
432 * LRA: Limo Real Aquila
433 * LUA: Limo Universal Aquila
438 * ADDR = 0xE0200000 + OFF
440 * OFF Universal LRA LUA OA TT SS P1P2 CYP
441 * J1: 0x0264 0x10 0x00 0x00 0x00 0x00 0x00 0x00
442 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x18 0x0F
443 * H3: 0x0C64 0x03 0x07 0x0F 0xff
444 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
445 * I: 0x0224 0x02 0x00 0x08
446 * MP03: 0x0324 0x9x 0xbx 0x9x
447 * MP05: 0x0364 0x80 0x88
451 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
453 board_rev |= J1_B2_BOARD;
455 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
456 gpio_direction_input(&gpio->gpio_j2, 6);
459 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
460 board_rev |= LIMO_UNIVERSAL_BOARD;
462 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
463 board_rev |= LIMO_REAL_BOARD;
465 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
466 board_rev |= MEDIA_BOARD;
468 /* set gpio to default value. */
469 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
470 gpio_direction_output(&gpio->gpio_j2, 6, 0);
472 /* Workaround: C110 Aquila Rev0.6 */
473 if (board_rev == 6) {
475 board_rev |= LIMO_REAL_BOARD;
478 /* C110 TickerTape */
479 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
480 gpio_get_value(&gpio->gpio_d1, 1) == 0)
481 board = MACH_TICKERTAPE;
483 /* C110 Cypress: Do first this than P1P2 */
484 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
485 gpio_direction_input(&gpio->gpio_j2, 2);
486 if (gpio_get_value(&gpio->gpio_j2, 2) == 1)
487 board = MACH_CYPRESS;
488 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
491 if (gpio_get_value(&gpio->gpio_h3, 7) == 1) {
493 board_rev &= ~BOARD_MASK;
496 /* set gpio configuration for P1P2. */
497 gpio_direction_input(&gpio->gpio_j0, 6);
498 gpio_direction_input(&gpio->gpio_j0, 7);
501 * do not change order below
502 * because it needs delay to get gpio value.
505 gpio_set_pull(&gpio->gpio_j0, 7, GPIO_PULL_NONE);
507 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
509 if (gpio_get_value(&gpio->gpio_j0, 7) == 1) {
511 board_rev &= ~BOARD_MASK;
512 if (gpio_get_value(&gpio->gpio_j0, 6) == 1)
513 board_rev |= P1_REAL_BOARD;
514 if (gpio_get_value(&gpio->gpio_j0, 6) == 0)
515 board_rev |= P2_REAL_BOARD;
518 /* set gpio to default value. */
520 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
522 gpio_set_pull(&gpio->gpio_j0, 7, GPIO_PULL_DOWN);
524 /* C110 Geminus for rev0.0 */
525 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
526 gpio_direction_input(&gpio->gpio_j1, 2);
527 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
528 board = MACH_GEMINUS;
529 if ((board_rev & ~BOARD_MASK) == 3)
532 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
533 gpio_direction_output(&gpio->gpio_j1, 2, 0);
535 /* C110 Geminus for rev0.1 ~ */
536 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
537 gpio_direction_input(&gpio->gpio_j0, 6);
538 if (gpio_get_value(&gpio->gpio_j0, 6) == 1)
539 board = MACH_GEMINUS;
540 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
544 if (cpu_is_s5pc110())
545 gd->bd->bi_arch_number = C110_MACH_START + board;
547 gd->bd->bi_arch_number = C100_MACH_START + board;
549 /* Architecture Common settings */
550 if (cpu_is_s5pc110()) {
551 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
553 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
555 setenv("updatek", "onenand erase 0x60000 0x300000; "
556 "onenand write 0x31008000 0x60000 0x300000");
560 static void show_hw_revision(void)
565 * Workaround for Rev 0.3 + CP Ver ES 3.1
568 if (board_is_limo_real()) {
570 /* default is Rev 0.4 */
576 if (cpu_is_s5pc110())
577 board = gd->bd->bi_arch_number - C110_MACH_START;
579 board = gd->bd->bi_arch_number - C100_MACH_START;
581 check_board_revision(board, board_rev);
583 /* Set CPU Revision */
584 if (board_is_limo_real()) {
585 if ((board_rev & 0xf) < 8)
586 s5pc1xx_set_cpu_rev(0);
588 s5pc1xx_set_cpu_rev(0);
591 dprintf("HW Revision:\t%x (%s%s)\n", board_rev, board_name[board],
592 display_features(board, board_rev));
595 static void check_auto_burn(void)
597 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
598 unsigned int count = 0;
601 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
602 printf("Auto burning bootloader\n");
603 count += sprintf(buf + count, "run updateb; ");
605 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
606 printf("Auto burning kernel\n");
607 count += sprintf(buf + count, "run updatek; ");
611 count += sprintf(buf + count, "reset");
612 setenv("bootcmd", buf);
615 /* Clear the magic value */
616 writel(0xa5a55a5a, magic_base);
617 writel(0xa5a55a5a, magic_base + 0x4);
620 static void pmic_pin_init(void)
622 unsigned int reg, value;
624 if (cpu_is_s5pc100())
627 /* AP_PS_HOLD: XEINT_0: GPH0[0]
628 * Note: Don't use GPIO PS_HOLD it doesn't work
630 reg = S5PC110_PS_HOLD_CONTROL;
632 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
633 S5PC110_PS_HOLD_DATA_HIGH |
634 S5PC110_PS_HOLD_OUT_EN;
637 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
638 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
639 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
642 static void enable_ldos(void)
644 if (cpu_is_s5pc100())
647 if (machine_is_p1p2())
650 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
651 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
654 static void enable_t_flash(void)
656 if (!(board_is_limo_universal() || board_is_limo_real()))
659 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
660 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
663 static void setup_limo_real_gpios(void)
665 if (!board_is_limo_real())
669 * Note: Please write GPIO alphabet order
671 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
672 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
675 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
676 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
678 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
679 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
681 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
682 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
683 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
686 static void setup_media_gpios(void)
688 if (!board_is_media())
692 * Note: Please write GPIO alphabet order
694 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
695 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
697 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
698 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
699 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
702 static void setup_p1p2_gpios(void)
704 if (!machine_is_p1p2())
708 * Note: Please write GPIO alphabet order
710 /* RESET_REQ_N: XM0FRnB[1]: MP0_3[5] output high */
711 gpio_direction_output(&s5pc110_gpio->gpio_mp0_3, 5, 1);
712 /* CODEC_LDO_EN: XM0FRnB[2]: MP0_3[6] output high */
713 gpio_direction_output(&s5pc110_gpio->gpio_mp0_3, 6, 1);
716 #define KBR3 (1 << 3)
717 #define KBR2 (1 << 2)
718 #define KBR1 (1 << 1)
719 #define KBR0 (1 << 0)
721 static void check_p2_keypad(void)
723 unsigned int auto_download = 0;
724 unsigned char addr = 0x34, val[2]; /* adp5587 key controller */
726 i2c_set_bus_num(I2C_2);
728 if (i2c_probe(addr)) {
729 printf("Can't found adp5587 key controller\n");
732 /* Row 8, Column 10 */
734 ret = i2c_write(addr, 0x1D, 1, val, 1); /* Set KP_GPIO1 */
736 ret |= i2c_write(addr, 0x1E, 1, val, 1); /* Set KP_GPIO2 */
738 ret |= i2c_write(addr, 0x1F, 1, val, 1); /* Set KP_GPIO3 */
739 val[0] = 0x3f; /* CMP2_INT | CMP1_INT | OVR_FLOW_INT |
740 K_LCK_INT | GPI_INT | KE_INT */
741 ret |= i2c_write(addr, 0x02, 1, val, 1); /* Status is W1C */
742 val[0] = 0x19; /* INT_CFG | OVR_FLOW_IEN | KE_IEN */
743 ret |= i2c_write(addr, 0x01, 1, val, 1);
744 for (i = 0; i < 10; i++) {
745 udelay(1000); /* FIXME */
746 i2c_read(addr, 0x04 + i, 1, val, 1);
751 if (auto_download == 1)
752 setenv("bootcmd", "usbdown");
755 static void check_keypad(void)
757 unsigned int reg, value;
758 unsigned int col_mask, row_mask;
759 unsigned int auto_download = 0;
760 unsigned int col_value[4], i;
762 if (cpu_is_s5pc100()) {
763 struct s5pc100_gpio *gpio =
764 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
766 /* Set GPH2[2:0] to KP_COL[2:0] */
767 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
768 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
769 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
771 /* Set GPH3[2:0] to KP_ROW[2:0] */
772 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
773 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
774 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
776 reg = S5PC100_KEYPAD_BASE;
778 if (board_is_limo_real() || board_is_limo_universal()) {
786 for (i = 0; i < 4; i++) {
787 /* Set GPH3[3:0] to KP_ROW[3:0] */
788 if (row_mask & (0xF << (i << 2))) {
789 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
790 if (!machine_is_p1p2())
791 gpio_set_pull(&s5pc110_gpio->gpio_h3,
795 /* Set GPH2[3:0] to KP_COL[3:0] */
796 if (col_mask & (0xF << (i << 2)))
797 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
798 if (machine_is_p1p2())
799 gpio_set_pull(&s5pc110_gpio->gpio_h2, i, GPIO_PULL_UP);
802 reg = S5PC110_KEYPAD_BASE;
806 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
807 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
808 /* VOLUMEDOWN and CAM(Half shot) Button */
809 if ((value & KBR1) == 0) {
812 value = readl(reg + S5PC1XX_KEYIFCOL_OFFSET);
815 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
817 col_value[i++] = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
819 writel(0x00, reg + S5PC1XX_KEYIFCOL_OFFSET);
821 /* expected value is row_value[0] = 0x00 row_value[1] = 0x01 */
823 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) == 0x3)
826 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) != 0x3)
828 if (machine_is_p1p2()) {
829 if ((col_value[0] & 0xd) == 0xd)
835 setenv("bootcmd", "usbdown");
838 static void enable_battery(void)
840 unsigned char val[2];
841 unsigned char addr = 0x36; /* max17040 fuel gauge */
843 if (machine_is_aquila()) {
848 if (machine_is_tickertape())
851 if (machine_is_cypress())
852 i2c_set_bus_num(I2C_GPIO7);
854 i2c_set_bus_num(I2C_GPIO3);
856 if (i2c_probe(addr)) {
857 printf("Can't found max17040 fuel gauge\n");
863 i2c_write(addr, 0xfe, 1, val, 2);
866 static void check_battery(void)
868 unsigned char val[2];
869 unsigned char addr = 0x36; /* max17040 fuel gauge */
871 if (machine_is_aquila()) {
876 if (machine_is_tickertape())
879 if (machine_is_cypress())
880 i2c_set_bus_num(I2C_GPIO7);
882 i2c_set_bus_num(I2C_GPIO3);
884 if (i2c_probe(addr)) {
885 printf("Can't found max17040 fuel gauge\n");
889 i2c_read(addr, 0x04, 1, val, 1);
891 dprintf("battery:\t%d%%\n", val[0]);
893 battery_soc = val[0];
896 static void check_mhl(void)
898 unsigned char val[2];
899 unsigned char addr = 0x39; /* SIL9230 */
901 /* MHL Power enable */
902 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
903 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
905 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
906 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
908 /* 10ms required after reset */
912 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
914 i2c_set_bus_num(I2C_GPIO5);
917 if (i2c_probe(addr)) {
918 printf("Can't found MHL Chip\n");
924 * set to Normal operation
927 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
928 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
933 * 00 = MHL termination ON
934 * 11 = MHL termination OFF
937 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
938 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
941 static void into_charge_mode(void)
943 unsigned char addr = 0xCC >> 1; /* max8998 */;
944 unsigned char val[2];
948 i2c_set_bus_num(I2C_PMIC);
950 if (i2c_probe(addr)) {
951 printf("Can't found max8998\n");
955 printf("Charge Mode\n");
957 i2c_read(addr, 0x0C, 1, val, 1);
958 val[0] &= ~(0x7 << 0);
959 val[0] |= 5; /* 600mA */
960 i2c_write(addr, 0x0C, 1, val, 1);
962 #ifdef CONFIG_S5PC1XXFB
963 /* TODO: change to Image animation */
966 set_font_color(FONT_WHITE);
967 fb_printf("charging");
969 level = battery_soc / 25;
971 for (i = 0; i < 3; i++) {
973 udelay(1 * 1000 * 1000);
975 for (j = 0; j < 4; j++) {
979 udelay(1 * 1000 * 1000);
983 udelay(1 * 1000 * 1000);
986 set_font_color(FONT_XOR);
987 fb_printf("charging........");
990 set_font_color(FONT_WHITE);
991 fb_printf("charging");
997 run_command("sleep 1", 0);
1000 static void check_micro_usb(int intr)
1003 unsigned char val[2];
1005 if (cpu_is_s5pc100())
1008 if (board_is_limo_real()) {
1009 if (hwrevision(0) || hwrevision(1))
1013 if (machine_is_cypress())
1014 i2c_set_bus_num(I2C_GPIO6);
1016 i2c_set_bus_num(I2C_PMIC);
1018 addr = 0x25; /* fsa9480 */
1019 if (i2c_probe(addr)) {
1020 printf("Can't found fsa9480\n");
1024 /* Clear Interrupt */
1026 i2c_read(addr, 0x03, 1, val, 2);
1030 /* Read Device Type 1 */
1031 i2c_read(addr, 0x0a, 1, val, 1);
1033 #define FSA_DEDICATED_CHARGER (1 << 6)
1034 #define FSA_UART (1 << 3)
1035 #define FSA_USB (1 << 2)
1038 * If USB, use default 475mA
1039 * If Charger, use 600mA and go to charge mode
1041 if (val[0] & FSA_DEDICATED_CHARGER)
1044 /* If Factory Mode is Boot ON-USB, go to download mode */
1045 i2c_read(addr, 0x07, 1, val, 1);
1047 #define FSA_ADC_FAC_USB 0x19
1048 #define FSA_ADC_FAC_UART 0x1d
1050 if (val[0] == FSA_ADC_FAC_USB)
1051 setenv("bootcmd", "usbdown");
1054 #define MAX8998_REG_ONOFF1 0x11
1055 #define MAX8998_REG_ONOFF2 0x12
1056 #define MAX8998_REG_ONOFF3 0x13
1057 #define MAX8998_LDO3 (1 << 2)
1058 #define MAX8998_LDO10 (1 << 3)
1059 #define MAX8998_LDO11 (1 << 2)
1060 #define MAX8998_LDO12 (1 << 1)
1061 #define MAX8998_LDO13 (1 << 0)
1062 #define MAX8998_LDO14 (1 << 7)
1063 #define MAX8998_LDO15 (1 << 6)
1064 #define MAX8998_LDO16 (1 << 5)
1065 #define MAX8998_LDO17 (1 << 4)
1067 static void init_pmic(void)
1070 unsigned char val[2];
1072 if (cpu_is_s5pc100())
1075 i2c_set_bus_num(I2C_PMIC);
1077 addr = 0xCC >> 1; /* max8998 */
1078 if (i2c_probe(addr)) {
1079 printf("Can't found max8998\n");
1084 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1085 val[0] &= ~MAX8998_LDO3;
1086 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1089 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1091 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1092 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1094 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1095 MAX8998_LDO12 | MAX8998_LDO13);
1097 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1098 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1100 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1102 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1103 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1105 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1106 MAX8998_LDO16 | MAX8998_LDO17);
1107 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1108 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1111 #define PDN_MASK(x) (0x3 << ((x) << 1))
1113 #define CON_INPUT(x) (0x0 << ((x) << 2))
1114 #define CON_OUTPUT(x) (0x1 << ((x) << 2))
1115 #define CON_IRQ(x) (0xf << ((x) << 2))
1117 #define DAT_SET(x) (0x1 << (x))
1118 #define DAT_CLEAR(x) (0x0 << (x))
1120 #define OUTPUT0(x) (0x0 << ((x) << 1))
1121 #define OUTPUT1(x) (0x1 << ((x) << 1))
1122 #define INPUT(x) (0x2 << ((x) << 1))
1124 #define PULL_DIS(x) (0x0 << ((x) << 1))
1125 #define PULL_DOWN(x) (0x1 << ((x) << 1))
1126 #define PULL_UP(x) (0x2 << ((x) << 1))
1128 #define PREVIOUS(x) (0x3 << ((x) << 1))
1130 struct gpio_powermode {
1131 unsigned int conpdn;
1132 unsigned int pudpdn;
1135 struct gpio_external {
1141 static struct gpio_powermode powerdown_modes[] = {
1142 { /* S5PC110_GPIO_A0_OFFSET */
1143 INPUT(0) | OUTPUT0(1) | INPUT(2) | OUTPUT0(3) |
1144 INPUT(4) | OUTPUT0(5) | INPUT(6) | OUTPUT0(7),
1145 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1146 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1147 }, { /* S5PC110_GPIO_A1_OFFSET */
1148 INPUT(0) | OUTPUT0(1) | INPUT(2) | OUTPUT0(3),
1149 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3),
1150 }, { /* S5PC110_GPIO_B_OFFSET */
1151 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1152 INPUT(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1153 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1154 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1155 }, { /* S5PC110_GPIO_C0_OFFSET */
1156 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1158 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1160 }, { /* S5PC110_GPIO_C1_OFFSET */
1161 /* OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1163 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1165 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1167 }, { /* S5PC110_GPIO_D0_OFFSET */
1168 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3),
1169 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3),
1170 }, { /* S5PC110_GPIO_D1_OFFSET */
1171 INPUT(0) | INPUT(1) | INPUT(2) | INPUT(3) |
1172 INPUT(4) | INPUT(5),
1173 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1174 PULL_DIS(4) | PULL_DIS(5),
1175 }, { /* S5PC110_GPIO_E0_OFFSET */
1176 INPUT(0) | INPUT(1) | INPUT(2) | INPUT(3) |
1177 INPUT(4) | INPUT(5) | INPUT(6) | INPUT(7),
1178 PULL_DOWN(0) | PULL_DOWN(1) | PULL_DOWN(2) | PULL_DOWN(3) |
1179 PULL_DOWN(4) | PULL_DOWN(5) | PULL_DOWN(6) | PULL_DOWN(7),
1180 }, { /* S5PC110_GPIO_E1_OFFSET */
1181 INPUT(0) | INPUT(1) | INPUT(2) | OUTPUT0(3) |
1183 PULL_DOWN(0) | PULL_DOWN(1) | PULL_DOWN(2) | PULL_DIS(3) |
1185 }, { /* S5PC110_GPIO_F0_OFFSET */
1186 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1187 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1188 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1189 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1190 }, { /* S5PC110_GPIO_F1_OFFSET */
1191 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1192 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1193 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1194 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1195 }, { /* S5PC110_GPIO_F2_OFFSET */
1196 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1197 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1198 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1199 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1200 }, { /* S5PC110_GPIO_F3_OFFSET */
1201 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1202 OUTPUT0(4) | OUTPUT0(5),
1203 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1204 PULL_DIS(4) | PULL_DIS(5),
1205 }, { /* S5PC110_GPIO_G0_OFFSET */
1206 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1207 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1208 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1209 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1210 }, { /* S5PC110_GPIO_G1_OFFSET */
1211 OUTPUT0(0) | INPUT(1) | OUTPUT0(2) | INPUT(3) |
1212 INPUT(4) | INPUT(5) | INPUT(6),
1213 PULL_DIS(0) | PULL_UP(1) | PULL_DIS(2) | PULL_UP(3) |
1214 PULL_UP(4) | PULL_UP(5) | PULL_UP(6),
1215 }, { /* S5PC110_GPIO_G2_OFFSET */
1216 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1217 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1218 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1219 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1220 }, { /* S5PC110_GPIO_G3_OFFSET */
1221 OUTPUT0(0) | OUTPUT0(1) | OUTPUT1(2) | INPUT(3) |
1222 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1223 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1224 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1225 }, { /* S5PC110_GPIO_I_OFFSET */
1226 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1227 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6),
1228 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1229 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6),
1230 }, { /* S5PC110_GPIO_J0_OFFSET */
1231 OUTPUT1(0) | OUTPUT0(1) | INPUT(2) | INPUT(3) |
1232 INPUT(4) | INPUT(5) | OUTPUT0(6) | OUTPUT0(7),
1233 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1234 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1235 }, { /* S5PC110_GPIO_J1_OFFSET */
1236 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1237 OUTPUT0(4) | OUTPUT0(5) | OUTPUT0(6) | OUTPUT0(7),
1238 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1239 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1240 }, { /* S5PC110_GPIO_J2_OFFSET */
1241 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1242 INPUT(4) | OUTPUT0(5) | OUTPUT0(6) | INPUT(7),
1243 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1244 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DOWN(7),
1245 }, { /* S5PC110_GPIO_J3_OFFSET */
1246 OUTPUT0(0) | OUTPUT0(1) | OUTPUT0(2) | OUTPUT0(3) |
1247 OUTPUT1(4) | OUTPUT0(5) | INPUT(6) | INPUT(7),
1248 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1249 PULL_DIS(4) | PULL_DIS(5) | PULL_DIS(6) | PULL_DIS(7),
1250 }, { /* S5PC110_GPIO_J4_OFFSET */
1251 INPUT(0) | OUTPUT0(1) | OUTPUT0(2) | INPUT(3) |
1253 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1258 static struct gpio_external external_powerdown_modes[] = {
1259 { /* S5PC110_GPIO_H0_OFFSET */
1260 CON_OUTPUT(0) | CON_INPUT(1) | CON_OUTPUT(2) | CON_OUTPUT(3) |
1261 CON_OUTPUT(4) | CON_OUTPUT(5) | CON_INPUT(6) | CON_INPUT(7),
1262 DAT_SET(0) | DAT_CLEAR(2) | DAT_CLEAR(3) |
1263 DAT_CLEAR(4) | DAT_CLEAR(5),
1264 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1265 PULL_DIS(4) | PULL_DIS(5),
1266 }, { /* S5PC110_GPIO_H1_OFFSET */
1267 /* CON_INPUT(0) | CON_INPUT(1) | CON_OUTPUT(2) | CON_IRQ(3) |
1268 CON_IRQ(4) | CON_INPUT(5) | CON_INPUT(6) | CON_INPUT(7),
1270 PULL_DOWN(0) | PULL_DOWN(1) |
1272 CON_INPUT(0) | CON_INPUT(1) | CON_OUTPUT(2) | CON_IRQ(3) |
1273 CON_INPUT(4) | CON_INPUT(5) | CON_OUTPUT(6) | CON_INPUT(7),
1275 PULL_DIS(0) | PULL_DIS(1) | PULL_DIS(2) | PULL_DIS(3) |
1277 }, { /* S5PC110_GPIO_H2_OFFSET */
1278 CON_OUTPUT(0) | CON_OUTPUT(1) | CON_OUTPUT(2) | CON_OUTPUT(3) |
1279 CON_IRQ(4) | CON_IRQ(5) | CON_IRQ(6) | CON_IRQ(7),
1280 DAT_CLEAR(0) | DAT_CLEAR(1) | DAT_CLEAR(2) | DAT_CLEAR(3),
1282 }, { /* S5PC110_GPIO_H3_OFFSET */
1283 CON_IRQ(0) | CON_IRQ(1) | CON_IRQ(2) | CON_OUTPUT(3) |
1284 CON_IRQ(4) | CON_INPUT(5) | CON_IRQ(6) | CON_OUTPUT(7),
1285 DAT_CLEAR(3) | DAT_CLEAR(7),
1290 static void setup_power_down_mode_registers(void)
1292 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1293 struct s5pc1xx_gpio_bank *bank;
1294 struct gpio_powermode *p;
1295 struct gpio_external *ge;
1298 if (cpu_is_s5pc100())
1301 if (!(machine_is_aquila() && board_is_limo_real()))
1304 bank = &gpio->gpio_a0;
1305 p = powerdown_modes;
1307 for (i = 0; i < ARRAY_SIZE(powerdown_modes); i++, p++, bank++) {
1308 writel(p->conpdn, &bank->pdn_con);
1309 writel(p->pudpdn, &bank->pdn_pull);
1311 bank = &gpio->gpio_i;
1312 writel(0x0008, &bank->dat);
1313 bank = &gpio->gpio_mp0_1;
1314 writel(0x5100, &bank->pdn_con);
1315 writel(0x0000, &bank->pdn_pull);
1316 bank = &gpio->gpio_mp0_2;
1317 writel(0x0020, &bank->pdn_con);
1318 writel(0x0000, &bank->pdn_pull);
1319 bank = &gpio->gpio_mp0_3;
1320 writel(0x0210, &bank->pdn_con);
1321 writel(0x0000, &bank->pdn_pull);
1322 bank = &gpio->gpio_mp0_4;
1323 writel(0x2280, &bank->pdn_con);
1324 writel(0x1140, &bank->pdn_pull);
1325 bank = &gpio->gpio_mp0_5;
1326 writel(0x00a2, &bank->pdn_con);
1327 writel(0x0001, &bank->pdn_pull);
1328 bank = &gpio->gpio_mp0_6;
1329 writel(0x0000, &bank->pdn_con);
1330 writel(0x0000, &bank->pdn_pull);
1331 bank = &gpio->gpio_mp0_7;
1332 writel(0x0000, &bank->pdn_con);
1333 writel(0x0000, &bank->pdn_pull);
1336 writel(0xff0022b0, (unsigned int *)0xF0000000);
1337 writel(0xff0022b0, (unsigned int *)0xF1400000);
1340 bank = &gpio->gpio_h0;
1341 ge = external_powerdown_modes;
1343 for (i = 0; i < ARRAY_SIZE(external_powerdown_modes); i++) {
1344 writel(ge->con, &bank->con);
1345 writel(ge->dat, &bank->dat);
1346 writel(ge->pud, &bank->pull);
1354 struct s6e63m0_platform_data {
1355 struct s5pc1xx_gpio_bank *bank;
1359 extern void s6e63m0_set_spi_interface(struct s6e63m0_platform_data *cs,
1360 struct s6e63m0_platform_data *clk, struct s6e63m0_platform_data *si,
1361 struct s6e63m0_platform_data *so);
1363 struct s6e63m0_platform_data pd_cs, pd_clk, pd_si, pd_so;
1364 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1366 void lcd_cfg_gpio(void)
1368 unsigned int i, f3_end = 4;
1370 for (i = 0; i < 8; i++) {
1371 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1372 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1373 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1374 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1375 /* pull-up/down disable */
1376 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1377 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1378 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1380 /* drive strength to max (24bit) */
1381 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1382 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1383 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1384 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1385 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1386 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1389 /* set DISPLAY_DE_B pin for dual rgb mode. */
1390 if (board_is_media())
1393 for (i = 0; i < f3_end; i++) {
1394 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1395 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1396 /* pull-up/down disable */
1397 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1398 /* drive strength to max (24bit) */
1399 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1400 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1402 /* display output path selection (only [1:0] valid) */
1403 writel(0x2, 0xE0107008);
1405 /* gpio pad configuration for LCD reset. */
1406 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1408 /* gpio pad configuration for LCD ON. */
1409 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1413 if (board_is_p2_real())
1414 gpio_cfg_pin(&gpio_base->gpio_j1, 4, GPIO_OUTPUT);
1417 /* LCD_BACKLIGHT_EN */
1418 if (machine_is_geminus())
1419 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1422 * gpio pad configuration for
1423 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1425 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1426 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1427 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1428 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1430 if (machine_is_aquila()) {
1431 pd_cs.bank = &gpio_base->gpio_mp0_1;
1433 pd_clk.bank = &gpio_base->gpio_mp0_4;
1435 pd_si.bank = &gpio_base->gpio_mp0_4;
1437 pd_so.bank = &gpio_base->gpio_mp0_4;
1440 /* these data would be sent to s6e63m0 lcd panel driver. */
1441 s6e63m0_set_spi_interface(&pd_cs, &pd_clk, &pd_si, &pd_so);
1444 if (machine_is_cypress()) {
1446 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1448 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1450 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1452 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1454 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1456 pd_cs.bank = &gpio_base->gpio_mp0_1;
1458 pd_clk.bank = &gpio_base->gpio_mp0_4;
1460 pd_si.bank = &gpio_base->gpio_mp0_4;
1463 /* these data would be sent to s6e63m0 lcd panel driver. */
1464 s6e63m0_set_spi_interface(&pd_cs, &pd_clk, &pd_si, NULL);
1470 void backlight_on(unsigned int onoff)
1472 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1475 if (machine_is_geminus())
1476 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1478 if (machine_is_geminus())
1479 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1483 void reset_lcd(void)
1485 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1487 if (machine_is_aquila() || machine_is_geminus())
1488 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1489 if (machine_is_cypress())
1490 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1493 void lcd_power_on(unsigned int onoff)
1495 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1498 if (machine_is_aquila() || machine_is_geminus())
1499 gpio_set_value(&gpio->gpio_j1, 3, 1);
1501 if (machine_is_cypress())
1502 gpio_set_value(&gpio->gpio_g2, 2, 1);
1505 if (board_is_p2_real())
1506 gpio_set_value(&gpio->gpio_j1, 4, 1);
1509 if (machine_is_aquila() || machine_is_geminus())
1510 gpio_set_value(&gpio->gpio_j1, 3, 0);
1512 if (machine_is_cypress())
1513 gpio_set_value(&gpio->gpio_g2, 2, 0);
1516 if (board_is_p2_real())
1517 gpio_set_value(&gpio->gpio_j1, 4, 0);
1522 extern void s6e63m0_cfg_ldo(void);
1523 extern void s6e63m0_enable_ldo(unsigned int onoff);
1525 void init_panel_info(vidinfo_t *vid)
1527 vid->cfg_gpio = NULL;
1528 vid->reset_lcd = NULL;
1529 vid->backlight_on = NULL;
1530 vid->lcd_power_on = NULL;
1532 vid->cfg_ldo = NULL;
1533 vid->enable_ldo = NULL;
1535 vid->init_delay = 0;
1536 vid->reset_delay = 0;
1537 vid->power_on_delay = 0;
1542 vid->vl_width = 480;
1543 vid->vl_height = 800;
1545 vid->dual_lcd_enabled = 0;
1547 if (board_is_media()) {
1550 vid->vl_width = 960;
1551 vid->vl_height = 800;
1553 /* enable dual lcd mode. */
1554 vid->dual_lcd_enabled = 1;
1557 vid->vl_clkp = CONFIG_SYS_HIGH;
1558 vid->vl_hsp = CONFIG_SYS_LOW;
1559 vid->vl_vsp = CONFIG_SYS_LOW;
1560 vid->vl_dp = CONFIG_SYS_HIGH;
1563 /* S6E63M0 LCD Panel */
1572 if (machine_is_aquila() || machine_is_cypress()) {
1573 vid->cfg_gpio = lcd_cfg_gpio;
1574 vid->reset_lcd = reset_lcd;
1575 vid->backlight_on = backlight_on;
1576 vid->lcd_power_on = lcd_power_on;
1578 vid->cfg_ldo = s6e63m0_cfg_ldo;
1579 vid->enable_ldo = s6e63m0_enable_ldo;
1581 vid->init_delay = 25000;
1582 vid->reset_delay = 120000;
1585 if (machine_is_geminus()) {
1589 vid->vl_width = 1024,
1590 vid->vl_height = 600,
1591 vid->vl_clkp = CONFIG_SYS_LOW,
1592 vid->vl_hsp = CONFIG_SYS_HIGH,
1593 vid->vl_vsp = CONFIG_SYS_HIGH,
1594 vid->vl_dp = CONFIG_SYS_LOW,
1605 vid->cfg_gpio = lcd_cfg_gpio;
1606 vid->reset_lcd = reset_lcd;
1607 vid->backlight_on = backlight_on;
1608 vid->lcd_power_on = lcd_power_on;
1614 vid->vl_width = 480,
1615 vid->vl_height = 800,
1616 vid->vl_clkp = CONFIG_SYS_HIGH,
1617 vid->vl_hsp = CONFIG_SYS_LOW,
1618 vid->vl_vsp = CONFIG_SYS_LOW,
1619 vid->vl_dp = CONFIG_SYS_HIGH,
1635 vid->vl_width = 1024,
1636 vid->vl_height = 600,
1637 vid->vl_clkp = CONFIG_SYS_HIGH,
1638 vid->vl_hsp = CONFIG_SYS_HIGH,
1639 vid->vl_vsp = CONFIG_SYS_HIGH,
1640 vid->vl_dp = CONFIG_SYS_LOW,
1643 /* AMS701KA AMOLED Panel. */
1655 static void setup_meminfo(void)
1657 char meminfo[64] = {0, };
1658 int count = 0, size, real;
1660 size = gd->bd->bi_dram[0].size >> 20;
1661 count += sprintf(meminfo + count, "mem=%dM", size);
1663 /* Each Chip Select can't exceed the 256MiB */
1664 size = gd->bd->bi_dram[1].size >> 20;
1665 real = min(size, 256);
1666 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1667 real, (unsigned int)gd->bd->bi_dram[1].start);
1671 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1672 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1675 setenv("meminfo", meminfo);
1678 int misc_init_r(void)
1681 /* It should be located at first */
1684 if (board_is_limo_real() ||
1685 board_is_limo_universal() ||
1687 setenv("lcdinfo", "lcd=s6e63m0");
1688 /* it can't classify tl2796 with single-lcd and dual-lcd.
1690 setenv("lcdinfo", "lcd=tl2796-dual");
1694 * env values below should be added in case that lcd panel of geminus,
1695 * p1 and p2 are enabled at u-boot.
1696 * setenv means that lcd panel has been turned on at u-boot.
1698 if (machine_is_geminus())
1699 setenv("lcdinfo", "lcd=lms480jc01");
1702 if (board_is_p2_real())
1703 setenv("lcdinfo", "lcd=ams701");
1710 /* Set proper PMIC pins */
1713 /* Check auto burning */
1716 /* To power up I2C2 */
1719 /* Enable T-Flash at Limo Real or Limo Universal */
1722 /* Setup Limo Real board GPIOs */
1723 setup_limo_real_gpios();
1725 /* Setup Media board GPIOs */
1726 setup_media_gpios();
1728 /* Setup P1P2 board GPIOS */
1731 /* To usbdown automatically */
1732 if (board_is_p2_real())
1740 #ifdef CONFIG_S5PC1XXFB
1741 display_device_info();
1744 setup_power_down_mode_registers();
1746 /* check max17040 */
1756 int board_init(void)
1758 /* Set Initial global variables */
1759 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1761 gd->bd->bi_arch_number = MACH_TYPE;
1762 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1764 /* Check H/W Revision */
1765 check_hw_revision();
1772 unsigned int base, memconfig0, size;
1773 unsigned int memconfig1, sz = 0;
1775 if (cpu_is_s5pc100()) {
1776 /* In mem setup, we swap the bank. So below size is correct */
1777 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1778 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1779 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1782 /* In S5PC110, we can't swap the DMC0/1 */
1783 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1784 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1786 base = S5PC110_DMC1_BASE;
1787 /* DMC configuration */
1788 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1789 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1791 size = (memconfig0 >> 16) & 0xFF;
1792 size = ((unsigned char) ~size) + 1;
1795 * (0x07 + 1) * 16 = 128 MiB
1796 * (0x0f + 1) * 16 = 256 MiB
1801 * Aquila Rev0.5 4G3G1G
1802 * Aquila Rev0.8 4G3G1G
1804 if (machine_is_aquila() && (hwrevision(5) || hwrevision(8))) {
1805 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1807 sz = (memconfig1 >> 16) & 0xFF;
1808 sz = ((unsigned char) ~sz) + 1;
1814 * bi_dram[1].size contains all DMC1 memory size
1816 gd->bd->bi_dram[1].size = (size + sz) << 20;
1821 /* Used for sleep test */
1822 static unsigned char saved_val[4][2];
1823 static unsigned int gpio_CP;
1824 static unsigned int gpio_T_FLASH;
1825 void board_sleep_init(void)
1829 unsigned char val[2];
1830 struct s5pc110_gpio *gpio =
1831 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1833 /* Set wakeup mask register */
1835 value &= ~(1 << 4); /* Keypad */
1836 value &= ~(1 << 3); /* RTC */
1837 value &= ~(1 << 2); /* RTC Alarm */
1838 writel(value, S5PC110_WAKEUP_MASK);
1840 /* Set external wakeup mask register */
1842 value &= ~(1 << 18); /* T-Flash */
1843 writel(value, S5PC110_EINT_WAKEUP_MASK);
1845 i2c_set_bus_num(I2C_PMIC);
1847 if (i2c_probe(addr)) {
1848 printf("Can't find max8998\n");
1853 gpio_CP = gpio_get_value(&gpio->gpio_h3, 7);
1854 gpio_set_value(&gpio->gpio_h3, 7, 0);
1855 value = gpio_get_value(&gpio->gpio_h3, 7);
1856 /* MMC T_FLASH off */
1857 gpio_T_FLASH = gpio_get_value(&gpio->gpio_mp0_5, 4);
1858 gpio_set_value(&gpio->gpio_mp0_5, 4, 0);
1859 value = gpio_get_value(&gpio->gpio_mp0_5, 4);
1861 gpio_set_value(&gpio->gpio_j2, 2, 0);
1862 gpio_set_value(&gpio->gpio_mp0_4, 7, 0);
1863 gpio_set_value(&gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1866 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1867 saved_val[0][0] = val[0];
1868 saved_val[0][1] = val[1];
1869 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1870 (1 << 1) | (1 << 0));
1871 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1872 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1874 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1875 saved_val[1][0] = val[0];
1876 saved_val[1][1] = val[1];
1877 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1878 (1 << 2) | (1 << 1) | (1 << 0));
1880 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1881 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1883 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1884 saved_val[2][0] = val[0];
1885 saved_val[2][1] = val[1];
1886 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
1887 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1888 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1890 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1891 saved_val[3][0] = val[0];
1892 saved_val[3][1] = val[1];
1893 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
1894 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1895 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1896 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
1897 __FILE__, __LINE__);
1900 void board_sleep_resume(void)
1904 unsigned char val[2];
1905 struct s5pc110_gpio *gpio =
1906 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1910 i2c_set_bus_num(I2C_PMIC);
1912 if (i2c_probe(addr)) {
1913 printf("Can't find max8998\n");
1918 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
1919 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1921 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
1922 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1924 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
1925 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1927 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
1928 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
1929 printf("Waked up.\n");
1932 gpio_set_value(&gpio->gpio_h3, 7, gpio_CP);
1933 value = gpio_get_value(&gpio->gpio_h3, 7);
1935 gpio_set_value(&gpio->gpio_mp0_5, 4, gpio_T_FLASH);
1936 value = gpio_get_value(&gpio->gpio_mp0_5, 4);
1938 /* check max17040 */
1945 #ifdef CONFIG_CMD_USBDOWN
1946 int usb_board_init(void)
1948 #ifdef CONFIG_CMD_PMIC
1949 run_command("pmic ldo 3 on", 0);
1952 if (cpu_is_s5pc100()) {
1953 #ifdef CONFIG_HARD_I2C
1954 uchar val[2] = {0,};
1957 if (i2c_read(0x66, 0, 1, val, 2)) {
1958 printf("i2c_read error\n");
1965 if (i2c_write(0x66, 0, 1, val, 2)) {
1966 printf("i2c_write error\n");
1969 i2c_read(0x66, 0, 1, val, 2);
1975 if (board_is_limo_universal() ||
1976 board_is_limo_real() ||
1978 /* check usb path */
1979 if (board_is_limo_real() && !hwrevision(6))
1983 if (machine_is_tickertape())
1984 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
1985 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
1991 #ifdef CONFIG_GENERIC_MMC
1992 int board_mmc_init(bd_t *bis)
1996 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
1999 /* MMC0 Clock source = SCLKMPLL */
2000 reg = readl(&clk->src4);
2003 writel(reg, &clk->src4);
2005 reg = readl(&clk->div4);
2008 /* set div value near 50MHz */
2009 clock = get_pll_clk(MPLL) / 1000000;
2010 for (i = 0; i < 0xf; i++) {
2011 if ((clock / (i + 1)) <= 50) {
2017 writel(reg, &clk->div4);
2023 * GPG0[2] SD_0_CDn -> Not used
2024 * GPG0[3:6] SD_0_DATA[0:3]
2026 for (i = 0; i < 7; i++) {
2029 /* GPG0[0:6] special function 2 */
2030 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2031 /* GPG0[0:6] pull disable */
2032 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2035 return s5pc1xx_mmc_init(0);
2039 #ifdef CONFIG_CMD_PMIC
2040 static int pmic_status(void)
2042 unsigned char addr, val[2];
2045 i2c_set_bus_num(I2C_PMIC);
2047 if (i2c_probe(addr)) {
2048 printf("Can't found max8998\n");
2053 i2c_read(addr, reg, 1, val, 1);
2054 for (i = 7; i >= 4; i--)
2055 printf("BUCK%d %s\n", 7 - i + 1,
2056 val[0] & (1 << i) ? "on" : "off");
2058 printf("LDO%d %s\n", 5 - i,
2059 val[0] & (1 << i) ? "on" : "off");
2061 i2c_read(addr, reg, 1, val, 1);
2062 for (i = 7; i >= 0; i--)
2063 printf("LDO%d %s\n", 7 - i + 6,
2064 val[0] & (1 << i) ? "on" : "off");
2066 i2c_read(addr, reg, 1, val, 1);
2067 for (i = 7; i >= 4; i--)
2068 printf("LDO%d %s\n", 7 - i + 14,
2069 val[0] & (1 << i) ? "on" : "off");
2073 static int pmic_ldo_control(int buck, int ldo, int on)
2075 unsigned char addr, val[2];
2076 unsigned int reg, shift;
2084 } else if (ldo <= 13) {
2087 } else if (ldo <= 17) {
2089 shift = 17 - ldo + 4;
2096 shift = 4 - buck + 4;
2100 i2c_set_bus_num(I2C_PMIC);
2102 if (i2c_probe(addr)) {
2103 printf("Can't found max8998\n");
2107 i2c_read(addr, reg, 1, val, 1);
2109 val[0] |= (1 << shift);
2111 val[0] &= ~(1 << shift);
2112 i2c_write(addr, reg, 1, val, 1);
2113 i2c_read(addr, reg, 1, val, 1);
2114 printf("%s %d value 0x%x, %s\n", buck ? "buck" : "ldo", buck ? : ldo,
2115 val[0], val[0] & (1 << shift) ? "on" : "off");
2120 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2122 int buck = 0, ldo = 0, on = -1;
2126 if (strncmp(argv[1], "status", 6) == 0)
2127 return pmic_status();
2130 if (strncmp(argv[1], "ldo", 3) == 0) {
2131 ldo = simple_strtoul(argv[2], NULL, 10);
2132 if (strncmp(argv[3], "on", 2) == 0)
2134 else if (strncmp(argv[3], "off", 3) == 0)
2138 return pmic_ldo_control(buck, ldo, on);
2140 if (strncmp(argv[1], "buck", 4) == 0) {
2141 buck = simple_strtoul(argv[2], NULL, 10);
2142 if (strncmp(argv[3], "on", 2) == 0)
2144 else if (strncmp(argv[3], "off", 3) == 0)
2148 return pmic_ldo_control(buck, ldo, on);
2160 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2161 "PMIC LDO & BUCK control",
2162 "status - Display PMIC LDO & BUCK status\n"
2163 "pmic ldo num on/off - Turn on/off the LDO\n"
2164 "pmic buck num on/off - Turn on/off the BUCK\n"
2168 #ifdef CONFIG_CMD_DEVICE_POWER
2182 static void power_display_devices(void)
2184 printf("devices:\n");
2185 printf("\t%d - touch\n", POWER_TOUCH);
2186 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2187 printf("\t%d - LCD\n", POWER_LCD);
2188 printf("\t%d - Haptic\n", POWER_HAPTIC);
2189 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2190 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2191 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2192 printf("\t%d - HDMI\n", POWER_HDMI);
2195 static int power_hdmi(int on)
2197 /* HDMI_EN1: GPJ2[2] */
2198 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2199 /* MHL_ON: GPJ2[3] */
2200 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2204 static int power_bt_wifi(int on)
2206 /* WLAN_BT_EN: GPB[5] */
2207 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2211 static int power_fm_radio(int on)
2213 /* FM_BUS_nRST: GPJ2[5] */
2214 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2218 static int power_audio_codec(int on)
2220 /* CODEC_LDO_EN: GPF3[4] */
2221 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2222 /* CODEC_XTAL_EN: GPH3[2] */
2223 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2227 static int power_haptic(int on)
2229 /* HAPTIC_ON: GPJ1[1] */
2230 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2234 static int power_lcd(int on)
2236 /* MLCD_ON: GPJ1[3] */
2237 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2241 static int power_touch(int on)
2243 /* TOUCH_EN: GPG3[6] */
2244 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2248 static int power_3_touchkey(int on)
2250 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2251 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2252 if (board_rev & J1_B2_BOARD)
2253 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2255 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2257 /* 3_TOUCH_CE - GPJ2[6] */
2258 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2262 unsigned char val[2];
2263 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2269 i2c_set_bus_num(I2C_GPIO6);
2271 /* Workaround to probe */
2272 if (i2c_probe(addr)) {
2273 if (i2c_probe(addr)) {
2274 printf("Can't found 3 touchkey\n");
2279 #define MCS5000_TK_HW_VERSION 0x06
2280 #define MCS5000_TK_FW_VERSION 0x0A
2281 #define MCS5000_TK_MI_VERSION 0x0B
2283 reg = MCS5000_TK_MI_VERSION;
2284 i2c_read(addr, reg, 1, val, 1);
2285 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2286 reg = MCS5000_TK_HW_VERSION;
2287 i2c_read(addr, reg, 1, val, 1);
2288 printf("H/W 0x%x, ", val[0]);
2289 reg = MCS5000_TK_FW_VERSION;
2290 i2c_read(addr, reg, 1, val, 1);
2291 printf("F/W 0x%x\n", val[0]);
2296 static int power_control(int device, int on)
2300 return power_touch(on);
2301 case POWER_3_TOUCHKEY:
2302 return power_3_touchkey(on);
2304 return power_lcd(on);
2306 return power_haptic(on);
2307 case POWER_AUDIO_CODEC:
2308 return power_audio_codec(on);
2309 case POWER_FM_RADIO:
2310 return power_fm_radio(on);
2312 return power_bt_wifi(on);
2314 return power_hdmi(on);
2316 printf("I don't know device %d\n", device);
2322 static int power_on(int on)
2325 power_3_touchkey(on);
2328 power_audio_codec(on);
2334 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2338 if (!machine_is_aquila())
2343 if (strncmp(argv[1], "on", 2) == 0)
2345 if (strncmp(argv[1], "off", 3) == 0)
2349 device = simple_strtoul(argv[1], NULL, 10);
2353 if (strncmp(argv[2], "on", 2) == 0)
2355 else if (strncmp(argv[2], "off", 3) == 0)
2359 return power_control(device, on);
2365 power_display_devices();
2370 power, CONFIG_SYS_MAXARGS, 1, do_power,
2371 "Device Power Management control",
2372 "device on/off - Turn on/off the device\n"