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/pwm_backlight.h>
26 #include <linux/gpio.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
32 #include <asm/arch/audio.h>
33 #include <asm/arch/palmtx.h>
34 #include <asm/arch/mmc.h>
35 #include <asm/arch/pxafb.h>
36 #include <asm/arch/pxa-regs.h>
37 #include <asm/arch/mfp-pxa27x.h>
38 #include <asm/arch/irda.h>
39 #include <asm/arch/pxa27x_keypad.h>
40 #include <asm/arch/udc.h>
45 /******************************************************************************
47 ******************************************************************************/
48 static unsigned long palmtx_pin_config
[] __initdata
= {
59 GPIO29_AC97_SDATA_IN_0
,
60 GPIO30_AC97_SDATA_OUT
,
74 /******************************************************************************
75 * SD/MMC card controller
76 ******************************************************************************/
77 static int palmtx_mci_init(struct device
*dev
, irq_handler_t palmtx_detect_int
,
82 /* Setup an interrupt for detecting card insert/remove events */
83 err
= request_irq(IRQ_GPIO_PALMTX_SD_DETECT_N
, palmtx_detect_int
,
84 IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
85 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
86 "SD/MMC card detect", data
);
88 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
93 err
= gpio_request(GPIO_NR_PALMTX_SD_POWER
, "SD_POWER");
97 err
= gpio_request(GPIO_NR_PALMTX_SD_READONLY
, "SD_READONLY");
101 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
106 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
108 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N
, data
);
112 static void palmtx_mci_exit(struct device
*dev
, void *data
)
114 gpio_free(GPIO_NR_PALMTX_SD_READONLY
);
115 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
116 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N
, data
);
119 static void palmtx_mci_power(struct device
*dev
, unsigned int vdd
)
121 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
122 gpio_set_value(GPIO_NR_PALMTX_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
125 static int palmtx_mci_get_ro(struct device
*dev
)
127 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY
);
130 static struct pxamci_platform_data palmtx_mci_platform_data
= {
131 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
132 .setpower
= palmtx_mci_power
,
133 .get_ro
= palmtx_mci_get_ro
,
134 .init
= palmtx_mci_init
,
135 .exit
= palmtx_mci_exit
,
138 /******************************************************************************
140 ******************************************************************************/
141 static unsigned int palmtx_matrix_keys
[] = {
142 KEY(0, 0, KEY_POWER
),
144 KEY(0, 2, KEY_ENTER
),
153 KEY(3, 0, KEY_RIGHT
),
158 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data
= {
159 .matrix_key_rows
= 4,
160 .matrix_key_cols
= 3,
161 .matrix_key_map
= palmtx_matrix_keys
,
162 .matrix_key_map_size
= ARRAY_SIZE(palmtx_matrix_keys
),
164 .debounce_interval
= 30,
167 /******************************************************************************
169 ******************************************************************************/
170 static struct gpio_keys_button palmtx_pxa_buttons
[] = {
171 {KEY_F8
, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
174 static struct gpio_keys_platform_data palmtx_pxa_keys_data
= {
175 .buttons
= palmtx_pxa_buttons
,
176 .nbuttons
= ARRAY_SIZE(palmtx_pxa_buttons
),
179 static struct platform_device palmtx_pxa_keys
= {
183 .platform_data
= &palmtx_pxa_keys_data
,
187 /******************************************************************************
189 ******************************************************************************/
190 static int palmtx_backlight_init(struct device
*dev
)
194 ret
= gpio_request(GPIO_NR_PALMTX_BL_POWER
, "BL POWER");
197 ret
= gpio_request(GPIO_NR_PALMTX_LCD_POWER
, "LCD POWER");
203 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
208 static int palmtx_backlight_notify(int brightness
)
210 gpio_set_value(GPIO_NR_PALMTX_BL_POWER
, brightness
);
211 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER
, brightness
);
215 static void palmtx_backlight_exit(struct device
*dev
)
217 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
218 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
221 static struct platform_pwm_backlight_data palmtx_backlight_data
= {
223 .max_brightness
= PALMTX_MAX_INTENSITY
,
224 .dft_brightness
= PALMTX_MAX_INTENSITY
,
225 .pwm_period_ns
= PALMTX_PERIOD_NS
,
226 .init
= palmtx_backlight_init
,
227 .notify
= palmtx_backlight_notify
,
228 .exit
= palmtx_backlight_exit
,
231 static struct platform_device palmtx_backlight
= {
232 .name
= "pwm-backlight",
234 .parent
= &pxa27x_device_pwm0
.dev
,
235 .platform_data
= &palmtx_backlight_data
,
239 /******************************************************************************
241 ******************************************************************************/
242 static void palmtx_irda_transceiver_mode(struct device
*dev
, int mode
)
244 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE
, mode
& IR_OFF
);
245 pxa2xx_transceiver_mode(dev
, mode
);
248 static struct pxaficp_platform_data palmtx_ficp_platform_data
= {
249 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
250 .transceiver_mode
= palmtx_irda_transceiver_mode
,
253 /******************************************************************************
255 ******************************************************************************/
256 static void palmtx_udc_command(int cmd
)
258 gpio_set_value(GPIO_NR_PALMTX_USB_POWER
, !cmd
);
260 gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP
, !cmd
);
263 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata
= {
264 .gpio_vbus
= GPIO_NR_PALMTX_USB_DETECT_N
,
265 .gpio_vbus_inverted
= 1,
266 .udc_command
= palmtx_udc_command
,
269 /******************************************************************************
271 ******************************************************************************/
272 static struct pxafb_mode_info palmtx_lcd_modes
[] = {
289 static struct pxafb_mach_info palmtx_lcd_screen
= {
290 .modes
= palmtx_lcd_modes
,
291 .num_modes
= ARRAY_SIZE(palmtx_lcd_modes
),
292 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
295 /******************************************************************************
297 ******************************************************************************/
298 static struct platform_device
*devices
[] __initdata
= {
299 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
305 static struct map_desc palmtx_io_desc
[] __initdata
= {
307 .virtual = PALMTX_PCMCIA_VIRT
,
308 .pfn
= __phys_to_pfn(PALMTX_PCMCIA_PHYS
),
309 .length
= PALMTX_PCMCIA_SIZE
,
314 static void __init
palmtx_map_io(void)
317 iotable_init(palmtx_io_desc
, ARRAY_SIZE(palmtx_io_desc
));
320 static void __init
palmtx_init(void)
322 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config
));
324 set_pxa_fb_info(&palmtx_lcd_screen
);
325 pxa_set_mci_info(&palmtx_mci_platform_data
);
326 pxa_set_udc_info(&palmtx_udc_info
);
327 pxa_set_ac97_info(NULL
);
328 pxa_set_ficp_info(&palmtx_ficp_platform_data
);
329 pxa_set_keypad_info(&palmtx_keypad_platform_data
);
331 platform_add_devices(devices
, ARRAY_SIZE(devices
));
334 MACHINE_START(PALMTX
, "Palm T|X")
335 .phys_io
= PALMTX_PHYS_IO_START
,
336 .io_pg_offst
= io_p2v(0x40000000),
337 .boot_params
= 0xa0000100,
338 .map_io
= palmtx_map_io
,
339 .init_irq
= pxa27x_init_irq
,
341 .init_machine
= palmtx_init