[ARM] 5153/1: Add support for PalmTX handheld computer
[linux-2.6/zen-sources.git] / arch / arm / mach-pxa / palmtx.c
blobae8973279c20de7fd0dbafdaf3a86c9c0f5c0385
1 /*
2 * Hardware definitions for PalmTX
4 * Author: Marek Vasut <marek.vasut@gmail.com>
6 * Based on work of:
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
10 * Michal Hrusecky
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>
42 #include "generic.h"
43 #include "devices.h"
45 /******************************************************************************
46 * Pin configuration
47 ******************************************************************************/
48 static unsigned long palmtx_pin_config[] __initdata = {
49 /* MMC */
50 GPIO32_MMC_CLK,
51 GPIO92_MMC_DAT_0,
52 GPIO109_MMC_DAT_1,
53 GPIO110_MMC_DAT_2,
54 GPIO111_MMC_DAT_3,
55 GPIO112_MMC_CMD,
57 /* AC97 */
58 GPIO28_AC97_BITCLK,
59 GPIO29_AC97_SDATA_IN_0,
60 GPIO30_AC97_SDATA_OUT,
61 GPIO31_AC97_SYNC,
63 /* IrDA */
64 GPIO46_FICP_RXD,
65 GPIO47_FICP_TXD,
67 /* PWM */
68 GPIO16_PWM0_OUT,
70 /* USB */
71 GPIO13_GPIO,
74 /******************************************************************************
75 * SD/MMC card controller
76 ******************************************************************************/
77 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
78 void *data)
80 int err = 0;
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);
87 if (err) {
88 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
89 __func__);
90 return err;
93 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
94 if (err)
95 goto pwr_err;
97 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
98 if (err)
99 goto ro_err;
101 printk(KERN_DEBUG "%s: irq registered\n", __func__);
103 return 0;
105 ro_err:
106 gpio_free(GPIO_NR_PALMTX_SD_POWER);
107 pwr_err:
108 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
109 return err;
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 /******************************************************************************
139 * GPIO keyboard
140 ******************************************************************************/
141 static unsigned int palmtx_matrix_keys[] = {
142 KEY(0, 0, KEY_POWER),
143 KEY(0, 1, KEY_F1),
144 KEY(0, 2, KEY_ENTER),
146 KEY(1, 0, KEY_F2),
147 KEY(1, 1, KEY_F3),
148 KEY(1, 2, KEY_F4),
150 KEY(2, 0, KEY_UP),
151 KEY(2, 2, KEY_DOWN),
153 KEY(3, 0, KEY_RIGHT),
154 KEY(3, 2, KEY_LEFT),
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 /******************************************************************************
168 * GPIO keys
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 = {
180 .name = "gpio-keys",
181 .id = -1,
182 .dev = {
183 .platform_data = &palmtx_pxa_keys_data,
187 /******************************************************************************
188 * Backlight
189 ******************************************************************************/
190 static int palmtx_backlight_init(struct device *dev)
192 int ret;
194 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
195 if (ret)
196 goto err;
197 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
198 if (ret)
199 goto err2;
201 return 0;
202 err2:
203 gpio_free(GPIO_NR_PALMTX_BL_POWER);
204 err:
205 return ret;
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);
212 return 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 = {
222 .pwm_id = 0,
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",
233 .dev = {
234 .parent = &pxa27x_device_pwm0.dev,
235 .platform_data = &palmtx_backlight_data,
239 /******************************************************************************
240 * IrDA
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 /******************************************************************************
254 * UDC
255 ******************************************************************************/
256 static void palmtx_udc_command(int cmd)
258 gpio_set_value(GPIO_NR_PALMTX_USB_POWER, !cmd);
259 udelay(50);
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 /******************************************************************************
270 * Framebuffer
271 ******************************************************************************/
272 static struct pxafb_mode_info palmtx_lcd_modes[] = {
274 .pixclock = 57692,
275 .xres = 320,
276 .yres = 480,
277 .bpp = 16,
279 .left_margin = 32,
280 .right_margin = 1,
281 .upper_margin = 7,
282 .lower_margin = 1,
284 .hsync_len = 4,
285 .vsync_len = 1,
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 /******************************************************************************
296 * Machine init
297 ******************************************************************************/
298 static struct platform_device *devices[] __initdata = {
299 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
300 &palmtx_pxa_keys,
301 #endif
302 &palmtx_backlight,
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,
310 .type = MT_DEVICE
314 static void __init palmtx_map_io(void)
316 pxa_map_io();
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,
340 .timer = &pxa_timer,
341 .init_machine = palmtx_init
342 MACHINE_END