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