blob: 0d3453bf567c29e85290774973bd19e0a59b5d89 [file] [log] [blame]
Vasily Khoruzhickc394f172010-05-11 09:55:07 +03001/* linux/arch/arm/mach-s3c2440/mach-rx1950.c
2 *
3 * Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev,
4 * Copyright (c) 2007-2010 Vasily Khoruzhick
5 *
6 * based on smdk2440 written by Ben Dooks
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12*/
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/list.h>
Russell King8d717a52010-05-22 19:47:18 +010018#include <linux/memblock.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030019#include <linux/delay.h>
20#include <linux/timer.h>
21#include <linux/init.h>
22#include <linux/gpio.h>
23#include <linux/platform_device.h>
24#include <linux/serial_core.h>
25#include <linux/input.h>
26#include <linux/gpio_keys.h>
27#include <linux/sysdev.h>
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +030028#include <linux/pda_power.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030029#include <linux/pwm_backlight.h>
30#include <linux/pwm.h>
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +030031#include <linux/s3c_adc_battery.h>
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +030032#include <linux/leds.h>
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +030033#include <linux/i2c.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030034
35#include <linux/mtd/mtd.h>
36#include <linux/mtd/partitions.h>
37
38#include <linux/mmc/host.h>
39
40#include <asm/mach/arch.h>
41#include <asm/mach/map.h>
42#include <asm/mach-types.h>
43
44#include <mach/regs-gpio.h>
45#include <mach/regs-gpioj.h>
Kukjin Kim61c542b2011-10-03 09:46:13 +090046#include <mach/regs-lcd.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030047#include <mach/h1940.h>
48#include <mach/fb.h>
49
50#include <plat/clock.h>
51#include <plat/regs-serial.h>
52#include <plat/regs-iic.h>
53#include <plat/mci.h>
54#include <plat/udc.h>
55#include <plat/nand.h>
56#include <plat/iic.h>
57#include <plat/devs.h>
58#include <plat/cpu.h>
59#include <plat/pm.h>
60#include <plat/irq.h>
61#include <plat/ts.h>
62
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +030063#include <sound/uda1380.h>
64
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030065#define LCD_PWM_PERIOD 192960
66#define LCD_PWM_DUTY 127353
67
68static struct map_desc rx1950_iodesc[] __initdata = {
69};
70
71static struct s3c24xx_uart_clksrc rx1950_serial_clocks[] = {
72 [0] = {
73 .name = "fclk",
74 .divisor = 0x0a,
75 .min_baud = 0,
76 .max_baud = 0,
77 },
78};
79
80static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
81 [0] = {
82 .hwport = 0,
83 .flags = 0,
84 .ucon = 0x3c5,
85 .ulcon = 0x03,
86 .ufcon = 0x51,
87 .clocks = rx1950_serial_clocks,
88 .clocks_size = ARRAY_SIZE(rx1950_serial_clocks),
89 },
90 [1] = {
91 .hwport = 1,
92 .flags = 0,
93 .ucon = 0x3c5,
94 .ulcon = 0x03,
95 .ufcon = 0x51,
96 .clocks = rx1950_serial_clocks,
97 .clocks_size = ARRAY_SIZE(rx1950_serial_clocks),
98 },
99 /* IR port */
100 [2] = {
101 .hwport = 2,
102 .flags = 0,
103 .ucon = 0x3c5,
104 .ulcon = 0x43,
105 .ufcon = 0xf1,
106 .clocks = rx1950_serial_clocks,
107 .clocks_size = ARRAY_SIZE(rx1950_serial_clocks),
108 },
109};
110
111static struct s3c2410fb_display rx1950_display = {
112 .type = S3C2410_LCDCON1_TFT,
113 .width = 240,
114 .height = 320,
115 .xres = 240,
116 .yres = 320,
117 .bpp = 16,
118
119 .pixclock = 260000,
120 .left_margin = 10,
121 .right_margin = 20,
122 .hsync_len = 10,
123 .upper_margin = 2,
124 .lower_margin = 2,
125 .vsync_len = 2,
126
127 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
128 S3C2410_LCDCON5_INVVCLK |
129 S3C2410_LCDCON5_INVVLINE |
130 S3C2410_LCDCON5_INVVFRAME |
131 S3C2410_LCDCON5_HWSWP |
132 (0x02 << 13) |
133 (0x02 << 15),
134
135};
136
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300137static int power_supply_init(struct device *dev)
138{
139 return gpio_request(S3C2410_GPF(2), "cable plugged");
140}
141
142static int rx1950_is_ac_online(void)
143{
144 return !gpio_get_value(S3C2410_GPF(2));
145}
146
147static void power_supply_exit(struct device *dev)
148{
149 gpio_free(S3C2410_GPF(2));
150}
151
152static char *rx1950_supplicants[] = {
153 "main-battery"
154};
155
156static struct pda_power_pdata power_supply_info = {
157 .init = power_supply_init,
158 .is_ac_online = rx1950_is_ac_online,
159 .exit = power_supply_exit,
160 .supplied_to = rx1950_supplicants,
161 .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
162};
163
164static struct resource power_supply_resources[] = {
165 [0] = {
166 .name = "ac",
167 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
168 IORESOURCE_IRQ_HIGHEDGE,
169 .start = IRQ_EINT2,
170 .end = IRQ_EINT2,
171 },
172};
173
174static struct platform_device power_supply = {
175 .name = "pda-power",
176 .id = -1,
177 .dev = {
178 .platform_data =
179 &power_supply_info,
180 },
181 .resource = power_supply_resources,
182 .num_resources = ARRAY_SIZE(power_supply_resources),
183};
184
185static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
186 { .volt = 4100, .cur = 156, .level = 100},
187 { .volt = 4050, .cur = 156, .level = 95},
188 { .volt = 4025, .cur = 141, .level = 90},
189 { .volt = 3995, .cur = 144, .level = 85},
190 { .volt = 3957, .cur = 162, .level = 80},
191 { .volt = 3931, .cur = 147, .level = 75},
192 { .volt = 3902, .cur = 147, .level = 70},
193 { .volt = 3863, .cur = 153, .level = 65},
194 { .volt = 3838, .cur = 150, .level = 60},
195 { .volt = 3800, .cur = 153, .level = 55},
196 { .volt = 3765, .cur = 153, .level = 50},
197 { .volt = 3748, .cur = 172, .level = 45},
198 { .volt = 3740, .cur = 153, .level = 40},
199 { .volt = 3714, .cur = 175, .level = 35},
200 { .volt = 3710, .cur = 156, .level = 30},
201 { .volt = 3963, .cur = 156, .level = 25},
202 { .volt = 3672, .cur = 178, .level = 20},
203 { .volt = 3651, .cur = 178, .level = 15},
204 { .volt = 3629, .cur = 178, .level = 10},
205 { .volt = 3612, .cur = 162, .level = 5},
206 { .volt = 3605, .cur = 162, .level = 0},
207};
208
209static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
210 { .volt = 4200, .cur = 0, .level = 100},
211 { .volt = 4190, .cur = 0, .level = 99},
212 { .volt = 4178, .cur = 0, .level = 95},
213 { .volt = 4110, .cur = 0, .level = 70},
214 { .volt = 4076, .cur = 0, .level = 65},
215 { .volt = 4046, .cur = 0, .level = 60},
216 { .volt = 4021, .cur = 0, .level = 55},
217 { .volt = 3999, .cur = 0, .level = 50},
218 { .volt = 3982, .cur = 0, .level = 45},
219 { .volt = 3965, .cur = 0, .level = 40},
220 { .volt = 3957, .cur = 0, .level = 35},
221 { .volt = 3948, .cur = 0, .level = 30},
222 { .volt = 3936, .cur = 0, .level = 25},
223 { .volt = 3927, .cur = 0, .level = 20},
224 { .volt = 3906, .cur = 0, .level = 15},
225 { .volt = 3880, .cur = 0, .level = 10},
226 { .volt = 3829, .cur = 0, .level = 5},
227 { .volt = 3820, .cur = 0, .level = 0},
228};
229
230int rx1950_bat_init(void)
231{
232 int ret;
233
234 ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
235 if (ret)
236 goto err_gpio1;
237 ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
238 if (ret)
239 goto err_gpio2;
240
241 return 0;
242
243err_gpio2:
244 gpio_free(S3C2410_GPJ(2));
245err_gpio1:
246 return ret;
247}
248
249void rx1950_bat_exit(void)
250{
251 gpio_free(S3C2410_GPJ(2));
252 gpio_free(S3C2410_GPJ(3));
253}
254
255void rx1950_enable_charger(void)
256{
257 gpio_direction_output(S3C2410_GPJ(2), 1);
258 gpio_direction_output(S3C2410_GPJ(3), 1);
259}
260
261void rx1950_disable_charger(void)
262{
263 gpio_direction_output(S3C2410_GPJ(2), 0);
264 gpio_direction_output(S3C2410_GPJ(3), 0);
265}
266
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200267DEFINE_SPINLOCK(rx1950_blink_spin);
268
269static int rx1950_led_blink_set(unsigned gpio, int state,
270 unsigned long *delay_on, unsigned long *delay_off)
271{
272 int blink_gpio, check_gpio;
273
274 switch (gpio) {
275 case S3C2410_GPA(6):
276 blink_gpio = S3C2410_GPA(4);
277 check_gpio = S3C2410_GPA(3);
278 break;
279 case S3C2410_GPA(7):
280 blink_gpio = S3C2410_GPA(3);
281 check_gpio = S3C2410_GPA(4);
282 break;
283 default:
284 return -EINVAL;
285 break;
286 }
287
288 if (delay_on && delay_off && !*delay_on && !*delay_off)
289 *delay_on = *delay_off = 500;
290
291 spin_lock(&rx1950_blink_spin);
292
293 switch (state) {
294 case GPIO_LED_NO_BLINK_LOW:
295 case GPIO_LED_NO_BLINK_HIGH:
296 if (!gpio_get_value(check_gpio))
297 gpio_set_value(S3C2410_GPJ(6), 0);
298 gpio_set_value(blink_gpio, 0);
299 gpio_set_value(gpio, state);
300 break;
301 case GPIO_LED_BLINK:
302 gpio_set_value(gpio, 0);
303 gpio_set_value(S3C2410_GPJ(6), 1);
304 gpio_set_value(blink_gpio, 1);
305 break;
306 }
307
308 spin_unlock(&rx1950_blink_spin);
309
310 return 0;
311}
312
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300313static struct gpio_led rx1950_leds_desc[] = {
314 {
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200315 .name = "Green",
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300316 .default_trigger = "main-battery-full",
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200317 .gpio = S3C2410_GPA(6),
318 .retain_state_suspended = 1,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300319 },
320 {
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200321 .name = "Red",
322 .default_trigger
323 = "main-battery-charging-blink-full-solid",
324 .gpio = S3C2410_GPA(7),
325 .retain_state_suspended = 1,
326 },
327 {
328 .name = "Blue",
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300329 .default_trigger = "rx1950-acx-mem",
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200330 .gpio = S3C2410_GPA(11),
331 .retain_state_suspended = 1,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300332 },
333};
334
335static struct gpio_led_platform_data rx1950_leds_pdata = {
336 .num_leds = ARRAY_SIZE(rx1950_leds_desc),
337 .leds = rx1950_leds_desc,
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200338 .gpio_blink_set = rx1950_led_blink_set,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300339};
340
341static struct platform_device rx1950_leds = {
342 .name = "leds-gpio",
343 .id = -1,
344 .dev = {
345 .platform_data = &rx1950_leds_pdata,
346 },
347};
348
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300349static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
350 .init = rx1950_bat_init,
351 .exit = rx1950_bat_exit,
352 .enable_charger = rx1950_enable_charger,
353 .disable_charger = rx1950_disable_charger,
354 .gpio_charge_finished = S3C2410_GPF(3),
355 .lut_noac = bat_lut_noac,
356 .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
357 .lut_acin = bat_lut_acin,
358 .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
359 .volt_channel = 0,
360 .current_channel = 1,
361 .volt_mult = 4235,
362 .current_mult = 2900,
363 .internal_impedance = 200,
364};
365
366static struct platform_device rx1950_battery = {
367 .name = "s3c-adc-battery",
368 .id = -1,
369 .dev = {
370 .parent = &s3c_device_adc.dev,
371 .platform_data = &rx1950_bat_cfg,
372 },
373};
374
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300375static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
376 .displays = &rx1950_display,
377 .num_displays = 1,
378 .default_display = 0,
379
380 .lpcsel = 0x02,
381 .gpccon = 0xaa9556a9,
382 .gpccon_mask = 0xffc003fc,
383 .gpcup = 0x0000ffff,
384 .gpcup_mask = 0xffffffff,
385
386 .gpdcon = 0xaa90aaa1,
387 .gpdcon_mask = 0xffc0fff0,
388 .gpdup = 0x0000fcfd,
389 .gpdup_mask = 0xffffffff,
390
391};
392
393static struct pwm_device *lcd_pwm;
394
395void rx1950_lcd_power(int enable)
396{
397 int i;
398 static int enabled;
399 if (enabled == enable)
400 return;
401 if (!enable) {
402
403 /* GPC11-GPC15->OUTPUT */
404 for (i = 11; i < 16; i++)
405 gpio_direction_output(S3C2410_GPC(i), 1);
406
407 /* Wait a bit here... */
408 mdelay(100);
409
410 /* GPD2-GPD7->OUTPUT */
411 /* GPD11-GPD15->OUTPUT */
412 /* GPD2-GPD7->1, GPD11-GPD15->1 */
413 for (i = 2; i < 8; i++)
414 gpio_direction_output(S3C2410_GPD(i), 1);
415 for (i = 11; i < 16; i++)
416 gpio_direction_output(S3C2410_GPD(i), 1);
417
418 /* Wait a bit here...*/
419 mdelay(100);
420
421 /* GPB0->OUTPUT, GPB0->0 */
422 gpio_direction_output(S3C2410_GPB(0), 0);
423
424 /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
425 for (i = 1; i < 5; i++)
426 gpio_direction_output(S3C2410_GPC(i), 0);
427
428 /* GPC15-GPC11->0 */
429 for (i = 11; i < 16; i++)
430 gpio_direction_output(S3C2410_GPC(i), 0);
431
432 /* GPD15-GPD11->0, GPD2->GPD7->0 */
433 for (i = 11; i < 16; i++)
434 gpio_direction_output(S3C2410_GPD(i), 0);
435
436 for (i = 2; i < 8; i++)
437 gpio_direction_output(S3C2410_GPD(i), 0);
438
439 /* GPC6->0, GPC7->0, GPC5->0 */
440 gpio_direction_output(S3C2410_GPC(6), 0);
441 gpio_direction_output(S3C2410_GPC(7), 0);
442 gpio_direction_output(S3C2410_GPC(5), 0);
443
444 /* GPB1->OUTPUT, GPB1->0 */
445 gpio_direction_output(S3C2410_GPB(1), 0);
446 pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
447 pwm_disable(lcd_pwm);
448
449 /* GPC0->0, GPC10->0 */
450 gpio_direction_output(S3C2410_GPC(0), 0);
451 gpio_direction_output(S3C2410_GPC(10), 0);
452 } else {
453 pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
454 pwm_enable(lcd_pwm);
455
456 gpio_direction_output(S3C2410_GPC(0), 1);
457 gpio_direction_output(S3C2410_GPC(5), 1);
458
459 s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
460 gpio_direction_output(S3C2410_GPC(7), 1);
461
462 for (i = 1; i < 5; i++)
463 s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
464
465 for (i = 11; i < 16; i++)
466 s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
467
468 for (i = 2; i < 8; i++)
469 s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
470
471 for (i = 11; i < 16; i++)
472 s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
473
474 gpio_direction_output(S3C2410_GPC(10), 1);
475 gpio_direction_output(S3C2410_GPC(6), 1);
476 }
477 enabled = enable;
478}
479
480static void rx1950_bl_power(int enable)
481{
482 static int enabled;
483 if (enabled == enable)
484 return;
485 if (!enable) {
486 gpio_direction_output(S3C2410_GPB(0), 0);
487 } else {
488 /* LED driver need a "push" to power on */
489 gpio_direction_output(S3C2410_GPB(0), 1);
490 /* Warm up backlight for one period of PWM.
491 * Without this trick its almost impossible to
492 * enable backlight with low brightness value
493 */
494 ndelay(48000);
495 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
496 }
497 enabled = enable;
498}
499
500static int rx1950_backlight_init(struct device *dev)
501{
502 WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
503 lcd_pwm = pwm_request(1, "RX1950 LCD");
504 if (IS_ERR(lcd_pwm)) {
505 dev_err(dev, "Unable to request PWM for LCD power!\n");
506 return PTR_ERR(lcd_pwm);
507 }
508
509 rx1950_lcd_power(1);
510 rx1950_bl_power(1);
511
512 return 0;
513}
514
515static void rx1950_backlight_exit(struct device *dev)
516{
517 rx1950_bl_power(0);
518 rx1950_lcd_power(0);
519
520 pwm_free(lcd_pwm);
521 gpio_free(S3C2410_GPB(0));
522}
523
524
525static int rx1950_backlight_notify(struct device *dev, int brightness)
526{
527 if (!brightness) {
528 rx1950_bl_power(0);
529 rx1950_lcd_power(0);
530 } else {
531 rx1950_lcd_power(1);
532 rx1950_bl_power(1);
533 }
534 return brightness;
535}
536
537static struct platform_pwm_backlight_data rx1950_backlight_data = {
538 .pwm_id = 0,
539 .max_brightness = 24,
540 .dft_brightness = 4,
541 .pwm_period_ns = 48000,
542 .init = rx1950_backlight_init,
543 .notify = rx1950_backlight_notify,
544 .exit = rx1950_backlight_exit,
545};
546
547static struct platform_device rx1950_backlight = {
548 .name = "pwm-backlight",
549 .dev = {
550 .parent = &s3c_device_timer[0].dev,
551 .platform_data = &rx1950_backlight_data,
552 },
553};
554
555static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
556{
557 switch (power_mode) {
558 case MMC_POWER_OFF:
559 gpio_direction_output(S3C2410_GPJ(1), 0);
560 break;
561 case MMC_POWER_UP:
562 case MMC_POWER_ON:
563 gpio_direction_output(S3C2410_GPJ(1), 1);
564 break;
565 default:
566 break;
567 }
568}
569
570static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
571 .gpio_detect = S3C2410_GPF(5),
572 .gpio_wprotect = S3C2410_GPH(8),
573 .set_power = rx1950_set_mmc_power,
574 .ocr_avail = MMC_VDD_32_33,
575};
576
577static struct mtd_partition rx1950_nand_part[] = {
578 [0] = {
579 .name = "Boot0",
580 .offset = 0,
581 .size = 0x4000,
582 .mask_flags = MTD_WRITEABLE,
583 },
584 [1] = {
585 .name = "Boot1",
586 .offset = MTDPART_OFS_APPEND,
587 .size = 0x40000,
588 .mask_flags = MTD_WRITEABLE,
589 },
590 [2] = {
591 .name = "Kernel",
592 .offset = MTDPART_OFS_APPEND,
593 .size = 0x300000,
594 .mask_flags = 0,
595 },
596 [3] = {
597 .name = "Filesystem",
598 .offset = MTDPART_OFS_APPEND,
599 .size = MTDPART_SIZ_FULL,
600 .mask_flags = 0,
601 },
602};
603
604static struct s3c2410_nand_set rx1950_nand_sets[] = {
605 [0] = {
606 .name = "Internal",
607 .nr_chips = 1,
608 .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
609 .partitions = rx1950_nand_part,
610 },
611};
612
613static struct s3c2410_platform_nand rx1950_nand_info = {
614 .tacls = 25,
615 .twrph0 = 50,
616 .twrph1 = 15,
617 .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
618 .sets = rx1950_nand_sets,
619};
620
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300621static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300622 .vbus_pin = S3C2410_GPG(5),
623 .vbus_pin_inverted = 1,
Lars-Peter Clausene27c3c52011-03-07 08:42:00 +0100624 .pullup_pin = S3C2410_GPJ(5),
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300625};
626
627static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
628 .delay = 10000,
629 .presc = 49,
630 .oversampling_shift = 3,
631};
632
633static struct gpio_keys_button rx1950_gpio_keys_table[] = {
634 {
635 .code = KEY_POWER,
636 .gpio = S3C2410_GPF(0),
637 .active_low = 1,
638 .desc = "Power button",
639 .wakeup = 1,
640 },
641 {
642 .code = KEY_F5,
643 .gpio = S3C2410_GPF(7),
644 .active_low = 1,
645 .desc = "Record button",
646 },
647 {
648 .code = KEY_F1,
649 .gpio = S3C2410_GPG(0),
650 .active_low = 1,
651 .desc = "Calendar button",
652 },
653 {
654 .code = KEY_F2,
655 .gpio = S3C2410_GPG(2),
656 .active_low = 1,
657 .desc = "Contacts button",
658 },
659 {
660 .code = KEY_F3,
661 .gpio = S3C2410_GPG(3),
662 .active_low = 1,
663 .desc = "Mail button",
664 },
665 {
666 .code = KEY_F4,
667 .gpio = S3C2410_GPG(7),
668 .active_low = 1,
669 .desc = "WLAN button",
670 },
671 {
672 .code = KEY_LEFT,
673 .gpio = S3C2410_GPG(10),
674 .active_low = 1,
675 .desc = "Left button",
676 },
677 {
678 .code = KEY_RIGHT,
679 .gpio = S3C2410_GPG(11),
680 .active_low = 1,
681 .desc = "Right button",
682 },
683 {
684 .code = KEY_UP,
685 .gpio = S3C2410_GPG(4),
686 .active_low = 1,
687 .desc = "Up button",
688 },
689 {
690 .code = KEY_DOWN,
691 .gpio = S3C2410_GPG(6),
692 .active_low = 1,
693 .desc = "Down button",
694 },
695 {
696 .code = KEY_ENTER,
697 .gpio = S3C2410_GPG(9),
698 .active_low = 1,
699 .desc = "Ok button"
700 },
701};
702
703static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
704 .buttons = rx1950_gpio_keys_table,
705 .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
706};
707
708static struct platform_device rx1950_device_gpiokeys = {
709 .name = "gpio-keys",
710 .dev.platform_data = &rx1950_gpio_keys_data,
711};
712
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +0300713static struct uda1380_platform_data uda1380_info = {
714 .gpio_power = S3C2410_GPJ(0),
715 .gpio_reset = S3C2410_GPD(0),
716 .dac_clk = UDA1380_DAC_CLK_SYSCLK,
717};
718
719static struct i2c_board_info rx1950_i2c_devices[] = {
720 {
721 I2C_BOARD_INFO("uda1380", 0x1a),
722 .platform_data = &uda1380_info,
723 },
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300724};
725
726static struct platform_device *rx1950_devices[] __initdata = {
727 &s3c_device_lcd,
728 &s3c_device_wdt,
729 &s3c_device_i2c0,
730 &s3c_device_iis,
Jassi Brar83e37b82010-11-22 15:35:53 +0900731 &samsung_asoc_dma,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300732 &s3c_device_usbgadget,
733 &s3c_device_rtc,
734 &s3c_device_nand,
735 &s3c_device_sdi,
736 &s3c_device_adc,
737 &s3c_device_ts,
738 &s3c_device_timer[0],
739 &s3c_device_timer[1],
740 &rx1950_backlight,
741 &rx1950_device_gpiokeys,
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300742 &power_supply,
743 &rx1950_battery,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300744 &rx1950_leds,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300745};
746
747static struct clk *rx1950_clocks[] __initdata = {
748 &s3c24xx_clkout0,
749 &s3c24xx_clkout1,
750};
751
752static void __init rx1950_map_io(void)
753{
754 s3c24xx_clkout0.parent = &clk_h;
755 s3c24xx_clkout1.parent = &clk_f;
756
757 s3c24xx_register_clocks(rx1950_clocks, ARRAY_SIZE(rx1950_clocks));
758
759 s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
760 s3c24xx_init_clocks(16934000);
761 s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
762
763 /* setup PM */
764
765#ifdef CONFIG_PM_H1940
766 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
767#endif
768
769 s3c_pm_init();
770}
771
772static void __init rx1950_init_machine(void)
773{
774 int i;
775
776 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
777 s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
778 s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
779 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +0300780 s3c_i2c0_set_platdata(NULL);
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300781 s3c_nand_set_platdata(&rx1950_nand_info);
782
783 /* Turn off suspend on both USB ports, and switch the
784 * selectable USB port to USB device mode. */
785 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
786 S3C2410_MISCCR_USBSUSPND0 |
787 S3C2410_MISCCR_USBSUSPND1, 0x0);
788
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300789 /* mmc power is disabled by default */
790 WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
791 gpio_direction_output(S3C2410_GPJ(1), 0);
792
793 for (i = 0; i < 8; i++)
794 WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
795
796 for (i = 10; i < 16; i++)
797 WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
798
799 for (i = 2; i < 8; i++)
800 WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
801
802 for (i = 11; i < 16; i++)
803 WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
804
805 WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
806
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200807 WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
808 WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
809 WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
810 gpio_direction_output(S3C2410_GPA(3), 0);
811 gpio_direction_output(S3C2410_GPA(4), 0);
812 gpio_direction_output(S3C2410_GPJ(6), 0);
813
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300814 platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +0300815
816 i2c_register_board_info(0, rx1950_i2c_devices,
817 ARRAY_SIZE(rx1950_i2c_devices));
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300818}
819
Russell King98c672c2010-05-22 18:18:57 +0100820/* H1940 and RX3715 need to reserve this for suspend */
821static void __init rx1950_reserve(void)
822{
Russell King8d717a52010-05-22 19:47:18 +0100823 memblock_reserve(0x30003000, 0x1000);
824 memblock_reserve(0x30081000, 0x1000);
Russell King98c672c2010-05-22 18:18:57 +0100825}
826
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300827MACHINE_START(RX1950, "HP iPAQ RX1950")
828 /* Maintainers: Vasily Khoruzhick */
Nicolas Pitre69d50712011-07-05 22:38:17 -0400829 .atag_offset = 0x100,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300830 .map_io = rx1950_map_io,
Russell King98c672c2010-05-22 18:18:57 +0100831 .reserve = rx1950_reserve,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300832 .init_irq = s3c24xx_init_irq,
833 .init_machine = rx1950_init_machine,
834 .timer = &s3c24xx_timer,
835MACHINE_END