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>
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
,
143 GPIO10_GPIO
, /* hotsync button */
144 GPIO12_GPIO
, /* power detect */
145 GPIO107_GPIO
, /* earphone detect */
148 /******************************************************************************
150 ******************************************************************************/
151 static struct mtd_partition palmtx_partitions
[] = {
154 .offset
= 0x00000000,
155 .size
= MTDPART_SIZ_FULL
,
160 static struct physmap_flash_data palmtx_flash_data
[] = {
162 .width
= 2, /* bankwidth in bytes */
163 .parts
= palmtx_partitions
,
164 .nr_parts
= ARRAY_SIZE(palmtx_partitions
)
168 static struct resource palmtx_flash_resource
= {
169 .start
= PXA_CS0_PHYS
,
170 .end
= PXA_CS0_PHYS
+ SZ_8M
- 1,
171 .flags
= IORESOURCE_MEM
,
174 static struct platform_device palmtx_flash
= {
175 .name
= "physmap-flash",
177 .resource
= &palmtx_flash_resource
,
180 .platform_data
= palmtx_flash_data
,
184 /******************************************************************************
185 * SD/MMC card controller
186 ******************************************************************************/
187 static struct pxamci_platform_data palmtx_mci_platform_data
= {
188 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
189 .gpio_card_detect
= GPIO_NR_PALMTX_SD_DETECT_N
,
190 .gpio_card_ro
= GPIO_NR_PALMTX_SD_READONLY
,
191 .gpio_power
= GPIO_NR_PALMTX_SD_POWER
,
195 /******************************************************************************
197 ******************************************************************************/
198 static unsigned int palmtx_matrix_keys
[] = {
199 KEY(0, 0, KEY_POWER
),
201 KEY(0, 2, KEY_ENTER
),
210 KEY(3, 0, KEY_RIGHT
),
214 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data
= {
215 .matrix_key_rows
= 4,
216 .matrix_key_cols
= 3,
217 .matrix_key_map
= palmtx_matrix_keys
,
218 .matrix_key_map_size
= ARRAY_SIZE(palmtx_matrix_keys
),
220 .debounce_interval
= 30,
223 /******************************************************************************
225 ******************************************************************************/
226 static struct gpio_keys_button palmtx_pxa_buttons
[] = {
227 {KEY_F8
, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
230 static struct gpio_keys_platform_data palmtx_pxa_keys_data
= {
231 .buttons
= palmtx_pxa_buttons
,
232 .nbuttons
= ARRAY_SIZE(palmtx_pxa_buttons
),
235 static struct platform_device palmtx_pxa_keys
= {
239 .platform_data
= &palmtx_pxa_keys_data
,
243 /******************************************************************************
245 ******************************************************************************/
246 static int palmtx_backlight_init(struct device
*dev
)
250 ret
= gpio_request(GPIO_NR_PALMTX_BL_POWER
, "BL POWER");
253 ret
= gpio_direction_output(GPIO_NR_PALMTX_BL_POWER
, 0);
256 ret
= gpio_request(GPIO_NR_PALMTX_LCD_POWER
, "LCD POWER");
259 ret
= gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER
, 0);
265 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
267 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
272 static int palmtx_backlight_notify(int brightness
)
274 gpio_set_value(GPIO_NR_PALMTX_BL_POWER
, brightness
);
275 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER
, brightness
);
279 static void palmtx_backlight_exit(struct device
*dev
)
281 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
282 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
285 static struct platform_pwm_backlight_data palmtx_backlight_data
= {
287 .max_brightness
= PALMTX_MAX_INTENSITY
,
288 .dft_brightness
= PALMTX_MAX_INTENSITY
,
289 .pwm_period_ns
= PALMTX_PERIOD_NS
,
290 .init
= palmtx_backlight_init
,
291 .notify
= palmtx_backlight_notify
,
292 .exit
= palmtx_backlight_exit
,
295 static struct platform_device palmtx_backlight
= {
296 .name
= "pwm-backlight",
298 .parent
= &pxa27x_device_pwm0
.dev
,
299 .platform_data
= &palmtx_backlight_data
,
303 /******************************************************************************
305 ******************************************************************************/
306 static int palmtx_irda_startup(struct device
*dev
)
309 err
= gpio_request(GPIO_NR_PALMTX_IR_DISABLE
, "IR DISABLE");
312 err
= gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE
, 1);
314 gpio_free(GPIO_NR_PALMTX_IR_DISABLE
);
319 static void palmtx_irda_shutdown(struct device
*dev
)
321 gpio_free(GPIO_NR_PALMTX_IR_DISABLE
);
324 static void palmtx_irda_transceiver_mode(struct device
*dev
, int mode
)
326 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE
, mode
& IR_OFF
);
327 pxa2xx_transceiver_mode(dev
, mode
);
330 static struct pxaficp_platform_data palmtx_ficp_platform_data
= {
331 .startup
= palmtx_irda_startup
,
332 .shutdown
= palmtx_irda_shutdown
,
333 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
334 .transceiver_mode
= palmtx_irda_transceiver_mode
,
337 /******************************************************************************
339 ******************************************************************************/
340 static struct gpio_vbus_mach_info palmtx_udc_info
= {
341 .gpio_vbus
= GPIO_NR_PALMTX_USB_DETECT_N
,
342 .gpio_vbus_inverted
= 1,
343 .gpio_pullup
= GPIO_NR_PALMTX_USB_PULLUP
,
346 static struct platform_device palmtx_gpio_vbus
= {
350 .platform_data
= &palmtx_udc_info
,
354 /******************************************************************************
356 ******************************************************************************/
357 static int power_supply_init(struct device
*dev
)
361 ret
= gpio_request(GPIO_NR_PALMTX_POWER_DETECT
, "CABLE_STATE_AC");
364 ret
= gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT
);
371 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
376 static int palmtx_is_ac_online(void)
378 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT
);
381 static void power_supply_exit(struct device
*dev
)
383 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
386 static char *palmtx_supplicants
[] = {
390 static struct pda_power_pdata power_supply_info
= {
391 .init
= power_supply_init
,
392 .is_ac_online
= palmtx_is_ac_online
,
393 .exit
= power_supply_exit
,
394 .supplied_to
= palmtx_supplicants
,
395 .num_supplicants
= ARRAY_SIZE(palmtx_supplicants
),
398 static struct platform_device power_supply
= {
402 .platform_data
= &power_supply_info
,
406 /******************************************************************************
408 ******************************************************************************/
409 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
410 .batt_aux
= WM97XX_AUX_ID3
,
411 .temp_aux
= WM97XX_AUX_ID2
,
413 .max_voltage
= PALMTX_BAT_MAX_VOLTAGE
,
414 .min_voltage
= PALMTX_BAT_MIN_VOLTAGE
,
419 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
420 .batt_name
= "main-batt",
423 /******************************************************************************
425 ******************************************************************************/
426 static struct palm27x_asoc_info palmtx_asoc_pdata
= {
427 .jack_gpio
= GPIO_NR_PALMTX_EARPHONE_DETECT
,
430 static pxa2xx_audio_ops_t palmtx_ac97_pdata
= {
434 static struct platform_device palmtx_asoc
= {
435 .name
= "palm27x-asoc",
438 .platform_data
= &palmtx_asoc_pdata
,
442 /******************************************************************************
444 ******************************************************************************/
445 static struct pxafb_mode_info palmtx_lcd_modes
[] = {
462 static struct pxafb_mach_info palmtx_lcd_screen
= {
463 .modes
= palmtx_lcd_modes
,
464 .num_modes
= ARRAY_SIZE(palmtx_lcd_modes
),
465 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
468 /******************************************************************************
470 ******************************************************************************/
471 static void palmtx_nand_cmd_ctl(struct mtd_info
*mtd
, int cmd
,
474 struct nand_chip
*this = mtd
->priv
;
475 unsigned long nandaddr
= (unsigned long)this->IO_ADDR_W
;
477 if (cmd
== NAND_CMD_NONE
)
481 writeb(cmd
, PALMTX_NAND_CLE_VIRT
);
482 else if (ctrl
& NAND_ALE
)
483 writeb(cmd
, PALMTX_NAND_ALE_VIRT
);
485 writeb(cmd
, nandaddr
);
488 static struct mtd_partition palmtx_partition_info
[] = {
492 .size
= MTDPART_SIZ_FULL
496 static const char *palmtx_part_probes
[] = { "cmdlinepart", NULL
};
498 struct platform_nand_data palmtx_nand_platdata
= {
502 .nr_partitions
= ARRAY_SIZE(palmtx_partition_info
),
503 .partitions
= palmtx_partition_info
,
505 .part_probe_types
= palmtx_part_probes
,
508 .cmd_ctrl
= palmtx_nand_cmd_ctl
,
512 static struct resource palmtx_nand_resource
[] = {
514 .start
= PXA_CS1_PHYS
,
515 .end
= PXA_CS1_PHYS
+ SZ_1M
- 1,
516 .flags
= IORESOURCE_MEM
,
520 static struct platform_device palmtx_nand
= {
522 .num_resources
= ARRAY_SIZE(palmtx_nand_resource
),
523 .resource
= palmtx_nand_resource
,
526 .platform_data
= &palmtx_nand_platdata
,
530 /******************************************************************************
531 * Power management - standby
532 ******************************************************************************/
533 static void __init
palmtx_pm_init(void)
535 static u32 resume
[] = {
536 0xe3a00101, /* mov r0, #0x40000000 */
537 0xe380060f, /* orr r0, r0, #0x00f00000 */
538 0xe590f008, /* ldr pc, [r0, #0x08] */
541 /* copy the bootloader */
542 memcpy(phys_to_virt(PALMTX_STR_BASE
), resume
, sizeof(resume
));
545 /******************************************************************************
547 ******************************************************************************/
548 static struct platform_device
*devices
[] __initdata
= {
549 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
560 static struct map_desc palmtx_io_desc
[] __initdata
= {
562 .virtual = PALMTX_PCMCIA_VIRT
,
563 .pfn
= __phys_to_pfn(PALMTX_PCMCIA_PHYS
),
564 .length
= PALMTX_PCMCIA_SIZE
,
567 .virtual = PALMTX_NAND_ALE_VIRT
,
568 .pfn
= __phys_to_pfn(PALMTX_NAND_ALE_PHYS
),
572 .virtual = PALMTX_NAND_CLE_VIRT
,
573 .pfn
= __phys_to_pfn(PALMTX_NAND_CLE_PHYS
),
579 static void __init
palmtx_map_io(void)
582 iotable_init(palmtx_io_desc
, ARRAY_SIZE(palmtx_io_desc
));
585 /* setup udc GPIOs initial state */
586 static void __init
palmtx_udc_init(void)
588 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP
, "UDC Vbus")) {
589 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP
, 1);
590 gpio_free(GPIO_NR_PALMTX_USB_PULLUP
);
595 static void __init
palmtx_init(void)
597 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config
));
600 set_pxa_fb_info(&palmtx_lcd_screen
);
601 pxa_set_mci_info(&palmtx_mci_platform_data
);
603 pxa_set_ac97_info(&palmtx_ac97_pdata
);
604 pxa_set_ficp_info(&palmtx_ficp_platform_data
);
605 pxa_set_keypad_info(&palmtx_keypad_platform_data
);
606 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
608 platform_add_devices(devices
, ARRAY_SIZE(devices
));
611 MACHINE_START(PALMTX
, "Palm T|X")
612 .phys_io
= PALMTX_PHYS_IO_START
,
613 .io_pg_offst
= io_p2v(0x40000000),
614 .boot_params
= 0xa0000100,
615 .map_io
= palmtx_map_io
,
616 .init_irq
= pxa27x_init_irq
,
618 .init_machine
= palmtx_init