blob: 3d0c9cc2a40648a049a3ccc81a34c5f03f4126de [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>
Russell King8d717a52010-05-22 19:47:18 +010023#include <linux/memblock.h>
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020024#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>
29#include <linux/sysdev.h>
30#include <linux/w1-gpio.h>
31
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
36#include <mach/pxa27x.h>
37#include <mach/pxa27x-udc.h>
38#include <mach/audio.h>
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +020039#include <mach/palmtreo.h>
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020040#include <mach/mmc.h>
41#include <mach/pxafb.h>
42#include <mach/irda.h>
43#include <mach/pxa27x_keypad.h>
44#include <mach/udc.h>
45#include <mach/ohci.h>
46#include <mach/pxa2xx-regs.h>
47#include <mach/palmasoc.h>
48#include <mach/camera.h>
49
50#include <sound/pxa2xx-lib.h>
51
52#include "generic.h"
53#include "devices.h"
54
55/******************************************************************************
56 * Pin configuration
57 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +020058static unsigned long treo_pin_config[] __initdata = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020059 /* MMC */
60 GPIO32_MMC_CLK,
61 GPIO92_MMC_DAT_0,
62 GPIO109_MMC_DAT_1,
63 GPIO110_MMC_DAT_2,
64 GPIO111_MMC_DAT_3,
65 GPIO112_MMC_CMD,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020066 GPIO113_GPIO, /* SD detect */
67
68 /* AC97 */
69 GPIO28_AC97_BITCLK,
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
72 GPIO31_AC97_SYNC,
73 GPIO89_AC97_SYSCLK,
74 GPIO95_AC97_nRESET,
75
76 /* IrDA */
77 GPIO46_FICP_RXD,
78 GPIO47_FICP_TXD,
79
80 /* PWM */
81 GPIO16_PWM0_OUT,
82
83 /* USB */
84 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
85
86 /* MATRIX KEYPAD */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020087 GPIO101_KP_MKIN_1,
88 GPIO102_KP_MKIN_2,
89 GPIO97_KP_MKIN_3,
90 GPIO98_KP_MKIN_4,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +020091 GPIO91_KP_MKIN_6,
92 GPIO13_KP_MKIN_7,
93 GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
94 GPIO104_KP_MKOUT_1,
95 GPIO105_KP_MKOUT_2,
96 GPIO106_KP_MKOUT_3,
97 GPIO107_KP_MKOUT_4,
98 GPIO108_KP_MKOUT_5,
99 GPIO96_KP_MKOUT_6,
100 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
101
102 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800103 GPIOxx_LCD_TFT_16BPP,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200104
105 /* Quick Capture Interface */
106 GPIO84_CIF_FV,
107 GPIO85_CIF_LV,
108 GPIO53_CIF_MCLK,
109 GPIO54_CIF_PCLK,
110 GPIO81_CIF_DD_0,
111 GPIO55_CIF_DD_1,
112 GPIO51_CIF_DD_2,
113 GPIO50_CIF_DD_3,
114 GPIO52_CIF_DD_4,
115 GPIO48_CIF_DD_5,
116 GPIO17_CIF_DD_6,
117 GPIO12_CIF_DD_7,
118
119 /* I2C */
120 GPIO117_I2C_SCL,
121 GPIO118_I2C_SDA,
122
123 /* GSM */
124 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
125 GPIO34_FFUART_RXD,
126 GPIO35_FFUART_CTS,
127 GPIO39_FFUART_TXD,
128 GPIO41_FFUART_RTS,
129
130 /* MISC. */
131 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
132 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
133 GPIO116_GPIO, /* headphone detect */
134 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
135};
136
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200137#ifdef CONFIG_MACH_TREO680
138static unsigned long treo680_pin_config[] __initdata = {
139 GPIO33_GPIO, /* SD read only */
140
141 /* MATRIX KEYPAD - different wake up source */
142 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
143 GPIO99_KP_MKIN_5,
144};
145#endif /* CONFIG_MACH_TREO680 */
146
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200147#ifdef CONFIG_MACH_CENTRO
148static unsigned long centro685_pin_config[] __initdata = {
149 /* Bluetooth attached to BT UART*/
150 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
151 GPIO42_BTUART_RXD,
152 GPIO43_BTUART_TXD,
153 GPIO44_BTUART_CTS,
154 GPIO45_BTUART_RTS,
155
156 /* MATRIX KEYPAD - different wake up source */
157 GPIO100_KP_MKIN_0,
158 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
159};
160#endif /* CONFIG_MACH_CENTRO */
161
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200162/******************************************************************************
163 * SD/MMC card controller
164 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200165#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200166static struct pxamci_platform_data treo680_mci_platform_data = {
walker@suse.cz7dafdf32009-08-31 19:25:57 +0200167 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200168 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
walker@suse.cz7dafdf32009-08-31 19:25:57 +0200169 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
170 .gpio_power = GPIO_NR_TREO680_SD_POWER,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200171};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200172#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200173
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200174#ifdef CONFIG_MACH_CENTRO
175static struct pxamci_platform_data centro_mci_platform_data = {
176 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
177 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
178 .gpio_card_ro = -1,
179 .gpio_power = GPIO_NR_CENTRO_SD_POWER,
180 .gpio_power_invert = 1,
181};
182#endif /* CONFIG_MACH_CENTRO */
183
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200184/******************************************************************************
185 * GPIO keyboard
186 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200187#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200188static unsigned int treo680_matrix_keys[] = {
189 KEY(0, 0, KEY_F8), /* Red/Off/Power */
190 KEY(0, 1, KEY_LEFT),
191 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
192 KEY(0, 3, KEY_L),
193 KEY(0, 4, KEY_A),
194 KEY(0, 5, KEY_Q),
195 KEY(0, 6, KEY_P),
196
197 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
198 KEY(1, 1, KEY_RIGHT),
199 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
200 KEY(1, 3, KEY_Z),
201 KEY(1, 4, KEY_S),
202 KEY(1, 5, KEY_W),
203
204 KEY(2, 0, KEY_F1), /* Phone */
205 KEY(2, 1, KEY_UP),
206 KEY(2, 2, KEY_0),
207 KEY(2, 3, KEY_X),
208 KEY(2, 4, KEY_D),
209 KEY(2, 5, KEY_E),
210
211 KEY(3, 0, KEY_F10), /* Calendar */
212 KEY(3, 1, KEY_DOWN),
213 KEY(3, 2, KEY_SPACE),
214 KEY(3, 3, KEY_C),
215 KEY(3, 4, KEY_F),
216 KEY(3, 5, KEY_R),
217
218 KEY(4, 0, KEY_F12), /* Mail */
219 KEY(4, 1, KEY_KPENTER),
220 KEY(4, 2, KEY_RIGHTALT), /* Alt */
221 KEY(4, 3, KEY_V),
222 KEY(4, 4, KEY_G),
223 KEY(4, 5, KEY_T),
224
225 KEY(5, 0, KEY_F9), /* Home */
226 KEY(5, 1, KEY_PAGEUP), /* Side up */
227 KEY(5, 2, KEY_DOT),
228 KEY(5, 3, KEY_B),
229 KEY(5, 4, KEY_H),
230 KEY(5, 5, KEY_Y),
231
232 KEY(6, 0, KEY_TAB), /* Side Activate */
233 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
234 KEY(6, 2, KEY_ENTER),
235 KEY(6, 3, KEY_N),
236 KEY(6, 4, KEY_J),
237 KEY(6, 5, KEY_U),
238
239 KEY(7, 0, KEY_F6), /* Green/Call */
240 KEY(7, 1, KEY_O),
241 KEY(7, 2, KEY_BACKSPACE),
242 KEY(7, 3, KEY_M),
243 KEY(7, 4, KEY_K),
244 KEY(7, 5, KEY_I),
245};
246
247static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
248 .matrix_key_rows = 8,
249 .matrix_key_cols = 7,
250 .matrix_key_map = treo680_matrix_keys,
251 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
252 .direct_key_map = { KEY_CONNECT },
253 .direct_key_num = 1,
254
255 .debounce_interval = 30,
256};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200257#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200258
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200259#ifdef CONFIG_MACH_CENTRO
260static unsigned int centro_matrix_keys[] = {
261 KEY(0, 0, KEY_F9), /* Home */
262 KEY(0, 1, KEY_LEFT),
263 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
264 KEY(0, 3, KEY_L),
265 KEY(0, 4, KEY_A),
266 KEY(0, 5, KEY_Q),
267 KEY(0, 6, KEY_P),
268
269 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
270 KEY(1, 1, KEY_RIGHT),
271 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
272 KEY(1, 3, KEY_Z),
273 KEY(1, 4, KEY_S),
274 KEY(1, 5, KEY_W),
275
276 KEY(2, 0, KEY_F1), /* Phone */
277 KEY(2, 1, KEY_UP),
278 KEY(2, 2, KEY_0),
279 KEY(2, 3, KEY_X),
280 KEY(2, 4, KEY_D),
281 KEY(2, 5, KEY_E),
282
283 KEY(3, 0, KEY_F10), /* Calendar */
284 KEY(3, 1, KEY_DOWN),
285 KEY(3, 2, KEY_SPACE),
286 KEY(3, 3, KEY_C),
287 KEY(3, 4, KEY_F),
288 KEY(3, 5, KEY_R),
289
290 KEY(4, 0, KEY_F12), /* Mail */
291 KEY(4, 1, KEY_KPENTER),
292 KEY(4, 2, KEY_RIGHTALT), /* Alt */
293 KEY(4, 3, KEY_V),
294 KEY(4, 4, KEY_G),
295 KEY(4, 5, KEY_T),
296
297 KEY(5, 0, KEY_F8), /* Red/Off/Power */
298 KEY(5, 1, KEY_PAGEUP), /* Side up */
299 KEY(5, 2, KEY_DOT),
300 KEY(5, 3, KEY_B),
301 KEY(5, 4, KEY_H),
302 KEY(5, 5, KEY_Y),
303
304 KEY(6, 0, KEY_TAB), /* Side Activate */
305 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
306 KEY(6, 2, KEY_ENTER),
307 KEY(6, 3, KEY_N),
308 KEY(6, 4, KEY_J),
309 KEY(6, 5, KEY_U),
310
311 KEY(7, 0, KEY_F6), /* Green/Call */
312 KEY(7, 1, KEY_O),
313 KEY(7, 2, KEY_BACKSPACE),
314 KEY(7, 3, KEY_M),
315 KEY(7, 4, KEY_K),
316 KEY(7, 5, KEY_I),
317};
318
319static struct pxa27x_keypad_platform_data centro_keypad_platform_data = {
320 .matrix_key_rows = 8,
321 .matrix_key_cols = 7,
322 .matrix_key_map = centro_matrix_keys,
323 .matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys),
324 .direct_key_map = { KEY_CONNECT },
325 .direct_key_num = 1,
326
327 .debounce_interval = 30,
328};
329#endif /* CONFIG_MACH_CENTRO */
330
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200331/******************************************************************************
332 * aSoC audio
333 ******************************************************************************/
334
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200335static pxa2xx_audio_ops_t treo_ac97_pdata = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200336 .reset_gpio = 95,
337};
338
339/******************************************************************************
340 * Backlight
341 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200342static int treo_backlight_init(struct device *dev)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200343{
344 int ret;
345
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200346 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200347 if (ret)
348 goto err;
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200349 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200350 if (ret)
351 goto err2;
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200352
353 return 0;
Tomáš Čech28d7a942009-09-03 16:55:47 +0200354
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200355err2:
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200356 gpio_free(GPIO_NR_TREO_BL_POWER);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200357err:
358 return ret;
359}
360
Eric Miao2d51a522010-01-04 11:42:01 +0800361static int treo_backlight_notify(struct device *dev, int brightness)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200362{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200363 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
364 return TREO_MAX_INTENSITY - brightness;
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200365};
366
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200367static void treo_backlight_exit(struct device *dev)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200368{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200369 gpio_free(GPIO_NR_TREO_BL_POWER);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200370}
371
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200372static struct platform_pwm_backlight_data treo_backlight_data = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200373 .pwm_id = 0,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200374 .max_brightness = TREO_MAX_INTENSITY,
375 .dft_brightness = TREO_DEFAULT_INTENSITY,
376 .pwm_period_ns = TREO_PERIOD_NS,
377 .init = treo_backlight_init,
378 .notify = treo_backlight_notify,
379 .exit = treo_backlight_exit,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200380};
381
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200382static struct platform_device treo_backlight = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200383 .name = "pwm-backlight",
384 .dev = {
385 .parent = &pxa27x_device_pwm0.dev,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200386 .platform_data = &treo_backlight_data,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200387 },
388};
389
390/******************************************************************************
391 * IrDA
392 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200393static struct pxaficp_platform_data treo_ficp_info = {
394 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
Marek Vasutc4bd0172009-07-17 12:50:43 +0200395 .transceiver_cap = IR_SIRMODE | IR_OFF,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200396};
397
398/******************************************************************************
399 * UDC
400 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200401static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
402 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200403 .gpio_vbus_inverted = 1,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200404 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200405};
406
407
408/******************************************************************************
409 * USB host
410 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200411#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200412static struct pxaohci_platform_data treo680_ohci_info = {
413 .port_mode = PMM_PERPORT_MODE,
414 .flags = ENABLE_PORT1 | ENABLE_PORT3,
415 .power_budget = 0,
416};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200417#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200418
419/******************************************************************************
420 * Power supply
421 ******************************************************************************/
422static int power_supply_init(struct device *dev)
423{
424 int ret;
425
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200426 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200427 if (ret)
428 goto err1;
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200429 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200430 if (ret)
431 goto err2;
432
433 return 0;
434
435err2:
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200436 gpio_free(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200437err1:
438 return ret;
439}
440
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200441static int treo_is_ac_online(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200442{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200443 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200444}
445
446static void power_supply_exit(struct device *dev)
447{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200448 gpio_free(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200449}
450
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200451static char *treo_supplicants[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200452 "main-battery",
453};
454
455static struct pda_power_pdata power_supply_info = {
456 .init = power_supply_init,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200457 .is_ac_online = treo_is_ac_online,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200458 .exit = power_supply_exit,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200459 .supplied_to = treo_supplicants,
460 .num_supplicants = ARRAY_SIZE(treo_supplicants),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200461};
462
463static struct platform_device power_supply = {
464 .name = "pda-power",
465 .id = -1,
466 .dev = {
467 .platform_data = &power_supply_info,
468 },
469};
470
471/******************************************************************************
472 * Vibra and LEDs
473 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200474#ifdef CONFIG_MACH_TREO680
475static struct gpio_led treo680_gpio_leds[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200476 {
477 .name = "treo680:vibra:vibra",
478 .default_trigger = "none",
479 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
480 },
481 {
482 .name = "treo680:green:led",
483 .default_trigger = "mmc0",
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200484 .gpio = GPIO_NR_TREO_GREEN_LED,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200485 },
486 {
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200487 .name = "treo680:white:keybbl",
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200488 .default_trigger = "none",
489 .gpio = GPIO_NR_TREO680_KEYB_BL,
490 },
491};
492
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200493static struct gpio_led_platform_data treo680_gpio_led_info = {
494 .leds = treo680_gpio_leds,
495 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200496};
497
498static struct platform_device treo680_leds = {
499 .name = "leds-gpio",
500 .id = -1,
501 .dev = {
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200502 .platform_data = &treo680_gpio_led_info,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200503 }
504};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200505#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200506
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200507#ifdef CONFIG_MACH_CENTRO
508static struct gpio_led centro_gpio_leds[] = {
509 {
510 .name = "centro:vibra:vibra",
511 .default_trigger = "none",
512 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
513 },
514 {
515 .name = "centro:green:led",
516 .default_trigger = "mmc0",
517 .gpio = GPIO_NR_TREO_GREEN_LED,
518 },
519 {
520 .name = "centro:white:keybbl",
521 .default_trigger = "none",
522 .active_low = 1,
523 .gpio = GPIO_NR_CENTRO_KEYB_BL,
524 },
525};
526
527static struct gpio_led_platform_data centro_gpio_led_info = {
528 .leds = centro_gpio_leds,
529 .num_leds = ARRAY_SIZE(centro_gpio_leds),
530};
531
532static struct platform_device centro_leds = {
533 .name = "leds-gpio",
534 .id = -1,
535 .dev = {
536 .platform_data = &centro_gpio_led_info,
537 }
538};
539#endif /* CONFIG_MACH_CENTRO */
540
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200541/******************************************************************************
542 * Framebuffer
543 ******************************************************************************/
544/* TODO: add support for 324x324 */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200545static struct pxafb_mode_info treo_lcd_modes[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200546{
547 .pixclock = 86538,
548 .xres = 320,
549 .yres = 320,
550 .bpp = 16,
551
552 .left_margin = 20,
553 .right_margin = 8,
554 .upper_margin = 8,
555 .lower_margin = 5,
556
557 .hsync_len = 4,
558 .vsync_len = 1,
559},
560};
561
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200562static void treo_lcd_power(int on, struct fb_var_screeninfo *info)
Tomáš Čech28d7a942009-09-03 16:55:47 +0200563{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200564 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200565}
566
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200567static struct pxafb_mach_info treo_lcd_screen = {
568 .modes = treo_lcd_modes,
569 .num_modes = ARRAY_SIZE(treo_lcd_modes),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200570 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
571};
572
573/******************************************************************************
574 * Power management - standby
575 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200576static void __init treo_pm_init(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200577{
578 static u32 resume[] = {
579 0xe3a00101, /* mov r0, #0x40000000 */
580 0xe380060f, /* orr r0, r0, #0x00f00000 */
581 0xe590f008, /* ldr pc, [r0, #0x08] */
582 };
583
584 /* this is where the bootloader jumps */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200585 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200586}
587
588/******************************************************************************
589 * Machine init
590 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200591static struct platform_device *treo_devices[] __initdata = {
592 &treo_backlight,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200593 &power_supply,
594};
595
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200596#ifdef CONFIG_MACH_TREO680
597static struct platform_device *treo680_devices[] __initdata = {
598 &treo680_leds,
599};
600#endif /* CONFIG_MACH_TREO680 */
601
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200602#ifdef CONFIG_MACH_CENTRO
603static struct platform_device *centro_devices[] __initdata = {
604 &centro_leds,
605};
606#endif /* CONFIG_MACH_CENTRO */
607
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200608/* setup udc GPIOs initial state */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200609static void __init treo_udc_init(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200610{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200611 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) {
612 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1);
613 gpio_free(GPIO_NR_TREO_USB_PULLUP);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200614 }
615}
616
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200617static void __init treo_lcd_power_init(void)
Tomáš Čech28d7a942009-09-03 16:55:47 +0200618{
619 int ret;
620
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200621 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
Tomáš Čech28d7a942009-09-03 16:55:47 +0200622 if (ret) {
623 pr_err("Treo680: LCD power GPIO request failed!\n");
624 return;
625 }
626
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200627 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200628 if (ret) {
629 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200630 gpio_free(GPIO_NR_TREO_LCD_POWER);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200631 return;
632 }
633
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200634 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
Tomáš Čech28d7a942009-09-03 16:55:47 +0200635}
636
Russell King98c672c2010-05-22 18:18:57 +0100637static void __init treo_reserve(void)
638{
Russell King8d717a52010-05-22 19:47:18 +0100639 memblock_reserve(0xa0000000, 0x1000);
640 memblock_reserve(0xa2000000, 0x1000);
Russell King98c672c2010-05-22 18:18:57 +0100641}
642
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200643static void __init treo_init(void)
644{
Russell Kingcc155c62009-11-09 13:34:08 +0800645 pxa_set_ffuart_info(NULL);
646 pxa_set_btuart_info(NULL);
647 pxa_set_stuart_info(NULL);
648
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200649 treo_pm_init();
650 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
651 treo_lcd_power_init();
652 set_pxa_fb_info(&treo_lcd_screen);
653 treo_udc_init();
654 pxa_set_udc_info(&treo_udc_info);
655 pxa_set_ac97_info(&treo_ac97_pdata);
656 pxa_set_ficp_info(&treo_ficp_info);
657
658 platform_add_devices(ARRAY_AND_SIZE(treo_devices));
659}
660
661#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200662static void __init treo680_init(void)
663{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200664 treo_init();
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200665 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200666 pxa_set_mci_info(&treo680_mci_platform_data);
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200667 pxa_set_keypad_info(&treo680_keypad_platform_data);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200668 pxa_set_ohci_info(&treo680_ohci_info);
669
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200670 platform_add_devices(ARRAY_AND_SIZE(treo680_devices));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200671}
672
673MACHINE_START(TREO680, "Palm Treo 680")
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200674 .phys_io = TREO_PHYS_IO_START,
675 .io_pg_offst = io_p2v(0x40000000),
676 .boot_params = 0xa0000100,
677 .map_io = pxa_map_io,
Russell King98c672c2010-05-22 18:18:57 +0100678 .reserve = treo_reserve,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200679 .init_irq = pxa27x_init_irq,
680 .timer = &pxa_timer,
681 .init_machine = treo680_init,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200682MACHINE_END
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200683#endif /* CONFIG_MACH_TREO680 */
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200684
685#ifdef CONFIG_MACH_CENTRO
686static void __init centro_init(void)
687{
688 treo_init();
689 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
690 pxa_set_mci_info(&centro_mci_platform_data);
691
692 pxa_set_keypad_info(&centro_keypad_platform_data);
693
694 platform_add_devices(ARRAY_AND_SIZE(centro_devices));
695}
696
697MACHINE_START(CENTRO, "Palm Centro 685")
698 .phys_io = TREO_PHYS_IO_START,
699 .io_pg_offst = io_p2v(0x40000000),
700 .boot_params = 0xa0000100,
701 .map_io = pxa_map_io,
Russell King98c672c2010-05-22 18:18:57 +0100702 .reserve = treo_reserve,
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200703 .init_irq = pxa27x_init_irq,
704 .timer = &pxa_timer,
705 .init_machine = centro_init,
706MACHINE_END
707#endif /* CONFIG_MACH_CENTRO */