2 * linux/arch/arm/mach-pxa/lubbock.c
4 * Support for the Intel DBPXA250 Development Platform.
6 * Author: Nicolas Pitre
7 * Created: Jun 15, 2001
8 * Copyright: MontaVista Software Inc.
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.
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/sysdev.h>
19 #include <linux/major.h>
21 #include <linux/interrupt.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/partitions.h>
25 #include <asm/setup.h>
26 #include <asm/memory.h>
27 #include <asm/mach-types.h>
28 #include <asm/hardware.h>
30 #include <asm/sizes.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/irq.h>
35 #include <asm/mach/flash.h>
37 #include <asm/hardware/sa1111.h>
39 #include <asm/arch/pxa-regs.h>
40 #include <asm/arch/lubbock.h>
41 #include <asm/arch/udc.h>
42 #include <asm/arch/irda.h>
43 #include <asm/arch/pxafb.h>
44 #include <asm/arch/mmc.h>
49 #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
51 void lubbock_set_misc_wr(unsigned int mask
, unsigned int set
)
55 local_irq_save(flags
);
56 LUB_MISC_WR
= (LUB_MISC_WR
& ~mask
) | (set
& mask
);
57 local_irq_restore(flags
);
59 EXPORT_SYMBOL(lubbock_set_misc_wr
);
61 static unsigned long lubbock_irq_enabled
;
63 static void lubbock_mask_irq(unsigned int irq
)
65 int lubbock_irq
= (irq
- LUBBOCK_IRQ(0));
66 LUB_IRQ_MASK_EN
= (lubbock_irq_enabled
&= ~(1 << lubbock_irq
));
69 static void lubbock_unmask_irq(unsigned int irq
)
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
));
77 static struct irqchip lubbock_irq_chip
= {
78 .ack
= lubbock_mask_irq
,
79 .mask
= lubbock_mask_irq
,
80 .unmask
= lubbock_unmask_irq
,
83 static void lubbock_irq_handler(unsigned int irq
, struct irqdesc
*desc
,
86 unsigned long pending
= LUB_IRQ_SET_CLR
& lubbock_irq_enabled
;
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
;
92 desc_handle_irq(irq
, desc
, regs
);
94 pending
= LUB_IRQ_SET_CLR
& lubbock_irq_enabled
;
98 static void __init
lubbock_init_irq(void)
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
);
111 set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler
);
112 set_irq_type(IRQ_GPIO(0), IRQT_FALLING
);
117 static int lubbock_irq_resume(struct sys_device
*dev
)
119 LUB_IRQ_MASK_EN
= lubbock_irq_enabled
;
123 static struct sysdev_class lubbock_irq_sysclass
= {
124 set_kset_name("cpld_irq"),
125 .resume
= lubbock_irq_resume
,
128 static struct sys_device lubbock_irq_device
= {
129 .cls
= &lubbock_irq_sysclass
,
132 static int __init
lubbock_irq_device_init(void)
134 int ret
= sysdev_class_register(&lubbock_irq_sysclass
);
136 ret
= sysdev_register(&lubbock_irq_device
);
140 device_initcall(lubbock_irq_device_init
);
144 static int lubbock_udc_is_connected(void)
146 return (LUB_MISC_RD
& (1 << 9)) == 0;
149 static 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
154 static struct platform_device lub_audio_device
= {
155 .name
= "pxa2xx-ac97",
159 static struct resource sa1111_resources
[] = {
163 .flags
= IORESOURCE_MEM
,
166 .start
= LUBBOCK_SA1111_IRQ
,
167 .end
= LUBBOCK_SA1111_IRQ
,
168 .flags
= IORESOURCE_IRQ
,
172 static struct platform_device sa1111_device
= {
175 .num_resources
= ARRAY_SIZE(sa1111_resources
),
176 .resource
= sa1111_resources
,
179 static struct resource smc91x_resources
[] = {
181 .name
= "smc91x-regs",
184 .flags
= IORESOURCE_MEM
,
187 .start
= LUBBOCK_ETH_IRQ
,
188 .end
= LUBBOCK_ETH_IRQ
,
189 .flags
= IORESOURCE_IRQ
,
192 .name
= "smc91x-attrib",
195 .flags
= IORESOURCE_MEM
,
199 static struct platform_device smc91x_device
= {
202 .num_resources
= ARRAY_SIZE(smc91x_resources
),
203 .resource
= smc91x_resources
,
206 static struct resource flash_resources
[] = {
210 .flags
= IORESOURCE_MEM
,
214 .end
= 0x04000000 + SZ_64M
- 1,
215 .flags
= IORESOURCE_MEM
,
219 static struct mtd_partition lubbock_partitions
[] = {
221 .name
= "Bootloader",
224 .mask_flags
= MTD_WRITEABLE
/* force read-only */
228 .offset
= 0x00040000,
230 .name
= "Filesystem",
231 .size
= MTDPART_SIZ_FULL
,
236 static struct flash_platform_data lubbock_flash_data
[2] = {
238 .map_name
= "cfi_probe",
239 .parts
= lubbock_partitions
,
240 .nr_parts
= ARRAY_SIZE(lubbock_partitions
),
242 .map_name
= "cfi_probe",
248 static struct platform_device lubbock_flash_device
[2] = {
250 .name
= "pxa2xx-flash",
253 .platform_data
= &lubbock_flash_data
[0],
255 .resource
= &flash_resources
[0],
259 .name
= "pxa2xx-flash",
262 .platform_data
= &lubbock_flash_data
[1],
264 .resource
= &flash_resources
[1],
269 static struct platform_device
*devices
[] __initdata
= {
273 &lubbock_flash_device
[0],
274 &lubbock_flash_device
[1],
277 static struct pxafb_mach_info sharp_lm8v31 __initdata
= {
288 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
293 .lccr3
= LCCR3_PCP
| LCCR3_Acb(255),
296 #define MMC_POLL_RATE msecs_to_jiffies(1000)
298 static void lubbock_mmc_poll(unsigned long);
299 static irqreturn_t (*mmc_detect_int
)(int, void *, struct pt_regs
*);
301 static struct timer_list mmc_timer
= {
302 .function
= lubbock_mmc_poll
,
305 static void lubbock_mmc_poll(unsigned long data
)
309 /* clear any previous irq state, then ... */
310 local_irq_save(flags
);
311 LUB_IRQ_SET_CLR
&= ~(1 << 0);
312 local_irq_restore(flags
);
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
);
318 (void) mmc_detect_int(LUBBOCK_SD_IRQ
, (void *)data
, NULL
);
319 enable_irq(LUBBOCK_SD_IRQ
);
323 static irqreturn_t
lubbock_detect_int(int irq
, void *data
, struct pt_regs
*regs
)
325 /* IRQ is level triggered; disable, and poll for removal */
327 mod_timer(&mmc_timer
, jiffies
+ MMC_POLL_RATE
);
329 return mmc_detect_int(irq
, data
, regs
);
332 static int lubbock_mci_init(struct device
*dev
,
333 irqreturn_t (*detect_int
)(int, void *, struct pt_regs
*),
336 /* setup GPIO for PXA25x MMC controller */
337 pxa_gpio_mode(GPIO6_MMCCLK_MD
);
338 pxa_gpio_mode(GPIO8_MMCCS0_MD
);
340 /* 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
);
348 static int lubbock_mci_get_ro(struct device
*dev
)
350 return (LUB_MISC_RD
& (1 << 2)) != 0;
353 static void lubbock_mci_exit(struct device
*dev
, void *data
)
355 free_irq(LUBBOCK_SD_IRQ
, data
);
356 del_timer_sync(&mmc_timer
);
359 static struct pxamci_platform_data lubbock_mci_platform_data
= {
360 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
362 .init
= lubbock_mci_init
,
363 .get_ro
= lubbock_mci_get_ro
,
364 .exit
= lubbock_mci_exit
,
367 static void lubbock_irda_transceiver_mode(struct device
*dev
, int mode
)
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;
377 local_irq_restore(flags
);
380 static struct pxaficp_platform_data lubbock_ficp_platform_data
= {
381 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
,
382 .transceiver_mode
= lubbock_irda_transceiver_mode
,
385 static void __init
lubbock_init(void)
387 int flashboot
= (LUB_CONF_SWITCHES
& 1);
389 pxa_set_udc_info(&udc_info
);
390 set_pxa_fb_info(&sharp_lm8v31
);
391 pxa_set_mci_info(&lubbock_mci_platform_data
);
392 pxa_set_ficp_info(&lubbock_ficp_platform_data
);
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
);
400 lubbock_flash_data
[flashboot
^1].name
= "application-flash";
401 lubbock_flash_data
[flashboot
].name
= "boot-rom";
402 (void) platform_add_devices(devices
, ARRAY_SIZE(devices
));
405 static struct map_desc lubbock_io_desc
[] __initdata
= {
407 .virtual = LUBBOCK_FPGA_VIRT
,
408 .pfn
= __phys_to_pfn(LUBBOCK_FPGA_PHYS
),
409 .length
= 0x00100000,
414 static void __init
lubbock_map_io(void)
417 iotable_init(lubbock_io_desc
, ARRAY_SIZE(lubbock_io_desc
));
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
);
425 /* This is for the SMC chip select */
426 pxa_gpio_mode(GPIO79_nCS_3_MD
);
428 /* setup sleep mode values */
438 MACHINE_START(LUBBOCK
, "Intel DBPXA250 Development Platform (aka Lubbock)")
439 /* Maintainer: MontaVista Software Inc. */
440 .phys_ram
= 0xa0000000,
441 .phys_io
= 0x40000000,
442 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
443 .map_io
= lubbock_map_io
,
444 .init_irq
= lubbock_init_irq
,
446 .init_machine
= lubbock_init
,