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>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <mach/audio.h>
34 #include <mach/palmtx.h>
36 #include <mach/pxafb.h>
37 #include <mach/pxa-regs.h>
38 #include <mach/mfp-pxa27x.h>
39 #include <mach/irda.h>
40 #include <mach/pxa27x_keypad.h>
46 /******************************************************************************
48 ******************************************************************************/
49 static unsigned long palmtx_pin_config
[] __initdata
= {
60 GPIO29_AC97_SDATA_IN_0
,
61 GPIO30_AC97_SDATA_OUT
,
87 /******************************************************************************
88 * SD/MMC card controller
89 ******************************************************************************/
90 static int palmtx_mci_init(struct device
*dev
, irq_handler_t palmtx_detect_int
,
95 /* Setup an interrupt for detecting card insert/remove events */
96 err
= request_irq(IRQ_GPIO_PALMTX_SD_DETECT_N
, palmtx_detect_int
,
97 IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
98 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
99 "SD/MMC card detect", data
);
101 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
106 err
= gpio_request(GPIO_NR_PALMTX_SD_POWER
, "SD_POWER");
110 err
= gpio_request(GPIO_NR_PALMTX_SD_READONLY
, "SD_READONLY");
114 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
119 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
121 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N
, data
);
125 static void palmtx_mci_exit(struct device
*dev
, void *data
)
127 gpio_free(GPIO_NR_PALMTX_SD_READONLY
);
128 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
129 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N
, data
);
132 static void palmtx_mci_power(struct device
*dev
, unsigned int vdd
)
134 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
135 gpio_set_value(GPIO_NR_PALMTX_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
138 static int palmtx_mci_get_ro(struct device
*dev
)
140 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY
);
143 static struct pxamci_platform_data palmtx_mci_platform_data
= {
144 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
145 .setpower
= palmtx_mci_power
,
146 .get_ro
= palmtx_mci_get_ro
,
147 .init
= palmtx_mci_init
,
148 .exit
= palmtx_mci_exit
,
151 /******************************************************************************
153 ******************************************************************************/
154 static unsigned int palmtx_matrix_keys
[] = {
155 KEY(0, 0, KEY_POWER
),
157 KEY(0, 2, KEY_ENTER
),
166 KEY(3, 0, KEY_RIGHT
),
171 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data
= {
172 .matrix_key_rows
= 4,
173 .matrix_key_cols
= 3,
174 .matrix_key_map
= palmtx_matrix_keys
,
175 .matrix_key_map_size
= ARRAY_SIZE(palmtx_matrix_keys
),
177 .debounce_interval
= 30,
180 /******************************************************************************
182 ******************************************************************************/
183 static struct gpio_keys_button palmtx_pxa_buttons
[] = {
184 {KEY_F8
, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
187 static struct gpio_keys_platform_data palmtx_pxa_keys_data
= {
188 .buttons
= palmtx_pxa_buttons
,
189 .nbuttons
= ARRAY_SIZE(palmtx_pxa_buttons
),
192 static struct platform_device palmtx_pxa_keys
= {
196 .platform_data
= &palmtx_pxa_keys_data
,
200 /******************************************************************************
202 ******************************************************************************/
203 static int palmtx_backlight_init(struct device
*dev
)
207 ret
= gpio_request(GPIO_NR_PALMTX_BL_POWER
, "BL POWER");
210 ret
= gpio_request(GPIO_NR_PALMTX_LCD_POWER
, "LCD POWER");
216 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
221 static int palmtx_backlight_notify(int brightness
)
223 gpio_set_value(GPIO_NR_PALMTX_BL_POWER
, brightness
);
224 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER
, brightness
);
228 static void palmtx_backlight_exit(struct device
*dev
)
230 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
231 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
234 static struct platform_pwm_backlight_data palmtx_backlight_data
= {
236 .max_brightness
= PALMTX_MAX_INTENSITY
,
237 .dft_brightness
= PALMTX_MAX_INTENSITY
,
238 .pwm_period_ns
= PALMTX_PERIOD_NS
,
239 .init
= palmtx_backlight_init
,
240 .notify
= palmtx_backlight_notify
,
241 .exit
= palmtx_backlight_exit
,
244 static struct platform_device palmtx_backlight
= {
245 .name
= "pwm-backlight",
247 .parent
= &pxa27x_device_pwm0
.dev
,
248 .platform_data
= &palmtx_backlight_data
,
252 /******************************************************************************
254 ******************************************************************************/
255 static void palmtx_irda_transceiver_mode(struct device
*dev
, int mode
)
257 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE
, mode
& IR_OFF
);
258 pxa2xx_transceiver_mode(dev
, mode
);
261 static struct pxaficp_platform_data palmtx_ficp_platform_data
= {
262 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
263 .transceiver_mode
= palmtx_irda_transceiver_mode
,
266 /******************************************************************************
268 ******************************************************************************/
269 static void palmtx_udc_command(int cmd
)
271 gpio_set_value(GPIO_NR_PALMTX_USB_POWER
, !cmd
);
273 gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP
, !cmd
);
276 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata
= {
277 .gpio_vbus
= GPIO_NR_PALMTX_USB_DETECT_N
,
278 .gpio_vbus_inverted
= 1,
279 .udc_command
= palmtx_udc_command
,
282 /******************************************************************************
284 ******************************************************************************/
285 static int power_supply_init(struct device
*dev
)
289 ret
= gpio_request(GPIO_NR_PALMTX_POWER_DETECT
, "CABLE_STATE_AC");
293 ret
= gpio_request(GPIO_NR_PALMTX_USB_DETECT_N
, "CABLE_STATE_USB");
300 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
305 static int palmtx_is_ac_online(void)
307 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT
);
310 static int palmtx_is_usb_online(void)
312 return !gpio_get_value(GPIO_NR_PALMTX_USB_DETECT_N
);
315 static void power_supply_exit(struct device
*dev
)
317 gpio_free(GPIO_NR_PALMTX_USB_DETECT_N
);
318 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
321 static char *palmtx_supplicants
[] = {
325 static struct pda_power_pdata power_supply_info
= {
326 .init
= power_supply_init
,
327 .is_ac_online
= palmtx_is_ac_online
,
328 .is_usb_online
= palmtx_is_usb_online
,
329 .exit
= power_supply_exit
,
330 .supplied_to
= palmtx_supplicants
,
331 .num_supplicants
= ARRAY_SIZE(palmtx_supplicants
),
334 static struct platform_device power_supply
= {
338 .platform_data
= &power_supply_info
,
342 /******************************************************************************
344 ******************************************************************************/
345 static struct pxafb_mode_info palmtx_lcd_modes
[] = {
362 static struct pxafb_mach_info palmtx_lcd_screen
= {
363 .modes
= palmtx_lcd_modes
,
364 .num_modes
= ARRAY_SIZE(palmtx_lcd_modes
),
365 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
368 /******************************************************************************
370 ******************************************************************************/
371 static struct platform_device
*devices
[] __initdata
= {
372 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
379 static struct map_desc palmtx_io_desc
[] __initdata
= {
381 .virtual = PALMTX_PCMCIA_VIRT
,
382 .pfn
= __phys_to_pfn(PALMTX_PCMCIA_PHYS
),
383 .length
= PALMTX_PCMCIA_SIZE
,
388 static void __init
palmtx_map_io(void)
391 iotable_init(palmtx_io_desc
, ARRAY_SIZE(palmtx_io_desc
));
394 static void __init
palmtx_init(void)
396 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config
));
398 set_pxa_fb_info(&palmtx_lcd_screen
);
399 pxa_set_mci_info(&palmtx_mci_platform_data
);
400 pxa_set_udc_info(&palmtx_udc_info
);
401 pxa_set_ac97_info(NULL
);
402 pxa_set_ficp_info(&palmtx_ficp_platform_data
);
403 pxa_set_keypad_info(&palmtx_keypad_platform_data
);
405 platform_add_devices(devices
, ARRAY_SIZE(devices
));
408 MACHINE_START(PALMTX
, "Palm T|X")
409 .phys_io
= PALMTX_PHYS_IO_START
,
410 .io_pg_offst
= io_p2v(0x40000000),
411 .boot_params
= 0xa0000100,
412 .map_io
= palmtx_map_io
,
413 .init_irq
= pxa27x_init_irq
,
415 .init_machine
= palmtx_init