]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-pxa/palmtx.c
[ARM] 5154/1: PalmTX PCMCIA
[linux-2.6-omap-h63xx.git] / arch / arm / mach-pxa / palmtx.c
1 /*
2  * Hardware definitions for PalmTX
3  *
4  * Author:     Marek Vasut <marek.vasut@gmail.com>
5  *
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
11  *
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.
15  *
16  * (find more info at www.hackndev.com)
17  *
18  */
19
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>
27
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31
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>
41
42 #include "generic.h"
43 #include "devices.h"
44
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,
56
57         /* AC97 */
58         GPIO28_AC97_BITCLK,
59         GPIO29_AC97_SDATA_IN_0,
60         GPIO30_AC97_SDATA_OUT,
61         GPIO31_AC97_SYNC,
62
63         /* IrDA */
64         GPIO46_FICP_RXD,
65         GPIO47_FICP_TXD,
66
67         /* PWM */
68         GPIO16_PWM0_OUT,
69
70         /* USB */
71         GPIO13_GPIO,
72
73         /* PCMCIA */
74         GPIO48_nPOE,
75         GPIO49_nPWE,
76         GPIO50_nPIOR,
77         GPIO51_nPIOW,
78         GPIO85_nPCE_1,
79         GPIO54_nPCE_2,
80         GPIO79_PSKTSEL,
81         GPIO55_nPREG,
82         GPIO56_nPWAIT,
83         GPIO57_nIOIS16,
84 };
85
86 /******************************************************************************
87  * SD/MMC card controller
88  ******************************************************************************/
89 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
90                                 void *data)
91 {
92         int err = 0;
93
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);
99         if (err) {
100                 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
101                                 __func__);
102                 return err;
103         }
104
105         err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
106         if (err)
107                 goto pwr_err;
108
109         err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
110         if (err)
111                 goto ro_err;
112
113         printk(KERN_DEBUG "%s: irq registered\n", __func__);
114
115         return 0;
116
117 ro_err:
118         gpio_free(GPIO_NR_PALMTX_SD_POWER);
119 pwr_err:
120         free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
121         return err;
122 }
123
124 static void palmtx_mci_exit(struct device *dev, void *data)
125 {
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);
129 }
130
131 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
132 {
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));
135 }
136
137 static int palmtx_mci_get_ro(struct device *dev)
138 {
139         return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
140 }
141
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,
148 };
149
150 /******************************************************************************
151  * GPIO keyboard
152  ******************************************************************************/
153 static unsigned int palmtx_matrix_keys[] = {
154         KEY(0, 0, KEY_POWER),
155         KEY(0, 1, KEY_F1),
156         KEY(0, 2, KEY_ENTER),
157
158         KEY(1, 0, KEY_F2),
159         KEY(1, 1, KEY_F3),
160         KEY(1, 2, KEY_F4),
161
162         KEY(2, 0, KEY_UP),
163         KEY(2, 2, KEY_DOWN),
164
165         KEY(3, 0, KEY_RIGHT),
166         KEY(3, 2, KEY_LEFT),
167
168 };
169
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),
175
176         .debounce_interval      = 30,
177 };
178
179 /******************************************************************************
180  * GPIO keys
181  ******************************************************************************/
182 static struct gpio_keys_button palmtx_pxa_buttons[] = {
183         {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
184 };
185
186 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
187         .buttons        = palmtx_pxa_buttons,
188         .nbuttons       = ARRAY_SIZE(palmtx_pxa_buttons),
189 };
190
191 static struct platform_device palmtx_pxa_keys = {
192         .name   = "gpio-keys",
193         .id     = -1,
194         .dev    = {
195                 .platform_data = &palmtx_pxa_keys_data,
196         },
197 };
198
199 /******************************************************************************
200  * Backlight
201  ******************************************************************************/
202 static int palmtx_backlight_init(struct device *dev)
203 {
204         int ret;
205
206         ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
207         if (ret)
208                 goto err;
209         ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
210         if (ret)
211                 goto err2;
212
213         return 0;
214 err2:
215         gpio_free(GPIO_NR_PALMTX_BL_POWER);
216 err:
217         return ret;
218 }
219
220 static int palmtx_backlight_notify(int brightness)
221 {
222         gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
223         gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
224         return brightness;
225 }
226
227 static void palmtx_backlight_exit(struct device *dev)
228 {
229         gpio_free(GPIO_NR_PALMTX_BL_POWER);
230         gpio_free(GPIO_NR_PALMTX_LCD_POWER);
231 }
232
233 static struct platform_pwm_backlight_data palmtx_backlight_data = {
234         .pwm_id         = 0,
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,
241 };
242
243 static struct platform_device palmtx_backlight = {
244         .name   = "pwm-backlight",
245         .dev    = {
246                 .parent         = &pxa27x_device_pwm0.dev,
247                 .platform_data  = &palmtx_backlight_data,
248         },
249 };
250
251 /******************************************************************************
252  * IrDA
253  ******************************************************************************/
254 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
255 {
256         gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
257         pxa2xx_transceiver_mode(dev, mode);
258 }
259
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,
263 };
264
265 /******************************************************************************
266  * UDC
267  ******************************************************************************/
268 static void palmtx_udc_command(int cmd)
269 {
270         gpio_set_value(GPIO_NR_PALMTX_USB_POWER, !cmd);
271         udelay(50);
272         gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP, !cmd);
273 }
274
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,
279 };
280
281 /******************************************************************************
282  * Framebuffer
283  ******************************************************************************/
284 static struct pxafb_mode_info palmtx_lcd_modes[] = {
285 {
286         .pixclock       = 57692,
287         .xres           = 320,
288         .yres           = 480,
289         .bpp            = 16,
290
291         .left_margin    = 32,
292         .right_margin   = 1,
293         .upper_margin   = 7,
294         .lower_margin   = 1,
295
296         .hsync_len      = 4,
297         .vsync_len      = 1,
298 },
299 };
300
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,
305 };
306
307 /******************************************************************************
308  * Machine init
309  ******************************************************************************/
310 static struct platform_device *devices[] __initdata = {
311 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
312         &palmtx_pxa_keys,
313 #endif
314         &palmtx_backlight,
315 };
316
317 static struct map_desc palmtx_io_desc[] __initdata = {
318 {
319         .virtual        = PALMTX_PCMCIA_VIRT,
320         .pfn            = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
321         .length         = PALMTX_PCMCIA_SIZE,
322         .type           = MT_DEVICE
323 },
324 };
325
326 static void __init palmtx_map_io(void)
327 {
328         pxa_map_io();
329         iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
330 }
331
332 static void __init palmtx_init(void)
333 {
334         pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
335
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);
342
343         platform_add_devices(devices, ARRAY_SIZE(devices));
344 }
345
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,
352         .timer          = &pxa_timer,
353         .init_machine   = palmtx_init
354 MACHINE_END