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,
86 /******************************************************************************
87 * SD/MMC card controller
88 ******************************************************************************/
89 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
94 /* Setup an interrupt for detecting card insert/remove events */
95 err = request_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, palmtx_detect_int,
96 IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
97 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
98 "SD/MMC card detect", data);
100 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
105 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
109 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
113 printk(KERN_DEBUG "%s: irq registered\n", __func__);
118 gpio_free(GPIO_NR_PALMTX_SD_POWER);
120 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
124 static void palmtx_mci_exit(struct device *dev, void *data)
126 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
127 gpio_free(GPIO_NR_PALMTX_SD_POWER);
128 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
131 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
133 struct pxamci_platform_data *p_d = dev->platform_data;
134 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
137 static int palmtx_mci_get_ro(struct device *dev)
139 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
142 static struct pxamci_platform_data palmtx_mci_platform_data = {
143 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
144 .setpower = palmtx_mci_power,
145 .get_ro = palmtx_mci_get_ro,
146 .init = palmtx_mci_init,
147 .exit = palmtx_mci_exit,
150 /******************************************************************************
152 ******************************************************************************/
153 static unsigned int palmtx_matrix_keys[] = {
154 KEY(0, 0, KEY_POWER),
156 KEY(0, 2, KEY_ENTER),
165 KEY(3, 0, KEY_RIGHT),
170 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
171 .matrix_key_rows = 4,
172 .matrix_key_cols = 3,
173 .matrix_key_map = palmtx_matrix_keys,
174 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
176 .debounce_interval = 30,
179 /******************************************************************************
181 ******************************************************************************/
182 static struct gpio_keys_button palmtx_pxa_buttons[] = {
183 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
186 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
187 .buttons = palmtx_pxa_buttons,
188 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
191 static struct platform_device palmtx_pxa_keys = {
195 .platform_data = &palmtx_pxa_keys_data,
199 /******************************************************************************
201 ******************************************************************************/
202 static int palmtx_backlight_init(struct device *dev)
206 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
209 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
215 gpio_free(GPIO_NR_PALMTX_BL_POWER);
220 static int palmtx_backlight_notify(int brightness)
222 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
223 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
227 static void palmtx_backlight_exit(struct device *dev)
229 gpio_free(GPIO_NR_PALMTX_BL_POWER);
230 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
233 static struct platform_pwm_backlight_data palmtx_backlight_data = {
235 .max_brightness = PALMTX_MAX_INTENSITY,
236 .dft_brightness = PALMTX_MAX_INTENSITY,
237 .pwm_period_ns = PALMTX_PERIOD_NS,
238 .init = palmtx_backlight_init,
239 .notify = palmtx_backlight_notify,
240 .exit = palmtx_backlight_exit,
243 static struct platform_device palmtx_backlight = {
244 .name = "pwm-backlight",
246 .parent = &pxa27x_device_pwm0.dev,
247 .platform_data = &palmtx_backlight_data,
251 /******************************************************************************
253 ******************************************************************************/
254 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
256 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
257 pxa2xx_transceiver_mode(dev, mode);
260 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
261 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
262 .transceiver_mode = palmtx_irda_transceiver_mode,
265 /******************************************************************************
267 ******************************************************************************/
268 static void palmtx_udc_command(int cmd)
270 gpio_set_value(GPIO_NR_PALMTX_USB_POWER, !cmd);
272 gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP, !cmd);
275 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
276 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
277 .gpio_vbus_inverted = 1,
278 .udc_command = palmtx_udc_command,
281 /******************************************************************************
283 ******************************************************************************/
284 static struct pxafb_mode_info palmtx_lcd_modes[] = {
301 static struct pxafb_mach_info palmtx_lcd_screen = {
302 .modes = palmtx_lcd_modes,
303 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
304 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
307 /******************************************************************************
309 ******************************************************************************/
310 static struct platform_device *devices[] __initdata = {
311 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
317 static struct map_desc palmtx_io_desc[] __initdata = {
319 .virtual = PALMTX_PCMCIA_VIRT,
320 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
321 .length = PALMTX_PCMCIA_SIZE,
326 static void __init palmtx_map_io(void)
329 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
332 static void __init palmtx_init(void)
334 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
336 set_pxa_fb_info(&palmtx_lcd_screen);
337 pxa_set_mci_info(&palmtx_mci_platform_data);
338 pxa_set_udc_info(&palmtx_udc_info);
339 pxa_set_ac97_info(NULL);
340 pxa_set_ficp_info(&palmtx_ficp_platform_data);
341 pxa_set_keypad_info(&palmtx_keypad_platform_data);
343 platform_add_devices(devices, ARRAY_SIZE(devices));
346 MACHINE_START(PALMTX, "Palm T|X")
347 .phys_io = PALMTX_PHYS_IO_START,
348 .io_pg_offst = io_p2v(0x40000000),
349 .boot_params = 0xa0000100,
350 .map_io = palmtx_map_io,
351 .init_irq = pxa27x_init_irq,
353 .init_machine = palmtx_init