blob: 4a9ca718962ff9c52f798bcb8d5346af758d92ac [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 Vasut8768dc92009-04-23 11:12:37 +020030#include <linux/usb/gpio_vbus.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010031
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
Eric Miao51c62982009-01-02 23:17:22 +080036#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/audio.h>
38#include <mach/palmtx.h>
39#include <mach/mmc.h>
40#include <mach/pxafb.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/irda.h>
42#include <mach/pxa27x_keypad.h>
43#include <mach/udc.h>
Marek Vasute91fb912009-04-17 11:37:35 +020044#include <mach/palmasoc.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010045
46#include "generic.h"
47#include "devices.h"
48
49/******************************************************************************
50 * Pin configuration
51 ******************************************************************************/
52static unsigned long palmtx_pin_config[] __initdata = {
53 /* MMC */
54 GPIO32_MMC_CLK,
55 GPIO92_MMC_DAT_0,
56 GPIO109_MMC_DAT_1,
57 GPIO110_MMC_DAT_2,
58 GPIO111_MMC_DAT_3,
59 GPIO112_MMC_CMD,
Marek Vasuta730b322008-11-20 17:34:57 +010060 GPIO14_GPIO, /* SD detect */
61 GPIO114_GPIO, /* SD power */
62 GPIO115_GPIO, /* SD r/o switch */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010063
64 /* AC97 */
65 GPIO28_AC97_BITCLK,
66 GPIO29_AC97_SDATA_IN_0,
67 GPIO30_AC97_SDATA_OUT,
68 GPIO31_AC97_SYNC,
Marek Vasut6ec04f42009-05-22 01:39:10 +020069 GPIO89_AC97_SYSCLK,
Marek Vasutefb12cd2009-04-12 16:37:23 +020070 GPIO95_AC97_nRESET,
Marek Vašutb5e4ad52008-07-07 17:25:46 +010071
72 /* IrDA */
Marek Vasuta730b322008-11-20 17:34:57 +010073 GPIO40_GPIO, /* ir disable */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010074 GPIO46_FICP_RXD,
75 GPIO47_FICP_TXD,
76
77 /* PWM */
78 GPIO16_PWM0_OUT,
79
80 /* USB */
Marek Vasuta730b322008-11-20 17:34:57 +010081 GPIO13_GPIO, /* usb detect */
Marek Vasutefb12cd2009-04-12 16:37:23 +020082 GPIO93_GPIO, /* usb power */
Marek Vašut35978402008-07-07 17:28:59 +010083
84 /* PCMCIA */
85 GPIO48_nPOE,
86 GPIO49_nPWE,
87 GPIO50_nPIOR,
88 GPIO51_nPIOW,
89 GPIO85_nPCE_1,
90 GPIO54_nPCE_2,
91 GPIO79_PSKTSEL,
92 GPIO55_nPREG,
93 GPIO56_nPWAIT,
94 GPIO57_nIOIS16,
Marek Vasuta730b322008-11-20 17:34:57 +010095 GPIO94_GPIO, /* wifi power 1 */
96 GPIO108_GPIO, /* wifi power 2 */
97 GPIO116_GPIO, /* wifi ready */
98
99 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +0100100 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
101 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
102 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
103 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
Marek Vasuta730b322008-11-20 17:34:57 +0100104 GPIO103_KP_MKOUT_0,
105 GPIO104_KP_MKOUT_1,
106 GPIO105_KP_MKOUT_2,
107
108 /* LCD */
109 GPIO58_LCD_LDD_0,
110 GPIO59_LCD_LDD_1,
111 GPIO60_LCD_LDD_2,
112 GPIO61_LCD_LDD_3,
113 GPIO62_LCD_LDD_4,
114 GPIO63_LCD_LDD_5,
115 GPIO64_LCD_LDD_6,
116 GPIO65_LCD_LDD_7,
117 GPIO66_LCD_LDD_8,
118 GPIO67_LCD_LDD_9,
119 GPIO68_LCD_LDD_10,
120 GPIO69_LCD_LDD_11,
121 GPIO70_LCD_LDD_12,
122 GPIO71_LCD_LDD_13,
123 GPIO72_LCD_LDD_14,
124 GPIO73_LCD_LDD_15,
125 GPIO74_LCD_FCLK,
126 GPIO75_LCD_LCLK,
127 GPIO76_LCD_PCLK,
128 GPIO77_LCD_BIAS,
129
Marek Vasutecf763c2009-07-16 19:37:29 +0200130 /* FFUART */
131 GPIO34_FFUART_RXD,
132 GPIO39_FFUART_TXD,
133
Marek Vasuta730b322008-11-20 17:34:57 +0100134 /* MISC. */
135 GPIO10_GPIO, /* hotsync button */
136 GPIO12_GPIO, /* power detect */
137 GPIO107_GPIO, /* earphone detect */
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100138};
139
140/******************************************************************************
141 * SD/MMC card controller
142 ******************************************************************************/
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100143static struct pxamci_platform_data palmtx_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200144 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
145 .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
146 .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
147 .gpio_power = GPIO_NR_PALMTX_SD_POWER,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100148};
149
150/******************************************************************************
151 * GPIO keyboard
152 ******************************************************************************/
153static unsigned int palmtx_matrix_keys[] = {
154 KEY(0, 0, KEY_POWER),
155 KEY(0, 1, KEY_F1),
156 KEY(0, 2, KEY_ENTER),
157
158 KEY(1, 0, KEY_F2),
159 KEY(1, 1, KEY_F3),
160 KEY(1, 2, KEY_F4),
161
162 KEY(2, 0, KEY_UP),
163 KEY(2, 2, KEY_DOWN),
164
165 KEY(3, 0, KEY_RIGHT),
166 KEY(3, 2, KEY_LEFT),
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100167};
168
169static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
170 .matrix_key_rows = 4,
171 .matrix_key_cols = 3,
172 .matrix_key_map = palmtx_matrix_keys,
173 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
174
175 .debounce_interval = 30,
176};
177
178/******************************************************************************
179 * GPIO keys
180 ******************************************************************************/
181static struct gpio_keys_button palmtx_pxa_buttons[] = {
182 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
183};
184
185static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
186 .buttons = palmtx_pxa_buttons,
187 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
188};
189
190static struct platform_device palmtx_pxa_keys = {
191 .name = "gpio-keys",
192 .id = -1,
193 .dev = {
194 .platform_data = &palmtx_pxa_keys_data,
195 },
196};
197
198/******************************************************************************
199 * Backlight
200 ******************************************************************************/
201static int palmtx_backlight_init(struct device *dev)
202{
203 int ret;
204
205 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
206 if (ret)
207 goto err;
Marek Vasuta730b322008-11-20 17:34:57 +0100208 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
209 if (ret)
210 goto err2;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100211 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
212 if (ret)
213 goto err2;
Marek Vasuta730b322008-11-20 17:34:57 +0100214 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
215 if (ret)
216 goto err3;
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100217
218 return 0;
Marek Vasuta730b322008-11-20 17:34:57 +0100219err3:
220 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100221err2:
222 gpio_free(GPIO_NR_PALMTX_BL_POWER);
223err:
224 return ret;
225}
226
227static int palmtx_backlight_notify(int brightness)
228{
229 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
230 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
231 return brightness;
232}
233
234static void palmtx_backlight_exit(struct device *dev)
235{
236 gpio_free(GPIO_NR_PALMTX_BL_POWER);
237 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
238}
239
240static struct platform_pwm_backlight_data palmtx_backlight_data = {
241 .pwm_id = 0,
242 .max_brightness = PALMTX_MAX_INTENSITY,
243 .dft_brightness = PALMTX_MAX_INTENSITY,
244 .pwm_period_ns = PALMTX_PERIOD_NS,
245 .init = palmtx_backlight_init,
246 .notify = palmtx_backlight_notify,
247 .exit = palmtx_backlight_exit,
248};
249
250static struct platform_device palmtx_backlight = {
251 .name = "pwm-backlight",
252 .dev = {
253 .parent = &pxa27x_device_pwm0.dev,
254 .platform_data = &palmtx_backlight_data,
255 },
256};
257
258/******************************************************************************
259 * IrDA
260 ******************************************************************************/
Marek Vasuta730b322008-11-20 17:34:57 +0100261static int palmtx_irda_startup(struct device *dev)
262{
263 int err;
264 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
265 if (err)
266 goto err;
267 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
268 if (err)
269 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
270err:
271 return err;
272}
273
274static void palmtx_irda_shutdown(struct device *dev)
275{
276 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
277}
278
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100279static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
280{
281 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
282 pxa2xx_transceiver_mode(dev, mode);
283}
284
285static struct pxaficp_platform_data palmtx_ficp_platform_data = {
Marek Vasuta730b322008-11-20 17:34:57 +0100286 .startup = palmtx_irda_startup,
287 .shutdown = palmtx_irda_shutdown,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100288 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
289 .transceiver_mode = palmtx_irda_transceiver_mode,
290};
291
292/******************************************************************************
293 * UDC
294 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200295static struct gpio_vbus_mach_info palmtx_udc_info = {
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100296 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
297 .gpio_vbus_inverted = 1,
Marek Vasutefb12cd2009-04-12 16:37:23 +0200298 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200299};
300
301static struct platform_device palmtx_gpio_vbus = {
302 .name = "gpio-vbus",
303 .id = -1,
304 .dev = {
305 .platform_data = &palmtx_udc_info,
306 },
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100307};
308
309/******************************************************************************
Marek Vašutd4b19c42008-07-07 17:31:58 +0100310 * Power supply
311 ******************************************************************************/
312static int power_supply_init(struct device *dev)
313{
314 int ret;
315
316 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
317 if (ret)
Marek Vasuta730b322008-11-20 17:34:57 +0100318 goto err1;
319 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
Marek Vašutd4b19c42008-07-07 17:31:58 +0100320 if (ret)
Marek Vasuta730b322008-11-20 17:34:57 +0100321 goto err2;
Marek Vašutd4b19c42008-07-07 17:31:58 +0100322
323 return 0;
324
Marek Vasuta730b322008-11-20 17:34:57 +0100325err2:
Marek Vašutd4b19c42008-07-07 17:31:58 +0100326 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
Marek Vasuta730b322008-11-20 17:34:57 +0100327err1:
Marek Vašutd4b19c42008-07-07 17:31:58 +0100328 return ret;
329}
330
331static int palmtx_is_ac_online(void)
332{
333 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
334}
335
Marek Vašutd4b19c42008-07-07 17:31:58 +0100336static void power_supply_exit(struct device *dev)
337{
Marek Vašutd4b19c42008-07-07 17:31:58 +0100338 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
339}
340
341static char *palmtx_supplicants[] = {
342 "main-battery",
343};
344
345static struct pda_power_pdata power_supply_info = {
346 .init = power_supply_init,
347 .is_ac_online = palmtx_is_ac_online,
Marek Vašutd4b19c42008-07-07 17:31:58 +0100348 .exit = power_supply_exit,
349 .supplied_to = palmtx_supplicants,
350 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
351};
352
353static struct platform_device power_supply = {
354 .name = "pda-power",
355 .id = -1,
356 .dev = {
357 .platform_data = &power_supply_info,
358 },
359};
360
361/******************************************************************************
Marek Vašut4e9687d2008-09-11 19:37:32 +0100362 * WM97xx battery
363 ******************************************************************************/
364static struct wm97xx_batt_info wm97xx_batt_pdata = {
365 .batt_aux = WM97XX_AUX_ID3,
366 .temp_aux = WM97XX_AUX_ID2,
367 .charge_gpio = -1,
368 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
369 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
370 .batt_mult = 1000,
371 .batt_div = 414,
372 .temp_mult = 1,
373 .temp_div = 1,
374 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
375 .batt_name = "main-batt",
376};
377
378/******************************************************************************
Marek Vasute91fb912009-04-17 11:37:35 +0200379 * aSoC audio
380 ******************************************************************************/
381static struct palm27x_asoc_info palmtx_asoc_pdata = {
382 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
383};
384
385static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
386 .reset_gpio = 95,
387};
388
389static struct platform_device palmtx_asoc = {
390 .name = "palm27x-asoc",
391 .id = -1,
392 .dev = {
393 .platform_data = &palmtx_asoc_pdata,
394 },
395};
396
397/******************************************************************************
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100398 * Framebuffer
399 ******************************************************************************/
400static struct pxafb_mode_info palmtx_lcd_modes[] = {
401{
402 .pixclock = 57692,
403 .xres = 320,
404 .yres = 480,
405 .bpp = 16,
406
407 .left_margin = 32,
408 .right_margin = 1,
409 .upper_margin = 7,
410 .lower_margin = 1,
411
412 .hsync_len = 4,
413 .vsync_len = 1,
414},
415};
416
417static struct pxafb_mach_info palmtx_lcd_screen = {
418 .modes = palmtx_lcd_modes,
419 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
420 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
421};
422
423/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100424 * Power management - standby
425 ******************************************************************************/
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200426static void __init palmtx_pm_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100427{
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200428 static u32 resume[] = {
429 0xe3a00101, /* mov r0, #0x40000000 */
430 0xe380060f, /* orr r0, r0, #0x00f00000 */
431 0xe590f008, /* ldr pc, [r0, #0x08] */
432 };
Marek Vasut81854f82009-03-28 12:37:42 +0100433
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200434 /* copy the bootloader */
435 memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
Marek Vasut81854f82009-03-28 12:37:42 +0100436}
437
Marek Vasut81854f82009-03-28 12:37:42 +0100438/******************************************************************************
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100439 * Machine init
440 ******************************************************************************/
441static struct platform_device *devices[] __initdata = {
442#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
443 &palmtx_pxa_keys,
444#endif
445 &palmtx_backlight,
Marek Vašutd4b19c42008-07-07 17:31:58 +0100446 &power_supply,
Marek Vasute91fb912009-04-17 11:37:35 +0200447 &palmtx_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200448 &palmtx_gpio_vbus,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100449};
450
451static struct map_desc palmtx_io_desc[] __initdata = {
452{
453 .virtual = PALMTX_PCMCIA_VIRT,
454 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
455 .length = PALMTX_PCMCIA_SIZE,
456 .type = MT_DEVICE
457},
458};
459
460static void __init palmtx_map_io(void)
461{
462 pxa_map_io();
463 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
464}
465
Marek Vasuta730b322008-11-20 17:34:57 +0100466/* setup udc GPIOs initial state */
467static void __init palmtx_udc_init(void)
468{
Marek Vasutefb12cd2009-04-12 16:37:23 +0200469 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
470 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
471 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
Marek Vasuta730b322008-11-20 17:34:57 +0100472 }
473}
474
475
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100476static void __init palmtx_init(void)
477{
478 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
479
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200480 palmtx_pm_init();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100481 set_pxa_fb_info(&palmtx_lcd_screen);
482 pxa_set_mci_info(&palmtx_mci_platform_data);
Marek Vasuta730b322008-11-20 17:34:57 +0100483 palmtx_udc_init();
Marek Vasute91fb912009-04-17 11:37:35 +0200484 pxa_set_ac97_info(&palmtx_ac97_pdata);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100485 pxa_set_ficp_info(&palmtx_ficp_platform_data);
486 pxa_set_keypad_info(&palmtx_keypad_platform_data);
Marek Vašut4e9687d2008-09-11 19:37:32 +0100487 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100488
489 platform_add_devices(devices, ARRAY_SIZE(devices));
490}
491
492MACHINE_START(PALMTX, "Palm T|X")
493 .phys_io = PALMTX_PHYS_IO_START,
494 .io_pg_offst = io_p2v(0x40000000),
495 .boot_params = 0xa0000100,
496 .map_io = palmtx_map_io,
497 .init_irq = pxa27x_init_irq,
498 .timer = &pxa_timer,
499 .init_machine = palmtx_init
500MACHINE_END