[ARM] pxa/magician: remove unused forward declaration of pasic3
[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>
431a2cff 23#include <linux/mtd/physmap.h>
ce529147 24#include <linux/gpio.h>
9ee40d9a
EM
25#include <linux/spi/spi.h>
26#include <linux/spi/ads7846.h>
6af7a8eb 27#include <linux/mtd/sharpsl.h>
1da177e4 28
a09e64fb 29#include <mach/hardware.h>
1da177e4
LT
30#include <asm/mach-types.h>
31#include <asm/irq.h>
32#include <asm/setup.h>
74617fb6 33#include <asm/system.h>
1da177e4
LT
34
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/irq.h>
38
a09e64fb
RK
39#include <mach/pxa-regs.h>
40#include <mach/pxa2xx-regs.h>
26b4c8dd 41#include <mach/mfp-pxa25x.h>
a09e64fb
RK
42#include <mach/mmc.h>
43#include <mach/udc.h>
f8787fdc 44#include <mach/i2c.h>
a09e64fb
RK
45#include <mach/irda.h>
46#include <mach/poodle.h>
47#include <mach/pxafb.h>
48#include <mach/sharpsl.h>
49#include <mach/ssp.h>
9ee40d9a 50#include <mach/pxa2xx_spi.h>
1da177e4
LT
51
52#include <asm/hardware/scoop.h>
53#include <asm/hardware/locomo.h>
54#include <asm/mach/sharpsl_param.h>
55
56#include "generic.h"
46c41e62 57#include "devices.h"
faed5684 58#include "sharpsl.h"
1da177e4 59
26b4c8dd
EM
60static unsigned long poodle_pin_config[] __initdata = {
61 /* I/O */
62 GPIO79_nCS_3,
63 GPIO80_nCS_4,
64 GPIO18_RDY,
65
66 /* Clock */
67 GPIO12_32KHz,
68
69 /* SSP1 */
70 GPIO23_SSP1_SCLK,
26b4c8dd
EM
71 GPIO25_SSP1_TXD,
72 GPIO26_SSP1_RXD,
9ee40d9a 73 GPIO24_GPIO, /* POODLE_GPIO_TP_CS - SFRM as chip select */
26b4c8dd
EM
74
75 /* I2S */
76 GPIO28_I2S_BITCLK_OUT,
77 GPIO29_I2S_SDATA_IN,
78 GPIO30_I2S_SDATA_OUT,
79 GPIO31_I2S_SYNC,
80 GPIO32_I2S_SYSCLK,
81
82 /* Infra-Red */
83 GPIO47_FICP_TXD,
84 GPIO46_FICP_RXD,
85
86 /* FFUART */
87 GPIO40_FFUART_DTR,
88 GPIO41_FFUART_RTS,
89 GPIO39_FFUART_TXD,
90 GPIO37_FFUART_DSR,
91 GPIO34_FFUART_RXD,
92 GPIO35_FFUART_CTS,
93
94 /* LCD */
95 GPIO58_LCD_LDD_0,
96 GPIO59_LCD_LDD_1,
97 GPIO60_LCD_LDD_2,
98 GPIO61_LCD_LDD_3,
99 GPIO62_LCD_LDD_4,
100 GPIO63_LCD_LDD_5,
101 GPIO64_LCD_LDD_6,
102 GPIO65_LCD_LDD_7,
103 GPIO66_LCD_LDD_8,
104 GPIO67_LCD_LDD_9,
105 GPIO68_LCD_LDD_10,
106 GPIO69_LCD_LDD_11,
107 GPIO70_LCD_LDD_12,
108 GPIO71_LCD_LDD_13,
109 GPIO72_LCD_LDD_14,
110 GPIO73_LCD_LDD_15,
111 GPIO74_LCD_FCLK,
112 GPIO75_LCD_LCLK,
113 GPIO76_LCD_PCLK,
4fa7c24e 114 GPIO77_LCD_BIAS,
26b4c8dd
EM
115
116 /* PC Card */
117 GPIO48_nPOE,
118 GPIO49_nPWE,
119 GPIO50_nPIOR,
120 GPIO51_nPIOW,
121 GPIO52_nPCE_1,
122 GPIO53_nPCE_2,
123 GPIO54_nPSKTSEL,
124 GPIO55_nPREG,
125 GPIO56_nPWAIT,
126 GPIO57_nIOIS16,
127
128 /* MMC */
129 GPIO6_MMC_CLK,
130 GPIO8_MMC_CS0,
131
132 /* GPIO */
133 GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */
134 GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */
135 GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */
136 GPIO33_GPIO, /* POODLE_GPIO_SD_PWR1 */
137
138 GPIO20_GPIO, /* POODLE_GPIO_USB_PULLUP */
139 GPIO22_GPIO, /* POODLE_GPIO_IR_ON */
140};
141
1da177e4
LT
142static struct resource poodle_scoop_resources[] = {
143 [0] = {
144 .start = 0x10800000,
145 .end = 0x10800fff,
146 .flags = IORESOURCE_MEM,
147 },
148};
149
150static struct scoop_config poodle_scoop_setup = {
151 .io_dir = POODLE_SCOOP_IO_DIR,
152 .io_out = POODLE_SCOOP_IO_OUT,
2d91f941 153 .gpio_base = POODLE_SCOOP_GPIO_BASE,
1da177e4
LT
154};
155
156struct platform_device poodle_scoop_device = {
157 .name = "sharp-scoop",
158 .id = -1,
159 .dev = {
160 .platform_data = &poodle_scoop_setup,
161 },
162 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
163 .resource = poodle_scoop_resources,
164};
165
0ce7625f
RP
166static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
167{
168 .dev = &poodle_scoop_device.dev,
169 .irq = POODLE_IRQ_GPIO_CF_IRQ,
170 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
171 .cd_irq_str = "PCMCIA0 CD",
172},
173};
174
a63ae442
RP
175static struct scoop_pcmcia_config poodle_pcmcia_config = {
176 .devs = &poodle_pcmcia_scoop[0],
177 .num_devs = 1,
a63ae442
RP
178};
179
180EXPORT_SYMBOL(poodle_scoop_device);
181
1da177e4
LT
182
183/* LoCoMo device */
184static struct resource locomo_resources[] = {
185 [0] = {
186 .start = 0x10000000,
187 .end = 0x10001fff,
188 .flags = IORESOURCE_MEM,
189 },
190 [1] = {
191 .start = IRQ_GPIO(10),
192 .end = IRQ_GPIO(10),
193 .flags = IORESOURCE_IRQ,
194 },
195};
196
faed5684 197struct platform_device poodle_locomo_device = {
1da177e4
LT
198 .name = "locomo",
199 .id = 0,
200 .num_resources = ARRAY_SIZE(locomo_resources),
201 .resource = locomo_resources,
202};
203
faed5684
RP
204EXPORT_SYMBOL(poodle_locomo_device);
205
9ee40d9a
EM
206#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
207static struct pxa2xx_spi_master poodle_spi_info = {
208 .num_chipselect = 1,
faed5684
RP
209};
210
9ee40d9a
EM
211static struct ads7846_platform_data poodle_ads7846_info = {
212 .model = 7846,
213 .vref_delay_usecs = 100,
214 .x_plate_ohms = 419,
215 .y_plate_ohms = 486,
216 .gpio_pendown = POODLE_GPIO_TP_INT,
faed5684
RP
217};
218
9ee40d9a 219static void ads7846_cs(u32 command)
faed5684 220{
9ee40d9a 221 gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
faed5684
RP
222}
223
9ee40d9a
EM
224static struct pxa2xx_spi_chip poodle_ads7846_chip = {
225 .cs_control = ads7846_cs,
faed5684
RP
226};
227
9ee40d9a
EM
228static struct spi_board_info poodle_spi_devices[] = {
229 {
230 .modalias = "ads7846",
231 .max_speed_hz = 10000,
232 .bus_num = 1,
233 .platform_data = &poodle_ads7846_info,
234 .controller_data= &poodle_ads7846_chip,
235 .irq = gpio_to_irq(POODLE_GPIO_TP_INT),
faed5684 236 },
faed5684
RP
237};
238
9ee40d9a
EM
239static void __init poodle_init_spi(void)
240{
241 int err;
242
243 err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
244 if (err)
245 return;
246
247 gpio_direction_output(POODLE_GPIO_TP_CS, 1);
248
249 pxa2xx_set_spi_info(1, &poodle_spi_info);
250 spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
251}
252#else
253static inline void poodle_init_spi(void) {}
254#endif
13b9d47e
RP
255
256/*
257 * MMC/SD Device
258 *
259 * The card detect interrupt isn't debounced so we delay it by 250ms
260 * to give the card a chance to fully insert/eject.
261 */
262static struct pxamci_platform_data poodle_mci_platform_data;
263
40220c1a 264static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
13b9d47e
RP
265{
266 int err;
267
ce529147
EM
268 err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
269 if (err)
270 goto err_out;
271
272 err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
273 if (err)
274 goto err_free_1;
275
276 err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
277 if (err)
278 goto err_free_2;
279
280 err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
281 if (err)
282 goto err_free_3;
283
284 gpio_direction_input(POODLE_GPIO_nSD_DETECT);
285 gpio_direction_input(POODLE_GPIO_nSD_WP);
286
287 gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
288 gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
13b9d47e
RP
289
290 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
291
9ded96f2 292 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
52e405ea 293 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
9ded96f2 294 "MMC card detect", data);
ce529147
EM
295 if (err) {
296 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
297 __func__);
298 goto err_free_4;
299 }
300
301 return 0;
13b9d47e 302
ce529147
EM
303err_free_4:
304 gpio_free(POODLE_GPIO_SD_PWR1);
305err_free_3:
306 gpio_free(POODLE_GPIO_SD_PWR);
307err_free_2:
308 gpio_free(POODLE_GPIO_nSD_WP);
309err_free_1:
310 gpio_free(POODLE_GPIO_nSD_DETECT);
311err_out:
2687bd38 312 return err;
13b9d47e
RP
313}
314
315static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
316{
317 struct pxamci_platform_data* p_d = dev->platform_data;
318
ce529147
EM
319 if ((1 << vdd) & p_d->ocr_mask) {
320 gpio_set_value(POODLE_GPIO_SD_PWR, 1);
88660351 321 mdelay(2);
ce529147 322 gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
88660351 323 } else {
ce529147
EM
324 gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
325 gpio_set_value(POODLE_GPIO_SD_PWR, 0);
88660351
RP
326 }
327}
328
329static int poodle_mci_get_ro(struct device *dev)
330{
ce529147 331 return !!gpio_get_value(POODLE_GPIO_nSD_WP);
88660351 332 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
13b9d47e
RP
333}
334
88660351 335
13b9d47e
RP
336static void poodle_mci_exit(struct device *dev, void *data)
337{
338 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
ce529147
EM
339 gpio_free(POODLE_GPIO_SD_PWR1);
340 gpio_free(POODLE_GPIO_SD_PWR);
341 gpio_free(POODLE_GPIO_nSD_WP);
342 gpio_free(POODLE_GPIO_nSD_DETECT);
13b9d47e
RP
343}
344
345static struct pxamci_platform_data poodle_mci_platform_data = {
346 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
347 .init = poodle_mci_init,
88660351 348 .get_ro = poodle_mci_get_ro,
13b9d47e
RP
349 .setpower = poodle_mci_setpower,
350 .exit = poodle_mci_exit,
351};
352
353
8e4b8715
RP
354/*
355 * Irda
356 */
357static void poodle_irda_transceiver_mode(struct device *dev, int mode)
358{
ce529147 359 gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
0fc3ff31 360 pxa2xx_transceiver_mode(dev, mode);
8e4b8715
RP
361}
362
ce529147
EM
363static int poodle_irda_startup(struct device *dev)
364{
365 int err;
366
367 err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
368 if (err)
369 return err;
370
371 gpio_direction_output(POODLE_GPIO_IR_ON, 1);
372 return 0;
373}
374
375static void poodle_irda_shutdown(struct device *dev)
376{
377 gpio_free(POODLE_GPIO_IR_ON);
378}
379
8e4b8715 380static struct pxaficp_platform_data poodle_ficp_platform_data = {
ce529147
EM
381 .transceiver_cap = IR_SIRMODE | IR_OFF,
382 .transceiver_mode = poodle_irda_transceiver_mode,
383 .startup = poodle_irda_startup,
384 .shutdown = poodle_irda_shutdown,
8e4b8715
RP
385};
386
387
13b9d47e
RP
388/*
389 * USB Device Controller
390 */
13b9d47e
RP
391static struct pxa2xx_udc_mach_info udc_info __initdata = {
392 /* no connect GPIO; poodle can't tell connection status */
1730aadf 393 .gpio_pullup = POODLE_GPIO_USB_PULLUP,
13b9d47e
RP
394};
395
396
1da177e4 397/* PXAFB device */
d14b272b 398static struct pxafb_mode_info poodle_fb_mode = {
1da177e4 399 .pixclock = 144700,
1da177e4
LT
400 .xres = 320,
401 .yres = 240,
402 .bpp = 16,
1da177e4
LT
403 .hsync_len = 7,
404 .left_margin = 11,
405 .right_margin = 30,
1da177e4
LT
406 .vsync_len = 2,
407 .upper_margin = 2,
408 .lower_margin = 0,
409 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
d14b272b 410};
1da177e4 411
d14b272b
RP
412static struct pxafb_mach_info poodle_fb_info = {
413 .modes = &poodle_fb_mode,
414 .num_modes = 1,
cf5eb8c0 415 .lcd_conn = LCD_COLOR_TFT_16BPP,
1da177e4
LT
416};
417
6af7a8eb
DB
418static struct mtd_partition sharpsl_nand_partitions[] = {
419 {
420 .name = "System Area",
421 .offset = 0,
422 .size = 7 * 1024 * 1024,
423 },
424 {
425 .name = "Root Filesystem",
426 .offset = 7 * 1024 * 1024,
427 .size = 22 * 1024 * 1024,
428 },
429 {
430 .name = "Home Filesystem",
431 .offset = MTDPART_OFS_APPEND,
432 .size = MTDPART_SIZ_FULL,
433 },
434};
435
436static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
437
438static struct nand_bbt_descr sharpsl_bbt = {
439 .options = 0,
440 .offs = 4,
441 .len = 2,
442 .pattern = scan_ff_pattern
443};
444
445static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
446 .badblock_pattern = &sharpsl_bbt,
447 .partitions = sharpsl_nand_partitions,
448 .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
449};
450
451static struct resource sharpsl_nand_resources[] = {
452 {
453 .start = 0x0C000000,
454 .end = 0x0C000FFF,
455 .flags = IORESOURCE_MEM,
456 },
457};
458
459static struct platform_device sharpsl_nand_device = {
460 .name = "sharpsl-nand",
461 .id = -1,
462 .resource = sharpsl_nand_resources,
463 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
464 .dev.platform_data = &sharpsl_nand_platform_data,
465};
466
431a2cff
DB
467static struct mtd_partition sharpsl_rom_parts[] = {
468 {
469 .name ="Boot PROM Filesystem",
470 .offset = 0x00120000,
471 .size = MTDPART_SIZ_FULL,
472 },
473};
474
475static struct physmap_flash_data sharpsl_rom_data = {
476 .width = 2,
477 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
478 .parts = sharpsl_rom_parts,
479};
480
481static struct resource sharpsl_rom_resources[] = {
482 {
483 .start = 0x00000000,
484 .end = 0x007fffff,
485 .flags = IORESOURCE_MEM,
486 },
487};
488
489static struct platform_device sharpsl_rom_device = {
490 .name = "physmap-flash",
491 .id = -1,
492 .resource = sharpsl_rom_resources,
493 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
494 .dev.platform_data = &sharpsl_rom_data,
495};
496
1da177e4 497static struct platform_device *devices[] __initdata = {
faed5684 498 &poodle_locomo_device,
1da177e4 499 &poodle_scoop_device,
6af7a8eb 500 &sharpsl_nand_device,
431a2cff 501 &sharpsl_rom_device,
1da177e4
LT
502};
503
74617fb6
RP
504static void poodle_poweroff(void)
505{
74617fb6
RP
506 arm_machine_restart('h');
507}
508
509static void poodle_restart(char mode)
510{
74617fb6
RP
511 arm_machine_restart('h');
512}
513
1da177e4
LT
514static void __init poodle_init(void)
515{
516 int ret = 0;
517
74617fb6
RP
518 pm_power_off = poodle_poweroff;
519 arm_pm_restart = poodle_restart;
520
f29d2455
RP
521 PCFR |= PCFR_OPDE;
522
26b4c8dd 523 pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
1da177e4 524
2b0defd4 525 platform_scoop_config = &poodle_pcmcia_config;
2b0defd4
EM
526
527 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
528 if (ret)
529 pr_warning("poodle: Unable to register LoCoMo device\n");
530
faed5684 531 set_pxa_fb_parent(&poodle_locomo_device.dev);
1da177e4 532 set_pxa_fb_info(&poodle_fb_info);
13b9d47e
RP
533 pxa_set_udc_info(&udc_info);
534 pxa_set_mci_info(&poodle_mci_platform_data);
8e4b8715 535 pxa_set_ficp_info(&poodle_ficp_platform_data);
f8787fdc 536 pxa_set_i2c_info(NULL);
9ee40d9a 537 poodle_init_spi();
1da177e4
LT
538}
539
540static void __init fixup_poodle(struct machine_desc *desc,
541 struct tag *tags, char **cmdline, struct meminfo *mi)
542{
543 sharpsl_save_param();
b2e6f755
RP
544 mi->nr_banks=1;
545 mi->bank[0].start = 0xa0000000;
546 mi->bank[0].node = 0;
547 mi->bank[0].size = (32*1024*1024);
1da177e4
LT
548}
549
1da177e4 550MACHINE_START(POODLE, "SHARP Poodle")
e9dea0c6 551 .phys_io = 0x40000000,
68070bde 552 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
e9dea0c6 553 .fixup = fixup_poodle,
f29d2455 554 .map_io = pxa_map_io,
cd49104d 555 .init_irq = pxa25x_init_irq,
e9dea0c6
RK
556 .timer = &pxa_timer,
557 .init_machine = poodle_init,
1da177e4 558MACHINE_END
This page took 0.409014 seconds and 5 git commands to generate.