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