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