]> err.no Git - linux-2.6/blob - arch/arm/mach-pxa/tosa.c
f3e01891e8510aaa328d384bc5945136889c2cbf
[linux-2.6] / arch / arm / mach-pxa / tosa.c
1 /*
2  *  Support for Sharp SL-C6000x PDAs
3  *  Model: (Tosa)
4  *
5  *  Copyright (c) 2005 Dirk Opfer
6  *
7  *      Based on code written by Sharp/Lineo for 2.4 kernels
8  *
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.
12  *
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/device.h>
18 #include <linux/major.h>
19 #include <linux/fs.h>
20 #include <linux/interrupt.h>
21 #include <linux/mmc/host.h>
22
23 #include <asm/setup.h>
24 #include <asm/memory.h>
25 #include <asm/mach-types.h>
26 #include <asm/hardware.h>
27 #include <asm/irq.h>
28 #include <asm/arch/irda.h>
29 #include <asm/arch/mmc.h>
30 #include <asm/arch/udc.h>
31
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/irq.h>
35
36 #include <asm/arch/pxa-regs.h>
37 #include <asm/arch/irq.h>
38 #include <asm/arch/tosa.h>
39
40 #include <asm/hardware/scoop.h>
41 #include <asm/mach/sharpsl_param.h>
42
43 #include "generic.h"
44
45
46 /*
47  * SCOOP Device
48  */
49 static struct resource tosa_scoop_resources[] = {
50         [0] = {
51                 .start  = TOSA_CF_PHYS,
52                 .end    = TOSA_CF_PHYS + 0xfff,
53                 .flags  = IORESOURCE_MEM,
54         },
55 };
56
57 static struct scoop_config tosa_scoop_setup = {
58         .io_dir         = TOSA_SCOOP_IO_DIR,
59         .io_out         = TOSA_SCOOP_IO_OUT,
60
61 };
62
63 struct platform_device tosascoop_device = {
64         .name           = "sharp-scoop",
65         .id             = 0,
66         .dev            = {
67                 .platform_data  = &tosa_scoop_setup,
68         },
69         .num_resources  = ARRAY_SIZE(tosa_scoop_resources),
70         .resource       = tosa_scoop_resources,
71 };
72
73
74 /*
75  * SCOOP Device Jacket
76  */
77 static struct resource tosa_scoop_jc_resources[] = {
78         [0] = {
79                 .start          = TOSA_SCOOP_PHYS + 0x40,
80                 .end            = TOSA_SCOOP_PHYS + 0xfff,
81                 .flags          = IORESOURCE_MEM,
82         },
83 };
84
85 static struct scoop_config tosa_scoop_jc_setup = {
86         .io_dir         = TOSA_SCOOP_JC_IO_DIR,
87         .io_out         = TOSA_SCOOP_JC_IO_OUT,
88 };
89
90 struct platform_device tosascoop_jc_device = {
91         .name           = "sharp-scoop",
92         .id             = 1,
93         .dev            = {
94                 .platform_data  = &tosa_scoop_jc_setup,
95                 .parent         = &tosascoop_device.dev,
96         },
97         .num_resources  = ARRAY_SIZE(tosa_scoop_jc_resources),
98         .resource       = tosa_scoop_jc_resources,
99 };
100
101 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
102 {
103         .dev        = &tosascoop_device.dev,
104         .irq        = TOSA_IRQ_GPIO_CF_IRQ,
105         .cd_irq     = TOSA_IRQ_GPIO_CF_CD,
106         .cd_irq_str = "PCMCIA0 CD",
107 },{
108         .dev        = &tosascoop_jc_device.dev,
109         .irq        = TOSA_IRQ_GPIO_JC_CF_IRQ,
110         .cd_irq     = -1,
111 },
112 };
113
114 /*
115  * USB Device Controller
116  */
117 static void tosa_udc_command(int cmd)
118 {
119         switch(cmd)     {
120                 case PXA2XX_UDC_CMD_CONNECT:
121                         set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
122                         break;
123                 case PXA2XX_UDC_CMD_DISCONNECT:
124                         reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
125                         break;
126         }
127 }
128
129 static int tosa_udc_is_connected(void)
130 {
131         return ((GPLR(TOSA_GPIO_USB_IN) & GPIO_bit(TOSA_GPIO_USB_IN)) == 0);
132 }
133
134
135 static struct pxa2xx_udc_mach_info udc_info __initdata = {
136         .udc_command            = tosa_udc_command,
137         .udc_is_connected       = tosa_udc_is_connected,
138 };
139
140 /*
141  * MMC/SD Device
142  */
143 static struct pxamci_platform_data tosa_mci_platform_data;
144
145 static int tosa_mci_init(struct device *dev, irqreturn_t (*tosa_detect_int)(int, void *, struct pt_regs *), void *data)
146 {
147         int err;
148
149         /* setup GPIO for PXA25x MMC controller */
150         pxa_gpio_mode(GPIO6_MMCCLK_MD);
151         pxa_gpio_mode(GPIO8_MMCCS0_MD);
152         pxa_gpio_mode(TOSA_GPIO_nSD_DETECT | GPIO_IN);
153
154         tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
155
156         err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int, SA_INTERRUPT,
157                                 "MMC/SD card detect", data);
158         if (err) {
159                 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
160                 return -1;
161         }
162
163         set_irq_type(TOSA_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
164
165         return 0;
166 }
167
168 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
169 {
170         struct pxamci_platform_data* p_d = dev->platform_data;
171
172         if (( 1 << vdd) & p_d->ocr_mask) {
173                 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
174         } else {
175                 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
176         }
177 }
178
179 static int tosa_mci_get_ro(struct device *dev)
180 {
181         return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
182 }
183
184 static void tosa_mci_exit(struct device *dev, void *data)
185 {
186         free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
187 }
188
189 static struct pxamci_platform_data tosa_mci_platform_data = {
190         .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
191         .init           = tosa_mci_init,
192         .get_ro         = tosa_mci_get_ro,
193         .setpower       = tosa_mci_setpower,
194         .exit           = tosa_mci_exit,
195 };
196
197 /*
198  * Irda
199  */
200 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
201 {
202         if (mode & IR_OFF) {
203                 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
204                 pxa_gpio_mode(GPIO47_STTXD|GPIO_DFLT_LOW);
205                 pxa_gpio_mode(GPIO47_STTXD|GPIO_OUT);
206         } else {
207                 pxa_gpio_mode(GPIO47_STTXD_MD);
208                 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
209         }
210 }
211
212 static struct pxaficp_platform_data tosa_ficp_platform_data = {
213         .transceiver_cap  = IR_SIRMODE | IR_OFF,
214         .transceiver_mode = tosa_irda_transceiver_mode,
215 };
216
217 /*
218  * Tosa Keyboard
219  */
220 static struct platform_device tosakbd_device = {
221         .name           = "tosa-keyboard",
222         .id             = -1,
223 };
224
225 static struct platform_device *devices[] __initdata = {
226         &tosascoop_device,
227         &tosascoop_jc_device,
228         &tosakbd_device,
229 };
230
231 static void __init tosa_init(void)
232 {
233         pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN);
234         pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN);
235         pxa_gpio_mode(TOSA_GPIO_USB_IN | GPIO_IN);
236
237         /* setup sleep mode values */
238         PWER  = 0x00000002;
239         PFER  = 0x00000000;
240         PRER  = 0x00000002;
241         PGSR0 = 0x00000000;
242         PGSR1 = 0x00FF0002;
243         PGSR2 = 0x00014000;
244         PCFR |= PCFR_OPDE;
245
246         /* enable batt_fault */
247         PMCR = 0x01;
248
249         pxa_set_mci_info(&tosa_mci_platform_data);
250         pxa_set_udc_info(&udc_info);
251         pxa_set_ficp_info(&tosa_ficp_platform_data);
252         platform_add_devices(devices, ARRAY_SIZE(devices));
253
254         scoop_num = 2;
255         scoop_devs = &tosa_pcmcia_scoop[0];
256 }
257
258 static void __init fixup_tosa(struct machine_desc *desc,
259                 struct tag *tags, char **cmdline, struct meminfo *mi)
260 {
261         sharpsl_save_param();
262         mi->nr_banks=1;
263         mi->bank[0].start = 0xa0000000;
264         mi->bank[0].node = 0;
265         mi->bank[0].size = (64*1024*1024);
266 }
267
268 MACHINE_START(TOSA, "SHARP Tosa")
269         .phys_ram       = 0xa0000000,
270         .phys_io        = 0x40000000,
271         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
272         .fixup          = fixup_tosa,
273         .map_io         = pxa_map_io,
274         .init_irq       = pxa_init_irq,
275         .init_machine   = tosa_init,
276         .timer          = &pxa_timer,
277 MACHINE_END