blob: 07332c92c9f7d1092b57c123b4105885dfad706c [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Marek Vašutb5e4ad52008-07-07 17:25:46 +01002/*
3 * Hardware definitions for PalmTX
4 *
5 * Author: Marek Vasut <marek.vasut@gmail.com>
6 *
7 * Based on work of:
8 * Alex Osborne <ato@meshy.org>
9 * Cristiano P. <cristianop@users.sourceforge.net>
10 * Jan Herman <2hp@seznam.cz>
11 * Michal Hrusecky
12 *
Marek Vašutb5e4ad52008-07-07 17:25:46 +010013 * (find more info at www.hackndev.com)
Marek Vašutb5e4ad52008-07-07 17:25:46 +010014 */
15
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/irq.h>
19#include <linux/gpio_keys.h>
20#include <linux/input.h>
Marek Vašutd4b19c42008-07-07 17:31:58 +010021#include <linux/pda_power.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010022#include <linux/pwm_backlight.h>
23#include <linux/gpio.h>
Marek Vasut241cf472010-06-04 03:07:33 +020024#include <linux/wm97xx.h>
Marek Vašut4e9687d2008-09-11 19:37:32 +010025#include <linux/power_supply.h>
Boris Brezillonc7921bb2018-09-07 00:38:46 +020026#include <linux/mtd/platnand.h>
Marek Vasut91cf6a92009-07-27 02:07:41 +020027#include <linux/mtd/mtd.h>
28#include <linux/mtd/physmap.h>
Marek Vašutb5e4ad52008-07-07 17:25:46 +010029
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010034#include "pxa27x.h"
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/audio.h>
36#include <mach/palmtx.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020037#include <linux/platform_data/mmc-pxamci.h>
38#include <linux/platform_data/video-pxafb.h>
39#include <linux/platform_data/irda-pxaficp.h>
40#include <linux/platform_data/keypad-pxa27x.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010041#include "udc.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020042#include <linux/platform_data/asoc-palm27x.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010043#include "palm27x.h"
Marek Vašutb5e4ad52008-07-07 17:25:46 +010044
45#include "generic.h"
46#include "devices.h"
47
48/******************************************************************************
49 * Pin configuration
50 ******************************************************************************/
51static unsigned long palmtx_pin_config[] __initdata = {
52 /* MMC */
53 GPIO32_MMC_CLK,
54 GPIO92_MMC_DAT_0,
55 GPIO109_MMC_DAT_1,
56 GPIO110_MMC_DAT_2,
57 GPIO111_MMC_DAT_3,
58 GPIO112_MMC_CMD,
Marek Vasuta730b322008-11-20 17:34:57 +010059 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO115_GPIO, /* SD r/o switch */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010062
63 /* AC97 */
64 GPIO28_AC97_BITCLK,
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
67 GPIO31_AC97_SYNC,
Marek Vasut6ec04f42009-05-22 01:39:10 +020068 GPIO89_AC97_SYSCLK,
Marek Vasutefb12cd2009-04-12 16:37:23 +020069 GPIO95_AC97_nRESET,
Marek Vašutb5e4ad52008-07-07 17:25:46 +010070
71 /* IrDA */
Marek Vasuta730b322008-11-20 17:34:57 +010072 GPIO40_GPIO, /* ir disable */
Marek Vašutb5e4ad52008-07-07 17:25:46 +010073 GPIO46_FICP_RXD,
74 GPIO47_FICP_TXD,
75
76 /* PWM */
77 GPIO16_PWM0_OUT,
78
79 /* USB */
Marek Vasuta730b322008-11-20 17:34:57 +010080 GPIO13_GPIO, /* usb detect */
Marek Vasutefb12cd2009-04-12 16:37:23 +020081 GPIO93_GPIO, /* usb power */
Marek Vašut35978402008-07-07 17:28:59 +010082
83 /* PCMCIA */
84 GPIO48_nPOE,
85 GPIO49_nPWE,
86 GPIO50_nPIOR,
87 GPIO51_nPIOW,
88 GPIO85_nPCE_1,
89 GPIO54_nPCE_2,
90 GPIO79_PSKTSEL,
91 GPIO55_nPREG,
92 GPIO56_nPWAIT,
93 GPIO57_nIOIS16,
Marek Vasuta730b322008-11-20 17:34:57 +010094 GPIO94_GPIO, /* wifi power 1 */
95 GPIO108_GPIO, /* wifi power 2 */
96 GPIO116_GPIO, /* wifi ready */
97
98 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +010099 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
100 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
101 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
102 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
Marek Vasuta730b322008-11-20 17:34:57 +0100103 GPIO103_KP_MKOUT_0,
104 GPIO104_KP_MKOUT_1,
105 GPIO105_KP_MKOUT_2,
106
107 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800108 GPIOxx_LCD_TFT_16BPP,
Marek Vasuta730b322008-11-20 17:34:57 +0100109
Marek Vasutecf763c2009-07-16 19:37:29 +0200110 /* FFUART */
111 GPIO34_FFUART_RXD,
112 GPIO39_FFUART_TXD,
113
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200114 /* NAND */
115 GPIO15_nCS_1,
116 GPIO18_RDY,
117
Marek Vasuta730b322008-11-20 17:34:57 +0100118 /* MISC. */
119 GPIO10_GPIO, /* hotsync button */
120 GPIO12_GPIO, /* power detect */
121 GPIO107_GPIO, /* earphone detect */
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100122};
123
124/******************************************************************************
Marek Vasut91cf6a92009-07-27 02:07:41 +0200125 * NOR Flash
126 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200127#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Marek Vasut91cf6a92009-07-27 02:07:41 +0200128static struct mtd_partition palmtx_partitions[] = {
129 {
130 .name = "Flash",
131 .offset = 0x00000000,
132 .size = MTDPART_SIZ_FULL,
133 .mask_flags = 0
134 }
135};
136
137static struct physmap_flash_data palmtx_flash_data[] = {
138 {
139 .width = 2, /* bankwidth in bytes */
140 .parts = palmtx_partitions,
141 .nr_parts = ARRAY_SIZE(palmtx_partitions)
142 }
143};
144
145static struct resource palmtx_flash_resource = {
146 .start = PXA_CS0_PHYS,
147 .end = PXA_CS0_PHYS + SZ_8M - 1,
148 .flags = IORESOURCE_MEM,
149};
150
151static struct platform_device palmtx_flash = {
152 .name = "physmap-flash",
153 .id = 0,
154 .resource = &palmtx_flash_resource,
155 .num_resources = 1,
156 .dev = {
157 .platform_data = palmtx_flash_data,
158 },
159};
160
Marek Vasut31620e22010-07-13 08:16:45 +0200161static void __init palmtx_nor_init(void)
162{
163 platform_device_register(&palmtx_flash);
164}
165#else
166static inline void palmtx_nor_init(void) {}
167#endif
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100168
169/******************************************************************************
170 * GPIO keyboard
171 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200172#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Chao Xie0a085a92013-05-05 20:24:58 -0700173static const unsigned int palmtx_matrix_keys[] = {
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100174 KEY(0, 0, KEY_POWER),
175 KEY(0, 1, KEY_F1),
176 KEY(0, 2, KEY_ENTER),
177
178 KEY(1, 0, KEY_F2),
179 KEY(1, 1, KEY_F3),
180 KEY(1, 2, KEY_F4),
181
182 KEY(2, 0, KEY_UP),
183 KEY(2, 2, KEY_DOWN),
184
185 KEY(3, 0, KEY_RIGHT),
186 KEY(3, 2, KEY_LEFT),
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100187};
188
Chao Xie0a085a92013-05-05 20:24:58 -0700189static struct matrix_keymap_data palmtx_matrix_keymap_data = {
190 .keymap = palmtx_matrix_keys,
191 .keymap_size = ARRAY_SIZE(palmtx_matrix_keys),
192};
193
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100194static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
195 .matrix_key_rows = 4,
196 .matrix_key_cols = 3,
Chao Xie0a085a92013-05-05 20:24:58 -0700197 .matrix_keymap_data = &palmtx_matrix_keymap_data,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100198
199 .debounce_interval = 30,
200};
201
Marek Vasut31620e22010-07-13 08:16:45 +0200202static void __init palmtx_kpc_init(void)
203{
204 pxa_set_keypad_info(&palmtx_keypad_platform_data);
205}
206#else
207static inline void palmtx_kpc_init(void) {}
208#endif
209
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100210/******************************************************************************
211 * GPIO keys
212 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200213#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100214static struct gpio_keys_button palmtx_pxa_buttons[] = {
215 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
216};
217
218static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
219 .buttons = palmtx_pxa_buttons,
220 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
221};
222
223static struct platform_device palmtx_pxa_keys = {
224 .name = "gpio-keys",
225 .id = -1,
226 .dev = {
227 .platform_data = &palmtx_pxa_keys_data,
228 },
229};
230
Marek Vasut31620e22010-07-13 08:16:45 +0200231static void __init palmtx_keys_init(void)
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100232{
Marek Vasut31620e22010-07-13 08:16:45 +0200233 platform_device_register(&palmtx_pxa_keys);
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100234}
Marek Vasut31620e22010-07-13 08:16:45 +0200235#else
236static inline void palmtx_keys_init(void) {}
237#endif
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100238
239/******************************************************************************
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200240 * NAND Flash
241 ******************************************************************************/
Marek Vasut9f1ee152010-11-06 23:34:03 +0100242#if defined(CONFIG_MTD_NAND_PLATFORM) || \
243 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
Boris Brezillon47bd59e2018-09-06 14:05:13 +0200244static void palmtx_nand_cmd_ctl(struct nand_chip *this, int cmd,
245 unsigned int ctrl)
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200246{
Boris Brezillon82fc5092018-09-07 00:38:34 +0200247 char __iomem *nandaddr = this->legacy.IO_ADDR_W;
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200248
249 if (cmd == NAND_CMD_NONE)
250 return;
251
252 if (ctrl & NAND_CLE)
253 writeb(cmd, PALMTX_NAND_CLE_VIRT);
254 else if (ctrl & NAND_ALE)
255 writeb(cmd, PALMTX_NAND_ALE_VIRT);
256 else
257 writeb(cmd, nandaddr);
258}
259
260static struct mtd_partition palmtx_partition_info[] = {
261 [0] = {
262 .name = "palmtx-0",
263 .offset = 0,
264 .size = MTDPART_SIZ_FULL
265 },
266};
267
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200268struct platform_nand_data palmtx_nand_platdata = {
269 .chip = {
270 .nr_chips = 1,
271 .chip_offset = 0,
272 .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
273 .partitions = palmtx_partition_info,
274 .chip_delay = 20,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200275 },
276 .ctrl = {
277 .cmd_ctrl = palmtx_nand_cmd_ctl,
278 },
279};
280
281static struct resource palmtx_nand_resource[] = {
282 [0] = {
283 .start = PXA_CS1_PHYS,
284 .end = PXA_CS1_PHYS + SZ_1M - 1,
285 .flags = IORESOURCE_MEM,
286 },
287};
288
289static struct platform_device palmtx_nand = {
290 .name = "gen_nand",
291 .num_resources = ARRAY_SIZE(palmtx_nand_resource),
292 .resource = palmtx_nand_resource,
293 .id = -1,
294 .dev = {
295 .platform_data = &palmtx_nand_platdata,
296 }
297};
298
Marek Vasut31620e22010-07-13 08:16:45 +0200299static void __init palmtx_nand_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100300{
Marek Vasut31620e22010-07-13 08:16:45 +0200301 platform_device_register(&palmtx_nand);
Marek Vasut81854f82009-03-28 12:37:42 +0100302}
Marek Vasut31620e22010-07-13 08:16:45 +0200303#else
304static inline void palmtx_nand_init(void) {}
305#endif
Marek Vasut81854f82009-03-28 12:37:42 +0100306
Marek Vasut81854f82009-03-28 12:37:42 +0100307/******************************************************************************
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100308 * Machine init
309 ******************************************************************************/
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100310static struct map_desc palmtx_io_desc[] __initdata = {
311{
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200312 .virtual = (unsigned long)PALMTX_PCMCIA_VIRT,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100313 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
314 .length = PALMTX_PCMCIA_SIZE,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200315 .type = MT_DEVICE,
316}, {
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200317 .virtual = (unsigned long)PALMTX_NAND_ALE_VIRT,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200318 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
319 .length = SZ_1M,
320 .type = MT_DEVICE,
321}, {
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200322 .virtual = (unsigned long)PALMTX_NAND_CLE_VIRT,
Marek Vasut3eb37ff2009-07-18 16:51:41 +0200323 .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
324 .length = SZ_1M,
325 .type = MT_DEVICE,
326}
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100327};
328
329static void __init palmtx_map_io(void)
330{
Marek Vasut851982c2010-10-11 02:20:19 +0200331 pxa27x_map_io();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100332 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
333}
334
Linus Walleij58e2d872018-12-02 09:43:23 +0100335static struct gpiod_lookup_table palmtx_mci_gpio_table = {
336 .dev_id = "pxa2xx-mci.0",
337 .table = {
338 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_DETECT_N,
339 "cd", GPIO_ACTIVE_LOW),
340 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY,
341 "wp", GPIO_ACTIVE_LOW),
Linus Walleijf54005b2018-12-02 09:43:27 +0100342 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_POWER,
343 "power", GPIO_ACTIVE_HIGH),
Linus Walleij58e2d872018-12-02 09:43:23 +0100344 { },
345 },
346};
347
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100348static void __init palmtx_init(void)
349{
350 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800351 pxa_set_ffuart_info(NULL);
352 pxa_set_btuart_info(NULL);
353 pxa_set_stuart_info(NULL);
354
Linus Walleijf54005b2018-12-02 09:43:27 +0100355 palm27x_mmc_init(&palmtx_mci_gpio_table);
Marek Vasut31620e22010-07-13 08:16:45 +0200356 palm27x_pm_init(PALMTX_STR_BASE);
357 palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
358 palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
359 GPIO_NR_PALMTX_USB_PULLUP, 1);
360 palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
361 palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
362 GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
363 palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
364 palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
365 palm27x_pmic_init();
366 palmtx_kpc_init();
367 palmtx_keys_init();
368 palmtx_nor_init();
369 palmtx_nand_init();
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100370}
371
372MACHINE_START(PALMTX, "Palm T|X")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400373 .atag_offset = 0x100,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100374 .map_io = palmtx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600375 .nr_irqs = PXA_NR_IRQS,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100376 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800377 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700378 .init_time = pxa_timer_init,
Russell King271a74f2011-11-04 14:15:53 +0000379 .init_machine = palmtx_init,
380 .restart = pxa_restart,
Marek Vašutb5e4ad52008-07-07 17:25:46 +0100381MACHINE_END