Commit | Line | Data |
---|---|---|
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> |
ce529147 | 23 | #include <linux/gpio.h> |
1da177e4 | 24 | |
a09e64fb | 25 | #include <mach/hardware.h> |
1da177e4 LT |
26 | #include <asm/mach-types.h> |
27 | #include <asm/irq.h> | |
28 | #include <asm/setup.h> | |
74617fb6 | 29 | #include <asm/system.h> |
1da177e4 LT |
30 | |
31 | #include <asm/mach/arch.h> | |
32 | #include <asm/mach/map.h> | |
33 | #include <asm/mach/irq.h> | |
34 | ||
a09e64fb RK |
35 | #include <mach/pxa-regs.h> |
36 | #include <mach/pxa2xx-regs.h> | |
26b4c8dd | 37 | #include <mach/mfp-pxa25x.h> |
a09e64fb RK |
38 | #include <mach/mmc.h> |
39 | #include <mach/udc.h> | |
f8787fdc | 40 | #include <mach/i2c.h> |
a09e64fb RK |
41 | #include <mach/irda.h> |
42 | #include <mach/poodle.h> | |
43 | #include <mach/pxafb.h> | |
44 | #include <mach/sharpsl.h> | |
45 | #include <mach/ssp.h> | |
1da177e4 LT |
46 | |
47 | #include <asm/hardware/scoop.h> | |
48 | #include <asm/hardware/locomo.h> | |
49 | #include <asm/mach/sharpsl_param.h> | |
50 | ||
51 | #include "generic.h" | |
46c41e62 | 52 | #include "devices.h" |
faed5684 | 53 | #include "sharpsl.h" |
1da177e4 | 54 | |
26b4c8dd EM |
55 | static unsigned long poodle_pin_config[] __initdata = { |
56 | /* I/O */ | |
57 | GPIO79_nCS_3, | |
58 | GPIO80_nCS_4, | |
59 | GPIO18_RDY, | |
60 | ||
61 | /* Clock */ | |
62 | GPIO12_32KHz, | |
63 | ||
64 | /* SSP1 */ | |
65 | GPIO23_SSP1_SCLK, | |
66 | GPIO24_SSP1_SFRM, | |
67 | GPIO25_SSP1_TXD, | |
68 | GPIO26_SSP1_RXD, | |
69 | ||
70 | /* I2S */ | |
71 | GPIO28_I2S_BITCLK_OUT, | |
72 | GPIO29_I2S_SDATA_IN, | |
73 | GPIO30_I2S_SDATA_OUT, | |
74 | GPIO31_I2S_SYNC, | |
75 | GPIO32_I2S_SYSCLK, | |
76 | ||
77 | /* Infra-Red */ | |
78 | GPIO47_FICP_TXD, | |
79 | GPIO46_FICP_RXD, | |
80 | ||
81 | /* FFUART */ | |
82 | GPIO40_FFUART_DTR, | |
83 | GPIO41_FFUART_RTS, | |
84 | GPIO39_FFUART_TXD, | |
85 | GPIO37_FFUART_DSR, | |
86 | GPIO34_FFUART_RXD, | |
87 | GPIO35_FFUART_CTS, | |
88 | ||
89 | /* LCD */ | |
90 | GPIO58_LCD_LDD_0, | |
91 | GPIO59_LCD_LDD_1, | |
92 | GPIO60_LCD_LDD_2, | |
93 | GPIO61_LCD_LDD_3, | |
94 | GPIO62_LCD_LDD_4, | |
95 | GPIO63_LCD_LDD_5, | |
96 | GPIO64_LCD_LDD_6, | |
97 | GPIO65_LCD_LDD_7, | |
98 | GPIO66_LCD_LDD_8, | |
99 | GPIO67_LCD_LDD_9, | |
100 | GPIO68_LCD_LDD_10, | |
101 | GPIO69_LCD_LDD_11, | |
102 | GPIO70_LCD_LDD_12, | |
103 | GPIO71_LCD_LDD_13, | |
104 | GPIO72_LCD_LDD_14, | |
105 | GPIO73_LCD_LDD_15, | |
106 | GPIO74_LCD_FCLK, | |
107 | GPIO75_LCD_LCLK, | |
108 | GPIO76_LCD_PCLK, | |
109 | GPIO77_LCD_ACBIAS, | |
110 | ||
111 | /* PC Card */ | |
112 | GPIO48_nPOE, | |
113 | GPIO49_nPWE, | |
114 | GPIO50_nPIOR, | |
115 | GPIO51_nPIOW, | |
116 | GPIO52_nPCE_1, | |
117 | GPIO53_nPCE_2, | |
118 | GPIO54_nPSKTSEL, | |
119 | GPIO55_nPREG, | |
120 | GPIO56_nPWAIT, | |
121 | GPIO57_nIOIS16, | |
122 | ||
123 | /* MMC */ | |
124 | GPIO6_MMC_CLK, | |
125 | GPIO8_MMC_CS0, | |
126 | ||
127 | /* GPIO */ | |
128 | GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */ | |
129 | GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */ | |
130 | GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */ | |
131 | GPIO33_GPIO, /* POODLE_GPIO_SD_PWR1 */ | |
132 | ||
133 | GPIO20_GPIO, /* POODLE_GPIO_USB_PULLUP */ | |
134 | GPIO22_GPIO, /* POODLE_GPIO_IR_ON */ | |
135 | }; | |
136 | ||
1da177e4 LT |
137 | static struct resource poodle_scoop_resources[] = { |
138 | [0] = { | |
139 | .start = 0x10800000, | |
140 | .end = 0x10800fff, | |
141 | .flags = IORESOURCE_MEM, | |
142 | }, | |
143 | }; | |
144 | ||
145 | static struct scoop_config poodle_scoop_setup = { | |
146 | .io_dir = POODLE_SCOOP_IO_DIR, | |
147 | .io_out = POODLE_SCOOP_IO_OUT, | |
148 | }; | |
149 | ||
150 | struct platform_device poodle_scoop_device = { | |
151 | .name = "sharp-scoop", | |
152 | .id = -1, | |
153 | .dev = { | |
154 | .platform_data = &poodle_scoop_setup, | |
155 | }, | |
156 | .num_resources = ARRAY_SIZE(poodle_scoop_resources), | |
157 | .resource = poodle_scoop_resources, | |
158 | }; | |
159 | ||
0ce7625f RP |
160 | static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = { |
161 | { | |
162 | .dev = &poodle_scoop_device.dev, | |
163 | .irq = POODLE_IRQ_GPIO_CF_IRQ, | |
164 | .cd_irq = POODLE_IRQ_GPIO_CF_CD, | |
165 | .cd_irq_str = "PCMCIA0 CD", | |
166 | }, | |
167 | }; | |
168 | ||
a63ae442 RP |
169 | static struct scoop_pcmcia_config poodle_pcmcia_config = { |
170 | .devs = &poodle_pcmcia_scoop[0], | |
171 | .num_devs = 1, | |
a63ae442 RP |
172 | }; |
173 | ||
174 | EXPORT_SYMBOL(poodle_scoop_device); | |
175 | ||
1da177e4 LT |
176 | |
177 | /* LoCoMo device */ | |
178 | static struct resource locomo_resources[] = { | |
179 | [0] = { | |
180 | .start = 0x10000000, | |
181 | .end = 0x10001fff, | |
182 | .flags = IORESOURCE_MEM, | |
183 | }, | |
184 | [1] = { | |
185 | .start = IRQ_GPIO(10), | |
186 | .end = IRQ_GPIO(10), | |
187 | .flags = IORESOURCE_IRQ, | |
188 | }, | |
189 | }; | |
190 | ||
faed5684 | 191 | struct platform_device poodle_locomo_device = { |
1da177e4 LT |
192 | .name = "locomo", |
193 | .id = 0, | |
194 | .num_resources = ARRAY_SIZE(locomo_resources), | |
195 | .resource = locomo_resources, | |
196 | }; | |
197 | ||
faed5684 RP |
198 | EXPORT_SYMBOL(poodle_locomo_device); |
199 | ||
200 | /* | |
201 | * Poodle SSP Device | |
202 | */ | |
203 | ||
204 | struct platform_device poodle_ssp_device = { | |
205 | .name = "corgi-ssp", | |
206 | .id = -1, | |
207 | }; | |
208 | ||
209 | struct corgissp_machinfo poodle_ssp_machinfo = { | |
210 | .port = 1, | |
211 | .cs_lcdcon = -1, | |
212 | .cs_ads7846 = -1, | |
213 | .cs_max1111 = -1, | |
214 | .clk_lcdcon = 2, | |
215 | .clk_ads7846 = 36, | |
216 | .clk_max1111 = 2, | |
217 | }; | |
218 | ||
219 | ||
220 | /* | |
221 | * Poodle Touch Screen Device | |
222 | */ | |
223 | static struct resource poodlets_resources[] = { | |
224 | [0] = { | |
225 | .start = POODLE_IRQ_GPIO_TP_INT, | |
226 | .end = POODLE_IRQ_GPIO_TP_INT, | |
227 | .flags = IORESOURCE_IRQ, | |
228 | }, | |
229 | }; | |
230 | ||
6a0bd09d | 231 | static unsigned long poodle_get_hsync_invperiod(void) |
faed5684 RP |
232 | { |
233 | return 0; | |
234 | } | |
235 | ||
236 | static void poodle_null_hsync(void) | |
237 | { | |
238 | } | |
239 | ||
240 | static struct corgits_machinfo poodle_ts_machinfo = { | |
6a0bd09d | 241 | .get_hsync_invperiod = poodle_get_hsync_invperiod, |
242 | .put_hsync = poodle_null_hsync, | |
243 | .wait_hsync = poodle_null_hsync, | |
faed5684 RP |
244 | }; |
245 | ||
246 | static struct platform_device poodle_ts_device = { | |
247 | .name = "corgi-ts", | |
248 | .dev = { | |
249 | .platform_data = &poodle_ts_machinfo, | |
250 | }, | |
251 | .id = -1, | |
252 | .num_resources = ARRAY_SIZE(poodlets_resources), | |
253 | .resource = poodlets_resources, | |
254 | }; | |
255 | ||
13b9d47e RP |
256 | |
257 | /* | |
258 | * MMC/SD Device | |
259 | * | |
260 | * The card detect interrupt isn't debounced so we delay it by 250ms | |
261 | * to give the card a chance to fully insert/eject. | |
262 | */ | |
263 | static struct pxamci_platform_data poodle_mci_platform_data; | |
264 | ||
40220c1a | 265 | static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data) |
13b9d47e RP |
266 | { |
267 | int err; | |
268 | ||
ce529147 EM |
269 | err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT"); |
270 | if (err) | |
271 | goto err_out; | |
272 | ||
273 | err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP"); | |
274 | if (err) | |
275 | goto err_free_1; | |
276 | ||
277 | err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR"); | |
278 | if (err) | |
279 | goto err_free_2; | |
280 | ||
281 | err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1"); | |
282 | if (err) | |
283 | goto err_free_3; | |
284 | ||
285 | gpio_direction_input(POODLE_GPIO_nSD_DETECT); | |
286 | gpio_direction_input(POODLE_GPIO_nSD_WP); | |
287 | ||
288 | gpio_direction_output(POODLE_GPIO_SD_PWR, 0); | |
289 | gpio_direction_output(POODLE_GPIO_SD_PWR1, 0); | |
13b9d47e RP |
290 | |
291 | poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250); | |
292 | ||
9ded96f2 | 293 | err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, |
52e405ea | 294 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
9ded96f2 | 295 | "MMC card detect", data); |
ce529147 EM |
296 | if (err) { |
297 | pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n", | |
298 | __func__); | |
299 | goto err_free_4; | |
300 | } | |
301 | ||
302 | return 0; | |
13b9d47e | 303 | |
ce529147 EM |
304 | err_free_4: |
305 | gpio_free(POODLE_GPIO_SD_PWR1); | |
306 | err_free_3: | |
307 | gpio_free(POODLE_GPIO_SD_PWR); | |
308 | err_free_2: | |
309 | gpio_free(POODLE_GPIO_nSD_WP); | |
310 | err_free_1: | |
311 | gpio_free(POODLE_GPIO_nSD_DETECT); | |
312 | err_out: | |
2687bd38 | 313 | return err; |
13b9d47e RP |
314 | } |
315 | ||
316 | static void poodle_mci_setpower(struct device *dev, unsigned int vdd) | |
317 | { | |
318 | struct pxamci_platform_data* p_d = dev->platform_data; | |
319 | ||
ce529147 EM |
320 | if ((1 << vdd) & p_d->ocr_mask) { |
321 | gpio_set_value(POODLE_GPIO_SD_PWR, 1); | |
88660351 | 322 | mdelay(2); |
ce529147 | 323 | gpio_set_value(POODLE_GPIO_SD_PWR1, 1); |
88660351 | 324 | } else { |
ce529147 EM |
325 | gpio_set_value(POODLE_GPIO_SD_PWR1, 0); |
326 | gpio_set_value(POODLE_GPIO_SD_PWR, 0); | |
88660351 RP |
327 | } |
328 | } | |
329 | ||
330 | static int poodle_mci_get_ro(struct device *dev) | |
331 | { | |
ce529147 | 332 | return !!gpio_get_value(POODLE_GPIO_nSD_WP); |
88660351 | 333 | return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP); |
13b9d47e RP |
334 | } |
335 | ||
88660351 | 336 | |
13b9d47e RP |
337 | static void poodle_mci_exit(struct device *dev, void *data) |
338 | { | |
339 | free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data); | |
ce529147 EM |
340 | gpio_free(POODLE_GPIO_SD_PWR1); |
341 | gpio_free(POODLE_GPIO_SD_PWR); | |
342 | gpio_free(POODLE_GPIO_nSD_WP); | |
343 | gpio_free(POODLE_GPIO_nSD_DETECT); | |
13b9d47e RP |
344 | } |
345 | ||
346 | static struct pxamci_platform_data poodle_mci_platform_data = { | |
347 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
348 | .init = poodle_mci_init, | |
88660351 | 349 | .get_ro = poodle_mci_get_ro, |
13b9d47e RP |
350 | .setpower = poodle_mci_setpower, |
351 | .exit = poodle_mci_exit, | |
352 | }; | |
353 | ||
354 | ||
8e4b8715 RP |
355 | /* |
356 | * Irda | |
357 | */ | |
358 | static void poodle_irda_transceiver_mode(struct device *dev, int mode) | |
359 | { | |
ce529147 | 360 | gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF); |
0fc3ff31 | 361 | pxa2xx_transceiver_mode(dev, mode); |
8e4b8715 RP |
362 | } |
363 | ||
ce529147 EM |
364 | static int poodle_irda_startup(struct device *dev) |
365 | { | |
366 | int err; | |
367 | ||
368 | err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON"); | |
369 | if (err) | |
370 | return err; | |
371 | ||
372 | gpio_direction_output(POODLE_GPIO_IR_ON, 1); | |
373 | return 0; | |
374 | } | |
375 | ||
376 | static void poodle_irda_shutdown(struct device *dev) | |
377 | { | |
378 | gpio_free(POODLE_GPIO_IR_ON); | |
379 | } | |
380 | ||
8e4b8715 | 381 | static struct pxaficp_platform_data poodle_ficp_platform_data = { |
ce529147 EM |
382 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
383 | .transceiver_mode = poodle_irda_transceiver_mode, | |
384 | .startup = poodle_irda_startup, | |
385 | .shutdown = poodle_irda_shutdown, | |
8e4b8715 RP |
386 | }; |
387 | ||
388 | ||
13b9d47e RP |
389 | /* |
390 | * USB Device Controller | |
391 | */ | |
13b9d47e RP |
392 | static struct pxa2xx_udc_mach_info udc_info __initdata = { |
393 | /* no connect GPIO; poodle can't tell connection status */ | |
1730aadf | 394 | .gpio_pullup = POODLE_GPIO_USB_PULLUP, |
13b9d47e RP |
395 | }; |
396 | ||
397 | ||
1da177e4 | 398 | /* PXAFB device */ |
d14b272b | 399 | static struct pxafb_mode_info poodle_fb_mode = { |
1da177e4 | 400 | .pixclock = 144700, |
1da177e4 LT |
401 | .xres = 320, |
402 | .yres = 240, | |
403 | .bpp = 16, | |
1da177e4 LT |
404 | .hsync_len = 7, |
405 | .left_margin = 11, | |
406 | .right_margin = 30, | |
1da177e4 LT |
407 | .vsync_len = 2, |
408 | .upper_margin = 2, | |
409 | .lower_margin = 0, | |
410 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
d14b272b | 411 | }; |
1da177e4 | 412 | |
d14b272b RP |
413 | static struct pxafb_mach_info poodle_fb_info = { |
414 | .modes = &poodle_fb_mode, | |
415 | .num_modes = 1, | |
cf5eb8c0 | 416 | .lcd_conn = LCD_COLOR_TFT_16BPP, |
1da177e4 LT |
417 | }; |
418 | ||
419 | static struct platform_device *devices[] __initdata = { | |
faed5684 | 420 | &poodle_locomo_device, |
1da177e4 | 421 | &poodle_scoop_device, |
faed5684 RP |
422 | &poodle_ssp_device, |
423 | &poodle_ts_device, | |
1da177e4 LT |
424 | }; |
425 | ||
74617fb6 RP |
426 | static void poodle_poweroff(void) |
427 | { | |
74617fb6 RP |
428 | arm_machine_restart('h'); |
429 | } | |
430 | ||
431 | static void poodle_restart(char mode) | |
432 | { | |
74617fb6 RP |
433 | arm_machine_restart('h'); |
434 | } | |
435 | ||
1da177e4 LT |
436 | static void __init poodle_init(void) |
437 | { | |
438 | int ret = 0; | |
439 | ||
74617fb6 RP |
440 | pm_power_off = poodle_poweroff; |
441 | arm_pm_restart = poodle_restart; | |
442 | ||
f29d2455 RP |
443 | PCFR |= PCFR_OPDE; |
444 | ||
26b4c8dd | 445 | pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config)); |
1da177e4 | 446 | |
2b0defd4 EM |
447 | platform_scoop_config = &poodle_pcmcia_config; |
448 | corgi_ssp_set_machinfo(&poodle_ssp_machinfo); | |
449 | ||
450 | ret = platform_add_devices(devices, ARRAY_SIZE(devices)); | |
451 | if (ret) | |
452 | pr_warning("poodle: Unable to register LoCoMo device\n"); | |
453 | ||
faed5684 | 454 | set_pxa_fb_parent(&poodle_locomo_device.dev); |
1da177e4 | 455 | set_pxa_fb_info(&poodle_fb_info); |
13b9d47e RP |
456 | pxa_set_udc_info(&udc_info); |
457 | pxa_set_mci_info(&poodle_mci_platform_data); | |
8e4b8715 | 458 | pxa_set_ficp_info(&poodle_ficp_platform_data); |
f8787fdc | 459 | pxa_set_i2c_info(NULL); |
1da177e4 LT |
460 | } |
461 | ||
462 | static void __init fixup_poodle(struct machine_desc *desc, | |
463 | struct tag *tags, char **cmdline, struct meminfo *mi) | |
464 | { | |
465 | sharpsl_save_param(); | |
b2e6f755 RP |
466 | mi->nr_banks=1; |
467 | mi->bank[0].start = 0xa0000000; | |
468 | mi->bank[0].node = 0; | |
469 | mi->bank[0].size = (32*1024*1024); | |
1da177e4 LT |
470 | } |
471 | ||
1da177e4 | 472 | MACHINE_START(POODLE, "SHARP Poodle") |
e9dea0c6 | 473 | .phys_io = 0x40000000, |
68070bde | 474 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
e9dea0c6 | 475 | .fixup = fixup_poodle, |
f29d2455 | 476 | .map_io = pxa_map_io, |
cd49104d | 477 | .init_irq = pxa25x_init_irq, |
e9dea0c6 RK |
478 | .timer = &pxa_timer, |
479 | .init_machine = poodle_init, | |
1da177e4 | 480 | MACHINE_END |