ARM: restart: prima2: use new restart hook
[linux-2.6-block.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>
241cf473 28#include <linux/wm97xx.h>
4e9687d9 29#include <linux/power_supply.h>
8768dc9b 30#include <linux/usb/gpio_vbus.h>
3eb37ff0
MV
31#include <linux/mtd/nand.h>
32#include <linux/mtd/partitions.h>
91cf6a97
MV
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/physmap.h>
b5e4ad57
MV
35
36#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39
51c62982 40#include <mach/pxa27x.h>
a09e64fb
RK
41#include <mach/audio.h>
42#include <mach/palmtx.h>
43#include <mach/mmc.h>
44#include <mach/pxafb.h>
a09e64fb 45#include <mach/irda.h>
4a2490ea 46#include <plat/pxa27x_keypad.h>
a09e64fb 47#include <mach/udc.h>
e91fb913 48#include <mach/palmasoc.h>
31620e21 49#include <mach/palm27x.h>
b5e4ad57
MV
50
51#include "generic.h"
52#include "devices.h"
53
54/******************************************************************************
55 * Pin configuration
56 ******************************************************************************/
57static unsigned long palmtx_pin_config[] __initdata = {
58 /* MMC */
59 GPIO32_MMC_CLK,
60 GPIO92_MMC_DAT_0,
61 GPIO109_MMC_DAT_1,
62 GPIO110_MMC_DAT_2,
63 GPIO111_MMC_DAT_3,
64 GPIO112_MMC_CMD,
a730b327
MV
65 GPIO14_GPIO, /* SD detect */
66 GPIO114_GPIO, /* SD power */
67 GPIO115_GPIO, /* SD r/o switch */
b5e4ad57
MV
68
69 /* AC97 */
70 GPIO28_AC97_BITCLK,
71 GPIO29_AC97_SDATA_IN_0,
72 GPIO30_AC97_SDATA_OUT,
73 GPIO31_AC97_SYNC,
6ec04f43 74 GPIO89_AC97_SYSCLK,
efb12cd2 75 GPIO95_AC97_nRESET,
b5e4ad57
MV
76
77 /* IrDA */
a730b327 78 GPIO40_GPIO, /* ir disable */
b5e4ad57
MV
79 GPIO46_FICP_RXD,
80 GPIO47_FICP_TXD,
81
82 /* PWM */
83 GPIO16_PWM0_OUT,
84
85 /* USB */
a730b327 86 GPIO13_GPIO, /* usb detect */
efb12cd2 87 GPIO93_GPIO, /* usb power */
35978408
MV
88
89 /* PCMCIA */
90 GPIO48_nPOE,
91 GPIO49_nPWE,
92 GPIO50_nPIOR,
93 GPIO51_nPIOW,
94 GPIO85_nPCE_1,
95 GPIO54_nPCE_2,
96 GPIO79_PSKTSEL,
97 GPIO55_nPREG,
98 GPIO56_nPWAIT,
99 GPIO57_nIOIS16,
a730b327
MV
100 GPIO94_GPIO, /* wifi power 1 */
101 GPIO108_GPIO, /* wifi power 2 */
102 GPIO116_GPIO, /* wifi ready */
103
104 /* MATRIX KEYPAD */
81854f82
MV
105 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
106 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
107 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
108 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
a730b327
MV
109 GPIO103_KP_MKOUT_0,
110 GPIO104_KP_MKOUT_1,
111 GPIO105_KP_MKOUT_2,
112
113 /* LCD */
bedbda97 114 GPIOxx_LCD_TFT_16BPP,
a730b327 115
ecf763c5
MV
116 /* FFUART */
117 GPIO34_FFUART_RXD,
118 GPIO39_FFUART_TXD,
119
3eb37ff0
MV
120 /* NAND */
121 GPIO15_nCS_1,
122 GPIO18_RDY,
123
a730b327
MV
124 /* MISC. */
125 GPIO10_GPIO, /* hotsync button */
126 GPIO12_GPIO, /* power detect */
127 GPIO107_GPIO, /* earphone detect */
b5e4ad57
MV
128};
129
91cf6a97
MV
130/******************************************************************************
131 * NOR Flash
132 ******************************************************************************/
31620e21 133#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
91cf6a97
MV
134static struct mtd_partition palmtx_partitions[] = {
135 {
136 .name = "Flash",
137 .offset = 0x00000000,
138 .size = MTDPART_SIZ_FULL,
139 .mask_flags = 0
140 }
141};
142
143static struct physmap_flash_data palmtx_flash_data[] = {
144 {
145 .width = 2, /* bankwidth in bytes */
146 .parts = palmtx_partitions,
147 .nr_parts = ARRAY_SIZE(palmtx_partitions)
148 }
149};
150
151static struct resource palmtx_flash_resource = {
152 .start = PXA_CS0_PHYS,
153 .end = PXA_CS0_PHYS + SZ_8M - 1,
154 .flags = IORESOURCE_MEM,
155};
156
157static struct platform_device palmtx_flash = {
158 .name = "physmap-flash",
159 .id = 0,
160 .resource = &palmtx_flash_resource,
161 .num_resources = 1,
162 .dev = {
163 .platform_data = palmtx_flash_data,
164 },
165};
166
31620e21
MV
167static void __init palmtx_nor_init(void)
168{
169 platform_device_register(&palmtx_flash);
170}
171#else
172static inline void palmtx_nor_init(void) {}
173#endif
b5e4ad57
MV
174
175/******************************************************************************
176 * GPIO keyboard
177 ******************************************************************************/
31620e21 178#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
b5e4ad57
MV
179static unsigned int palmtx_matrix_keys[] = {
180 KEY(0, 0, KEY_POWER),
181 KEY(0, 1, KEY_F1),
182 KEY(0, 2, KEY_ENTER),
183
184 KEY(1, 0, KEY_F2),
185 KEY(1, 1, KEY_F3),
186 KEY(1, 2, KEY_F4),
187
188 KEY(2, 0, KEY_UP),
189 KEY(2, 2, KEY_DOWN),
190
191 KEY(3, 0, KEY_RIGHT),
192 KEY(3, 2, KEY_LEFT),
b5e4ad57
MV
193};
194
195static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
196 .matrix_key_rows = 4,
197 .matrix_key_cols = 3,
198 .matrix_key_map = palmtx_matrix_keys,
199 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
200
201 .debounce_interval = 30,
202};
203
31620e21
MV
204static void __init palmtx_kpc_init(void)
205{
206 pxa_set_keypad_info(&palmtx_keypad_platform_data);
207}
208#else
209static inline void palmtx_kpc_init(void) {}
210#endif
211
b5e4ad57
MV
212/******************************************************************************
213 * GPIO keys
214 ******************************************************************************/
31620e21 215#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
b5e4ad57
MV
216static struct gpio_keys_button palmtx_pxa_buttons[] = {
217 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
218};
219
220static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
221 .buttons = palmtx_pxa_buttons,
222 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
223};
224
225static struct platform_device palmtx_pxa_keys = {
226 .name = "gpio-keys",
227 .id = -1,
228 .dev = {
229 .platform_data = &palmtx_pxa_keys_data,
230 },
231};
232
31620e21 233static void __init palmtx_keys_init(void)
d4b19c42 234{
31620e21 235 platform_device_register(&palmtx_pxa_keys);
d4b19c42 236}
31620e21
MV
237#else
238static inline void palmtx_keys_init(void) {}
239#endif
b5e4ad57 240
3eb37ff0
MV
241/******************************************************************************
242 * NAND Flash
243 ******************************************************************************/
9f1ee150
MV
244#if defined(CONFIG_MTD_NAND_PLATFORM) || \
245 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
3eb37ff0
MV
246static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
247 unsigned int ctrl)
248{
249 struct nand_chip *this = mtd->priv;
97b09da4 250 char __iomem *nandaddr = this->IO_ADDR_W;
3eb37ff0
MV
251
252 if (cmd == NAND_CMD_NONE)
253 return;
254
255 if (ctrl & NAND_CLE)
256 writeb(cmd, PALMTX_NAND_CLE_VIRT);
257 else if (ctrl & NAND_ALE)
258 writeb(cmd, PALMTX_NAND_ALE_VIRT);
259 else
260 writeb(cmd, nandaddr);
261}
262
263static struct mtd_partition palmtx_partition_info[] = {
264 [0] = {
265 .name = "palmtx-0",
266 .offset = 0,
267 .size = MTDPART_SIZ_FULL
268 },
269};
270
271static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
272
273struct platform_nand_data palmtx_nand_platdata = {
274 .chip = {
275 .nr_chips = 1,
276 .chip_offset = 0,
277 .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
278 .partitions = palmtx_partition_info,
279 .chip_delay = 20,
280 .part_probe_types = palmtx_part_probes,
281 },
282 .ctrl = {
283 .cmd_ctrl = palmtx_nand_cmd_ctl,
284 },
285};
286
287static struct resource palmtx_nand_resource[] = {
288 [0] = {
289 .start = PXA_CS1_PHYS,
290 .end = PXA_CS1_PHYS + SZ_1M - 1,
291 .flags = IORESOURCE_MEM,
292 },
293};
294
295static struct platform_device palmtx_nand = {
296 .name = "gen_nand",
297 .num_resources = ARRAY_SIZE(palmtx_nand_resource),
298 .resource = palmtx_nand_resource,
299 .id = -1,
300 .dev = {
301 .platform_data = &palmtx_nand_platdata,
302 }
303};
304
31620e21 305static void __init palmtx_nand_init(void)
81854f82 306{
31620e21 307 platform_device_register(&palmtx_nand);
81854f82 308}
31620e21
MV
309#else
310static inline void palmtx_nand_init(void) {}
311#endif
81854f82 312
b5e4ad57
MV
313/******************************************************************************
314 * Machine init
315 ******************************************************************************/
b5e4ad57
MV
316static struct map_desc palmtx_io_desc[] __initdata = {
317{
97b09da4 318 .virtual = (unsigned long)PALMTX_PCMCIA_VIRT,
b5e4ad57
MV
319 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
320 .length = PALMTX_PCMCIA_SIZE,
3eb37ff0
MV
321 .type = MT_DEVICE,
322}, {
97b09da4 323 .virtual = (unsigned long)PALMTX_NAND_ALE_VIRT,
3eb37ff0
MV
324 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
325 .length = SZ_1M,
326 .type = MT_DEVICE,
327}, {
97b09da4 328 .virtual = (unsigned long)PALMTX_NAND_CLE_VIRT,
3eb37ff0
MV
329 .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
330 .length = SZ_1M,
331 .type = MT_DEVICE,
332}
b5e4ad57
MV
333};
334
335static void __init palmtx_map_io(void)
336{
851982c1 337 pxa27x_map_io();
b5e4ad57
MV
338 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
339}
340
341static void __init palmtx_init(void)
342{
343 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
cc155c6f
RK
344 pxa_set_ffuart_info(NULL);
345 pxa_set_btuart_info(NULL);
346 pxa_set_stuart_info(NULL);
347
31620e21
MV
348 palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY,
349 GPIO_NR_PALMTX_SD_POWER, 0);
350 palm27x_pm_init(PALMTX_STR_BASE);
351 palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
352 palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
353 GPIO_NR_PALMTX_USB_PULLUP, 1);
354 palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
355 palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
356 GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
357 palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
358 palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
359 palm27x_pmic_init();
360 palmtx_kpc_init();
361 palmtx_keys_init();
362 palmtx_nor_init();
363 palmtx_nand_init();
b5e4ad57
MV
364}
365
366MACHINE_START(PALMTX, "Palm T|X")
7375aba6 367 .atag_offset = 0x100,
b5e4ad57
MV
368 .map_io = palmtx_map_io,
369 .init_irq = pxa27x_init_irq,
8a97ae2f 370 .handle_irq = pxa27x_handle_irq,
b5e4ad57
MV
371 .timer = &pxa_timer,
372 .init_machine = palmtx_init
373MACHINE_END