2 * Hardware definitions for PalmTX
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
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.
16 * (find more info at www.hackndev.com)
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>
25 #include <linux/pda_power.h>
26 #include <linux/pwm_backlight.h>
27 #include <linux/gpio.h>
28 #include <linux/wm97xx.h>
29 #include <linux/power_supply.h>
30 #include <linux/usb/gpio_vbus.h>
31 #include <linux/mtd/nand.h>
32 #include <linux/mtd/partitions.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/physmap.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
40 #include <mach/pxa27x.h>
41 #include <mach/audio.h>
42 #include <mach/palmtx.h>
44 #include <mach/pxafb.h>
45 #include <mach/irda.h>
46 #include <mach/pxa27x_keypad.h>
48 #include <mach/palmasoc.h>
53 /******************************************************************************
55 ******************************************************************************/
56 static unsigned long palmtx_pin_config[] __initdata = {
64 GPIO14_GPIO, /* SD detect */
65 GPIO114_GPIO, /* SD power */
66 GPIO115_GPIO, /* SD r/o switch */
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
77 GPIO40_GPIO, /* ir disable */
85 GPIO13_GPIO, /* usb detect */
86 GPIO93_GPIO, /* usb power */
99 GPIO94_GPIO, /* wifi power 1 */
100 GPIO108_GPIO, /* wifi power 2 */
101 GPIO116_GPIO, /* wifi ready */
104 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,
113 GPIOxx_LCD_TFT_16BPP,
124 GPIO10_GPIO, /* hotsync button */
125 GPIO12_GPIO, /* power detect */
126 GPIO107_GPIO, /* earphone detect */
129 /******************************************************************************
131 ******************************************************************************/
132 static struct mtd_partition palmtx_partitions[] = {
135 .offset = 0x00000000,
136 .size = MTDPART_SIZ_FULL,
141 static struct physmap_flash_data palmtx_flash_data[] = {
143 .width = 2, /* bankwidth in bytes */
144 .parts = palmtx_partitions,
145 .nr_parts = ARRAY_SIZE(palmtx_partitions)
149 static struct resource palmtx_flash_resource = {
150 .start = PXA_CS0_PHYS,
151 .end = PXA_CS0_PHYS + SZ_8M - 1,
152 .flags = IORESOURCE_MEM,
155 static struct platform_device palmtx_flash = {
156 .name = "physmap-flash",
158 .resource = &palmtx_flash_resource,
161 .platform_data = palmtx_flash_data,
165 /******************************************************************************
166 * SD/MMC card controller
167 ******************************************************************************/
168 static struct pxamci_platform_data palmtx_mci_platform_data = {
169 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
170 .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
171 .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
172 .gpio_power = GPIO_NR_PALMTX_SD_POWER,
173 .detect_delay_ms = 200,
176 /******************************************************************************
178 ******************************************************************************/
179 static unsigned int palmtx_matrix_keys[] = {
180 KEY(0, 0, KEY_POWER),
182 KEY(0, 2, KEY_ENTER),
191 KEY(3, 0, KEY_RIGHT),
195 static 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),
201 .debounce_interval = 30,
204 /******************************************************************************
206 ******************************************************************************/
207 static struct gpio_keys_button palmtx_pxa_buttons[] = {
208 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
211 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
212 .buttons = palmtx_pxa_buttons,
213 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
216 static struct platform_device palmtx_pxa_keys = {
220 .platform_data = &palmtx_pxa_keys_data,
224 /******************************************************************************
226 ******************************************************************************/
227 static int palmtx_backlight_init(struct device *dev)
231 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
234 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
237 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
240 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
246 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
248 gpio_free(GPIO_NR_PALMTX_BL_POWER);
253 static int palmtx_backlight_notify(struct device *dev, int brightness)
255 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
256 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
260 static void palmtx_backlight_exit(struct device *dev)
262 gpio_free(GPIO_NR_PALMTX_BL_POWER);
263 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
266 static struct platform_pwm_backlight_data palmtx_backlight_data = {
268 .max_brightness = PALMTX_MAX_INTENSITY,
269 .dft_brightness = PALMTX_MAX_INTENSITY,
270 .pwm_period_ns = PALMTX_PERIOD_NS,
271 .init = palmtx_backlight_init,
272 .notify = palmtx_backlight_notify,
273 .exit = palmtx_backlight_exit,
276 static struct platform_device palmtx_backlight = {
277 .name = "pwm-backlight",
279 .parent = &pxa27x_device_pwm0.dev,
280 .platform_data = &palmtx_backlight_data,
284 /******************************************************************************
286 ******************************************************************************/
287 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
288 .gpio_pwdown = GPIO_NR_PALMTX_IR_DISABLE,
289 .transceiver_cap = IR_SIRMODE | IR_OFF,
292 /******************************************************************************
294 ******************************************************************************/
295 static struct gpio_vbus_mach_info palmtx_udc_info = {
296 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
297 .gpio_vbus_inverted = 1,
298 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
301 static struct platform_device palmtx_gpio_vbus = {
305 .platform_data = &palmtx_udc_info,
309 /******************************************************************************
311 ******************************************************************************/
312 static int power_supply_init(struct device *dev)
316 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
319 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
326 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
331 static int palmtx_is_ac_online(void)
333 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
336 static void power_supply_exit(struct device *dev)
338 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
341 static char *palmtx_supplicants[] = {
345 static struct pda_power_pdata power_supply_info = {
346 .init = power_supply_init,
347 .is_ac_online = palmtx_is_ac_online,
348 .exit = power_supply_exit,
349 .supplied_to = palmtx_supplicants,
350 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
353 static struct platform_device power_supply = {
357 .platform_data = &power_supply_info,
361 /******************************************************************************
362 * WM97xx audio, battery
363 ******************************************************************************/
364 static struct wm97xx_batt_pdata palmtx_batt_pdata = {
365 .batt_aux = WM97XX_AUX_ID3,
366 .temp_aux = WM97XX_AUX_ID2,
368 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
369 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
374 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
375 .batt_name = "main-batt",
378 static struct wm97xx_pdata palmtx_wm97xx_pdata = {
379 .batt_pdata = &palmtx_batt_pdata,
382 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
384 .codec_pdata = { &palmtx_wm97xx_pdata, },
387 static struct palm27x_asoc_info palmtx_asoc_pdata = {
388 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
391 static struct platform_device palmtx_asoc = {
392 .name = "palm27x-asoc",
395 .platform_data = &palmtx_asoc_pdata,
399 /******************************************************************************
401 ******************************************************************************/
402 static struct pxafb_mode_info palmtx_lcd_modes[] = {
419 static struct pxafb_mach_info palmtx_lcd_screen = {
420 .modes = palmtx_lcd_modes,
421 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
422 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
425 /******************************************************************************
427 ******************************************************************************/
428 static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
431 struct nand_chip *this = mtd->priv;
432 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
434 if (cmd == NAND_CMD_NONE)
438 writeb(cmd, PALMTX_NAND_CLE_VIRT);
439 else if (ctrl & NAND_ALE)
440 writeb(cmd, PALMTX_NAND_ALE_VIRT);
442 writeb(cmd, nandaddr);
445 static struct mtd_partition palmtx_partition_info[] = {
449 .size = MTDPART_SIZ_FULL
453 static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
455 struct platform_nand_data palmtx_nand_platdata = {
459 .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
460 .partitions = palmtx_partition_info,
462 .part_probe_types = palmtx_part_probes,
465 .cmd_ctrl = palmtx_nand_cmd_ctl,
469 static struct resource palmtx_nand_resource[] = {
471 .start = PXA_CS1_PHYS,
472 .end = PXA_CS1_PHYS + SZ_1M - 1,
473 .flags = IORESOURCE_MEM,
477 static struct platform_device palmtx_nand = {
479 .num_resources = ARRAY_SIZE(palmtx_nand_resource),
480 .resource = palmtx_nand_resource,
483 .platform_data = &palmtx_nand_platdata,
487 /******************************************************************************
488 * Power management - standby
489 ******************************************************************************/
490 static void __init palmtx_pm_init(void)
492 static u32 resume[] = {
493 0xe3a00101, /* mov r0, #0x40000000 */
494 0xe380060f, /* orr r0, r0, #0x00f00000 */
495 0xe590f008, /* ldr pc, [r0, #0x08] */
498 /* copy the bootloader */
499 memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
502 /******************************************************************************
504 ******************************************************************************/
505 static struct platform_device *devices[] __initdata = {
506 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
517 static struct map_desc palmtx_io_desc[] __initdata = {
519 .virtual = PALMTX_PCMCIA_VIRT,
520 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
521 .length = PALMTX_PCMCIA_SIZE,
524 .virtual = PALMTX_NAND_ALE_VIRT,
525 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
529 .virtual = PALMTX_NAND_CLE_VIRT,
530 .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
536 static void __init palmtx_map_io(void)
539 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
542 /* setup udc GPIOs initial state */
543 static void __init palmtx_udc_init(void)
545 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
546 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
547 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
552 static void __init palmtx_init(void)
554 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
556 pxa_set_ffuart_info(NULL);
557 pxa_set_btuart_info(NULL);
558 pxa_set_stuart_info(NULL);
561 set_pxa_fb_info(&palmtx_lcd_screen);
562 pxa_set_mci_info(&palmtx_mci_platform_data);
564 pxa_set_ac97_info(&palmtx_ac97_pdata);
565 pxa_set_ficp_info(&palmtx_ficp_platform_data);
566 pxa_set_keypad_info(&palmtx_keypad_platform_data);
568 platform_add_devices(devices, ARRAY_SIZE(devices));
571 MACHINE_START(PALMTX, "Palm T|X")
572 .phys_io = PALMTX_PHYS_IO_START,
573 .io_pg_offst = io_p2v(0x40000000),
574 .boot_params = 0xa0000100,
575 .map_io = palmtx_map_io,
576 .init_irq = pxa27x_init_irq,
578 .init_machine = palmtx_init