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