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