blob: ef71bf2abb4761bea3591b618eee1f17b3d40141 [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>
Boris Brezillonc7921bb2018-09-07 00:38:46 +020031#include <linux/mtd/platnand.h>
Marek Vasut91cf6a92009-07-27 02:07:41 +020032#include <linux/mtd/mtd.h>
33#include <linux/mtd/physmap.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010034
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010039#include "pxa27x.h"
Russell Kinga09e64f2008-08-05 16:14:15 +010040#include <mach/audio.h>
41#include <mach/palmtx.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020042#include <linux/platform_data/mmc-pxamci.h>
43#include <linux/platform_data/video-pxafb.h>
44#include <linux/platform_data/irda-pxaficp.h>
45#include <linux/platform_data/keypad-pxa27x.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010046#include "udc.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020047#include <linux/platform_data/asoc-palm27x.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010048#include "palm27x.h"
Marek Vašutb5e4ad52008-07-07 17:25:46 +010049
50#include "generic.h"
51#include "devices.h"
52
53/******************************************************************************
54 * Pin configuration
55 ******************************************************************************/
56static unsigned long palmtx_pin_config[] __initdata = {
57 /* MMC */
58 GPIO32_MMC_CLK,
59 GPIO92_MMC_DAT_0,
60 GPIO109_MMC_DAT_1,
61 GPIO110_MMC_DAT_2,
62 GPIO111_MMC_DAT_3,
63 GPIO112_MMC_CMD,
Marek Vasuta730b322008-11-20 17:34:57 +010064 GPIO14_GPIO, /* SD detect */
65 GPIO114_GPIO, /* SD power */
66 GPIO115_GPIO, /* SD r/o switch */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010067
68 /* AC97 */
69 GPIO28_AC97_BITCLK,
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
72 GPIO31_AC97_SYNC,
Marek Vasut6ec04f42009-05-22 01:39:10 +020073 GPIO89_AC97_SYSCLK,
Marek Vasutefb12cd2009-04-12 16:37:23 +020074 GPIO95_AC97_nRESET,
Marek Vašutb5e4ad52008-07-07 17:25:46 +010075
76 /* IrDA */
Marek Vasuta730b322008-11-20 17:34:57 +010077 GPIO40_GPIO, /* ir disable */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010078 GPIO46_FICP_RXD,
79 GPIO47_FICP_TXD,
80
81 /* PWM */
82 GPIO16_PWM0_OUT,
83
84 /* USB */
Marek Vasuta730b322008-11-20 17:34:57 +010085 GPIO13_GPIO, /* usb detect */
Marek Vasutefb12cd2009-04-12 16:37:23 +020086 GPIO93_GPIO, /* usb power */
Marek Vašut35978402008-07-07 17:28:59 +010087
88 /* PCMCIA */
89 GPIO48_nPOE,
90 GPIO49_nPWE,
91 GPIO50_nPIOR,
92 GPIO51_nPIOW,
93 GPIO85_nPCE_1,
94 GPIO54_nPCE_2,
95 GPIO79_PSKTSEL,
96 GPIO55_nPREG,
97 GPIO56_nPWAIT,
98 GPIO57_nIOIS16,
Marek Vasuta730b322008-11-20 17:34:57 +010099 GPIO94_GPIO, /* wifi power 1 */
100 GPIO108_GPIO, /* wifi power 2 */
101 GPIO116_GPIO, /* wifi ready */
102
103 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +0100104 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
105 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
106 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
107 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
Marek Vasuta730b322008-11-20 17:34:57 +0100108 GPIO103_KP_MKOUT_0,
109 GPIO104_KP_MKOUT_1,
110 GPIO105_KP_MKOUT_2,
111
112 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800113 GPIOxx_LCD_TFT_16BPP,
Marek Vasuta730b322008-11-20 17:34:57 +0100114
Marek Vasutecf763c2009-07-16 19:37:29 +0200115 /* FFUART */
116 GPIO34_FFUART_RXD,
117 GPIO39_FFUART_TXD,
118
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200119 /* NAND */
120 GPIO15_nCS_1,
121 GPIO18_RDY,
122
Marek Vasuta730b322008-11-20 17:34:57 +0100123 /* MISC. */
124 GPIO10_GPIO, /* hotsync button */
125 GPIO12_GPIO, /* power detect */
126 GPIO107_GPIO, /* earphone detect */
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100127};
128
129/******************************************************************************
Marek Vasut91cf6a92009-07-27 02:07:41 +0200130 * NOR Flash
131 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200132#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Marek Vasut91cf6a92009-07-27 02:07:41 +0200133static struct mtd_partition palmtx_partitions[] = {
134 {
135 .name = "Flash",
136 .offset = 0x00000000,
137 .size = MTDPART_SIZ_FULL,
138 .mask_flags = 0
139 }
140};
141
142static struct physmap_flash_data palmtx_flash_data[] = {
143 {
144 .width = 2, /* bankwidth in bytes */
145 .parts = palmtx_partitions,
146 .nr_parts = ARRAY_SIZE(palmtx_partitions)
147 }
148};
149
150static struct resource palmtx_flash_resource = {
151 .start = PXA_CS0_PHYS,
152 .end = PXA_CS0_PHYS + SZ_8M - 1,
153 .flags = IORESOURCE_MEM,
154};
155
156static struct platform_device palmtx_flash = {
157 .name = "physmap-flash",
158 .id = 0,
159 .resource = &palmtx_flash_resource,
160 .num_resources = 1,
161 .dev = {
162 .platform_data = palmtx_flash_data,
163 },
164};
165
Marek Vasut31620e22010-07-13 08:16:45 +0200166static void __init palmtx_nor_init(void)
167{
168 platform_device_register(&palmtx_flash);
169}
170#else
171static inline void palmtx_nor_init(void) {}
172#endif
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100173
174/******************************************************************************
175 * GPIO keyboard
176 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200177#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Chao Xie0a085a92013-05-05 20:24:58 -0700178static const unsigned int palmtx_matrix_keys[] = {
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100179 KEY(0, 0, KEY_POWER),
180 KEY(0, 1, KEY_F1),
181 KEY(0, 2, KEY_ENTER),
182
183 KEY(1, 0, KEY_F2),
184 KEY(1, 1, KEY_F3),
185 KEY(1, 2, KEY_F4),
186
187 KEY(2, 0, KEY_UP),
188 KEY(2, 2, KEY_DOWN),
189
190 KEY(3, 0, KEY_RIGHT),
191 KEY(3, 2, KEY_LEFT),
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100192};
193
Chao Xie0a085a92013-05-05 20:24:58 -0700194static struct matrix_keymap_data palmtx_matrix_keymap_data = {
195 .keymap = palmtx_matrix_keys,
196 .keymap_size = ARRAY_SIZE(palmtx_matrix_keys),
197};
198
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100199static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
200 .matrix_key_rows = 4,
201 .matrix_key_cols = 3,
Chao Xie0a085a92013-05-05 20:24:58 -0700202 .matrix_keymap_data = &palmtx_matrix_keymap_data,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100203
204 .debounce_interval = 30,
205};
206
Marek Vasut31620e22010-07-13 08:16:45 +0200207static void __init palmtx_kpc_init(void)
208{
209 pxa_set_keypad_info(&palmtx_keypad_platform_data);
210}
211#else
212static inline void palmtx_kpc_init(void) {}
213#endif
214
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100215/******************************************************************************
216 * GPIO keys
217 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200218#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100219static struct gpio_keys_button palmtx_pxa_buttons[] = {
220 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
221};
222
223static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
224 .buttons = palmtx_pxa_buttons,
225 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
226};
227
228static struct platform_device palmtx_pxa_keys = {
229 .name = "gpio-keys",
230 .id = -1,
231 .dev = {
232 .platform_data = &palmtx_pxa_keys_data,
233 },
234};
235
Marek Vasut31620e22010-07-13 08:16:45 +0200236static void __init palmtx_keys_init(void)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100237{
Marek Vasut31620e22010-07-13 08:16:45 +0200238 platform_device_register(&palmtx_pxa_keys);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100239}
Marek Vasut31620e22010-07-13 08:16:45 +0200240#else
241static inline void palmtx_keys_init(void) {}
242#endif
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100243
244/******************************************************************************
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200245 * NAND Flash
246 ******************************************************************************/
Marek Vasut9f1ee152010-11-06 23:34:03 +0100247#if defined(CONFIG_MTD_NAND_PLATFORM) || \
248 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
Boris Brezillon47bd59e2018-09-06 14:05:13 +0200249static void palmtx_nand_cmd_ctl(struct nand_chip *this, int cmd,
250 unsigned int ctrl)
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200251{
Boris Brezillon82fc5092018-09-07 00:38:34 +0200252 char __iomem *nandaddr = this->legacy.IO_ADDR_W;
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200253
254 if (cmd == NAND_CMD_NONE)
255 return;
256
257 if (ctrl & NAND_CLE)
258 writeb(cmd, PALMTX_NAND_CLE_VIRT);
259 else if (ctrl & NAND_ALE)
260 writeb(cmd, PALMTX_NAND_ALE_VIRT);
261 else
262 writeb(cmd, nandaddr);
263}
264
265static struct mtd_partition palmtx_partition_info[] = {
266 [0] = {
267 .name = "palmtx-0",
268 .offset = 0,
269 .size = MTDPART_SIZ_FULL
270 },
271};
272
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200273struct 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,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200280 },
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{
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200317 .virtual = (unsigned long)PALMTX_PCMCIA_VIRT,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100318 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
319 .length = PALMTX_PCMCIA_SIZE,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200320 .type = MT_DEVICE,
321}, {
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200322 .virtual = (unsigned long)PALMTX_NAND_ALE_VIRT,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200323 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
324 .length = SZ_1M,
325 .type = MT_DEVICE,
326}, {
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200327 .virtual = (unsigned long)PALMTX_NAND_CLE_VIRT,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200328 .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{
Marek Vasut851982c2010-10-11 02:20:19 +0200336 pxa27x_map_io();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100337 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
338}
339
Linus Walleij58e2d872018-12-02 09:43:23 +0100340static struct gpiod_lookup_table palmtx_mci_gpio_table = {
341 .dev_id = "pxa2xx-mci.0",
342 .table = {
343 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_DETECT_N,
344 "cd", GPIO_ACTIVE_LOW),
345 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY,
346 "wp", GPIO_ACTIVE_LOW),
Linus Walleijf54005b2018-12-02 09:43:27 +0100347 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_POWER,
348 "power", GPIO_ACTIVE_HIGH),
Linus Walleij58e2d872018-12-02 09:43:23 +0100349 { },
350 },
351};
352
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100353static void __init palmtx_init(void)
354{
355 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800356 pxa_set_ffuart_info(NULL);
357 pxa_set_btuart_info(NULL);
358 pxa_set_stuart_info(NULL);
359
Linus Walleijf54005b2018-12-02 09:43:27 +0100360 palm27x_mmc_init(&palmtx_mci_gpio_table);
Marek Vasut31620e22010-07-13 08:16:45 +0200361 palm27x_pm_init(PALMTX_STR_BASE);
362 palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
363 palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
364 GPIO_NR_PALMTX_USB_PULLUP, 1);
365 palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
366 palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
367 GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
368 palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
369 palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
370 palm27x_pmic_init();
371 palmtx_kpc_init();
372 palmtx_keys_init();
373 palmtx_nor_init();
374 palmtx_nand_init();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100375}
376
377MACHINE_START(PALMTX, "Palm T|X")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400378 .atag_offset = 0x100,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100379 .map_io = palmtx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600380 .nr_irqs = PXA_NR_IRQS,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100381 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800382 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700383 .init_time = pxa_timer_init,
Russell King271a74f2011-11-04 14:15:53 +0000384 .init_machine = palmtx_init,
385 .restart = pxa_restart,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100386MACHINE_END