]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - arch/arm/mach-pxa/corgi.c
[PATCH] Input: Add a new switch event type
[thirdparty/kernel/stable.git] / arch / arm / mach-pxa / corgi.c
CommitLineData
1da177e4
LT
1/*
2 * Support for Sharp SL-C7xx PDAs
3 * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky)
4 *
5 * Copyright (c) 2004-2005 Richard Purdie
6 *
7 * Based on Sharp's 2.4 kernel patches/lubbock.c
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 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/device.h>
18#include <linux/major.h>
19#include <linux/fs.h>
20#include <linux/interrupt.h>
21#include <linux/mmc/host.h>
22
23#include <asm/setup.h>
24#include <asm/memory.h>
25#include <asm/mach-types.h>
26#include <asm/hardware.h>
27#include <asm/irq.h>
28#include <asm/io.h>
29
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33
34#include <asm/arch/pxa-regs.h>
35#include <asm/arch/irq.h>
36#include <asm/arch/mmc.h>
37#include <asm/arch/udc.h>
38#include <asm/arch/corgi.h>
39
40#include <asm/mach/sharpsl_param.h>
41#include <asm/hardware/scoop.h>
1da177e4
LT
42
43#include "generic.h"
44
45
46/*
47 * Corgi SCOOP Device
48 */
49static struct resource corgi_scoop_resources[] = {
50 [0] = {
51 .start = 0x10800000,
52 .end = 0x10800fff,
53 .flags = IORESOURCE_MEM,
54 },
55};
56
57static struct scoop_config corgi_scoop_setup = {
58 .io_dir = CORGI_SCOOP_IO_DIR,
59 .io_out = CORGI_SCOOP_IO_OUT,
60};
61
0ce7625f
RP
62static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
63{
64 .dev = &corgiscoop_device.dev,
65 .irq = CORGI_IRQ_GPIO_CF_IRQ,
66 .cd_irq = CORGI_IRQ_GPIO_CF_CD,
67 .cd_irq_str = "PCMCIA0 CD",
68},
69};
70
1da177e4
LT
71struct platform_device corgiscoop_device = {
72 .name = "sharp-scoop",
73 .id = -1,
74 .dev = {
75 .platform_data = &corgi_scoop_setup,
76 },
77 .num_resources = ARRAY_SIZE(corgi_scoop_resources),
78 .resource = corgi_scoop_resources,
79};
80
81
82/*
83 * Corgi SSP Device
84 *
85 * Set the parent as the scoop device because a lot of SSP devices
86 * also use scoop functions and this makes the power up/down order
87 * work correctly.
88 */
41b1bce8 89struct platform_device corgissp_device = {
1da177e4
LT
90 .name = "corgi-ssp",
91 .dev = {
92 .parent = &corgiscoop_device.dev,
93 },
94 .id = -1,
95};
96
97
1da177e4
LT
98/*
99 * Corgi Backlight Device
100 */
101static struct platform_device corgibl_device = {
102 .name = "corgi-bl",
103 .dev = {
104 .parent = &corgifb_device.dev,
105 },
106 .id = -1,
107};
108
109
110/*
111 * MMC/SD Device
112 *
113 * The card detect interrupt isn't debounced so we delay it by HZ/4
114 * to give the card a chance to fully insert/eject.
115 */
116static struct mmc_detect {
117 struct timer_list detect_timer;
118 void *devid;
119} mmc_detect;
120
121static void mmc_detect_callback(unsigned long data)
122{
123 mmc_detect_change(mmc_detect.devid);
124}
125
126static irqreturn_t corgi_mmc_detect_int(int irq, void *devid, struct pt_regs *regs)
127{
128 mmc_detect.devid=devid;
129 mod_timer(&mmc_detect.detect_timer, jiffies + HZ/4);
130 return IRQ_HANDLED;
131}
132
133static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(int, void *, struct pt_regs *), void *data)
134{
135 int err;
136
137 /* setup GPIO for PXA25x MMC controller */
138 pxa_gpio_mode(GPIO6_MMCCLK_MD);
139 pxa_gpio_mode(GPIO8_MMCCS0_MD);
140 pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN);
141 pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT);
142
143 init_timer(&mmc_detect.detect_timer);
144 mmc_detect.detect_timer.function = mmc_detect_callback;
145 mmc_detect.detect_timer.data = (unsigned long) &mmc_detect;
146
147 err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_mmc_detect_int, SA_INTERRUPT,
148 "MMC card detect", data);
149 if (err) {
150 printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
151 return -1;
152 }
153
154 set_irq_type(CORGI_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
155
156 return 0;
157}
158
159static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
160{
161 struct pxamci_platform_data* p_d = dev->platform_data;
162
163 if (( 1 << vdd) & p_d->ocr_mask) {
164 printk(KERN_DEBUG "%s: on\n", __FUNCTION__);
165 GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
166 } else {
167 printk(KERN_DEBUG "%s: off\n", __FUNCTION__);
168 GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
169 }
170}
171
172static void corgi_mci_exit(struct device *dev, void *data)
173{
174 free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
175 del_timer(&mmc_detect.detect_timer);
176}
177
178static struct pxamci_platform_data corgi_mci_platform_data = {
179 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
180 .init = corgi_mci_init,
181 .setpower = corgi_mci_setpower,
182 .exit = corgi_mci_exit,
183};
184
185
186/*
187 * USB Device Controller
188 */
189static void corgi_udc_command(int cmd)
190{
191 switch(cmd) {
192 case PXA2XX_UDC_CMD_CONNECT:
193 GPSR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
194 break;
195 case PXA2XX_UDC_CMD_DISCONNECT:
196 GPCR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
197 break;
198 }
199}
200
201static struct pxa2xx_udc_mach_info udc_info __initdata = {
202 /* no connect GPIO; corgi can't tell connection status */
203 .udc_command = corgi_udc_command,
204};
205
206
207static struct platform_device *devices[] __initdata = {
208 &corgiscoop_device,
209 &corgissp_device,
210 &corgifb_device,
211 &corgibl_device,
212};
213
214static void __init corgi_init(void)
215{
1da177e4
LT
216 pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT);
217 pxa_set_udc_info(&udc_info);
218 pxa_set_mci_info(&corgi_mci_platform_data);
219
0ce7625f
RP
220 scoop_num = 1;
221 scoop_devs = &corgi_pcmcia_scoop[0];
222
1da177e4
LT
223 platform_add_devices(devices, ARRAY_SIZE(devices));
224}
225
226static void __init fixup_corgi(struct machine_desc *desc,
227 struct tag *tags, char **cmdline, struct meminfo *mi)
228{
229 sharpsl_save_param();
230 mi->nr_banks=1;
231 mi->bank[0].start = 0xa0000000;
232 mi->bank[0].node = 0;
233 if (machine_is_corgi())
234 mi->bank[0].size = (32*1024*1024);
235 else
236 mi->bank[0].size = (64*1024*1024);
237}
238
239static void __init corgi_init_irq(void)
240{
241 pxa_init_irq();
242}
243
244static struct map_desc corgi_io_desc[] __initdata = {
245/* virtual physical length */
246/* { 0xf1000000, 0x08000000, 0x01000000, MT_DEVICE },*/ /* LCDC (readable for Qt driver) */
247/* { 0xef700000, 0x10800000, 0x00001000, MT_DEVICE },*/ /* SCOOP */
248 { 0xef800000, 0x00000000, 0x00800000, MT_DEVICE }, /* Boot Flash */
249};
250
251static void __init corgi_map_io(void)
252{
253 pxa_map_io();
254 iotable_init(corgi_io_desc,ARRAY_SIZE(corgi_io_desc));
255
256 /* setup sleep mode values */
257 PWER = 0x00000002;
258 PFER = 0x00000000;
259 PRER = 0x00000002;
260 PGSR0 = 0x0158C000;
261 PGSR1 = 0x00FF0080;
262 PGSR2 = 0x0001C004;
263 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
264 PCFR |= PCFR_OPDE;
265}
266
267#ifdef CONFIG_MACH_CORGI
268MACHINE_START(CORGI, "SHARP Corgi")
e9dea0c6
RK
269 .phys_ram = 0xa0000000,
270 .phys_io = 0x40000000,
68070bde 271 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
e9dea0c6
RK
272 .fixup = fixup_corgi,
273 .map_io = corgi_map_io,
274 .init_irq = corgi_init_irq,
275 .init_machine = corgi_init,
276 .timer = &pxa_timer,
1da177e4
LT
277MACHINE_END
278#endif
279
280#ifdef CONFIG_MACH_SHEPHERD
281MACHINE_START(SHEPHERD, "SHARP Shepherd")
e9dea0c6
RK
282 .phys_ram = 0xa0000000,
283 .phys_io = 0x40000000,
68070bde 284 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
e9dea0c6
RK
285 .fixup = fixup_corgi,
286 .map_io = corgi_map_io,
287 .init_irq = corgi_init_irq,
288 .init_machine = corgi_init,
289 .timer = &pxa_timer,
1da177e4
LT
290MACHINE_END
291#endif
292
293#ifdef CONFIG_MACH_HUSKY
294MACHINE_START(HUSKY, "SHARP Husky")
e9dea0c6
RK
295 .phys_ram = 0xa0000000,
296 .phys_io = 0x40000000,
68070bde 297 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
e9dea0c6
RK
298 .fixup = fixup_corgi,
299 .map_io = corgi_map_io,
300 .init_irq = corgi_init_irq,
301 .init_machine = corgi_init,
302 .timer = &pxa_timer,
1da177e4
LT
303MACHINE_END
304#endif
305