s5pc110: wmg160: No MMC & LCD support
[kernel/u-boot.git] / board / samsung / universal / universal.c
1 /*
2  * Copyright (C) 2009 Samsung Electronics
3  * Kyungmin Park <kyungmin.park@samsung.com>
4  * Minkyu Kang <mk7.kang@samsung.com>
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
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.
13  *
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.
18  *
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,
22  * MA 02111-1307 USA
23  */
24
25 #include <common.h>
26 #include <i2c.h>
27 #include <malloc.h>
28 #include <asm/io.h>
29 #include <asm/arch/clk.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/keypad.h>
33 #include <asm/arch/mmc.h>
34 #include <asm/arch/power.h>
35 #include <asm/arch/mem.h>
36 #include <asm/errno.h>
37 #include <fbutils.h>
38 #include <lcd.h>
39 #include <bmp_layout.h>
40
41 #include "animation_frames.h"
42 #include "gpio_setting.h"
43
44 DECLARE_GLOBAL_DATA_PTR;
45
46 #define C100_MACH_START                 3000
47 #define C110_MACH_START                 3100
48
49 /* FIXME Neptune workaround */
50 #define USE_NEPTUNE_BOARD
51 #undef USE_NEPTUNE_BOARD
52
53 static unsigned int board_rev;
54 static unsigned int battery_soc;
55 static struct s5pc110_gpio *s5pc110_gpio;
56
57 enum {
58         I2C_2,
59         I2C_GPIO3,
60         I2C_PMIC,
61         I2C_GPIO5,
62         I2C_GPIO6,
63         I2C_GPIO7,
64         I2C_GPIO10,
65 };
66
67 /*
68  * i2c 2
69  * SDA: GPD1[4]
70  * SCL: GPD1[5]
71  */
72 static struct i2c_gpio_bus_data i2c_2 = {
73         .sda_pin        = 4,
74         .scl_pin        = 5,
75 };
76
77 /*
78  * i2c gpio3
79  * SDA: GPJ3[6]
80  * SCL: GPJ3[7]
81  */
82 static struct i2c_gpio_bus_data i2c_gpio3 = {
83         .sda_pin        = 6,
84         .scl_pin        = 7,
85 };
86
87 /*
88  * i2c pmic
89  * SDA: GPJ4[0]
90  * SCL: GPJ4[3]
91  */
92 static struct i2c_gpio_bus_data i2c_pmic = {
93         .sda_pin        = 0,
94         .scl_pin        = 3,
95 };
96
97 /*
98  * i2c gpio5
99  * SDA: MP05[3]
100  * SCL: MP05[2]
101  */
102 static struct i2c_gpio_bus_data i2c_gpio5 = {
103         .sda_pin        = 3,
104         .scl_pin        = 2,
105 };
106
107 /*
108  * i2c gpio6
109  * SDA: GPJ3[4]
110  * SCL: GPJ3[5]
111  */
112 static struct i2c_gpio_bus_data i2c_gpio6 = {
113         .sda_pin        = 4,
114         .scl_pin        = 5,
115 };
116
117 /*
118  * i2c gpio7 - aries
119  * SDA: MP05[1]
120  * SCL: MP05[0]
121  */
122 static struct i2c_gpio_bus_data i2c_gpio7 = {
123         .sda_pin        = 1,
124         .scl_pin        = 0,
125 };
126
127 /*
128  * i2c gpio7 - cypress
129  * SDA: MP05[6]
130  * SCL: MP05[4]
131  */
132 static struct i2c_gpio_bus_data i2c_cypress_gpio7 = {
133         .sda_pin        = 6,
134         .scl_pin        = 4,
135 };
136
137 /*
138  * i2c gpio10
139  * SDA: GPJ3[0]
140  * SCL: GPJ3[1]
141  */
142 static struct i2c_gpio_bus_data i2c_gpio10 = {
143         .sda_pin        = 0,
144         .scl_pin        = 1,
145 };
146
147
148 static struct i2c_gpio_bus i2c_gpio[] = {
149         {
150                 .bus    = &i2c_2,
151         }, {
152                 .bus    = &i2c_gpio3,
153         }, {
154                 .bus    = &i2c_pmic,
155         }, {
156                 .bus    = &i2c_gpio5,
157         }, {
158                 .bus    = &i2c_gpio6,
159         }, {
160                 .bus    = &i2c_gpio7,
161         }, {
162                 .bus    = &i2c_gpio10,
163         },
164 };
165
166 u32 get_board_rev(void)
167 {
168         return board_rev;
169 }
170
171 static int hwrevision(int rev)
172 {
173         return (board_rev & 0xf) == rev;
174 }
175
176 enum {
177         MACH_UNIVERSAL,
178         MACH_TICKERTAPE,
179         MACH_AQUILA,
180         MACH_P1P2,      /* Don't remove it */
181         MACH_GEMINUS,
182         MACH_CYPRESS,
183
184         MACH_WMG160 = 160,
185 };
186
187 #define SPLIT_SCREEN_FEATURE    0x100
188
189 /* board is MACH_AQUILA and board is like below. */
190 #define J1_B2_BOARD             0x0200
191 #define LIMO_UNIVERSAL_BOARD    0x0400
192 #define LIMO_REAL_BOARD         0x0800
193 #define MEDIA_BOARD             0x1000
194 #define BAMBOO_BOARD            0x2000
195 #define ARIES_BOARD             0x4000
196 #define NEPTUNE_BOARD           0x8000
197
198 #define BOARD_MASK              0xFF00
199
200 static int c110_machine_id(void)
201 {
202         return gd->bd->bi_arch_number - C110_MACH_START;
203 }
204
205 static int machine_is_aquila(void)
206 {
207         return c110_machine_id() == MACH_AQUILA;
208 }
209
210 static int machine_is_tickertape(void)
211 {
212         return c110_machine_id() == MACH_TICKERTAPE;
213 }
214
215 static int machine_is_geminus(void)
216 {
217         return c110_machine_id() == MACH_GEMINUS;
218 }
219
220 static int machine_is_cypress(void)
221 {
222         return c110_machine_id() == MACH_CYPRESS;
223 }
224
225 static int board_is_limo_universal(void)
226 {
227         return machine_is_aquila() && (board_rev & LIMO_UNIVERSAL_BOARD);
228 }
229
230 static int board_is_limo_real(void)
231 {
232         return machine_is_aquila() && (board_rev & LIMO_REAL_BOARD);
233 }
234
235 static int board_is_media(void)
236 {
237         return machine_is_aquila() && (board_rev & MEDIA_BOARD);
238 }
239
240 static int board_is_bamboo(void)
241 {
242         return machine_is_aquila() && (board_rev & BAMBOO_BOARD);
243 }
244
245 static int board_is_j1b2(void)
246 {
247         return machine_is_aquila() && (board_rev & J1_B2_BOARD);
248 }
249
250 static int board_is_aries(void)
251 {
252         return machine_is_aquila() && (board_rev & ARIES_BOARD);
253 }
254
255 static int board_is_neptune(void)
256 {
257         return machine_is_aquila() && (board_rev & NEPTUNE_BOARD);
258 }
259
260 /* DLNA Dongle */
261 static int machine_is_wmg160(void)
262 {
263         return c110_machine_id() == MACH_WMG160;
264 }
265
266 static void enable_battery(void);
267
268 void i2c_init_board(void)
269 {
270         struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
271         int num_bus;
272
273         if (cpu_is_s5pc100())
274                 return;
275
276         num_bus = ARRAY_SIZE(i2c_gpio);
277
278         if (machine_is_aquila()) {
279                 if (board_is_aries()) {
280                         i2c_gpio[I2C_GPIO7].bus->gpio_base =
281                                 (unsigned int)&gpio->gpio_mp0_5;
282                 } else {
283                         i2c_gpio[I2C_GPIO6].bus->gpio_base = 0;
284                         i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
285                 }
286         } else if (machine_is_cypress()) {
287                 i2c_gpio[I2C_GPIO7].bus = &i2c_cypress_gpio7;
288                 i2c_gpio[I2C_GPIO7].bus->gpio_base =
289                         (unsigned int)&gpio->gpio_mp0_5;
290         } else {
291                 i2c_gpio[I2C_GPIO7].bus->gpio_base = 0;
292         }
293
294         i2c_gpio[I2C_2].bus->gpio_base = (unsigned int)&gpio->gpio_d1;
295         i2c_gpio[I2C_GPIO3].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
296         i2c_gpio[I2C_PMIC].bus->gpio_base = (unsigned int)&gpio->gpio_j4;
297         i2c_gpio[I2C_GPIO5].bus->gpio_base = (unsigned int)&gpio->gpio_mp0_5;
298         i2c_gpio[I2C_GPIO6].bus->gpio_base = (unsigned int)&gpio->gpio_j3;
299
300         i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
301
302         /* Reset on max17040 early */
303         if (battery_soc == 0)
304                 enable_battery();
305 }
306
307 #ifdef CONFIG_MISC_INIT_R
308 #define DEV_INFO_LEN            512
309 static char device_info[DEV_INFO_LEN];
310 static int display_info;
311
312 static void dprintf(const char *fmt, ...)
313 {
314         va_list args;
315         uint i;
316         char buf[128];
317
318         va_start(args, fmt);
319         i = vsprintf(buf, fmt, args);
320         va_end(args);
321
322         buf[127] = 0;
323
324         if ((strlen(device_info) + strlen(buf)) > (DEV_INFO_LEN - 1)) {
325                 puts("Flushing device info...\n");
326                 puts(device_info);
327                 device_info[0] = 0;
328         }
329         strcat(device_info, buf);
330         puts(buf);
331 }
332
333 #ifdef CONFIG_S5PC1XXFB
334 static void display_device_info(void)
335 {
336         if (!display_info)
337                 return;
338
339         init_font();
340         set_font_xy(0, 450);
341         set_font_color(FONT_WHITE);
342         fb_printf(device_info);
343         exit_font();
344
345         memset(device_info, 0x0, DEV_INFO_LEN);
346
347         udelay(5 * 1000 * 1000);
348 }
349 #endif
350
351 static const char *board_name[] = {
352         "Universal",
353         "TickerTape",
354         "Aquila",
355         "P1P2",         /* Don't remove it */
356         "Geminus",
357         "Cypress",
358         "Neptune",
359 };
360
361 enum {
362         MEM_4G1G1G,
363         MEM_4G2G1G,
364         MEM_4G3G1G,
365         MEM_4G4G1G,
366 };
367
368 static char feature_buffer[32];
369
370 static char *display_features(int board, int board_rev)
371 {
372         int count = 0;
373         char *buf = feature_buffer;
374         char *name = NULL;
375
376         if (board == MACH_AQUILA) {
377                 if (board_rev & SPLIT_SCREEN_FEATURE)
378                         name = "SplitScreen";
379                 if (board_rev & J1_B2_BOARD)
380                         name = "J1 B2";
381                 /* Limo Real or Universal */
382                 if (board_rev & LIMO_REAL_BOARD)
383                         name = "Limo Real";
384                 else if (board_rev & LIMO_UNIVERSAL_BOARD)
385                         name = "Limo Universal";
386                 if (board_rev & MEDIA_BOARD)
387                         name = "Media";
388                 if (board_rev & BAMBOO_BOARD)
389                         name = "Bamboo";
390                 if (board_rev & ARIES_BOARD)
391                         name = "Aries";
392                 if (board_rev & NEPTUNE_BOARD)
393                         name = "Neptune";
394
395                 if (name)
396                         count += sprintf(buf + count, " - %s", name);
397         }
398
399         return buf;
400 }
401
402 static char *get_board_name(int board)
403 {
404         if (board == MACH_WMG160)
405                 return "WMG160";
406         return (char *) board_name[board];
407 }
408
409 static void check_board_revision(int board, int rev)
410 {
411         switch (board) {
412         case MACH_AQUILA:
413                 /* Limo Real or Universal */
414                 if (rev & LIMO_UNIVERSAL_BOARD)
415                         board_rev &= ~J1_B2_BOARD;
416                 if (rev & LIMO_REAL_BOARD)
417                         board_rev &= ~(J1_B2_BOARD |
418                                         LIMO_UNIVERSAL_BOARD);
419                 if (rev & MEDIA_BOARD)
420                         board_rev &= ~(J1_B2_BOARD |
421                                         LIMO_UNIVERSAL_BOARD);
422                 if (rev & BAMBOO_BOARD)
423                         board_rev &= ~(J1_B2_BOARD |
424                                         LIMO_UNIVERSAL_BOARD |
425                                         LIMO_REAL_BOARD |
426                                         MEDIA_BOARD);
427                 if (rev & ARIES_BOARD)
428                         board_rev &= ~(J1_B2_BOARD |
429                                         LIMO_UNIVERSAL_BOARD);
430                 if (rev & NEPTUNE_BOARD)
431                         board_rev &= ~(J1_B2_BOARD |
432                                         LIMO_UNIVERSAL_BOARD);
433                 break;
434         case MACH_CYPRESS:
435         case MACH_TICKERTAPE:
436         case MACH_GEMINUS:
437         case MACH_WMG160:
438                 board_rev &= ~BOARD_MASK;
439                 break;
440         default:
441                 break;
442         }
443 }
444
445 static unsigned int get_hw_revision(struct s5pc1xx_gpio_bank *bank, int hwrev3)
446 {
447         unsigned int rev;
448         int mode3 = 1;
449
450         if (hwrev3)
451                 mode3 = 7;
452
453         gpio_direction_input(bank, 2);
454         gpio_direction_input(bank, 3);
455         gpio_direction_input(bank, 4);
456         gpio_direction_input(bank, mode3);
457
458         gpio_set_pull(bank, 2, GPIO_PULL_NONE);         /* HWREV_MODE0 */
459         gpio_set_pull(bank, 3, GPIO_PULL_NONE);         /* HWREV_MODE1 */
460         gpio_set_pull(bank, 4, GPIO_PULL_NONE);         /* HWREV_MODE2 */
461         gpio_set_pull(bank, mode3, GPIO_PULL_NONE);     /* HWREV_MODE3 */
462
463         rev = gpio_get_value(bank, 2);
464         rev |= (gpio_get_value(bank, 3) << 1);
465         rev |= (gpio_get_value(bank, 4) << 2);
466         rev |= (gpio_get_value(bank, mode3) << 3);
467
468         return rev;
469 }
470
471 static void check_hw_revision(void)
472 {
473         unsigned int board = MACH_UNIVERSAL;    /* Default is Universal */
474
475         if (cpu_is_s5pc100()) {
476                 struct s5pc100_gpio *gpio =
477                         (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
478
479                 board_rev = get_hw_revision(&gpio->gpio_j0, 0);
480
481                 /* C100 TickerTape */
482                 if (board_rev == 3)
483                         board = MACH_TICKERTAPE;
484         } else {
485                 struct s5pc110_gpio *gpio =
486                         (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
487                 int hwrev3 = 0;
488
489                 board_rev = 0;
490
491                 /*
492                  * Note Check 'Aquila' board first
493                  *
494                  * TT: TickerTape
495                  * SS: SplitScreen
496                  * LRA: Limo Real Aquila
497                  * LUA: Limo Universal Aquila
498                  * OA: Old Aquila
499                  * CYP: Cypress
500                  * BB: Bamboo
501                  *
502                  * ADDR = 0xE0200000 + OFF
503                  *
504                  *       OFF    Universal BB   LRA  LUA  OA   TT   SS        CYP
505                  *   J1: 0x0264 0x10      0x10 0x00 0x00 0x00 0x00 0x00     
506                  *   J2: 0x0284           0x01 0x10 0x00 
507                  *   H1: 0x0C24    W           0x28 0xA8 0x1C                0x0F
508                  *   H3: 0x0C64                0x03 0x07 0x0F               
509                  *   D1: 0x00C4 0x0F           0x3F 0x3F 0x0F 0xXC 0x3F
510                  *    I: 0x0224                          0x02 0x00 0x08
511                  * MP03: 0x0324                          0x9x      0xbx 0x9x
512                  * MP05: 0x0364                          0x80      0x88
513                  */
514
515                 /* C110 Aquila */
516                 if (gpio_get_value(&gpio->gpio_j1, 4) == 0) {
517                         board = MACH_AQUILA;
518                         board_rev |= J1_B2_BOARD;
519
520                         gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_NONE);
521                         gpio_direction_input(&gpio->gpio_j2, 6);
522
523                         /* Check board */
524                         if (gpio_get_value(&gpio->gpio_h1, 2) == 0)
525                                 board_rev |= LIMO_UNIVERSAL_BOARD;
526
527                         if (gpio_get_value(&gpio->gpio_h3, 2) == 0)
528                                 board_rev |= LIMO_REAL_BOARD;
529
530                         if (gpio_get_value(&gpio->gpio_j2, 6) == 1)
531                                 board_rev |= MEDIA_BOARD;
532
533                         /* set gpio to default value. */
534                         gpio_set_pull(&gpio->gpio_j2, 6, GPIO_PULL_DOWN);
535                         gpio_direction_output(&gpio->gpio_j2, 6, 0);
536                 }
537
538                 /* Workaround: C110 Aquila Rev0.6 */
539                 if (board_rev == 6) {
540                         board = MACH_AQUILA;
541                         board_rev |= LIMO_REAL_BOARD;
542                 }
543
544                 /* C110 Aquila Bamboo */
545                 if (gpio_get_value(&gpio->gpio_j2, 0) == 1) {
546                         board = MACH_AQUILA;
547                         board_rev |= BAMBOO_BOARD;
548                 }
549
550                 /* C110 TickerTape */
551                 if (gpio_get_value(&gpio->gpio_d1, 0) == 0 &&
552                                 gpio_get_value(&gpio->gpio_d1, 1) == 0)
553                         board = MACH_TICKERTAPE;
554
555                 /* C110 Geminus for rev0.0 */
556                 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_NONE);
557                 gpio_direction_input(&gpio->gpio_j1, 2);
558                 if (gpio_get_value(&gpio->gpio_j1, 2) == 1) {
559                         board = MACH_GEMINUS;
560                         if ((board_rev & ~BOARD_MASK) == 3)
561                                 board_rev &= ~0xff;
562                 }
563                 gpio_set_pull(&gpio->gpio_j1, 2, GPIO_PULL_DOWN);
564                 gpio_direction_output(&gpio->gpio_j1, 2, 0);
565
566                 /* C110 Geminus for rev0.1 ~ */
567                 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_NONE);
568                 gpio_direction_input(&gpio->gpio_j0, 6);
569                 if (gpio_get_value(&gpio->gpio_j0, 6) == 1) {
570                         board = MACH_GEMINUS;
571                         hwrev3 = 1;
572                 }
573                 gpio_set_pull(&gpio->gpio_j0, 6, GPIO_PULL_DOWN);
574
575                 /* Aquila - Aries MP0_5[6] == 1 */
576                 gpio_direction_input(&gpio->gpio_mp0_5, 6);
577                 if (gpio_get_value(&gpio->gpio_mp0_5, 6) == 1) {
578                         /* Cypress: Do this for cypress */
579                         gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_NONE);
580                         gpio_direction_input(&gpio->gpio_j2, 2);
581                         if (gpio_get_value(&gpio->gpio_j2, 2) == 1) {
582                                 board = MACH_CYPRESS;
583                                 gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
584                         } else {
585                                 board = MACH_AQUILA;
586                                 board_rev |= ARIES_BOARD;
587 #ifdef USE_NEPTUNE_BOARD
588                                 board_rev &= ~ARIES_BOARD;
589                                 board_rev |= NEPTUNE_BOARD;
590 #endif
591                         }
592                         gpio_set_pull(&gpio->gpio_j2, 2, GPIO_PULL_DOWN);
593                         hwrev3 = 1;
594                 } else
595                         gpio_direction_output(&gpio->gpio_mp0_5, 6, 0);
596
597                 /* WMG160 - GPB[0:7] == 0x00000000 */
598                 do {
599                         int i, wmg160 = 1;
600
601                         for (i = 0; i < 8; i++) {
602                                 if (gpio_get_value(&gpio->gpio_b, i) == 0)
603                                         continue;
604                                 wmg160 = 0;
605                         }
606                         if (wmg160) {
607                                 board = MACH_WMG160;
608                                 hwrev3 = 1;
609                         }
610                 } while (0);
611
612                 board_rev |= get_hw_revision(&gpio->gpio_j0, hwrev3);
613         }
614
615         /* Set machine id */
616         if (cpu_is_s5pc110())
617                 gd->bd->bi_arch_number = C110_MACH_START + board;
618         else
619                 gd->bd->bi_arch_number = C100_MACH_START + board;
620
621         /* Architecture Common settings */
622         if (cpu_is_s5pc110()) {
623                 setenv("mtdparts", MTDPARTS_DEFAULT_4KB);
624         } else {
625                 setenv("bootk", "onenand read 0x30007FC0 0x60000 0x300000; "
626                                 "bootm 0x30007FC0");
627                 setenv("updatek", "onenand erase 0x60000 0x300000; "
628                                   "onenand write 0x31008000 0x60000 0x300000");
629         }
630 }
631
632 static void show_hw_revision(void)
633 {
634         int board;
635
636         /*
637          * Workaround for Rev 0.3 + CP Ver ES 3.1
638          * it's Rev 0.4
639          */
640         if (board_is_limo_real()) {
641                 if (hwrevision(0)) {
642                         /* default is Rev 0.4 */
643                         board_rev &= ~0xf;
644                         board_rev |= 0x4;
645                 }
646         }
647
648         if (cpu_is_s5pc110())
649                 board = gd->bd->bi_arch_number - C110_MACH_START;
650         else
651                 board = gd->bd->bi_arch_number - C100_MACH_START;
652
653         check_board_revision(board, board_rev);
654
655         /* Set CPU Revision */
656         if (machine_is_aquila()) {
657                 if (board_is_limo_real()) {
658                         if ((board_rev & 0xf) < 8)
659                                 s5pc1xx_set_cpu_rev(0);
660                 }
661         } else if (machine_is_geminus()) {
662                 if ((board_rev & 0xf) < 1)
663                         s5pc1xx_set_cpu_rev(0);
664         } else {
665                 s5pc1xx_set_cpu_rev(0);
666         }
667
668         dprintf("HW Revision:\t%x (%s%s) %s\n",
669                 board_rev, get_board_name(board),
670                 display_features(board, board_rev),
671                 s5pc1xx_get_cpu_rev() ? "" : "EVT0");
672 }
673
674 static void check_auto_burn(void)
675 {
676         unsigned long magic_base = CONFIG_SYS_SDRAM_BASE + 0x02000000;
677         unsigned int count = 0;
678         char buf[64];
679
680         if (readl(magic_base) == 0x426f6f74) {  /* ASICC: Boot */
681                 printf("Auto burning bootloader\n");
682                 count += sprintf(buf + count, "run updateb; ");
683         }
684         if (readl(magic_base + 0x04) == 0x4b65726e) {   /* ASICC: Kern */
685                 printf("Auto burning kernel\n");
686                 count += sprintf(buf + count, "run updatek; ");
687         }
688
689         if (count) {
690                 count += sprintf(buf + count, "reset");
691                 setenv("bootcmd", buf);
692         }
693
694         /* Clear the magic value */
695         writel(0xa5a55a5a, magic_base);
696         writel(0xa5a55a5a, magic_base + 0x4);
697 }
698
699 static void pmic_pin_init(void)
700 {
701         unsigned int reg, value;
702
703         if (cpu_is_s5pc100())
704                 return;
705
706         /* AP_PS_HOLD: XEINT_0: GPH0[0]
707          * Note: Don't use GPIO PS_HOLD it doesn't work
708          */
709         reg = S5PC110_PS_HOLD_CONTROL;
710         value = readl(reg);
711         value |= S5PC110_PS_HOLD_DIR_OUTPUT |
712                 S5PC110_PS_HOLD_DATA_HIGH |
713                 S5PC110_PS_HOLD_OUT_EN;
714         writel(value, reg);
715
716         /* nPOWER: XEINT_22: GPH2[6] interrupt mode */
717         gpio_cfg_pin(&s5pc110_gpio->gpio_h2, 6, GPIO_IRQ);
718         gpio_set_pull(&s5pc110_gpio->gpio_h2, 6, GPIO_PULL_UP);
719 }
720
721 static void enable_ldos(void)
722 {
723         if (cpu_is_s5pc100())
724                 return;
725
726         /* TOUCH_EN: XMMC3DATA_3: GPG3[6] output high */
727         gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, 1);
728 }
729
730 static void enable_t_flash(void)
731 {
732         if (!(board_is_limo_universal() || board_is_limo_real()))
733                 return;
734
735         /* T_FLASH_EN : XM0ADDR_13: MP0_5[4] output high */
736         gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 1);
737 }
738
739 static void setup_limo_real_gpios(void)
740 {
741         if (!board_is_limo_real())
742                 return;
743
744         /*
745          * Note: Please write GPIO alphabet order
746          */
747         /* CODEC_LDO_EN: XVVSYNC_LDI: GPF3[4] output high */
748         gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 1);
749
750         if (hwrevision(0))
751                 /* RESET_REQ_N: XM0BEN_1: MP0_2[1] output high */
752                 gpio_direction_output(&s5pc110_gpio->gpio_mp0_2, 1, 1);
753         else
754                 /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
755                 gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
756
757         /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
758         gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
759         gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
760 }
761
762 static void setup_media_gpios(void)
763 {
764         if (!board_is_media())
765                 return;
766
767         /*
768          * Note: Please write GPIO alphabet order
769          */
770         /* RESET_REQ_N: XM0CSn_2: MP0_1[2] output high */
771         gpio_direction_output(&s5pc110_gpio->gpio_mp0_1, 2, 1);
772
773         /* T_FLASH_DETECT: EINT28: GPH3[4] interrupt mode */
774         gpio_cfg_pin(&s5pc110_gpio->gpio_h3, 4, GPIO_IRQ);
775         gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
776 }
777
778 #define KBR3            (1 << 3)
779 #define KBR2            (1 << 2)
780 #define KBR1            (1 << 1)
781 #define KBR0            (1 << 0)
782
783 static void check_keypad(void)
784 {
785         unsigned int reg, value;
786         unsigned int col_mask, row_mask;
787         unsigned int auto_download = 0;
788         unsigned int col_value[4], i;
789
790         if (machine_is_wmg160())
791                 return;
792
793         if (cpu_is_s5pc100()) {
794                 struct s5pc100_gpio *gpio =
795                         (struct s5pc100_gpio *)S5PC100_GPIO_BASE;
796
797                 /* Set GPH2[2:0] to KP_COL[2:0] */
798                 gpio_cfg_pin(&gpio->gpio_h2, 0, 0x3);
799                 gpio_cfg_pin(&gpio->gpio_h2, 1, 0x3);
800                 gpio_cfg_pin(&gpio->gpio_h2, 2, 0x3);
801
802                 /* Set GPH3[2:0] to KP_ROW[2:0] */
803                 gpio_cfg_pin(&gpio->gpio_h3, 0, 0x3);
804                 gpio_cfg_pin(&gpio->gpio_h3, 1, 0x3);
805                 gpio_cfg_pin(&gpio->gpio_h3, 2, 0x3);
806
807                 reg = S5PC100_KEYPAD_BASE;
808         } else {
809                 if (board_is_limo_real() || board_is_limo_universal()) {
810                         row_mask = 0x00FF;
811                         col_mask = 0x0FFF;
812                 } else {
813                         row_mask = 0xFFFF;
814                         col_mask = 0xFFFF;
815                 }
816
817                 for (i = 0; i < 4; i++) {
818                         /* Set GPH3[3:0] to KP_ROW[3:0] */
819                         if (row_mask & (0xF << (i << 2))) {
820                                 gpio_cfg_pin(&s5pc110_gpio->gpio_h3, i, 0x3);
821                                 gpio_set_pull(&s5pc110_gpio->gpio_h3, i,
822                                                 GPIO_PULL_UP);
823                         }
824
825                         /* Set GPH2[3:0] to KP_COL[3:0] */
826                         if (col_mask & (0xF << (i << 2)))
827                                 gpio_cfg_pin(&s5pc110_gpio->gpio_h2, i, 0x3);
828                 }
829
830                 reg = S5PC110_KEYPAD_BASE;
831         }
832         /* init col */
833         value = 0x00;
834         writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
835         value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
836         /* VOLUMEDOWN and CAM(Half shot) Button */
837         if ((value & KBR1) == 0) {
838                 i = 0;
839                 while (i < 4) {
840                         value = readl(reg + S5PC1XX_KEYIFCOL_OFFSET);
841                         value |= 0xff;
842                         value &= ~(1 << i);
843                         writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
844                         udelay(10*1000);
845                         col_value[i++] = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
846                 }
847                 writel(0x00, reg + S5PC1XX_KEYIFCOL_OFFSET);
848
849                 /* expected value is row_value[0] = 0x00 row_value[1] = 0x01 */
850                 /* workaround */
851                 if (col_value[1] == 0xd && col_value[2] == 0xe && machine_is_geminus())
852                         auto_download = 1;
853
854                 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) == 0x3)
855                         auto_download = 1;
856
857                 if ((col_value[0] & 0x3) == 0x3 && (col_value[1] & 0x3) != 0x3)
858                         display_info = 1;
859         }
860
861         if (auto_download)
862                 setenv("bootcmd", "usbdown");
863 }
864
865 static void enable_battery(void)
866 {
867         unsigned char val[2];
868         unsigned char addr = 0x36;      /* max17040 fuel gauge */
869
870         i2c_set_bus_num(I2C_GPIO3);
871
872         if (machine_is_aquila()) {
873                 if (board_is_aries() || board_is_neptune())
874                         i2c_set_bus_num(I2C_GPIO7);
875                 else if (board_is_j1b2())
876                         return;
877         } else if (machine_is_tickertape()) {
878                 return;
879         } else if (machine_is_cypress()) {
880                 i2c_set_bus_num(I2C_GPIO7);
881         } else if (machine_is_geminus()) {
882                 if (hwrevision(1))
883                         i2c_set_bus_num(I2C_GPIO7);
884         }
885
886         if (i2c_probe(addr)) {
887                 printf("Can't found max17040 fuel gauge\n");
888                 return;
889         }
890
891         val[0] = 0x54;
892         val[1] = 0x00;
893         i2c_write(addr, 0xfe, 1, val, 2);
894 }
895
896 static void check_battery(void)
897 {
898         unsigned char val[2];
899         unsigned char addr = 0x36;      /* max17040 fuel gauge */
900
901         i2c_set_bus_num(I2C_GPIO3);
902
903         if (machine_is_aquila()) {
904                 if (board_is_aries() || board_is_neptune())
905                         i2c_set_bus_num(I2C_GPIO7);
906                 else if (board_is_j1b2())
907                         return;
908         } else if (machine_is_cypress()) {
909                 i2c_set_bus_num(I2C_GPIO7);
910         } else if (machine_is_geminus()) {
911                 if (hwrevision(1))
912                         i2c_set_bus_num(I2C_GPIO7);
913         } else
914                 return;
915
916         if (i2c_probe(addr)) {
917                 printf("Can't found max17040 fuel gauge\n");
918                 return;
919         }
920
921         i2c_read(addr, 0x04, 1, val, 1);
922
923         dprintf("battery:\t%d%%\n", val[0]);
924
925         battery_soc = val[0];
926 }
927
928 static void check_mhl(void)
929 {
930         unsigned char val[2];
931         unsigned char addr = 0x39;      /* SIL9230 */
932
933         /* MHL Power enable */
934         /* HDMI_EN : GPJ2[2] XMSMDATA_2 output mode */
935         gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 1);
936
937         /* MHL_RST : MP0_4[7] XM0ADDR_7 output mode */
938         gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
939
940         /* 10ms required after reset */
941         udelay(10000);
942
943         /* output enable */
944         gpio_set_value(&s5pc110_gpio->gpio_mp0_4, 7, 1);
945
946         i2c_set_bus_num(I2C_GPIO5);
947
948         /* set usb path */
949         if (i2c_probe(addr)) {
950                 printf("Can't found MHL Chip\n");
951                 return;
952         }
953
954         /*
955          * System Control #1
956          * set to Normal operation
957          */
958         val[0] = 0x35;
959         i2c_write((0x72 >> 1), 0x08, 1, val, 1);
960         i2c_read((0x72 >> 1), 0x08, 1, val, 1);
961
962         /*
963          * MHL TX Control #1
964          * TERM_MODE [7:6]
965          * 00 = MHL termination ON
966          * 11 = MHL termination OFF
967          */
968         val[0] = 0xd0;
969         i2c_write((0x72 >> 1), 0xa0, 1, val, 1);
970         i2c_read((0x72 >> 1), 0xa0, 1, val, 1);
971 }
972
973 #define CHARGER_ANIMATION_FRAME         6
974 static int max8998_power_key(void)
975 {
976         unsigned char addr, val[2];
977         i2c_set_bus_num(I2C_PMIC);
978         addr = 0xCC >> 1;
979         if (i2c_probe(addr)) {
980                 printf("Can't found max8998\n");
981                 return 0;
982         }
983
984         /* Accessing IRQ1 register */
985         i2c_read(addr, 0x00, 1, val, 1);
986         if (val[0] & (1 << 6))
987                 return 1;
988
989         return 0;
990 }
991
992 extern void lcd_display_clear(void);
993 extern int lcd_display_bitmap(ulong bmp_image, int x, int y);
994
995 static void into_charge_mode(void)
996 {
997         unsigned char addr = 0xCC >> 1; /* max8998 */;
998         unsigned char val[2];
999         unsigned int level;
1000         int i, j;
1001         bmp_image_t *bmp;
1002         unsigned long len;
1003         ulong bmp_addr[CHARGER_ANIMATION_FRAME];
1004
1005         i2c_set_bus_num(I2C_PMIC);
1006
1007         if (i2c_probe(addr)) {
1008                 printf("Can't found max8998\n");
1009                 return;
1010         }
1011
1012         printf("Charge Mode\n");
1013
1014         i2c_read(addr, 0x0C, 1, val, 1);
1015         val[0] &= ~(0x7 << 0);
1016         val[0] |= 5;            /* 600mA */
1017         i2c_write(addr, 0x0C, 1, val, 1);
1018
1019 #ifdef CONFIG_S5PC1XXFB
1020         init_font();
1021
1022         /* TODO: write the image-text for the charger */
1023
1024         level = battery_soc * CHARGER_ANIMATION_FRAME / 100;
1025         if (level >= CHARGER_ANIMATION_FRAME)
1026                 level = CHARGER_ANIMATION_FRAME - 1;
1027
1028         for (i = 0; i < CHARGER_ANIMATION_FRAME; i++)
1029                 bmp_addr[i] = (ulong)battery_charging_animation[i];
1030
1031         lcd_display_clear();
1032         for (i = 0; i < 3; i++) {
1033                 for (j = level; j < CHARGER_ANIMATION_FRAME; j++) {
1034                         int k;
1035
1036                         bmp = gunzip_bmp(bmp_addr[j], &len);
1037                         lcd_display_bitmap((ulong) bmp, 140, 202);
1038                         free(bmp);
1039
1040                         for (k = 0; k < 10; k++)
1041                                 if (max8998_power_key()) {
1042                                         lcd_display_clear();
1043                                         /* FIXME don't use static function */
1044                                         /* draw_samsung_logo(lcd_base); */
1045                                         return;
1046                                 } else
1047                                         udelay(100 * 1000);
1048                 }
1049         }
1050         exit_font();
1051 #endif
1052
1053         /* EVT0: sleep 1, EVT1: sleep */
1054         if (s5pc1xx_get_cpu_rev() == 0) {
1055                 run_command("sleep 1", 0);
1056                 return;
1057         }
1058
1059         run_command("sleep", 0);
1060 }
1061
1062 static void check_micro_usb(int intr)
1063 {
1064         unsigned char addr;
1065         unsigned char val[2];
1066         static int started_charging_once = 0;
1067         char *path;
1068
1069         if (cpu_is_s5pc100())
1070                 return;
1071
1072         if (board_is_limo_real()) {
1073                 if (hwrevision(0) || hwrevision(1))
1074                         return;
1075         }
1076
1077         i2c_set_bus_num(I2C_PMIC);
1078
1079         if (machine_is_aquila()) {
1080                 if (board_is_aries() || board_is_neptune())
1081                         i2c_set_bus_num(I2C_GPIO6);
1082         } else if (machine_is_cypress()) {
1083                 i2c_set_bus_num(I2C_GPIO6);
1084         } else if (machine_is_geminus()) {
1085                 if (hwrevision(1))
1086                         i2c_set_bus_num(I2C_GPIO6);
1087         } else if (machine_is_wmg160())
1088                 i2c_set_bus_num(I2C_GPIO6);
1089
1090         addr = 0x25;            /* fsa9480 */
1091         if (i2c_probe(addr)) {
1092                 printf("Can't found fsa9480\n");
1093                 return;
1094         }
1095
1096         /* Clear Interrupt */
1097         if (intr) {
1098                 i2c_read(addr, 0x03, 1, val, 2);
1099                 udelay(500 * 1000);
1100         }
1101
1102         /* Read Device Type 1 */
1103         i2c_read(addr, 0x0a, 1, val, 1);
1104
1105 #define FSA_DEDICATED_CHARGER   (1 << 6)
1106 #define FSA_UART                (1 << 3)
1107 #define FSA_USB                 (1 << 2)
1108
1109         /*
1110          * If USB, use default 475mA
1111          * If Charger, use 600mA and go to charge mode
1112          */
1113         if ((val[0] & FSA_DEDICATED_CHARGER) && !started_charging_once) {
1114                 started_charging_once = 1;
1115                 into_charge_mode();
1116         }
1117
1118         /* If Factory Mode is Boot ON-USB, go to download mode */
1119         i2c_read(addr, 0x07, 1, val, 1);
1120
1121 #define FSA_ADC_FAC_USB         0x19
1122 #define FSA_ADC_FAC_UART        0x1d
1123
1124         if (val[0] == FSA_ADC_FAC_USB)
1125                 setenv("bootcmd", "usbdown");
1126
1127         path = getenv("usb");
1128
1129         if (!strncmp(path, "cp", 2))
1130                 run_command("microusb cp", 0);
1131 }
1132
1133 static void micro_usb_switch(int path)
1134 {
1135         unsigned char addr;
1136         unsigned char val[2];
1137
1138         i2c_set_bus_num(I2C_PMIC);
1139
1140         if (machine_is_aquila()) {
1141                 if (board_is_aries() || board_is_neptune())
1142                         i2c_set_bus_num(I2C_GPIO6);
1143         } else if (machine_is_cypress()) {
1144                 i2c_set_bus_num(I2C_GPIO6);
1145         } else if (machine_is_geminus()) {
1146                 if (hwrevision(1))
1147                         i2c_set_bus_num(I2C_GPIO6);
1148         } else if (machine_is_wmg160())
1149                 i2c_set_bus_num(I2C_GPIO6);
1150
1151         addr = 0x25;            /* fsa9480 */
1152         if (i2c_probe(addr)) {
1153                 printf("Can't found fsa9480\n");
1154                 return;
1155         }
1156
1157         if (path)
1158                 val[0] = 0x90;  /* VAUDIO */
1159         else
1160                 val[0] = 0x24;  /* DHOST */
1161
1162         i2c_write(addr, 0x13, 1, val, 1);       /* MANSW1 */
1163
1164         i2c_read(addr, 0x2, 1, val, 1);
1165         val[0] &= ~(1 << 2);
1166         i2c_write(addr, 0x2, 1, val, 1);
1167 }
1168
1169 #define MAX8998_REG_ONOFF1      0x11
1170 #define MAX8998_REG_ONOFF2      0x12
1171 #define MAX8998_REG_ONOFF3      0x13
1172 #define MAX8998_REG_LDO7        0x21
1173 #define MAX8998_REG_LDO17       0x29
1174 /* ONOFF1 */
1175 #define MAX8998_LDO3            (1 << 2)
1176 /* ONOFF2 */
1177 #define MAX8998_LDO6            (1 << 7)
1178 #define MAX8998_LDO7            (1 << 6)
1179 #define MAX8998_LDO8            (1 << 5)
1180 #define MAX8998_LDO9            (1 << 4)
1181 #define MAX8998_LDO10           (1 << 3)
1182 #define MAX8998_LDO11           (1 << 2)
1183 #define MAX8998_LDO12           (1 << 1)
1184 #define MAX8998_LDO13           (1 << 0)
1185 /* ONOFF3 */
1186 #define MAX8998_LDO14           (1 << 7)
1187 #define MAX8998_LDO15           (1 << 6)
1188 #define MAX8998_LDO16           (1 << 5)
1189 #define MAX8998_LDO17           (1 << 4)
1190
1191
1192 static void init_pmic(void)
1193 {
1194         unsigned char addr;
1195         unsigned char val[2];
1196
1197         if (cpu_is_s5pc100())
1198                 return;
1199
1200         i2c_set_bus_num(I2C_PMIC);
1201
1202         addr = 0xCC >> 1;       /* max8998 */
1203         if (i2c_probe(addr)) {
1204                 if (i2c_probe(addr)) {
1205                         printf("Can't found max8998\n");
1206                         return;
1207                 }
1208         }
1209
1210         /* ONOFF1 */
1211         i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1212         val[0] &= ~MAX8998_LDO3;
1213         i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1214
1215         /* ONOFF2 */
1216         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1217         /*
1218          * Disable LDO10(VPLL_1.1V), LDO11(CAM_IO_2.8V),
1219          * LDO12(CAM_ISP_1.2V), LDO13(CAM_A_2.8V)
1220          */
1221         val[0] &= ~(MAX8998_LDO10 | MAX8998_LDO11 |
1222                         MAX8998_LDO12 | MAX8998_LDO13);
1223
1224         if (board_is_aries() || board_is_neptune())
1225                 val[0] |= MAX8998_LDO7;         /* LDO7: VLCD_1.8V */
1226
1227         i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1228         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1229         /* ONOFF3 */
1230         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1231         /*
1232          * Disable LDO14(CAM_CIF_1.8), LDO15(CAM_AF_3.3V),
1233          * LDO16(VMIPI_1.8V), LDO17(CAM_8M_1.8V)
1234          */
1235         val[0] &= ~(MAX8998_LDO14 | MAX8998_LDO15 |
1236                         MAX8998_LDO16 | MAX8998_LDO17);
1237
1238         if (board_is_aries() || board_is_neptune())
1239                 val[0] |= MAX8998_LDO17;        /* LDO17: VCC_3.0V_LCD */
1240
1241         i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1242         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1243 }
1244
1245 static void setup_power_down_mode_registers(void)
1246 {
1247         struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
1248         struct s5pc1xx_gpio_bank *bank;
1249         struct gpio_powermode *p;
1250         int n_p;
1251         struct gpio_external *ge;
1252         int n_ge;
1253         struct s5pc1xx_gpio_item *mr;
1254         int n_mr;
1255         int i;
1256
1257         if (cpu_is_s5pc100())
1258                 return;
1259
1260         /* Only Limo real and aries supports worked for sleep currnet */
1261         if (machine_is_aquila()) {
1262                 if (board_is_limo_real())
1263                         /* Support */;
1264                 else if (board_is_aries() || board_is_neptune())
1265                         /* Support */;
1266                 else
1267                         return;
1268         } else if (machine_is_geminus()) {
1269                 /* Support */;
1270         } else
1271                 return;
1272
1273         if (machine_is_aquila()) {
1274                 if (board_is_aries() || board_is_neptune()) {
1275                         /* Aquila rev 0.9 */
1276                         p = aries_powerdown_modes;
1277                         ge = aries_external_powerdown_modes;
1278                         mr = aries_mirror_powerdown_mode;
1279                         n_p = ARRAY_SIZE(aries_powerdown_modes);
1280                         n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1281                         n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1282                 } else {
1283                         /* Aquila rev 0.8 or lower */
1284                         p = aquila_powerdown_modes;
1285                         ge = aquila_external_powerdown_modes;
1286                         mr = aquila_mirror_powerdown_mode;
1287                         n_p = ARRAY_SIZE(aquila_powerdown_modes);
1288                         n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1289                         n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1290                 }
1291         } else if (machine_is_geminus()) {
1292                 if (hwrevision(1)) {
1293                         /* Same as Aquila rev 0.9 */
1294 #if 0
1295                         p = aries_powerdown_modes;
1296                         ge = aries_external_powerdown_modes;
1297                         mr = aries_mirror_powerdown_mode;
1298                         n_p = ARRAY_SIZE(aries_powerdown_modes);
1299                         n_ge = ARRAY_SIZE(aries_external_powerdown_modes);
1300                         n_mr = ARRAY_SIZE(aries_mirror_powerdown_mode);
1301 #else
1302                         p = aquila_powerdown_modes;
1303                         ge = aquila_external_powerdown_modes;
1304                         mr = aquila_mirror_powerdown_mode;
1305                         n_p = ARRAY_SIZE(aquila_powerdown_modes);
1306                         n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1307                         n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1308 #endif
1309                 } else if (hwrevision(0)) {
1310                         /* Same as Aquila rev 0.8 or lower */
1311                         p = aquila_powerdown_modes;
1312                         ge = aquila_external_powerdown_modes;
1313                         mr = aquila_mirror_powerdown_mode;
1314                         n_p = ARRAY_SIZE(aquila_powerdown_modes);
1315                         n_ge = ARRAY_SIZE(aquila_external_powerdown_modes);
1316                         n_mr = ARRAY_SIZE(aquila_mirror_powerdown_mode);
1317                 } else {
1318                         return; /* Not supported */
1319                 }
1320         }
1321
1322         bank = &gpio->gpio_a0;
1323
1324         for (i = 0; i < n_p; i++, p++, bank++) {
1325                 writel(p->conpdn, &bank->pdn_con);
1326                 writel(p->pudpdn, &bank->pdn_pull);
1327         }
1328         /* M299 */
1329         writel(0xff0022b0, (unsigned int *)0xF0000000);
1330         writel(0xff0022b0, (unsigned int *)0xF1400000);
1331
1332         bank = &gpio->gpio_h0;
1333
1334         for (i = 0; i < n_ge; i++) {
1335                 writel(ge->con, &bank->con);
1336                 writel(ge->dat, &bank->dat);
1337                 writel(ge->pud, &bank->pull);
1338
1339                 bank++;
1340                 ge++;
1341         }
1342
1343         for (i = 0; i < n_mr; i++) {
1344                 unsigned int reg = readl(&mr->bank->pdn_con);
1345                 reg &= ~(1 << mr->number);
1346                 if (readl(&mr->bank->dat) & (1 << mr->number))
1347                         reg |= 1 << mr->number;
1348                 writel(reg, &mr->bank->pdn_con);
1349
1350                 printf("[%8.8X] = %8.8X\n", (unsigned int) (&mr->bank->pdn_con), reg);
1351
1352                 mr++;
1353         }
1354 }
1355
1356 #ifdef CONFIG_LCD
1357 struct spi_platform_data {
1358         struct s5pc1xx_gpio_bank *cs_bank;
1359         struct s5pc1xx_gpio_bank *clk_bank;
1360         struct s5pc1xx_gpio_bank *si_bank;
1361         struct s5pc1xx_gpio_bank *so_bank;
1362
1363         unsigned int cs_num;
1364         unsigned int clk_num;
1365         unsigned int si_num;
1366         unsigned int so_num;
1367
1368         unsigned int board_is_media;
1369 };
1370
1371 extern void s6e63m0_set_platform_data(struct spi_platform_data *pd);
1372 extern void s6d16a0x_set_platform_data(struct spi_platform_data *pd);
1373
1374 struct spi_platform_data spi_pd;
1375
1376 struct s5pc110_gpio *gpio_base = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1377
1378 void lcd_cfg_gpio(void)
1379 {
1380         unsigned int i, f3_end = 4;
1381
1382         for (i = 0; i < 8; i++) {
1383                 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1384                 gpio_cfg_pin(&gpio_base->gpio_f0, i, GPIO_FUNC(2));
1385                 gpio_cfg_pin(&gpio_base->gpio_f1, i, GPIO_FUNC(2));
1386                 gpio_cfg_pin(&gpio_base->gpio_f2, i, GPIO_FUNC(2));
1387                 /* pull-up/down disable */
1388                 gpio_set_pull(&gpio_base->gpio_f0, i, GPIO_PULL_NONE);
1389                 gpio_set_pull(&gpio_base->gpio_f1, i, GPIO_PULL_NONE);
1390                 gpio_set_pull(&gpio_base->gpio_f2, i, GPIO_PULL_NONE);
1391
1392                 /* drive strength to max (24bit) */
1393                 gpio_set_drv(&gpio_base->gpio_f0, i, GPIO_DRV_4x);
1394                 gpio_set_rate(&gpio_base->gpio_f0, i, GPIO_DRV_SLOW);
1395                 gpio_set_drv(&gpio_base->gpio_f1, i, GPIO_DRV_4x);
1396                 gpio_set_rate(&gpio_base->gpio_f1, i, GPIO_DRV_SLOW);
1397                 gpio_set_drv(&gpio_base->gpio_f2, i, GPIO_DRV_4x);
1398                 gpio_set_rate(&gpio_base->gpio_f2, i, GPIO_DRV_SLOW);
1399         }
1400
1401         /* set DISPLAY_DE_B pin for dual rgb mode. */
1402         if (board_is_media())
1403                 f3_end = 5;
1404
1405         for (i = 0; i < f3_end; i++) {
1406                 /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */
1407                 gpio_cfg_pin(&gpio_base->gpio_f3, i, GPIO_PULL_UP);
1408                 /* pull-up/down disable */
1409                 gpio_set_pull(&gpio_base->gpio_f3, i, GPIO_PULL_NONE);
1410                 /* drive strength to max (24bit) */
1411                 gpio_set_drv(&gpio_base->gpio_f3, i, GPIO_DRV_4x);
1412                 gpio_set_rate(&gpio_base->gpio_f3, i, GPIO_DRV_SLOW);
1413         }
1414         /* display output path selection (only [1:0] valid) */
1415         writel(0x2, 0xE0107008);
1416
1417         /* gpio pad configuration for LCD reset. */
1418         gpio_cfg_pin(&gpio_base->gpio_mp0_5, 5, GPIO_OUTPUT);
1419
1420         /* gpio pad configuration for LCD ON. */
1421         gpio_cfg_pin(&gpio_base->gpio_j1, 3, GPIO_OUTPUT);
1422
1423         /* LCD_BACKLIGHT_EN */
1424         if (machine_is_geminus())
1425                 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
1426
1427         /*
1428          * gpio pad configuration for
1429          * DISPLAY_CS, DISPLAY_CLK, DISPLAY_SO, DISPLAY_SI.
1430          */
1431         gpio_cfg_pin(&gpio_base->gpio_mp0_1, 1, GPIO_OUTPUT);
1432         gpio_cfg_pin(&gpio_base->gpio_mp0_4, 1, GPIO_OUTPUT);
1433         gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_INPUT);
1434         gpio_cfg_pin(&gpio_base->gpio_mp0_4, 3, GPIO_OUTPUT);
1435
1436         if (machine_is_aquila()) {
1437                 spi_pd.cs_bank = &gpio_base->gpio_mp0_1;
1438                 spi_pd.cs_num = 1;
1439                 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1440                 spi_pd.clk_num = 1;
1441                 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1442                 spi_pd.si_num = 3;
1443                 spi_pd.so_bank = &gpio_base->gpio_mp0_4;
1444                 spi_pd.so_num = 2;
1445
1446                 if (board_is_neptune())
1447                         s6d16a0x_set_platform_data(&spi_pd);
1448                 else {
1449                         s6e63m0_set_platform_data(&spi_pd);
1450                         if (board_is_media())
1451                                 spi_pd.board_is_media = 1;
1452                 }
1453         }
1454
1455         if (machine_is_cypress()) {
1456 #if 0           /* universal cypress */
1457                 /* FLCD_CS */
1458                 gpio_cfg_pin(&gpio_base->gpio_mp0_1, 0, GPIO_OUTPUT);
1459 #endif
1460                 /* FLCD_CS_S */
1461                 gpio_cfg_pin(&gpio_base->gpio_mp0_5, 1, GPIO_OUTPUT);
1462                 /* FLCD_CLK */
1463                 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 0, GPIO_OUTPUT);
1464                 /* FLCD_SDI */
1465                 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 2, GPIO_OUTPUT);
1466                 /* FLCD_RST_S */
1467                 gpio_cfg_pin(&gpio_base->gpio_mp0_4, 5, GPIO_OUTPUT);
1468                 /* FLCD_ON_S */
1469                 gpio_cfg_pin(&gpio_base->gpio_g2, 2, GPIO_OUTPUT);
1470 #if 0           /* universal cypress */
1471                 pd_cs.bank = &gpio_base->gpio_mp0_1;
1472                 pd_cs.num = 0;
1473 #endif
1474                 spi_pd.cs_bank = &gpio_base->gpio_mp0_5;
1475                 spi_pd.cs_num = 1;
1476                 spi_pd.clk_bank = &gpio_base->gpio_mp0_4;
1477                 spi_pd.clk_num = 0;
1478                 spi_pd.si_bank = &gpio_base->gpio_mp0_4;
1479                 spi_pd.si_num = 2;
1480
1481                 /* these data would be sent to s6e63m0 lcd panel driver. */
1482                 s6e63m0_set_platform_data(&spi_pd);
1483         }
1484
1485         return;
1486 }
1487
1488 void backlight_on(unsigned int onoff)
1489 {
1490         struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1491
1492         if (onoff) {
1493                 if (machine_is_geminus())
1494                         gpio_set_value(&gpio->gpio_mp0_5, 0, 1);
1495         } else {
1496                 if (machine_is_geminus())
1497                         gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
1498         }
1499 }
1500
1501 void reset_lcd(void)
1502 {
1503         struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1504
1505         if (machine_is_aquila() || machine_is_geminus())
1506                 gpio_set_value(&gpio->gpio_mp0_5, 5, 1);
1507         if (machine_is_cypress())
1508                 gpio_set_value(&gpio->gpio_mp0_4, 5, 1);
1509 }
1510
1511 void lcd_power_on(unsigned int onoff)
1512 {
1513         struct s5pc110_gpio *gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1514         if (onoff) {
1515                 /* TSP_LDO_ON */
1516                 if (machine_is_aquila() || machine_is_geminus())
1517                         gpio_set_value(&gpio->gpio_j1, 3, 1);
1518
1519                 if (machine_is_cypress())
1520                         gpio_set_value(&gpio->gpio_g2, 2, 1);
1521
1522                 if (board_is_aries() || board_is_neptune()) {
1523                         unsigned char addr;
1524                         unsigned char val[2];
1525                         unsigned char val2[2];
1526
1527                         i2c_set_bus_num(I2C_PMIC);
1528                         addr = 0xCC >> 1;       /* max8998 */
1529                         if (i2c_probe(addr)) {
1530                                 printf("Can't found max8998\n");
1531                                 return;
1532                         }
1533                         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1534                         val[0] &= ~(MAX8998_LDO17);
1535                         val[0] |= MAX8998_LDO17;        /* LDO17: VCC_3.0V_LCD */
1536                         i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1537
1538                         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1539                         val[0] |= MAX8998_LDO17;
1540                         val2[0] = 0xE;
1541                         i2c_write(addr, MAX8998_REG_LDO17, 1, val2, 1);
1542                         i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1543
1544                         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1545                         val[0] |= MAX8998_LDO7;
1546                         val2[0] = 0x2;
1547                         i2c_write(addr, MAX8998_REG_LDO7, 1, val2, 1);
1548                         i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1549                 }
1550         } else {
1551                 if (machine_is_aquila() || machine_is_geminus())
1552                         gpio_set_value(&gpio->gpio_j1, 3, 0);
1553
1554                 if (machine_is_cypress())
1555                         gpio_set_value(&gpio->gpio_g2, 2, 0);
1556
1557                 if (board_is_aries() || board_is_neptune()) {
1558                         unsigned char addr;
1559                         unsigned char val[2];
1560
1561                         i2c_set_bus_num(I2C_PMIC);
1562                         addr = 0xCC >> 1;       /* max8998 */
1563                         if (i2c_probe(addr)) {
1564                                 printf("Can't found max8998\n");
1565                                 return;
1566                         }
1567
1568                         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1569                         val[0] &= ~(1 << 7);
1570                         i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1571                         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1572
1573                         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1574                         val[0] &= ~MAX8998_LDO17;
1575                         i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1576                         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1577                 }
1578         }
1579 }
1580
1581 extern void s6e63m0_cfg_ldo(void);
1582 extern void s6e63m0_enable_ldo(unsigned int onoff);
1583 extern void s6d16a0x_cfg_ldo(void);
1584 extern void s6d16a0x_enable_ldo(unsigned int onoff);
1585
1586 int s5p_no_lcd_support(void)
1587 {
1588         if (machine_is_wmg160())
1589                 return 1;
1590         return 0;
1591 }
1592
1593 void init_panel_info(vidinfo_t *vid)
1594 {
1595         vid->cfg_gpio = NULL;
1596         vid->reset_lcd = NULL;
1597         vid->backlight_on = NULL;
1598         vid->lcd_power_on = NULL;
1599
1600         vid->cfg_ldo = NULL;
1601         vid->enable_ldo = NULL;
1602
1603         vid->init_delay = 0;
1604         vid->reset_delay = 0;
1605         vid->power_on_delay = 0;
1606
1607         vid->vl_freq    = 60;
1608         vid->vl_col     = 480;
1609         vid->vl_row     = 800;
1610         vid->vl_width   = 480;
1611         vid->vl_height  = 800;
1612
1613         vid->dual_lcd_enabled = 0;
1614
1615         if (board_is_media()) {
1616                 vid->vl_col     = 960;
1617                 vid->vl_row     = 800;
1618                 vid->vl_width   = 960;
1619                 vid->vl_height  = 800;
1620
1621                 /* enable dual lcd mode. */
1622                 vid->dual_lcd_enabled = 1;
1623         }
1624
1625         vid->vl_clkp    = CONFIG_SYS_HIGH;
1626         vid->vl_hsp     = CONFIG_SYS_LOW;
1627         vid->vl_vsp     = CONFIG_SYS_LOW;
1628         vid->vl_dp      = CONFIG_SYS_HIGH;
1629         vid->vl_bpix    = 32;
1630
1631         /* S6E63M0 LCD Panel */
1632         vid->vl_hspw    = 2;
1633         vid->vl_hbpd    = 16;
1634         vid->vl_hfpd    = 16;
1635
1636         vid->vl_vspw    = 2;
1637         vid->vl_vbpd    = 3;
1638         vid->vl_vfpd    = 28;
1639
1640         if (machine_is_aquila() || machine_is_cypress()) {
1641                 vid->cfg_gpio = lcd_cfg_gpio;
1642                 vid->reset_lcd = reset_lcd;
1643                 vid->backlight_on = backlight_on;
1644                 vid->lcd_power_on = lcd_power_on;
1645                 vid->cfg_ldo = s6e63m0_cfg_ldo;
1646                 vid->enable_ldo = s6e63m0_enable_ldo;
1647
1648                 vid->init_delay = 25000;
1649                 vid->reset_delay = 120000;
1650         }
1651
1652         if (board_is_neptune()) {
1653                 vid->vl_freq    = 100;
1654                 vid->vl_col     = 320;
1655                 vid->vl_row     = 480;
1656                 vid->vl_width   = 320;
1657                 vid->vl_height  = 480;
1658
1659                 vid->vl_clkp    = CONFIG_SYS_HIGH;
1660                 vid->vl_hsp     = CONFIG_SYS_HIGH;
1661                 vid->vl_vsp     = CONFIG_SYS_HIGH;
1662                 vid->vl_dp      = CONFIG_SYS_LOW;
1663                 vid->vl_bpix    = 32;
1664
1665                 /* disable dual lcd mode. */
1666                 vid->dual_lcd_enabled = 0;
1667
1668                 /* S6D16A0X LCD Panel */
1669                 vid->vl_hspw    = 16;
1670                 vid->vl_hbpd    = 24;
1671                 vid->vl_hfpd    = 16;
1672
1673                 vid->vl_vspw    = 2;
1674                 vid->vl_vbpd    = 2;
1675                 vid->vl_vfpd    = 4;
1676
1677                 vid->cfg_gpio = lcd_cfg_gpio;
1678                 vid->backlight_on = NULL;
1679                 vid->lcd_power_on = lcd_power_on;
1680                 vid->reset_lcd = reset_lcd;
1681                 vid->cfg_ldo = s6d16a0x_cfg_ldo;
1682                 vid->enable_ldo = s6d16a0x_enable_ldo;
1683
1684                 vid->init_delay = 10000;
1685                 vid->power_on_delay = 10000;
1686                 vid->reset_delay = 1000;
1687
1688         }
1689
1690         if (machine_is_geminus()) {
1691                 vid->vl_freq    = 60;
1692                 vid->vl_col     = 1024,
1693                 vid->vl_row     = 600,
1694                 vid->vl_width   = 1024,
1695                 vid->vl_height  = 600,
1696                 vid->vl_clkp    = CONFIG_SYS_LOW,
1697                 vid->vl_hsp     = CONFIG_SYS_HIGH,
1698                 vid->vl_vsp     = CONFIG_SYS_HIGH,
1699                 vid->vl_dp      = CONFIG_SYS_LOW,
1700                 vid->vl_bpix    = 32,
1701
1702                 vid->vl_hspw    = 32,
1703                 vid->vl_hfpd    = 48,
1704                 vid->vl_hbpd    = 80,
1705
1706                 vid->vl_vspw    = 1,
1707                 vid->vl_vfpd    = 3,
1708                 vid->vl_vbpd    = 4,
1709
1710                 vid->cfg_gpio = lcd_cfg_gpio;
1711                 vid->reset_lcd = reset_lcd;
1712                 vid->backlight_on = backlight_on;
1713                 vid->lcd_power_on = lcd_power_on;
1714         }
1715 #if 0
1716         vid->vl_freq    = 60;
1717         vid->vl_col     = 480,
1718         vid->vl_row     = 800,
1719         vid->vl_width   = 480,
1720         vid->vl_height  = 800,
1721         vid->vl_clkp    = CONFIG_SYS_HIGH,
1722         vid->vl_hsp     = CONFIG_SYS_LOW,
1723         vid->vl_vsp     = CONFIG_SYS_LOW,
1724         vid->vl_dp      = CONFIG_SYS_HIGH,
1725         vid->vl_bpix    = 32,
1726
1727         /* tl2796 panel. */
1728         vid->vl_hpw     = 4,
1729         vid->vl_blw     = 8,
1730         vid->vl_elw     = 8,
1731
1732         vid->vl_vpw     = 4,
1733         vid->vl_bfw     = 8,
1734         vid->vl_efw     = 8,
1735 #endif
1736 #if 0
1737         vid->vl_freq    = 60;
1738         vid->vl_col     = 1024,
1739         vid->vl_row     = 600,
1740         vid->vl_width   = 1024,
1741         vid->vl_height  = 600,
1742         vid->vl_clkp    = CONFIG_SYS_HIGH,
1743         vid->vl_hsp     = CONFIG_SYS_HIGH,
1744         vid->vl_vsp     = CONFIG_SYS_HIGH,
1745         vid->vl_dp      = CONFIG_SYS_LOW,
1746         vid->vl_bpix    = 32,
1747
1748         /* AMS701KA AMOLED Panel. */
1749         vid->vl_hpw     = 30,
1750         vid->vl_blw     = 114,
1751         vid->vl_elw     = 48,
1752
1753         vid->vl_vpw     = 2,
1754         vid->vl_bfw     = 6,
1755         vid->vl_efw     = 8,
1756 #endif
1757 }
1758 #endif
1759
1760 static void setup_meminfo(void)
1761 {
1762         char meminfo[64] = {0, };
1763         int count = 0, size, real;
1764
1765         size = gd->bd->bi_dram[0].size >> 20;
1766         count += sprintf(meminfo + count, "mem=%dM", size);
1767
1768         /* Each Chip Select can't exceed the 256MiB */
1769         size = gd->bd->bi_dram[1].size >> 20;
1770         real = min(size, 256);
1771         count += sprintf(meminfo + count, " mem=%dM@0x%x",
1772                 real, (unsigned int)gd->bd->bi_dram[1].start);
1773
1774         size -= real;
1775         if (size > 0) {
1776                 count += sprintf(meminfo + count, " mem=%dM@0x%x", size,
1777                         (unsigned int)gd->bd->bi_dram[1].start + (real << 20));
1778         }
1779
1780         setenv("meminfo", meminfo);
1781 }
1782
1783 /*
1784  * CSA partition Migration
1785  * It will be deleted
1786  */
1787 static void csa_migration(void)
1788 {
1789         unsigned int *ubi_id;
1790         int i;
1791
1792         run_command("onenand read 0x40000000 0x400000 0x400000", 0);
1793
1794         for (i = 0; i < 10; i++) {
1795                 ubi_id = (void *) (0x40000000 + 0x40000 * i);
1796                 if (*ubi_id == 0x23494255) /* 0x23494255 = UBI */ {
1797                         printf("CSA Migration is already done....\n");
1798                         return;
1799                 }
1800         }
1801         run_command("onenand erase 0x400000 0x800000", 0);
1802 }
1803
1804 int misc_init_r(void)
1805 {
1806 #ifdef CONFIG_LCD
1807         /* It should be located at first */
1808         lcd_is_enabled = 0;
1809
1810         if (board_is_neptune())
1811                 setenv("lcdinfo", "lcd=s6d16a0x");
1812         else if ((board_is_limo_real() ||
1813                 board_is_limo_universal() ||
1814                 board_is_j1b2()))
1815                 setenv("lcdinfo", "lcd=s6e63m0");
1816         /* it can't classify tl2796 with single-lcd and dual-lcd.
1817         else
1818                 setenv("lcdinfo", "lcd=tl2796-dual");
1819         */
1820
1821         /*
1822          * env values below should be added in case that lcd panel of geminus.
1823          * setenv means that lcd panel has been turned on at u-boot.
1824          */
1825         if (machine_is_geminus())
1826                 setenv("lcdinfo", "lcd=lms480jc01");
1827         if (board_is_media())
1828                 setenv("lcdinfo", "lcd=media");
1829 #endif
1830         setup_meminfo();
1831
1832         show_hw_revision();
1833
1834         /* Set proper PMIC pins */
1835         pmic_pin_init();
1836
1837         /* Check auto burning */
1838         check_auto_burn();
1839
1840         /* To power up I2C2 */
1841         enable_ldos();
1842
1843         /* Enable T-Flash at Limo Real or Limo Universal */
1844         enable_t_flash();
1845
1846         /* Setup Limo Real board GPIOs */
1847         setup_limo_real_gpios();
1848
1849         /* Setup Media board GPIOs */
1850         setup_media_gpios();
1851
1852         /* To usbdown automatically */
1853         check_keypad();
1854
1855         /* check max8998 */
1856         init_pmic();
1857
1858 #ifdef CONFIG_S5PC1XXFB
1859         display_device_info();
1860 #endif
1861
1862         setup_power_down_mode_registers();
1863
1864         /* check max17040 */
1865         check_battery();
1866
1867         /* check fsa9480 */
1868         check_micro_usb(0);
1869
1870         /* csa migration (temporary) */
1871         csa_migration();
1872
1873         return 0;
1874 }
1875 #endif
1876
1877 int board_init(void)
1878 {
1879         /* Set Initial global variables */
1880         s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
1881
1882         gd->bd->bi_arch_number = MACH_TYPE;
1883         gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
1884
1885         /* Check H/W Revision */
1886         check_hw_revision();
1887
1888         return 0;
1889 }
1890
1891 int dram_init(void)
1892 {
1893         unsigned int base, memconfig0, size;
1894         unsigned int memconfig1, sz = 0;
1895
1896         if (cpu_is_s5pc100()) {
1897                 /* In mem setup, we swap the bank. So below size is correct */
1898                 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1899                 gd->bd->bi_dram[0].size = PHYS_SDRAM_2_SIZE;
1900                 gd->bd->bi_dram[1].start = S5PC100_PHYS_SDRAM_2;
1901                 size = 128;
1902         } else {
1903                 /* In S5PC110, we can't swap the DMC0/1 */
1904                 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1905                 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
1906
1907                 base = S5PC110_DMC1_BASE;
1908                 /* DMC configuration */
1909                 memconfig0 = readl(base + MEMCONFIG0_OFFSET);
1910                 gd->bd->bi_dram[1].start = memconfig0 & 0xFF000000;
1911
1912                 size = (memconfig0 >> 16) & 0xFF;
1913                 size = ((unsigned char) ~size) + 1;
1914
1915                 /*
1916                  * (0x07 + 1) * 16 = 128 MiB
1917                  * (0x0f + 1) * 16 = 256 MiB
1918                  */
1919                 size = size << 4;
1920
1921                 /*
1922                  * Aquila Rev0.5 4G3G1G
1923                  * Aquila Rev0.8 4G3G1G
1924                  * Aquila Rev0.9 4G3G1G
1925                  */
1926                 if (machine_is_aquila() &&
1927                     (hwrevision(5) || hwrevision(8) || hwrevision(9))) {
1928                         memconfig1 = readl(base + MEMCONFIG1_OFFSET);
1929
1930                         sz = (memconfig1 >> 16) & 0xFF;
1931                         sz = ((unsigned char) ~sz) + 1;
1932                         sz = sz << 4;
1933                 }
1934
1935         }
1936         /*
1937          * bi_dram[1].size contains all DMC1 memory size
1938          */
1939         gd->bd->bi_dram[1].size = (size + sz) << 20;
1940
1941         return 0;
1942 }
1943
1944 /* Used for sleep test */
1945 static unsigned char saved_val[4][2];
1946 void board_sleep_init_late(void)
1947 {
1948         /* CODEC_LDO_EN: GPF3[4] */
1949         gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, 0);
1950         /* CODEC_XTAL_EN: GPH3[2] */
1951         gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, 0);
1952
1953         /* MMC T_FLASH off */
1954         gpio_direction_output(&s5pc110_gpio->gpio_mp0_5, 4, 0);
1955         /* MHL off */
1956         gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, 0);
1957         gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 7, 0);
1958         gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, 0); /* MHL_ON for REV02 or higher */
1959
1960
1961 }
1962 void board_sleep_init(void)
1963 {
1964         unsigned char addr;
1965         unsigned char val[2];
1966
1967         i2c_set_bus_num(I2C_PMIC);
1968         addr = 0xCC >> 1;
1969         if (i2c_probe(addr)) {
1970                 printf("Can't find max8998\n");
1971                 return;
1972         }
1973
1974         /* Set ONOFF1 */
1975         i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1976         saved_val[0][0] = val[0];
1977         saved_val[0][1] = val[1];
1978         val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4) | (1 << 2) |
1979                         (1 << 1) | (1 << 0));
1980         i2c_write(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1981         i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
1982         /* Set ONOFF2 */
1983         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1984         saved_val[1][0] = val[0];
1985         saved_val[1][1] = val[1];
1986         val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 3) |
1987                         (1 << 2) | (1 << 1) | (1 << 0));
1988         val[0] |= (1 << 7);
1989         i2c_write(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1990         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
1991         /* Set ONOFF3 */
1992         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1993         saved_val[2][0] = val[0];
1994         saved_val[2][1] = val[1];
1995         val[0] &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4));
1996         i2c_write(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1997         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
1998         /* Set ONOFF4 */
1999         i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2000         saved_val[3][0] = val[0];
2001         saved_val[3][1] = val[1];
2002         val[0] &= ~((1 << 7) | (1 << 6) | (1 << 4));
2003         i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2004         i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2005         printf("Turned off regulators. Preparing to sleep. [%s:%d]\n",
2006                         __FILE__, __LINE__);
2007 }
2008
2009 void board_sleep_resume(void)
2010 {
2011         unsigned char addr;
2012         unsigned char val[2];
2013
2014         show_hw_revision();
2015
2016         i2c_set_bus_num(I2C_PMIC);
2017         addr = 0xCC >> 1;
2018         if (i2c_probe(addr)) {
2019                 printf("Can't find max8998\n");
2020                 return;
2021         }
2022
2023         /* Set ONOFF1 */
2024         i2c_write(addr, MAX8998_REG_ONOFF1, 1, saved_val[0], 1);
2025         i2c_read(addr, MAX8998_REG_ONOFF1, 1, val, 1);
2026         /* Set ONOFF2 */
2027         i2c_write(addr, MAX8998_REG_ONOFF2, 1, saved_val[1], 1);
2028         i2c_read(addr, MAX8998_REG_ONOFF2, 1, val, 1);
2029         /* Set ONOFF3 */
2030         i2c_write(addr, MAX8998_REG_ONOFF3, 1, saved_val[2], 1);
2031         i2c_read(addr, MAX8998_REG_ONOFF3, 1, val, 1);
2032         /* Set ONOFF4 */
2033         i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
2034         i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
2035         printf("Waked up.\n");
2036
2037         /* check max17040 */
2038         check_battery();
2039
2040         /* check fsa9480 */
2041         check_micro_usb(1);
2042 }
2043
2044 #ifdef CONFIG_CMD_USBDOWN
2045 int usb_board_init(void)
2046 {
2047 #ifdef CONFIG_CMD_PMIC
2048         run_command("pmic ldo 3 on", 0);
2049 #endif
2050
2051         if (cpu_is_s5pc100()) {
2052 #ifdef CONFIG_HARD_I2C
2053                 uchar val[2] = {0,};
2054
2055                 /* PMIC */
2056                 if (i2c_read(0x66, 0, 1, val, 2)) {
2057                         printf("i2c_read error\n");
2058                         return 1;
2059                 }
2060
2061                 val[0] |= (1 << 3);
2062                 val[1] |= (1 << 5);
2063
2064                 if (i2c_write(0x66, 0, 1, val, 2)) {
2065                         printf("i2c_write error\n");
2066                         return 1;
2067                 }
2068                 i2c_read(0x66, 0, 1, val, 2);
2069 #endif
2070                 return 0;
2071         }
2072
2073         /* S5PC110 */
2074         if (board_is_limo_universal() ||
2075                 board_is_limo_real() ||
2076                 board_is_media()) {
2077                 /* check usb path */
2078                 if (board_is_limo_real() && !hwrevision(6))
2079                         check_mhl();
2080         }
2081
2082         if (machine_is_tickertape())
2083                 /* USB_SEL: XM0ADDR_0: MP04[0] output mode */
2084                 gpio_direction_output(&s5pc110_gpio->gpio_mp0_4, 0, 0);
2085
2086         /* USB Path to AP */
2087         micro_usb_switch(0);
2088
2089         return 0;
2090 }
2091 #endif
2092
2093 #ifdef CONFIG_GENERIC_MMC
2094 int board_mmc_init(bd_t *bis)
2095 {
2096         unsigned int reg;
2097         unsigned int clock;
2098         struct s5pc110_clock *clk = (struct s5pc110_clock *)S5PC1XX_CLOCK_BASE;
2099         int i;
2100
2101         /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
2102         if (machine_is_aquila() && (board_is_aries() || board_is_neptune()))
2103                 gpio_direction_output(&s5pc110_gpio->gpio_j2, 7, 1);
2104
2105         if (machine_is_wmg160())
2106                 return -1;
2107
2108         /* MMC0 Clock source = SCLKMPLL */
2109         reg = readl(&clk->src4);
2110         reg &= ~0xf;
2111         reg |= 0x6;
2112         writel(reg, &clk->src4);
2113
2114         reg = readl(&clk->div4);
2115         reg &= ~0xf;
2116
2117         /* set div value near 50MHz */
2118         clock = get_pll_clk(MPLL) / 1000000;
2119         for (i = 0; i < 0xf; i++) {
2120                 if ((clock / (i + 1)) <= 50) {
2121                         reg |= i << 0;
2122                         break;
2123                 }
2124         }
2125
2126         writel(reg, &clk->div4);
2127
2128         /*
2129          * MMC0 GPIO
2130          * GPG0[0]      SD_0_CLK
2131          * GPG0[1]      SD_0_CMD
2132          * GPG0[2]      SD_0_CDn        -> Not used
2133          * GPG0[3:6]    SD_0_DATA[0:3]
2134          */
2135         for (i = 0; i < 7; i++) {
2136                 if (i == 2)
2137                         continue;
2138                 /* GPG0[0:6] special function 2 */
2139                 gpio_cfg_pin(&s5pc110_gpio->gpio_g0, i, 0x2);
2140                 /* GPG0[0:6] pull disable */
2141                 gpio_set_pull(&s5pc110_gpio->gpio_g0, i, GPIO_PULL_NONE);
2142                 /* GPG0[0:6] drv 4x */
2143                 gpio_set_drv(&s5pc110_gpio->gpio_g0, i, GPIO_DRV_4x);
2144         }
2145
2146         return s5pc1xx_mmc_init(0);
2147 }
2148 #endif
2149
2150 #ifdef CONFIG_CMD_PMIC
2151 static int pmic_status(void)
2152 {
2153         unsigned char addr, val[2];
2154         int reg, i;
2155
2156         i2c_set_bus_num(I2C_PMIC);
2157         addr = 0xCC >> 1;
2158         if (i2c_probe(addr)) {
2159                 printf("Can't found max8998\n");
2160                 return -1;
2161         }
2162
2163         reg = 0x11;
2164         i2c_read(addr, reg, 1, val, 1);
2165         for (i = 7; i >= 4; i--)
2166                 printf("BUCK%d %s\n", 7 - i + 1,
2167                         val[0] & (1 << i) ? "on" : "off");
2168         for (; i >= 0; i--)
2169                 printf("LDO%d %s\n", 5 - i,
2170                         val[0] & (1 << i) ? "on" : "off");
2171         reg = 0x12;
2172         i2c_read(addr, reg, 1, val, 1);
2173         for (i = 7; i >= 0; i--)
2174                 printf("LDO%d %s\n", 7 - i + 6,
2175                         val[0] & (1 << i) ? "on" : "off");
2176         reg = 0x13;
2177         i2c_read(addr, reg, 1, val, 1);
2178         for (i = 7; i >= 4; i--)
2179                 printf("LDO%d %s\n", 7 - i + 14,
2180                         val[0] & (1 << i) ? "on" : "off");
2181
2182         reg = 0xd;
2183         i2c_read(addr, reg, 1, val, 1);
2184         for (i = 7; i >= 6; i--)
2185                 printf("SAFEOUT%d %s\n", 7 - i + 1,
2186                         val[0] & (1 << i) ? "on" : "off");
2187         return 0;
2188 }
2189
2190 static int pmic_ldo_control(int buck, int ldo, int safeout, int on)
2191 {
2192         unsigned char addr, val[2];
2193         unsigned int reg, shift;
2194
2195         if (ldo) {
2196                 if (ldo < 2)
2197                         return -1;
2198                 if (ldo <= 5) {
2199                         reg = 0x11;
2200                         shift = 5 - ldo;
2201                 } else if (ldo <= 13) {
2202                         reg = 0x12;
2203                         shift = 13 - ldo;
2204                 } else if (ldo <= 17) {
2205                         reg = 0x13;
2206                         shift = 17 - ldo + 4;
2207                 } else
2208                         return -1;
2209         } else if (buck) {
2210                 if (buck > 4)
2211                         return -1;
2212                 reg = 0x11;
2213                 shift = 4 - buck + 4;
2214         } else if (safeout) {
2215                 if (safeout > 3)
2216                         return -1;
2217                 reg = 0xd;
2218                 shift = 8 - safeout;
2219         } else
2220                 return -1;
2221
2222         i2c_set_bus_num(I2C_PMIC);
2223         addr = 0xCC >> 1;
2224         if (i2c_probe(addr)) {
2225                 printf("Can't found max8998\n");
2226                 return -1;
2227         }
2228
2229         i2c_read(addr, reg, 1, val, 1);
2230         if (on)
2231                 val[0] |= (1 << shift);
2232         else
2233                 val[0] &= ~(1 << shift);
2234         i2c_write(addr, reg, 1, val, 1);
2235         i2c_read(addr, reg, 1, val, 1);
2236
2237         if (ldo)
2238                 printf("ldo %d value 0x%x, %s\n", ldo, val[0],
2239                         val[0] & (1 << shift) ? "on" : "off");
2240         else if (buck)
2241                 printf("buck %d value 0x%x, %s\n", buck, val[0],
2242                         val[0] & (1 << shift) ? "on" : "off");
2243         else if (safeout)
2244                 printf("safeout %d value 0x%x, %s\n", safeout, val[0],
2245                         val[0] & (1 << shift) ? "on" : "off");
2246
2247         return 0;
2248 }
2249
2250 static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2251 {
2252         int buck = 0, ldo = 0, safeout = 0, on = -1;
2253
2254         switch (argc) {
2255         case 2:
2256                 if (strncmp(argv[1], "status", 6) == 0)
2257                         return pmic_status();
2258                 break;
2259         case 4:
2260                 if (strncmp(argv[1], "ldo", 3) == 0)
2261                         ldo = simple_strtoul(argv[2], NULL, 10);
2262                 else if (strncmp(argv[1], "buck", 4) == 0)
2263                         buck = simple_strtoul(argv[2], NULL, 10);
2264                 else if (strncmp(argv[1], "safeout", 7) == 0)
2265                         safeout = simple_strtoul(argv[2], NULL, 10);
2266                 else
2267                         break;
2268
2269                 if (strncmp(argv[3], "on", 2) == 0)
2270                         on = 1;
2271                 else if (strncmp(argv[3], "off", 3) == 0)
2272                         on = 0;
2273                 else
2274                         break;
2275
2276                 return pmic_ldo_control(buck, ldo, safeout, on);
2277
2278         default:
2279                 break;
2280         }
2281
2282         cmd_usage(cmdtp);
2283         return 1;
2284 }
2285
2286 U_BOOT_CMD(
2287         pmic,           CONFIG_SYS_MAXARGS,     1, do_pmic,
2288         "PMIC LDO & BUCK control",
2289         "status - Display PMIC LDO & BUCK status\n"
2290         "pmic ldo num on/off - Turn on/off the LDO\n"
2291         "pmic buck num on/off - Turn on/off the BUCK\n"
2292         "pmic safeout num on/off - Turn on/off the SAFEOUT\n"
2293 );
2294 #endif
2295
2296 #ifdef CONFIG_CMD_DEVICE_POWER
2297
2298 enum {
2299         POWER_NONE,
2300         POWER_TOUCH,
2301         POWER_3_TOUCHKEY,
2302         POWER_LCD,
2303         POWER_HAPTIC,
2304         POWER_AUDIO_CODEC,
2305         POWER_FM_RADIO,
2306         POWER_BT_WIFI,
2307         POWER_HDMI,
2308 };
2309
2310 static void power_display_devices(void)
2311 {
2312         printf("devices:\n");
2313         printf("\t%d - touch\n", POWER_TOUCH);
2314         printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
2315         printf("\t%d - LCD\n", POWER_LCD);
2316         printf("\t%d - Haptic\n", POWER_HAPTIC);
2317         printf("\t%d - Audio Codec\n", POWER_AUDIO_CODEC);
2318         printf("\t%d - FM Radio\n", POWER_FM_RADIO);
2319         printf("\t%d - BT/WiFi\n", POWER_BT_WIFI);
2320         printf("\t%d - HDMI\n", POWER_HDMI);
2321 }
2322
2323 static int power_hdmi(int on)
2324 {
2325         /* HDMI_EN1: GPJ2[2] */
2326         gpio_direction_output(&s5pc110_gpio->gpio_j2, 2, on);
2327         /* MHL_ON: GPJ2[3] */
2328         gpio_direction_output(&s5pc110_gpio->gpio_j2, 3, on);
2329         return 0;
2330 }
2331
2332 static int power_bt_wifi(int on)
2333 {
2334         /* WLAN_BT_EN: GPB[5] */
2335         gpio_direction_output(&s5pc110_gpio->gpio_b, 5, on);
2336         return 0;
2337 }
2338
2339 static int power_fm_radio(int on)
2340 {
2341         /* FM_BUS_nRST: GPJ2[5] */
2342         gpio_direction_output(&s5pc110_gpio->gpio_j2, 5, !on);
2343         return 0;
2344 }
2345
2346 static int power_audio_codec(int on)
2347 {
2348         /* CODEC_LDO_EN: GPF3[4] */
2349         gpio_direction_output(&s5pc110_gpio->gpio_f3, 4, on);
2350         /* CODEC_XTAL_EN: GPH3[2] */
2351         gpio_direction_output(&s5pc110_gpio->gpio_h3, 2, on);
2352         return 0;
2353 }
2354
2355 static int power_haptic(int on)
2356 {
2357         /* HAPTIC_ON: GPJ1[1] */
2358         gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
2359         return 0;
2360 }
2361
2362 static int power_lcd(int on)
2363 {
2364         /* MLCD_ON: GPJ1[3] */
2365         gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
2366         return 0;
2367 }
2368
2369 static int power_touch(int on)
2370 {
2371         /* TOUCH_EN: GPG3[6] */
2372         gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
2373         return 0;
2374 }
2375
2376 static int power_3_touchkey(int on)
2377 {
2378         if (on) {
2379                 /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
2380                 /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
2381                 if (board_rev & J1_B2_BOARD)
2382                         gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
2383                 else
2384                         gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
2385
2386                 /* 3_TOUCH_CE - GPJ2[6] */
2387                 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on);   /* TOUCH_CE */
2388         } else {
2389                 /* 3_TOUCH_CE - GPJ2[6] */
2390                 gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on);   /* TOUCH_CE */
2391         }
2392
2393         if (on) {
2394                 unsigned int reg;
2395                 unsigned char val[2];
2396                 unsigned char addr = 0x20;              /* mcs5000 3-touchkey */
2397
2398                 /* Require 100ms */
2399                 udelay(80 * 1000);
2400
2401                 /* 3 touchkey */
2402                 i2c_set_bus_num(I2C_GPIO10);
2403
2404                 /* Workaround to probe */
2405                 if (i2c_probe(addr)) {
2406                         if (i2c_probe(addr)) {
2407                                 printf("Can't found 3 touchkey\n");
2408                                 return -ENODEV;
2409                         }
2410                 }
2411
2412 #define MCS5000_TK_HW_VERSION  0x06
2413 #define MCS5000_TK_FW_VERSION  0x0A
2414 #define MCS5000_TK_MI_VERSION  0x0B
2415
2416                 reg = MCS5000_TK_MI_VERSION;
2417                 i2c_read(addr, reg, 1, val, 1);
2418                 printf("3-touchkey:\tM/I 0x%x, ", val[0]);
2419                 reg = MCS5000_TK_HW_VERSION;
2420                 i2c_read(addr, reg, 1, val, 1);
2421                 printf("H/W 0x%x, ", val[0]);
2422                 reg = MCS5000_TK_FW_VERSION;
2423                 i2c_read(addr, reg, 1, val, 1);
2424                 printf("F/W 0x%x\n", val[0]);
2425         }
2426         return 0;
2427 }
2428
2429 static int power_control(int device, int on)
2430 {
2431         switch (device) {
2432         case POWER_TOUCH:
2433                 return power_touch(on);
2434         case POWER_3_TOUCHKEY:
2435                 return power_3_touchkey(on);
2436         case POWER_LCD:
2437                 return power_lcd(on);
2438         case POWER_HAPTIC:
2439                 return power_haptic(on);
2440         case POWER_AUDIO_CODEC:
2441                 return power_audio_codec(on);
2442         case POWER_FM_RADIO:
2443                 return power_fm_radio(on);
2444         case POWER_BT_WIFI:
2445                 return power_bt_wifi(on);
2446         case POWER_HDMI:
2447                 return power_hdmi(on);
2448         default:
2449                 printf("I don't know device %d\n", device);
2450                 break;
2451         }
2452         return 0;
2453 }
2454
2455 static int power_on(int on)
2456 {
2457         power_touch(on);
2458         power_3_touchkey(on);
2459         power_lcd(on);
2460         power_haptic(on);
2461         power_audio_codec(on);
2462         power_fm_radio(on);
2463         power_bt_wifi(on);
2464         power_hdmi(on);
2465
2466         return 0;
2467 }
2468
2469 static int do_power(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2470 {
2471         int device, on;
2472
2473         if (!machine_is_aquila())
2474                 goto out;
2475
2476         switch (argc) {
2477         case 2:
2478                 if (strncmp(argv[1], "on", 2) == 0)
2479                         return power_on(1);
2480                 if (strncmp(argv[1], "off", 3) == 0)
2481                         return power_on(0);
2482                 break;
2483         case 3:
2484                 device = simple_strtoul(argv[1], NULL, 10);
2485                 if (device < 0)
2486                         break;
2487
2488                 if (strncmp(argv[2], "on", 2) == 0)
2489                         on = 1;
2490                 else if (strncmp(argv[2], "off", 3) == 0)
2491                         on = 0;
2492                 else
2493                         break;
2494                 return power_control(device, on);
2495         default:
2496                 break;
2497         }
2498 out:
2499         cmd_usage(cmdtp);
2500         power_display_devices();
2501         return 1;
2502 }
2503
2504 U_BOOT_CMD(
2505         power,          CONFIG_SYS_MAXARGS,     1, do_power,
2506         "Device Power Management control",
2507         "device on/off - Turn on/off the device\n"
2508 );
2509
2510 static int do_microusb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2511 {
2512         switch (argc) {
2513         case 2:
2514                 if (strncmp(argv[1], "cp", 2) == 0) {
2515                         micro_usb_switch(1);
2516                         pmic_ldo_control(0, 0, 2, 1);
2517                         setenv("usb", "cp");
2518                 } else if (strncmp(argv[1], "ap", 2) == 0) {
2519                         micro_usb_switch(0);
2520                         pmic_ldo_control(0, 0, 2, 0);
2521                         setenv("usb", "ap");
2522                 }
2523                 break;
2524         default:
2525                 cmd_usage(cmdtp);
2526                 return 1;
2527         }
2528
2529         saveenv();
2530
2531         printf("USB Path is set to %s\n", getenv("usb"));
2532
2533         return 0;
2534 }
2535
2536 U_BOOT_CMD(
2537         microusb,               CONFIG_SYS_MAXARGS,     1, do_microusb,
2538         "Micro USB Switch",
2539         "cp - switch to CP\n"
2540         "microusb ap - switch to AP\n"
2541 );
2542 #endif