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_batt.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>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <mach/pxa27x.h>
39 #include <mach/audio.h>
40 #include <mach/palmtx.h>
42 #include <mach/pxafb.h>
43 #include <mach/irda.h>
44 #include <mach/pxa27x_keypad.h>
46 #include <mach/palmasoc.h>
51 /******************************************************************************
53 ******************************************************************************/
54 static unsigned long palmtx_pin_config[] __initdata = {
62 GPIO14_GPIO, /* SD detect */
63 GPIO114_GPIO, /* SD power */
64 GPIO115_GPIO, /* SD r/o switch */
68 GPIO29_AC97_SDATA_IN_0,
69 GPIO30_AC97_SDATA_OUT,
75 GPIO40_GPIO, /* ir disable */
83 GPIO13_GPIO, /* usb detect */
84 GPIO93_GPIO, /* usb power */
97 GPIO94_GPIO, /* wifi power 1 */
98 GPIO108_GPIO, /* wifi power 2 */
99 GPIO116_GPIO, /* wifi ready */
102 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
103 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
104 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
105 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
141 GPIO10_GPIO, /* hotsync button */
142 GPIO12_GPIO, /* power detect */
143 GPIO107_GPIO, /* earphone detect */
146 /******************************************************************************
147 * SD/MMC card controller
148 ******************************************************************************/
149 static struct pxamci_platform_data palmtx_mci_platform_data = {
150 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
151 .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
152 .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
153 .gpio_power = GPIO_NR_PALMTX_SD_POWER,
157 /******************************************************************************
159 ******************************************************************************/
160 static unsigned int palmtx_matrix_keys[] = {
161 KEY(0, 0, KEY_POWER),
163 KEY(0, 2, KEY_ENTER),
172 KEY(3, 0, KEY_RIGHT),
176 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
177 .matrix_key_rows = 4,
178 .matrix_key_cols = 3,
179 .matrix_key_map = palmtx_matrix_keys,
180 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
182 .debounce_interval = 30,
185 /******************************************************************************
187 ******************************************************************************/
188 static struct gpio_keys_button palmtx_pxa_buttons[] = {
189 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
192 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
193 .buttons = palmtx_pxa_buttons,
194 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
197 static struct platform_device palmtx_pxa_keys = {
201 .platform_data = &palmtx_pxa_keys_data,
205 /******************************************************************************
207 ******************************************************************************/
208 static int palmtx_backlight_init(struct device *dev)
212 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
215 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
218 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
221 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
227 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
229 gpio_free(GPIO_NR_PALMTX_BL_POWER);
234 static int palmtx_backlight_notify(int brightness)
236 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
237 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
241 static void palmtx_backlight_exit(struct device *dev)
243 gpio_free(GPIO_NR_PALMTX_BL_POWER);
244 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
247 static struct platform_pwm_backlight_data palmtx_backlight_data = {
249 .max_brightness = PALMTX_MAX_INTENSITY,
250 .dft_brightness = PALMTX_MAX_INTENSITY,
251 .pwm_period_ns = PALMTX_PERIOD_NS,
252 .init = palmtx_backlight_init,
253 .notify = palmtx_backlight_notify,
254 .exit = palmtx_backlight_exit,
257 static struct platform_device palmtx_backlight = {
258 .name = "pwm-backlight",
260 .parent = &pxa27x_device_pwm0.dev,
261 .platform_data = &palmtx_backlight_data,
265 /******************************************************************************
267 ******************************************************************************/
268 static int palmtx_irda_startup(struct device *dev)
271 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
274 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
276 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
281 static void palmtx_irda_shutdown(struct device *dev)
283 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
286 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
288 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
289 pxa2xx_transceiver_mode(dev, mode);
292 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
293 .startup = palmtx_irda_startup,
294 .shutdown = palmtx_irda_shutdown,
295 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
296 .transceiver_mode = palmtx_irda_transceiver_mode,
299 /******************************************************************************
301 ******************************************************************************/
302 static struct gpio_vbus_mach_info palmtx_udc_info = {
303 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
304 .gpio_vbus_inverted = 1,
305 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
308 static struct platform_device palmtx_gpio_vbus = {
312 .platform_data = &palmtx_udc_info,
316 /******************************************************************************
318 ******************************************************************************/
319 static int power_supply_init(struct device *dev)
323 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
326 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
333 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
338 static int palmtx_is_ac_online(void)
340 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
343 static void power_supply_exit(struct device *dev)
345 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
348 static char *palmtx_supplicants[] = {
352 static struct pda_power_pdata power_supply_info = {
353 .init = power_supply_init,
354 .is_ac_online = palmtx_is_ac_online,
355 .exit = power_supply_exit,
356 .supplied_to = palmtx_supplicants,
357 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
360 static struct platform_device power_supply = {
364 .platform_data = &power_supply_info,
368 /******************************************************************************
370 ******************************************************************************/
371 static struct wm97xx_batt_info wm97xx_batt_pdata = {
372 .batt_aux = WM97XX_AUX_ID3,
373 .temp_aux = WM97XX_AUX_ID2,
375 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
376 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
381 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
382 .batt_name = "main-batt",
385 /******************************************************************************
387 ******************************************************************************/
388 static struct palm27x_asoc_info palmtx_asoc_pdata = {
389 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
392 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
396 static struct platform_device palmtx_asoc = {
397 .name = "palm27x-asoc",
400 .platform_data = &palmtx_asoc_pdata,
404 /******************************************************************************
406 ******************************************************************************/
407 static struct pxafb_mode_info palmtx_lcd_modes[] = {
424 static struct pxafb_mach_info palmtx_lcd_screen = {
425 .modes = palmtx_lcd_modes,
426 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
427 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
430 /******************************************************************************
432 ******************************************************************************/
433 static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
436 struct nand_chip *this = mtd->priv;
437 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
439 if (cmd == NAND_CMD_NONE)
443 writeb(cmd, PALMTX_NAND_CLE_VIRT);
444 else if (ctrl & NAND_ALE)
445 writeb(cmd, PALMTX_NAND_ALE_VIRT);
447 writeb(cmd, nandaddr);
450 static struct mtd_partition palmtx_partition_info[] = {
454 .size = MTDPART_SIZ_FULL
458 static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
460 struct platform_nand_data palmtx_nand_platdata = {
464 .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
465 .partitions = palmtx_partition_info,
467 .part_probe_types = palmtx_part_probes,
470 .cmd_ctrl = palmtx_nand_cmd_ctl,
474 static struct resource palmtx_nand_resource[] = {
476 .start = PXA_CS1_PHYS,
477 .end = PXA_CS1_PHYS + SZ_1M - 1,
478 .flags = IORESOURCE_MEM,
482 static struct platform_device palmtx_nand = {
484 .num_resources = ARRAY_SIZE(palmtx_nand_resource),
485 .resource = palmtx_nand_resource,
488 .platform_data = &palmtx_nand_platdata,
492 /******************************************************************************
493 * Power management - standby
494 ******************************************************************************/
495 static void __init palmtx_pm_init(void)
497 static u32 resume[] = {
498 0xe3a00101, /* mov r0, #0x40000000 */
499 0xe380060f, /* orr r0, r0, #0x00f00000 */
500 0xe590f008, /* ldr pc, [r0, #0x08] */
503 /* copy the bootloader */
504 memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
507 /******************************************************************************
509 ******************************************************************************/
510 static struct platform_device *devices[] __initdata = {
511 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
521 static struct map_desc palmtx_io_desc[] __initdata = {
523 .virtual = PALMTX_PCMCIA_VIRT,
524 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
525 .length = PALMTX_PCMCIA_SIZE,
528 .virtual = PALMTX_NAND_ALE_VIRT,
529 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
533 .virtual = PALMTX_NAND_CLE_VIRT,
534 .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
540 static void __init palmtx_map_io(void)
543 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
546 /* setup udc GPIOs initial state */
547 static void __init palmtx_udc_init(void)
549 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
550 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
551 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
556 static void __init palmtx_init(void)
558 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
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);
567 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
569 platform_add_devices(devices, ARRAY_SIZE(devices));
572 MACHINE_START(PALMTX, "Palm T|X")
573 .phys_io = PALMTX_PHYS_IO_START,
574 .io_pg_offst = io_p2v(0x40000000),
575 .boot_params = 0xa0000100,
576 .map_io = palmtx_map_io,
577 .init_irq = pxa27x_init_irq,
579 .init_machine = palmtx_init