[ARM] 3455/1: ARM: OMAP: 7/8 Misc updates, take 2
[deliverable/linux.git] / 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/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
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/tosa.h>
38
39 #include <asm/hardware/scoop.h>
40 #include <asm/mach/sharpsl_param.h>
41
42 #include "generic.h"
43
44
45 /*
46 * SCOOP Device
47 */
48 static struct resource tosa_scoop_resources[] = {
49 [0] = {
50 .start = TOSA_CF_PHYS,
51 .end = TOSA_CF_PHYS + 0xfff,
52 .flags = IORESOURCE_MEM,
53 },
54 };
55
56 static struct scoop_config tosa_scoop_setup = {
57 .io_dir = TOSA_SCOOP_IO_DIR,
58 .io_out = TOSA_SCOOP_IO_OUT,
59
60 };
61
62 struct platform_device tosascoop_device = {
63 .name = "sharp-scoop",
64 .id = 0,
65 .dev = {
66 .platform_data = &tosa_scoop_setup,
67 },
68 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
69 .resource = tosa_scoop_resources,
70 };
71
72
73 /*
74 * SCOOP Device Jacket
75 */
76 static struct resource tosa_scoop_jc_resources[] = {
77 [0] = {
78 .start = TOSA_SCOOP_PHYS + 0x40,
79 .end = TOSA_SCOOP_PHYS + 0xfff,
80 .flags = IORESOURCE_MEM,
81 },
82 };
83
84 static struct scoop_config tosa_scoop_jc_setup = {
85 .io_dir = TOSA_SCOOP_JC_IO_DIR,
86 .io_out = TOSA_SCOOP_JC_IO_OUT,
87 };
88
89 struct platform_device tosascoop_jc_device = {
90 .name = "sharp-scoop",
91 .id = 1,
92 .dev = {
93 .platform_data = &tosa_scoop_jc_setup,
94 .parent = &tosascoop_device.dev,
95 },
96 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
97 .resource = tosa_scoop_jc_resources,
98 };
99
100 /*
101 * PCMCIA
102 */
103 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
104 {
105 .dev = &tosascoop_device.dev,
106 .irq = TOSA_IRQ_GPIO_CF_IRQ,
107 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
108 .cd_irq_str = "PCMCIA0 CD",
109 },{
110 .dev = &tosascoop_jc_device.dev,
111 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
112 .cd_irq = -1,
113 },
114 };
115
116 static void tosa_pcmcia_init(void)
117 {
118 /* Setup default state of GPIO outputs
119 before we enable them as outputs. */
120 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
121 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
122 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
123 GPIO_bit(GPIO53_nPCE_2);
124
125 pxa_gpio_mode(GPIO48_nPOE_MD);
126 pxa_gpio_mode(GPIO49_nPWE_MD);
127 pxa_gpio_mode(GPIO50_nPIOR_MD);
128 pxa_gpio_mode(GPIO51_nPIOW_MD);
129 pxa_gpio_mode(GPIO55_nPREG_MD);
130 pxa_gpio_mode(GPIO56_nPWAIT_MD);
131 pxa_gpio_mode(GPIO57_nIOIS16_MD);
132 pxa_gpio_mode(GPIO52_nPCE_1_MD);
133 pxa_gpio_mode(GPIO53_nPCE_2_MD);
134 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
135 }
136
137 static struct scoop_pcmcia_config tosa_pcmcia_config = {
138 .devs = &tosa_pcmcia_scoop[0],
139 .num_devs = 2,
140 .pcmcia_init = tosa_pcmcia_init,
141 };
142
143 /*
144 * USB Device Controller
145 */
146 static void tosa_udc_command(int cmd)
147 {
148 switch(cmd) {
149 case PXA2XX_UDC_CMD_CONNECT:
150 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
151 break;
152 case PXA2XX_UDC_CMD_DISCONNECT:
153 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
154 break;
155 }
156 }
157
158 static int tosa_udc_is_connected(void)
159 {
160 return ((GPLR(TOSA_GPIO_USB_IN) & GPIO_bit(TOSA_GPIO_USB_IN)) == 0);
161 }
162
163
164 static struct pxa2xx_udc_mach_info udc_info __initdata = {
165 .udc_command = tosa_udc_command,
166 .udc_is_connected = tosa_udc_is_connected,
167 };
168
169 /*
170 * MMC/SD Device
171 */
172 static struct pxamci_platform_data tosa_mci_platform_data;
173
174 static int tosa_mci_init(struct device *dev, irqreturn_t (*tosa_detect_int)(int, void *, struct pt_regs *), void *data)
175 {
176 int err;
177
178 /* setup GPIO for PXA25x MMC controller */
179 pxa_gpio_mode(GPIO6_MMCCLK_MD);
180 pxa_gpio_mode(GPIO8_MMCCS0_MD);
181 pxa_gpio_mode(TOSA_GPIO_nSD_DETECT | GPIO_IN);
182
183 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
184
185 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int, SA_INTERRUPT,
186 "MMC/SD card detect", data);
187 if (err) {
188 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
189 return -1;
190 }
191
192 set_irq_type(TOSA_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
193
194 return 0;
195 }
196
197 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
198 {
199 struct pxamci_platform_data* p_d = dev->platform_data;
200
201 if (( 1 << vdd) & p_d->ocr_mask) {
202 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
203 } else {
204 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
205 }
206 }
207
208 static int tosa_mci_get_ro(struct device *dev)
209 {
210 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
211 }
212
213 static void tosa_mci_exit(struct device *dev, void *data)
214 {
215 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
216 }
217
218 static struct pxamci_platform_data tosa_mci_platform_data = {
219 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
220 .init = tosa_mci_init,
221 .get_ro = tosa_mci_get_ro,
222 .setpower = tosa_mci_setpower,
223 .exit = tosa_mci_exit,
224 };
225
226 /*
227 * Irda
228 */
229 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
230 {
231 if (mode & IR_OFF) {
232 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
233 pxa_gpio_mode(GPIO47_STTXD|GPIO_DFLT_LOW);
234 pxa_gpio_mode(GPIO47_STTXD|GPIO_OUT);
235 } else {
236 pxa_gpio_mode(GPIO47_STTXD_MD);
237 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
238 }
239 }
240
241 static struct pxaficp_platform_data tosa_ficp_platform_data = {
242 .transceiver_cap = IR_SIRMODE | IR_OFF,
243 .transceiver_mode = tosa_irda_transceiver_mode,
244 };
245
246 /*
247 * Tosa Keyboard
248 */
249 static struct platform_device tosakbd_device = {
250 .name = "tosa-keyboard",
251 .id = -1,
252 };
253
254 /*
255 * Tosa LEDs
256 */
257 static struct platform_device tosaled_device = {
258 .name = "tosa-led",
259 .id = -1,
260 };
261
262 static struct platform_device *devices[] __initdata = {
263 &tosascoop_device,
264 &tosascoop_jc_device,
265 &tosakbd_device,
266 &tosaled_device,
267 };
268
269 static void __init tosa_init(void)
270 {
271 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN);
272 pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN);
273 pxa_gpio_mode(TOSA_GPIO_USB_IN | GPIO_IN);
274
275 /* setup sleep mode values */
276 PWER = 0x00000002;
277 PFER = 0x00000000;
278 PRER = 0x00000002;
279 PGSR0 = 0x00000000;
280 PGSR1 = 0x00FF0002;
281 PGSR2 = 0x00014000;
282 PCFR |= PCFR_OPDE;
283
284 /* enable batt_fault */
285 PMCR = 0x01;
286
287 pxa_set_mci_info(&tosa_mci_platform_data);
288 pxa_set_udc_info(&udc_info);
289 pxa_set_ficp_info(&tosa_ficp_platform_data);
290 platform_scoop_config = &tosa_pcmcia_config;
291
292 platform_add_devices(devices, ARRAY_SIZE(devices));
293 }
294
295 static void __init fixup_tosa(struct machine_desc *desc,
296 struct tag *tags, char **cmdline, struct meminfo *mi)
297 {
298 sharpsl_save_param();
299 mi->nr_banks=1;
300 mi->bank[0].start = 0xa0000000;
301 mi->bank[0].node = 0;
302 mi->bank[0].size = (64*1024*1024);
303 }
304
305 MACHINE_START(TOSA, "SHARP Tosa")
306 .phys_io = 0x40000000,
307 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
308 .fixup = fixup_tosa,
309 .map_io = pxa_map_io,
310 .init_irq = pxa_init_irq,
311 .init_machine = tosa_init,
312 .timer = &pxa_timer,
313 MACHINE_END
This page took 0.036023 seconds and 5 git commands to generate.