blob: d2060a1d1d6820bcaf796e1a256a92989ce45365 [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 Vasut241cf472010-06-04 03:07:33 +020028#include <linux/wm97xx.h>
Marek Vašut4e9687d2008-09-11 19:37:32 +010029#include <linux/power_supply.h>
Marek Vasut8768dc92009-04-23 11:12:37 +020030#include <linux/usb/gpio_vbus.h>
Marek Vasut3eb37ff2009-07-18 16:51:41 +020031#include <linux/mtd/nand.h>
32#include <linux/mtd/partitions.h>
Marek Vasut91cf6a92009-07-27 02:07:41 +020033#include <linux/mtd/mtd.h>
34#include <linux/mtd/physmap.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010035
36#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39
Eric Miao51c62982009-01-02 23:17:22 +080040#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/audio.h>
42#include <mach/palmtx.h>
43#include <mach/mmc.h>
44#include <mach/pxafb.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010045#include <mach/irda.h>
Mark F. Brown4a2490e2010-09-03 18:28:06 -040046#include <plat/pxa27x_keypad.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010047#include <mach/udc.h>
Marek Vasute91fb912009-04-17 11:37:35 +020048#include <mach/palmasoc.h>
Marek Vasut31620e22010-07-13 08:16:45 +020049#include <mach/palm27x.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010050
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,
Marek Vasuta730b322008-11-20 17:34:57 +010065 GPIO14_GPIO, /* SD detect */
66 GPIO114_GPIO, /* SD power */
67 GPIO115_GPIO, /* SD r/o switch */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010068
69 /* AC97 */
70 GPIO28_AC97_BITCLK,
71 GPIO29_AC97_SDATA_IN_0,
72 GPIO30_AC97_SDATA_OUT,
73 GPIO31_AC97_SYNC,
Marek Vasut6ec04f42009-05-22 01:39:10 +020074 GPIO89_AC97_SYSCLK,
Marek Vasutefb12cd2009-04-12 16:37:23 +020075 GPIO95_AC97_nRESET,
Marek Vašutb5e4ad52008-07-07 17:25:46 +010076
77 /* IrDA */
Marek Vasuta730b322008-11-20 17:34:57 +010078 GPIO40_GPIO, /* ir disable */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010079 GPIO46_FICP_RXD,
80 GPIO47_FICP_TXD,
81
82 /* PWM */
83 GPIO16_PWM0_OUT,
84
85 /* USB */
Marek Vasuta730b322008-11-20 17:34:57 +010086 GPIO13_GPIO, /* usb detect */
Marek Vasutefb12cd2009-04-12 16:37:23 +020087 GPIO93_GPIO, /* usb power */
Marek Vašut35978402008-07-07 17:28:59 +010088
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,
Marek Vasuta730b322008-11-20 17:34:57 +0100100 GPIO94_GPIO, /* wifi power 1 */
101 GPIO108_GPIO, /* wifi power 2 */
102 GPIO116_GPIO, /* wifi ready */
103
104 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +0100105 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,
Marek Vasuta730b322008-11-20 17:34:57 +0100109 GPIO103_KP_MKOUT_0,
110 GPIO104_KP_MKOUT_1,
111 GPIO105_KP_MKOUT_2,
112
113 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800114 GPIOxx_LCD_TFT_16BPP,
Marek Vasuta730b322008-11-20 17:34:57 +0100115
Marek Vasutecf763c2009-07-16 19:37:29 +0200116 /* FFUART */
117 GPIO34_FFUART_RXD,
118 GPIO39_FFUART_TXD,
119
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200120 /* NAND */
121 GPIO15_nCS_1,
122 GPIO18_RDY,
123
Marek Vasuta730b322008-11-20 17:34:57 +0100124 /* MISC. */
125 GPIO10_GPIO, /* hotsync button */
126 GPIO12_GPIO, /* power detect */
127 GPIO107_GPIO, /* earphone detect */
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100128};
129
130/******************************************************************************
Marek Vasut91cf6a92009-07-27 02:07:41 +0200131 * NOR Flash
132 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200133#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Marek Vasut91cf6a92009-07-27 02:07:41 +0200134static 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
Marek Vasut31620e22010-07-13 08:16:45 +0200167static 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
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100174
175/******************************************************************************
176 * GPIO keyboard
177 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200178#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100179static 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),
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100193};
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
Marek Vasut31620e22010-07-13 08:16:45 +0200204static 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
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100212/******************************************************************************
213 * GPIO keys
214 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200215#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100216static 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
Marek Vasut31620e22010-07-13 08:16:45 +0200233static void __init palmtx_keys_init(void)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100234{
Marek Vasut31620e22010-07-13 08:16:45 +0200235 platform_device_register(&palmtx_pxa_keys);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100236}
Marek Vasut31620e22010-07-13 08:16:45 +0200237#else
238static inline void palmtx_keys_init(void) {}
239#endif
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100240
241/******************************************************************************
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200242 * NAND Flash
243 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200244#if defined(CONFIG_MTD_NAND_GPIO) || defined(CONFIG_MTD_NAND_GPIO_MODULE)
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200245static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
246 unsigned int ctrl)
247{
248 struct nand_chip *this = mtd->priv;
249 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
250
251 if (cmd == NAND_CMD_NONE)
252 return;
253
254 if (ctrl & NAND_CLE)
255 writeb(cmd, PALMTX_NAND_CLE_VIRT);
256 else if (ctrl & NAND_ALE)
257 writeb(cmd, PALMTX_NAND_ALE_VIRT);
258 else
259 writeb(cmd, nandaddr);
260}
261
262static struct mtd_partition palmtx_partition_info[] = {
263 [0] = {
264 .name = "palmtx-0",
265 .offset = 0,
266 .size = MTDPART_SIZ_FULL
267 },
268};
269
270static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
271
272struct platform_nand_data palmtx_nand_platdata = {
273 .chip = {
274 .nr_chips = 1,
275 .chip_offset = 0,
276 .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
277 .partitions = palmtx_partition_info,
278 .chip_delay = 20,
279 .part_probe_types = palmtx_part_probes,
280 },
281 .ctrl = {
282 .cmd_ctrl = palmtx_nand_cmd_ctl,
283 },
284};
285
286static struct resource palmtx_nand_resource[] = {
287 [0] = {
288 .start = PXA_CS1_PHYS,
289 .end = PXA_CS1_PHYS + SZ_1M - 1,
290 .flags = IORESOURCE_MEM,
291 },
292};
293
294static struct platform_device palmtx_nand = {
295 .name = "gen_nand",
296 .num_resources = ARRAY_SIZE(palmtx_nand_resource),
297 .resource = palmtx_nand_resource,
298 .id = -1,
299 .dev = {
300 .platform_data = &palmtx_nand_platdata,
301 }
302};
303
Marek Vasut31620e22010-07-13 08:16:45 +0200304static void __init palmtx_nand_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100305{
Marek Vasut31620e22010-07-13 08:16:45 +0200306 platform_device_register(&palmtx_nand);
Marek Vasut81854f82009-03-28 12:37:42 +0100307}
Marek Vasut31620e22010-07-13 08:16:45 +0200308#else
309static inline void palmtx_nand_init(void) {}
310#endif
Marek Vasut81854f82009-03-28 12:37:42 +0100311
Marek Vasut81854f82009-03-28 12:37:42 +0100312/******************************************************************************
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100313 * Machine init
314 ******************************************************************************/
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100315static struct map_desc palmtx_io_desc[] __initdata = {
316{
317 .virtual = PALMTX_PCMCIA_VIRT,
318 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
319 .length = PALMTX_PCMCIA_SIZE,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200320 .type = MT_DEVICE,
321}, {
322 .virtual = PALMTX_NAND_ALE_VIRT,
323 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
324 .length = SZ_1M,
325 .type = MT_DEVICE,
326}, {
327 .virtual = PALMTX_NAND_CLE_VIRT,
328 .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
329 .length = SZ_1M,
330 .type = MT_DEVICE,
331}
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100332};
333
334static void __init palmtx_map_io(void)
335{
336 pxa_map_io();
337 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
338}
339
340static void __init palmtx_init(void)
341{
342 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800343 pxa_set_ffuart_info(NULL);
344 pxa_set_btuart_info(NULL);
345 pxa_set_stuart_info(NULL);
346
Marek Vasut31620e22010-07-13 08:16:45 +0200347 palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY,
348 GPIO_NR_PALMTX_SD_POWER, 0);
349 palm27x_pm_init(PALMTX_STR_BASE);
350 palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
351 palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
352 GPIO_NR_PALMTX_USB_PULLUP, 1);
353 palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
354 palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
355 GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
356 palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
357 palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
358 palm27x_pmic_init();
359 palmtx_kpc_init();
360 palmtx_keys_init();
361 palmtx_nor_init();
362 palmtx_nand_init();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100363}
364
365MACHINE_START(PALMTX, "Palm T|X")
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100366 .boot_params = 0xa0000100,
367 .map_io = palmtx_map_io,
368 .init_irq = pxa27x_init_irq,
369 .timer = &pxa_timer,
370 .init_machine = palmtx_init
371MACHINE_END