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/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
);
62 if (irr
& IRR_ETHERNET
) {
63 d
= irq_desc
+ IRQ_NEPONSET_SMC9196
;
64 d
->handle(IRQ_NEPONSET_SMC9196
, d
, regs
);
68 d
= irq_desc
+ IRQ_NEPONSET_USAR
;
69 d
->handle(IRQ_NEPONSET_USAR
, d
, regs
);
72 desc
->chip
->unmask(irq
);
75 if (irr
& IRR_SA1111
) {
76 d
= irq_desc
+ IRQ_NEPONSET_SA1111
;
77 d
->handle(IRQ_NEPONSET_SA1111
, d
, regs
);
82 static void neponset_set_mctrl(struct uart_port
*port
, u_int mctrl
)
84 u_int mdm_ctl0
= MDM_CTL_0
;
86 if (port
->mapbase
== _Ser1UTCR0
) {
87 if (mctrl
& TIOCM_RTS
)
88 mdm_ctl0
&= ~MDM_CTL0_RTS2
;
90 mdm_ctl0
|= MDM_CTL0_RTS2
;
92 if (mctrl
& TIOCM_DTR
)
93 mdm_ctl0
&= ~MDM_CTL0_DTR2
;
95 mdm_ctl0
|= MDM_CTL0_DTR2
;
96 } else if (port
->mapbase
== _Ser3UTCR0
) {
97 if (mctrl
& TIOCM_RTS
)
98 mdm_ctl0
&= ~MDM_CTL0_RTS1
;
100 mdm_ctl0
|= MDM_CTL0_RTS1
;
102 if (mctrl
& TIOCM_DTR
)
103 mdm_ctl0
&= ~MDM_CTL0_DTR1
;
105 mdm_ctl0
|= MDM_CTL0_DTR1
;
108 MDM_CTL_0
= mdm_ctl0
;
111 static u_int
neponset_get_mctrl(struct uart_port
*port
)
113 u_int ret
= TIOCM_CD
| TIOCM_CTS
| TIOCM_DSR
;
114 u_int mdm_ctl1
= MDM_CTL_1
;
116 if (port
->mapbase
== _Ser1UTCR0
) {
117 if (mdm_ctl1
& MDM_CTL1_DCD2
)
119 if (mdm_ctl1
& MDM_CTL1_CTS2
)
121 if (mdm_ctl1
& MDM_CTL1_DSR2
)
123 } else if (port
->mapbase
== _Ser3UTCR0
) {
124 if (mdm_ctl1
& MDM_CTL1_DCD1
)
126 if (mdm_ctl1
& MDM_CTL1_CTS1
)
128 if (mdm_ctl1
& MDM_CTL1_DSR1
)
135 static struct sa1100_port_fns neponset_port_fns __initdata
= {
136 .set_mctrl
= neponset_set_mctrl
,
137 .get_mctrl
= neponset_get_mctrl
,
140 static int neponset_probe(struct device
*dev
)
142 sa1100_register_uart_fns(&neponset_port_fns
);
145 * Install handler for GPIO25.
147 set_irq_type(IRQ_GPIO25
, IRQT_RISING
);
148 set_irq_chained_handler(IRQ_GPIO25
, neponset_irq_handler
);
151 * We would set IRQ_GPIO25 to be a wake-up IRQ, but
152 * unfortunately something on the Neponset activates
153 * this IRQ on sleep (ethernet?)
156 enable_irq_wake(IRQ_GPIO25
);
160 * Setup other Neponset IRQs. SA1111 will be done by the
161 * generic SA1111 code.
163 set_irq_handler(IRQ_NEPONSET_SMC9196
, do_simple_IRQ
);
164 set_irq_flags(IRQ_NEPONSET_SMC9196
, IRQF_VALID
| IRQF_PROBE
);
165 set_irq_handler(IRQ_NEPONSET_USAR
, do_simple_IRQ
);
166 set_irq_flags(IRQ_NEPONSET_USAR
, IRQF_VALID
| IRQF_PROBE
);
169 * Disable GPIO 0/1 drivers so the buttons work on the module.
171 NCR_0
= NCR_GP01_OFF
;
177 * LDM power management.
179 static int neponset_suspend(struct device
*dev
, u32 state
, u32 level
)
184 if (level
== SUSPEND_SAVE_STATE
||
185 level
== SUSPEND_DISABLE
||
186 level
== SUSPEND_POWER_DOWN
) {
187 if (!dev
->saved_state
)
188 dev
->saved_state
= kmalloc(sizeof(unsigned int), GFP_KERNEL
);
189 if (!dev
->saved_state
)
192 *(unsigned int *)dev
->saved_state
= NCR_0
;
198 static int neponset_resume(struct device
*dev
, u32 level
)
200 if (level
== RESUME_RESTORE_STATE
|| level
== RESUME_ENABLE
) {
201 if (dev
->saved_state
) {
202 NCR_0
= *(unsigned int *)dev
->saved_state
;
203 kfree(dev
->saved_state
);
204 dev
->saved_state
= NULL
;
211 static struct device_driver neponset_device_driver
= {
213 .bus
= &platform_bus_type
,
214 .probe
= neponset_probe
,
215 .suspend
= neponset_suspend
,
216 .resume
= neponset_resume
,
219 static struct resource neponset_resources
[] = {
223 .flags
= IORESOURCE_MEM
,
227 static struct platform_device neponset_device
= {
230 .num_resources
= ARRAY_SIZE(neponset_resources
),
231 .resource
= neponset_resources
,
234 static struct resource sa1111_resources
[] = {
238 .flags
= IORESOURCE_MEM
,
241 .start
= IRQ_NEPONSET_SA1111
,
242 .end
= IRQ_NEPONSET_SA1111
,
243 .flags
= IORESOURCE_IRQ
,
247 static u64 sa1111_dmamask
= 0xffffffffUL
;
249 static struct platform_device sa1111_device
= {
253 .dma_mask
= &sa1111_dmamask
,
254 .coherent_dma_mask
= 0xffffffff,
256 .num_resources
= ARRAY_SIZE(sa1111_resources
),
257 .resource
= sa1111_resources
,
260 static struct resource smc91x_resources
[] = {
262 .start
= SA1100_CS3_PHYS
,
263 .end
= SA1100_CS3_PHYS
+ 0x01ffffff,
264 .flags
= IORESOURCE_MEM
,
267 .start
= IRQ_NEPONSET_SMC9196
,
268 .end
= IRQ_NEPONSET_SMC9196
,
269 .flags
= IORESOURCE_IRQ
,
272 .start
= SA1100_CS3_PHYS
+ 0x02000000,
273 .end
= SA1100_CS3_PHYS
+ 0x03ffffff,
274 .flags
= IORESOURCE_MEM
,
278 static struct platform_device smc91x_device
= {
281 .num_resources
= ARRAY_SIZE(smc91x_resources
),
282 .resource
= smc91x_resources
,
285 static struct platform_device
*devices
[] __initdata
= {
291 static int __init
neponset_init(void)
293 driver_register(&neponset_device_driver
);
296 * The Neponset is only present on the Assabet machine type.
298 if (!machine_is_assabet())
302 * Ensure that the memory bus request/grant signals are setup,
303 * and the grant is held in its inactive state, whether or not
304 * we actually have a Neponset attached.
308 if (!machine_has_neponset()) {
309 printk(KERN_DEBUG
"Neponset expansion board not present\n");
313 if (WHOAMI
!= 0x11) {
314 printk(KERN_WARNING
"Neponset board detected, but "
315 "wrong ID: %02x\n", WHOAMI
);
319 return platform_add_devices(devices
, ARRAY_SIZE(devices
));
322 subsys_initcall(neponset_init
);
324 static struct map_desc neponset_io_desc
[] __initdata
= {
325 /* virtual physical length type */
326 { 0xf3000000, 0x10000000, SZ_1M
, MT_DEVICE
}, /* System Registers */
327 { 0xf4000000, 0x40000000, SZ_1M
, MT_DEVICE
} /* SA-1111 */
330 void __init
neponset_map_io(void)
332 iotable_init(neponset_io_desc
, ARRAY_SIZE(neponset_io_desc
));