2 * linux/arch/arm/mach-pxa/poodle.c
4 * Support for the SHARP Poodle Board.
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
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.
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
22 #include <linux/delay.h>
23 #include <linux/mtd/physmap.h>
24 #include <linux/gpio.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/ads7846.h>
27 #include <linux/mtd/sharpsl.h>
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
32 #include <asm/setup.h>
33 #include <asm/system.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/irq.h>
39 #include <mach/pxa-regs.h>
40 #include <mach/pxa2xx-regs.h>
41 #include <mach/mfp-pxa25x.h>
45 #include <mach/irda.h>
46 #include <mach/poodle.h>
47 #include <mach/pxafb.h>
48 #include <mach/sharpsl.h>
50 #include <mach/pxa2xx_spi.h>
52 #include <asm/hardware/scoop.h>
53 #include <asm/hardware/locomo.h>
54 #include <asm/mach/sharpsl_param.h>
60 static unsigned long poodle_pin_config
[] __initdata
= {
73 GPIO24_GPIO
, /* POODLE_GPIO_TP_CS - SFRM as chip select */
76 GPIO28_I2S_BITCLK_OUT
,
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 */
138 GPIO20_GPIO
, /* POODLE_GPIO_USB_PULLUP */
139 GPIO22_GPIO
, /* POODLE_GPIO_IR_ON */
142 static struct resource poodle_scoop_resources
[] = {
146 .flags
= IORESOURCE_MEM
,
150 static struct scoop_config poodle_scoop_setup
= {
151 .io_dir
= POODLE_SCOOP_IO_DIR
,
152 .io_out
= POODLE_SCOOP_IO_OUT
,
153 .gpio_base
= POODLE_SCOOP_GPIO_BASE
,
156 struct platform_device poodle_scoop_device
= {
157 .name
= "sharp-scoop",
160 .platform_data
= &poodle_scoop_setup
,
162 .num_resources
= ARRAY_SIZE(poodle_scoop_resources
),
163 .resource
= poodle_scoop_resources
,
166 static struct scoop_pcmcia_dev poodle_pcmcia_scoop
[] = {
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",
175 static struct scoop_pcmcia_config poodle_pcmcia_config
= {
176 .devs
= &poodle_pcmcia_scoop
[0],
180 EXPORT_SYMBOL(poodle_scoop_device
);
184 static struct resource locomo_resources
[] = {
188 .flags
= IORESOURCE_MEM
,
191 .start
= IRQ_GPIO(10),
193 .flags
= IORESOURCE_IRQ
,
197 struct platform_device poodle_locomo_device
= {
200 .num_resources
= ARRAY_SIZE(locomo_resources
),
201 .resource
= locomo_resources
,
204 EXPORT_SYMBOL(poodle_locomo_device
);
206 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
207 static struct pxa2xx_spi_master poodle_spi_info
= {
211 static struct ads7846_platform_data poodle_ads7846_info
= {
213 .vref_delay_usecs
= 100,
216 .gpio_pendown
= POODLE_GPIO_TP_INT
,
219 static void ads7846_cs(u32 command
)
221 gpio_set_value(POODLE_GPIO_TP_CS
, !(command
== PXA2XX_CS_ASSERT
));
224 static struct pxa2xx_spi_chip poodle_ads7846_chip
= {
225 .cs_control
= ads7846_cs
,
228 static struct spi_board_info poodle_spi_devices
[] = {
230 .modalias
= "ads7846",
231 .max_speed_hz
= 10000,
233 .platform_data
= &poodle_ads7846_info
,
234 .controller_data
= &poodle_ads7846_chip
,
235 .irq
= gpio_to_irq(POODLE_GPIO_TP_INT
),
239 static void __init
poodle_init_spi(void)
243 err
= gpio_request(POODLE_GPIO_TP_CS
, "ADS7846_CS");
247 gpio_direction_output(POODLE_GPIO_TP_CS
, 1);
249 pxa2xx_set_spi_info(1, &poodle_spi_info
);
250 spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices
));
253 static inline void poodle_init_spi(void) {}
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.
262 static struct pxamci_platform_data poodle_mci_platform_data
;
264 static int poodle_mci_init(struct device
*dev
, irq_handler_t poodle_detect_int
, void *data
)
268 err
= gpio_request(POODLE_GPIO_nSD_DETECT
, "nSD_DETECT");
272 err
= gpio_request(POODLE_GPIO_nSD_WP
, "nSD_WP");
276 err
= gpio_request(POODLE_GPIO_SD_PWR
, "SD_PWR");
280 err
= gpio_request(POODLE_GPIO_SD_PWR1
, "SD_PWR1");
284 gpio_direction_input(POODLE_GPIO_nSD_DETECT
);
285 gpio_direction_input(POODLE_GPIO_nSD_WP
);
287 gpio_direction_output(POODLE_GPIO_SD_PWR
, 0);
288 gpio_direction_output(POODLE_GPIO_SD_PWR1
, 0);
290 poodle_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
292 err
= request_irq(POODLE_IRQ_GPIO_nSD_DETECT
, poodle_detect_int
,
293 IRQF_DISABLED
| IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
,
294 "MMC card detect", data
);
296 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
304 gpio_free(POODLE_GPIO_SD_PWR1
);
306 gpio_free(POODLE_GPIO_SD_PWR
);
308 gpio_free(POODLE_GPIO_nSD_WP
);
310 gpio_free(POODLE_GPIO_nSD_DETECT
);
315 static void poodle_mci_setpower(struct device
*dev
, unsigned int vdd
)
317 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
319 if ((1 << vdd
) & p_d
->ocr_mask
) {
320 gpio_set_value(POODLE_GPIO_SD_PWR
, 1);
322 gpio_set_value(POODLE_GPIO_SD_PWR1
, 1);
324 gpio_set_value(POODLE_GPIO_SD_PWR1
, 0);
325 gpio_set_value(POODLE_GPIO_SD_PWR
, 0);
329 static int poodle_mci_get_ro(struct device
*dev
)
331 return !!gpio_get_value(POODLE_GPIO_nSD_WP
);
332 return GPLR(POODLE_GPIO_nSD_WP
) & GPIO_bit(POODLE_GPIO_nSD_WP
);
336 static void poodle_mci_exit(struct device
*dev
, void *data
)
338 free_irq(POODLE_IRQ_GPIO_nSD_DETECT
, data
);
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
);
345 static struct pxamci_platform_data poodle_mci_platform_data
= {
346 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
347 .init
= poodle_mci_init
,
348 .get_ro
= poodle_mci_get_ro
,
349 .setpower
= poodle_mci_setpower
,
350 .exit
= poodle_mci_exit
,
357 static void poodle_irda_transceiver_mode(struct device
*dev
, int mode
)
359 gpio_set_value(POODLE_GPIO_IR_ON
, mode
& IR_OFF
);
360 pxa2xx_transceiver_mode(dev
, mode
);
363 static int poodle_irda_startup(struct device
*dev
)
367 err
= gpio_request(POODLE_GPIO_IR_ON
, "IR_ON");
371 gpio_direction_output(POODLE_GPIO_IR_ON
, 1);
375 static void poodle_irda_shutdown(struct device
*dev
)
377 gpio_free(POODLE_GPIO_IR_ON
);
380 static struct pxaficp_platform_data poodle_ficp_platform_data
= {
381 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
382 .transceiver_mode
= poodle_irda_transceiver_mode
,
383 .startup
= poodle_irda_startup
,
384 .shutdown
= poodle_irda_shutdown
,
389 * USB Device Controller
391 static struct pxa2xx_udc_mach_info udc_info __initdata
= {
392 /* no connect GPIO; poodle can't tell connection status */
393 .gpio_pullup
= POODLE_GPIO_USB_PULLUP
,
398 static struct pxafb_mode_info poodle_fb_mode
= {
409 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
412 static struct pxafb_mach_info poodle_fb_info
= {
413 .modes
= &poodle_fb_mode
,
415 .lcd_conn
= LCD_COLOR_TFT_16BPP
,
418 static struct mtd_partition sharpsl_nand_partitions
[] = {
420 .name
= "System Area",
422 .size
= 7 * 1024 * 1024,
425 .name
= "Root Filesystem",
426 .offset
= 7 * 1024 * 1024,
427 .size
= 22 * 1024 * 1024,
430 .name
= "Home Filesystem",
431 .offset
= MTDPART_OFS_APPEND
,
432 .size
= MTDPART_SIZ_FULL
,
436 static uint8_t scan_ff_pattern
[] = { 0xff, 0xff };
438 static struct nand_bbt_descr sharpsl_bbt
= {
442 .pattern
= scan_ff_pattern
445 static 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
),
451 static struct resource sharpsl_nand_resources
[] = {
455 .flags
= IORESOURCE_MEM
,
459 static struct platform_device sharpsl_nand_device
= {
460 .name
= "sharpsl-nand",
462 .resource
= sharpsl_nand_resources
,
463 .num_resources
= ARRAY_SIZE(sharpsl_nand_resources
),
464 .dev
.platform_data
= &sharpsl_nand_platform_data
,
467 static struct mtd_partition sharpsl_rom_parts
[] = {
469 .name
="Boot PROM Filesystem",
470 .offset
= 0x00120000,
471 .size
= MTDPART_SIZ_FULL
,
475 static struct physmap_flash_data sharpsl_rom_data
= {
477 .nr_parts
= ARRAY_SIZE(sharpsl_rom_parts
),
478 .parts
= sharpsl_rom_parts
,
481 static struct resource sharpsl_rom_resources
[] = {
485 .flags
= IORESOURCE_MEM
,
489 static struct platform_device sharpsl_rom_device
= {
490 .name
= "physmap-flash",
492 .resource
= sharpsl_rom_resources
,
493 .num_resources
= ARRAY_SIZE(sharpsl_rom_resources
),
494 .dev
.platform_data
= &sharpsl_rom_data
,
497 static struct platform_device
*devices
[] __initdata
= {
498 &poodle_locomo_device
,
499 &poodle_scoop_device
,
500 &sharpsl_nand_device
,
504 static void poodle_poweroff(void)
506 arm_machine_restart('h');
509 static void poodle_restart(char mode
)
511 arm_machine_restart('h');
514 static void __init
poodle_init(void)
518 pm_power_off
= poodle_poweroff
;
519 arm_pm_restart
= poodle_restart
;
523 pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config
));
525 platform_scoop_config
= &poodle_pcmcia_config
;
527 ret
= platform_add_devices(devices
, ARRAY_SIZE(devices
));
529 pr_warning("poodle: Unable to register LoCoMo device\n");
531 set_pxa_fb_parent(&poodle_locomo_device
.dev
);
532 set_pxa_fb_info(&poodle_fb_info
);
533 pxa_set_udc_info(&udc_info
);
534 pxa_set_mci_info(&poodle_mci_platform_data
);
535 pxa_set_ficp_info(&poodle_ficp_platform_data
);
536 pxa_set_i2c_info(NULL
);
540 static void __init
fixup_poodle(struct machine_desc
*desc
,
541 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
543 sharpsl_save_param();
545 mi
->bank
[0].start
= 0xa0000000;
546 mi
->bank
[0].node
= 0;
547 mi
->bank
[0].size
= (32*1024*1024);
550 MACHINE_START(POODLE
, "SHARP Poodle")
551 .phys_io
= 0x40000000,
552 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
553 .fixup
= fixup_poodle
,
554 .map_io
= pxa_map_io
,
555 .init_irq
= pxa25x_init_irq
,
557 .init_machine
= poodle_init
,