[ARM] pxa: fix mci_init functions returning -1
[deliverable/linux.git] / arch / arm / mach-pxa / poodle.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/arm/mach-pxa/poodle.c
3 *
4 * Support for the SHARP Poodle Board.
5 *
6 * Based on:
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
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 * Change Log
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
d052d1be 19#include <linux/platform_device.h>
1da177e4 20#include <linux/fb.h>
74617fb6 21#include <linux/pm.h>
88660351 22#include <linux/delay.h>
1da177e4
LT
23
24#include <asm/hardware.h>
25#include <asm/mach-types.h>
26#include <asm/irq.h>
27#include <asm/setup.h>
74617fb6 28#include <asm/system.h>
1da177e4
LT
29
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33
34#include <asm/arch/pxa-regs.h>
13b9d47e
RP
35#include <asm/arch/mmc.h>
36#include <asm/arch/udc.h>
8e4b8715 37#include <asm/arch/irda.h>
1da177e4
LT
38#include <asm/arch/poodle.h>
39#include <asm/arch/pxafb.h>
faed5684
RP
40#include <asm/arch/sharpsl.h>
41#include <asm/arch/ssp.h>
1da177e4
LT
42
43#include <asm/hardware/scoop.h>
44#include <asm/hardware/locomo.h>
45#include <asm/mach/sharpsl_param.h>
46
47#include "generic.h"
46c41e62 48#include "devices.h"
faed5684 49#include "sharpsl.h"
1da177e4
LT
50
51static struct resource poodle_scoop_resources[] = {
52 [0] = {
53 .start = 0x10800000,
54 .end = 0x10800fff,
55 .flags = IORESOURCE_MEM,
56 },
57};
58
59static struct scoop_config poodle_scoop_setup = {
60 .io_dir = POODLE_SCOOP_IO_DIR,
61 .io_out = POODLE_SCOOP_IO_OUT,
62};
63
64struct platform_device poodle_scoop_device = {
65 .name = "sharp-scoop",
66 .id = -1,
67 .dev = {
68 .platform_data = &poodle_scoop_setup,
69 },
70 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
71 .resource = poodle_scoop_resources,
72};
73
a63ae442
RP
74static void poodle_pcmcia_init(void)
75{
76 /* Setup default state of GPIO outputs
77 before we enable them as outputs. */
78 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
79 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
80 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
81 GPIO_bit(GPIO53_nPCE_2);
82
83 pxa_gpio_mode(GPIO48_nPOE_MD);
84 pxa_gpio_mode(GPIO49_nPWE_MD);
85 pxa_gpio_mode(GPIO50_nPIOR_MD);
86 pxa_gpio_mode(GPIO51_nPIOW_MD);
87 pxa_gpio_mode(GPIO55_nPREG_MD);
88 pxa_gpio_mode(GPIO56_nPWAIT_MD);
89 pxa_gpio_mode(GPIO57_nIOIS16_MD);
90 pxa_gpio_mode(GPIO52_nPCE_1_MD);
91 pxa_gpio_mode(GPIO53_nPCE_2_MD);
92 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
93}
94
0ce7625f
RP
95static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
96{
97 .dev = &poodle_scoop_device.dev,
98 .irq = POODLE_IRQ_GPIO_CF_IRQ,
99 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
100 .cd_irq_str = "PCMCIA0 CD",
101},
102};
103
a63ae442
RP
104static struct scoop_pcmcia_config poodle_pcmcia_config = {
105 .devs = &poodle_pcmcia_scoop[0],
106 .num_devs = 1,
107 .pcmcia_init = poodle_pcmcia_init,
108};
109
110EXPORT_SYMBOL(poodle_scoop_device);
111
1da177e4
LT
112
113/* LoCoMo device */
114static struct resource locomo_resources[] = {
115 [0] = {
116 .start = 0x10000000,
117 .end = 0x10001fff,
118 .flags = IORESOURCE_MEM,
119 },
120 [1] = {
121 .start = IRQ_GPIO(10),
122 .end = IRQ_GPIO(10),
123 .flags = IORESOURCE_IRQ,
124 },
125};
126
faed5684 127struct platform_device poodle_locomo_device = {
1da177e4
LT
128 .name = "locomo",
129 .id = 0,
130 .num_resources = ARRAY_SIZE(locomo_resources),
131 .resource = locomo_resources,
132};
133
faed5684
RP
134EXPORT_SYMBOL(poodle_locomo_device);
135
136/*
137 * Poodle SSP Device
138 */
139
140struct platform_device poodle_ssp_device = {
141 .name = "corgi-ssp",
142 .id = -1,
143};
144
145struct corgissp_machinfo poodle_ssp_machinfo = {
146 .port = 1,
147 .cs_lcdcon = -1,
148 .cs_ads7846 = -1,
149 .cs_max1111 = -1,
150 .clk_lcdcon = 2,
151 .clk_ads7846 = 36,
152 .clk_max1111 = 2,
153};
154
155
156/*
157 * Poodle Touch Screen Device
158 */
159static struct resource poodlets_resources[] = {
160 [0] = {
161 .start = POODLE_IRQ_GPIO_TP_INT,
162 .end = POODLE_IRQ_GPIO_TP_INT,
163 .flags = IORESOURCE_IRQ,
164 },
165};
166
167static unsigned long poodle_get_hsync_len(void)
168{
169 return 0;
170}
171
172static void poodle_null_hsync(void)
173{
174}
175
176static struct corgits_machinfo poodle_ts_machinfo = {
177 .get_hsync_len = poodle_get_hsync_len,
178 .put_hsync = poodle_null_hsync,
179 .wait_hsync = poodle_null_hsync,
180};
181
182static struct platform_device poodle_ts_device = {
183 .name = "corgi-ts",
184 .dev = {
185 .platform_data = &poodle_ts_machinfo,
186 },
187 .id = -1,
188 .num_resources = ARRAY_SIZE(poodlets_resources),
189 .resource = poodlets_resources,
190};
191
13b9d47e
RP
192
193/*
194 * MMC/SD Device
195 *
196 * The card detect interrupt isn't debounced so we delay it by 250ms
197 * to give the card a chance to fully insert/eject.
198 */
199static struct pxamci_platform_data poodle_mci_platform_data;
200
40220c1a 201static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
13b9d47e
RP
202{
203 int err;
204
205 /* setup GPIO for PXA25x MMC controller */
206 pxa_gpio_mode(GPIO6_MMCCLK_MD);
207 pxa_gpio_mode(GPIO8_MMCCS0_MD);
208 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
88660351 209 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
13b9d47e 210 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
88660351 211 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
13b9d47e
RP
212
213 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
214
9ded96f2 215 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
52e405ea 216 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
9ded96f2 217 "MMC card detect", data);
2687bd38 218 if (err)
13b9d47e 219 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
13b9d47e 220
2687bd38 221 return err;
13b9d47e
RP
222}
223
224static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
225{
226 struct pxamci_platform_data* p_d = dev->platform_data;
227
88660351
RP
228 if (( 1 << vdd) & p_d->ocr_mask) {
229 GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
230 mdelay(2);
231 GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
232 } else {
233 GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
234 GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
235 }
236}
237
238static int poodle_mci_get_ro(struct device *dev)
239{
240 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
13b9d47e
RP
241}
242
88660351 243
13b9d47e
RP
244static void poodle_mci_exit(struct device *dev, void *data)
245{
246 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
247}
248
249static struct pxamci_platform_data poodle_mci_platform_data = {
250 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
251 .init = poodle_mci_init,
88660351 252 .get_ro = poodle_mci_get_ro,
13b9d47e
RP
253 .setpower = poodle_mci_setpower,
254 .exit = poodle_mci_exit,
255};
256
257
8e4b8715
RP
258/*
259 * Irda
260 */
261static void poodle_irda_transceiver_mode(struct device *dev, int mode)
262{
263 if (mode & IR_OFF) {
264 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
265 } else {
266 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
267 }
268}
269
270static struct pxaficp_platform_data poodle_ficp_platform_data = {
271 .transceiver_cap = IR_SIRMODE | IR_OFF,
272 .transceiver_mode = poodle_irda_transceiver_mode,
273};
274
275
13b9d47e
RP
276/*
277 * USB Device Controller
278 */
279static void poodle_udc_command(int cmd)
280{
281 switch(cmd) {
282 case PXA2XX_UDC_CMD_CONNECT:
283 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
284 break;
285 case PXA2XX_UDC_CMD_DISCONNECT:
286 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
287 break;
288 }
289}
290
291static struct pxa2xx_udc_mach_info udc_info __initdata = {
292 /* no connect GPIO; poodle can't tell connection status */
293 .udc_command = poodle_udc_command,
294};
295
296
1da177e4 297/* PXAFB device */
d14b272b 298static struct pxafb_mode_info poodle_fb_mode = {
1da177e4 299 .pixclock = 144700,
1da177e4
LT
300 .xres = 320,
301 .yres = 240,
302 .bpp = 16,
1da177e4
LT
303 .hsync_len = 7,
304 .left_margin = 11,
305 .right_margin = 30,
1da177e4
LT
306 .vsync_len = 2,
307 .upper_margin = 2,
308 .lower_margin = 0,
309 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
d14b272b 310};
1da177e4 311
d14b272b
RP
312static struct pxafb_mach_info poodle_fb_info = {
313 .modes = &poodle_fb_mode,
314 .num_modes = 1,
1da177e4
LT
315 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
316 .lccr3 = 0,
1da177e4
LT
317};
318
319static struct platform_device *devices[] __initdata = {
faed5684 320 &poodle_locomo_device,
1da177e4 321 &poodle_scoop_device,
faed5684
RP
322 &poodle_ssp_device,
323 &poodle_ts_device,
1da177e4
LT
324};
325
74617fb6
RP
326static void poodle_poweroff(void)
327{
328 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
329 arm_machine_restart('h');
330}
331
332static void poodle_restart(char mode)
333{
334 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
335 arm_machine_restart('h');
336}
337
1da177e4
LT
338static void __init poodle_init(void)
339{
340 int ret = 0;
341
74617fb6
RP
342 pm_power_off = poodle_poweroff;
343 arm_pm_restart = poodle_restart;
344
f29d2455
RP
345 /* setup sleep mode values */
346 PWER = 0x00000002;
347 PFER = 0x00000000;
348 PRER = 0x00000002;
349 PGSR0 = 0x00008000;
350 PGSR1 = 0x003F0202;
351 PGSR2 = 0x0001C000;
352 PCFR |= PCFR_OPDE;
353
1da177e4
LT
354 /* cpu initialize */
355 /* Pgsr Register */
356 PGSR0 = 0x0146dd80;
357 PGSR1 = 0x03bf0890;
358 PGSR2 = 0x0001c000;
359
360 /* Alternate Register */
361 GAFR0_L = 0x01001000;
362 GAFR0_U = 0x591a8010;
363 GAFR1_L = 0x900a8451;
364 GAFR1_U = 0xaaa5aaaa;
365 GAFR2_L = 0x8aaaaaaa;
366 GAFR2_U = 0x00000002;
367
368 /* Direction Register */
369 GPDR0 = 0xd3f0904c;
370 GPDR1 = 0xfcffb7d3;
371 GPDR2 = 0x0001ffff;
372
373 /* Output Register */
374 GPCR0 = 0x00000000;
375 GPCR1 = 0x00000000;
376 GPCR2 = 0x00000000;
377
378 GPSR0 = 0x00400000;
379 GPSR1 = 0x00000000;
380 GPSR2 = 0x00000000;
381
faed5684 382 set_pxa_fb_parent(&poodle_locomo_device.dev);
1da177e4 383 set_pxa_fb_info(&poodle_fb_info);
13b9d47e 384 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
8e4b8715 385 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
13b9d47e
RP
386 pxa_set_udc_info(&udc_info);
387 pxa_set_mci_info(&poodle_mci_platform_data);
8e4b8715 388 pxa_set_ficp_info(&poodle_ficp_platform_data);
1da177e4 389
a63ae442 390 platform_scoop_config = &poodle_pcmcia_config;
0ce7625f 391
1da177e4
LT
392 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
393 if (ret) {
394 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
395 }
faed5684 396 corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
1da177e4
LT
397}
398
399static void __init fixup_poodle(struct machine_desc *desc,
400 struct tag *tags, char **cmdline, struct meminfo *mi)
401{
402 sharpsl_save_param();
b2e6f755
RP
403 mi->nr_banks=1;
404 mi->bank[0].start = 0xa0000000;
405 mi->bank[0].node = 0;
406 mi->bank[0].size = (32*1024*1024);
1da177e4
LT
407}
408
1da177e4 409MACHINE_START(POODLE, "SHARP Poodle")
e9dea0c6 410 .phys_io = 0x40000000,
68070bde 411 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
e9dea0c6 412 .fixup = fixup_poodle,
f29d2455 413 .map_io = pxa_map_io,
cd49104d 414 .init_irq = pxa25x_init_irq,
e9dea0c6
RK
415 .timer = &pxa_timer,
416 .init_machine = poodle_init,
1da177e4 417MACHINE_END
This page took 0.282134 seconds and 5 git commands to generate.