Commit | Line | Data |
---|---|---|
54088bf5 MV |
1 | /* |
2 | * Hardware definitions for Palm Tungsten|E2 | |
3 | * | |
4 | * Author: | |
5 | * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com> | |
6 | * | |
7 | * Rewrite for mainline: | |
8 | * Marek Vasut <marek.vasut@gmail.com> | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License version 2 as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * (find more info at www.hackndev.com) | |
15 | * | |
16 | */ | |
17 | ||
18 | #include <linux/platform_device.h> | |
19 | #include <linux/delay.h> | |
20 | #include <linux/irq.h> | |
21 | #include <linux/gpio_keys.h> | |
22 | #include <linux/input.h> | |
8c8aa5fa | 23 | #include <linux/pda_power.h> |
54088bf5 MV |
24 | #include <linux/pwm_backlight.h> |
25 | #include <linux/gpio.h> | |
8c8aa5fa MV |
26 | #include <linux/wm97xx_batt.h> |
27 | #include <linux/power_supply.h> | |
8768dc9b | 28 | #include <linux/usb/gpio_vbus.h> |
54088bf5 MV |
29 | |
30 | #include <asm/mach-types.h> | |
31 | #include <asm/mach/arch.h> | |
32 | #include <asm/mach/map.h> | |
33 | ||
34 | #include <mach/audio.h> | |
35 | #include <mach/palmte2.h> | |
36 | #include <mach/mmc.h> | |
37 | #include <mach/pxafb.h> | |
38 | #include <mach/mfp-pxa25x.h> | |
8c8aa5fa MV |
39 | #include <mach/irda.h> |
40 | #include <mach/udc.h> | |
37330efd | 41 | #include <mach/palmasoc.h> |
54088bf5 MV |
42 | |
43 | #include "generic.h" | |
44 | #include "devices.h" | |
45 | ||
46 | /****************************************************************************** | |
47 | * Pin configuration | |
48 | ******************************************************************************/ | |
49 | static unsigned long palmte2_pin_config[] __initdata = { | |
50 | /* MMC */ | |
51 | GPIO6_MMC_CLK, | |
52 | GPIO8_MMC_CS0, | |
53 | GPIO10_GPIO, /* SD detect */ | |
54 | GPIO55_GPIO, /* SD power */ | |
55 | GPIO51_GPIO, /* SD r/o switch */ | |
56 | ||
57 | /* AC97 */ | |
58 | GPIO28_AC97_BITCLK, | |
59 | GPIO29_AC97_SDATA_IN_0, | |
60 | GPIO30_AC97_SDATA_OUT, | |
61 | GPIO31_AC97_SYNC, | |
62 | ||
63 | /* PWM */ | |
64 | GPIO16_PWM0_OUT, | |
65 | ||
8c8aa5fa MV |
66 | /* USB */ |
67 | GPIO15_GPIO, /* usb detect */ | |
68 | GPIO53_GPIO, /* usb power */ | |
69 | ||
70 | /* IrDA */ | |
71 | GPIO48_GPIO, /* ir disable */ | |
72 | GPIO46_FICP_RXD, | |
73 | GPIO47_FICP_TXD, | |
74 | ||
54088bf5 MV |
75 | /* LCD */ |
76 | GPIO58_LCD_LDD_0, | |
77 | GPIO59_LCD_LDD_1, | |
78 | GPIO60_LCD_LDD_2, | |
79 | GPIO61_LCD_LDD_3, | |
80 | GPIO62_LCD_LDD_4, | |
81 | GPIO63_LCD_LDD_5, | |
82 | GPIO64_LCD_LDD_6, | |
83 | GPIO65_LCD_LDD_7, | |
84 | GPIO66_LCD_LDD_8, | |
85 | GPIO67_LCD_LDD_9, | |
86 | GPIO68_LCD_LDD_10, | |
87 | GPIO69_LCD_LDD_11, | |
88 | GPIO70_LCD_LDD_12, | |
89 | GPIO71_LCD_LDD_13, | |
90 | GPIO72_LCD_LDD_14, | |
91 | GPIO73_LCD_LDD_15, | |
92 | GPIO74_LCD_FCLK, | |
93 | GPIO75_LCD_LCLK, | |
94 | GPIO76_LCD_PCLK, | |
8c8aa5fa | 95 | GPIO77_LCD_BIAS, |
54088bf5 MV |
96 | |
97 | /* GPIO KEYS */ | |
98 | GPIO5_GPIO, /* notes */ | |
99 | GPIO7_GPIO, /* tasks */ | |
100 | GPIO11_GPIO, /* calendar */ | |
101 | GPIO13_GPIO, /* contacts */ | |
102 | GPIO14_GPIO, /* center */ | |
103 | GPIO19_GPIO, /* left */ | |
104 | GPIO20_GPIO, /* right */ | |
105 | GPIO21_GPIO, /* down */ | |
106 | GPIO22_GPIO, /* up */ | |
107 | ||
108 | /* MISC */ | |
109 | GPIO1_RST, /* reset */ | |
8c8aa5fa MV |
110 | GPIO4_GPIO, /* Hotsync button */ |
111 | GPIO9_GPIO, /* power detect */ | |
37330efd | 112 | GPIO15_GPIO, /* earphone detect */ |
8c8aa5fa MV |
113 | GPIO37_GPIO, /* LCD power */ |
114 | GPIO56_GPIO, /* Backlight power */ | |
54088bf5 MV |
115 | }; |
116 | ||
117 | /****************************************************************************** | |
118 | * SD/MMC card controller | |
119 | ******************************************************************************/ | |
120 | static int palmte2_mci_init(struct device *dev, | |
121 | irq_handler_t palmte2_detect_int, void *data) | |
122 | { | |
123 | int err = 0; | |
124 | ||
125 | /* Setup an interrupt for detecting card insert/remove events */ | |
126 | err = gpio_request(GPIO_NR_PALMTE2_SD_DETECT_N, "SD IRQ"); | |
127 | if (err) | |
128 | goto err; | |
129 | err = gpio_direction_input(GPIO_NR_PALMTE2_SD_DETECT_N); | |
130 | if (err) | |
131 | goto err2; | |
132 | err = request_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), | |
133 | palmte2_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM | | |
134 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | |
135 | "SD/MMC card detect", data); | |
136 | if (err) { | |
137 | printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n", | |
138 | __func__); | |
139 | goto err2; | |
140 | } | |
141 | ||
142 | err = gpio_request(GPIO_NR_PALMTE2_SD_POWER, "SD_POWER"); | |
143 | if (err) | |
144 | goto err3; | |
145 | err = gpio_direction_output(GPIO_NR_PALMTE2_SD_POWER, 0); | |
146 | if (err) | |
147 | goto err4; | |
148 | ||
149 | err = gpio_request(GPIO_NR_PALMTE2_SD_READONLY, "SD_READONLY"); | |
150 | if (err) | |
151 | goto err4; | |
152 | err = gpio_direction_input(GPIO_NR_PALMTE2_SD_READONLY); | |
153 | if (err) | |
154 | goto err5; | |
155 | ||
156 | printk(KERN_DEBUG "%s: irq registered\n", __func__); | |
157 | ||
158 | return 0; | |
159 | ||
160 | err5: | |
161 | gpio_free(GPIO_NR_PALMTE2_SD_READONLY); | |
162 | err4: | |
163 | gpio_free(GPIO_NR_PALMTE2_SD_POWER); | |
164 | err3: | |
165 | free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data); | |
166 | err2: | |
167 | gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N); | |
168 | err: | |
169 | return err; | |
170 | } | |
171 | ||
172 | static void palmte2_mci_exit(struct device *dev, void *data) | |
173 | { | |
174 | gpio_free(GPIO_NR_PALMTE2_SD_READONLY); | |
175 | gpio_free(GPIO_NR_PALMTE2_SD_POWER); | |
176 | free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data); | |
177 | gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N); | |
178 | } | |
179 | ||
180 | static void palmte2_mci_power(struct device *dev, unsigned int vdd) | |
181 | { | |
182 | struct pxamci_platform_data *p_d = dev->platform_data; | |
183 | gpio_set_value(GPIO_NR_PALMTE2_SD_POWER, p_d->ocr_mask & (1 << vdd)); | |
184 | } | |
185 | ||
186 | static int palmte2_mci_get_ro(struct device *dev) | |
187 | { | |
188 | return gpio_get_value(GPIO_NR_PALMTE2_SD_READONLY); | |
189 | } | |
190 | ||
191 | static struct pxamci_platform_data palmte2_mci_platform_data = { | |
192 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | |
193 | .setpower = palmte2_mci_power, | |
194 | .get_ro = palmte2_mci_get_ro, | |
195 | .init = palmte2_mci_init, | |
196 | .exit = palmte2_mci_exit, | |
197 | }; | |
198 | ||
199 | /****************************************************************************** | |
200 | * GPIO keys | |
201 | ******************************************************************************/ | |
202 | static struct gpio_keys_button palmte2_pxa_buttons[] = { | |
203 | {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" }, | |
204 | {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" }, | |
205 | {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" }, | |
206 | {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" }, | |
207 | {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" }, | |
208 | {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" }, | |
209 | {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" }, | |
210 | {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" }, | |
211 | {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" }, | |
212 | }; | |
213 | ||
214 | static struct gpio_keys_platform_data palmte2_pxa_keys_data = { | |
215 | .buttons = palmte2_pxa_buttons, | |
216 | .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons), | |
217 | }; | |
218 | ||
219 | static struct platform_device palmte2_pxa_keys = { | |
220 | .name = "gpio-keys", | |
221 | .id = -1, | |
222 | .dev = { | |
223 | .platform_data = &palmte2_pxa_keys_data, | |
224 | }, | |
225 | }; | |
226 | ||
227 | /****************************************************************************** | |
228 | * Backlight | |
229 | ******************************************************************************/ | |
8c8aa5fa MV |
230 | static int palmte2_backlight_init(struct device *dev) |
231 | { | |
232 | int ret; | |
233 | ||
234 | ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER"); | |
235 | if (ret) | |
236 | goto err; | |
237 | ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0); | |
238 | if (ret) | |
239 | goto err2; | |
240 | ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER"); | |
241 | if (ret) | |
242 | goto err2; | |
243 | ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0); | |
244 | if (ret) | |
245 | goto err3; | |
246 | ||
247 | return 0; | |
248 | err3: | |
249 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); | |
250 | err2: | |
251 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); | |
252 | err: | |
253 | return ret; | |
254 | } | |
255 | ||
256 | static int palmte2_backlight_notify(int brightness) | |
257 | { | |
258 | gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness); | |
259 | gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness); | |
260 | return brightness; | |
261 | } | |
262 | ||
263 | static void palmte2_backlight_exit(struct device *dev) | |
264 | { | |
265 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); | |
266 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); | |
267 | } | |
268 | ||
54088bf5 MV |
269 | static struct platform_pwm_backlight_data palmte2_backlight_data = { |
270 | .pwm_id = 0, | |
271 | .max_brightness = PALMTE2_MAX_INTENSITY, | |
272 | .dft_brightness = PALMTE2_MAX_INTENSITY, | |
273 | .pwm_period_ns = PALMTE2_PERIOD_NS, | |
8c8aa5fa MV |
274 | .init = palmte2_backlight_init, |
275 | .notify = palmte2_backlight_notify, | |
276 | .exit = palmte2_backlight_exit, | |
54088bf5 MV |
277 | }; |
278 | ||
279 | static struct platform_device palmte2_backlight = { | |
280 | .name = "pwm-backlight", | |
281 | .dev = { | |
282 | .parent = &pxa25x_device_pwm0.dev, | |
283 | .platform_data = &palmte2_backlight_data, | |
284 | }, | |
285 | }; | |
286 | ||
8c8aa5fa MV |
287 | /****************************************************************************** |
288 | * IrDA | |
289 | ******************************************************************************/ | |
290 | static int palmte2_irda_startup(struct device *dev) | |
291 | { | |
292 | int err; | |
293 | err = gpio_request(GPIO_NR_PALMTE2_IR_DISABLE, "IR DISABLE"); | |
294 | if (err) | |
295 | goto err; | |
296 | err = gpio_direction_output(GPIO_NR_PALMTE2_IR_DISABLE, 1); | |
297 | if (err) | |
298 | gpio_free(GPIO_NR_PALMTE2_IR_DISABLE); | |
299 | err: | |
300 | return err; | |
301 | } | |
302 | ||
303 | static void palmte2_irda_shutdown(struct device *dev) | |
304 | { | |
305 | gpio_free(GPIO_NR_PALMTE2_IR_DISABLE); | |
306 | } | |
307 | ||
308 | static void palmte2_irda_transceiver_mode(struct device *dev, int mode) | |
309 | { | |
310 | gpio_set_value(GPIO_NR_PALMTE2_IR_DISABLE, mode & IR_OFF); | |
311 | pxa2xx_transceiver_mode(dev, mode); | |
312 | } | |
313 | ||
314 | static struct pxaficp_platform_data palmte2_ficp_platform_data = { | |
315 | .startup = palmte2_irda_startup, | |
316 | .shutdown = palmte2_irda_shutdown, | |
317 | .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, | |
318 | .transceiver_mode = palmte2_irda_transceiver_mode, | |
319 | }; | |
320 | ||
321 | /****************************************************************************** | |
322 | * UDC | |
323 | ******************************************************************************/ | |
8768dc9b | 324 | static struct gpio_vbus_mach_info palmte2_udc_info = { |
8c8aa5fa MV |
325 | .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N, |
326 | .gpio_vbus_inverted = 1, | |
327 | .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP, | |
8768dc9b MV |
328 | }; |
329 | ||
330 | static struct platform_device palmte2_gpio_vbus = { | |
331 | .name = "gpio-vbus", | |
332 | .id = -1, | |
333 | .dev = { | |
334 | .platform_data = &palmte2_udc_info, | |
335 | }, | |
8c8aa5fa MV |
336 | }; |
337 | ||
338 | /****************************************************************************** | |
339 | * Power supply | |
340 | ******************************************************************************/ | |
341 | static int power_supply_init(struct device *dev) | |
342 | { | |
343 | int ret; | |
344 | ||
345 | ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC"); | |
346 | if (ret) | |
347 | goto err1; | |
348 | ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT); | |
349 | if (ret) | |
350 | goto err2; | |
351 | ||
352 | return 0; | |
353 | ||
354 | err2: | |
355 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); | |
356 | err1: | |
357 | return ret; | |
358 | } | |
359 | ||
360 | static int palmte2_is_ac_online(void) | |
361 | { | |
362 | return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT); | |
363 | } | |
364 | ||
365 | static void power_supply_exit(struct device *dev) | |
366 | { | |
367 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); | |
368 | } | |
369 | ||
370 | static char *palmte2_supplicants[] = { | |
371 | "main-battery", | |
372 | }; | |
373 | ||
374 | static struct pda_power_pdata power_supply_info = { | |
375 | .init = power_supply_init, | |
376 | .is_ac_online = palmte2_is_ac_online, | |
377 | .exit = power_supply_exit, | |
378 | .supplied_to = palmte2_supplicants, | |
379 | .num_supplicants = ARRAY_SIZE(palmte2_supplicants), | |
380 | }; | |
381 | ||
382 | static struct platform_device power_supply = { | |
383 | .name = "pda-power", | |
384 | .id = -1, | |
385 | .dev = { | |
386 | .platform_data = &power_supply_info, | |
387 | }, | |
388 | }; | |
389 | ||
390 | /****************************************************************************** | |
391 | * WM97xx battery | |
392 | ******************************************************************************/ | |
393 | static struct wm97xx_batt_info wm97xx_batt_pdata = { | |
394 | .batt_aux = WM97XX_AUX_ID3, | |
395 | .temp_aux = WM97XX_AUX_ID2, | |
396 | .charge_gpio = -1, | |
397 | .max_voltage = PALMTE2_BAT_MAX_VOLTAGE, | |
398 | .min_voltage = PALMTE2_BAT_MIN_VOLTAGE, | |
399 | .batt_mult = 1000, | |
400 | .batt_div = 414, | |
401 | .temp_mult = 1, | |
402 | .temp_div = 1, | |
403 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, | |
404 | .batt_name = "main-batt", | |
405 | }; | |
406 | ||
37330efd MV |
407 | /****************************************************************************** |
408 | * aSoC audio | |
409 | ******************************************************************************/ | |
410 | static struct palm27x_asoc_info palmte2_asoc_pdata = { | |
411 | .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT, | |
412 | }; | |
413 | ||
414 | static struct platform_device palmte2_asoc = { | |
415 | .name = "palm27x-asoc", | |
416 | .id = -1, | |
417 | .dev = { | |
418 | .platform_data = &palmte2_asoc_pdata, | |
419 | }, | |
420 | }; | |
421 | ||
54088bf5 MV |
422 | /****************************************************************************** |
423 | * Framebuffer | |
424 | ******************************************************************************/ | |
425 | static struct pxafb_mode_info palmte2_lcd_modes[] = { | |
426 | { | |
427 | .pixclock = 77757, | |
428 | .xres = 320, | |
429 | .yres = 320, | |
430 | .bpp = 16, | |
431 | ||
432 | .left_margin = 28, | |
433 | .right_margin = 7, | |
434 | .upper_margin = 7, | |
435 | .lower_margin = 5, | |
436 | ||
437 | .hsync_len = 4, | |
438 | .vsync_len = 1, | |
439 | }, | |
440 | }; | |
441 | ||
442 | static struct pxafb_mach_info palmte2_lcd_screen = { | |
443 | .modes = palmte2_lcd_modes, | |
444 | .num_modes = ARRAY_SIZE(palmte2_lcd_modes), | |
445 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
446 | }; | |
447 | ||
448 | /****************************************************************************** | |
449 | * Machine init | |
450 | ******************************************************************************/ | |
451 | static struct platform_device *devices[] __initdata = { | |
452 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
453 | &palmte2_pxa_keys, | |
454 | #endif | |
455 | &palmte2_backlight, | |
8c8aa5fa | 456 | &power_supply, |
37330efd | 457 | &palmte2_asoc, |
8768dc9b | 458 | &palmte2_gpio_vbus, |
54088bf5 MV |
459 | }; |
460 | ||
8c8aa5fa MV |
461 | /* setup udc GPIOs initial state */ |
462 | static void __init palmte2_udc_init(void) | |
463 | { | |
464 | if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) { | |
465 | gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1); | |
466 | gpio_free(GPIO_NR_PALMTE2_USB_PULLUP); | |
467 | } | |
468 | } | |
469 | ||
54088bf5 MV |
470 | static void __init palmte2_init(void) |
471 | { | |
472 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config)); | |
473 | ||
474 | set_pxa_fb_info(&palmte2_lcd_screen); | |
475 | pxa_set_mci_info(&palmte2_mci_platform_data); | |
8c8aa5fa | 476 | palmte2_udc_init(); |
54088bf5 | 477 | pxa_set_ac97_info(NULL); |
8c8aa5fa MV |
478 | pxa_set_ficp_info(&palmte2_ficp_platform_data); |
479 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); | |
54088bf5 MV |
480 | |
481 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
482 | } | |
483 | ||
484 | MACHINE_START(PALMTE2, "Palm Tungsten|E2") | |
485 | .phys_io = 0x40000000, | |
486 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
487 | .boot_params = 0xa0000100, | |
488 | .map_io = pxa_map_io, | |
489 | .init_irq = pxa25x_init_irq, | |
490 | .timer = &pxa_timer, | |
491 | .init_machine = palmte2_init | |
492 | MACHINE_END |