blob: 606eb7e8a17ea1fd231bec6930eea4a410eed54c [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 */
102 GPIO58_LCD_LDD_0,
103 GPIO59_LCD_LDD_1,
104 GPIO60_LCD_LDD_2,
105 GPIO61_LCD_LDD_3,
106 GPIO62_LCD_LDD_4,
107 GPIO63_LCD_LDD_5,
108 GPIO64_LCD_LDD_6,
109 GPIO65_LCD_LDD_7,
110 GPIO66_LCD_LDD_8,
111 GPIO67_LCD_LDD_9,
112 GPIO68_LCD_LDD_10,
113 GPIO69_LCD_LDD_11,
114 GPIO70_LCD_LDD_12,
115 GPIO71_LCD_LDD_13,
116 GPIO72_LCD_LDD_14,
117 GPIO73_LCD_LDD_15,
118 GPIO74_LCD_FCLK,
119 GPIO75_LCD_LCLK,
120 GPIO76_LCD_PCLK,
121
122 /* Quick Capture Interface */
123 GPIO84_CIF_FV,
124 GPIO85_CIF_LV,
125 GPIO53_CIF_MCLK,
126 GPIO54_CIF_PCLK,
127 GPIO81_CIF_DD_0,
128 GPIO55_CIF_DD_1,
129 GPIO51_CIF_DD_2,
130 GPIO50_CIF_DD_3,
131 GPIO52_CIF_DD_4,
132 GPIO48_CIF_DD_5,
133 GPIO17_CIF_DD_6,
134 GPIO12_CIF_DD_7,
135
136 /* I2C */
137 GPIO117_I2C_SCL,
138 GPIO118_I2C_SDA,
139
140 /* GSM */
141 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
142 GPIO34_FFUART_RXD,
143 GPIO35_FFUART_CTS,
144 GPIO39_FFUART_TXD,
145 GPIO41_FFUART_RTS,
146
147 /* MISC. */
148 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
149 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
150 GPIO116_GPIO, /* headphone detect */
151 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
152};
153
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200154#ifdef CONFIG_MACH_TREO680
155static unsigned long treo680_pin_config[] __initdata = {
156 GPIO33_GPIO, /* SD read only */
157
158 /* MATRIX KEYPAD - different wake up source */
159 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
160 GPIO99_KP_MKIN_5,
161};
162#endif /* CONFIG_MACH_TREO680 */
163
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200164#ifdef CONFIG_MACH_CENTRO
165static unsigned long centro685_pin_config[] __initdata = {
166 /* Bluetooth attached to BT UART*/
167 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
168 GPIO42_BTUART_RXD,
169 GPIO43_BTUART_TXD,
170 GPIO44_BTUART_CTS,
171 GPIO45_BTUART_RTS,
172
173 /* MATRIX KEYPAD - different wake up source */
174 GPIO100_KP_MKIN_0,
175 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
176};
177#endif /* CONFIG_MACH_CENTRO */
178
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200179/******************************************************************************
180 * SD/MMC card controller
181 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200182#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200183static struct pxamci_platform_data treo680_mci_platform_data = {
walker@suse.cz7dafdf32009-08-31 19:25:57 +0200184 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200185 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
walker@suse.cz7dafdf32009-08-31 19:25:57 +0200186 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
187 .gpio_power = GPIO_NR_TREO680_SD_POWER,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200188};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200189#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200190
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200191#ifdef CONFIG_MACH_CENTRO
192static struct pxamci_platform_data centro_mci_platform_data = {
193 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
194 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
195 .gpio_card_ro = -1,
196 .gpio_power = GPIO_NR_CENTRO_SD_POWER,
197 .gpio_power_invert = 1,
198};
199#endif /* CONFIG_MACH_CENTRO */
200
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200201/******************************************************************************
202 * GPIO keyboard
203 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200204#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200205static unsigned int treo680_matrix_keys[] = {
206 KEY(0, 0, KEY_F8), /* Red/Off/Power */
207 KEY(0, 1, KEY_LEFT),
208 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
209 KEY(0, 3, KEY_L),
210 KEY(0, 4, KEY_A),
211 KEY(0, 5, KEY_Q),
212 KEY(0, 6, KEY_P),
213
214 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
215 KEY(1, 1, KEY_RIGHT),
216 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
217 KEY(1, 3, KEY_Z),
218 KEY(1, 4, KEY_S),
219 KEY(1, 5, KEY_W),
220
221 KEY(2, 0, KEY_F1), /* Phone */
222 KEY(2, 1, KEY_UP),
223 KEY(2, 2, KEY_0),
224 KEY(2, 3, KEY_X),
225 KEY(2, 4, KEY_D),
226 KEY(2, 5, KEY_E),
227
228 KEY(3, 0, KEY_F10), /* Calendar */
229 KEY(3, 1, KEY_DOWN),
230 KEY(3, 2, KEY_SPACE),
231 KEY(3, 3, KEY_C),
232 KEY(3, 4, KEY_F),
233 KEY(3, 5, KEY_R),
234
235 KEY(4, 0, KEY_F12), /* Mail */
236 KEY(4, 1, KEY_KPENTER),
237 KEY(4, 2, KEY_RIGHTALT), /* Alt */
238 KEY(4, 3, KEY_V),
239 KEY(4, 4, KEY_G),
240 KEY(4, 5, KEY_T),
241
242 KEY(5, 0, KEY_F9), /* Home */
243 KEY(5, 1, KEY_PAGEUP), /* Side up */
244 KEY(5, 2, KEY_DOT),
245 KEY(5, 3, KEY_B),
246 KEY(5, 4, KEY_H),
247 KEY(5, 5, KEY_Y),
248
249 KEY(6, 0, KEY_TAB), /* Side Activate */
250 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
251 KEY(6, 2, KEY_ENTER),
252 KEY(6, 3, KEY_N),
253 KEY(6, 4, KEY_J),
254 KEY(6, 5, KEY_U),
255
256 KEY(7, 0, KEY_F6), /* Green/Call */
257 KEY(7, 1, KEY_O),
258 KEY(7, 2, KEY_BACKSPACE),
259 KEY(7, 3, KEY_M),
260 KEY(7, 4, KEY_K),
261 KEY(7, 5, KEY_I),
262};
263
264static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
265 .matrix_key_rows = 8,
266 .matrix_key_cols = 7,
267 .matrix_key_map = treo680_matrix_keys,
268 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
269 .direct_key_map = { KEY_CONNECT },
270 .direct_key_num = 1,
271
272 .debounce_interval = 30,
273};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200274#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200275
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200276#ifdef CONFIG_MACH_CENTRO
277static unsigned int centro_matrix_keys[] = {
278 KEY(0, 0, KEY_F9), /* Home */
279 KEY(0, 1, KEY_LEFT),
280 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
281 KEY(0, 3, KEY_L),
282 KEY(0, 4, KEY_A),
283 KEY(0, 5, KEY_Q),
284 KEY(0, 6, KEY_P),
285
286 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
287 KEY(1, 1, KEY_RIGHT),
288 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
289 KEY(1, 3, KEY_Z),
290 KEY(1, 4, KEY_S),
291 KEY(1, 5, KEY_W),
292
293 KEY(2, 0, KEY_F1), /* Phone */
294 KEY(2, 1, KEY_UP),
295 KEY(2, 2, KEY_0),
296 KEY(2, 3, KEY_X),
297 KEY(2, 4, KEY_D),
298 KEY(2, 5, KEY_E),
299
300 KEY(3, 0, KEY_F10), /* Calendar */
301 KEY(3, 1, KEY_DOWN),
302 KEY(3, 2, KEY_SPACE),
303 KEY(3, 3, KEY_C),
304 KEY(3, 4, KEY_F),
305 KEY(3, 5, KEY_R),
306
307 KEY(4, 0, KEY_F12), /* Mail */
308 KEY(4, 1, KEY_KPENTER),
309 KEY(4, 2, KEY_RIGHTALT), /* Alt */
310 KEY(4, 3, KEY_V),
311 KEY(4, 4, KEY_G),
312 KEY(4, 5, KEY_T),
313
314 KEY(5, 0, KEY_F8), /* Red/Off/Power */
315 KEY(5, 1, KEY_PAGEUP), /* Side up */
316 KEY(5, 2, KEY_DOT),
317 KEY(5, 3, KEY_B),
318 KEY(5, 4, KEY_H),
319 KEY(5, 5, KEY_Y),
320
321 KEY(6, 0, KEY_TAB), /* Side Activate */
322 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
323 KEY(6, 2, KEY_ENTER),
324 KEY(6, 3, KEY_N),
325 KEY(6, 4, KEY_J),
326 KEY(6, 5, KEY_U),
327
328 KEY(7, 0, KEY_F6), /* Green/Call */
329 KEY(7, 1, KEY_O),
330 KEY(7, 2, KEY_BACKSPACE),
331 KEY(7, 3, KEY_M),
332 KEY(7, 4, KEY_K),
333 KEY(7, 5, KEY_I),
334};
335
336static struct pxa27x_keypad_platform_data centro_keypad_platform_data = {
337 .matrix_key_rows = 8,
338 .matrix_key_cols = 7,
339 .matrix_key_map = centro_matrix_keys,
340 .matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys),
341 .direct_key_map = { KEY_CONNECT },
342 .direct_key_num = 1,
343
344 .debounce_interval = 30,
345};
346#endif /* CONFIG_MACH_CENTRO */
347
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200348/******************************************************************************
349 * aSoC audio
350 ******************************************************************************/
351
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200352static pxa2xx_audio_ops_t treo_ac97_pdata = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200353 .reset_gpio = 95,
354};
355
356/******************************************************************************
357 * Backlight
358 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200359static int treo_backlight_init(struct device *dev)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200360{
361 int ret;
362
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200363 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200364 if (ret)
365 goto err;
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200366 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200367 if (ret)
368 goto err2;
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200369
370 return 0;
Tomáš Čech28d7a942009-09-03 16:55:47 +0200371
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200372err2:
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200373 gpio_free(GPIO_NR_TREO_BL_POWER);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200374err:
375 return ret;
376}
377
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200378static int treo_backlight_notify(int brightness)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200379{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200380 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
381 return TREO_MAX_INTENSITY - brightness;
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200382};
383
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200384static void treo_backlight_exit(struct device *dev)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200385{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200386 gpio_free(GPIO_NR_TREO_BL_POWER);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200387}
388
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200389static struct platform_pwm_backlight_data treo_backlight_data = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200390 .pwm_id = 0,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200391 .max_brightness = TREO_MAX_INTENSITY,
392 .dft_brightness = TREO_DEFAULT_INTENSITY,
393 .pwm_period_ns = TREO_PERIOD_NS,
394 .init = treo_backlight_init,
395 .notify = treo_backlight_notify,
396 .exit = treo_backlight_exit,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200397};
398
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200399static struct platform_device treo_backlight = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200400 .name = "pwm-backlight",
401 .dev = {
402 .parent = &pxa27x_device_pwm0.dev,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200403 .platform_data = &treo_backlight_data,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200404 },
405};
406
407/******************************************************************************
408 * IrDA
409 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200410static struct pxaficp_platform_data treo_ficp_info = {
411 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
Marek Vasutc4bd0172009-07-17 12:50:43 +0200412 .transceiver_cap = IR_SIRMODE | IR_OFF,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200413};
414
415/******************************************************************************
416 * UDC
417 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200418static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
419 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200420 .gpio_vbus_inverted = 1,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200421 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200422};
423
424
425/******************************************************************************
426 * USB host
427 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200428#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200429static struct pxaohci_platform_data treo680_ohci_info = {
430 .port_mode = PMM_PERPORT_MODE,
431 .flags = ENABLE_PORT1 | ENABLE_PORT3,
432 .power_budget = 0,
433};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200434#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200435
436/******************************************************************************
437 * Power supply
438 ******************************************************************************/
439static int power_supply_init(struct device *dev)
440{
441 int ret;
442
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200443 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200444 if (ret)
445 goto err1;
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200446 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200447 if (ret)
448 goto err2;
449
450 return 0;
451
452err2:
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200453 gpio_free(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200454err1:
455 return ret;
456}
457
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200458static int treo_is_ac_online(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200459{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200460 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200461}
462
463static void power_supply_exit(struct device *dev)
464{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200465 gpio_free(GPIO_NR_TREO_POWER_DETECT);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200466}
467
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200468static char *treo_supplicants[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200469 "main-battery",
470};
471
472static struct pda_power_pdata power_supply_info = {
473 .init = power_supply_init,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200474 .is_ac_online = treo_is_ac_online,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200475 .exit = power_supply_exit,
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200476 .supplied_to = treo_supplicants,
477 .num_supplicants = ARRAY_SIZE(treo_supplicants),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200478};
479
480static struct platform_device power_supply = {
481 .name = "pda-power",
482 .id = -1,
483 .dev = {
484 .platform_data = &power_supply_info,
485 },
486};
487
488/******************************************************************************
489 * Vibra and LEDs
490 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200491#ifdef CONFIG_MACH_TREO680
492static struct gpio_led treo680_gpio_leds[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200493 {
494 .name = "treo680:vibra:vibra",
495 .default_trigger = "none",
496 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
497 },
498 {
499 .name = "treo680:green:led",
500 .default_trigger = "mmc0",
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200501 .gpio = GPIO_NR_TREO_GREEN_LED,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200502 },
503 {
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200504 .name = "treo680:white:keybbl",
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200505 .default_trigger = "none",
506 .gpio = GPIO_NR_TREO680_KEYB_BL,
507 },
508};
509
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200510static struct gpio_led_platform_data treo680_gpio_led_info = {
511 .leds = treo680_gpio_leds,
512 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200513};
514
515static struct platform_device treo680_leds = {
516 .name = "leds-gpio",
517 .id = -1,
518 .dev = {
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200519 .platform_data = &treo680_gpio_led_info,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200520 }
521};
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200522#endif /* CONFIG_MACH_TREO680 */
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200523
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200524#ifdef CONFIG_MACH_CENTRO
525static struct gpio_led centro_gpio_leds[] = {
526 {
527 .name = "centro:vibra:vibra",
528 .default_trigger = "none",
529 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
530 },
531 {
532 .name = "centro:green:led",
533 .default_trigger = "mmc0",
534 .gpio = GPIO_NR_TREO_GREEN_LED,
535 },
536 {
537 .name = "centro:white:keybbl",
538 .default_trigger = "none",
539 .active_low = 1,
540 .gpio = GPIO_NR_CENTRO_KEYB_BL,
541 },
542};
543
544static struct gpio_led_platform_data centro_gpio_led_info = {
545 .leds = centro_gpio_leds,
546 .num_leds = ARRAY_SIZE(centro_gpio_leds),
547};
548
549static struct platform_device centro_leds = {
550 .name = "leds-gpio",
551 .id = -1,
552 .dev = {
553 .platform_data = &centro_gpio_led_info,
554 }
555};
556#endif /* CONFIG_MACH_CENTRO */
557
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200558/******************************************************************************
559 * Framebuffer
560 ******************************************************************************/
561/* TODO: add support for 324x324 */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200562static struct pxafb_mode_info treo_lcd_modes[] = {
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200563{
564 .pixclock = 86538,
565 .xres = 320,
566 .yres = 320,
567 .bpp = 16,
568
569 .left_margin = 20,
570 .right_margin = 8,
571 .upper_margin = 8,
572 .lower_margin = 5,
573
574 .hsync_len = 4,
575 .vsync_len = 1,
576},
577};
578
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200579static void treo_lcd_power(int on, struct fb_var_screeninfo *info)
Tomáš Čech28d7a942009-09-03 16:55:47 +0200580{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200581 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200582}
583
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200584static struct pxafb_mach_info treo_lcd_screen = {
585 .modes = treo_lcd_modes,
586 .num_modes = ARRAY_SIZE(treo_lcd_modes),
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200587 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
588};
589
590/******************************************************************************
591 * Power management - standby
592 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200593static void __init treo_pm_init(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200594{
595 static u32 resume[] = {
596 0xe3a00101, /* mov r0, #0x40000000 */
597 0xe380060f, /* orr r0, r0, #0x00f00000 */
598 0xe590f008, /* ldr pc, [r0, #0x08] */
599 };
600
601 /* this is where the bootloader jumps */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200602 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200603}
604
605/******************************************************************************
606 * Machine init
607 ******************************************************************************/
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200608static struct platform_device *treo_devices[] __initdata = {
609 &treo_backlight,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200610 &power_supply,
611};
612
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200613#ifdef CONFIG_MACH_TREO680
614static struct platform_device *treo680_devices[] __initdata = {
615 &treo680_leds,
616};
617#endif /* CONFIG_MACH_TREO680 */
618
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200619#ifdef CONFIG_MACH_CENTRO
620static struct platform_device *centro_devices[] __initdata = {
621 &centro_leds,
622};
623#endif /* CONFIG_MACH_CENTRO */
624
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200625/* setup udc GPIOs initial state */
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200626static void __init treo_udc_init(void)
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200627{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200628 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) {
629 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1);
630 gpio_free(GPIO_NR_TREO_USB_PULLUP);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200631 }
632}
633
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200634static void __init treo_lcd_power_init(void)
Tomáš Čech28d7a942009-09-03 16:55:47 +0200635{
636 int ret;
637
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200638 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
Tomáš Čech28d7a942009-09-03 16:55:47 +0200639 if (ret) {
640 pr_err("Treo680: LCD power GPIO request failed!\n");
641 return;
642 }
643
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200644 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200645 if (ret) {
646 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200647 gpio_free(GPIO_NR_TREO_LCD_POWER);
Tomáš Čech28d7a942009-09-03 16:55:47 +0200648 return;
649 }
650
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200651 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
Tomáš Čech28d7a942009-09-03 16:55:47 +0200652}
653
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200654static void __init treo_init(void)
655{
Russell Kingcc155c62009-11-09 13:34:08 +0800656 pxa_set_ffuart_info(NULL);
657 pxa_set_btuart_info(NULL);
658 pxa_set_stuart_info(NULL);
659
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200660 treo_pm_init();
661 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
662 treo_lcd_power_init();
663 set_pxa_fb_info(&treo_lcd_screen);
664 treo_udc_init();
665 pxa_set_udc_info(&treo_udc_info);
666 pxa_set_ac97_info(&treo_ac97_pdata);
667 pxa_set_ficp_info(&treo_ficp_info);
668
669 platform_add_devices(ARRAY_AND_SIZE(treo_devices));
670}
671
672#ifdef CONFIG_MACH_TREO680
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200673static void __init treo680_init(void)
674{
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200675 treo_init();
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200676 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200677 pxa_set_mci_info(&treo680_mci_platform_data);
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200678 pxa_set_keypad_info(&treo680_keypad_platform_data);
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200679 pxa_set_ohci_info(&treo680_ohci_info);
680
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200681 platform_add_devices(ARRAY_AND_SIZE(treo680_devices));
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200682}
683
684MACHINE_START(TREO680, "Palm Treo 680")
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200685 .phys_io = TREO_PHYS_IO_START,
686 .io_pg_offst = io_p2v(0x40000000),
687 .boot_params = 0xa0000100,
688 .map_io = pxa_map_io,
689 .init_irq = pxa27x_init_irq,
690 .timer = &pxa_timer,
691 .init_machine = treo680_init,
Tomas 'Sleep_Walker' Ceche6c3f4b2009-05-18 15:24:14 +0200692MACHINE_END
Tomáš Čechbb2ae8f2009-09-11 13:57:01 +0200693#endif /* CONFIG_MACH_TREO680 */
Tomáš Čechd0a92fd2009-09-11 13:57:02 +0200694
695#ifdef CONFIG_MACH_CENTRO
696static void __init centro_init(void)
697{
698 treo_init();
699 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
700 pxa_set_mci_info(&centro_mci_platform_data);
701
702 pxa_set_keypad_info(&centro_keypad_platform_data);
703
704 platform_add_devices(ARRAY_AND_SIZE(centro_devices));
705}
706
707MACHINE_START(CENTRO, "Palm Centro 685")
708 .phys_io = TREO_PHYS_IO_START,
709 .io_pg_offst = io_p2v(0x40000000),
710 .boot_params = 0xa0000100,
711 .map_io = pxa_map_io,
712 .init_irq = pxa27x_init_irq,
713 .timer = &pxa_timer,
714 .init_machine = centro_init,
715MACHINE_END
716#endif /* CONFIG_MACH_CENTRO */