ARM: mach-s3c24*: convert boot_params to atag_offset
[deliverable/linux.git] / arch / arm / mach-s3c2410 / mach-h1940.c
CommitLineData
1da177e4
LT
1/* linux/arch/arm/mach-s3c2410/mach-h1940.c
2 *
3 * Copyright (c) 2003-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * http://www.handhelds.org/projects/h1940.html
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 *
1da177e4
LT
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>
1da177e4
LT
19#include <linux/timer.h>
20#include <linux/init.h>
333a42e1 21#include <linux/sysdev.h>
b6d1f542 22#include <linux/serial_core.h>
d052d1be 23#include <linux/platform_device.h>
fced80c7 24#include <linux/io.h>
3909b9f7 25#include <linux/gpio.h>
bbb1c832
APR
26#include <linux/input.h>
27#include <linux/gpio_keys.h>
22e649ff 28#include <linux/pwm_backlight.h>
68730b45 29#include <linux/i2c.h>
50e2d10d 30#include <linux/leds.h>
a8e99850
VK
31#include <linux/pda_power.h>
32#include <linux/s3c_adc_battery.h>
25d391cb 33#include <linux/delay.h>
50e2d10d 34
22e649ff 35#include <video/platform_lcd.h>
3909b9f7 36
37#include <linux/mmc/host.h>
1da177e4
LT
38
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41#include <asm/mach/irq.h>
42
a09e64fb 43#include <mach/hardware.h>
1da177e4
LT
44#include <asm/irq.h>
45#include <asm/mach-types.h>
46
a2b7ba9c 47#include <plat/regs-serial.h>
a09e64fb 48#include <mach/regs-lcd.h>
a09e64fb 49#include <mach/regs-clock.h>
f92273c1 50
3909b9f7 51#include <mach/regs-gpio.h>
52#include <mach/gpio-fns.h>
53#include <mach/gpio-nrs.h>
54
a09e64fb
RK
55#include <mach/h1940.h>
56#include <mach/h1940-latch.h>
57#include <mach/fb.h>
57bd4b91 58#include <plat/udc.h>
3e1b776c 59#include <plat/iic.h>
1da177e4 60
40b956f0 61#include <plat/gpio-cfg.h>
d5120ae7 62#include <plat/clock.h>
a2b7ba9c
BD
63#include <plat/devs.h>
64#include <plat/cpu.h>
e24b864a 65#include <plat/pll.h>
a2b7ba9c 66#include <plat/pm.h>
3909b9f7 67#include <plat/mci.h>
73e59b1d 68#include <plat/ts.h>
1da177e4 69
68730b45
VK
70#include <sound/uda1380.h>
71
14477095
VK
72#define H1940_LATCH ((void __force __iomem *)0xF8000000)
73
74#define H1940_PA_LATCH S3C2410_CS2
75
76#define H1940_LATCH_BIT(x) (1 << ((x) + 16 - S3C_GPIO_END))
77
1da177e4 78static struct map_desc h1940_iodesc[] __initdata = {
e1981680
BD
79 [0] = {
80 .virtual = (unsigned long)H1940_LATCH,
81 .pfn = __phys_to_pfn(H1940_PA_LATCH),
82 .length = SZ_16K,
83 .type = MT_DEVICE
84 },
1da177e4
LT
85};
86
87#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
88#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
89#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
90
66a9b49a 91static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
1da177e4
LT
92 [0] = {
93 .hwport = 0,
94 .flags = 0,
95 .ucon = 0x3c5,
96 .ulcon = 0x03,
97 .ufcon = 0x51,
98 },
99 [1] = {
100 .hwport = 1,
101 .flags = 0,
102 .ucon = 0x245,
103 .ulcon = 0x03,
104 .ufcon = 0x00,
105 },
106 /* IR port */
107 [2] = {
108 .hwport = 2,
109 .flags = 0,
110 .uart_flags = UPF_CONS_FLOW,
111 .ucon = 0x3c5,
112 .ulcon = 0x43,
113 .ufcon = 0x51,
114 }
115};
116
e1981680
BD
117/* Board control latch control */
118
53193dd3 119static unsigned int latch_state;
e1981680 120
14477095 121static void h1940_latch_control(unsigned int clear, unsigned int set)
e1981680
BD
122{
123 unsigned long flags;
124
125 local_irq_save(flags);
126
127 latch_state &= ~clear;
128 latch_state |= set;
129
130 __raw_writel(latch_state, H1940_LATCH);
131
132 local_irq_restore(flags);
133}
134
14477095
VK
135static inline int h1940_gpiolib_to_latch(int offset)
136{
137 return 1 << (offset + 16);
138}
139
140static void h1940_gpiolib_latch_set(struct gpio_chip *chip,
141 unsigned offset, int value)
142{
143 int latch_bit = h1940_gpiolib_to_latch(offset);
144
145 h1940_latch_control(value ? 0 : latch_bit,
146 value ? latch_bit : 0);
147}
148
149static int h1940_gpiolib_latch_output(struct gpio_chip *chip,
150 unsigned offset, int value)
151{
152 h1940_gpiolib_latch_set(chip, offset, value);
153 return 0;
154}
155
156static int h1940_gpiolib_latch_get(struct gpio_chip *chip,
157 unsigned offset)
158{
159 return (latch_state >> (offset + 16)) & 1;
160}
161
162struct gpio_chip h1940_latch_gpiochip = {
163 .base = H1940_LATCH_GPIO(0),
164 .owner = THIS_MODULE,
165 .label = "H1940_LATCH",
166 .ngpio = 16,
167 .direction_output = h1940_gpiolib_latch_output,
168 .set = h1940_gpiolib_latch_set,
169 .get = h1940_gpiolib_latch_get,
170};
1da177e4 171
71a9c424 172static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
070276d5 173 .vbus_pin = S3C2410_GPG(5),
71a9c424 174 .vbus_pin_inverted = 1,
e27c3c5c 175 .pullup_pin = H1940_LATCH_USB_DP,
71a9c424
AP
176};
177
ce8877b5
AP
178static struct s3c2410_ts_mach_info h1940_ts_cfg __initdata = {
179 .delay = 10000,
180 .presc = 49,
181 .oversampling_shift = 2,
5bfdca14 182 .cfg_gpio = s3c24xx_ts_cfg_gpio,
ce8877b5 183};
71a9c424 184
f92273c1
AP
185/**
186 * Set lcd on or off
187 **/
09fe75f6 188static struct s3c2410fb_display h1940_lcd __initdata = {
f28ef573
KH
189 .lcdcon5= S3C2410_LCDCON5_FRM565 | \
190 S3C2410_LCDCON5_INVVLINE | \
191 S3C2410_LCDCON5_HWSWP,
09fe75f6 192
1f411537 193 .type = S3C2410_LCDCON1_TFT,
09fe75f6
KH
194 .width = 240,
195 .height = 320,
69816699 196 .pixclock = 260000,
09fe75f6
KH
197 .xres = 240,
198 .yres = 320,
199 .bpp = 16,
26be1b7b
MS
200 .left_margin = 8,
201 .right_margin = 20,
93d11f5a 202 .hsync_len = 4,
5f20f69b
KH
203 .upper_margin = 8,
204 .lower_margin = 7,
93d11f5a 205 .vsync_len = 1,
09fe75f6
KH
206};
207
208static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
09fe75f6
KH
209 .displays = &h1940_lcd,
210 .num_displays = 1,
211 .default_display = 0,
212
25d391cb
VK
213 .lpcsel = 0x02,
214 .gpccon = 0xaa940659,
215 .gpccon_mask = 0xffffc0f0,
216 .gpcup = 0x0000ffff,
217 .gpcup_mask = 0xffffffff,
218 .gpdcon = 0xaa84aaa0,
219 .gpdcon_mask = 0xffffffff,
220 .gpdup = 0x0000faff,
221 .gpdup_mask = 0xffffffff,
f92273c1 222};
1da177e4 223
a8e99850
VK
224static int power_supply_init(struct device *dev)
225{
226 return gpio_request(S3C2410_GPF(2), "cable plugged");
227}
228
229static int h1940_is_ac_online(void)
230{
231 return !gpio_get_value(S3C2410_GPF(2));
232}
233
234static void power_supply_exit(struct device *dev)
235{
236 gpio_free(S3C2410_GPF(2));
237}
238
239static char *h1940_supplicants[] = {
240 "main-battery",
241 "backup-battery",
242};
243
244static struct pda_power_pdata power_supply_info = {
245 .init = power_supply_init,
246 .is_ac_online = h1940_is_ac_online,
247 .exit = power_supply_exit,
248 .supplied_to = h1940_supplicants,
249 .num_supplicants = ARRAY_SIZE(h1940_supplicants),
250};
251
252static struct resource power_supply_resources[] = {
253 [0] = {
254 .name = "ac",
255 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
256 IORESOURCE_IRQ_HIGHEDGE,
257 .start = IRQ_EINT2,
258 .end = IRQ_EINT2,
259 },
260};
261
262static struct platform_device power_supply = {
263 .name = "pda-power",
264 .id = -1,
265 .dev = {
266 .platform_data =
267 &power_supply_info,
268 },
269 .resource = power_supply_resources,
270 .num_resources = ARRAY_SIZE(power_supply_resources),
271};
272
273static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
274 { .volt = 4070, .cur = 162, .level = 100},
275 { .volt = 4040, .cur = 165, .level = 95},
276 { .volt = 4016, .cur = 164, .level = 90},
277 { .volt = 3996, .cur = 166, .level = 85},
278 { .volt = 3971, .cur = 168, .level = 80},
279 { .volt = 3951, .cur = 168, .level = 75},
280 { .volt = 3931, .cur = 170, .level = 70},
281 { .volt = 3903, .cur = 172, .level = 65},
282 { .volt = 3886, .cur = 172, .level = 60},
283 { .volt = 3858, .cur = 176, .level = 55},
284 { .volt = 3842, .cur = 176, .level = 50},
285 { .volt = 3818, .cur = 176, .level = 45},
286 { .volt = 3789, .cur = 180, .level = 40},
287 { .volt = 3769, .cur = 180, .level = 35},
288 { .volt = 3749, .cur = 184, .level = 30},
289 { .volt = 3732, .cur = 184, .level = 25},
290 { .volt = 3716, .cur = 184, .level = 20},
291 { .volt = 3708, .cur = 184, .level = 15},
292 { .volt = 3716, .cur = 96, .level = 10},
293 { .volt = 3700, .cur = 96, .level = 5},
294 { .volt = 3684, .cur = 96, .level = 0},
295};
296
297static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
298 { .volt = 4130, .cur = 0, .level = 100},
299 { .volt = 3982, .cur = 0, .level = 50},
300 { .volt = 3854, .cur = 0, .level = 10},
301 { .volt = 3841, .cur = 0, .level = 0},
302};
303
304int h1940_bat_init(void)
305{
306 int ret;
307
308 ret = gpio_request(H1940_LATCH_SM803_ENABLE, "h1940-charger-enable");
309 if (ret)
310 return ret;
311 gpio_direction_output(H1940_LATCH_SM803_ENABLE, 0);
312
313 return 0;
314
315}
316
317void h1940_bat_exit(void)
318{
319 gpio_free(H1940_LATCH_SM803_ENABLE);
320}
321
322void h1940_enable_charger(void)
323{
324 gpio_set_value(H1940_LATCH_SM803_ENABLE, 1);
325}
326
327void h1940_disable_charger(void)
328{
329 gpio_set_value(H1940_LATCH_SM803_ENABLE, 0);
330}
331
332static struct s3c_adc_bat_pdata h1940_bat_cfg = {
333 .init = h1940_bat_init,
334 .exit = h1940_bat_exit,
335 .enable_charger = h1940_enable_charger,
336 .disable_charger = h1940_disable_charger,
337 .gpio_charge_finished = S3C2410_GPF(3),
338 .gpio_inverted = 1,
339 .lut_noac = bat_lut_noac,
340 .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
341 .lut_acin = bat_lut_acin,
342 .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
343 .volt_channel = 0,
344 .current_channel = 1,
345 .volt_mult = 4056,
346 .current_mult = 1893,
347 .internal_impedance = 200,
348 .backup_volt_channel = 3,
349 /* TODO Check backup volt multiplier */
350 .backup_volt_mult = 4056,
351 .backup_volt_min = 0,
352 .backup_volt_max = 4149288
353};
354
355static struct platform_device h1940_battery = {
356 .name = "s3c-adc-battery",
357 .id = -1,
358 .dev = {
359 .parent = &s3c_device_adc.dev,
360 .platform_data = &h1940_bat_cfg,
361 },
362};
363
50e2d10d
VK
364DEFINE_SPINLOCK(h1940_blink_spin);
365
366int h1940_led_blink_set(unsigned gpio, int state,
367 unsigned long *delay_on, unsigned long *delay_off)
368{
369 int blink_gpio, check_gpio1, check_gpio2;
370
371 switch (gpio) {
372 case H1940_LATCH_LED_GREEN:
373 blink_gpio = S3C2410_GPA(7);
374 check_gpio1 = S3C2410_GPA(1);
375 check_gpio2 = S3C2410_GPA(3);
376 break;
377 case H1940_LATCH_LED_RED:
378 blink_gpio = S3C2410_GPA(1);
379 check_gpio1 = S3C2410_GPA(7);
380 check_gpio2 = S3C2410_GPA(3);
381 break;
382 default:
383 blink_gpio = S3C2410_GPA(3);
384 check_gpio1 = S3C2410_GPA(1);
385 check_gpio1 = S3C2410_GPA(7);
386 break;
387 }
388
389 if (delay_on && delay_off && !*delay_on && !*delay_off)
390 *delay_on = *delay_off = 500;
391
392 spin_lock(&h1940_blink_spin);
393
394 switch (state) {
395 case GPIO_LED_NO_BLINK_LOW:
396 case GPIO_LED_NO_BLINK_HIGH:
397 if (!gpio_get_value(check_gpio1) &&
398 !gpio_get_value(check_gpio2))
399 gpio_set_value(H1940_LATCH_LED_FLASH, 0);
400 gpio_set_value(blink_gpio, 0);
401 if (gpio_is_valid(gpio))
402 gpio_set_value(gpio, state);
403 break;
404 case GPIO_LED_BLINK:
405 if (gpio_is_valid(gpio))
406 gpio_set_value(gpio, 0);
407 gpio_set_value(H1940_LATCH_LED_FLASH, 1);
408 gpio_set_value(blink_gpio, 1);
409 break;
410 }
411
412 spin_unlock(&h1940_blink_spin);
413
414 return 0;
415}
416EXPORT_SYMBOL(h1940_led_blink_set);
417
418static struct gpio_led h1940_leds_desc[] = {
419 {
420 .name = "Green",
9edb2406 421 .default_trigger = "main-battery-full",
50e2d10d
VK
422 .gpio = H1940_LATCH_LED_GREEN,
423 .retain_state_suspended = 1,
424 },
425 {
426 .name = "Red",
9edb2406
VK
427 .default_trigger
428 = "main-battery-charging-blink-full-solid",
50e2d10d
VK
429 .gpio = H1940_LATCH_LED_RED,
430 .retain_state_suspended = 1,
431 },
432};
433
434static struct gpio_led_platform_data h1940_leds_pdata = {
435 .num_leds = ARRAY_SIZE(h1940_leds_desc),
436 .leds = h1940_leds_desc,
437 .gpio_blink_set = h1940_led_blink_set,
438};
439
ff34aaa9 440static struct platform_device h1940_device_leds = {
50e2d10d
VK
441 .name = "leds-gpio",
442 .id = -1,
443 .dev = {
444 .platform_data = &h1940_leds_pdata,
445 },
d2a76020
AP
446};
447
ff34aaa9 448static struct platform_device h1940_device_bluetooth = {
7fdc7849
AP
449 .name = "h1940-bt",
450 .id = -1,
451};
452
48cd65a6
VK
453static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
454{
455 switch (power_mode) {
456 case MMC_POWER_OFF:
457 gpio_set_value(H1940_LATCH_SD_POWER, 0);
458 break;
459 case MMC_POWER_UP:
460 case MMC_POWER_ON:
461 gpio_set_value(H1940_LATCH_SD_POWER, 1);
462 break;
463 default:
464 break;
465 };
466}
467
22c810ab 468static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
3909b9f7 469 .gpio_detect = S3C2410_GPF(5),
470 .gpio_wprotect = S3C2410_GPH(8),
48cd65a6 471 .set_power = h1940_set_mmc_power,
3909b9f7 472 .ocr_avail = MMC_VDD_32_33,
473};
474
22e649ff 475static int h1940_backlight_init(struct device *dev)
476{
477 gpio_request(S3C2410_GPB(0), "Backlight");
478
db61ac54 479 gpio_direction_output(S3C2410_GPB(0), 0);
fb378747 480 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
40b956f0 481 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
53193dd3 482 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
22e649ff 483
484 return 0;
485}
486
53193dd3
VK
487static int h1940_backlight_notify(struct device *dev, int brightness)
488{
489 if (!brightness) {
490 gpio_direction_output(S3C2410_GPB(0), 1);
491 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
492 } else {
493 gpio_direction_output(S3C2410_GPB(0), 0);
494 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
495 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
496 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
497 }
498 return brightness;
499}
500
22e649ff 501static void h1940_backlight_exit(struct device *dev)
502{
db61ac54 503 gpio_direction_output(S3C2410_GPB(0), 1);
53193dd3 504 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
22e649ff 505}
506
53193dd3 507
22e649ff 508static struct platform_pwm_backlight_data backlight_data = {
509 .pwm_id = 0,
510 .max_brightness = 100,
511 .dft_brightness = 50,
512 /* tcnt = 0x31 */
513 .pwm_period_ns = 36296,
514 .init = h1940_backlight_init,
53193dd3 515 .notify = h1940_backlight_notify,
22e649ff 516 .exit = h1940_backlight_exit,
517};
518
519static struct platform_device h1940_backlight = {
520 .name = "pwm-backlight",
521 .dev = {
522 .parent = &s3c_device_timer[0].dev,
523 .platform_data = &backlight_data,
524 },
525 .id = -1,
526};
527
528static void h1940_lcd_power_set(struct plat_lcd_data *pd,
529 unsigned int power)
530{
25d391cb 531 int value, retries = 100;
22e649ff 532
533 if (!power) {
53193dd3 534 gpio_set_value(S3C2410_GPC(0), 0);
22e649ff 535 /* wait for 3ac */
536 do {
db61ac54 537 value = gpio_get_value(S3C2410_GPC(6));
25d391cb 538 } while (value && retries--);
53193dd3
VK
539
540 gpio_set_value(H1940_LATCH_LCD_P2, 0);
541 gpio_set_value(H1940_LATCH_LCD_P3, 0);
542 gpio_set_value(H1940_LATCH_LCD_P4, 0);
543
544 gpio_direction_output(S3C2410_GPC(1), 0);
545 gpio_direction_output(S3C2410_GPC(4), 0);
546
547 gpio_set_value(H1940_LATCH_LCD_P1, 0);
548 gpio_set_value(H1940_LATCH_LCD_P0, 0);
549
550 gpio_set_value(S3C2410_GPC(5), 0);
551
22e649ff 552 } else {
53193dd3
VK
553 gpio_set_value(H1940_LATCH_LCD_P0, 1);
554 gpio_set_value(H1940_LATCH_LCD_P1, 1);
555
25d391cb
VK
556 gpio_direction_input(S3C2410_GPC(1));
557 gpio_direction_input(S3C2410_GPC(4));
558 mdelay(10);
53193dd3
VK
559 s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2));
560 s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2));
561
562 gpio_set_value(S3C2410_GPC(5), 1);
563 gpio_set_value(S3C2410_GPC(0), 1);
564
565 gpio_set_value(H1940_LATCH_LCD_P3, 1);
566 gpio_set_value(H1940_LATCH_LCD_P2, 1);
567 gpio_set_value(H1940_LATCH_LCD_P4, 1);
22e649ff 568 }
569}
570
571static struct plat_lcd_data h1940_lcd_power_data = {
572 .set_power = h1940_lcd_power_set,
573};
574
575static struct platform_device h1940_lcd_powerdev = {
576 .name = "platform-lcd",
577 .dev.parent = &s3c_device_lcd.dev,
578 .dev.platform_data = &h1940_lcd_power_data,
579};
580
68730b45
VK
581static struct uda1380_platform_data uda1380_info = {
582 .gpio_power = H1940_LATCH_UDA_POWER,
583 .gpio_reset = S3C2410_GPA(12),
584 .dac_clk = UDA1380_DAC_CLK_SYSCLK,
585};
586
587static struct i2c_board_info h1940_i2c_devices[] = {
588 {
589 I2C_BOARD_INFO("uda1380", 0x1a),
590 .platform_data = &uda1380_info,
591 },
592};
593
bbb1c832
APR
594#define DECLARE_BUTTON(p, k, n, w) \
595 { \
596 .gpio = p, \
597 .code = k, \
598 .desc = n, \
599 .wakeup = w, \
600 .active_low = 1, \
601 }
602
603static struct gpio_keys_button h1940_buttons[] = {
604 DECLARE_BUTTON(S3C2410_GPF(0), KEY_POWER, "Power", 1),
605 DECLARE_BUTTON(S3C2410_GPF(6), KEY_ENTER, "Select", 1),
606 DECLARE_BUTTON(S3C2410_GPF(7), KEY_RECORD, "Record", 0),
607 DECLARE_BUTTON(S3C2410_GPG(0), KEY_F11, "Calendar", 0),
608 DECLARE_BUTTON(S3C2410_GPG(2), KEY_F12, "Contacts", 0),
609 DECLARE_BUTTON(S3C2410_GPG(3), KEY_MAIL, "Mail", 0),
610 DECLARE_BUTTON(S3C2410_GPG(6), KEY_LEFT, "Left_arrow", 0),
611 DECLARE_BUTTON(S3C2410_GPG(7), KEY_HOMEPAGE, "Home", 0),
612 DECLARE_BUTTON(S3C2410_GPG(8), KEY_RIGHT, "Right_arrow", 0),
613 DECLARE_BUTTON(S3C2410_GPG(9), KEY_UP, "Up_arrow", 0),
614 DECLARE_BUTTON(S3C2410_GPG(10), KEY_DOWN, "Down_arrow", 0),
615};
616
617static struct gpio_keys_platform_data h1940_buttons_data = {
618 .buttons = h1940_buttons,
619 .nbuttons = ARRAY_SIZE(h1940_buttons),
620};
621
622static struct platform_device h1940_dev_buttons = {
623 .name = "gpio-keys",
624 .id = -1,
625 .dev = {
626 .platform_data = &h1940_buttons_data,
627 }
628};
629
1da177e4 630static struct platform_device *h1940_devices[] __initdata = {
bbb1c832 631 &h1940_dev_buttons,
b813248c 632 &s3c_device_ohci,
1da177e4
LT
633 &s3c_device_lcd,
634 &s3c_device_wdt,
3e1b776c 635 &s3c_device_i2c0,
1da177e4 636 &s3c_device_iis,
83e37b8e 637 &samsung_asoc_dma,
71a9c424 638 &s3c_device_usbgadget,
ff34aaa9
BD
639 &h1940_device_leds,
640 &h1940_device_bluetooth,
3909b9f7 641 &s3c_device_sdi,
13733d52 642 &s3c_device_rtc,
22e649ff 643 &s3c_device_timer[0],
644 &h1940_backlight,
645 &h1940_lcd_powerdev,
17dcd13a
AP
646 &s3c_device_adc,
647 &s3c_device_ts,
a8e99850
VK
648 &power_supply,
649 &h1940_battery,
1da177e4
LT
650};
651
5fe10ab1 652static void __init h1940_map_io(void)
1da177e4
LT
653{
654 s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
655 s3c24xx_init_clocks(0);
656 s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
9073341c
BD
657
658 /* setup PM */
659
b1dfe1f1 660#ifdef CONFIG_PM_H1940
9073341c 661 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
b1dfe1f1 662#endif
4e59c25d 663 s3c_pm_init();
14477095 664
53193dd3
VK
665 /* Add latch gpio chip, set latch initial value */
666 h1940_latch_control(0, 0);
14477095 667 WARN_ON(gpiochip_add(&h1940_latch_gpiochip));
1da177e4
LT
668}
669
98c672cf
RK
670/* H1940 and RX3715 need to reserve this for suspend */
671static void __init h1940_reserve(void)
672{
8d717a52
RK
673 memblock_reserve(0x30003000, 0x1000);
674 memblock_reserve(0x30081000, 0x1000);
98c672cf
RK
675}
676
5fe10ab1 677static void __init h1940_init_irq(void)
1da177e4
LT
678{
679 s3c24xx_init_irq();
1da177e4
LT
680}
681
5fe10ab1 682static void __init h1940_init(void)
f92273c1 683{
71a9c424
AP
684 u32 tmp;
685
09fe75f6 686 s3c24xx_fb_set_platdata(&h1940_fb_info);
22c810ab 687 s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
71a9c424 688 s3c24xx_udc_set_platdata(&h1940_udc_cfg);
ce8877b5 689 s3c24xx_ts_set_platdata(&h1940_ts_cfg);
3e1b776c 690 s3c_i2c0_set_platdata(NULL);
71a9c424
AP
691
692 /* Turn off suspend on both USB ports, and switch the
693 * selectable USB port to USB device mode. */
694
695 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
696 S3C2410_MISCCR_USBSUSPND0 |
697 S3C2410_MISCCR_USBSUSPND1, 0x0);
698
e24b864a
BD
699 tmp = (0x78 << S3C24XX_PLLCON_MDIVSHIFT)
700 | (0x02 << S3C24XX_PLLCON_PDIVSHIFT)
701 | (0x03 << S3C24XX_PLLCON_SDIVSHIFT);
71a9c424 702 writel(tmp, S3C2410_UPLLCON);
57e5171c 703
22e649ff 704 gpio_request(S3C2410_GPC(0), "LCD power");
53193dd3
VK
705 gpio_request(S3C2410_GPC(1), "LCD power");
706 gpio_request(S3C2410_GPC(4), "LCD power");
22e649ff 707 gpio_request(S3C2410_GPC(5), "LCD power");
708 gpio_request(S3C2410_GPC(6), "LCD power");
53193dd3
VK
709 gpio_request(H1940_LATCH_LCD_P0, "LCD power");
710 gpio_request(H1940_LATCH_LCD_P1, "LCD power");
711 gpio_request(H1940_LATCH_LCD_P2, "LCD power");
712 gpio_request(H1940_LATCH_LCD_P3, "LCD power");
713 gpio_request(H1940_LATCH_LCD_P4, "LCD power");
714 gpio_request(H1940_LATCH_MAX1698_nSHUTDOWN, "LCD power");
715 gpio_direction_output(S3C2410_GPC(0), 0);
716 gpio_direction_output(S3C2410_GPC(1), 0);
717 gpio_direction_output(S3C2410_GPC(4), 0);
718 gpio_direction_output(S3C2410_GPC(5), 0);
db61ac54 719 gpio_direction_input(S3C2410_GPC(6));
53193dd3
VK
720 gpio_direction_output(H1940_LATCH_LCD_P0, 0);
721 gpio_direction_output(H1940_LATCH_LCD_P1, 0);
722 gpio_direction_output(H1940_LATCH_LCD_P2, 0);
723 gpio_direction_output(H1940_LATCH_LCD_P3, 0);
724 gpio_direction_output(H1940_LATCH_LCD_P4, 0);
725 gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
22e649ff 726
48cd65a6
VK
727 gpio_request(H1940_LATCH_SD_POWER, "SD power");
728 gpio_direction_output(H1940_LATCH_SD_POWER, 0);
22e649ff 729
57e5171c 730 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
68730b45 731
50e2d10d
VK
732 gpio_request(S3C2410_GPA(1), "Red LED blink");
733 gpio_request(S3C2410_GPA(3), "Blue LED blink");
734 gpio_request(S3C2410_GPA(7), "Green LED blink");
735 gpio_request(H1940_LATCH_LED_FLASH, "LED blink");
736 gpio_direction_output(S3C2410_GPA(1), 0);
737 gpio_direction_output(S3C2410_GPA(3), 0);
738 gpio_direction_output(S3C2410_GPA(7), 0);
739 gpio_direction_output(H1940_LATCH_LED_FLASH, 0);
740
68730b45
VK
741 i2c_register_board_info(0, h1940_i2c_devices,
742 ARRAY_SIZE(h1940_i2c_devices));
f92273c1
AP
743}
744
1da177e4 745MACHINE_START(H1940, "IPAQ-H1940")
afdd225d 746 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
69d50710 747 .atag_offset = 0x100,
e9dea0c6 748 .map_io = h1940_map_io,
98c672cf 749 .reserve = h1940_reserve,
e9dea0c6 750 .init_irq = h1940_init_irq,
71a9c424 751 .init_machine = h1940_init,
1da177e4
LT
752 .timer = &s3c24xx_timer,
753MACHINE_END
This page took 0.511555 seconds and 5 git commands to generate.