1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <linux/platform_device.h>
20#include <linux/delay.h>
21#include <linux/irq.h>
22#include <linux/gpio_keys.h>
23#include <linux/input.h>
24#include <linux/pda_power.h>
25#include <linux/pwm_backlight.h>
26#include <linux/gpio.h>
27#include <linux/wm97xx_batt.h>
28#include <linux/power_supply.h>
29#include <linux/usb/gpio_vbus.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/audio.h>
37#include <mach/palmt5.h>
38#include <mach/mmc.h>
39#include <mach/pxafb.h>
40#include <mach/irda.h>
41#include <mach/pxa27x_keypad.h>
42#include <mach/udc.h>
43#include <mach/palmasoc.h>
44
45#include "generic.h"
46#include "devices.h"
47
48
49
50
51static unsigned long palmt5_pin_config[] __initdata = {
52
53 GPIO32_MMC_CLK,
54 GPIO92_MMC_DAT_0,
55 GPIO109_MMC_DAT_1,
56 GPIO110_MMC_DAT_2,
57 GPIO111_MMC_DAT_3,
58 GPIO112_MMC_CMD,
59 GPIO14_GPIO,
60 GPIO114_GPIO,
61 GPIO115_GPIO,
62
63
64 GPIO28_AC97_BITCLK,
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
67 GPIO31_AC97_SYNC,
68 GPIO89_AC97_SYSCLK,
69 GPIO95_AC97_nRESET,
70
71
72 GPIO40_GPIO,
73 GPIO46_FICP_RXD,
74 GPIO47_FICP_TXD,
75
76
77 GPIO15_GPIO,
78 GPIO93_GPIO,
79
80
81 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
82 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
83 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
84 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
85 GPIO103_KP_MKOUT_0,
86 GPIO104_KP_MKOUT_1,
87 GPIO105_KP_MKOUT_2,
88
89
90 GPIO58_LCD_LDD_0,
91 GPIO59_LCD_LDD_1,
92 GPIO60_LCD_LDD_2,
93 GPIO61_LCD_LDD_3,
94 GPIO62_LCD_LDD_4,
95 GPIO63_LCD_LDD_5,
96 GPIO64_LCD_LDD_6,
97 GPIO65_LCD_LDD_7,
98 GPIO66_LCD_LDD_8,
99 GPIO67_LCD_LDD_9,
100 GPIO68_LCD_LDD_10,
101 GPIO69_LCD_LDD_11,
102 GPIO70_LCD_LDD_12,
103 GPIO71_LCD_LDD_13,
104 GPIO72_LCD_LDD_14,
105 GPIO73_LCD_LDD_15,
106 GPIO74_LCD_FCLK,
107 GPIO75_LCD_LCLK,
108 GPIO76_LCD_PCLK,
109 GPIO77_LCD_BIAS,
110
111
112 GPIO16_PWM0_OUT,
113
114
115 GPIO34_FFUART_RXD,
116 GPIO39_FFUART_TXD,
117
118
119 GPIO10_GPIO,
120 GPIO90_GPIO,
121 GPIO107_GPIO,
122};
123
124
125
126
127static struct pxamci_platform_data palmt5_mci_platform_data = {
128 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
129 .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N,
130 .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY,
131 .gpio_power = GPIO_NR_PALMT5_SD_POWER,
132 .detect_delay = 20,
133};
134
135
136
137
138static unsigned int palmt5_matrix_keys[] = {
139 KEY(0, 0, KEY_POWER),
140 KEY(0, 1, KEY_F1),
141 KEY(0, 2, KEY_ENTER),
142
143 KEY(1, 0, KEY_F2),
144 KEY(1, 1, KEY_F3),
145 KEY(1, 2, KEY_F4),
146
147 KEY(2, 0, KEY_UP),
148 KEY(2, 2, KEY_DOWN),
149
150 KEY(3, 0, KEY_RIGHT),
151 KEY(3, 2, KEY_LEFT),
152};
153
154static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
155 .matrix_key_rows = 4,
156 .matrix_key_cols = 3,
157 .matrix_key_map = palmt5_matrix_keys,
158 .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
159
160 .debounce_interval = 30,
161};
162
163
164
165
166static struct gpio_keys_button palmt5_pxa_buttons[] = {
167 {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
168};
169
170static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
171 .buttons = palmt5_pxa_buttons,
172 .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
173};
174
175static struct platform_device palmt5_pxa_keys = {
176 .name = "gpio-keys",
177 .id = -1,
178 .dev = {
179 .platform_data = &palmt5_pxa_keys_data,
180 },
181};
182
183
184
185
186static int palmt5_backlight_init(struct device *dev)
187{
188 int ret;
189
190 ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
191 if (ret)
192 goto err;
193 ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
194 if (ret)
195 goto err2;
196 ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
197 if (ret)
198 goto err2;
199 ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
200 if (ret)
201 goto err3;
202
203 return 0;
204err3:
205 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
206err2:
207 gpio_free(GPIO_NR_PALMT5_BL_POWER);
208err:
209 return ret;
210}
211
212static int palmt5_backlight_notify(int brightness)
213{
214 gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
215 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
216 return brightness;
217}
218
219static void palmt5_backlight_exit(struct device *dev)
220{
221 gpio_free(GPIO_NR_PALMT5_BL_POWER);
222 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
223}
224
225static struct platform_pwm_backlight_data palmt5_backlight_data = {
226 .pwm_id = 0,
227 .max_brightness = PALMT5_MAX_INTENSITY,
228 .dft_brightness = PALMT5_MAX_INTENSITY,
229 .pwm_period_ns = PALMT5_PERIOD_NS,
230 .init = palmt5_backlight_init,
231 .notify = palmt5_backlight_notify,
232 .exit = palmt5_backlight_exit,
233};
234
235static struct platform_device palmt5_backlight = {
236 .name = "pwm-backlight",
237 .dev = {
238 .parent = &pxa27x_device_pwm0.dev,
239 .platform_data = &palmt5_backlight_data,
240 },
241};
242
243
244
245
246static struct pxaficp_platform_data palmt5_ficp_platform_data = {
247 .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE,
248 .transceiver_cap = IR_SIRMODE | IR_OFF,
249};
250
251
252
253
254static struct gpio_vbus_mach_info palmt5_udc_info = {
255 .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
256 .gpio_vbus_inverted = 1,
257 .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
258};
259
260static struct platform_device palmt5_gpio_vbus = {
261 .name = "gpio-vbus",
262 .id = -1,
263 .dev = {
264 .platform_data = &palmt5_udc_info,
265 },
266};
267
268
269
270
271static int power_supply_init(struct device *dev)
272{
273 int ret;
274
275 ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
276 if (ret)
277 goto err1;
278 ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
279 if (ret)
280 goto err2;
281
282 return 0;
283err2:
284 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
285err1:
286 return ret;
287}
288
289static int palmt5_is_ac_online(void)
290{
291 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
292}
293
294static void power_supply_exit(struct device *dev)
295{
296 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
297}
298
299static char *palmt5_supplicants[] = {
300 "main-battery",
301};
302
303static struct pda_power_pdata power_supply_info = {
304 .init = power_supply_init,
305 .is_ac_online = palmt5_is_ac_online,
306 .exit = power_supply_exit,
307 .supplied_to = palmt5_supplicants,
308 .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
309};
310
311static struct platform_device power_supply = {
312 .name = "pda-power",
313 .id = -1,
314 .dev = {
315 .platform_data = &power_supply_info,
316 },
317};
318
319
320
321
322static struct wm97xx_batt_info wm97xx_batt_pdata = {
323 .batt_aux = WM97XX_AUX_ID3,
324 .temp_aux = WM97XX_AUX_ID2,
325 .charge_gpio = -1,
326 .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
327 .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
328 .batt_mult = 1000,
329 .batt_div = 414,
330 .temp_mult = 1,
331 .temp_div = 1,
332 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
333 .batt_name = "main-batt",
334};
335
336
337
338
339static struct palm27x_asoc_info palmt5_asoc_pdata = {
340 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
341};
342
343static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
344 .reset_gpio = 95,
345};
346
347static struct platform_device palmt5_asoc = {
348 .name = "palm27x-asoc",
349 .id = -1,
350 .dev = {
351 .platform_data = &palmt5_asoc_pdata,
352 },
353};
354
355
356
357
358static struct pxafb_mode_info palmt5_lcd_modes[] = {
359{
360 .pixclock = 57692,
361 .xres = 320,
362 .yres = 480,
363 .bpp = 16,
364
365 .left_margin = 32,
366 .right_margin = 1,
367 .upper_margin = 7,
368 .lower_margin = 1,
369
370 .hsync_len = 4,
371 .vsync_len = 1,
372},
373};
374
375static struct pxafb_mach_info palmt5_lcd_screen = {
376 .modes = palmt5_lcd_modes,
377 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
378 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
379};
380
381
382
383
384static void __init palmt5_pm_init(void)
385{
386 static u32 resume[] = {
387 0xe3a00101,
388 0xe380060f,
389 0xe590f008,
390 };
391
392
393 memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
394}
395
396
397
398
399static struct platform_device *devices[] __initdata = {
400#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
401 &palmt5_pxa_keys,
402#endif
403 &palmt5_backlight,
404 &power_supply,
405 &palmt5_asoc,
406 &palmt5_gpio_vbus,
407};
408
409
410static void __init palmt5_udc_init(void)
411{
412 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
413 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
414 gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
415 }
416}
417
418static void __init palmt5_init(void)
419{
420 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
421
422 palmt5_pm_init();
423 set_pxa_fb_info(&palmt5_lcd_screen);
424 pxa_set_mci_info(&palmt5_mci_platform_data);
425 palmt5_udc_init();
426 pxa_set_ac97_info(&palmt5_ac97_pdata);
427 pxa_set_ficp_info(&palmt5_ficp_platform_data);
428 pxa_set_keypad_info(&palmt5_keypad_platform_data);
429 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
430
431 platform_add_devices(devices, ARRAY_SIZE(devices));
432}
433
434MACHINE_START(PALMT5, "Palm Tungsten|T5")
435 .phys_io = PALMT5_PHYS_IO_START,
436 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
437 .boot_params = 0xa0000100,
438 .map_io = pxa_map_io,
439 .init_irq = pxa27x_init_irq,
440 .timer = &pxa_timer,
441 .init_machine = palmt5_init
442MACHINE_END
443