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