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 | ||
2d51a521 | 212 | static int palmt5_backlight_notify(struct device *dev, int brightness) |
0f6ff0f0 MV |
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 | ******************************************************************************/ | |
0f6ff0f0 | 246 | static struct pxaficp_platform_data palmt5_ficp_platform_data = { |
c4bd0172 MV |
247 | .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE, |
248 | .transceiver_cap = IR_SIRMODE | IR_OFF, | |
0f6ff0f0 MV |
249 | }; |
250 | ||
251 | /****************************************************************************** | |
252 | * UDC | |
253 | ******************************************************************************/ | |
8768dc9b | 254 | static struct gpio_vbus_mach_info palmt5_udc_info = { |
0f6ff0f0 MV |
255 | .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N, |
256 | .gpio_vbus_inverted = 1, | |
efb12cd2 | 257 | .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP, |
8768dc9b MV |
258 | }; |
259 | ||
260 | static struct platform_device palmt5_gpio_vbus = { | |
261 | .name = "gpio-vbus", | |
262 | .id = -1, | |
263 | .dev = { | |
264 | .platform_data = &palmt5_udc_info, | |
265 | }, | |
0f6ff0f0 MV |
266 | }; |
267 | ||
268 | /****************************************************************************** | |
269 | * Power supply | |
270 | ******************************************************************************/ | |
271 | static int power_supply_init(struct device *dev) | |
272 | { | |
273 | int ret; | |
274 | ||
275 | ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC"); | |
276 | if (ret) | |
277 | goto err1; | |
278 | ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT); | |
279 | if (ret) | |
280 | goto err2; | |
281 | ||
282 | return 0; | |
283 | err2: | |
284 | gpio_free(GPIO_NR_PALMT5_POWER_DETECT); | |
285 | err1: | |
286 | return ret; | |
287 | } | |
288 | ||
289 | static int palmt5_is_ac_online(void) | |
290 | { | |
291 | return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT); | |
292 | } | |
293 | ||
294 | static void power_supply_exit(struct device *dev) | |
295 | { | |
296 | gpio_free(GPIO_NR_PALMT5_POWER_DETECT); | |
297 | } | |
298 | ||
299 | static char *palmt5_supplicants[] = { | |
300 | "main-battery", | |
301 | }; | |
302 | ||
303 | static struct pda_power_pdata power_supply_info = { | |
304 | .init = power_supply_init, | |
305 | .is_ac_online = palmt5_is_ac_online, | |
306 | .exit = power_supply_exit, | |
307 | .supplied_to = palmt5_supplicants, | |
308 | .num_supplicants = ARRAY_SIZE(palmt5_supplicants), | |
309 | }; | |
310 | ||
311 | static struct platform_device power_supply = { | |
312 | .name = "pda-power", | |
313 | .id = -1, | |
314 | .dev = { | |
315 | .platform_data = &power_supply_info, | |
316 | }, | |
317 | }; | |
318 | ||
319 | /****************************************************************************** | |
320 | * WM97xx battery | |
321 | ******************************************************************************/ | |
322 | static struct wm97xx_batt_info wm97xx_batt_pdata = { | |
323 | .batt_aux = WM97XX_AUX_ID3, | |
324 | .temp_aux = WM97XX_AUX_ID2, | |
325 | .charge_gpio = -1, | |
326 | .max_voltage = PALMT5_BAT_MAX_VOLTAGE, | |
327 | .min_voltage = PALMT5_BAT_MIN_VOLTAGE, | |
328 | .batt_mult = 1000, | |
329 | .batt_div = 414, | |
330 | .temp_mult = 1, | |
331 | .temp_div = 1, | |
332 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, | |
333 | .batt_name = "main-batt", | |
334 | }; | |
335 | ||
336 | /****************************************************************************** | |
337 | * aSoC audio | |
338 | ******************************************************************************/ | |
e91fb913 | 339 | static struct palm27x_asoc_info palmt5_asoc_pdata = { |
0f6ff0f0 MV |
340 | .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT, |
341 | }; | |
342 | ||
e91fb913 MV |
343 | static pxa2xx_audio_ops_t palmt5_ac97_pdata = { |
344 | .reset_gpio = 95, | |
345 | }; | |
346 | ||
347 | static struct platform_device palmt5_asoc = { | |
348 | .name = "palm27x-asoc", | |
349 | .id = -1, | |
350 | .dev = { | |
351 | .platform_data = &palmt5_asoc_pdata, | |
352 | }, | |
353 | }; | |
354 | ||
0f6ff0f0 MV |
355 | /****************************************************************************** |
356 | * Framebuffer | |
357 | ******************************************************************************/ | |
358 | static struct pxafb_mode_info palmt5_lcd_modes[] = { | |
359 | { | |
360 | .pixclock = 57692, | |
361 | .xres = 320, | |
362 | .yres = 480, | |
363 | .bpp = 16, | |
364 | ||
365 | .left_margin = 32, | |
366 | .right_margin = 1, | |
367 | .upper_margin = 7, | |
368 | .lower_margin = 1, | |
369 | ||
370 | .hsync_len = 4, | |
371 | .vsync_len = 1, | |
372 | }, | |
373 | }; | |
374 | ||
375 | static struct pxafb_mach_info palmt5_lcd_screen = { | |
376 | .modes = palmt5_lcd_modes, | |
377 | .num_modes = ARRAY_SIZE(palmt5_lcd_modes), | |
378 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
379 | }; | |
380 | ||
81854f82 MV |
381 | /****************************************************************************** |
382 | * Power management - standby | |
383 | ******************************************************************************/ | |
fc9c1b6f | 384 | static void __init palmt5_pm_init(void) |
81854f82 | 385 | { |
fc9c1b6f MV |
386 | static u32 resume[] = { |
387 | 0xe3a00101, /* mov r0, #0x40000000 */ | |
388 | 0xe380060f, /* orr r0, r0, #0x00f00000 */ | |
389 | 0xe590f008, /* ldr pc, [r0, #0x08] */ | |
390 | }; | |
391 | ||
392 | /* copy the bootloader */ | |
393 | memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume)); | |
81854f82 MV |
394 | } |
395 | ||
0f6ff0f0 MV |
396 | /****************************************************************************** |
397 | * Machine init | |
398 | ******************************************************************************/ | |
399 | static struct platform_device *devices[] __initdata = { | |
400 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
401 | &palmt5_pxa_keys, | |
402 | #endif | |
403 | &palmt5_backlight, | |
404 | &power_supply, | |
e91fb913 | 405 | &palmt5_asoc, |
8768dc9b | 406 | &palmt5_gpio_vbus, |
0f6ff0f0 MV |
407 | }; |
408 | ||
409 | /* setup udc GPIOs initial state */ | |
410 | static void __init palmt5_udc_init(void) | |
411 | { | |
efb12cd2 MV |
412 | if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) { |
413 | gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1); | |
414 | gpio_free(GPIO_NR_PALMT5_USB_PULLUP); | |
0f6ff0f0 MV |
415 | } |
416 | } | |
417 | ||
418 | static void __init palmt5_init(void) | |
419 | { | |
420 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config)); | |
421 | ||
cc155c6f RK |
422 | pxa_set_ffuart_info(NULL); |
423 | pxa_set_btuart_info(NULL); | |
424 | pxa_set_stuart_info(NULL); | |
425 | ||
fc9c1b6f | 426 | palmt5_pm_init(); |
0f6ff0f0 MV |
427 | set_pxa_fb_info(&palmt5_lcd_screen); |
428 | pxa_set_mci_info(&palmt5_mci_platform_data); | |
429 | palmt5_udc_init(); | |
e91fb913 | 430 | pxa_set_ac97_info(&palmt5_ac97_pdata); |
0f6ff0f0 MV |
431 | pxa_set_ficp_info(&palmt5_ficp_platform_data); |
432 | pxa_set_keypad_info(&palmt5_keypad_platform_data); | |
433 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); | |
fc9c1b6f | 434 | |
0f6ff0f0 MV |
435 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
436 | } | |
437 | ||
438 | MACHINE_START(PALMT5, "Palm Tungsten|T5") | |
439 | .phys_io = PALMT5_PHYS_IO_START, | |
440 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
441 | .boot_params = 0xa0000100, | |
442 | .map_io = pxa_map_io, | |
443 | .init_irq = pxa27x_init_irq, | |
444 | .timer = &pxa_timer, | |
445 | .init_machine = palmt5_init | |
446 | MACHINE_END |