blob: b464bc88ff93234e853f72649763a0c864e87b9f [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>
Russell Kingd052d1b2005-10-29 19:07:23 +010017#include <linux/platform_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>
Todd Poynor74ec71e2005-11-04 17:15:45 +000022#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include <asm/setup.h>
26#include <asm/memory.h>
27#include <asm/mach-types.h>
28#include <asm/hardware.h>
29#include <asm/irq.h>
Todd Poynor74ec71e2005-11-04 17:15:45 +000030#include <asm/sizes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34#include <asm/mach/irq.h>
Todd Poynor74ec71e2005-11-04 17:15:45 +000035#include <asm/mach/flash.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37#include <asm/hardware/sa1111.h>
38
39#include <asm/arch/pxa-regs.h>
40#include <asm/arch/lubbock.h>
41#include <asm/arch/udc.h>
Nicolas Pitre6f475c02005-10-28 16:39:33 +010042#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <asm/arch/pxafb.h>
44#include <asm/arch/mmc.h>
45
46#include "generic.h"
47
48
49#define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
50
51void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
52{
53 unsigned long flags;
54
55 local_irq_save(flags);
56 LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
57 local_irq_restore(flags);
58}
59EXPORT_SYMBOL(lubbock_set_misc_wr);
60
61static unsigned long lubbock_irq_enabled;
62
63static void lubbock_mask_irq(unsigned int irq)
64{
65 int lubbock_irq = (irq - LUBBOCK_IRQ(0));
66 LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
67}
68
69static void lubbock_unmask_irq(unsigned int irq)
70{
71 int lubbock_irq = (irq - LUBBOCK_IRQ(0));
72 /* the irq can be acknowledged only if deasserted, so it's done here */
73 LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
74 LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
75}
76
77static struct irqchip lubbock_irq_chip = {
78 .ack = lubbock_mask_irq,
79 .mask = lubbock_mask_irq,
80 .unmask = lubbock_unmask_irq,
81};
82
83static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
84 struct pt_regs *regs)
85{
86 unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
87 do {
88 GEDR(0) = GPIO_bit(0); /* clear our parent irq */
89 if (likely(pending)) {
90 irq = LUBBOCK_IRQ(0) + __ffs(pending);
91 desc = irq_desc + irq;
Russell King664399e2005-09-04 19:45:00 +010092 desc_handle_irq(irq, desc, regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 }
94 pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
95 } while (pending);
96}
97
98static void __init lubbock_init_irq(void)
99{
100 int irq;
101
102 pxa_init_irq();
103
104 /* setup extra lubbock irqs */
105 for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
106 set_irq_chip(irq, &lubbock_irq_chip);
107 set_irq_handler(irq, do_level_IRQ);
108 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
109 }
110
111 set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
112 set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
113}
114
Nicolas Pitre22f11c42005-06-16 21:23:56 +0100115#ifdef CONFIG_PM
116
117static int lubbock_irq_resume(struct sys_device *dev)
118{
119 LUB_IRQ_MASK_EN = lubbock_irq_enabled;
120 return 0;
121}
122
123static struct sysdev_class lubbock_irq_sysclass = {
124 set_kset_name("cpld_irq"),
125 .resume = lubbock_irq_resume,
126};
127
128static struct sys_device lubbock_irq_device = {
129 .cls = &lubbock_irq_sysclass,
130};
131
132static int __init lubbock_irq_device_init(void)
133{
134 int ret = sysdev_class_register(&lubbock_irq_sysclass);
135 if (ret == 0)
136 ret = sysdev_register(&lubbock_irq_device);
137 return ret;
138}
139
140device_initcall(lubbock_irq_device_init);
141
142#endif
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144static int lubbock_udc_is_connected(void)
145{
146 return (LUB_MISC_RD & (1 << 9)) == 0;
147}
148
149static struct pxa2xx_udc_mach_info udc_info __initdata = {
150 .udc_is_connected = lubbock_udc_is_connected,
151 // no D+ pullup; lubbock can't connect/disconnect in software
152};
153
Nicolas Pitre2cef2d52005-09-14 22:42:31 +0100154static struct platform_device lub_audio_device = {
155 .name = "pxa2xx-ac97",
156 .id = -1,
157};
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159static struct resource sa1111_resources[] = {
160 [0] = {
161 .start = 0x10000000,
162 .end = 0x10001fff,
163 .flags = IORESOURCE_MEM,
164 },
165 [1] = {
166 .start = LUBBOCK_SA1111_IRQ,
167 .end = LUBBOCK_SA1111_IRQ,
168 .flags = IORESOURCE_IRQ,
169 },
170};
171
172static struct platform_device sa1111_device = {
173 .name = "sa1111",
174 .id = -1,
175 .num_resources = ARRAY_SIZE(sa1111_resources),
176 .resource = sa1111_resources,
177};
178
179static struct resource smc91x_resources[] = {
180 [0] = {
181 .name = "smc91x-regs",
David Brownell85eb2262005-11-01 19:44:30 +0000182 .start = 0x0c000c00,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 .end = 0x0c0fffff,
184 .flags = IORESOURCE_MEM,
185 },
186 [1] = {
187 .start = LUBBOCK_ETH_IRQ,
188 .end = LUBBOCK_ETH_IRQ,
189 .flags = IORESOURCE_IRQ,
190 },
191 [2] = {
192 .name = "smc91x-attrib",
193 .start = 0x0e000000,
194 .end = 0x0e0fffff,
195 .flags = IORESOURCE_MEM,
196 },
197};
198
199static struct platform_device smc91x_device = {
200 .name = "smc91x",
201 .id = -1,
202 .num_resources = ARRAY_SIZE(smc91x_resources),
203 .resource = smc91x_resources,
204};
205
Todd Poynor74ec71e2005-11-04 17:15:45 +0000206static struct resource flash_resources[] = {
207 [0] = {
208 .start = 0x00000000,
209 .end = SZ_64M - 1,
210 .flags = IORESOURCE_MEM,
211 },
212 [1] = {
213 .start = 0x04000000,
214 .end = 0x04000000 + SZ_64M - 1,
215 .flags = IORESOURCE_MEM,
216 },
217};
218
219static struct mtd_partition lubbock_partitions[] = {
220 {
221 .name = "Bootloader",
222 .size = 0x00040000,
223 .offset = 0,
224 .mask_flags = MTD_WRITEABLE /* force read-only */
225 },{
226 .name = "Kernel",
227 .size = 0x00100000,
228 .offset = 0x00040000,
229 },{
230 .name = "Filesystem",
231 .size = MTDPART_SIZ_FULL,
232 .offset = 0x00140000
233 }
234};
235
236static struct flash_platform_data lubbock_flash_data[2] = {
237 {
238 .map_name = "cfi_probe",
239 .parts = lubbock_partitions,
240 .nr_parts = ARRAY_SIZE(lubbock_partitions),
241 }, {
242 .map_name = "cfi_probe",
243 .parts = NULL,
244 .nr_parts = 0,
245 }
246};
247
248static struct platform_device lubbock_flash_device[2] = {
249 {
250 .name = "pxa2xx-flash",
251 .id = 0,
252 .dev = {
253 .platform_data = &lubbock_flash_data[0],
254 },
255 .resource = &flash_resources[0],
256 .num_resources = 1,
257 },
258 {
259 .name = "pxa2xx-flash",
260 .id = 1,
261 .dev = {
262 .platform_data = &lubbock_flash_data[1],
263 },
264 .resource = &flash_resources[1],
265 .num_resources = 1,
266 },
267};
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269static struct platform_device *devices[] __initdata = {
270 &sa1111_device,
Nicolas Pitre2cef2d52005-09-14 22:42:31 +0100271 &lub_audio_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 &smc91x_device,
Todd Poynor74ec71e2005-11-04 17:15:45 +0000273 &lubbock_flash_device[0],
274 &lubbock_flash_device[1],
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275};
276
277static struct pxafb_mach_info sharp_lm8v31 __initdata = {
278 .pixclock = 270000,
279 .xres = 640,
280 .yres = 480,
281 .bpp = 16,
282 .hsync_len = 1,
283 .left_margin = 3,
284 .right_margin = 3,
285 .vsync_len = 1,
286 .upper_margin = 0,
287 .lower_margin = 0,
288 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
289 .cmap_greyscale = 0,
290 .cmap_inverse = 0,
291 .cmap_static = 0,
292 .lccr0 = LCCR0_SDS,
293 .lccr3 = LCCR3_PCP | LCCR3_Acb(255),
294};
295
David Brownell85eb2262005-11-01 19:44:30 +0000296#define MMC_POLL_RATE msecs_to_jiffies(1000)
297
298static void lubbock_mmc_poll(unsigned long);
299static irqreturn_t (*mmc_detect_int)(int, void *, struct pt_regs *);
300
301static struct timer_list mmc_timer = {
302 .function = lubbock_mmc_poll,
303};
304
305static void lubbock_mmc_poll(unsigned long data)
306{
307 unsigned long flags;
308
309 /* clear any previous irq state, then ... */
310 local_irq_save(flags);
311 LUB_IRQ_SET_CLR &= ~(1 << 0);
312 local_irq_restore(flags);
313
314 /* poll until mmc/sd card is removed */
315 if (LUB_IRQ_SET_CLR & (1 << 0))
316 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
317 else {
318 (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data, NULL);
319 enable_irq(LUBBOCK_SD_IRQ);
320 }
321}
322
323static irqreturn_t lubbock_detect_int(int irq, void *data, struct pt_regs *regs)
324{
325 /* IRQ is level triggered; disable, and poll for removal */
326 disable_irq(irq);
327 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
328
329 return mmc_detect_int(irq, data, regs);
330}
331
332static int lubbock_mci_init(struct device *dev,
333 irqreturn_t (*detect_int)(int, void *, struct pt_regs *),
334 void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335{
336 /* setup GPIO for PXA25x MMC controller */
337 pxa_gpio_mode(GPIO6_MMCCLK_MD);
338 pxa_gpio_mode(GPIO8_MMCCS0_MD);
339
David Brownell85eb2262005-11-01 19:44:30 +0000340 /* detect card insert/eject */
341 mmc_detect_int = detect_int;
342 init_timer(&mmc_timer);
343 mmc_timer.data = (unsigned long) data;
344 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
345 SA_SAMPLE_RANDOM, "lubbock-sd-detect", data);
346}
347
348static int lubbock_mci_get_ro(struct device *dev)
349{
350 return (LUB_MISC_RD & (1 << 2)) != 0;
351}
352
353static void lubbock_mci_exit(struct device *dev, void *data)
354{
355 free_irq(LUBBOCK_SD_IRQ, data);
356 del_timer_sync(&mmc_timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357}
358
359static struct pxamci_platform_data lubbock_mci_platform_data = {
360 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
David Brownell85eb2262005-11-01 19:44:30 +0000361 .detect_delay = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 .init = lubbock_mci_init,
David Brownell85eb2262005-11-01 19:44:30 +0000363 .get_ro = lubbock_mci_get_ro,
364 .exit = lubbock_mci_exit,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365};
366
Nicolas Pitre6f475c02005-10-28 16:39:33 +0100367static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
368{
369 unsigned long flags;
370
371 local_irq_save(flags);
372 if (mode & IR_SIRMODE) {
373 LUB_MISC_WR &= ~(1 << 4);
374 } else if (mode & IR_FIRMODE) {
375 LUB_MISC_WR |= 1 << 4;
376 }
377 local_irq_restore(flags);
378}
379
380static struct pxaficp_platform_data lubbock_ficp_platform_data = {
381 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
382 .transceiver_mode = lubbock_irda_transceiver_mode,
383};
384
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385static void __init lubbock_init(void)
386{
Todd Poynor74ec71e2005-11-04 17:15:45 +0000387 int flashboot = (LUB_CONF_SWITCHES & 1);
388
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 pxa_set_udc_info(&udc_info);
390 set_pxa_fb_info(&sharp_lm8v31);
391 pxa_set_mci_info(&lubbock_mci_platform_data);
Nicolas Pitre6f475c02005-10-28 16:39:33 +0100392 pxa_set_ficp_info(&lubbock_ficp_platform_data);
Todd Poynor74ec71e2005-11-04 17:15:45 +0000393
394 lubbock_flash_data[0].width = lubbock_flash_data[1].width =
395 (BOOT_DEF & 1) ? 2 : 4;
396 /* Compensate for the nROMBT switch which swaps the flash banks */
397 printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
398 flashboot?"Flash":"ROM", flashboot);
399
400 lubbock_flash_data[flashboot^1].name = "application-flash";
401 lubbock_flash_data[flashboot].name = "boot-rom";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
403}
404
405static struct map_desc lubbock_io_desc[] __initdata = {
Deepak Saxena6f9182e2005-10-28 15:19:01 +0100406 { /* CPLD */
407 .virtual = LUBBOCK_FPGA_VIRT,
408 .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
409 .length = 0x00100000,
410 .type = MT_DEVICE
411 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412};
413
414static void __init lubbock_map_io(void)
415{
416 pxa_map_io();
417 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
418
419 /* This enables the BTUART */
420 pxa_gpio_mode(GPIO42_BTRXD_MD);
421 pxa_gpio_mode(GPIO43_BTTXD_MD);
422 pxa_gpio_mode(GPIO44_BTCTS_MD);
423 pxa_gpio_mode(GPIO45_BTRTS_MD);
424
425 /* This is for the SMC chip select */
426 pxa_gpio_mode(GPIO79_nCS_3_MD);
427
428 /* setup sleep mode values */
429 PWER = 0x00000002;
430 PFER = 0x00000000;
431 PRER = 0x00000002;
432 PGSR0 = 0x00008000;
433 PGSR1 = 0x003F0202;
434 PGSR2 = 0x0001C000;
435 PCFR |= PCFR_OPDE;
436}
437
438MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100439 /* Maintainer: MontaVista Software Inc. */
440 .phys_ram = 0xa0000000,
441 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100442 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100443 .map_io = lubbock_map_io,
444 .init_irq = lubbock_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 .timer = &pxa_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100446 .init_machine = lubbock_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447MACHINE_END