Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
[pandora-kernel.git] / arch / arm / mach-pxa / palmld.c
1 /*
2  * Hardware definitions for Palm LifeDrive
3  *
4  * Author:     Marek Vasut <marek.vasut@gmail.com>
5  *
6  * Based on work of:
7  *              Alex Osborne <ato@meshy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  * (find more info at www.hackndev.com)
14  *
15  */
16
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/irq.h>
20 #include <linux/gpio_keys.h>
21 #include <linux/input.h>
22 #include <linux/pda_power.h>
23 #include <linux/pwm_backlight.h>
24 #include <linux/gpio.h>
25 #include <linux/wm97xx.h>
26 #include <linux/power_supply.h>
27 #include <linux/sysdev.h>
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/physmap.h>
31
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35
36 #include <mach/pxa27x.h>
37 #include <mach/audio.h>
38 #include <mach/palmld.h>
39 #include <mach/mmc.h>
40 #include <mach/pxafb.h>
41 #include <mach/irda.h>
42 #include <plat/pxa27x_keypad.h>
43 #include <mach/palmasoc.h>
44 #include <mach/palm27x.h>
45
46 #include "generic.h"
47 #include "devices.h"
48
49 /******************************************************************************
50  * Pin configuration
51  ******************************************************************************/
52 static unsigned long palmld_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,
60         GPIO14_GPIO,    /* SD detect */
61         GPIO114_GPIO,   /* SD power */
62         GPIO116_GPIO,   /* SD r/o switch */
63
64         /* AC97 */
65         GPIO28_AC97_BITCLK,
66         GPIO29_AC97_SDATA_IN_0,
67         GPIO30_AC97_SDATA_OUT,
68         GPIO31_AC97_SYNC,
69         GPIO89_AC97_SYSCLK,
70         GPIO95_AC97_nRESET,
71
72         /* IrDA */
73         GPIO108_GPIO,   /* ir disable */
74         GPIO46_FICP_RXD,
75         GPIO47_FICP_TXD,
76
77         /* MATRIX KEYPAD */
78         GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
79         GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
80         GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
81         GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
82         GPIO103_KP_MKOUT_0,
83         GPIO104_KP_MKOUT_1,
84         GPIO105_KP_MKOUT_2,
85
86         /* LCD */
87         GPIOxx_LCD_TFT_16BPP,
88
89         /* PWM */
90         GPIO16_PWM0_OUT,
91
92         /* GPIO KEYS */
93         GPIO10_GPIO,    /* hotsync button */
94         GPIO12_GPIO,    /* power switch */
95         GPIO15_GPIO,    /* lock switch */
96
97         /* LEDs */
98         GPIO52_GPIO,    /* green led */
99         GPIO94_GPIO,    /* orange led */
100
101         /* PCMCIA */
102         GPIO48_nPOE,
103         GPIO49_nPWE,
104         GPIO50_nPIOR,
105         GPIO51_nPIOW,
106         GPIO85_nPCE_1,
107         GPIO54_nPCE_2,
108         GPIO79_PSKTSEL,
109         GPIO55_nPREG,
110         GPIO56_nPWAIT,
111         GPIO57_nIOIS16,
112         GPIO36_GPIO,    /* wifi power */
113         GPIO38_GPIO,    /* wifi ready */
114         GPIO81_GPIO,    /* wifi reset */
115
116         /* FFUART */
117         GPIO34_FFUART_RXD,
118         GPIO39_FFUART_TXD,
119
120         /* HDD */
121         GPIO98_GPIO,    /* HDD reset */
122         GPIO115_GPIO,   /* HDD power */
123
124         /* MISC */
125         GPIO13_GPIO,    /* earphone detect */
126 };
127
128 /******************************************************************************
129  * NOR Flash
130  ******************************************************************************/
131 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
132 static struct mtd_partition palmld_partitions[] = {
133         {
134                 .name           = "Flash",
135                 .offset         = 0x00000000,
136                 .size           = MTDPART_SIZ_FULL,
137                 .mask_flags     = 0
138         }
139 };
140
141 static struct physmap_flash_data palmld_flash_data[] = {
142         {
143                 .width          = 2,                    /* bankwidth in bytes */
144                 .parts          = palmld_partitions,
145                 .nr_parts       = ARRAY_SIZE(palmld_partitions)
146         }
147 };
148
149 static struct resource palmld_flash_resource = {
150         .start  = PXA_CS0_PHYS,
151         .end    = PXA_CS0_PHYS + SZ_4M - 1,
152         .flags  = IORESOURCE_MEM,
153 };
154
155 static struct platform_device palmld_flash = {
156         .name           = "physmap-flash",
157         .id             = 0,
158         .resource       = &palmld_flash_resource,
159         .num_resources  = 1,
160         .dev            = {
161                 .platform_data = palmld_flash_data,
162         },
163 };
164
165 static void __init palmld_nor_init(void)
166 {
167         platform_device_register(&palmld_flash);
168 }
169 #else
170 static inline void palmld_nor_init(void) {}
171 #endif
172
173 /******************************************************************************
174  * GPIO keyboard
175  ******************************************************************************/
176 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
177 static unsigned int palmld_matrix_keys[] = {
178         KEY(0, 1, KEY_F2),
179         KEY(0, 2, KEY_UP),
180
181         KEY(1, 0, KEY_F3),
182         KEY(1, 1, KEY_F4),
183         KEY(1, 2, KEY_RIGHT),
184
185         KEY(2, 0, KEY_F1),
186         KEY(2, 1, KEY_F5),
187         KEY(2, 2, KEY_DOWN),
188
189         KEY(3, 0, KEY_F6),
190         KEY(3, 1, KEY_ENTER),
191         KEY(3, 2, KEY_LEFT),
192 };
193
194 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
195         .matrix_key_rows        = 4,
196         .matrix_key_cols        = 3,
197         .matrix_key_map         = palmld_matrix_keys,
198         .matrix_key_map_size    = ARRAY_SIZE(palmld_matrix_keys),
199
200         .debounce_interval      = 30,
201 };
202
203 static void __init palmld_kpc_init(void)
204 {
205         pxa_set_keypad_info(&palmld_keypad_platform_data);
206 }
207 #else
208 static inline void palmld_kpc_init(void) {}
209 #endif
210
211 /******************************************************************************
212  * GPIO keys
213  ******************************************************************************/
214 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
215 static struct gpio_keys_button palmld_pxa_buttons[] = {
216         {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
217         {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
218         {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
219 };
220
221 static struct gpio_keys_platform_data palmld_pxa_keys_data = {
222         .buttons        = palmld_pxa_buttons,
223         .nbuttons       = ARRAY_SIZE(palmld_pxa_buttons),
224 };
225
226 static struct platform_device palmld_pxa_keys = {
227         .name   = "gpio-keys",
228         .id     = -1,
229         .dev    = {
230                 .platform_data = &palmld_pxa_keys_data,
231         },
232 };
233
234 static void __init palmld_keys_init(void)
235 {
236         platform_device_register(&palmld_pxa_keys);
237 }
238 #else
239 static inline void palmld_keys_init(void) {}
240 #endif
241
242 /******************************************************************************
243  * LEDs
244  ******************************************************************************/
245 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
246 struct gpio_led gpio_leds[] = {
247 {
248         .name                   = "palmld:green:led",
249         .default_trigger        = "none",
250         .gpio                   = GPIO_NR_PALMLD_LED_GREEN,
251 }, {
252         .name                   = "palmld:amber:led",
253         .default_trigger        = "none",
254         .gpio                   = GPIO_NR_PALMLD_LED_AMBER,
255 },
256 };
257
258 static struct gpio_led_platform_data gpio_led_info = {
259         .leds           = gpio_leds,
260         .num_leds       = ARRAY_SIZE(gpio_leds),
261 };
262
263 static struct platform_device palmld_leds = {
264         .name   = "leds-gpio",
265         .id     = -1,
266         .dev    = {
267                 .platform_data  = &gpio_led_info,
268         }
269 };
270
271 static void __init palmld_leds_init(void)
272 {
273         platform_device_register(&palmld_leds);
274 }
275 #else
276 static inline void palmld_leds_init(void) {}
277 #endif
278
279 /******************************************************************************
280  * HDD
281  ******************************************************************************/
282 #if defined(CONFIG_PATA_PALMLD) || defined(CONFIG_PATA_PALMLD_MODULE)
283 static struct platform_device palmld_ide_device = {
284         .name   = "pata_palmld",
285         .id     = -1,
286 };
287
288 static void __init palmld_ide_init(void)
289 {
290         platform_device_register(&palmld_ide_device);
291 }
292 #else
293 static inline void palmld_ide_init(void) {}
294 #endif
295
296 /******************************************************************************
297  * Machine init
298  ******************************************************************************/
299 static struct map_desc palmld_io_desc[] __initdata = {
300 {
301         .virtual        = PALMLD_IDE_VIRT,
302         .pfn            = __phys_to_pfn(PALMLD_IDE_PHYS),
303         .length         = PALMLD_IDE_SIZE,
304         .type           = MT_DEVICE
305 },
306 {
307         .virtual        = PALMLD_USB_VIRT,
308         .pfn            = __phys_to_pfn(PALMLD_USB_PHYS),
309         .length         = PALMLD_USB_SIZE,
310         .type           = MT_DEVICE
311 },
312 };
313
314 static void __init palmld_map_io(void)
315 {
316         pxa_map_io();
317         iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
318 }
319
320 static void __init palmld_init(void)
321 {
322         pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
323         pxa_set_ffuart_info(NULL);
324         pxa_set_btuart_info(NULL);
325         pxa_set_stuart_info(NULL);
326
327         palm27x_mmc_init(GPIO_NR_PALMLD_SD_DETECT_N, GPIO_NR_PALMLD_SD_READONLY,
328                         GPIO_NR_PALMLD_SD_POWER, 0);
329         palm27x_pm_init(PALMLD_STR_BASE);
330         palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
331         palm27x_irda_init(GPIO_NR_PALMLD_IR_DISABLE);
332         palm27x_ac97_init(PALMLD_BAT_MIN_VOLTAGE, PALMLD_BAT_MAX_VOLTAGE,
333                         GPIO_NR_PALMLD_EARPHONE_DETECT, 95);
334         palm27x_pwm_init(GPIO_NR_PALMLD_BL_POWER, GPIO_NR_PALMLD_LCD_POWER);
335         palm27x_power_init(GPIO_NR_PALMLD_POWER_DETECT,
336                         GPIO_NR_PALMLD_USB_DETECT_N);
337         palm27x_pmic_init();
338         palmld_kpc_init();
339         palmld_keys_init();
340         palmld_nor_init();
341         palmld_leds_init();
342         palmld_ide_init();
343 }
344
345 MACHINE_START(PALMLD, "Palm LifeDrive")
346         .boot_params    = 0xa0000100,
347         .map_io         = palmld_map_io,
348         .init_irq       = pxa27x_init_irq,
349         .timer          = &pxa_timer,
350         .init_machine   = palmld_init
351 MACHINE_END