blob: d8b4469607a1e1794a1775238bddd8c478e99e4a [file] [log] [blame]
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +02001/*
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +02002 * Hardware definitions for Palm Treo smartphones
3 *
4 * currently supported:
5 * Palm Treo 680 (GSM)
Tomáš Čechd0a92fd2009-09-11 13:57:02 +02006 * Palm Centro 685 (GSM)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +02007 *
8 * Author: Tomas Cech <sleep_walker@suse.cz>
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>
23#include <linux/pda_power.h>
24#include <linux/pwm_backlight.h>
25#include <linux/gpio.h>
26#include <linux/wm97xx_batt.h>
27#include <linux/power_supply.h>
28#include <linux/sysdev.h>
29#include <linux/w1-gpio.h>
30
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
35#include <mach/pxa27x.h>
36#include <mach/pxa27x-udc.h>
37#include <mach/audio.h>
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +020038#include <mach/palmtreo.h>
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020039#include <mach/mmc.h>
40#include <mach/pxafb.h>
41#include <mach/irda.h>
42#include <mach/pxa27x_keypad.h>
43#include <mach/udc.h>
44#include <mach/ohci.h>
45#include <mach/pxa2xx-regs.h>
46#include <mach/palmasoc.h>
47#include <mach/camera.h>
48
49#include <sound/pxa2xx-lib.h>
50
51#include "generic.h"
52#include "devices.h"
53
54/******************************************************************************
55 * Pin configuration
56 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +020057static unsigned long treo_pin_config[] __initdata = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020058 /* MMC */
59 GPIO32_MMC_CLK,
60 GPIO92_MMC_DAT_0,
61 GPIO109_MMC_DAT_1,
62 GPIO110_MMC_DAT_2,
63 GPIO111_MMC_DAT_3,
64 GPIO112_MMC_CMD,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020065 GPIO113_GPIO, /* SD detect */
66
67 /* AC97 */
68 GPIO28_AC97_BITCLK,
69 GPIO29_AC97_SDATA_IN_0,
70 GPIO30_AC97_SDATA_OUT,
71 GPIO31_AC97_SYNC,
72 GPIO89_AC97_SYSCLK,
73 GPIO95_AC97_nRESET,
74
75 /* IrDA */
76 GPIO46_FICP_RXD,
77 GPIO47_FICP_TXD,
78
79 /* PWM */
80 GPIO16_PWM0_OUT,
81
82 /* USB */
83 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
84
85 /* MATRIX KEYPAD */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020086 GPIO101_KP_MKIN_1,
87 GPIO102_KP_MKIN_2,
88 GPIO97_KP_MKIN_3,
89 GPIO98_KP_MKIN_4,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020090 GPIO91_KP_MKIN_6,
91 GPIO13_KP_MKIN_7,
92 GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
93 GPIO104_KP_MKOUT_1,
94 GPIO105_KP_MKOUT_2,
95 GPIO106_KP_MKOUT_3,
96 GPIO107_KP_MKOUT_4,
97 GPIO108_KP_MKOUT_5,
98 GPIO96_KP_MKOUT_6,
99 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
100
101 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800102 GPIOxx_LCD_TFT_16BPP,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200103
104 /* Quick Capture Interface */
105 GPIO84_CIF_FV,
106 GPIO85_CIF_LV,
107 GPIO53_CIF_MCLK,
108 GPIO54_CIF_PCLK,
109 GPIO81_CIF_DD_0,
110 GPIO55_CIF_DD_1,
111 GPIO51_CIF_DD_2,
112 GPIO50_CIF_DD_3,
113 GPIO52_CIF_DD_4,
114 GPIO48_CIF_DD_5,
115 GPIO17_CIF_DD_6,
116 GPIO12_CIF_DD_7,
117
118 /* I2C */
119 GPIO117_I2C_SCL,
120 GPIO118_I2C_SDA,
121
122 /* GSM */
123 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
124 GPIO34_FFUART_RXD,
125 GPIO35_FFUART_CTS,
126 GPIO39_FFUART_TXD,
127 GPIO41_FFUART_RTS,
128
129 /* MISC. */
130 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
131 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
132 GPIO116_GPIO, /* headphone detect */
133 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
134};
135
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200136#ifdef CONFIG_MACH_TREO680
137static unsigned long treo680_pin_config[] __initdata = {
138 GPIO33_GPIO, /* SD read only */
139
140 /* MATRIX KEYPAD - different wake up source */
141 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
142 GPIO99_KP_MKIN_5,
143};
144#endif /* CONFIG_MACH_TREO680 */
145
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200146#ifdef CONFIG_MACH_CENTRO
147static unsigned long centro685_pin_config[] __initdata = {
148 /* Bluetooth attached to BT UART*/
149 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
150 GPIO42_BTUART_RXD,
151 GPIO43_BTUART_TXD,
152 GPIO44_BTUART_CTS,
153 GPIO45_BTUART_RTS,
154
155 /* MATRIX KEYPAD - different wake up source */
156 GPIO100_KP_MKIN_0,
157 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
158};
159#endif /* CONFIG_MACH_CENTRO */
160
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200161/******************************************************************************
162 * SD/MMC card controller
163 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200164#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200165static struct pxamci_platform_data treo680_mci_platform_data = {
walker@suse.cz7dafdf32009-08-31 19:25:57 +0200166 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200167 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
walker@suse.cz7dafdf32009-08-31 19:25:57 +0200168 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
169 .gpio_power = GPIO_NR_TREO680_SD_POWER,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200170};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200171#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200172
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200173#ifdef CONFIG_MACH_CENTRO
174static struct pxamci_platform_data centro_mci_platform_data = {
175 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
176 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
177 .gpio_card_ro = -1,
178 .gpio_power = GPIO_NR_CENTRO_SD_POWER,
179 .gpio_power_invert = 1,
180};
181#endif /* CONFIG_MACH_CENTRO */
182
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200183/******************************************************************************
184 * GPIO keyboard
185 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200186#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200187static unsigned int treo680_matrix_keys[] = {
188 KEY(0, 0, KEY_F8), /* Red/Off/Power */
189 KEY(0, 1, KEY_LEFT),
190 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
191 KEY(0, 3, KEY_L),
192 KEY(0, 4, KEY_A),
193 KEY(0, 5, KEY_Q),
194 KEY(0, 6, KEY_P),
195
196 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
197 KEY(1, 1, KEY_RIGHT),
198 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
199 KEY(1, 3, KEY_Z),
200 KEY(1, 4, KEY_S),
201 KEY(1, 5, KEY_W),
202
203 KEY(2, 0, KEY_F1), /* Phone */
204 KEY(2, 1, KEY_UP),
205 KEY(2, 2, KEY_0),
206 KEY(2, 3, KEY_X),
207 KEY(2, 4, KEY_D),
208 KEY(2, 5, KEY_E),
209
210 KEY(3, 0, KEY_F10), /* Calendar */
211 KEY(3, 1, KEY_DOWN),
212 KEY(3, 2, KEY_SPACE),
213 KEY(3, 3, KEY_C),
214 KEY(3, 4, KEY_F),
215 KEY(3, 5, KEY_R),
216
217 KEY(4, 0, KEY_F12), /* Mail */
218 KEY(4, 1, KEY_KPENTER),
219 KEY(4, 2, KEY_RIGHTALT), /* Alt */
220 KEY(4, 3, KEY_V),
221 KEY(4, 4, KEY_G),
222 KEY(4, 5, KEY_T),
223
224 KEY(5, 0, KEY_F9), /* Home */
225 KEY(5, 1, KEY_PAGEUP), /* Side up */
226 KEY(5, 2, KEY_DOT),
227 KEY(5, 3, KEY_B),
228 KEY(5, 4, KEY_H),
229 KEY(5, 5, KEY_Y),
230
231 KEY(6, 0, KEY_TAB), /* Side Activate */
232 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
233 KEY(6, 2, KEY_ENTER),
234 KEY(6, 3, KEY_N),
235 KEY(6, 4, KEY_J),
236 KEY(6, 5, KEY_U),
237
238 KEY(7, 0, KEY_F6), /* Green/Call */
239 KEY(7, 1, KEY_O),
240 KEY(7, 2, KEY_BACKSPACE),
241 KEY(7, 3, KEY_M),
242 KEY(7, 4, KEY_K),
243 KEY(7, 5, KEY_I),
244};
245
246static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
247 .matrix_key_rows = 8,
248 .matrix_key_cols = 7,
249 .matrix_key_map = treo680_matrix_keys,
250 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
251 .direct_key_map = { KEY_CONNECT },
252 .direct_key_num = 1,
253
254 .debounce_interval = 30,
255};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200256#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200257
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200258#ifdef CONFIG_MACH_CENTRO
259static unsigned int centro_matrix_keys[] = {
260 KEY(0, 0, KEY_F9), /* Home */
261 KEY(0, 1, KEY_LEFT),
262 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
263 KEY(0, 3, KEY_L),
264 KEY(0, 4, KEY_A),
265 KEY(0, 5, KEY_Q),
266 KEY(0, 6, KEY_P),
267
268 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
269 KEY(1, 1, KEY_RIGHT),
270 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
271 KEY(1, 3, KEY_Z),
272 KEY(1, 4, KEY_S),
273 KEY(1, 5, KEY_W),
274
275 KEY(2, 0, KEY_F1), /* Phone */
276 KEY(2, 1, KEY_UP),
277 KEY(2, 2, KEY_0),
278 KEY(2, 3, KEY_X),
279 KEY(2, 4, KEY_D),
280 KEY(2, 5, KEY_E),
281
282 KEY(3, 0, KEY_F10), /* Calendar */
283 KEY(3, 1, KEY_DOWN),
284 KEY(3, 2, KEY_SPACE),
285 KEY(3, 3, KEY_C),
286 KEY(3, 4, KEY_F),
287 KEY(3, 5, KEY_R),
288
289 KEY(4, 0, KEY_F12), /* Mail */
290 KEY(4, 1, KEY_KPENTER),
291 KEY(4, 2, KEY_RIGHTALT), /* Alt */
292 KEY(4, 3, KEY_V),
293 KEY(4, 4, KEY_G),
294 KEY(4, 5, KEY_T),
295
296 KEY(5, 0, KEY_F8), /* Red/Off/Power */
297 KEY(5, 1, KEY_PAGEUP), /* Side up */
298 KEY(5, 2, KEY_DOT),
299 KEY(5, 3, KEY_B),
300 KEY(5, 4, KEY_H),
301 KEY(5, 5, KEY_Y),
302
303 KEY(6, 0, KEY_TAB), /* Side Activate */
304 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
305 KEY(6, 2, KEY_ENTER),
306 KEY(6, 3, KEY_N),
307 KEY(6, 4, KEY_J),
308 KEY(6, 5, KEY_U),
309
310 KEY(7, 0, KEY_F6), /* Green/Call */
311 KEY(7, 1, KEY_O),
312 KEY(7, 2, KEY_BACKSPACE),
313 KEY(7, 3, KEY_M),
314 KEY(7, 4, KEY_K),
315 KEY(7, 5, KEY_I),
316};
317
318static struct pxa27x_keypad_platform_data centro_keypad_platform_data = {
319 .matrix_key_rows = 8,
320 .matrix_key_cols = 7,
321 .matrix_key_map = centro_matrix_keys,
322 .matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys),
323 .direct_key_map = { KEY_CONNECT },
324 .direct_key_num = 1,
325
326 .debounce_interval = 30,
327};
328#endif /* CONFIG_MACH_CENTRO */
329
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200330/******************************************************************************
331 * aSoC audio
332 ******************************************************************************/
333
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200334static pxa2xx_audio_ops_t treo_ac97_pdata = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200335 .reset_gpio = 95,
336};
337
338/******************************************************************************
339 * Backlight
340 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200341static int treo_backlight_init(struct device *dev)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200342{
343 int ret;
344
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200345 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200346 if (ret)
347 goto err;
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200348 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200349 if (ret)
350 goto err2;
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200351
352 return 0;
Tomáš Čech28d7a942009-09-03 16:55:47 +0200353
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200354err2:
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200355 gpio_free(GPIO_NR_TREO_BL_POWER);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200356err:
357 return ret;
358}
359
Eric Miao2d51a522010-01-04 11:42:01 +0800360static int treo_backlight_notify(struct device *dev, int brightness)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200361{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200362 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
363 return TREO_MAX_INTENSITY - brightness;
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200364};
365
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200366static void treo_backlight_exit(struct device *dev)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200367{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200368 gpio_free(GPIO_NR_TREO_BL_POWER);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200369}
370
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200371static struct platform_pwm_backlight_data treo_backlight_data = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200372 .pwm_id = 0,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200373 .max_brightness = TREO_MAX_INTENSITY,
374 .dft_brightness = TREO_DEFAULT_INTENSITY,
375 .pwm_period_ns = TREO_PERIOD_NS,
376 .init = treo_backlight_init,
377 .notify = treo_backlight_notify,
378 .exit = treo_backlight_exit,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200379};
380
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200381static struct platform_device treo_backlight = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200382 .name = "pwm-backlight",
383 .dev = {
384 .parent = &pxa27x_device_pwm0.dev,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200385 .platform_data = &treo_backlight_data,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200386 },
387};
388
389/******************************************************************************
390 * IrDA
391 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200392static struct pxaficp_platform_data treo_ficp_info = {
393 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
Marek Vasutc4bd0172009-07-17 12:50:43 +0200394 .transceiver_cap = IR_SIRMODE | IR_OFF,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200395};
396
397/******************************************************************************
398 * UDC
399 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200400static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
401 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200402 .gpio_vbus_inverted = 1,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200403 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200404};
405
406
407/******************************************************************************
408 * USB host
409 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200410#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200411static struct pxaohci_platform_data treo680_ohci_info = {
412 .port_mode = PMM_PERPORT_MODE,
413 .flags = ENABLE_PORT1 | ENABLE_PORT3,
414 .power_budget = 0,
415};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200416#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200417
418/******************************************************************************
419 * Power supply
420 ******************************************************************************/
421static int power_supply_init(struct device *dev)
422{
423 int ret;
424
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200425 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200426 if (ret)
427 goto err1;
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200428 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200429 if (ret)
430 goto err2;
431
432 return 0;
433
434err2:
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200435 gpio_free(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200436err1:
437 return ret;
438}
439
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200440static int treo_is_ac_online(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200441{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200442 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200443}
444
445static void power_supply_exit(struct device *dev)
446{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200447 gpio_free(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200448}
449
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200450static char *treo_supplicants[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200451 "main-battery",
452};
453
454static struct pda_power_pdata power_supply_info = {
455 .init = power_supply_init,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200456 .is_ac_online = treo_is_ac_online,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200457 .exit = power_supply_exit,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200458 .supplied_to = treo_supplicants,
459 .num_supplicants = ARRAY_SIZE(treo_supplicants),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200460};
461
462static struct platform_device power_supply = {
463 .name = "pda-power",
464 .id = -1,
465 .dev = {
466 .platform_data = &power_supply_info,
467 },
468};
469
470/******************************************************************************
471 * Vibra and LEDs
472 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200473#ifdef CONFIG_MACH_TREO680
474static struct gpio_led treo680_gpio_leds[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200475 {
476 .name = "treo680:vibra:vibra",
477 .default_trigger = "none",
478 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
479 },
480 {
481 .name = "treo680:green:led",
482 .default_trigger = "mmc0",
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200483 .gpio = GPIO_NR_TREO_GREEN_LED,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200484 },
485 {
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200486 .name = "treo680:white:keybbl",
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200487 .default_trigger = "none",
488 .gpio = GPIO_NR_TREO680_KEYB_BL,
489 },
490};
491
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200492static struct gpio_led_platform_data treo680_gpio_led_info = {
493 .leds = treo680_gpio_leds,
494 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200495};
496
497static struct platform_device treo680_leds = {
498 .name = "leds-gpio",
499 .id = -1,
500 .dev = {
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200501 .platform_data = &treo680_gpio_led_info,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200502 }
503};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200504#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200505
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200506#ifdef CONFIG_MACH_CENTRO
507static struct gpio_led centro_gpio_leds[] = {
508 {
509 .name = "centro:vibra:vibra",
510 .default_trigger = "none",
511 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
512 },
513 {
514 .name = "centro:green:led",
515 .default_trigger = "mmc0",
516 .gpio = GPIO_NR_TREO_GREEN_LED,
517 },
518 {
519 .name = "centro:white:keybbl",
520 .default_trigger = "none",
521 .active_low = 1,
522 .gpio = GPIO_NR_CENTRO_KEYB_BL,
523 },
524};
525
526static struct gpio_led_platform_data centro_gpio_led_info = {
527 .leds = centro_gpio_leds,
528 .num_leds = ARRAY_SIZE(centro_gpio_leds),
529};
530
531static struct platform_device centro_leds = {
532 .name = "leds-gpio",
533 .id = -1,
534 .dev = {
535 .platform_data = &centro_gpio_led_info,
536 }
537};
538#endif /* CONFIG_MACH_CENTRO */
539
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200540/******************************************************************************
541 * Framebuffer
542 ******************************************************************************/
543/* TODO: add support for 324x324 */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200544static struct pxafb_mode_info treo_lcd_modes[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200545{
546 .pixclock = 86538,
547 .xres = 320,
548 .yres = 320,
549 .bpp = 16,
550
551 .left_margin = 20,
552 .right_margin = 8,
553 .upper_margin = 8,
554 .lower_margin = 5,
555
556 .hsync_len = 4,
557 .vsync_len = 1,
558},
559};
560
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200561static void treo_lcd_power(int on, struct fb_var_screeninfo *info)
Tomáš Čech28d7a942009-09-03 16:55:47 +0200562{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200563 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200564}
565
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200566static struct pxafb_mach_info treo_lcd_screen = {
567 .modes = treo_lcd_modes,
568 .num_modes = ARRAY_SIZE(treo_lcd_modes),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200569 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
570};
571
572/******************************************************************************
573 * Power management - standby
574 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200575static void __init treo_pm_init(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200576{
577 static u32 resume[] = {
578 0xe3a00101, /* mov r0, #0x40000000 */
579 0xe380060f, /* orr r0, r0, #0x00f00000 */
580 0xe590f008, /* ldr pc, [r0, #0x08] */
581 };
582
583 /* this is where the bootloader jumps */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200584 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200585}
586
587/******************************************************************************
588 * Machine init
589 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200590static struct platform_device *treo_devices[] __initdata = {
591 &treo_backlight,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200592 &power_supply,
593};
594
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200595#ifdef CONFIG_MACH_TREO680
596static struct platform_device *treo680_devices[] __initdata = {
597 &treo680_leds,
598};
599#endif /* CONFIG_MACH_TREO680 */
600
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200601#ifdef CONFIG_MACH_CENTRO
602static struct platform_device *centro_devices[] __initdata = {
603 &centro_leds,
604};
605#endif /* CONFIG_MACH_CENTRO */
606
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200607/* setup udc GPIOs initial state */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200608static void __init treo_udc_init(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200609{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200610 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) {
611 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1);
612 gpio_free(GPIO_NR_TREO_USB_PULLUP);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200613 }
614}
615
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200616static void __init treo_lcd_power_init(void)
Tomáš Čech28d7a942009-09-03 16:55:47 +0200617{
618 int ret;
619
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200620 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
Tomáš Čech28d7a942009-09-03 16:55:47 +0200621 if (ret) {
622 pr_err("Treo680: LCD power GPIO request failed!\n");
623 return;
624 }
625
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200626 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200627 if (ret) {
628 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200629 gpio_free(GPIO_NR_TREO_LCD_POWER);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200630 return;
631 }
632
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200633 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
Tomáš Čech28d7a942009-09-03 16:55:47 +0200634}
635
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200636static void __init treo_init(void)
637{
Russell Kingcc155c62009-11-09 13:34:08 +0800638 pxa_set_ffuart_info(NULL);
639 pxa_set_btuart_info(NULL);
640 pxa_set_stuart_info(NULL);
641
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200642 treo_pm_init();
643 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
644 treo_lcd_power_init();
645 set_pxa_fb_info(&treo_lcd_screen);
646 treo_udc_init();
647 pxa_set_udc_info(&treo_udc_info);
648 pxa_set_ac97_info(&treo_ac97_pdata);
649 pxa_set_ficp_info(&treo_ficp_info);
650
651 platform_add_devices(ARRAY_AND_SIZE(treo_devices));
652}
653
654#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200655static void __init treo680_init(void)
656{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200657 treo_init();
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200658 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200659 pxa_set_mci_info(&treo680_mci_platform_data);
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200660 pxa_set_keypad_info(&treo680_keypad_platform_data);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200661 pxa_set_ohci_info(&treo680_ohci_info);
662
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200663 platform_add_devices(ARRAY_AND_SIZE(treo680_devices));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200664}
665
666MACHINE_START(TREO680, "Palm Treo 680")
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200667 .phys_io = TREO_PHYS_IO_START,
668 .io_pg_offst = io_p2v(0x40000000),
669 .boot_params = 0xa0000100,
670 .map_io = pxa_map_io,
671 .init_irq = pxa27x_init_irq,
672 .timer = &pxa_timer,
673 .init_machine = treo680_init,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200674MACHINE_END
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200675#endif /* CONFIG_MACH_TREO680 */
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200676
677#ifdef CONFIG_MACH_CENTRO
678static void __init centro_init(void)
679{
680 treo_init();
681 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
682 pxa_set_mci_info(&centro_mci_platform_data);
683
684 pxa_set_keypad_info(&centro_keypad_platform_data);
685
686 platform_add_devices(ARRAY_AND_SIZE(centro_devices));
687}
688
689MACHINE_START(CENTRO, "Palm Centro 685")
690 .phys_io = TREO_PHYS_IO_START,
691 .io_pg_offst = io_p2v(0x40000000),
692 .boot_params = 0xa0000100,
693 .map_io = pxa_map_io,
694 .init_irq = pxa27x_init_irq,
695 .timer = &pxa_timer,
696 .init_machine = centro_init,
697MACHINE_END
698#endif /* CONFIG_MACH_CENTRO */