blob: 59d0c1cba5563940e8ba993300bb444743acc753 [file] [log] [blame]
Marek Vašutb5e4ad52008-07-07 17:25:46 +01001/*
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>
Marek Vašutd4b19c42008-07-07 17:31:58 +010025#include <linux/pda_power.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010026#include <linux/pwm_backlight.h>
27#include <linux/gpio.h>
Marek Vašut4e9687d2008-09-11 19:37:32 +010028#include <linux/wm97xx_batt.h>
29#include <linux/power_supply.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010030
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
Eric Miao51c62982009-01-02 23:17:22 +080035#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/audio.h>
37#include <mach/palmtx.h>
38#include <mach/mmc.h>
39#include <mach/pxafb.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010040#include <mach/irda.h>
41#include <mach/pxa27x_keypad.h>
42#include <mach/udc.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010043
44#include "generic.h"
45#include "devices.h"
46
47/******************************************************************************
48 * Pin configuration
49 ******************************************************************************/
50static unsigned long palmtx_pin_config[] __initdata = {
51 /* MMC */
52 GPIO32_MMC_CLK,
53 GPIO92_MMC_DAT_0,
54 GPIO109_MMC_DAT_1,
55 GPIO110_MMC_DAT_2,
56 GPIO111_MMC_DAT_3,
57 GPIO112_MMC_CMD,
Marek Vasuta730b322008-11-20 17:34:57 +010058 GPIO14_GPIO, /* SD detect */
59 GPIO114_GPIO, /* SD power */
60 GPIO115_GPIO, /* SD r/o switch */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010061
62 /* AC97 */
63 GPIO28_AC97_BITCLK,
64 GPIO29_AC97_SDATA_IN_0,
65 GPIO30_AC97_SDATA_OUT,
66 GPIO31_AC97_SYNC,
67
68 /* IrDA */
Marek Vasuta730b322008-11-20 17:34:57 +010069 GPIO40_GPIO, /* ir disable */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010070 GPIO46_FICP_RXD,
71 GPIO47_FICP_TXD,
72
73 /* PWM */
74 GPIO16_PWM0_OUT,
75
76 /* USB */
Marek Vasuta730b322008-11-20 17:34:57 +010077 GPIO13_GPIO, /* usb detect */
78 GPIO95_GPIO, /* usb power */
Marek Vašut35978402008-07-07 17:28:59 +010079
80 /* PCMCIA */
81 GPIO48_nPOE,
82 GPIO49_nPWE,
83 GPIO50_nPIOR,
84 GPIO51_nPIOW,
85 GPIO85_nPCE_1,
86 GPIO54_nPCE_2,
87 GPIO79_PSKTSEL,
88 GPIO55_nPREG,
89 GPIO56_nPWAIT,
90 GPIO57_nIOIS16,
Marek Vasuta730b322008-11-20 17:34:57 +010091 GPIO94_GPIO, /* wifi power 1 */
92 GPIO108_GPIO, /* wifi power 2 */
93 GPIO116_GPIO, /* wifi ready */
94
95 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +010096 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
97 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
98 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
99 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
Marek Vasuta730b322008-11-20 17:34:57 +0100100 GPIO103_KP_MKOUT_0,
101 GPIO104_KP_MKOUT_1,
102 GPIO105_KP_MKOUT_2,
103
104 /* LCD */
105 GPIO58_LCD_LDD_0,
106 GPIO59_LCD_LDD_1,
107 GPIO60_LCD_LDD_2,
108 GPIO61_LCD_LDD_3,
109 GPIO62_LCD_LDD_4,
110 GPIO63_LCD_LDD_5,
111 GPIO64_LCD_LDD_6,
112 GPIO65_LCD_LDD_7,
113 GPIO66_LCD_LDD_8,
114 GPIO67_LCD_LDD_9,
115 GPIO68_LCD_LDD_10,
116 GPIO69_LCD_LDD_11,
117 GPIO70_LCD_LDD_12,
118 GPIO71_LCD_LDD_13,
119 GPIO72_LCD_LDD_14,
120 GPIO73_LCD_LDD_15,
121 GPIO74_LCD_FCLK,
122 GPIO75_LCD_LCLK,
123 GPIO76_LCD_PCLK,
124 GPIO77_LCD_BIAS,
125
126 /* MISC. */
127 GPIO10_GPIO, /* hotsync button */
128 GPIO12_GPIO, /* power detect */
129 GPIO107_GPIO, /* earphone detect */
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100130};
131
132/******************************************************************************
133 * SD/MMC card controller
134 ******************************************************************************/
135static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
136 void *data)
137{
138 int err = 0;
139
140 /* Setup an interrupt for detecting card insert/remove events */
Marek Vasuta730b322008-11-20 17:34:57 +0100141 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
142 if (err)
143 goto err;
144 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
145 if (err)
146 goto err2;
147 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
148 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100149 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
150 "SD/MMC card detect", data);
151 if (err) {
152 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
153 __func__);
Marek Vasuta730b322008-11-20 17:34:57 +0100154 goto err2;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100155 }
156
157 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
158 if (err)
Marek Vasuta730b322008-11-20 17:34:57 +0100159 goto err3;
160 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
161 if (err)
162 goto err4;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100163
164 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
165 if (err)
Marek Vasuta730b322008-11-20 17:34:57 +0100166 goto err4;
167 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
168 if (err)
169 goto err5;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100170
171 printk(KERN_DEBUG "%s: irq registered\n", __func__);
172
173 return 0;
174
Marek Vasuta730b322008-11-20 17:34:57 +0100175err5:
176 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
177err4:
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100178 gpio_free(GPIO_NR_PALMTX_SD_POWER);
Marek Vasuta730b322008-11-20 17:34:57 +0100179err3:
180 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
181err2:
182 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
183err:
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100184 return err;
185}
186
187static void palmtx_mci_exit(struct device *dev, void *data)
188{
189 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
190 gpio_free(GPIO_NR_PALMTX_SD_POWER);
Marek Vasuta730b322008-11-20 17:34:57 +0100191 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
192 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100193}
194
195static void palmtx_mci_power(struct device *dev, unsigned int vdd)
196{
197 struct pxamci_platform_data *p_d = dev->platform_data;
198 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
199}
200
201static int palmtx_mci_get_ro(struct device *dev)
202{
203 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
204}
205
206static struct pxamci_platform_data palmtx_mci_platform_data = {
207 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
208 .setpower = palmtx_mci_power,
209 .get_ro = palmtx_mci_get_ro,
210 .init = palmtx_mci_init,
211 .exit = palmtx_mci_exit,
212};
213
214/******************************************************************************
215 * GPIO keyboard
216 ******************************************************************************/
217static unsigned int palmtx_matrix_keys[] = {
218 KEY(0, 0, KEY_POWER),
219 KEY(0, 1, KEY_F1),
220 KEY(0, 2, KEY_ENTER),
221
222 KEY(1, 0, KEY_F2),
223 KEY(1, 1, KEY_F3),
224 KEY(1, 2, KEY_F4),
225
226 KEY(2, 0, KEY_UP),
227 KEY(2, 2, KEY_DOWN),
228
229 KEY(3, 0, KEY_RIGHT),
230 KEY(3, 2, KEY_LEFT),
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100231};
232
233static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
234 .matrix_key_rows = 4,
235 .matrix_key_cols = 3,
236 .matrix_key_map = palmtx_matrix_keys,
237 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
238
239 .debounce_interval = 30,
240};
241
242/******************************************************************************
243 * GPIO keys
244 ******************************************************************************/
245static struct gpio_keys_button palmtx_pxa_buttons[] = {
246 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
247};
248
249static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
250 .buttons = palmtx_pxa_buttons,
251 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
252};
253
254static struct platform_device palmtx_pxa_keys = {
255 .name = "gpio-keys",
256 .id = -1,
257 .dev = {
258 .platform_data = &palmtx_pxa_keys_data,
259 },
260};
261
262/******************************************************************************
263 * Backlight
264 ******************************************************************************/
265static int palmtx_backlight_init(struct device *dev)
266{
267 int ret;
268
269 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
270 if (ret)
271 goto err;
Marek Vasuta730b322008-11-20 17:34:57 +0100272 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
273 if (ret)
274 goto err2;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100275 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
276 if (ret)
277 goto err2;
Marek Vasuta730b322008-11-20 17:34:57 +0100278 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
279 if (ret)
280 goto err3;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100281
282 return 0;
Marek Vasuta730b322008-11-20 17:34:57 +0100283err3:
284 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100285err2:
286 gpio_free(GPIO_NR_PALMTX_BL_POWER);
287err:
288 return ret;
289}
290
291static int palmtx_backlight_notify(int brightness)
292{
293 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
294 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
295 return brightness;
296}
297
298static void palmtx_backlight_exit(struct device *dev)
299{
300 gpio_free(GPIO_NR_PALMTX_BL_POWER);
301 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
302}
303
304static struct platform_pwm_backlight_data palmtx_backlight_data = {
305 .pwm_id = 0,
306 .max_brightness = PALMTX_MAX_INTENSITY,
307 .dft_brightness = PALMTX_MAX_INTENSITY,
308 .pwm_period_ns = PALMTX_PERIOD_NS,
309 .init = palmtx_backlight_init,
310 .notify = palmtx_backlight_notify,
311 .exit = palmtx_backlight_exit,
312};
313
314static struct platform_device palmtx_backlight = {
315 .name = "pwm-backlight",
316 .dev = {
317 .parent = &pxa27x_device_pwm0.dev,
318 .platform_data = &palmtx_backlight_data,
319 },
320};
321
322/******************************************************************************
323 * IrDA
324 ******************************************************************************/
Marek Vasuta730b322008-11-20 17:34:57 +0100325static int palmtx_irda_startup(struct device *dev)
326{
327 int err;
328 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
329 if (err)
330 goto err;
331 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
332 if (err)
333 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
334err:
335 return err;
336}
337
338static void palmtx_irda_shutdown(struct device *dev)
339{
340 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
341}
342
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100343static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
344{
345 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
346 pxa2xx_transceiver_mode(dev, mode);
347}
348
349static struct pxaficp_platform_data palmtx_ficp_platform_data = {
Marek Vasuta730b322008-11-20 17:34:57 +0100350 .startup = palmtx_irda_startup,
351 .shutdown = palmtx_irda_shutdown,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100352 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
353 .transceiver_mode = palmtx_irda_transceiver_mode,
354};
355
356/******************************************************************************
357 * UDC
358 ******************************************************************************/
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100359static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
360 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
361 .gpio_vbus_inverted = 1,
Marek Vasuta730b322008-11-20 17:34:57 +0100362 .gpio_pullup = GPIO_NR_PALMTX_USB_POWER,
363 .gpio_pullup_inverted = 0,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100364};
365
366/******************************************************************************
Marek Vašutd4b19c42008-07-07 17:31:58 +0100367 * Power supply
368 ******************************************************************************/
369static int power_supply_init(struct device *dev)
370{
371 int ret;
372
373 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
374 if (ret)
Marek Vasuta730b322008-11-20 17:34:57 +0100375 goto err1;
376 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
Marek Vašutd4b19c42008-07-07 17:31:58 +0100377 if (ret)
Marek Vasuta730b322008-11-20 17:34:57 +0100378 goto err2;
Marek Vašutd4b19c42008-07-07 17:31:58 +0100379
380 return 0;
381
Marek Vasuta730b322008-11-20 17:34:57 +0100382err2:
Marek Vašutd4b19c42008-07-07 17:31:58 +0100383 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
Marek Vasuta730b322008-11-20 17:34:57 +0100384err1:
Marek Vašutd4b19c42008-07-07 17:31:58 +0100385 return ret;
386}
387
388static int palmtx_is_ac_online(void)
389{
390 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
391}
392
Marek Vašutd4b19c42008-07-07 17:31:58 +0100393static void power_supply_exit(struct device *dev)
394{
Marek Vašutd4b19c42008-07-07 17:31:58 +0100395 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
396}
397
398static char *palmtx_supplicants[] = {
399 "main-battery",
400};
401
402static struct pda_power_pdata power_supply_info = {
403 .init = power_supply_init,
404 .is_ac_online = palmtx_is_ac_online,
Marek Vašutd4b19c42008-07-07 17:31:58 +0100405 .exit = power_supply_exit,
406 .supplied_to = palmtx_supplicants,
407 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
408};
409
410static struct platform_device power_supply = {
411 .name = "pda-power",
412 .id = -1,
413 .dev = {
414 .platform_data = &power_supply_info,
415 },
416};
417
418/******************************************************************************
Marek Vašut4e9687d2008-09-11 19:37:32 +0100419 * WM97xx battery
420 ******************************************************************************/
421static struct wm97xx_batt_info wm97xx_batt_pdata = {
422 .batt_aux = WM97XX_AUX_ID3,
423 .temp_aux = WM97XX_AUX_ID2,
424 .charge_gpio = -1,
425 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
426 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
427 .batt_mult = 1000,
428 .batt_div = 414,
429 .temp_mult = 1,
430 .temp_div = 1,
431 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
432 .batt_name = "main-batt",
433};
434
435/******************************************************************************
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100436 * Framebuffer
437 ******************************************************************************/
438static struct pxafb_mode_info palmtx_lcd_modes[] = {
439{
440 .pixclock = 57692,
441 .xres = 320,
442 .yres = 480,
443 .bpp = 16,
444
445 .left_margin = 32,
446 .right_margin = 1,
447 .upper_margin = 7,
448 .lower_margin = 1,
449
450 .hsync_len = 4,
451 .vsync_len = 1,
452},
453};
454
455static struct pxafb_mach_info palmtx_lcd_screen = {
456 .modes = palmtx_lcd_modes,
457 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
458 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
459};
460
461/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100462 * Power management - standby
463 ******************************************************************************/
464#ifdef CONFIG_PM
465static u32 *addr __initdata;
466static u32 resume[3] __initdata = {
467 0xe3a00101, /* mov r0, #0x40000000 */
468 0xe380060f, /* orr r0, r0, #0x00f00000 */
469 0xe590f008, /* ldr pc, [r0, #0x08] */
470};
471
472static int __init palmtx_pm_init(void)
473{
474 int i;
475
476 /* this is where the bootloader jumps */
477 addr = phys_to_virt(PALMTX_STR_BASE);
478
479 for (i = 0; i < 3; i++)
480 addr[i] = resume[i];
481
482 return 0;
483}
484
485device_initcall(palmtx_pm_init);
486#endif
487
488/******************************************************************************
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100489 * Machine init
490 ******************************************************************************/
491static struct platform_device *devices[] __initdata = {
492#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
493 &palmtx_pxa_keys,
494#endif
495 &palmtx_backlight,
Marek Vašutd4b19c42008-07-07 17:31:58 +0100496 &power_supply,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100497};
498
499static struct map_desc palmtx_io_desc[] __initdata = {
500{
501 .virtual = PALMTX_PCMCIA_VIRT,
502 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
503 .length = PALMTX_PCMCIA_SIZE,
504 .type = MT_DEVICE
505},
506};
507
508static void __init palmtx_map_io(void)
509{
510 pxa_map_io();
511 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
512}
513
Marek Vasuta730b322008-11-20 17:34:57 +0100514/* setup udc GPIOs initial state */
515static void __init palmtx_udc_init(void)
516{
517 if (!gpio_request(GPIO_NR_PALMTX_USB_POWER, "UDC Vbus")) {
518 gpio_direction_output(GPIO_NR_PALMTX_USB_POWER, 1);
519 gpio_free(GPIO_NR_PALMTX_USB_POWER);
520 }
521}
522
523
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100524static void __init palmtx_init(void)
525{
526 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
527
528 set_pxa_fb_info(&palmtx_lcd_screen);
529 pxa_set_mci_info(&palmtx_mci_platform_data);
Marek Vasuta730b322008-11-20 17:34:57 +0100530 palmtx_udc_init();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100531 pxa_set_udc_info(&palmtx_udc_info);
532 pxa_set_ac97_info(NULL);
533 pxa_set_ficp_info(&palmtx_ficp_platform_data);
534 pxa_set_keypad_info(&palmtx_keypad_platform_data);
Marek Vašut4e9687d2008-09-11 19:37:32 +0100535 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100536
537 platform_add_devices(devices, ARRAY_SIZE(devices));
538}
539
540MACHINE_START(PALMTX, "Palm T|X")
541 .phys_io = PALMTX_PHYS_IO_START,
542 .io_pg_offst = io_p2v(0x40000000),
543 .boot_params = 0xa0000100,
544 .map_io = palmtx_map_io,
545 .init_irq = pxa27x_init_irq,
546 .timer = &pxa_timer,
547 .init_machine = palmtx_init
548MACHINE_END