blob: 689f31349bd62df5a3a33a6e694a45cf14150073 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-pxa/lubbock.c
3 *
4 * Support for the Intel DBPXA250 Development Platform.
5 *
6 * Author: Nicolas Pitre
7 * Created: Jun 15, 2001
8 * Copyright: MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/device.h>
Nicolas Pitre22f11c42005-06-16 21:23:56 +010018#include <linux/sysdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/major.h>
20#include <linux/fb.h>
21#include <linux/interrupt.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
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/irq.h>
32
33#include <asm/hardware/sa1111.h>
34
35#include <asm/arch/pxa-regs.h>
36#include <asm/arch/lubbock.h>
37#include <asm/arch/udc.h>
Nicolas Pitre6f475c02005-10-28 16:39:33 +010038#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <asm/arch/pxafb.h>
40#include <asm/arch/mmc.h>
41
42#include "generic.h"
43
44
45#define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
46
47void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
48{
49 unsigned long flags;
50
51 local_irq_save(flags);
52 LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
53 local_irq_restore(flags);
54}
55EXPORT_SYMBOL(lubbock_set_misc_wr);
56
57static unsigned long lubbock_irq_enabled;
58
59static void lubbock_mask_irq(unsigned int irq)
60{
61 int lubbock_irq = (irq - LUBBOCK_IRQ(0));
62 LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
63}
64
65static void lubbock_unmask_irq(unsigned int irq)
66{
67 int lubbock_irq = (irq - LUBBOCK_IRQ(0));
68 /* the irq can be acknowledged only if deasserted, so it's done here */
69 LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
70 LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
71}
72
73static struct irqchip lubbock_irq_chip = {
74 .ack = lubbock_mask_irq,
75 .mask = lubbock_mask_irq,
76 .unmask = lubbock_unmask_irq,
77};
78
79static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
80 struct pt_regs *regs)
81{
82 unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
83 do {
84 GEDR(0) = GPIO_bit(0); /* clear our parent irq */
85 if (likely(pending)) {
86 irq = LUBBOCK_IRQ(0) + __ffs(pending);
87 desc = irq_desc + irq;
Russell King664399e2005-09-04 19:45:00 +010088 desc_handle_irq(irq, desc, regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90 pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
91 } while (pending);
92}
93
94static void __init lubbock_init_irq(void)
95{
96 int irq;
97
98 pxa_init_irq();
99
100 /* setup extra lubbock irqs */
101 for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
102 set_irq_chip(irq, &lubbock_irq_chip);
103 set_irq_handler(irq, do_level_IRQ);
104 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
105 }
106
107 set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
108 set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
109}
110
Nicolas Pitre22f11c42005-06-16 21:23:56 +0100111#ifdef CONFIG_PM
112
113static int lubbock_irq_resume(struct sys_device *dev)
114{
115 LUB_IRQ_MASK_EN = lubbock_irq_enabled;
116 return 0;
117}
118
119static struct sysdev_class lubbock_irq_sysclass = {
120 set_kset_name("cpld_irq"),
121 .resume = lubbock_irq_resume,
122};
123
124static struct sys_device lubbock_irq_device = {
125 .cls = &lubbock_irq_sysclass,
126};
127
128static int __init lubbock_irq_device_init(void)
129{
130 int ret = sysdev_class_register(&lubbock_irq_sysclass);
131 if (ret == 0)
132 ret = sysdev_register(&lubbock_irq_device);
133 return ret;
134}
135
136device_initcall(lubbock_irq_device_init);
137
138#endif
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140static int lubbock_udc_is_connected(void)
141{
142 return (LUB_MISC_RD & (1 << 9)) == 0;
143}
144
145static struct pxa2xx_udc_mach_info udc_info __initdata = {
146 .udc_is_connected = lubbock_udc_is_connected,
147 // no D+ pullup; lubbock can't connect/disconnect in software
148};
149
Nicolas Pitre2cef2d52005-09-14 22:42:31 +0100150static struct platform_device lub_audio_device = {
151 .name = "pxa2xx-ac97",
152 .id = -1,
153};
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155static struct resource sa1111_resources[] = {
156 [0] = {
157 .start = 0x10000000,
158 .end = 0x10001fff,
159 .flags = IORESOURCE_MEM,
160 },
161 [1] = {
162 .start = LUBBOCK_SA1111_IRQ,
163 .end = LUBBOCK_SA1111_IRQ,
164 .flags = IORESOURCE_IRQ,
165 },
166};
167
168static struct platform_device sa1111_device = {
169 .name = "sa1111",
170 .id = -1,
171 .num_resources = ARRAY_SIZE(sa1111_resources),
172 .resource = sa1111_resources,
173};
174
175static struct resource smc91x_resources[] = {
176 [0] = {
177 .name = "smc91x-regs",
David Brownell85eb2262005-11-01 19:44:30 +0000178 .start = 0x0c000c00,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 .end = 0x0c0fffff,
180 .flags = IORESOURCE_MEM,
181 },
182 [1] = {
183 .start = LUBBOCK_ETH_IRQ,
184 .end = LUBBOCK_ETH_IRQ,
185 .flags = IORESOURCE_IRQ,
186 },
187 [2] = {
188 .name = "smc91x-attrib",
189 .start = 0x0e000000,
190 .end = 0x0e0fffff,
191 .flags = IORESOURCE_MEM,
192 },
193};
194
195static struct platform_device smc91x_device = {
196 .name = "smc91x",
197 .id = -1,
198 .num_resources = ARRAY_SIZE(smc91x_resources),
199 .resource = smc91x_resources,
200};
201
202static struct platform_device *devices[] __initdata = {
203 &sa1111_device,
Nicolas Pitre2cef2d52005-09-14 22:42:31 +0100204 &lub_audio_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 &smc91x_device,
206};
207
208static struct pxafb_mach_info sharp_lm8v31 __initdata = {
209 .pixclock = 270000,
210 .xres = 640,
211 .yres = 480,
212 .bpp = 16,
213 .hsync_len = 1,
214 .left_margin = 3,
215 .right_margin = 3,
216 .vsync_len = 1,
217 .upper_margin = 0,
218 .lower_margin = 0,
219 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
220 .cmap_greyscale = 0,
221 .cmap_inverse = 0,
222 .cmap_static = 0,
223 .lccr0 = LCCR0_SDS,
224 .lccr3 = LCCR3_PCP | LCCR3_Acb(255),
225};
226
David Brownell85eb2262005-11-01 19:44:30 +0000227#define MMC_POLL_RATE msecs_to_jiffies(1000)
228
229static void lubbock_mmc_poll(unsigned long);
230static irqreturn_t (*mmc_detect_int)(int, void *, struct pt_regs *);
231
232static struct timer_list mmc_timer = {
233 .function = lubbock_mmc_poll,
234};
235
236static void lubbock_mmc_poll(unsigned long data)
237{
238 unsigned long flags;
239
240 /* clear any previous irq state, then ... */
241 local_irq_save(flags);
242 LUB_IRQ_SET_CLR &= ~(1 << 0);
243 local_irq_restore(flags);
244
245 /* poll until mmc/sd card is removed */
246 if (LUB_IRQ_SET_CLR & (1 << 0))
247 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
248 else {
249 (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data, NULL);
250 enable_irq(LUBBOCK_SD_IRQ);
251 }
252}
253
254static irqreturn_t lubbock_detect_int(int irq, void *data, struct pt_regs *regs)
255{
256 /* IRQ is level triggered; disable, and poll for removal */
257 disable_irq(irq);
258 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
259
260 return mmc_detect_int(irq, data, regs);
261}
262
263static int lubbock_mci_init(struct device *dev,
264 irqreturn_t (*detect_int)(int, void *, struct pt_regs *),
265 void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266{
267 /* setup GPIO for PXA25x MMC controller */
268 pxa_gpio_mode(GPIO6_MMCCLK_MD);
269 pxa_gpio_mode(GPIO8_MMCCS0_MD);
270
David Brownell85eb2262005-11-01 19:44:30 +0000271 /* detect card insert/eject */
272 mmc_detect_int = detect_int;
273 init_timer(&mmc_timer);
274 mmc_timer.data = (unsigned long) data;
275 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
276 SA_SAMPLE_RANDOM, "lubbock-sd-detect", data);
277}
278
279static int lubbock_mci_get_ro(struct device *dev)
280{
281 return (LUB_MISC_RD & (1 << 2)) != 0;
282}
283
284static void lubbock_mci_exit(struct device *dev, void *data)
285{
286 free_irq(LUBBOCK_SD_IRQ, data);
287 del_timer_sync(&mmc_timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288}
289
290static struct pxamci_platform_data lubbock_mci_platform_data = {
291 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
David Brownell85eb2262005-11-01 19:44:30 +0000292 .detect_delay = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 .init = lubbock_mci_init,
David Brownell85eb2262005-11-01 19:44:30 +0000294 .get_ro = lubbock_mci_get_ro,
295 .exit = lubbock_mci_exit,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296};
297
Nicolas Pitre6f475c02005-10-28 16:39:33 +0100298static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
299{
300 unsigned long flags;
301
302 local_irq_save(flags);
303 if (mode & IR_SIRMODE) {
304 LUB_MISC_WR &= ~(1 << 4);
305 } else if (mode & IR_FIRMODE) {
306 LUB_MISC_WR |= 1 << 4;
307 }
308 local_irq_restore(flags);
309}
310
311static struct pxaficp_platform_data lubbock_ficp_platform_data = {
312 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
313 .transceiver_mode = lubbock_irda_transceiver_mode,
314};
315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316static void __init lubbock_init(void)
317{
318 pxa_set_udc_info(&udc_info);
319 set_pxa_fb_info(&sharp_lm8v31);
320 pxa_set_mci_info(&lubbock_mci_platform_data);
Nicolas Pitre6f475c02005-10-28 16:39:33 +0100321 pxa_set_ficp_info(&lubbock_ficp_platform_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
323}
324
325static struct map_desc lubbock_io_desc[] __initdata = {
Deepak Saxena6f9182e2005-10-28 15:19:01 +0100326 { /* CPLD */
327 .virtual = LUBBOCK_FPGA_VIRT,
328 .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
329 .length = 0x00100000,
330 .type = MT_DEVICE
331 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332};
333
334static void __init lubbock_map_io(void)
335{
336 pxa_map_io();
337 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
338
339 /* This enables the BTUART */
340 pxa_gpio_mode(GPIO42_BTRXD_MD);
341 pxa_gpio_mode(GPIO43_BTTXD_MD);
342 pxa_gpio_mode(GPIO44_BTCTS_MD);
343 pxa_gpio_mode(GPIO45_BTRTS_MD);
344
345 /* This is for the SMC chip select */
346 pxa_gpio_mode(GPIO79_nCS_3_MD);
347
348 /* setup sleep mode values */
349 PWER = 0x00000002;
350 PFER = 0x00000000;
351 PRER = 0x00000002;
352 PGSR0 = 0x00008000;
353 PGSR1 = 0x003F0202;
354 PGSR2 = 0x0001C000;
355 PCFR |= PCFR_OPDE;
356}
357
358MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100359 /* Maintainer: MontaVista Software Inc. */
360 .phys_ram = 0xa0000000,
361 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100362 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100363 .map_io = lubbock_map_io,
364 .init_irq = lubbock_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 .timer = &pxa_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100366 .init_machine = lubbock_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367MACHINE_END