[ARM] 4960/1: Rewrite tosa pin configuration to use MFP tables.
[linux-2.6/mini2440.git] / arch / arm / mach-pxa / tosa.c
blob7d35f9ef8567aafb6796261da7b8133a0d6664fb
1 /*
2 * Support for Sharp SL-C6000x PDAs
3 * Model: (Tosa)
5 * Copyright (c) 2005 Dirk Opfer
7 * Based on code written by Sharp/Lineo for 2.4 kernels
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/major.h>
19 #include <linux/fs.h>
20 #include <linux/interrupt.h>
21 #include <linux/mmc/host.h>
22 #include <linux/pm.h>
23 #include <linux/delay.h>
24 #include <linux/gpio_keys.h>
25 #include <linux/input.h>
27 #include <asm/setup.h>
28 #include <asm/memory.h>
29 #include <asm/mach-types.h>
30 #include <asm/hardware.h>
31 #include <asm/irq.h>
32 #include <asm/system.h>
33 #include <asm/arch/pxa-regs.h>
34 #include <asm/arch/pxa2xx-regs.h>
35 #include <asm/arch/mfp-pxa25x.h>
36 #include <asm/arch/irda.h>
37 #include <asm/arch/mmc.h>
38 #include <asm/arch/udc.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/irq.h>
43 #include <asm/arch/tosa.h>
45 #include <asm/hardware/scoop.h>
46 #include <asm/mach/sharpsl_param.h>
48 #include "generic.h"
49 #include "devices.h"
51 static unsigned long tosa_pin_config[] = {
52 GPIO78_nCS_2, /* Scoop */
53 GPIO80_nCS_4, /* tg6393xb */
54 GPIO33_nCS_5, /* Scoop */
56 // GPIO76 CARD_VCC_ON1
58 GPIO19_GPIO, /* Reset out */
59 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
61 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
62 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
63 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
64 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
65 GPIO20_GPIO, /* EAR_IN */
66 GPIO22_GPIO, /* On */
68 GPIO5_GPIO, /* USB_IN */
69 GPIO32_GPIO, /* Pen IRQ */
71 GPIO7_GPIO, /* Jacket Detect */
72 GPIO14_GPIO, /* BAT0_CRG */
73 GPIO12_GPIO, /* BAT1_CRG */
74 GPIO17_GPIO, /* BAT0_LOW */
75 GPIO84_GPIO, /* BAT1_LOW */
76 GPIO38_GPIO, /* BAT_LOCK */
78 GPIO11_3_6MHz,
79 GPIO15_GPIO, /* TC6393XB IRQ */
80 GPIO18_RDY,
81 GPIO27_GPIO, /* LCD Sync */
83 /* MMC */
84 GPIO6_MMC_CLK,
85 GPIO8_MMC_CS0,
86 GPIO9_GPIO, /* Detect */
87 // GPIO10 nSD_INT
89 /* CF */
90 GPIO13_GPIO, /* CD_IRQ */
91 GPIO21_GPIO, /* Main Slot IRQ */
92 GPIO36_GPIO, /* Jacket Slot IRQ */
93 GPIO48_nPOE,
94 GPIO49_nPWE,
95 GPIO50_nPIOR,
96 GPIO51_nPIOW,
97 GPIO52_nPCE_1,
98 GPIO53_nPCE_2,
99 GPIO54_nPSKTSEL,
100 GPIO55_nPREG,
101 GPIO56_nPWAIT,
102 GPIO57_nIOIS16,
104 /* AC97 */
105 GPIO31_AC97_SYNC,
106 GPIO30_AC97_SDATA_OUT,
107 GPIO28_AC97_BITCLK,
108 GPIO29_AC97_SDATA_IN_0,
109 // GPIO79 nAUD_IRQ
111 /* FFUART */
112 GPIO34_FFUART_RXD,
113 GPIO35_FFUART_CTS,
114 GPIO37_FFUART_DSR,
115 GPIO39_FFUART_TXD,
116 GPIO40_FFUART_DTR,
117 GPIO41_FFUART_RTS,
119 /* BTUART */
120 GPIO42_BTUART_RXD,
121 GPIO43_BTUART_TXD,
122 GPIO44_BTUART_CTS,
123 GPIO45_BTUART_RTS,
125 /* IrDA */
126 GPIO46_STUART_RXD,
127 GPIO47_STUART_TXD,
129 /* Keybd */
130 GPIO58_GPIO,
131 GPIO59_GPIO,
132 GPIO60_GPIO,
133 GPIO61_GPIO,
134 GPIO62_GPIO,
135 GPIO63_GPIO,
136 GPIO64_GPIO,
137 GPIO65_GPIO,
138 GPIO66_GPIO,
139 GPIO67_GPIO,
140 GPIO68_GPIO,
141 GPIO69_GPIO,
142 GPIO70_GPIO,
143 GPIO71_GPIO,
144 GPIO72_GPIO,
145 GPIO73_GPIO,
146 GPIO74_GPIO,
147 GPIO75_GPIO,
149 /* SPI */
150 GPIO81_SSP2_CLK_OUT,
151 GPIO82_SSP2_FRM_OUT,
152 GPIO83_SSP2_TXD,
156 * SCOOP Device
158 static struct resource tosa_scoop_resources[] = {
159 [0] = {
160 .start = TOSA_CF_PHYS,
161 .end = TOSA_CF_PHYS + 0xfff,
162 .flags = IORESOURCE_MEM,
166 static struct scoop_config tosa_scoop_setup = {
167 .io_dir = TOSA_SCOOP_IO_DIR,
168 .io_out = TOSA_SCOOP_IO_OUT,
172 struct platform_device tosascoop_device = {
173 .name = "sharp-scoop",
174 .id = 0,
175 .dev = {
176 .platform_data = &tosa_scoop_setup,
178 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
179 .resource = tosa_scoop_resources,
184 * SCOOP Device Jacket
186 static struct resource tosa_scoop_jc_resources[] = {
187 [0] = {
188 .start = TOSA_SCOOP_PHYS + 0x40,
189 .end = TOSA_SCOOP_PHYS + 0xfff,
190 .flags = IORESOURCE_MEM,
194 static struct scoop_config tosa_scoop_jc_setup = {
195 .io_dir = TOSA_SCOOP_JC_IO_DIR,
196 .io_out = TOSA_SCOOP_JC_IO_OUT,
199 struct platform_device tosascoop_jc_device = {
200 .name = "sharp-scoop",
201 .id = 1,
202 .dev = {
203 .platform_data = &tosa_scoop_jc_setup,
204 .parent = &tosascoop_device.dev,
206 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
207 .resource = tosa_scoop_jc_resources,
211 * PCMCIA
213 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
215 .dev = &tosascoop_device.dev,
216 .irq = TOSA_IRQ_GPIO_CF_IRQ,
217 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
218 .cd_irq_str = "PCMCIA0 CD",
220 .dev = &tosascoop_jc_device.dev,
221 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
222 .cd_irq = -1,
226 static struct scoop_pcmcia_config tosa_pcmcia_config = {
227 .devs = &tosa_pcmcia_scoop[0],
228 .num_devs = 2,
232 * USB Device Controller
234 static void tosa_udc_command(int cmd)
236 switch(cmd) {
237 case PXA2XX_UDC_CMD_CONNECT:
238 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
239 break;
240 case PXA2XX_UDC_CMD_DISCONNECT:
241 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
242 break;
246 static struct pxa2xx_udc_mach_info udc_info __initdata = {
247 .udc_command = tosa_udc_command,
248 .gpio_vbus = TOSA_GPIO_USB_IN,
249 .gpio_vbus_inverted = 1,
253 * MMC/SD Device
255 static struct pxamci_platform_data tosa_mci_platform_data;
257 static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
259 int err;
261 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
263 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
264 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
265 "MMC/SD card detect", data);
266 if (err)
267 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
269 return err;
272 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
274 struct pxamci_platform_data* p_d = dev->platform_data;
276 if (( 1 << vdd) & p_d->ocr_mask) {
277 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
278 } else {
279 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
283 static int tosa_mci_get_ro(struct device *dev)
285 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
288 static void tosa_mci_exit(struct device *dev, void *data)
290 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
293 static struct pxamci_platform_data tosa_mci_platform_data = {
294 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
295 .init = tosa_mci_init,
296 .get_ro = tosa_mci_get_ro,
297 .setpower = tosa_mci_setpower,
298 .exit = tosa_mci_exit,
302 * Irda
304 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
306 if (mode & IR_OFF) {
307 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
308 } else {
309 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
313 static struct pxaficp_platform_data tosa_ficp_platform_data = {
314 .transceiver_cap = IR_SIRMODE | IR_OFF,
315 .transceiver_mode = tosa_irda_transceiver_mode,
319 * Tosa Keyboard
321 static struct platform_device tosakbd_device = {
322 .name = "tosa-keyboard",
323 .id = -1,
326 static struct gpio_keys_button tosa_gpio_keys[] = {
328 .type = EV_PWR,
329 .code = KEY_SUSPEND,
330 .gpio = TOSA_GPIO_ON_KEY,
331 .desc = "On key",
332 .wakeup = 1,
333 .active_low = 1,
336 .type = EV_KEY,
337 .code = TOSA_KEY_RECORD,
338 .gpio = TOSA_GPIO_RECORD_BTN,
339 .desc = "Record Button",
340 .wakeup = 1,
341 .active_low = 1,
344 .type = EV_KEY,
345 .code = TOSA_KEY_SYNC,
346 .gpio = TOSA_GPIO_SYNC,
347 .desc = "Sync Button",
348 .wakeup = 1,
349 .active_low = 1,
353 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
354 .buttons = tosa_gpio_keys,
355 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
358 static struct platform_device tosa_gpio_keys_device = {
359 .name = "gpio-keys",
360 .id = -1,
361 .dev = {
362 .platform_data = &tosa_gpio_keys_platform_data,
367 * Tosa LEDs
369 static struct platform_device tosaled_device = {
370 .name = "tosa-led",
371 .id = -1,
374 static struct platform_device *devices[] __initdata = {
375 &tosascoop_device,
376 &tosascoop_jc_device,
377 &tosakbd_device,
378 &tosa_gpio_keys_device,
379 &tosaled_device,
382 static void tosa_poweroff(void)
384 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
386 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT);
387 GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET);
389 mdelay(1000);
390 arm_machine_restart('h');
393 static void tosa_restart(char mode)
395 /* Bootloader magic for a reboot */
396 if((MSC0 & 0xffff0000) == 0x7ff00000)
397 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
399 tosa_poweroff();
402 static void __init tosa_init(void)
404 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
405 gpio_set_wake(MFP_PIN_GPIO1, 1);
406 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
408 pm_power_off = tosa_poweroff;
409 arm_pm_restart = tosa_restart;
411 PCFR |= PCFR_OPDE;
413 /* enable batt_fault */
414 PMCR = 0x01;
416 pxa_set_mci_info(&tosa_mci_platform_data);
417 pxa_set_udc_info(&udc_info);
418 pxa_set_ficp_info(&tosa_ficp_platform_data);
419 platform_scoop_config = &tosa_pcmcia_config;
421 platform_add_devices(devices, ARRAY_SIZE(devices));
424 static void __init fixup_tosa(struct machine_desc *desc,
425 struct tag *tags, char **cmdline, struct meminfo *mi)
427 sharpsl_save_param();
428 mi->nr_banks=1;
429 mi->bank[0].start = 0xa0000000;
430 mi->bank[0].node = 0;
431 mi->bank[0].size = (64*1024*1024);
434 MACHINE_START(TOSA, "SHARP Tosa")
435 .phys_io = 0x40000000,
436 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
437 .fixup = fixup_tosa,
438 .map_io = pxa_map_io,
439 .init_irq = pxa25x_init_irq,
440 .init_machine = tosa_init,
441 .timer = &pxa_timer,
442 MACHINE_END