Commit | Line | Data |
---|---|---|
0f6ff0f0 MV |
1 | /* |
2 | * Hardware definitions for Palm Tungsten|T5 | |
3 | * | |
4 | * Author: Marek Vasut <marek.vasut@gmail.com> | |
5 | * | |
6 | * Based on work of: | |
7 | * Ales Snuparek <snuparek@atlas.cz> | |
8 | * Justin Kendrick <twilightsentry@gmail.com> | |
9 | * RichardT5 <richard_t5@users.sourceforge.net> | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License version 2 as | |
13 | * published by the Free Software Foundation. | |
14 | * | |
15 | * (find more info at www.hackndev.com) | |
16 | * | |
17 | */ | |
18 | ||
19 | #include <linux/platform_device.h> | |
20 | #include <linux/delay.h> | |
21 | #include <linux/irq.h> | |
22 | #include <linux/gpio_keys.h> | |
23 | #include <linux/input.h> | |
24 | #include <linux/pda_power.h> | |
25 | #include <linux/pwm_backlight.h> | |
26 | #include <linux/gpio.h> | |
27 | #include <linux/wm97xx_batt.h> | |
28 | #include <linux/power_supply.h> | |
8768dc9b | 29 | #include <linux/usb/gpio_vbus.h> |
0f6ff0f0 MV |
30 | |
31 | #include <asm/mach-types.h> | |
32 | #include <asm/mach/arch.h> | |
33 | #include <asm/mach/map.h> | |
34 | ||
51c62982 | 35 | #include <mach/pxa27x.h> |
0f6ff0f0 MV |
36 | #include <mach/audio.h> |
37 | #include <mach/palmt5.h> | |
38 | #include <mach/mmc.h> | |
39 | #include <mach/pxafb.h> | |
0f6ff0f0 MV |
40 | #include <mach/irda.h> |
41 | #include <mach/pxa27x_keypad.h> | |
42 | #include <mach/udc.h> | |
43 | #include <mach/palmasoc.h> | |
44 | ||
45 | #include "generic.h" | |
46 | #include "devices.h" | |
47 | ||
48 | /****************************************************************************** | |
49 | * Pin configuration | |
50 | ******************************************************************************/ | |
51 | static unsigned long palmt5_pin_config[] __initdata = { | |
52 | /* MMC */ | |
53 | GPIO32_MMC_CLK, | |
54 | GPIO92_MMC_DAT_0, | |
55 | GPIO109_MMC_DAT_1, | |
56 | GPIO110_MMC_DAT_2, | |
57 | GPIO111_MMC_DAT_3, | |
58 | GPIO112_MMC_CMD, | |
59 | GPIO14_GPIO, /* SD detect */ | |
60 | GPIO114_GPIO, /* SD power */ | |
61 | GPIO115_GPIO, /* SD r/o switch */ | |
62 | ||
63 | /* AC97 */ | |
64 | GPIO28_AC97_BITCLK, | |
65 | GPIO29_AC97_SDATA_IN_0, | |
66 | GPIO30_AC97_SDATA_OUT, | |
67 | GPIO31_AC97_SYNC, | |
6ec04f43 | 68 | GPIO89_AC97_SYSCLK, |
efb12cd2 | 69 | GPIO95_AC97_nRESET, |
0f6ff0f0 MV |
70 | |
71 | /* IrDA */ | |
72 | GPIO40_GPIO, /* ir disable */ | |
73 | GPIO46_FICP_RXD, | |
74 | GPIO47_FICP_TXD, | |
75 | ||
76 | /* USB */ | |
77 | GPIO15_GPIO, /* usb detect */ | |
efb12cd2 | 78 | GPIO93_GPIO, /* usb power */ |
0f6ff0f0 MV |
79 | |
80 | /* MATRIX KEYPAD */ | |
81854f82 MV |
81 | GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH, |
82 | GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH, | |
83 | GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH, | |
84 | GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH, | |
0f6ff0f0 MV |
85 | GPIO103_KP_MKOUT_0, |
86 | GPIO104_KP_MKOUT_1, | |
87 | GPIO105_KP_MKOUT_2, | |
88 | ||
89 | /* LCD */ | |
90 | GPIO58_LCD_LDD_0, | |
91 | GPIO59_LCD_LDD_1, | |
92 | GPIO60_LCD_LDD_2, | |
93 | GPIO61_LCD_LDD_3, | |
94 | GPIO62_LCD_LDD_4, | |
95 | GPIO63_LCD_LDD_5, | |
96 | GPIO64_LCD_LDD_6, | |
97 | GPIO65_LCD_LDD_7, | |
98 | GPIO66_LCD_LDD_8, | |
99 | GPIO67_LCD_LDD_9, | |
100 | GPIO68_LCD_LDD_10, | |
101 | GPIO69_LCD_LDD_11, | |
102 | GPIO70_LCD_LDD_12, | |
103 | GPIO71_LCD_LDD_13, | |
104 | GPIO72_LCD_LDD_14, | |
105 | GPIO73_LCD_LDD_15, | |
106 | GPIO74_LCD_FCLK, | |
107 | GPIO75_LCD_LCLK, | |
108 | GPIO76_LCD_PCLK, | |
109 | GPIO77_LCD_BIAS, | |
110 | ||
111 | /* PWM */ | |
112 | GPIO16_PWM0_OUT, | |
113 | ||
ecf763c5 MV |
114 | /* FFUART */ |
115 | GPIO34_FFUART_RXD, | |
116 | GPIO39_FFUART_TXD, | |
117 | ||
0f6ff0f0 MV |
118 | /* MISC */ |
119 | GPIO10_GPIO, /* hotsync button */ | |
120 | GPIO90_GPIO, /* power detect */ | |
121 | GPIO107_GPIO, /* earphone detect */ | |
122 | }; | |
123 | ||
124 | /****************************************************************************** | |
125 | * SD/MMC card controller | |
126 | ******************************************************************************/ | |
0f6ff0f0 | 127 | static struct pxamci_platform_data palmt5_mci_platform_data = { |
7a648256 RJ |
128 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
129 | .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N, | |
130 | .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY, | |
131 | .gpio_power = GPIO_NR_PALMT5_SD_POWER, | |
9845b6b1 | 132 | .detect_delay = 20, |
0f6ff0f0 MV |
133 | }; |
134 | ||
135 | /****************************************************************************** | |
136 | * GPIO keyboard | |
137 | ******************************************************************************/ | |
138 | static unsigned int palmt5_matrix_keys[] = { | |
139 | KEY(0, 0, KEY_POWER), | |
140 | KEY(0, 1, KEY_F1), | |
141 | KEY(0, 2, KEY_ENTER), | |
142 | ||
143 | KEY(1, 0, KEY_F2), | |
144 | KEY(1, 1, KEY_F3), | |
145 | KEY(1, 2, KEY_F4), | |
146 | ||
147 | KEY(2, 0, KEY_UP), | |
148 | KEY(2, 2, KEY_DOWN), | |
149 | ||
150 | KEY(3, 0, KEY_RIGHT), | |
151 | KEY(3, 2, KEY_LEFT), | |
152 | }; | |
153 | ||
154 | static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = { | |
155 | .matrix_key_rows = 4, | |
156 | .matrix_key_cols = 3, | |
157 | .matrix_key_map = palmt5_matrix_keys, | |
158 | .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys), | |
159 | ||
160 | .debounce_interval = 30, | |
161 | }; | |
162 | ||
163 | /****************************************************************************** | |
164 | * GPIO keys | |
165 | ******************************************************************************/ | |
166 | static struct gpio_keys_button palmt5_pxa_buttons[] = { | |
167 | {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" }, | |
168 | }; | |
169 | ||
170 | static struct gpio_keys_platform_data palmt5_pxa_keys_data = { | |
171 | .buttons = palmt5_pxa_buttons, | |
172 | .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons), | |
173 | }; | |
174 | ||
175 | static struct platform_device palmt5_pxa_keys = { | |
176 | .name = "gpio-keys", | |
177 | .id = -1, | |
178 | .dev = { | |
179 | .platform_data = &palmt5_pxa_keys_data, | |
180 | }, | |
181 | }; | |
182 | ||
183 | /****************************************************************************** | |
184 | * Backlight | |
185 | ******************************************************************************/ | |
186 | static int palmt5_backlight_init(struct device *dev) | |
187 | { | |
188 | int ret; | |
189 | ||
190 | ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER"); | |
191 | if (ret) | |
192 | goto err; | |
193 | ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0); | |
194 | if (ret) | |
195 | goto err2; | |
196 | ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER"); | |
197 | if (ret) | |
198 | goto err2; | |
199 | ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0); | |
200 | if (ret) | |
201 | goto err3; | |
202 | ||
203 | return 0; | |
204 | err3: | |
205 | gpio_free(GPIO_NR_PALMT5_LCD_POWER); | |
206 | err2: | |
207 | gpio_free(GPIO_NR_PALMT5_BL_POWER); | |
208 | err: | |
209 | return ret; | |
210 | } | |
211 | ||
212 | static int palmt5_backlight_notify(int brightness) | |
213 | { | |
214 | gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness); | |
215 | gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness); | |
216 | return brightness; | |
217 | } | |
218 | ||
219 | static void palmt5_backlight_exit(struct device *dev) | |
220 | { | |
221 | gpio_free(GPIO_NR_PALMT5_BL_POWER); | |
222 | gpio_free(GPIO_NR_PALMT5_LCD_POWER); | |
223 | } | |
224 | ||
225 | static struct platform_pwm_backlight_data palmt5_backlight_data = { | |
226 | .pwm_id = 0, | |
227 | .max_brightness = PALMT5_MAX_INTENSITY, | |
228 | .dft_brightness = PALMT5_MAX_INTENSITY, | |
229 | .pwm_period_ns = PALMT5_PERIOD_NS, | |
230 | .init = palmt5_backlight_init, | |
231 | .notify = palmt5_backlight_notify, | |
232 | .exit = palmt5_backlight_exit, | |
233 | }; | |
234 | ||
235 | static struct platform_device palmt5_backlight = { | |
236 | .name = "pwm-backlight", | |
237 | .dev = { | |
238 | .parent = &pxa27x_device_pwm0.dev, | |
239 | .platform_data = &palmt5_backlight_data, | |
240 | }, | |
241 | }; | |
242 | ||
243 | /****************************************************************************** | |
244 | * IrDA | |
245 | ******************************************************************************/ | |
246 | static int palmt5_irda_startup(struct device *dev) | |
247 | { | |
248 | int err; | |
249 | err = gpio_request(GPIO_NR_PALMT5_IR_DISABLE, "IR DISABLE"); | |
250 | if (err) | |
251 | goto err; | |
252 | err = gpio_direction_output(GPIO_NR_PALMT5_IR_DISABLE, 1); | |
253 | if (err) | |
254 | gpio_free(GPIO_NR_PALMT5_IR_DISABLE); | |
255 | err: | |
256 | return err; | |
257 | } | |
258 | ||
259 | static void palmt5_irda_shutdown(struct device *dev) | |
260 | { | |
261 | gpio_free(GPIO_NR_PALMT5_IR_DISABLE); | |
262 | } | |
263 | ||
264 | static void palmt5_irda_transceiver_mode(struct device *dev, int mode) | |
265 | { | |
266 | gpio_set_value(GPIO_NR_PALMT5_IR_DISABLE, mode & IR_OFF); | |
267 | pxa2xx_transceiver_mode(dev, mode); | |
268 | } | |
269 | ||
270 | static struct pxaficp_platform_data palmt5_ficp_platform_data = { | |
271 | .startup = palmt5_irda_startup, | |
272 | .shutdown = palmt5_irda_shutdown, | |
273 | .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, | |
274 | .transceiver_mode = palmt5_irda_transceiver_mode, | |
275 | }; | |
276 | ||
277 | /****************************************************************************** | |
278 | * UDC | |
279 | ******************************************************************************/ | |
8768dc9b | 280 | static struct gpio_vbus_mach_info palmt5_udc_info = { |
0f6ff0f0 MV |
281 | .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N, |
282 | .gpio_vbus_inverted = 1, | |
efb12cd2 | 283 | .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP, |
8768dc9b MV |
284 | }; |
285 | ||
286 | static struct platform_device palmt5_gpio_vbus = { | |
287 | .name = "gpio-vbus", | |
288 | .id = -1, | |
289 | .dev = { | |
290 | .platform_data = &palmt5_udc_info, | |
291 | }, | |
0f6ff0f0 MV |
292 | }; |
293 | ||
294 | /****************************************************************************** | |
295 | * Power supply | |
296 | ******************************************************************************/ | |
297 | static int power_supply_init(struct device *dev) | |
298 | { | |
299 | int ret; | |
300 | ||
301 | ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC"); | |
302 | if (ret) | |
303 | goto err1; | |
304 | ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT); | |
305 | if (ret) | |
306 | goto err2; | |
307 | ||
308 | return 0; | |
309 | err2: | |
310 | gpio_free(GPIO_NR_PALMT5_POWER_DETECT); | |
311 | err1: | |
312 | return ret; | |
313 | } | |
314 | ||
315 | static int palmt5_is_ac_online(void) | |
316 | { | |
317 | return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT); | |
318 | } | |
319 | ||
320 | static void power_supply_exit(struct device *dev) | |
321 | { | |
322 | gpio_free(GPIO_NR_PALMT5_POWER_DETECT); | |
323 | } | |
324 | ||
325 | static char *palmt5_supplicants[] = { | |
326 | "main-battery", | |
327 | }; | |
328 | ||
329 | static struct pda_power_pdata power_supply_info = { | |
330 | .init = power_supply_init, | |
331 | .is_ac_online = palmt5_is_ac_online, | |
332 | .exit = power_supply_exit, | |
333 | .supplied_to = palmt5_supplicants, | |
334 | .num_supplicants = ARRAY_SIZE(palmt5_supplicants), | |
335 | }; | |
336 | ||
337 | static struct platform_device power_supply = { | |
338 | .name = "pda-power", | |
339 | .id = -1, | |
340 | .dev = { | |
341 | .platform_data = &power_supply_info, | |
342 | }, | |
343 | }; | |
344 | ||
345 | /****************************************************************************** | |
346 | * WM97xx battery | |
347 | ******************************************************************************/ | |
348 | static struct wm97xx_batt_info wm97xx_batt_pdata = { | |
349 | .batt_aux = WM97XX_AUX_ID3, | |
350 | .temp_aux = WM97XX_AUX_ID2, | |
351 | .charge_gpio = -1, | |
352 | .max_voltage = PALMT5_BAT_MAX_VOLTAGE, | |
353 | .min_voltage = PALMT5_BAT_MIN_VOLTAGE, | |
354 | .batt_mult = 1000, | |
355 | .batt_div = 414, | |
356 | .temp_mult = 1, | |
357 | .temp_div = 1, | |
358 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, | |
359 | .batt_name = "main-batt", | |
360 | }; | |
361 | ||
362 | /****************************************************************************** | |
363 | * aSoC audio | |
364 | ******************************************************************************/ | |
e91fb913 | 365 | static struct palm27x_asoc_info palmt5_asoc_pdata = { |
0f6ff0f0 MV |
366 | .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT, |
367 | }; | |
368 | ||
e91fb913 MV |
369 | static pxa2xx_audio_ops_t palmt5_ac97_pdata = { |
370 | .reset_gpio = 95, | |
371 | }; | |
372 | ||
373 | static struct platform_device palmt5_asoc = { | |
374 | .name = "palm27x-asoc", | |
375 | .id = -1, | |
376 | .dev = { | |
377 | .platform_data = &palmt5_asoc_pdata, | |
378 | }, | |
379 | }; | |
380 | ||
0f6ff0f0 MV |
381 | /****************************************************************************** |
382 | * Framebuffer | |
383 | ******************************************************************************/ | |
384 | static struct pxafb_mode_info palmt5_lcd_modes[] = { | |
385 | { | |
386 | .pixclock = 57692, | |
387 | .xres = 320, | |
388 | .yres = 480, | |
389 | .bpp = 16, | |
390 | ||
391 | .left_margin = 32, | |
392 | .right_margin = 1, | |
393 | .upper_margin = 7, | |
394 | .lower_margin = 1, | |
395 | ||
396 | .hsync_len = 4, | |
397 | .vsync_len = 1, | |
398 | }, | |
399 | }; | |
400 | ||
401 | static struct pxafb_mach_info palmt5_lcd_screen = { | |
402 | .modes = palmt5_lcd_modes, | |
403 | .num_modes = ARRAY_SIZE(palmt5_lcd_modes), | |
404 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
405 | }; | |
406 | ||
81854f82 MV |
407 | /****************************************************************************** |
408 | * Power management - standby | |
409 | ******************************************************************************/ | |
fc9c1b6f | 410 | static void __init palmt5_pm_init(void) |
81854f82 | 411 | { |
fc9c1b6f MV |
412 | static u32 resume[] = { |
413 | 0xe3a00101, /* mov r0, #0x40000000 */ | |
414 | 0xe380060f, /* orr r0, r0, #0x00f00000 */ | |
415 | 0xe590f008, /* ldr pc, [r0, #0x08] */ | |
416 | }; | |
417 | ||
418 | /* copy the bootloader */ | |
419 | memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume)); | |
81854f82 MV |
420 | } |
421 | ||
0f6ff0f0 MV |
422 | /****************************************************************************** |
423 | * Machine init | |
424 | ******************************************************************************/ | |
425 | static struct platform_device *devices[] __initdata = { | |
426 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
427 | &palmt5_pxa_keys, | |
428 | #endif | |
429 | &palmt5_backlight, | |
430 | &power_supply, | |
e91fb913 | 431 | &palmt5_asoc, |
8768dc9b | 432 | &palmt5_gpio_vbus, |
0f6ff0f0 MV |
433 | }; |
434 | ||
435 | /* setup udc GPIOs initial state */ | |
436 | static void __init palmt5_udc_init(void) | |
437 | { | |
efb12cd2 MV |
438 | if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) { |
439 | gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1); | |
440 | gpio_free(GPIO_NR_PALMT5_USB_PULLUP); | |
0f6ff0f0 MV |
441 | } |
442 | } | |
443 | ||
444 | static void __init palmt5_init(void) | |
445 | { | |
446 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config)); | |
447 | ||
fc9c1b6f | 448 | palmt5_pm_init(); |
0f6ff0f0 MV |
449 | set_pxa_fb_info(&palmt5_lcd_screen); |
450 | pxa_set_mci_info(&palmt5_mci_platform_data); | |
451 | palmt5_udc_init(); | |
e91fb913 | 452 | pxa_set_ac97_info(&palmt5_ac97_pdata); |
0f6ff0f0 MV |
453 | pxa_set_ficp_info(&palmt5_ficp_platform_data); |
454 | pxa_set_keypad_info(&palmt5_keypad_platform_data); | |
455 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); | |
fc9c1b6f | 456 | |
0f6ff0f0 MV |
457 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
458 | } | |
459 | ||
460 | MACHINE_START(PALMT5, "Palm Tungsten|T5") | |
461 | .phys_io = PALMT5_PHYS_IO_START, | |
462 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
463 | .boot_params = 0xa0000100, | |
464 | .map_io = pxa_map_io, | |
465 | .init_irq = pxa27x_init_irq, | |
466 | .timer = &pxa_timer, | |
467 | .init_machine = palmt5_init | |
468 | MACHINE_END |