2 * linux/arch/arm/mach-pxa/mainstone.c
4 * Support for the Intel HCDDBBVA0 Development Platform.
5 * (go figure how they came up with such name...)
7 * Author: Nicolas Pitre
8 * Created: Nov 05, 2002
9 * Copyright: MontaVista Software Inc.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 #include <linux/gpio.h>
16 #include <linux/gpio/gpio-reg.h>
17 #include <linux/gpio/machine.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/syscore_ops.h>
21 #include <linux/interrupt.h>
22 #include <linux/sched.h>
23 #include <linux/bitops.h>
25 #include <linux/ioport.h>
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/input.h>
29 #include <linux/gpio_keys.h>
30 #include <linux/pwm.h>
31 #include <linux/pwm_backlight.h>
32 #include <linux/smc91x.h>
33 #include <linux/platform_data/i2c-pxa.h>
34 #include <linux/slab.h>
35 #include <linux/leds.h>
37 #include <asm/types.h>
38 #include <asm/setup.h>
39 #include <asm/memory.h>
40 #include <asm/mach-types.h>
41 #include <mach/hardware.h>
43 #include <asm/sizes.h>
45 #include <asm/mach/arch.h>
46 #include <asm/mach/map.h>
47 #include <asm/mach/irq.h>
48 #include <asm/mach/flash.h>
51 #include <mach/mainstone.h>
52 #include <mach/audio.h>
53 #include <linux/platform_data/video-pxafb.h>
54 #include <linux/platform_data/mmc-pxamci.h>
55 #include <linux/platform_data/irda-pxaficp.h>
56 #include <linux/platform_data/usb-ohci-pxa27x.h>
57 #include <linux/platform_data/keypad-pxa27x.h>
58 #include <mach/smemc.h>
63 static unsigned long mainstone_pin_config
[] = {
67 /* LCD - 16bpp Active TFT */
69 GPIO16_PWM0_OUT
, /* Backlight */
97 GPIO29_AC97_SDATA_IN_0
,
98 GPIO30_AC97_SDATA_OUT
,
106 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
107 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
108 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
109 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
110 GPIO98_KP_MKIN_4
| WAKEUP_ON_LEVEL_HIGH
,
111 GPIO99_KP_MKIN_5
| WAKEUP_ON_LEVEL_HIGH
,
125 GPIO1_GPIO
| WAKEUP_ON_EDGE_BOTH
,
128 static struct resource smc91x_resources
[] = {
130 .start
= (MST_ETH_PHYS
+ 0x300),
131 .end
= (MST_ETH_PHYS
+ 0xfffff),
132 .flags
= IORESOURCE_MEM
,
135 .start
= MAINSTONE_IRQ(3),
136 .end
= MAINSTONE_IRQ(3),
137 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
141 static struct smc91x_platdata mainstone_smc91x_info
= {
142 .flags
= SMC91X_USE_8BIT
| SMC91X_USE_16BIT
| SMC91X_USE_32BIT
|
143 SMC91X_NOWAIT
| SMC91X_USE_DMA
,
144 .pxa_u16_align4
= true,
147 static struct platform_device smc91x_device
= {
150 .num_resources
= ARRAY_SIZE(smc91x_resources
),
151 .resource
= smc91x_resources
,
153 .platform_data
= &mainstone_smc91x_info
,
157 static int mst_audio_startup(struct snd_pcm_substream
*substream
, void *priv
)
159 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
160 MST_MSCWR2
&= ~MST_MSCWR2_AC97_SPKROFF
;
164 static void mst_audio_shutdown(struct snd_pcm_substream
*substream
, void *priv
)
166 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
167 MST_MSCWR2
|= MST_MSCWR2_AC97_SPKROFF
;
170 static long mst_audio_suspend_mask
;
172 static void mst_audio_suspend(void *priv
)
174 mst_audio_suspend_mask
= MST_MSCWR2
;
175 MST_MSCWR2
|= MST_MSCWR2_AC97_SPKROFF
;
178 static void mst_audio_resume(void *priv
)
180 MST_MSCWR2
&= mst_audio_suspend_mask
| ~MST_MSCWR2_AC97_SPKROFF
;
183 static pxa2xx_audio_ops_t mst_audio_ops
= {
184 .startup
= mst_audio_startup
,
185 .shutdown
= mst_audio_shutdown
,
186 .suspend
= mst_audio_suspend
,
187 .resume
= mst_audio_resume
,
190 static struct resource flash_resources
[] = {
192 .start
= PXA_CS0_PHYS
,
193 .end
= PXA_CS0_PHYS
+ SZ_64M
- 1,
194 .flags
= IORESOURCE_MEM
,
197 .start
= PXA_CS1_PHYS
,
198 .end
= PXA_CS1_PHYS
+ SZ_64M
- 1,
199 .flags
= IORESOURCE_MEM
,
203 static struct mtd_partition mainstoneflash0_partitions
[] = {
205 .name
= "Bootloader",
208 .mask_flags
= MTD_WRITEABLE
/* force read-only */
212 .offset
= 0x00040000,
214 .name
= "Filesystem",
215 .size
= MTDPART_SIZ_FULL
,
220 static struct flash_platform_data mst_flash_data
[2] = {
222 .map_name
= "cfi_probe",
223 .parts
= mainstoneflash0_partitions
,
224 .nr_parts
= ARRAY_SIZE(mainstoneflash0_partitions
),
226 .map_name
= "cfi_probe",
232 static struct platform_device mst_flash_device
[2] = {
234 .name
= "pxa2xx-flash",
237 .platform_data
= &mst_flash_data
[0],
239 .resource
= &flash_resources
[0],
243 .name
= "pxa2xx-flash",
246 .platform_data
= &mst_flash_data
[1],
248 .resource
= &flash_resources
[1],
253 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
254 static struct pwm_lookup mainstone_pwm_lookup
[] = {
255 PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL
, 78770,
256 PWM_POLARITY_NORMAL
),
259 static struct platform_pwm_backlight_data mainstone_backlight_data
= {
260 .max_brightness
= 1023,
261 .dft_brightness
= 1023,
265 static struct platform_device mainstone_backlight_device
= {
266 .name
= "pwm-backlight",
268 .parent
= &pxa27x_device_pwm0
.dev
,
269 .platform_data
= &mainstone_backlight_data
,
273 static void __init
mainstone_backlight_register(void)
277 pwm_add_table(mainstone_pwm_lookup
, ARRAY_SIZE(mainstone_pwm_lookup
));
279 ret
= platform_device_register(&mainstone_backlight_device
);
281 printk(KERN_ERR
"mainstone: failed to register backlight device: %d\n", ret
);
282 pwm_remove_table(mainstone_pwm_lookup
,
283 ARRAY_SIZE(mainstone_pwm_lookup
));
287 #define mainstone_backlight_register() do { } while (0)
290 static struct pxafb_mode_info toshiba_ltm04c380k_mode
= {
301 .sync
= FB_SYNC_HOR_HIGH_ACT
|FB_SYNC_VERT_HIGH_ACT
,
304 static struct pxafb_mode_info toshiba_ltm035a776c_mode
= {
315 .sync
= FB_SYNC_HOR_HIGH_ACT
|FB_SYNC_VERT_HIGH_ACT
,
318 static struct pxafb_mach_info mainstone_pxafb_info
= {
320 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
323 static int mainstone_mci_init(struct device
*dev
, irq_handler_t mstone_detect_int
, void *data
)
327 /* make sure SD/Memory Stick multiplexer's signals
328 * are routed to MMC controller
330 MST_MSCWR1
&= ~MST_MSCWR1_MS_SEL
;
332 err
= request_irq(MAINSTONE_MMC_IRQ
, mstone_detect_int
, 0,
333 "MMC card detect", data
);
335 printk(KERN_ERR
"mainstone_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
340 static int mainstone_mci_setpower(struct device
*dev
, unsigned int vdd
)
342 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
344 if (( 1 << vdd
) & p_d
->ocr_mask
) {
345 printk(KERN_DEBUG
"%s: on\n", __func__
);
346 MST_MSCWR1
|= MST_MSCWR1_MMC_ON
;
347 MST_MSCWR1
&= ~MST_MSCWR1_MS_SEL
;
349 printk(KERN_DEBUG
"%s: off\n", __func__
);
350 MST_MSCWR1
&= ~MST_MSCWR1_MMC_ON
;
355 static void mainstone_mci_exit(struct device
*dev
, void *data
)
357 free_irq(MAINSTONE_MMC_IRQ
, data
);
360 static struct pxamci_platform_data mainstone_mci_platform_data
= {
361 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
362 .init
= mainstone_mci_init
,
363 .setpower
= mainstone_mci_setpower
,
364 .exit
= mainstone_mci_exit
,
367 static void mainstone_irda_transceiver_mode(struct device
*dev
, int mode
)
371 local_irq_save(flags
);
372 if (mode
& IR_SIRMODE
) {
373 MST_MSCWR1
&= ~MST_MSCWR1_IRDA_FIR
;
374 } else if (mode
& IR_FIRMODE
) {
375 MST_MSCWR1
|= MST_MSCWR1_IRDA_FIR
;
377 pxa2xx_transceiver_mode(dev
, mode
);
379 MST_MSCWR1
= (MST_MSCWR1
& ~MST_MSCWR1_IRDA_MASK
) | MST_MSCWR1_IRDA_OFF
;
381 MST_MSCWR1
= (MST_MSCWR1
& ~MST_MSCWR1_IRDA_MASK
) | MST_MSCWR1_IRDA_FULL
;
383 local_irq_restore(flags
);
386 static struct pxaficp_platform_data mainstone_ficp_platform_data
= {
388 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
389 .transceiver_mode
= mainstone_irda_transceiver_mode
,
392 static struct gpio_keys_button gpio_keys_button
[] = {
402 static struct gpio_keys_platform_data mainstone_gpio_keys
= {
403 .buttons
= gpio_keys_button
,
407 static struct platform_device mst_gpio_keys_device
= {
411 .platform_data
= &mainstone_gpio_keys
,
415 static struct resource mst_cplds_resources
[] = {
417 .start
= MST_FPGA_PHYS
+ 0xc0,
418 .end
= MST_FPGA_PHYS
+ 0xe0 - 1,
419 .flags
= IORESOURCE_MEM
,
422 .start
= PXA_GPIO_TO_IRQ(0),
423 .end
= PXA_GPIO_TO_IRQ(0),
424 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
427 .start
= MAINSTONE_IRQ(0),
428 .end
= MAINSTONE_IRQ(15),
429 .flags
= IORESOURCE_IRQ
,
433 static struct platform_device mst_cplds_device
= {
434 .name
= "pxa_cplds_irqs",
436 .resource
= &mst_cplds_resources
[0],
440 static struct platform_device
*platform_devices
[] __initdata
= {
442 &mst_flash_device
[0],
443 &mst_flash_device
[1],
444 &mst_gpio_keys_device
,
448 static struct pxaohci_platform_data mainstone_ohci_platform_data
= {
449 .port_mode
= PMM_PERPORT_MODE
,
450 .flags
= ENABLE_PORT_ALL
| POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
453 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
454 static const unsigned int mainstone_matrix_keys
[] = {
455 KEY(0, 0, KEY_A
), KEY(1, 0, KEY_B
), KEY(2, 0, KEY_C
),
456 KEY(3, 0, KEY_D
), KEY(4, 0, KEY_E
), KEY(5, 0, KEY_F
),
457 KEY(0, 1, KEY_G
), KEY(1, 1, KEY_H
), KEY(2, 1, KEY_I
),
458 KEY(3, 1, KEY_J
), KEY(4, 1, KEY_K
), KEY(5, 1, KEY_L
),
459 KEY(0, 2, KEY_M
), KEY(1, 2, KEY_N
), KEY(2, 2, KEY_O
),
460 KEY(3, 2, KEY_P
), KEY(4, 2, KEY_Q
), KEY(5, 2, KEY_R
),
461 KEY(0, 3, KEY_S
), KEY(1, 3, KEY_T
), KEY(2, 3, KEY_U
),
462 KEY(3, 3, KEY_V
), KEY(4, 3, KEY_W
), KEY(5, 3, KEY_X
),
463 KEY(2, 4, KEY_Y
), KEY(3, 4, KEY_Z
),
465 KEY(0, 4, KEY_DOT
), /* . */
466 KEY(1, 4, KEY_CLOSE
), /* @ */
467 KEY(4, 4, KEY_SLASH
),
468 KEY(5, 4, KEY_BACKSLASH
),
470 KEY(1, 5, KEY_LEFTSHIFT
),
471 KEY(2, 5, KEY_SPACE
),
472 KEY(3, 5, KEY_SPACE
),
473 KEY(4, 5, KEY_ENTER
),
474 KEY(5, 5, KEY_BACKSPACE
),
479 KEY(3, 6, KEY_RIGHT
),
480 KEY(4, 6, KEY_SELECT
),
483 static struct matrix_keymap_data mainstone_matrix_keymap_data
= {
484 .keymap
= mainstone_matrix_keys
,
485 .keymap_size
= ARRAY_SIZE(mainstone_matrix_keys
),
488 struct pxa27x_keypad_platform_data mainstone_keypad_info
= {
489 .matrix_key_rows
= 6,
490 .matrix_key_cols
= 7,
491 .matrix_keymap_data
= &mainstone_matrix_keymap_data
,
494 .rotary0_up_key
= KEY_UP
,
495 .rotary0_down_key
= KEY_DOWN
,
497 .debounce_interval
= 30,
500 static void __init
mainstone_init_keypad(void)
502 pxa_set_keypad_info(&mainstone_keypad_info
);
505 static inline void mainstone_init_keypad(void) {}
508 static int mst_pcmcia0_irqs
[11] = {
510 [5] = MAINSTONE_S0_CD_IRQ
,
511 [8] = MAINSTONE_S0_STSCHG_IRQ
,
512 [10] = MAINSTONE_S0_IRQ
,
515 static int mst_pcmcia1_irqs
[11] = {
517 [5] = MAINSTONE_S1_CD_IRQ
,
518 [8] = MAINSTONE_S1_STSCHG_IRQ
,
519 [10] = MAINSTONE_S1_IRQ
,
522 static struct gpiod_lookup_table mainstone_pcmcia_gpio_table
= {
523 .dev_id
= "pxa2xx-pcmcia",
525 GPIO_LOOKUP("mst-pcmcia0", 0, "a0vpp", GPIO_ACTIVE_HIGH
),
526 GPIO_LOOKUP("mst-pcmcia0", 1, "a1vpp", GPIO_ACTIVE_HIGH
),
527 GPIO_LOOKUP("mst-pcmcia0", 2, "a0vcc", GPIO_ACTIVE_HIGH
),
528 GPIO_LOOKUP("mst-pcmcia0", 3, "a1vcc", GPIO_ACTIVE_HIGH
),
529 GPIO_LOOKUP("mst-pcmcia0", 4, "areset", GPIO_ACTIVE_HIGH
),
530 GPIO_LOOKUP("mst-pcmcia0", 5, "adetect", GPIO_ACTIVE_LOW
),
531 GPIO_LOOKUP("mst-pcmcia0", 6, "avs1", GPIO_ACTIVE_LOW
),
532 GPIO_LOOKUP("mst-pcmcia0", 7, "avs2", GPIO_ACTIVE_LOW
),
533 GPIO_LOOKUP("mst-pcmcia0", 8, "abvd1", GPIO_ACTIVE_HIGH
),
534 GPIO_LOOKUP("mst-pcmcia0", 9, "abvd2", GPIO_ACTIVE_HIGH
),
535 GPIO_LOOKUP("mst-pcmcia0", 10, "aready", GPIO_ACTIVE_HIGH
),
536 GPIO_LOOKUP("mst-pcmcia1", 0, "b0vpp", GPIO_ACTIVE_HIGH
),
537 GPIO_LOOKUP("mst-pcmcia1", 1, "b1vpp", GPIO_ACTIVE_HIGH
),
538 GPIO_LOOKUP("mst-pcmcia1", 2, "b0vcc", GPIO_ACTIVE_HIGH
),
539 GPIO_LOOKUP("mst-pcmcia1", 3, "b1vcc", GPIO_ACTIVE_HIGH
),
540 GPIO_LOOKUP("mst-pcmcia1", 4, "breset", GPIO_ACTIVE_HIGH
),
541 GPIO_LOOKUP("mst-pcmcia1", 5, "bdetect", GPIO_ACTIVE_LOW
),
542 GPIO_LOOKUP("mst-pcmcia1", 6, "bvs1", GPIO_ACTIVE_LOW
),
543 GPIO_LOOKUP("mst-pcmcia1", 7, "bvs2", GPIO_ACTIVE_LOW
),
544 GPIO_LOOKUP("mst-pcmcia1", 8, "bbvd1", GPIO_ACTIVE_HIGH
),
545 GPIO_LOOKUP("mst-pcmcia1", 9, "bbvd2", GPIO_ACTIVE_HIGH
),
546 GPIO_LOOKUP("mst-pcmcia1", 10, "bready", GPIO_ACTIVE_HIGH
),
551 static void __init
mainstone_init(void)
553 int SW7
= 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
555 pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config
));
557 /* Register board control register(s) as GPIOs */
558 gpio_reg_init(NULL
, (void __iomem
*)&MST_PCMCIA0
, -1, 11,
559 "mst-pcmcia0", MST_PCMCIA_INPUTS
, 0, NULL
,
560 NULL
, mst_pcmcia0_irqs
);
561 gpio_reg_init(NULL
, (void __iomem
*)&MST_PCMCIA1
, -1, 11,
562 "mst-pcmcia1", MST_PCMCIA_INPUTS
, 0, NULL
,
563 NULL
, mst_pcmcia1_irqs
);
564 gpiod_add_lookup_table(&mainstone_pcmcia_gpio_table
);
566 pxa_set_ffuart_info(NULL
);
567 pxa_set_btuart_info(NULL
);
568 pxa_set_stuart_info(NULL
);
570 mst_flash_data
[0].width
= (__raw_readl(BOOT_DEF
) & 1) ? 2 : 4;
571 mst_flash_data
[1].width
= 4;
573 /* Compensate for SW7 which swaps the flash banks */
574 mst_flash_data
[SW7
].name
= "processor-flash";
575 mst_flash_data
[SW7
^ 1].name
= "mainboard-flash";
577 printk(KERN_NOTICE
"Mainstone configured to boot from %s\n",
578 mst_flash_data
[0].name
);
580 /* system bus arbiter setting
582 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
584 ARB_CNTRL
= ARB_CORE_PARK
| 0x234;
586 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));
588 /* reading Mainstone's "Virtual Configuration Register"
589 might be handy to select LCD type here */
591 mainstone_pxafb_info
.modes
= &toshiba_ltm04c380k_mode
;
593 mainstone_pxafb_info
.modes
= &toshiba_ltm035a776c_mode
;
595 pxa_set_fb_info(NULL
, &mainstone_pxafb_info
);
596 mainstone_backlight_register();
598 pxa_set_mci_info(&mainstone_mci_platform_data
);
599 pxa_set_ficp_info(&mainstone_ficp_platform_data
);
600 pxa_set_ohci_info(&mainstone_ohci_platform_data
);
601 pxa_set_i2c_info(NULL
);
602 pxa_set_ac97_info(&mst_audio_ops
);
604 mainstone_init_keypad();
608 static struct map_desc mainstone_io_desc
[] __initdata
= {
610 .virtual = MST_FPGA_VIRT
,
611 .pfn
= __phys_to_pfn(MST_FPGA_PHYS
),
612 .length
= 0x00100000,
617 static void __init
mainstone_map_io(void)
620 iotable_init(mainstone_io_desc
, ARRAY_SIZE(mainstone_io_desc
));
622 /* for use I SRAM as framebuffer. */
628 * Driver for the 8 discrete LEDs available for general use:
629 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
630 * so be sure to not monkey with them here.
633 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
634 struct mainstone_led
{
635 struct led_classdev cdev
;
640 * The triggers lines up below will only be used if the
641 * LED triggers are compiled in.
643 static const struct {
646 } mainstone_leds
[] = {
647 { "mainstone:D28", "default-on", },
648 { "mainstone:D27", "cpu0", },
649 { "mainstone:D26", "heartbeat" },
650 { "mainstone:D25", },
651 { "mainstone:D24", },
652 { "mainstone:D23", },
653 { "mainstone:D22", },
654 { "mainstone:D21", },
657 static void mainstone_led_set(struct led_classdev
*cdev
,
658 enum led_brightness b
)
660 struct mainstone_led
*led
= container_of(cdev
,
661 struct mainstone_led
, cdev
);
662 u32 reg
= MST_LEDCTRL
;
672 static enum led_brightness
mainstone_led_get(struct led_classdev
*cdev
)
674 struct mainstone_led
*led
= container_of(cdev
,
675 struct mainstone_led
, cdev
);
676 u32 reg
= MST_LEDCTRL
;
678 return (reg
& led
->mask
) ? LED_FULL
: LED_OFF
;
681 static int __init
mainstone_leds_init(void)
685 if (!machine_is_mainstone())
690 for (i
= 0; i
< ARRAY_SIZE(mainstone_leds
); i
++) {
691 struct mainstone_led
*led
;
693 led
= kzalloc(sizeof(*led
), GFP_KERNEL
);
697 led
->cdev
.name
= mainstone_leds
[i
].name
;
698 led
->cdev
.brightness_set
= mainstone_led_set
;
699 led
->cdev
.brightness_get
= mainstone_led_get
;
700 led
->cdev
.default_trigger
= mainstone_leds
[i
].trigger
;
703 if (led_classdev_register(NULL
, &led
->cdev
) < 0) {
713 * Since we may have triggers on any subsystem, defer registration
714 * until after subsystem_init.
716 fs_initcall(mainstone_leds_init
);
719 MACHINE_START(MAINSTONE
, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
720 /* Maintainer: MontaVista Software Inc. */
721 .atag_offset
= 0x100, /* BLOB boot parameter setting */
722 .map_io
= mainstone_map_io
,
723 .nr_irqs
= MAINSTONE_NR_IRQS
,
724 .init_irq
= pxa27x_init_irq
,
725 .handle_irq
= pxa27x_handle_irq
,
726 .init_time
= pxa_timer_init
,
727 .init_machine
= mainstone_init
,
728 .restart
= pxa_restart
,