Merge branch 'topic/core-id-check' into for-linus
[deliverable/linux.git] / arch / arm / mach-pxa / palmtx.c
CommitLineData
b5e4ad57
MV
1/*
2 * Hardware definitions for PalmTX
3 *
4 * Author: Marek Vasut <marek.vasut@gmail.com>
5 *
6 * Based on work of:
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
10 * Michal Hrusecky
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 * (find more info at www.hackndev.com)
17 *
18 */
19
20#include <linux/platform_device.h>
21#include <linux/delay.h>
22#include <linux/irq.h>
23#include <linux/gpio_keys.h>
24#include <linux/input.h>
d4b19c42 25#include <linux/pda_power.h>
b5e4ad57
MV
26#include <linux/pwm_backlight.h>
27#include <linux/gpio.h>
4e9687d9
MV
28#include <linux/wm97xx_batt.h>
29#include <linux/power_supply.h>
b5e4ad57
MV
30
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
51c62982 35#include <mach/pxa27x.h>
a09e64fb
RK
36#include <mach/audio.h>
37#include <mach/palmtx.h>
38#include <mach/mmc.h>
39#include <mach/pxafb.h>
a09e64fb
RK
40#include <mach/irda.h>
41#include <mach/pxa27x_keypad.h>
42#include <mach/udc.h>
e91fb913 43#include <mach/palmasoc.h>
b5e4ad57
MV
44
45#include "generic.h"
46#include "devices.h"
47
48/******************************************************************************
49 * Pin configuration
50 ******************************************************************************/
51static unsigned long palmtx_pin_config[] __initdata = {
52 /* MMC */
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,
a730b327
MV
59 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO115_GPIO, /* SD r/o switch */
b5e4ad57
MV
62
63 /* AC97 */
64 GPIO28_AC97_BITCLK,
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
67 GPIO31_AC97_SYNC,
6ec04f43 68 GPIO89_AC97_SYSCLK,
efb12cd2 69 GPIO95_AC97_nRESET,
b5e4ad57
MV
70
71 /* IrDA */
a730b327 72 GPIO40_GPIO, /* ir disable */
b5e4ad57
MV
73 GPIO46_FICP_RXD,
74 GPIO47_FICP_TXD,
75
76 /* PWM */
77 GPIO16_PWM0_OUT,
78
79 /* USB */
a730b327 80 GPIO13_GPIO, /* usb detect */
efb12cd2 81 GPIO93_GPIO, /* usb power */
35978408
MV
82
83 /* PCMCIA */
84 GPIO48_nPOE,
85 GPIO49_nPWE,
86 GPIO50_nPIOR,
87 GPIO51_nPIOW,
88 GPIO85_nPCE_1,
89 GPIO54_nPCE_2,
90 GPIO79_PSKTSEL,
91 GPIO55_nPREG,
92 GPIO56_nPWAIT,
93 GPIO57_nIOIS16,
a730b327
MV
94 GPIO94_GPIO, /* wifi power 1 */
95 GPIO108_GPIO, /* wifi power 2 */
96 GPIO116_GPIO, /* wifi ready */
97
98 /* MATRIX KEYPAD */
81854f82
MV
99 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
100 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
101 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
102 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
a730b327
MV
103 GPIO103_KP_MKOUT_0,
104 GPIO104_KP_MKOUT_1,
105 GPIO105_KP_MKOUT_2,
106
107 /* LCD */
108 GPIO58_LCD_LDD_0,
109 GPIO59_LCD_LDD_1,
110 GPIO60_LCD_LDD_2,
111 GPIO61_LCD_LDD_3,
112 GPIO62_LCD_LDD_4,
113 GPIO63_LCD_LDD_5,
114 GPIO64_LCD_LDD_6,
115 GPIO65_LCD_LDD_7,
116 GPIO66_LCD_LDD_8,
117 GPIO67_LCD_LDD_9,
118 GPIO68_LCD_LDD_10,
119 GPIO69_LCD_LDD_11,
120 GPIO70_LCD_LDD_12,
121 GPIO71_LCD_LDD_13,
122 GPIO72_LCD_LDD_14,
123 GPIO73_LCD_LDD_15,
124 GPIO74_LCD_FCLK,
125 GPIO75_LCD_LCLK,
126 GPIO76_LCD_PCLK,
127 GPIO77_LCD_BIAS,
128
129 /* MISC. */
130 GPIO10_GPIO, /* hotsync button */
131 GPIO12_GPIO, /* power detect */
132 GPIO107_GPIO, /* earphone detect */
b5e4ad57
MV
133};
134
135/******************************************************************************
136 * SD/MMC card controller
137 ******************************************************************************/
138static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
139 void *data)
140{
141 int err = 0;
142
143 /* Setup an interrupt for detecting card insert/remove events */
a730b327
MV
144 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
145 if (err)
146 goto err;
147 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
148 if (err)
149 goto err2;
150 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
151 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
b5e4ad57
MV
152 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
153 "SD/MMC card detect", data);
154 if (err) {
155 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
156 __func__);
a730b327 157 goto err2;
b5e4ad57
MV
158 }
159
160 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
161 if (err)
a730b327
MV
162 goto err3;
163 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
164 if (err)
165 goto err4;
b5e4ad57
MV
166
167 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
168 if (err)
a730b327
MV
169 goto err4;
170 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
171 if (err)
172 goto err5;
b5e4ad57
MV
173
174 printk(KERN_DEBUG "%s: irq registered\n", __func__);
175
176 return 0;
177
a730b327
MV
178err5:
179 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
180err4:
b5e4ad57 181 gpio_free(GPIO_NR_PALMTX_SD_POWER);
a730b327
MV
182err3:
183 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
184err2:
185 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
186err:
b5e4ad57
MV
187 return err;
188}
189
190static void palmtx_mci_exit(struct device *dev, void *data)
191{
192 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
193 gpio_free(GPIO_NR_PALMTX_SD_POWER);
a730b327
MV
194 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
195 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
b5e4ad57
MV
196}
197
198static void palmtx_mci_power(struct device *dev, unsigned int vdd)
199{
200 struct pxamci_platform_data *p_d = dev->platform_data;
201 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
202}
203
204static int palmtx_mci_get_ro(struct device *dev)
205{
206 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
207}
208
209static struct pxamci_platform_data palmtx_mci_platform_data = {
210 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
211 .setpower = palmtx_mci_power,
212 .get_ro = palmtx_mci_get_ro,
213 .init = palmtx_mci_init,
214 .exit = palmtx_mci_exit,
215};
216
217/******************************************************************************
218 * GPIO keyboard
219 ******************************************************************************/
220static unsigned int palmtx_matrix_keys[] = {
221 KEY(0, 0, KEY_POWER),
222 KEY(0, 1, KEY_F1),
223 KEY(0, 2, KEY_ENTER),
224
225 KEY(1, 0, KEY_F2),
226 KEY(1, 1, KEY_F3),
227 KEY(1, 2, KEY_F4),
228
229 KEY(2, 0, KEY_UP),
230 KEY(2, 2, KEY_DOWN),
231
232 KEY(3, 0, KEY_RIGHT),
233 KEY(3, 2, KEY_LEFT),
b5e4ad57
MV
234};
235
236static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
237 .matrix_key_rows = 4,
238 .matrix_key_cols = 3,
239 .matrix_key_map = palmtx_matrix_keys,
240 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
241
242 .debounce_interval = 30,
243};
244
245/******************************************************************************
246 * GPIO keys
247 ******************************************************************************/
248static struct gpio_keys_button palmtx_pxa_buttons[] = {
249 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
250};
251
252static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
253 .buttons = palmtx_pxa_buttons,
254 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
255};
256
257static struct platform_device palmtx_pxa_keys = {
258 .name = "gpio-keys",
259 .id = -1,
260 .dev = {
261 .platform_data = &palmtx_pxa_keys_data,
262 },
263};
264
265/******************************************************************************
266 * Backlight
267 ******************************************************************************/
268static int palmtx_backlight_init(struct device *dev)
269{
270 int ret;
271
272 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
273 if (ret)
274 goto err;
a730b327
MV
275 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
276 if (ret)
277 goto err2;
b5e4ad57
MV
278 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
279 if (ret)
280 goto err2;
a730b327
MV
281 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
282 if (ret)
283 goto err3;
b5e4ad57
MV
284
285 return 0;
a730b327
MV
286err3:
287 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
b5e4ad57
MV
288err2:
289 gpio_free(GPIO_NR_PALMTX_BL_POWER);
290err:
291 return ret;
292}
293
294static int palmtx_backlight_notify(int brightness)
295{
296 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
297 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
298 return brightness;
299}
300
301static void palmtx_backlight_exit(struct device *dev)
302{
303 gpio_free(GPIO_NR_PALMTX_BL_POWER);
304 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
305}
306
307static struct platform_pwm_backlight_data palmtx_backlight_data = {
308 .pwm_id = 0,
309 .max_brightness = PALMTX_MAX_INTENSITY,
310 .dft_brightness = PALMTX_MAX_INTENSITY,
311 .pwm_period_ns = PALMTX_PERIOD_NS,
312 .init = palmtx_backlight_init,
313 .notify = palmtx_backlight_notify,
314 .exit = palmtx_backlight_exit,
315};
316
317static struct platform_device palmtx_backlight = {
318 .name = "pwm-backlight",
319 .dev = {
320 .parent = &pxa27x_device_pwm0.dev,
321 .platform_data = &palmtx_backlight_data,
322 },
323};
324
325/******************************************************************************
326 * IrDA
327 ******************************************************************************/
a730b327
MV
328static int palmtx_irda_startup(struct device *dev)
329{
330 int err;
331 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
332 if (err)
333 goto err;
334 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
335 if (err)
336 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
337err:
338 return err;
339}
340
341static void palmtx_irda_shutdown(struct device *dev)
342{
343 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
344}
345
b5e4ad57
MV
346static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
347{
348 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
349 pxa2xx_transceiver_mode(dev, mode);
350}
351
352static struct pxaficp_platform_data palmtx_ficp_platform_data = {
a730b327
MV
353 .startup = palmtx_irda_startup,
354 .shutdown = palmtx_irda_shutdown,
b5e4ad57
MV
355 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
356 .transceiver_mode = palmtx_irda_transceiver_mode,
357};
358
359/******************************************************************************
360 * UDC
361 ******************************************************************************/
b5e4ad57
MV
362static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
363 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
364 .gpio_vbus_inverted = 1,
efb12cd2 365 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
a730b327 366 .gpio_pullup_inverted = 0,
b5e4ad57
MV
367};
368
d4b19c42
MV
369/******************************************************************************
370 * Power supply
371 ******************************************************************************/
372static int power_supply_init(struct device *dev)
373{
374 int ret;
375
376 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
377 if (ret)
a730b327
MV
378 goto err1;
379 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
d4b19c42 380 if (ret)
a730b327 381 goto err2;
d4b19c42
MV
382
383 return 0;
384
a730b327 385err2:
d4b19c42 386 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
a730b327 387err1:
d4b19c42
MV
388 return ret;
389}
390
391static int palmtx_is_ac_online(void)
392{
393 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
394}
395
d4b19c42
MV
396static void power_supply_exit(struct device *dev)
397{
d4b19c42
MV
398 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
399}
400
401static char *palmtx_supplicants[] = {
402 "main-battery",
403};
404
405static struct pda_power_pdata power_supply_info = {
406 .init = power_supply_init,
407 .is_ac_online = palmtx_is_ac_online,
d4b19c42
MV
408 .exit = power_supply_exit,
409 .supplied_to = palmtx_supplicants,
410 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
411};
412
413static struct platform_device power_supply = {
414 .name = "pda-power",
415 .id = -1,
416 .dev = {
417 .platform_data = &power_supply_info,
418 },
419};
420
4e9687d9
MV
421/******************************************************************************
422 * WM97xx battery
423 ******************************************************************************/
424static struct wm97xx_batt_info wm97xx_batt_pdata = {
425 .batt_aux = WM97XX_AUX_ID3,
426 .temp_aux = WM97XX_AUX_ID2,
427 .charge_gpio = -1,
428 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
429 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
430 .batt_mult = 1000,
431 .batt_div = 414,
432 .temp_mult = 1,
433 .temp_div = 1,
434 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
435 .batt_name = "main-batt",
436};
437
e91fb913
MV
438/******************************************************************************
439 * aSoC audio
440 ******************************************************************************/
441static struct palm27x_asoc_info palmtx_asoc_pdata = {
442 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
443};
444
445static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
446 .reset_gpio = 95,
447};
448
449static struct platform_device palmtx_asoc = {
450 .name = "palm27x-asoc",
451 .id = -1,
452 .dev = {
453 .platform_data = &palmtx_asoc_pdata,
454 },
455};
456
b5e4ad57
MV
457/******************************************************************************
458 * Framebuffer
459 ******************************************************************************/
460static struct pxafb_mode_info palmtx_lcd_modes[] = {
461{
462 .pixclock = 57692,
463 .xres = 320,
464 .yres = 480,
465 .bpp = 16,
466
467 .left_margin = 32,
468 .right_margin = 1,
469 .upper_margin = 7,
470 .lower_margin = 1,
471
472 .hsync_len = 4,
473 .vsync_len = 1,
474},
475};
476
477static struct pxafb_mach_info palmtx_lcd_screen = {
478 .modes = palmtx_lcd_modes,
479 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
480 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
481};
482
81854f82
MV
483/******************************************************************************
484 * Power management - standby
485 ******************************************************************************/
486#ifdef CONFIG_PM
487static u32 *addr __initdata;
488static u32 resume[3] __initdata = {
489 0xe3a00101, /* mov r0, #0x40000000 */
490 0xe380060f, /* orr r0, r0, #0x00f00000 */
491 0xe590f008, /* ldr pc, [r0, #0x08] */
492};
493
494static int __init palmtx_pm_init(void)
495{
496 int i;
497
498 /* this is where the bootloader jumps */
499 addr = phys_to_virt(PALMTX_STR_BASE);
500
501 for (i = 0; i < 3; i++)
502 addr[i] = resume[i];
503
504 return 0;
505}
506
507device_initcall(palmtx_pm_init);
508#endif
509
b5e4ad57
MV
510/******************************************************************************
511 * Machine init
512 ******************************************************************************/
513static struct platform_device *devices[] __initdata = {
514#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
515 &palmtx_pxa_keys,
516#endif
517 &palmtx_backlight,
d4b19c42 518 &power_supply,
e91fb913 519 &palmtx_asoc,
b5e4ad57
MV
520};
521
522static struct map_desc palmtx_io_desc[] __initdata = {
523{
524 .virtual = PALMTX_PCMCIA_VIRT,
525 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
526 .length = PALMTX_PCMCIA_SIZE,
527 .type = MT_DEVICE
528},
529};
530
531static void __init palmtx_map_io(void)
532{
533 pxa_map_io();
534 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
535}
536
a730b327
MV
537/* setup udc GPIOs initial state */
538static void __init palmtx_udc_init(void)
539{
efb12cd2
MV
540 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
541 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
542 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
a730b327
MV
543 }
544}
545
546
b5e4ad57
MV
547static void __init palmtx_init(void)
548{
549 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
550
551 set_pxa_fb_info(&palmtx_lcd_screen);
552 pxa_set_mci_info(&palmtx_mci_platform_data);
a730b327 553 palmtx_udc_init();
e91fb913 554 pxa_set_ac97_info(&palmtx_ac97_pdata);
b5e4ad57 555 pxa_set_udc_info(&palmtx_udc_info);
b5e4ad57
MV
556 pxa_set_ficp_info(&palmtx_ficp_platform_data);
557 pxa_set_keypad_info(&palmtx_keypad_platform_data);
4e9687d9 558 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
b5e4ad57
MV
559
560 platform_add_devices(devices, ARRAY_SIZE(devices));
561}
562
563MACHINE_START(PALMTX, "Palm T|X")
564 .phys_io = PALMTX_PHYS_IO_START,
565 .io_pg_offst = io_p2v(0x40000000),
566 .boot_params = 0xa0000100,
567 .map_io = palmtx_map_io,
568 .init_irq = pxa27x_init_irq,
569 .timer = &pxa_timer,
570 .init_machine = palmtx_init
571MACHINE_END
This page took 0.09886 seconds and 5 git commands to generate.