Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-sa1100/neponset.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | */ |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 4 | #include <linux/err.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <linux/ioport.h> |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 7 | #include <linux/irq.h> |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 8 | #include <linux/kernel.h> |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 9 | #include <linux/module.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 10 | #include <linux/platform_device.h> |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 11 | #include <linux/serial_core.h> |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 12 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/mach/map.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/mach/serial_sa1100.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <asm/hardware/sa1111.h> |
| 18 | #include <asm/sizes.h> |
| 19 | |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 20 | #include <mach/hardware.h> |
| 21 | #include <mach/assabet.h> |
| 22 | #include <mach/neponset.h> |
| 23 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 24 | #define NEP_IRQ_SMC91X 0 |
| 25 | #define NEP_IRQ_USAR 1 |
| 26 | #define NEP_IRQ_SA1111 2 |
| 27 | #define NEP_IRQ_NR 3 |
| 28 | |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 29 | struct neponset_drvdata { |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 30 | struct platform_device *sa1111; |
| 31 | struct platform_device *smc91x; |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 32 | unsigned irq_base; |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 33 | #ifdef CONFIG_PM_SLEEP |
| 34 | u32 ncr0; |
| 35 | u32 mdm_ctl_0; |
| 36 | #endif |
| 37 | }; |
| 38 | |
Russell King | 6ad1b61 | 2012-01-16 09:31:47 +0000 | [diff] [blame] | 39 | void neponset_ncr_frob(unsigned int mask, unsigned int val) |
| 40 | { |
| 41 | unsigned long flags; |
| 42 | |
| 43 | local_irq_save(flags); |
| 44 | NCR_0 = (NCR_0 & ~mask) | val; |
| 45 | local_irq_restore(flags); |
| 46 | } |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | static void neponset_set_mctrl(struct uart_port *port, u_int mctrl) |
| 49 | { |
| 50 | u_int mdm_ctl0 = MDM_CTL_0; |
| 51 | |
| 52 | if (port->mapbase == _Ser1UTCR0) { |
| 53 | if (mctrl & TIOCM_RTS) |
| 54 | mdm_ctl0 &= ~MDM_CTL0_RTS2; |
| 55 | else |
| 56 | mdm_ctl0 |= MDM_CTL0_RTS2; |
| 57 | |
| 58 | if (mctrl & TIOCM_DTR) |
| 59 | mdm_ctl0 &= ~MDM_CTL0_DTR2; |
| 60 | else |
| 61 | mdm_ctl0 |= MDM_CTL0_DTR2; |
| 62 | } else if (port->mapbase == _Ser3UTCR0) { |
| 63 | if (mctrl & TIOCM_RTS) |
| 64 | mdm_ctl0 &= ~MDM_CTL0_RTS1; |
| 65 | else |
| 66 | mdm_ctl0 |= MDM_CTL0_RTS1; |
| 67 | |
| 68 | if (mctrl & TIOCM_DTR) |
| 69 | mdm_ctl0 &= ~MDM_CTL0_DTR1; |
| 70 | else |
| 71 | mdm_ctl0 |= MDM_CTL0_DTR1; |
| 72 | } |
| 73 | |
| 74 | MDM_CTL_0 = mdm_ctl0; |
| 75 | } |
| 76 | |
| 77 | static u_int neponset_get_mctrl(struct uart_port *port) |
| 78 | { |
| 79 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; |
| 80 | u_int mdm_ctl1 = MDM_CTL_1; |
| 81 | |
| 82 | if (port->mapbase == _Ser1UTCR0) { |
| 83 | if (mdm_ctl1 & MDM_CTL1_DCD2) |
| 84 | ret &= ~TIOCM_CD; |
| 85 | if (mdm_ctl1 & MDM_CTL1_CTS2) |
| 86 | ret &= ~TIOCM_CTS; |
| 87 | if (mdm_ctl1 & MDM_CTL1_DSR2) |
| 88 | ret &= ~TIOCM_DSR; |
| 89 | } else if (port->mapbase == _Ser3UTCR0) { |
| 90 | if (mdm_ctl1 & MDM_CTL1_DCD1) |
| 91 | ret &= ~TIOCM_CD; |
| 92 | if (mdm_ctl1 & MDM_CTL1_CTS1) |
| 93 | ret &= ~TIOCM_CTS; |
| 94 | if (mdm_ctl1 & MDM_CTL1_DSR1) |
| 95 | ret &= ~TIOCM_DSR; |
| 96 | } |
| 97 | |
| 98 | return ret; |
| 99 | } |
| 100 | |
Russell King | cdea460 | 2007-05-30 17:48:45 +0100 | [diff] [blame] | 101 | static struct sa1100_port_fns neponset_port_fns __devinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | .set_mctrl = neponset_set_mctrl, |
| 103 | .get_mctrl = neponset_get_mctrl, |
| 104 | }; |
| 105 | |
Russell King | 7104552 | 2012-01-16 00:17:41 +0000 | [diff] [blame] | 106 | /* |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 107 | * Install handler for Neponset IRQ. Note that we have to loop here |
| 108 | * since the ETHERNET and USAR IRQs are level based, and we need to |
| 109 | * ensure that the IRQ signal is deasserted before returning. This |
| 110 | * is rather unfortunate. |
| 111 | */ |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 112 | static void neponset_irq_handler(unsigned int irq, struct irq_desc *desc) |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 113 | { |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 114 | struct neponset_drvdata *d = irq_desc_get_handler_data(desc); |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 115 | unsigned int irr; |
| 116 | |
| 117 | while (1) { |
| 118 | /* |
| 119 | * Acknowledge the parent IRQ. |
| 120 | */ |
| 121 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
| 122 | |
| 123 | /* |
| 124 | * Read the interrupt reason register. Let's have all |
| 125 | * active IRQ bits high. Note: there is a typo in the |
| 126 | * Neponset user's guide for the SA1111 IRR level. |
| 127 | */ |
| 128 | irr = IRR ^ (IRR_ETHERNET | IRR_USAR); |
| 129 | |
| 130 | if ((irr & (IRR_ETHERNET | IRR_USAR | IRR_SA1111)) == 0) |
| 131 | break; |
| 132 | |
| 133 | /* |
| 134 | * Since there is no individual mask, we have to |
| 135 | * mask the parent IRQ. This is safe, since we'll |
| 136 | * recheck the register for any pending IRQs. |
| 137 | */ |
| 138 | if (irr & (IRR_ETHERNET | IRR_USAR)) { |
| 139 | desc->irq_data.chip->irq_mask(&desc->irq_data); |
| 140 | |
| 141 | /* |
| 142 | * Ack the interrupt now to prevent re-entering |
| 143 | * this neponset handler. Again, this is safe |
| 144 | * since we'll check the IRR register prior to |
| 145 | * leaving. |
| 146 | */ |
| 147 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
| 148 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 149 | if (irr & IRR_ETHERNET) |
| 150 | generic_handle_irq(d->irq_base + NEP_IRQ_SMC91X); |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 151 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 152 | if (irr & IRR_USAR) |
| 153 | generic_handle_irq(d->irq_base + NEP_IRQ_USAR); |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 154 | |
| 155 | desc->irq_data.chip->irq_unmask(&desc->irq_data); |
| 156 | } |
| 157 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 158 | if (irr & IRR_SA1111) |
| 159 | generic_handle_irq(d->irq_base + NEP_IRQ_SA1111); |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 163 | /* Yes, we really do not have any kind of masking or unmasking */ |
Russell King | 7104552 | 2012-01-16 00:17:41 +0000 | [diff] [blame] | 164 | static void nochip_noop(struct irq_data *irq) |
| 165 | { |
| 166 | } |
| 167 | |
| 168 | static struct irq_chip nochip = { |
| 169 | .name = "neponset", |
| 170 | .irq_ack = nochip_noop, |
| 171 | .irq_mask = nochip_noop, |
| 172 | .irq_unmask = nochip_noop, |
| 173 | }; |
| 174 | |
Russell King | 92e617d | 2012-01-24 22:13:00 +0000 | [diff] [blame] | 175 | static struct sa1111_platform_data sa1111_info = { |
| 176 | .irq_base = IRQ_BOARD_END, |
| 177 | }; |
| 178 | |
Russell King | cdea460 | 2007-05-30 17:48:45 +0100 | [diff] [blame] | 179 | static int __devinit neponset_probe(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | { |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 181 | struct neponset_drvdata *d; |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 182 | struct resource sa1111_resources[] = { |
| 183 | DEFINE_RES_MEM(0x40000000, SZ_8K), |
| 184 | { .flags = IORESOURCE_IRQ }, |
| 185 | }; |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 186 | struct platform_device_info sa1111_devinfo = { |
| 187 | .parent = &dev->dev, |
| 188 | .name = "sa1111", |
| 189 | .id = 0, |
| 190 | .res = sa1111_resources, |
| 191 | .num_res = ARRAY_SIZE(sa1111_resources), |
| 192 | .data = &sa1111_info, |
| 193 | .size_data = sizeof(sa1111_info), |
| 194 | .dma_mask = 0xffffffffUL, |
| 195 | }; |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 196 | struct resource smc91x_resources[] = { |
| 197 | DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, |
| 198 | 0x02000000, "smc91x-regs"), |
| 199 | DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000, |
| 200 | 0x02000000, "smc91x-attrib"), |
| 201 | { .flags = IORESOURCE_IRQ }, |
| 202 | }; |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 203 | struct platform_device_info smc91x_devinfo = { |
| 204 | .parent = &dev->dev, |
| 205 | .name = "smc91x", |
| 206 | .id = 0, |
| 207 | .res = smc91x_resources, |
| 208 | .num_res = ARRAY_SIZE(smc91x_resources), |
| 209 | }; |
Russell King | b6bdfcf | 2012-01-24 23:05:08 +0000 | [diff] [blame^] | 210 | int ret, irq; |
| 211 | |
| 212 | irq = ret = platform_get_irq(dev, 0); |
| 213 | if (ret < 0) |
| 214 | goto err_alloc; |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 215 | |
| 216 | d = kzalloc(sizeof(*d), GFP_KERNEL); |
| 217 | if (!d) { |
| 218 | ret = -ENOMEM; |
| 219 | goto err_alloc; |
| 220 | } |
| 221 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 222 | ret = irq_alloc_descs(-1, IRQ_BOARD_START, NEP_IRQ_NR, -1); |
| 223 | if (ret <= 0) { |
| 224 | dev_err(&dev->dev, "unable to allocate %u irqs: %d\n", |
| 225 | NEP_IRQ_NR, ret); |
| 226 | if (ret == 0) |
| 227 | ret = -ENOMEM; |
| 228 | goto err_irq_alloc; |
| 229 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 231 | d->irq_base = ret; |
| 232 | |
| 233 | irq_set_chip_and_handler(d->irq_base + NEP_IRQ_SMC91X, &nochip, |
| 234 | handle_simple_irq); |
| 235 | set_irq_flags(d->irq_base + NEP_IRQ_SMC91X, IRQF_VALID | IRQF_PROBE); |
| 236 | irq_set_chip_and_handler(d->irq_base + NEP_IRQ_USAR, &nochip, |
| 237 | handle_simple_irq); |
| 238 | set_irq_flags(d->irq_base + NEP_IRQ_USAR, IRQF_VALID | IRQF_PROBE); |
| 239 | irq_set_chip(d->irq_base + NEP_IRQ_SA1111, &nochip); |
| 240 | |
Russell King | b6bdfcf | 2012-01-24 23:05:08 +0000 | [diff] [blame^] | 241 | irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING); |
| 242 | irq_set_handler_data(irq, d); |
| 243 | irq_set_chained_handler(irq, neponset_irq_handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
| 245 | /* |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 246 | * We would set IRQ_GPIO25 to be a wake-up IRQ, but unfortunately |
| 247 | * something on the Neponset activates this IRQ on sleep (eth?) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | */ |
| 249 | #if 0 |
Russell King | b6bdfcf | 2012-01-24 23:05:08 +0000 | [diff] [blame^] | 250 | enable_irq_wake(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | #endif |
| 252 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 253 | dev_info(&dev->dev, "Neponset daughter board, providing IRQ%u-%u\n", |
| 254 | d->irq_base, d->irq_base + NEP_IRQ_NR - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 256 | sa1100_register_uart_fns(&neponset_port_fns); |
| 257 | |
| 258 | /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | NCR_0 = NCR_GP01_OFF; |
| 260 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 261 | sa1111_resources[1].start = d->irq_base + NEP_IRQ_SA1111; |
| 262 | sa1111_resources[1].end = d->irq_base + NEP_IRQ_SA1111; |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 263 | d->sa1111 = platform_device_register_full(&sa1111_devinfo); |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 264 | |
| 265 | smc91x_resources[2].start = d->irq_base + NEP_IRQ_SMC91X; |
| 266 | smc91x_resources[2].end = d->irq_base + NEP_IRQ_SMC91X; |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 267 | d->smc91x = platform_device_register_full(&smc91x_devinfo); |
| 268 | |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 269 | platform_set_drvdata(dev, d); |
| 270 | |
| 271 | return 0; |
| 272 | |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 273 | err_irq_alloc: |
| 274 | kfree(d); |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 275 | err_alloc: |
| 276 | return ret; |
| 277 | } |
| 278 | |
| 279 | static int __devexit neponset_remove(struct platform_device *dev) |
| 280 | { |
| 281 | struct neponset_drvdata *d = platform_get_drvdata(dev); |
Russell King | b6bdfcf | 2012-01-24 23:05:08 +0000 | [diff] [blame^] | 282 | int irq = platform_get_irq(dev, 0); |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 283 | |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 284 | if (!IS_ERR(d->sa1111)) |
| 285 | platform_device_unregister(d->sa1111); |
| 286 | if (!IS_ERR(d->smc91x)) |
| 287 | platform_device_unregister(d->smc91x); |
Russell King | b6bdfcf | 2012-01-24 23:05:08 +0000 | [diff] [blame^] | 288 | irq_set_chained_handler(irq, NULL); |
Russell King | ced8d21 | 2012-01-24 22:22:18 +0000 | [diff] [blame] | 289 | irq_free_descs(d->irq_base, NEP_IRQ_NR); |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 290 | kfree(d); |
| 291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | #ifdef CONFIG_PM |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 296 | static int neponset_suspend(struct platform_device *dev, pm_message_t state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | { |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 298 | struct neponset_drvdata *d = platform_get_drvdata(dev); |
| 299 | |
| 300 | d->ncr0 = NCR_0; |
| 301 | d->mdm_ctl_0 = MDM_CTL_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 306 | static int neponset_resume(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | { |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 308 | struct neponset_drvdata *d = platform_get_drvdata(dev); |
| 309 | |
| 310 | NCR_0 = d->ncr0; |
| 311 | MDM_CTL_0 = d->mdm_ctl_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | #else |
| 317 | #define neponset_suspend NULL |
| 318 | #define neponset_resume NULL |
| 319 | #endif |
| 320 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 321 | static struct platform_driver neponset_device_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | .probe = neponset_probe, |
Russell King | ae14c2e | 2012-01-24 22:10:02 +0000 | [diff] [blame] | 323 | .remove = __devexit_p(neponset_remove), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | .suspend = neponset_suspend, |
| 325 | .resume = neponset_resume, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 326 | .driver = { |
| 327 | .name = "neponset", |
Russell King | 398e58d | 2012-01-24 23:33:28 +0000 | [diff] [blame] | 328 | .owner = THIS_MODULE, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 329 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | }; |
| 331 | |
| 332 | static struct resource neponset_resources[] = { |
Russell King | b6bdfcf | 2012-01-24 23:05:08 +0000 | [diff] [blame^] | 333 | DEFINE_RES_MEM(0x10000000, 0x08000000), |
| 334 | DEFINE_RES_IRQ(IRQ_GPIO25), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | }; |
| 336 | |
| 337 | static struct platform_device neponset_device = { |
| 338 | .name = "neponset", |
| 339 | .id = 0, |
| 340 | .num_resources = ARRAY_SIZE(neponset_resources), |
| 341 | .resource = neponset_resources, |
| 342 | }; |
| 343 | |
Russell King | cdcb81f | 2007-07-20 10:32:46 +0100 | [diff] [blame] | 344 | extern void sa1110_mb_disable(void); |
| 345 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | static int __init neponset_init(void) |
| 347 | { |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 348 | platform_driver_register(&neponset_device_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
| 350 | /* |
| 351 | * The Neponset is only present on the Assabet machine type. |
| 352 | */ |
| 353 | if (!machine_is_assabet()) |
| 354 | return -ENODEV; |
| 355 | |
| 356 | /* |
| 357 | * Ensure that the memory bus request/grant signals are setup, |
| 358 | * and the grant is held in its inactive state, whether or not |
| 359 | * we actually have a Neponset attached. |
| 360 | */ |
| 361 | sa1110_mb_disable(); |
| 362 | |
| 363 | if (!machine_has_neponset()) { |
| 364 | printk(KERN_DEBUG "Neponset expansion board not present\n"); |
| 365 | return -ENODEV; |
| 366 | } |
| 367 | |
| 368 | if (WHOAMI != 0x11) { |
| 369 | printk(KERN_WARNING "Neponset board detected, but " |
| 370 | "wrong ID: %02x\n", WHOAMI); |
| 371 | return -ENODEV; |
| 372 | } |
| 373 | |
Russell King | 9590e89 | 2012-01-24 22:36:47 +0000 | [diff] [blame] | 374 | return platform_device_register(&neponset_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | subsys_initcall(neponset_init); |
| 378 | |
| 379 | static struct map_desc neponset_io_desc[] __initdata = { |
Deepak Saxena | 92519d8 | 2005-10-28 15:19:04 +0100 | [diff] [blame] | 380 | { /* System Registers */ |
| 381 | .virtual = 0xf3000000, |
| 382 | .pfn = __phys_to_pfn(0x10000000), |
| 383 | .length = SZ_1M, |
| 384 | .type = MT_DEVICE |
| 385 | }, { /* SA-1111 */ |
| 386 | .virtual = 0xf4000000, |
| 387 | .pfn = __phys_to_pfn(0x40000000), |
| 388 | .length = SZ_1M, |
| 389 | .type = MT_DEVICE |
| 390 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | void __init neponset_map_io(void) |
| 394 | { |
| 395 | iotable_init(neponset_io_desc, ARRAY_SIZE(neponset_io_desc)); |
| 396 | } |