2 * linux/arch/arm/mach-sa1100/neponset.c
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/ptrace.h>
9 #include <linux/ioport.h>
10 #include <linux/serial_core.h>
11 #include <linux/platform_device.h>
12 #include <linux/slab.h>
14 #include <asm/hardware.h>
15 #include <asm/mach-types.h>
17 #include <asm/mach/map.h>
18 #include <asm/mach/irq.h>
19 #include <asm/mach/serial_sa1100.h>
20 #include <asm/arch/assabet.h>
21 #include <asm/arch/neponset.h>
22 #include <asm/hardware/sa1111.h>
23 #include <asm/sizes.h>
26 * Install handler for Neponset IRQ. Note that we have to loop here
27 * since the ETHERNET and USAR IRQs are level based, and we need to
28 * ensure that the IRQ signal is deasserted before returning. This
29 * is rather unfortunate.
32 neponset_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
40 * Acknowledge the parent IRQ.
45 * Read the interrupt reason register. Let's have all
46 * active IRQ bits high. Note: there is a typo in the
47 * Neponset user's guide for the SA1111 IRR level.
49 irr = IRR ^ (IRR_ETHERNET | IRR_USAR);
51 if ((irr & (IRR_ETHERNET | IRR_USAR | IRR_SA1111)) == 0)
55 * Since there is no individual mask, we have to
56 * mask the parent IRQ. This is safe, since we'll
57 * recheck the register for any pending IRQs.
59 if (irr & (IRR_ETHERNET | IRR_USAR)) {
60 desc->chip->mask(irq);
63 * Ack the interrupt now to prevent re-entering
64 * this neponset handler. Again, this is safe
65 * since we'll check the IRR register prior to
70 if (irr & IRR_ETHERNET) {
71 d = irq_desc + IRQ_NEPONSET_SMC9196;
72 desc_handle_irq(IRQ_NEPONSET_SMC9196, d, regs);
76 d = irq_desc + IRQ_NEPONSET_USAR;
77 desc_handle_irq(IRQ_NEPONSET_USAR, d, regs);
80 desc->chip->unmask(irq);
83 if (irr & IRR_SA1111) {
84 d = irq_desc + IRQ_NEPONSET_SA1111;
85 desc_handle_irq(IRQ_NEPONSET_SA1111, d, regs);
90 static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
92 u_int mdm_ctl0 = MDM_CTL_0;
94 if (port->mapbase == _Ser1UTCR0) {
95 if (mctrl & TIOCM_RTS)
96 mdm_ctl0 &= ~MDM_CTL0_RTS2;
98 mdm_ctl0 |= MDM_CTL0_RTS2;
100 if (mctrl & TIOCM_DTR)
101 mdm_ctl0 &= ~MDM_CTL0_DTR2;
103 mdm_ctl0 |= MDM_CTL0_DTR2;
104 } else if (port->mapbase == _Ser3UTCR0) {
105 if (mctrl & TIOCM_RTS)
106 mdm_ctl0 &= ~MDM_CTL0_RTS1;
108 mdm_ctl0 |= MDM_CTL0_RTS1;
110 if (mctrl & TIOCM_DTR)
111 mdm_ctl0 &= ~MDM_CTL0_DTR1;
113 mdm_ctl0 |= MDM_CTL0_DTR1;
116 MDM_CTL_0 = mdm_ctl0;
119 static u_int neponset_get_mctrl(struct uart_port *port)
121 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
122 u_int mdm_ctl1 = MDM_CTL_1;
124 if (port->mapbase == _Ser1UTCR0) {
125 if (mdm_ctl1 & MDM_CTL1_DCD2)
127 if (mdm_ctl1 & MDM_CTL1_CTS2)
129 if (mdm_ctl1 & MDM_CTL1_DSR2)
131 } else if (port->mapbase == _Ser3UTCR0) {
132 if (mdm_ctl1 & MDM_CTL1_DCD1)
134 if (mdm_ctl1 & MDM_CTL1_CTS1)
136 if (mdm_ctl1 & MDM_CTL1_DSR1)
143 static struct sa1100_port_fns neponset_port_fns __initdata = {
144 .set_mctrl = neponset_set_mctrl,
145 .get_mctrl = neponset_get_mctrl,
148 static int neponset_probe(struct platform_device *dev)
150 sa1100_register_uart_fns(&neponset_port_fns);
153 * Install handler for GPIO25.
155 set_irq_type(IRQ_GPIO25, IRQT_RISING);
156 set_irq_chained_handler(IRQ_GPIO25, neponset_irq_handler);
159 * We would set IRQ_GPIO25 to be a wake-up IRQ, but
160 * unfortunately something on the Neponset activates
161 * this IRQ on sleep (ethernet?)
164 enable_irq_wake(IRQ_GPIO25);
168 * Setup other Neponset IRQs. SA1111 will be done by the
169 * generic SA1111 code.
171 set_irq_handler(IRQ_NEPONSET_SMC9196, do_simple_IRQ);
172 set_irq_flags(IRQ_NEPONSET_SMC9196, IRQF_VALID | IRQF_PROBE);
173 set_irq_handler(IRQ_NEPONSET_USAR, do_simple_IRQ);
174 set_irq_flags(IRQ_NEPONSET_USAR, IRQF_VALID | IRQF_PROBE);
177 * Disable GPIO 0/1 drivers so the buttons work on the module.
179 NCR_0 = NCR_GP01_OFF;
187 * LDM power management.
189 static int neponset_suspend(struct platform_device *dev, pm_message_t state)
194 if (!dev->dev.power.saved_state)
195 dev->dev.power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
196 if (!dev->dev.power.saved_state)
199 *(unsigned int *)dev->dev.power.saved_state = NCR_0;
204 static int neponset_resume(struct platform_device *dev)
206 if (dev->dev.power.saved_state) {
207 NCR_0 = *(unsigned int *)dev->dev.power.saved_state;
208 kfree(dev->dev.power.saved_state);
209 dev->dev.power.saved_state = NULL;
216 #define neponset_suspend NULL
217 #define neponset_resume NULL
220 static struct platform_driver neponset_device_driver = {
221 .probe = neponset_probe,
222 .suspend = neponset_suspend,
223 .resume = neponset_resume,
229 static struct resource neponset_resources[] = {
233 .flags = IORESOURCE_MEM,
237 static struct platform_device neponset_device = {
240 .num_resources = ARRAY_SIZE(neponset_resources),
241 .resource = neponset_resources,
244 static struct resource sa1111_resources[] = {
248 .flags = IORESOURCE_MEM,
251 .start = IRQ_NEPONSET_SA1111,
252 .end = IRQ_NEPONSET_SA1111,
253 .flags = IORESOURCE_IRQ,
257 static u64 sa1111_dmamask = 0xffffffffUL;
259 static struct platform_device sa1111_device = {
263 .dma_mask = &sa1111_dmamask,
264 .coherent_dma_mask = 0xffffffff,
266 .num_resources = ARRAY_SIZE(sa1111_resources),
267 .resource = sa1111_resources,
270 static struct resource smc91x_resources[] = {
272 .name = "smc91x-regs",
273 .start = SA1100_CS3_PHYS,
274 .end = SA1100_CS3_PHYS + 0x01ffffff,
275 .flags = IORESOURCE_MEM,
278 .start = IRQ_NEPONSET_SMC9196,
279 .end = IRQ_NEPONSET_SMC9196,
280 .flags = IORESOURCE_IRQ,
283 .name = "smc91x-attrib",
284 .start = SA1100_CS3_PHYS + 0x02000000,
285 .end = SA1100_CS3_PHYS + 0x03ffffff,
286 .flags = IORESOURCE_MEM,
290 static struct platform_device smc91x_device = {
293 .num_resources = ARRAY_SIZE(smc91x_resources),
294 .resource = smc91x_resources,
297 static struct platform_device *devices[] __initdata = {
303 static int __init neponset_init(void)
305 platform_driver_register(&neponset_device_driver);
308 * The Neponset is only present on the Assabet machine type.
310 if (!machine_is_assabet())
314 * Ensure that the memory bus request/grant signals are setup,
315 * and the grant is held in its inactive state, whether or not
316 * we actually have a Neponset attached.
320 if (!machine_has_neponset()) {
321 printk(KERN_DEBUG "Neponset expansion board not present\n");
325 if (WHOAMI != 0x11) {
326 printk(KERN_WARNING "Neponset board detected, but "
327 "wrong ID: %02x\n", WHOAMI);
331 return platform_add_devices(devices, ARRAY_SIZE(devices));
334 subsys_initcall(neponset_init);
336 static struct map_desc neponset_io_desc[] __initdata = {
337 { /* System Registers */
338 .virtual = 0xf3000000,
339 .pfn = __phys_to_pfn(0x10000000),
343 .virtual = 0xf4000000,
344 .pfn = __phys_to_pfn(0x40000000),
350 void __init neponset_map_io(void)
352 iotable_init(neponset_io_desc, ARRAY_SIZE(neponset_io_desc));