2 * Copyright (C) 2009 Samsung Electronics
3 * Kyungmin Park <kyungmin.park@samsung.com>
4 * Minkyu Kang <mk7.kang@samsung.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <asm/arch/clk.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/keypad.h>
33 #include <asm/arch/mmc.h>
34 #include <asm/arch/power.h>
35 #include <asm/arch/mem.h>
36 #include <asm/arch/hs_otg.h>
37 #include <asm/arch/regs-otg.h>
38 #include <asm/errno.h>
41 #include <bmp_layout.h>
43 #include "animation_frames.h"
44 #include "gpio_setting.h"
46 DECLARE_GLOBAL_DATA_PTR;
48 #define C100_MACH_START 3000
49 #define C110_MACH_START 3100
51 static unsigned int board_rev;
52 static unsigned int battery_soc;
53 static struct s5pc110_gpio *s5pc110_gpio;
70 static struct i2c_gpio_bus_data i2c_2 = {
80 static struct i2c_gpio_bus_data i2c_gpio3 = {
90 static struct i2c_gpio_bus_data i2c_pmic = {
100 static struct i2c_gpio_bus_data i2c_gpio5 = {
110 static struct i2c_gpio_bus_data i2c_gpio6 = {
116 * i2c gpio7 - kessler
120 static struct i2c_gpio_bus_data i2c_gpio7 = {
126 * i2c gpio7 - cypress
130 static struct i2c_gpio_bus_data i2c_cypress_gpio7 = {
140 static struct i2c_gpio_bus_data i2c_gpio10 = {
146 static struct i2c_gpio_bus i2c_gpio[] = {
164 u32 get_board_rev(void)
169 static int hwrevision(int rev)
171 return (board_rev & 0xf) == rev;
178 MACH_P1P2, /* Don't remove it */
189 #define SPLIT_SCREEN_FEATURE 0x100
191 /* board is MACH_AQUILA and board is like below. */
192 #define J1_B2_BOARD 0x0200
193 #define LIMO_UNIVERSAL_BOARD 0x0400
194 #define LIMO_REAL_BOARD 0x0800
195 #define MEDIA_BOARD 0x1000
196 #define BAMBOO_BOARD 0x2000
198 /* board is MACH_KESSLER and board is like below */
199 #define ARIES_BOARD 0x4000
200 #define NEPTUNE_BOARD 0x8000
202 #define BOARD_MASK 0xFF00
204 static int c110_machine_id(void)
206 return gd->bd->bi_arch_number - C110_MACH_START;
209 static int machine_is_aquila(void)
211 return (gd->bd->bi_arch_number == MACH_AQUILA);
214 static int machine_is_tickertape(void)
216 return c110_machine_id() == MACH_TICKERTAPE;
219 static int machine_is_geminus(void)
221 return c110_machine_id() == MACH_GEMINUS;
224 static int machine_is_cypress(void)
226 return c110_machine_id() == MACH_CYPRESS;
229 static int board_is_limo_universal(void)
231 return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
234 static int board_is_limo_real(void)
236 return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
239 static int board_is_media(void)
241 return machine_is_aquila() && (board_rev & MEDIA_BOARD);
244 static int board_is_j1b2(void)
246 return machine_is_aquila() && (board_rev & J1_B2_BOARD);
250 static int machine_is_kessler(void)
252 return gd->bd->bi_arch_number == MACH_KESSLER;
255 static int board_is_neptune(void)
257 return machine_is_kessler() && (board_rev & NEPTUNE_BOARD);
261 static int machine_is_wmg160(void)
263 return c110_machine_id() == MACH_WMG160;
266 static void enable_battery(void);
268 void i2c_init_board(void)
270 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
273 if (cpu_is_s5pc100())
276 num_bus = ARRAY_SIZE(i2c_gpio);
278 if (machine_is_aquila()) {
279 i2c_gpio[I2C_GPIO6].bus->gpio_base = 0;
280 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
281 } else if (machine_is_kessler()) {
282 i2c_gpio[I2C_GPIO7].bus->gpio_base =
283 (unsigned int)&gpio->gpio_mp0_5;
284 } else if (machine_is_cypress()) {
285 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
286 i2c_gpio[I2C_GPIO7].bus->gpio_base =
287 (unsigned int)&gpio->gpio_mp0_5;
289 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
292 i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
293 i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
294 i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
295 i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
296 i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
298 i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
300 /* Reset on max17040 early */
301 if (battery_soc == 0)
305 #ifdef CONFIG_MISC_INIT_R
306 #define DEV_INFO_LEN 512
307 static char device_info[DEV_INFO_LEN];
308 static int display_info;
310 static void dprintf(const char *fmt, ...)
317 i = vsprintf(buf, fmt, args);
322 if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
323 puts("Flushing device info...\n");
327 strcat(device_info, buf);
331 #ifdef CONFIG_S5PC1XXFB
332 static void display_device_info(void)
339 set_font_color(FONT_WHITE);
340 fb_printf(device_info);
343 memset(device_info, 0x0, DEV_INFO_LEN);
345 udelay(5 * 1000 * 1000);
349 static const char *board_name[] = {
353 "P1P2", /* Don't remove it */
366 static char feature_buffer[32];
368 static char *display_features(int board, int board_rev)
371 char *buf = feature_buffer;
374 if (board == MACH_AQUILA) {
375 if (board_rev & SPLIT_SCREEN_FEATURE)
376 name = "SplitScreen";
377 if (board_rev & J1_B2_BOARD)
379 /* Limo Real or Universal */
380 if (board_rev & LIMO_REAL_BOARD)
382 else if (board_rev & LIMO_UNIVERSAL_BOARD)
383 name = "Limo Universal";
384 if (board_rev & MEDIA_BOARD)
386 if (board_rev & BAMBOO_BOARD)
388 } else if (board == MACH_KESSLER) {
389 if (board_rev & ARIES_BOARD)
391 if (board_rev & NEPTUNE_BOARD)
395 count += sprintf(buf + count, " - %s", name);
400 static char *get_board_name(int board)
402 if (board == MACH_AQUILA)
404 else if (board == MACH_KESSLER)
406 else if (board == MACH_WMG160)
408 return (char *) board_name[board];
411 static void check_board_revision(int board, int rev)
413 if (board == MACH_AQUILA) {
414 /* Limo Real or Universal */
415 if (rev & LIMO_UNIVERSAL_BOARD)
416 board_rev &= ~J1_B2_BOARD;
417 if (rev & LIMO_REAL_BOARD)
418 board_rev &= ~(J1_B2_BOARD |
419 LIMO_UNIVERSAL_BOARD);
420 if (rev & MEDIA_BOARD)
421 board_rev &= ~(J1_B2_BOARD |
422 LIMO_UNIVERSAL_BOARD);
423 if (rev & BAMBOO_BOARD)
424 board_rev &= ~(J1_B2_BOARD |
425 LIMO_UNIVERSAL_BOARD |
428 } else if (board == MACH_KESSLER) {
429 if (rev & ARIES_BOARD)
430 board_rev &= ~(J1_B2_BOARD |
431 LIMO_UNIVERSAL_BOARD);
432 if (rev & NEPTUNE_BOARD)
433 board_rev &= ~(J1_B2_BOARD |
434 LIMO_UNIVERSAL_BOARD);
436 board_rev &= ~BOARD_MASK;
439 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank, int hwrev3)
447 gpio_direction_input(bank, 2);
448 gpio_direction_input(bank, 3);
449 gpio_direction_input(bank, 4);
450 gpio_direction_input(bank, mode3);
452 gpio_set_pull(bank, 2, GPIO_PULL_NONE); /* HWREV_MODE0 */
453 gpio_set_pull(bank, 3, GPIO_PULL_NONE); /* HWREV_MODE1 */
454 gpio_set_pull(bank, 4, GPIO_PULL_NONE); /* HWREV_MODE2 */
455 gpio_set_pull(bank, mode3, GPIO_PULL_NONE); /* HWREV_MODE3 */
457 rev = gpio_get_value(bank, 2);
458 rev |= (gpio_get_value(bank, 3) << 1);
459 rev |= (gpio_get_value(bank, 4) << 2);
460 rev |= (gpio_get_value(bank, mode3) << 3);
465 static void check_hw_revision(void)
467 unsigned int board = MACH_UNIVERSAL; /* Default is Universal */
469 if (cpu_is_s5pc100()) {
470 struct s5pc100_gpio *gpio =
471 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
473 board_rev = get_hw_revision(&gpio->gpio_j0, 0);
475 /* C100 TickerTape */
477 board = MACH_TICKERTAPE;
479 struct s5pc110_gpio *gpio =
480 (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
486 * Note Check 'Aquila' board first
490 * LRA: Limo Real Aquila
491 * LUA: Limo Universal Aquila
496 * ADDR = 0xE0200000 + OFF
498 * OFF Universal BB LRA LUA OA TT SS CYP
499 * J1: 0x0264 0x10 0x10 0x00 0x00 0x00 0x00 0x00
500 * J2: 0x0284 0x01 0x10 0x00
501 * H1: 0x0C24 W 0x28 0xA8 0x1C 0x0F
502 * H3: 0x0C64 0x03 0x07 0x0F
503 * D1: 0x00C4 0x0F 0x3F 0x3F 0x0F 0xXC 0x3F
504 * I: 0x0224 0x02 0x00 0x08
505 * MP03: 0x0324 0x9x 0xbx 0x9x
506 * MP05: 0x0364 0x80 0x88
510 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
512 board_rev |= J1_B2_BOARD;
514 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
515 gpio_direction_input(&gpio->gpio_j2, 6);
518 if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
519 board_rev |= LIMO_UNIVERSAL_BOARD;
521 if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
522 board_rev |= LIMO_REAL_BOARD;
524 if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
525 board_rev |= MEDIA_BOARD;
527 /* set gpio to default value. */
528 gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
529 gpio_direction_output(&gpio->gpio_j2, 6, 0);
532 /* Workaround: C110 Aquila Rev0.6 */
533 if (board_rev == 6) {
535 board_rev |= LIMO_REAL_BOARD;
538 /* C110 Aquila Bamboo */
539 if (gpio_get_value(&gpio->gpio_j2, 0) == 1) {
541 board_rev |= BAMBOO_BOARD;
544 /* C110 TickerTape */
545 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
546 gpio_get_value(&gpio->gpio_d1, 1) == 0)
547 board = MACH_TICKERTAPE;
549 /* WMG160 - GPH3[0:4] = 0x00 */
550 if (board == MACH_TICKERTAPE) {
553 for (i = 0; i < 4; i++) {
554 if (gpio_get_value(&gpio->gpio_h3, i) != 0) {
565 /* C110 Geminus for rev0.0 */
566 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
567 gpio_direction_input(&gpio->gpio_j1, 2);
568 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
569 board = MACH_GEMINUS;
570 if ((board_rev & ~BOARD_MASK) == 3)
573 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
574 gpio_direction_output(&gpio->gpio_j1, 2, 0);
576 /* C110 Geminus for rev0.1 ~ */
577 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
578 gpio_direction_input(&gpio->gpio_j0, 6);
579 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
580 board = MACH_GEMINUS;
583 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
585 /* Kessler MP0_5[6] == 1 */
586 gpio_direction_input(&gpio->gpio_mp0_5, 6);
587 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
588 /* Cypress: Do this for cypress */
589 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
590 gpio_direction_input(&gpio->gpio_j2, 2);
591 if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
592 board = MACH_CYPRESS;
593 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
595 board = MACH_KESSLER;
596 board_rev |= ARIES_BOARD;
598 /* Neptune MP0_5[4] == 1 */
599 gpio_direction_input(&gpio->gpio_mp0_5, 4);
600 if (gpio_get_value(&gpio->gpio_mp0_5, 4) == 1) {
601 board_rev &= ~ARIES_BOARD;
602 board_rev |= NEPTUNE_BOARD;
605 gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
608 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
610 board_rev |= get_hw_revision(&gpio->gpio_j0, hwrev3);
614 if (board == MACH_AQUILA)
615 gd->bd->bi_arch_number = MACH_AQUILA;
616 else if (board == MACH_KESSLER)
617 gd->bd->bi_arch_number = MACH_KESSLER;
618 else if (cpu_is_s5pc110())
619 gd->bd->bi_arch_number = C110_MACH_START + board;
621 gd->bd->bi_arch_number = C100_MACH_START + board;
623 /* Architecture Common settings */
624 if (cpu_is_s5pc110()) {
625 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
627 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
629 setenv("updatek", "onenand erase 0x60000 0x300000; "
630 "onenand write 0x31008000 0x60000 0x300000");
634 static void show_hw_revision(void)
639 * Workaround for Rev 0.3 + CP Ver ES 3.1
642 if (board_is_limo_real()) {
644 /* default is Rev 0.4 */
650 if (machine_is_aquila())
652 else if (machine_is_kessler())
653 board = MACH_KESSLER;
654 else if (cpu_is_s5pc110())
655 board = gd->bd->bi_arch_number - C110_MACH_START;
657 board = gd->bd->bi_arch_number - C100_MACH_START;
659 check_board_revision(board, board_rev);
661 /* Set CPU Revision */
662 if (machine_is_aquila()) {
663 if (board_is_limo_real()) {
664 if ((board_rev & 0xf) < 8)
665 s5pc1xx_set_cpu_rev(0);
667 } else if (machine_is_kessler())
668 s5pc1xx_set_cpu_rev(1);
669 else if (machine_is_geminus()) {
670 if ((board_rev & 0xf) < 1)
671 s5pc1xx_set_cpu_rev(0);
672 } else if (machine_is_cypress()) {
673 s5pc1xx_set_cpu_rev(1);
675 s5pc1xx_set_cpu_rev(0);
678 dprintf("HW Revision:\t%x (%s%s) %s\n",
679 board_rev, get_board_name(board),
680 display_features(board, board_rev),
681 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
684 static void check_auto_burn(void)
686 unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
687 unsigned int count = 0;
690 if (readl(magic_base) == 0x426f6f74) { /* ASICC: Boot */
691 printf("Auto burning bootloader\n");
692 count += sprintf(buf + count, "run updateb; ");
694 if (readl(magic_base + 0x04) == 0x4b65726e) { /* ASICC: Kern */
695 printf("Auto burning kernel\n");
696 count += sprintf(buf + count, "run updatek; ");
700 count += sprintf(buf + count, "reset");
701 setenv("bootcmd", buf);
704 /* Clear the magic value */
705 writel(0xa5a55a5a, magic_base);
706 writel(0xa5a55a5a, magic_base + 0x4);
709 static void pmic_pin_init(void)
711 unsigned int reg, value;
713 if (cpu_is_s5pc100())
716 /* AP_PS_HOLD: XEINT_0: GPH0[0]
717 * Note: Don't use GPIO PS_HOLD it doesn't work
719 reg = S5PC110_PS_HOLD_CONTROL;
721 value |= S5PC110_PS_HOLD_DIR_OUTPUT |
722 S5PC110_PS_HOLD_DATA_HIGH |
723 S5PC110_PS_HOLD_OUT_EN;
726 /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
727 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
728 gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
731 static void enable_ldos(void)
733 if (cpu_is_s5pc100())
736 /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
737 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
740 static void enable_t_flash(void)
742 if (!(board_is_limo_universal() || board_is_limo_real()))
745 /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
746 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
749 static void setup_limo_real_gpios(void)
751 if (!board_is_limo_real())
755 * Note: Please write GPIO alphabet order
757 /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
758 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
761 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
762 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
764 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
765 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
767 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
768 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
769 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
772 static void setup_media_gpios(void)
774 if (!board_is_media())
778 * Note: Please write GPIO alphabet order
780 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
781 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
783 /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
784 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
785 gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
788 #define KBR3 (1 << 3)
789 #define KBR2 (1 << 2)
790 #define KBR1 (1 << 1)
791 #define KBR0 (1 << 0)
793 static void check_keypad(void)
795 unsigned int reg, value;
796 unsigned int col_num, row_num;
797 unsigned int col_mask;
798 unsigned int col_mask_shift;
799 unsigned int row_state[4];
801 unsigned int auto_download = 0;
803 if (machine_is_wmg160())
806 if (cpu_is_s5pc100()) {
807 struct s5pc100_gpio *gpio =
808 (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
813 /* Set GPH2[2:0] to KP_COL[2:0] */
814 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
815 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
816 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
818 /* Set GPH3[2:0] to KP_ROW[2:0] */
819 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
820 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
821 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
823 reg = S5PC100_KEYPAD_BASE;
824 col_mask = S5PC1XX_KEYIFCOL_MASK;
827 if (board_is_limo_real() || board_is_limo_universal()) {
835 for (i = 0; i < row_num; i++) {
836 /* Set GPH3[3:0] to KP_ROW[3:0] */
837 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
838 gpio_set_pull(&s5pc110_gpio->gpio_h3, i, GPIO_PULL_UP);
841 for (i = 0; i < col_num; i++)
842 /* Set GPH2[3:0] to KP_COL[3:0] */
843 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
845 reg = S5PC110_KEYPAD_BASE;
846 col_mask = S5PC110_KEYIFCOLEN_MASK;
850 /* KEYIFCOL reg clear */
851 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
854 for (i = 0; i < col_num; i++) {
856 value &= ~(1 << i) << col_mask_shift;
858 writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
861 value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
862 row_state[i] = ~value & ((1 << row_num) - 1);
864 printf("[%d col] row_state: 0x%x\n", i, row_state[i]);
867 /* KEYIFCOL reg clear */
868 writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
870 if (machine_is_aquila() || machine_is_kessler()) {
871 /* cam full shot & volume down */
872 if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
875 else if ((row_state[1] & 0x2))
877 } else if (machine_is_geminus())
878 /* volume down & home */
879 if ((row_state[1] & 0x2) && (row_state[2] & 0x1))
883 setenv("bootcmd", "usbdown");
886 static void enable_battery(void)
888 unsigned char val[2];
889 unsigned char addr = 0x36; /* max17040 fuel gauge */
891 i2c_set_bus_num(I2C_GPIO3);
893 if (machine_is_aquila()) {
896 } else if (machine_is_kessler())
897 i2c_set_bus_num(I2C_GPIO7);
898 else if (machine_is_tickertape()) {
900 } else if (machine_is_cypress()) {
901 i2c_set_bus_num(I2C_GPIO7);
902 } else if (machine_is_geminus()) {
904 i2c_set_bus_num(I2C_GPIO7);
907 if (i2c_probe(addr)) {
908 printf("Can't found max17040 fuel gauge\n");
914 i2c_write(addr, 0xfe, 1, val, 2);
917 static void check_battery(void)
919 unsigned char val[2];
920 unsigned char addr = 0x36; /* max17040 fuel gauge */
922 i2c_set_bus_num(I2C_GPIO3);
924 if (machine_is_aquila()) {
927 } else if (machine_is_kessler())
928 i2c_set_bus_num(I2C_GPIO7);
929 else if (machine_is_cypress()) {
930 i2c_set_bus_num(I2C_GPIO7);
931 } else if (machine_is_geminus()) {
933 i2c_set_bus_num(I2C_GPIO7);
937 if (i2c_probe(addr)) {
938 printf("Can't found max17040 fuel gauge\n");
942 i2c_read(addr, 0x04, 1, val, 1);
944 dprintf("battery:\t%d%%\n", val[0]);
946 battery_soc = val[0];
949 static void check_mhl(void)
951 unsigned char val[2];
952 unsigned char addr = 0x39; /* SIL9230 */
954 /* MHL Power enable */
955 /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
956 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
958 /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
959 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
961 /* 10ms required after reset */
965 gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
967 i2c_set_bus_num(I2C_GPIO5);
970 if (i2c_probe(addr)) {
971 printf("Can't found MHL Chip\n");
977 * set to Normal operation
980 i2c_write((0x72 >> 1), 0x08, 1, val, 1);
981 i2c_read((0x72 >> 1), 0x08, 1, val, 1);
986 * 00 = MHL termination ON
987 * 11 = MHL termination OFF
990 i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
991 i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
994 #define CHARGER_ANIMATION_FRAME 6
995 static int max8998_power_key(void)
997 unsigned char addr, val[2];
998 i2c_set_bus_num(I2C_PMIC);
1000 if (i2c_probe(addr)) {
1001 printf("Can't found max8998\n");
1005 /* Accessing IRQ1 register */
1006 i2c_read(addr, 0x00, 1, val, 1);
1007 if (val[0] & (1 << 6))
1013 static int max8998_has_ext_power_source(void)
1015 unsigned char addr, val[2];
1016 i2c_set_bus_num(I2C_PMIC);
1018 if (i2c_probe(addr)) {
1019 printf("Can't found max8998\n");
1023 /* Accessing STATUS2 register */
1024 i2c_read(addr, 0x09, 1, val, 1);
1025 if (val[0] & (1 << 5))
1031 extern void lcd_display_clear(void);
1032 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
1034 static void into_charge_mode(void)
1036 unsigned char addr = 0xCC >> 1; /* max8998 */;
1037 unsigned char val[2];
1042 ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1044 i2c_set_bus_num(I2C_PMIC);
1046 if (i2c_probe(addr)) {
1047 printf("Can't found max8998\n");
1051 printf("Charge Mode\n");
1053 i2c_read(addr, 0x0C, 1, val, 1);
1054 val[0] &= ~(0x7 << 0);
1055 val[0] &= ~(0x7 << 5);
1056 val[0] |= 5; /* 600mA */
1057 val[0] |= (3 << 5); /* Stop at 150mA(25%) */
1058 i2c_write(addr, 0x0C, 1, val, 1);
1060 #ifdef CONFIG_S5PC1XXFB
1063 /* TODO: write the image-text for the charger */
1065 level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1066 if (level >= CHARGER_ANIMATION_FRAME)
1067 level = CHARGER_ANIMATION_FRAME - 1;
1069 for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1070 bmp_addr[i] = (ulong)battery_charging_animation[i];
1072 lcd_display_clear();
1073 for (i = 0; i < 3; i++) {
1074 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1077 bmp = gunzip_bmp(bmp_addr[j], &len);
1078 lcd_display_bitmap((ulong) bmp, 140, 202);
1081 for (k = 0; k < 10; k++)
1082 if (max8998_power_key()) {
1083 lcd_display_clear();
1085 } else if (!max8998_has_ext_power_source()) {
1086 lcd_display_clear();
1095 /* EVT0: sleep 1, EVT1: sleep */
1096 if (s5pc1xx_get_cpu_rev() == 0) {
1097 run_command("sleep 1", 0);
1101 run_command("sleep", 0);
1104 static void check_micro_usb(int intr)
1107 unsigned char val[2];
1108 static int started_charging_once = 0;
1111 if (cpu_is_s5pc100())
1114 if (board_is_limo_real()) {
1115 if (hwrevision(0) || hwrevision(1))
1119 i2c_set_bus_num(I2C_PMIC);
1121 if (machine_is_kessler())
1122 i2c_set_bus_num(I2C_GPIO6);
1123 else if (machine_is_cypress()) {
1124 i2c_set_bus_num(I2C_GPIO6);
1125 } else if (machine_is_geminus()) {
1127 i2c_set_bus_num(I2C_GPIO6);
1128 } else if (machine_is_wmg160())
1129 i2c_set_bus_num(I2C_GPIO6);
1131 addr = 0x25; /* fsa9480 */
1132 if (i2c_probe(addr)) {
1133 printf("Can't found fsa9480\n");
1137 /* Clear Interrupt */
1139 i2c_read(addr, 0x03, 1, val, 2);
1143 /* Read Device Type 1 */
1144 i2c_read(addr, 0x0a, 1, val, 1);
1146 #define FSA_DEV1_CHARGER (1 << 6)
1147 #define FSA_DEV1_UART (1 << 3)
1148 #define FSA_DEV1_USB (1 << 2)
1149 #define FSA_DEV2_JIG_USB_OFF (1 << 1)
1150 #define FSA_DEV2_JIG_USB_ON (1 << 0)
1153 * If USB, use default 475mA
1154 * If Charger, use 600mA and go to charge mode
1156 if ((val[0] & FSA_DEV1_CHARGER) && !started_charging_once) {
1157 started_charging_once = 1;
1161 /* If Factory Mode is Boot ON-USB, go to download mode */
1162 i2c_read(addr, 0x07, 1, val, 1);
1164 #define FSA_ADC_FAC_USB_OFF 0x18
1165 #define FSA_ADC_FAC_USB_ON 0x19
1166 #define FSA_ADC_FAC_UART 0x1d
1168 if (val[0] == FSA_ADC_FAC_USB_ON || val[0] == FSA_ADC_FAC_USB_OFF)
1169 setenv("bootcmd", "usbdown");
1171 path = getenv("usb");
1173 if (!strncmp(path, "cp", 2))
1174 run_command("microusb cp", 0);
1177 static void micro_usb_switch(int path)
1180 unsigned char val[2];
1182 i2c_set_bus_num(I2C_PMIC);
1184 if (machine_is_kessler())
1185 i2c_set_bus_num(I2C_GPIO6);
1186 else if (machine_is_cypress()) {
1187 i2c_set_bus_num(I2C_GPIO6);
1188 } else if (machine_is_geminus()) {
1190 i2c_set_bus_num(I2C_GPIO6);
1191 } else if (machine_is_wmg160()) {
1192 i2c_set_bus_num(I2C_GPIO6);
1196 addr = 0x25; /* fsa9480 */
1197 if (i2c_probe(addr)) {
1198 printf("Can't found fsa9480\n");
1203 val[0] = 0x90; /* VAUDIO */
1205 val[0] = (1 << 5) | (1 << 2); /* DHOST */
1207 i2c_write(addr, 0x13, 1, val, 1); /* MANSW1 */
1209 i2c_read(addr, 0x2, 1, val, 1);
1210 val[0] &= ~(1 << 2); /* Manual switching */
1211 i2c_write(addr, 0x2, 1, val, 1);
1214 #define MAX8998_REG_ONOFF1 0x11
1215 #define MAX8998_REG_ONOFF2 0x12
1216 #define MAX8998_REG_ONOFF3 0x13
1217 #define MAX8998_REG_LDO7 0x21
1218 #define MAX8998_REG_LDO17 0x29
1220 #define MAX8998_LDO3 (1 << 2)
1222 #define MAX8998_LDO6 (1 << 7)
1223 #define MAX8998_LDO7 (1 << 6)
1224 #define MAX8998_LDO8 (1 << 5)
1225 #define MAX8998_LDO9 (1 << 4)
1226 #define MAX8998_LDO10 (1 << 3)
1227 #define MAX8998_LDO11 (1 << 2)
1228 #define MAX8998_LDO12 (1 << 1)
1229 #define MAX8998_LDO13 (1 << 0)
1231 #define MAX8998_LDO14 (1 << 7)
1232 #define MAX8998_LDO15 (1 << 6)
1233 #define MAX8998_LDO16 (1 << 5)
1234 #define MAX8998_LDO17 (1 << 4)
1237 static void init_pmic(void)
1240 unsigned char val[2];
1242 if (cpu_is_s5pc100())
1245 i2c_set_bus_num(I2C_PMIC);
1247 addr = 0xCC >> 1; /* max8998 */
1248 if (i2c_probe(addr)) {
1249 if (i2c_probe(addr)) {
1250 printf("Can't found max8998\n");
1256 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1257 val[0] &= ~MAX8998_LDO3;
1258 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1261 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1263 * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1264 * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1266 val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1267 MAX8998_LDO12 | MAX8998_LDO13);
1269 if (machine_is_kessler())
1270 val[0] |= MAX8998_LDO7; /* LDO7: VLCD_1.8V */
1272 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1273 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1275 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1277 * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1278 * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1280 val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1281 MAX8998_LDO16 | MAX8998_LDO17);
1283 if (machine_is_kessler())
1284 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1286 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1287 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
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;
1296 struct gpio_external *ge;
1298 struct s5pc1xx_gpio_item *mr;
1302 if (cpu_is_s5pc100())
1305 /* Only Limo real and kessler supports worked for sleep currnet */
1306 if (machine_is_aquila()) {
1307 if (board_is_limo_real())
1311 } else if (machine_is_kessler()) {
1313 } else if (machine_is_geminus()) {
1318 if (machine_is_aquila()) {
1319 /* Aquila rev 0.8 or lower */
1320 p = aquila_powerdown_modes;
1321 ge = aquila_external_powerdown_modes;
1322 mr = aquila_mirror_powerdown_mode;
1323 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1324 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1325 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1326 } else if (machine_is_kessler()) {
1327 /* Aquila rev 0.9 */
1328 p = kessler_powerdown_modes;
1329 ge = kessler_external_powerdown_modes;
1330 mr = kessler_mirror_powerdown_mode;
1331 n_p = ARRAY_SIZE(kessler_powerdown_modes);
1332 n_ge = ARRAY_SIZE(kessler_external_powerdown_modes);
1333 n_mr = ARRAY_SIZE(kessler_mirror_powerdown_mode);
1334 } else if (machine_is_geminus()) {
1335 if (hwrevision(1)) {
1336 /* Same as Aquila rev 0.9 */
1338 p = kessler_powerdown_modes;
1339 ge = kessler_external_powerdown_modes;
1340 mr = kessler_mirror_powerdown_mode;
1341 n_p = ARRAY_SIZE(kessler_powerdown_modes);
1342 n_ge = ARRAY_SIZE(kessler_external_powerdown_modes);
1343 n_mr = ARRAY_SIZE(kessler_mirror_powerdown_mode);
1345 p = aquila_powerdown_modes;
1346 ge = aquila_external_powerdown_modes;
1347 mr = aquila_mirror_powerdown_mode;
1348 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1349 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1350 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1352 } else if (hwrevision(0)) {
1353 /* Same as Aquila rev 0.8 or lower */
1354 p = aquila_powerdown_modes;
1355 ge = aquila_external_powerdown_modes;
1356 mr = aquila_mirror_powerdown_mode;
1357 n_p = ARRAY_SIZE(aquila_powerdown_modes);
1358 n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1359 n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1361 return; /* Not supported */
1365 bank = &gpio->gpio_a0;
1367 for (i = 0; i < n_p; i++, p++, bank++) {
1368 writel(p->conpdn, &bank->pdn_con);
1369 writel(p->pudpdn, &bank->pdn_pull);
1372 writel(0xff0022b0, (unsigned int *)0xF0000000);
1373 writel(0xff0022b0, (unsigned int *)0xF1400000);
1375 bank = &gpio->gpio_h0;
1377 for (i = 0; i < n_ge; i++) {
1378 writel(ge->con, &bank->con);
1379 writel(ge->dat, &bank->dat);
1380 writel(ge->pud, &bank->pull);
1386 for (i = 0; i < n_mr; i++) {
1387 unsigned int reg = readl(&mr->bank->pdn_con);
1388 reg &= ~(1 << mr->number);
1389 if (readl(&mr->bank->dat) & (1 << mr->number))
1390 reg |= 1 << mr->number;
1391 writel(reg, &mr->bank->pdn_con);
1393 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1400 #include "../../../drivers/video/s5p-spi.h"
1402 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1403 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1405 struct spi_platform_data spi_pd;
1407 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1409 void lcd_cfg_gpio(void)
1411 unsigned int i, f3_end = 4;
1413 for (i = 0; i < 8; i++) {
1414 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1415 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1416 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1417 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1418 /* pull-up/down disable */
1419 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1420 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1421 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1423 /* drive strength to max (24bit) */
1424 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4X);
1425 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1426 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4X);
1427 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1428 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4X);
1429 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1432 /* set DISPLAY_DE_B pin for dual rgb mode. */
1433 if (board_is_media())
1436 for (i = 0; i < f3_end; i++) {
1437 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1438 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1439 /* pull-up/down disable */
1440 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1441 /* drive strength to max (24bit) */
1442 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4X);
1443 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1445 /* display output path selection (only [1:0] valid) */
1446 writel(0x2, 0xE0107008);
1448 /* gpio pad configuration for LCD reset. */
1449 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1451 /* gpio pad configuration for LCD ON. */
1452 gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1454 /* LCD_BACKLIGHT_EN */
1455 if (machine_is_geminus())
1456 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1459 * gpio pad configuration for
1460 * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1462 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1463 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1464 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1465 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1467 if (machine_is_aquila() || machine_is_kessler()) {
1468 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1470 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1472 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1474 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1477 if (board_is_neptune())
1478 s6d16a0x_set_platform_data(&spi_pd);
1480 s6e63m0_set_platform_data(&spi_pd);
1481 if (board_is_media())
1486 if (machine_is_cypress()) {
1487 #if 0 /* universal cypress */
1489 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1492 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1494 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1496 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1498 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1500 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1501 #if 0 /* universal cypress */
1502 pd_cs.bank = &gpio_base->gpio_mp0_1;
1505 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1507 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1509 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1514 /* these data would be sent to s6e63m0 lcd panel driver. */
1515 s6e63m0_set_platform_data(&spi_pd);
1521 void backlight_on(unsigned int onoff)
1523 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1526 if (machine_is_geminus())
1527 gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1529 if (machine_is_geminus())
1530 gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1534 void reset_lcd(void)
1536 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1538 if (machine_is_aquila() || machine_is_kessler() || machine_is_geminus())
1539 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1540 if (machine_is_cypress())
1541 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1544 void lcd_power_on(unsigned int onoff)
1546 struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1549 if (machine_is_aquila() || machine_is_geminus())
1550 gpio_set_value(&gpio->gpio_j1, 3, 1);
1552 if (machine_is_cypress())
1553 gpio_set_value(&gpio->gpio_g2, 2, 1);
1555 if (machine_is_kessler()) {
1557 unsigned char val[2];
1558 unsigned char val2[2];
1560 gpio_set_value(&gpio->gpio_j1, 3, 1);
1562 i2c_set_bus_num(I2C_PMIC);
1563 addr = 0xCC >> 1; /* max8998 */
1564 if (i2c_probe(addr)) {
1565 printf("Can't found max8998\n");
1568 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1569 val[0] &= ~(MAX8998_LDO17);
1570 val[0] |= MAX8998_LDO17; /* LDO17: VCC_3.0V_LCD */
1571 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1573 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1574 val[0] |= MAX8998_LDO17;
1576 i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1577 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1579 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1580 val[0] |= MAX8998_LDO7;
1582 i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1583 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1586 if (machine_is_aquila() || machine_is_geminus())
1587 gpio_set_value(&gpio->gpio_j1, 3, 0);
1589 if (machine_is_cypress())
1590 gpio_set_value(&gpio->gpio_g2, 2, 0);
1592 if (machine_is_kessler()) {
1594 unsigned char val[2];
1596 i2c_set_bus_num(I2C_PMIC);
1597 addr = 0xCC >> 1; /* max8998 */
1598 if (i2c_probe(addr)) {
1599 printf("Can't found max8998\n");
1603 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1604 val[0] &= ~(1 << 7);
1605 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1606 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1608 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1609 val[0] &= ~MAX8998_LDO17;
1610 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1611 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1616 extern void s6e63m0_cfg_ldo(void);
1617 extern void s6e63m0_enable_ldo(unsigned int onoff);
1618 extern void s6d16a0x_cfg_ldo(void);
1619 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1621 int s5p_no_lcd_support(void)
1623 if (machine_is_wmg160())
1628 void init_panel_info(vidinfo_t *vid)
1630 vid->cfg_gpio = NULL;
1631 vid->reset_lcd = NULL;
1632 vid->backlight_on = NULL;
1633 vid->lcd_power_on = NULL;
1635 vid->cfg_ldo = NULL;
1636 vid->enable_ldo = NULL;
1638 vid->init_delay = 0;
1639 vid->reset_delay = 0;
1640 vid->power_on_delay = 0;
1645 vid->vl_width = 480;
1646 vid->vl_height = 800;
1648 vid->dual_lcd_enabled = 0;
1650 if (board_is_media()) {
1653 vid->vl_width = 960;
1654 vid->vl_height = 800;
1656 /* enable dual lcd mode. */
1657 vid->dual_lcd_enabled = 1;
1660 vid->vl_clkp = CONFIG_SYS_HIGH;
1661 vid->vl_hsp = CONFIG_SYS_LOW;
1662 vid->vl_vsp = CONFIG_SYS_LOW;
1663 vid->vl_dp = CONFIG_SYS_HIGH;
1666 /* S6E63M0 LCD Panel */
1675 if (machine_is_aquila() || machine_is_kessler() || machine_is_cypress()) {
1676 vid->cfg_gpio = lcd_cfg_gpio;
1677 vid->reset_lcd = reset_lcd;
1678 vid->backlight_on = backlight_on;
1679 vid->lcd_power_on = lcd_power_on;
1680 vid->cfg_ldo = s6e63m0_cfg_ldo;
1681 vid->enable_ldo = s6e63m0_enable_ldo;
1683 vid->init_delay = 25000;
1684 vid->reset_delay = 120000;
1687 if (board_is_neptune()) {
1691 vid->vl_width = 320;
1692 vid->vl_height = 480;
1694 vid->vl_clkp = CONFIG_SYS_HIGH;
1695 vid->vl_hsp = CONFIG_SYS_HIGH;
1696 vid->vl_vsp = CONFIG_SYS_HIGH;
1697 vid->vl_dp = CONFIG_SYS_LOW;
1700 /* disable dual lcd mode. */
1701 vid->dual_lcd_enabled = 0;
1703 /* S6D16A0X LCD Panel */
1712 vid->cfg_gpio = lcd_cfg_gpio;
1713 vid->backlight_on = NULL;
1714 vid->lcd_power_on = lcd_power_on;
1715 vid->reset_lcd = reset_lcd;
1716 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1717 vid->enable_ldo = s6d16a0x_enable_ldo;
1719 vid->init_delay = 10000;
1720 vid->power_on_delay = 10000;
1721 vid->reset_delay = 1000;
1725 if (machine_is_geminus()) {
1729 vid->vl_width = 1024,
1730 vid->vl_height = 600,
1731 vid->vl_clkp = CONFIG_SYS_LOW,
1732 vid->vl_hsp = CONFIG_SYS_HIGH,
1733 vid->vl_vsp = CONFIG_SYS_HIGH,
1734 vid->vl_dp = CONFIG_SYS_LOW,
1745 vid->cfg_gpio = lcd_cfg_gpio;
1746 vid->reset_lcd = reset_lcd;
1747 vid->backlight_on = backlight_on;
1748 vid->lcd_power_on = lcd_power_on;
1754 vid->vl_width = 480,
1755 vid->vl_height = 800,
1756 vid->vl_clkp = CONFIG_SYS_HIGH,
1757 vid->vl_hsp = CONFIG_SYS_LOW,
1758 vid->vl_vsp = CONFIG_SYS_LOW,
1759 vid->vl_dp = CONFIG_SYS_HIGH,
1775 vid->vl_width = 1024,
1776 vid->vl_height = 600,
1777 vid->vl_clkp = CONFIG_SYS_HIGH,
1778 vid->vl_hsp = CONFIG_SYS_HIGH,
1779 vid->vl_vsp = CONFIG_SYS_HIGH,
1780 vid->vl_dp = CONFIG_SYS_LOW,
1783 /* AMS701KA AMOLED Panel. */
1795 static void setup_meminfo(void)
1797 char meminfo[64] = {0, };
1798 int count = 0, size, real;
1800 size = gd->bd->bi_dram[0].size >> 20;
1801 count += sprintf(meminfo + count, "mem=%dM", size);
1803 /* Each Chip Select can't exceed the 256MiB */
1804 size = gd->bd->bi_dram[1].size >> 20;
1805 real = min(size, 256);
1806 count += sprintf(meminfo + count, " mem=%dM@0x%x",
1807 real, (unsigned int)gd->bd->bi_dram[1].start);
1811 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1812 (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1815 setenv("meminfo", meminfo);
1818 int misc_init_r(void)
1821 /* It should be located at first */
1824 if (machine_is_aquila() || machine_is_kessler()) {
1825 if (board_is_neptune())
1826 setenv("lcdinfo", "lcd=s6d16a0x");
1827 else if (board_is_media())
1828 setenv("lcdinfo", "lcd=s6e63m0");
1830 setenv("lcdinfo", "lcd=s6e63m0");
1832 if (machine_is_geminus())
1833 setenv("lcdinfo", "lcd=lms480jc01");
1834 if (machine_is_cypress())
1835 setenv("lcdinfo", "lcd=s6e63m0");
1841 /* Set proper PMIC pins */
1844 /* Check auto burning */
1847 /* To power up I2C2 */
1850 /* Enable T-Flash at Limo Real or Limo Universal */
1853 /* Setup Limo Real board GPIOs */
1854 setup_limo_real_gpios();
1856 /* Setup Media board GPIOs */
1857 setup_media_gpios();
1859 /* To usbdown automatically */
1865 #ifdef CONFIG_S5PC1XXFB
1866 display_device_info();
1869 setup_power_down_mode_registers();
1871 /* check max17040 */
1881 int board_init(void)
1883 /* Set Initial global variables */
1884 s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1886 gd->bd->bi_arch_number = MACH_AQUILA;
1887 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1889 /* Check H/W Revision */
1890 check_hw_revision();
1897 unsigned int base, memconfig0, size;
1898 unsigned int memconfig1, sz = 0;
1900 if (cpu_is_s5pc100()) {
1901 /* In mem setup, we swap the bank. So below size is correct */
1902 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1903 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1904 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1907 /* In S5PC110, we can't swap the DMC0/1 */
1908 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1909 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1911 base = S5PC110_DMC1_BASE;
1912 /* DMC configuration */
1913 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1914 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1916 size = (memconfig0 >> 16) & 0xFF;
1917 size = ((unsigned char) ~size) + 1;
1920 * (0x07 + 1) * 16 = 128 MiB
1921 * (0x0f + 1) * 16 = 256 MiB
1926 * Aquila Rev0.5 4G3G1G
1927 * Aquila Rev0.8 4G3G1G
1928 * Aquila Rev0.9 4G3G1G
1930 if (machine_is_aquila() || machine_is_kessler())
1931 if (hwrevision(5) || hwrevision(8) || hwrevision(9)) {
1932 memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1934 sz = (memconfig1 >> 16) & 0xFF;
1935 sz = ((unsigned char) ~sz) + 1;
1941 * bi_dram[1].size contains all DMC1 memory size
1943 gd->bd->bi_dram[1].size = (size + sz) << 20;
1948 /* Used for sleep test */
1949 static unsigned char saved_val[4][2];
1950 void board_sleep_init_late(void)
1952 /* CODEC_LDO_EN: GPF3[4] */
1953 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1954 /* CODEC_XTAL_EN: GPH3[2] */
1955 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1957 /* MMC T_FLASH off */
1958 gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1960 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1961 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1962 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1966 void board_sleep_init(void)
1969 unsigned char val[2];
1971 i2c_set_bus_num(I2C_PMIC);
1973 if (i2c_probe(addr)) {
1974 printf("Can't find max8998\n");
1979 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1980 saved_val[0][0] = val[0];
1981 saved_val[0][1] = val[1];
1982 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1983 (1 << 1) | (1 << 0));
1984 i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1985 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1987 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1988 saved_val[1][0] = val[0];
1989 saved_val[1][1] = val[1];
1990 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1991 (1 << 2) | (1 << 1) | (1 << 0));
1993 i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1994 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1996 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1997 saved_val[2][0] = val[0];
1998 saved_val[2][1] = val[1];
1999 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
2000 i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2001 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2003 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2004 saved_val[3][0] = val[0];
2005 saved_val[3][1] = val[1];
2006 val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2007 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2008 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2009 printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2010 __FILE__, __LINE__);
2013 void board_sleep_resume(void)
2016 unsigned char val[2];
2020 i2c_set_bus_num(I2C_PMIC);
2022 if (i2c_probe(addr)) {
2023 printf("Can't find max8998\n");
2028 i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2029 i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2031 i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2032 i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2034 i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2035 i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2037 i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2038 i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2039 printf("Waked up.\n");
2041 /* check max17040 */
2048 #if defined(CONFIG_USB_GADGET_S3C_UDC_OTG)
2050 static int s5pc1xx_phy_control(int on)
2054 if (on && !status) {
2055 // printf("turning USB power on\n");
2056 #ifdef CONFIG_CMD_PMIC
2057 run_command("pmic ldo 3 on", 0);
2060 if (board_is_limo_universal() ||
2061 board_is_limo_real() ||
2063 /* check usb path */
2064 if (board_is_limo_real() && !hwrevision(6))
2068 if (machine_is_tickertape())
2069 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2070 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2072 /* USB Path to AP */
2073 micro_usb_switch(0);
2075 } else if (!on && status) {
2076 // printf("turning USB power off\n");
2077 #ifdef CONFIG_CMD_PMIC
2078 run_command("pmic ldo 3 off", 0);
2085 struct s3c_plat_otg_data s5pc110_otg_data = {
2086 .phy_control = s5pc1xx_phy_control,
2087 .regs_phy = S5PC110_PHY_BASE,
2088 .regs_otg = S5PC110_OTG_BASE,
2091 int board_eth_init(bd_t *bis)
2095 if (cpu_is_s5pc100())
2098 s3c_udc_probe(&s5pc110_otg_data);
2099 if (usb_eth_initialize(bis) >= 0)
2105 #ifdef CONFIG_CMD_USBDOWN
2106 int usb_board_init(void)
2108 #ifdef CONFIG_CMD_PMIC
2109 run_command("pmic ldo 3 on", 0);
2112 if (cpu_is_s5pc100()) {
2113 #ifdef CONFIG_HARD_I2C
2114 uchar val[2] = {0,};
2117 if (i2c_read(0x66, 0, 1, val, 2)) {
2118 printf("i2c_read error\n");
2125 if (i2c_write(0x66, 0, 1, val, 2)) {
2126 printf("i2c_write error\n");
2129 i2c_read(0x66, 0, 1, val, 2);
2135 if (board_is_limo_universal() ||
2136 board_is_limo_real() ||
2138 /* check usb path */
2139 if (board_is_limo_real() && !hwrevision(6))
2143 if (machine_is_tickertape())
2144 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2145 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2147 /* USB Path to AP */
2148 micro_usb_switch(0);
2154 #ifdef CONFIG_GENERIC_MMC
2155 int s5p_no_mmc_support(void)
2157 if (machine_is_wmg160())
2162 int board_mmc_init(bd_t *bis)
2166 struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2169 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2170 if (machine_is_kessler())
2171 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2173 if (machine_is_wmg160())
2176 /* MMC0 Clock source = SCLKMPLL */
2177 reg = readl(&clk->src4);
2180 writel(reg, &clk->src4);
2182 reg = readl(&clk->div4);
2185 /* set div value near 50MHz */
2186 clock = get_pll_clk(MPLL) / 1000000;
2187 for (i = 0; i < 0xf; i++) {
2188 if ((clock / (i + 1)) <= 50) {
2194 writel(reg, &clk->div4);
2200 * GPG0[2] SD_0_CDn -> Not used
2201 * GPG0[3:6] SD_0_DATA[0:3]
2203 for (i = 0; i < 7; i++) {
2206 /* GPG0[0:6] special function 2 */
2207 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2208 /* GPG0[0:6] pull disable */
2209 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2210 /* GPG0[0:6] drv 4x */
2211 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4X);
2214 return s5pc1xx_mmc_init(0);
2218 #ifdef CONFIG_CMD_PMIC
2219 static int pmic_status(void)
2221 unsigned char addr, val[2];
2224 i2c_set_bus_num(I2C_PMIC);
2226 if (i2c_probe(addr)) {
2227 printf("Can't found max8998\n");
2232 i2c_read(addr, reg, 1, val, 1);
2233 for (i = 7; i >= 4; i--)
2234 printf("BUCK%d %s\n", 7 - i + 1,
2235 val[0] & (1 << i) ? "on" : "off");
2237 printf("LDO%d %s\n", 5 - i,
2238 val[0] & (1 << i) ? "on" : "off");
2240 i2c_read(addr, reg, 1, val, 1);
2241 for (i = 7; i >= 0; i--)
2242 printf("LDO%d %s\n", 7 - i + 6,
2243 val[0] & (1 << i) ? "on" : "off");
2245 i2c_read(addr, reg, 1, val, 1);
2246 for (i = 7; i >= 4; i--)
2247 printf("LDO%d %s\n", 7 - i + 14,
2248 val[0] & (1 << i) ? "on" : "off");
2251 i2c_read(addr, reg, 1, val, 1);
2252 for (i = 7; i >= 6; i--)
2253 printf("SAFEOUT%d %s\n", 7 - i + 1,
2254 val[0] & (1 << i) ? "on" : "off");
2258 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2260 unsigned char addr, val[2];
2261 unsigned int reg, shift;
2269 } else if (ldo <= 13) {
2272 } else if (ldo <= 17) {
2274 shift = 17 - ldo + 4;
2281 shift = 4 - buck + 4;
2282 } else if (safeout) {
2286 shift = 8 - safeout;
2290 i2c_set_bus_num(I2C_PMIC);
2292 if (i2c_probe(addr)) {
2293 printf("Can't found max8998\n");
2297 i2c_read(addr, reg, 1, val, 1);
2299 val[0] |= (1 << shift);
2301 val[0] &= ~(1 << shift);
2302 i2c_write(addr, reg, 1, val, 1);
2303 i2c_read(addr, reg, 1, val, 1);
2306 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2307 val[0] & (1 << shift) ? "on" : "off");
2309 printf("buck %d value 0x%x, %s\n", buck, val[0],
2310 val[0] & (1 << shift) ? "on" : "off");
2312 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2313 val[0] & (1 << shift) ? "on" : "off");
2318 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2320 int buck = 0, ldo = 0, safeout = 0, on = -1;
2324 if (strncmp(argv[1], "status", 6) == 0)
2325 return pmic_status();
2328 if (strncmp(argv[1], "ldo", 3) == 0)
2329 ldo = simple_strtoul(argv[2], NULL, 10);
2330 else if (strncmp(argv[1], "buck", 4) == 0)
2331 buck = simple_strtoul(argv[2], NULL, 10);
2332 else if (strncmp(argv[1], "safeout", 7) == 0)
2333 safeout = simple_strtoul(argv[2], NULL, 10);
2337 if (strncmp(argv[3], "on", 2) == 0)
2339 else if (strncmp(argv[3], "off", 3) == 0)
2344 return pmic_ldo_control(buck, ldo, safeout, on);
2355 pmic, CONFIG_SYS_MAXARGS, 1, do_pmic,
2356 "PMIC LDO & BUCK control",
2357 "status - Display PMIC LDO & BUCK status\n"
2358 "pmic ldo num on/off - Turn on/off the LDO\n"
2359 "pmic buck num on/off - Turn on/off the BUCK\n"
2360 "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2364 #ifdef CONFIG_CMD_DEVICE_POWER
2378 static void power_display_devices(void)
2380 printf("devices:\n");
2381 printf("\t%d - touch\n", POWER_TOUCH);
2382 printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2383 printf("\t%d - LCD\n", POWER_LCD);
2384 printf("\t%d - Haptic\n", POWER_HAPTIC);
2385 printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2386 printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2387 printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2388 printf("\t%d - HDMI\n", POWER_HDMI);
2391 static int power_hdmi(int on)
2393 /* HDMI_EN1: GPJ2[2] */
2394 gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2395 /* MHL_ON: GPJ2[3] */
2396 gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2400 static int power_bt_wifi(int on)
2402 /* WLAN_BT_EN: GPB[5] */
2403 gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2407 static int power_fm_radio(int on)
2409 /* FM_BUS_nRST: GPJ2[5] */
2410 gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2414 static int power_audio_codec(int on)
2416 /* CODEC_LDO_EN: GPF3[4] */
2417 gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2418 /* CODEC_XTAL_EN: GPH3[2] */
2419 gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2423 static int power_haptic(int on)
2425 /* HAPTIC_ON: GPJ1[1] */
2426 gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2430 static int power_lcd(int on)
2432 /* MLCD_ON: GPJ1[3] */
2433 gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2437 static int power_touch(int on)
2439 /* TOUCH_EN: GPG3[6] */
2440 gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2444 static int power_3_touchkey(int on)
2447 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2448 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2449 if (board_rev & J1_B2_BOARD)
2450 gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2452 gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2454 /* 3_TOUCH_CE - GPJ2[6] */
2455 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2457 /* 3_TOUCH_CE - GPJ2[6] */
2458 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
2463 unsigned char val[2];
2464 unsigned char addr = 0x20; /* mcs5000 3-touchkey */
2470 i2c_set_bus_num(I2C_GPIO10);
2472 /* Workaround to probe */
2473 if (i2c_probe(addr)) {
2474 if (i2c_probe(addr)) {
2475 printf("Can't found 3 touchkey\n");
2480 #define MCS5000_TK_HW_VERSION 0x06
2481 #define MCS5000_TK_FW_VERSION 0x0A
2482 #define MCS5000_TK_MI_VERSION 0x0B
2484 reg = MCS5000_TK_MI_VERSION;
2485 i2c_read(addr, reg, 1, val, 1);
2486 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2487 reg = MCS5000_TK_HW_VERSION;
2488 i2c_read(addr, reg, 1, val, 1);
2489 printf("H/W 0x%x, ", val[0]);
2490 reg = MCS5000_TK_FW_VERSION;
2491 i2c_read(addr, reg, 1, val, 1);
2492 printf("F/W 0x%x\n", val[0]);
2497 static int power_control(int device, int on)
2501 return power_touch(on);
2502 case POWER_3_TOUCHKEY:
2503 return power_3_touchkey(on);
2505 return power_lcd(on);
2507 return power_haptic(on);
2508 case POWER_AUDIO_CODEC:
2509 return power_audio_codec(on);
2510 case POWER_FM_RADIO:
2511 return power_fm_radio(on);
2513 return power_bt_wifi(on);
2515 return power_hdmi(on);
2517 printf("I don't know device %d\n", device);
2523 static int power_on(int on)
2526 power_3_touchkey(on);
2529 power_audio_codec(on);
2537 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2541 if (!machine_is_aquila() && !machine_is_kessler())
2546 if (strncmp(argv[1], "on", 2) == 0)
2548 if (strncmp(argv[1], "off", 3) == 0)
2552 device = simple_strtoul(argv[1], NULL, 10);
2556 if (strncmp(argv[2], "on", 2) == 0)
2558 else if (strncmp(argv[2], "off", 3) == 0)
2562 return power_control(device, on);
2568 power_display_devices();
2573 power, CONFIG_SYS_MAXARGS, 1, do_power,
2574 "Device Power Management control",
2575 "device on/off - Turn on/off the device\n"
2578 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2582 if (strncmp(argv[1], "cp", 2) == 0) {
2583 micro_usb_switch(1);
2584 pmic_ldo_control(0, 0, 2, 1);
2585 setenv("usb", "cp");
2586 } else if (strncmp(argv[1], "ap", 2) == 0) {
2587 micro_usb_switch(0);
2588 pmic_ldo_control(0, 0, 2, 0);
2589 setenv("usb", "ap");
2599 printf("USB Path is set to %s\n", getenv("usb"));
2605 microusb, CONFIG_SYS_MAXARGS, 1, do_microusb,
2607 "cp - switch to CP\n"
2608 "microusb ap - switch to AP\n"