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 | ******************************************************************************/ | |
54088bf5 | 120 | static struct pxamci_platform_data palmte2_mci_platform_data = { |
7a648256 RJ |
121 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
122 | .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N, | |
123 | .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY, | |
124 | .gpio_power = GPIO_NR_PALMTE2_SD_POWER, | |
54088bf5 MV |
125 | }; |
126 | ||
127 | /****************************************************************************** | |
128 | * GPIO keys | |
129 | ******************************************************************************/ | |
130 | static struct gpio_keys_button palmte2_pxa_buttons[] = { | |
131 | {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" }, | |
132 | {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" }, | |
133 | {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" }, | |
134 | {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" }, | |
135 | {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" }, | |
136 | {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" }, | |
137 | {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" }, | |
138 | {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" }, | |
139 | {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" }, | |
140 | }; | |
141 | ||
142 | static struct gpio_keys_platform_data palmte2_pxa_keys_data = { | |
143 | .buttons = palmte2_pxa_buttons, | |
144 | .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons), | |
145 | }; | |
146 | ||
147 | static struct platform_device palmte2_pxa_keys = { | |
148 | .name = "gpio-keys", | |
149 | .id = -1, | |
150 | .dev = { | |
151 | .platform_data = &palmte2_pxa_keys_data, | |
152 | }, | |
153 | }; | |
154 | ||
155 | /****************************************************************************** | |
156 | * Backlight | |
157 | ******************************************************************************/ | |
8c8aa5fa MV |
158 | static int palmte2_backlight_init(struct device *dev) |
159 | { | |
160 | int ret; | |
161 | ||
162 | ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER"); | |
163 | if (ret) | |
164 | goto err; | |
165 | ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0); | |
166 | if (ret) | |
167 | goto err2; | |
168 | ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER"); | |
169 | if (ret) | |
170 | goto err2; | |
171 | ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0); | |
172 | if (ret) | |
173 | goto err3; | |
174 | ||
175 | return 0; | |
176 | err3: | |
177 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); | |
178 | err2: | |
179 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); | |
180 | err: | |
181 | return ret; | |
182 | } | |
183 | ||
2d51a521 | 184 | static int palmte2_backlight_notify(struct device *dev, int brightness) |
8c8aa5fa MV |
185 | { |
186 | gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness); | |
187 | gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness); | |
188 | return brightness; | |
189 | } | |
190 | ||
191 | static void palmte2_backlight_exit(struct device *dev) | |
192 | { | |
193 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); | |
194 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); | |
195 | } | |
196 | ||
54088bf5 MV |
197 | static struct platform_pwm_backlight_data palmte2_backlight_data = { |
198 | .pwm_id = 0, | |
199 | .max_brightness = PALMTE2_MAX_INTENSITY, | |
200 | .dft_brightness = PALMTE2_MAX_INTENSITY, | |
201 | .pwm_period_ns = PALMTE2_PERIOD_NS, | |
8c8aa5fa MV |
202 | .init = palmte2_backlight_init, |
203 | .notify = palmte2_backlight_notify, | |
204 | .exit = palmte2_backlight_exit, | |
54088bf5 MV |
205 | }; |
206 | ||
207 | static struct platform_device palmte2_backlight = { | |
208 | .name = "pwm-backlight", | |
209 | .dev = { | |
210 | .parent = &pxa25x_device_pwm0.dev, | |
211 | .platform_data = &palmte2_backlight_data, | |
212 | }, | |
213 | }; | |
214 | ||
8c8aa5fa MV |
215 | /****************************************************************************** |
216 | * IrDA | |
217 | ******************************************************************************/ | |
8c8aa5fa | 218 | static struct pxaficp_platform_data palmte2_ficp_platform_data = { |
c4bd0172 MV |
219 | .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE, |
220 | .transceiver_cap = IR_SIRMODE | IR_OFF, | |
8c8aa5fa MV |
221 | }; |
222 | ||
223 | /****************************************************************************** | |
224 | * UDC | |
225 | ******************************************************************************/ | |
8768dc9b | 226 | static struct gpio_vbus_mach_info palmte2_udc_info = { |
8c8aa5fa MV |
227 | .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N, |
228 | .gpio_vbus_inverted = 1, | |
229 | .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP, | |
8768dc9b MV |
230 | }; |
231 | ||
232 | static struct platform_device palmte2_gpio_vbus = { | |
233 | .name = "gpio-vbus", | |
234 | .id = -1, | |
235 | .dev = { | |
236 | .platform_data = &palmte2_udc_info, | |
237 | }, | |
8c8aa5fa MV |
238 | }; |
239 | ||
240 | /****************************************************************************** | |
241 | * Power supply | |
242 | ******************************************************************************/ | |
243 | static int power_supply_init(struct device *dev) | |
244 | { | |
245 | int ret; | |
246 | ||
247 | ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC"); | |
248 | if (ret) | |
249 | goto err1; | |
250 | ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT); | |
251 | if (ret) | |
252 | goto err2; | |
253 | ||
254 | return 0; | |
255 | ||
256 | err2: | |
257 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); | |
258 | err1: | |
259 | return ret; | |
260 | } | |
261 | ||
262 | static int palmte2_is_ac_online(void) | |
263 | { | |
264 | return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT); | |
265 | } | |
266 | ||
267 | static void power_supply_exit(struct device *dev) | |
268 | { | |
269 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); | |
270 | } | |
271 | ||
272 | static char *palmte2_supplicants[] = { | |
273 | "main-battery", | |
274 | }; | |
275 | ||
276 | static struct pda_power_pdata power_supply_info = { | |
277 | .init = power_supply_init, | |
278 | .is_ac_online = palmte2_is_ac_online, | |
279 | .exit = power_supply_exit, | |
280 | .supplied_to = palmte2_supplicants, | |
281 | .num_supplicants = ARRAY_SIZE(palmte2_supplicants), | |
282 | }; | |
283 | ||
284 | static struct platform_device power_supply = { | |
285 | .name = "pda-power", | |
286 | .id = -1, | |
287 | .dev = { | |
288 | .platform_data = &power_supply_info, | |
289 | }, | |
290 | }; | |
291 | ||
292 | /****************************************************************************** | |
293 | * WM97xx battery | |
294 | ******************************************************************************/ | |
295 | static struct wm97xx_batt_info wm97xx_batt_pdata = { | |
296 | .batt_aux = WM97XX_AUX_ID3, | |
297 | .temp_aux = WM97XX_AUX_ID2, | |
298 | .charge_gpio = -1, | |
299 | .max_voltage = PALMTE2_BAT_MAX_VOLTAGE, | |
300 | .min_voltage = PALMTE2_BAT_MIN_VOLTAGE, | |
301 | .batt_mult = 1000, | |
302 | .batt_div = 414, | |
303 | .temp_mult = 1, | |
304 | .temp_div = 1, | |
305 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, | |
306 | .batt_name = "main-batt", | |
307 | }; | |
308 | ||
37330efd MV |
309 | /****************************************************************************** |
310 | * aSoC audio | |
311 | ******************************************************************************/ | |
312 | static struct palm27x_asoc_info palmte2_asoc_pdata = { | |
313 | .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT, | |
314 | }; | |
315 | ||
316 | static struct platform_device palmte2_asoc = { | |
317 | .name = "palm27x-asoc", | |
318 | .id = -1, | |
319 | .dev = { | |
320 | .platform_data = &palmte2_asoc_pdata, | |
321 | }, | |
322 | }; | |
323 | ||
54088bf5 MV |
324 | /****************************************************************************** |
325 | * Framebuffer | |
326 | ******************************************************************************/ | |
327 | static struct pxafb_mode_info palmte2_lcd_modes[] = { | |
328 | { | |
329 | .pixclock = 77757, | |
330 | .xres = 320, | |
331 | .yres = 320, | |
332 | .bpp = 16, | |
333 | ||
334 | .left_margin = 28, | |
335 | .right_margin = 7, | |
336 | .upper_margin = 7, | |
337 | .lower_margin = 5, | |
338 | ||
339 | .hsync_len = 4, | |
340 | .vsync_len = 1, | |
341 | }, | |
342 | }; | |
343 | ||
344 | static struct pxafb_mach_info palmte2_lcd_screen = { | |
345 | .modes = palmte2_lcd_modes, | |
346 | .num_modes = ARRAY_SIZE(palmte2_lcd_modes), | |
347 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
348 | }; | |
349 | ||
350 | /****************************************************************************** | |
351 | * Machine init | |
352 | ******************************************************************************/ | |
353 | static struct platform_device *devices[] __initdata = { | |
354 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
355 | &palmte2_pxa_keys, | |
356 | #endif | |
357 | &palmte2_backlight, | |
8c8aa5fa | 358 | &power_supply, |
37330efd | 359 | &palmte2_asoc, |
8768dc9b | 360 | &palmte2_gpio_vbus, |
54088bf5 MV |
361 | }; |
362 | ||
8c8aa5fa MV |
363 | /* setup udc GPIOs initial state */ |
364 | static void __init palmte2_udc_init(void) | |
365 | { | |
366 | if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) { | |
367 | gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1); | |
368 | gpio_free(GPIO_NR_PALMTE2_USB_PULLUP); | |
369 | } | |
370 | } | |
371 | ||
54088bf5 MV |
372 | static void __init palmte2_init(void) |
373 | { | |
374 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config)); | |
375 | ||
cc155c6f RK |
376 | pxa_set_ffuart_info(NULL); |
377 | pxa_set_btuart_info(NULL); | |
378 | pxa_set_stuart_info(NULL); | |
379 | ||
54088bf5 MV |
380 | set_pxa_fb_info(&palmte2_lcd_screen); |
381 | pxa_set_mci_info(&palmte2_mci_platform_data); | |
8c8aa5fa | 382 | palmte2_udc_init(); |
54088bf5 | 383 | pxa_set_ac97_info(NULL); |
8c8aa5fa MV |
384 | pxa_set_ficp_info(&palmte2_ficp_platform_data); |
385 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); | |
54088bf5 MV |
386 | |
387 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
388 | } | |
389 | ||
390 | MACHINE_START(PALMTE2, "Palm Tungsten|E2") | |
391 | .phys_io = 0x40000000, | |
392 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
393 | .boot_params = 0xa0000100, | |
394 | .map_io = pxa_map_io, | |
395 | .init_irq = pxa25x_init_irq, | |
396 | .timer = &pxa_timer, | |
397 | .init_machine = palmte2_init | |
398 | MACHINE_END |