Merge git://git.infradead.org/mtd-2.6
[pandora-kernel.git] / arch / arm / mach-pxa / pcm027.c
1 /*
2  *  linux/arch/arm/mach-pxa/pcm027.c
3  *  Support for the Phytec phyCORE-PXA270 CPU card (aka PCM-027).
4  *
5  *  Refer
6  *   http://www.phytec.com/products/sbc/ARM-XScale/phyCORE-XScale-PXA270.html
7  *  for additional hardware info
8  *
9  *  Author:     Juergen Kilb
10  *  Created:    April 05, 2005
11  *  Copyright:  Phytec Messtechnik GmbH
12  *  e-Mail:     armlinux@phytec.de
13  *
14  *  based on Intel Mainstone Board
15  *
16  *  Copyright 2007 Juergen Beisert @ Pengutronix (j.beisert@pengutronix.de)
17  *
18  *  This program is free software; you can redistribute it and/or modify
19  *  it under the terms of the GNU General Public License version 2 as
20  *  published by the Free Software Foundation.
21  */
22
23 #include <linux/irq.h>
24 #include <linux/platform_device.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/spi/spi.h>
27 #include <linux/leds.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/arch/hardware.h>
31 #include <asm/arch/pxa-regs.h>
32 #include <asm/arch/pxa2xx-regs.h>
33 #include <asm/arch/pxa2xx_spi.h>
34 #include <asm/arch/pcm027.h>
35 #include "generic.h"
36
37 /*
38  * ABSTRACT:
39  *
40  * The PXA270 processor comes with a bunch of hardware on its silicon.
41  * Not all of this hardware can be used at the same time and not all
42  * is routed to module's connectors. Also it depends on the baseboard, what
43  * kind of hardware can be used in which way.
44  * -> So this file supports the main devices on the CPU card only!
45  * Refer pcm990-baseboard.c how to extend this features to get a full
46  * blown system with many common interfaces.
47  *
48  * The PCM-027 supports the following interfaces through its connectors and
49  * will be used in pcm990-baseboard.c:
50  *
51  * - LCD support
52  * - MMC support
53  * - IDE/CF card
54  * - FFUART
55  * - BTUART
56  * - IRUART
57  * - AC97
58  * - SSP
59  * - SSP3
60  *
61  * Claimed GPIOs:
62  * GPIO0 -> IRQ input from RTC
63  * GPIO2 -> SYS_ENA*)
64  * GPIO3 -> PWR_SCL
65  * GPIO4 -> PWR_SDA
66  * GPIO5 -> PowerCap0*)
67  * GPIO6 -> PowerCap1*)
68  * GPIO7 -> PowerCap2*)
69  * GPIO8 -> PowerCap3*)
70  * GPIO15 -> /CS1
71  * GPIO20 -> /CS2
72  * GPIO21 -> /CS3
73  * GPIO33 -> /CS5 network controller select
74  * GPIO52 -> IRQ from network controller
75  * GPIO78 -> /CS2
76  * GPIO80 -> /CS4
77  * GPIO90 -> LED0
78  * GPIO91 -> LED1
79  * GPIO114 -> IRQ from CAN controller
80  * GPIO117 -> SCL
81  * GPIO118 -> SDA
82  *
83  * *) CPU internal use only
84  */
85
86 /*
87  * SMC91x network controller specific stuff
88  */
89 static struct resource smc91x_resources[] = {
90         [0] = {
91                 .start  = PCM027_ETH_PHYS + 0x300,
92                 .end    = PCM027_ETH_PHYS + PCM027_ETH_SIZE,
93                 .flags  = IORESOURCE_MEM,
94         },
95         [1] = {
96                 .start  = PCM027_ETH_IRQ,
97                 .end    = PCM027_ETH_IRQ,
98                 /* note: smc91x's driver doesn't use the trigger bits yet */
99                 .flags  = IORESOURCE_IRQ | PCM027_ETH_IRQ_EDGE,
100         }
101 };
102
103 static struct platform_device smc91x_device = {
104         .name           = "smc91x",
105         .id             = 0,
106         .num_resources  = ARRAY_SIZE(smc91x_resources),
107         .resource       = smc91x_resources,
108 };
109
110 static struct physmap_flash_data pcm027_flash_data = {
111         .width  = 4,
112 };
113
114 static struct resource pcm027_flash_resource = {
115         .start          = PCM027_FLASH_PHYS,
116         .end            = PCM027_FLASH_PHYS + PCM027_FLASH_SIZE - 1 ,
117         .flags          = IORESOURCE_MEM,
118 };
119
120 static struct platform_device pcm027_flash = {
121         .name           = "physmap-flash",
122         .id             = 0,
123         .dev            = {
124                 .platform_data  = &pcm027_flash_data,
125         },
126         .resource       = &pcm027_flash_resource,
127         .num_resources  = 1,
128 };
129
130 #ifdef CONFIG_LEDS_GPIO
131
132 static struct gpio_led pcm027_led[] = {
133         {
134                 .name = "led0:red",     /* FIXME */
135                 .gpio = PCM027_LED_CPU
136         },
137         {
138                 .name = "led1:green",   /* FIXME */
139                 .gpio = PCM027_LED_HEARD_BEAT
140         },
141 };
142
143 static struct gpio_led_platform_data pcm027_led_data = {
144         .num_leds       = ARRAY_SIZE(pcm027_led),
145         .leds           = pcm027_led
146 };
147
148 static struct platform_device pcm027_led_dev = {
149         .name           = "leds-gpio",
150         .id             = 0,
151         .dev            = {
152                 .platform_data  = &pcm027_led_data,
153         },
154 };
155
156 #endif /* CONFIG_LEDS_GPIO */
157
158 /*
159  * declare the available device resources on this board
160  */
161 static struct platform_device *devices[] __initdata = {
162         &smc91x_device,
163         &pcm027_flash,
164 #ifdef CONFIG_LEDS_GPIO
165         &pcm027_led_dev
166 #endif
167 };
168
169 /*
170  * pcm027_init - breath some life into the board
171  */
172 static void __init pcm027_init(void)
173 {
174         /* system bus arbiter setting
175          * - Core_Park
176          * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
177          */
178         ARB_CNTRL = ARB_CORE_PARK | 0x234;
179
180         platform_add_devices(devices, ARRAY_SIZE(devices));
181
182         /* LEDs (on demand only) */
183 #ifdef CONFIG_LEDS_GPIO
184         pxa_gpio_mode(PCM027_LED_CPU | GPIO_OUT);
185         pxa_gpio_mode(PCM027_LED_HEARD_BEAT | GPIO_OUT);
186 #endif /* CONFIG_LEDS_GPIO */
187
188         /* at last call the baseboard to initialize itself */
189 #ifdef CONFIG_MACH_PCM990_BASEBOARD
190         pcm990_baseboard_init();
191 #endif
192 }
193
194 static void __init pcm027_map_io(void)
195 {
196         pxa_map_io();
197
198         /* initialize sleep mode regs (wake-up sources, etc) */
199         PGSR0 = 0x01308000;
200         PGSR1 = 0x00CF0002;
201         PGSR2 = 0x0E294000;
202         PGSR3 = 0x0000C000;
203         PWER  = 0x40000000 | PWER_GPIO0 | PWER_GPIO1;
204         PRER  = 0x00000000;
205         PFER  = 0x00000003;
206 }
207
208 MACHINE_START(PCM027, "Phytec Messtechnik GmbH phyCORE-PXA270")
209         /* Maintainer: Pengutronix */
210         .boot_params    = 0xa0000100,
211         .phys_io        = 0x40000000,
212         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
213         .map_io         = pcm027_map_io,
214         .init_irq       = pxa27x_init_irq,
215         .timer          = &pxa_timer,
216         .init_machine   = pcm027_init,
217 MACHINE_END