diff options
| author | Geert Uytterhoeven <geert@linux-m68k.org> | 2009-04-05 07:13:20 -0400 |
|---|---|---|
| committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-26 13:51:09 -0400 |
| commit | 6f8221c26be5d80f749b1b6c2e7c8456fefb5250 (patch) | |
| tree | a670659f15741e4f41a0038ceb05f739c74ac22d | |
| parent | 826e8c8c804e5a38586c6b48ef38d1e755789f0c (diff) | |
m68k: amiga - Parallel port platform device conversion
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
| -rw-r--r-- | arch/m68k/amiga/platform.c | 3 | ||||
| -rw-r--r-- | drivers/parport/parport_amiga.c | 64 |
2 files changed, 43 insertions, 24 deletions
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index 52aa62da8528..c985db029503 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c | |||
| @@ -171,6 +171,9 @@ static int __init amiga_init_devices(void) | |||
| 171 | if (AMIGAHW_PRESENT(AMI_SERIAL)) | 171 | if (AMIGAHW_PRESENT(AMI_SERIAL)) |
| 172 | platform_device_register_simple("amiga-serial", -1, NULL, 0); | 172 | platform_device_register_simple("amiga-serial", -1, NULL, 0); |
| 173 | 173 | ||
| 174 | if (AMIGAHW_PRESENT(AMI_PARALLEL)) | ||
| 175 | platform_device_register_simple("amiga-parallel", -1, NULL, 0); | ||
| 176 | |||
| 174 | return 0; | 177 | return 0; |
| 175 | } | 178 | } |
| 176 | 179 | ||
diff --git a/drivers/parport/parport_amiga.c b/drivers/parport/parport_amiga.c index 1586e1caa2f5..8bef6d60f88b 100644 --- a/drivers/parport/parport_amiga.c +++ b/drivers/parport/parport_amiga.c | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | #include <linux/parport.h> | 18 | #include <linux/parport.h> |
| 19 | #include <linux/ioport.h> | 19 | #include <linux/ioport.h> |
| 20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
| 21 | #include <linux/platform_device.h> | ||
| 22 | |||
| 21 | #include <asm/setup.h> | 23 | #include <asm/setup.h> |
| 22 | #include <asm/amigahw.h> | 24 | #include <asm/amigahw.h> |
| 23 | #include <asm/irq.h> | 25 | #include <asm/irq.h> |
| @@ -31,7 +33,6 @@ | |||
| 31 | #define DPRINTK(x...) do { } while (0) | 33 | #define DPRINTK(x...) do { } while (0) |
| 32 | #endif | 34 | #endif |
| 33 | 35 | ||
| 34 | static struct parport *this_port = NULL; | ||
| 35 | 36 | ||
| 36 | static void amiga_write_data(struct parport *p, unsigned char data) | 37 | static void amiga_write_data(struct parport *p, unsigned char data) |
| 37 | { | 38 | { |
| @@ -227,18 +228,11 @@ static struct parport_operations pp_amiga_ops = { | |||
| 227 | 228 | ||
| 228 | /* ----------- Initialisation code --------------------------------- */ | 229 | /* ----------- Initialisation code --------------------------------- */ |
| 229 | 230 | ||
| 230 | static int __init parport_amiga_init(void) | 231 | static int __init amiga_parallel_probe(struct platform_device *pdev) |
| 231 | { | 232 | { |
| 232 | struct parport *p; | 233 | struct parport *p; |
| 233 | int err; | 234 | int err; |
| 234 | 235 | ||
| 235 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_PARALLEL)) | ||
| 236 | return -ENODEV; | ||
| 237 | |||
| 238 | err = -EBUSY; | ||
| 239 | if (!request_mem_region(CIAA_PHYSADDR-1+0x100, 0x100, "parallel")) | ||
| 240 | goto out_mem; | ||
| 241 | |||
| 242 | ciaa.ddrb = 0xff; | 236 | ciaa.ddrb = 0xff; |
| 243 | ciab.ddra &= 0xf8; | 237 | ciab.ddra &= 0xf8; |
| 244 | mb(); | 238 | mb(); |
| @@ -246,41 +240,63 @@ static int __init parport_amiga_init(void) | |||
| 246 | p = parport_register_port((unsigned long)&ciaa.prb, IRQ_AMIGA_CIAA_FLG, | 240 | p = parport_register_port((unsigned long)&ciaa.prb, IRQ_AMIGA_CIAA_FLG, |
| 247 | PARPORT_DMA_NONE, &pp_amiga_ops); | 241 | PARPORT_DMA_NONE, &pp_amiga_ops); |
| 248 | if (!p) | 242 | if (!p) |
| 249 | goto out_port; | 243 | return -EBUSY; |
| 250 | 244 | ||
| 251 | err = request_irq(IRQ_AMIGA_CIAA_FLG, parport_irq_handler, 0, p->name, p); | 245 | err = request_irq(IRQ_AMIGA_CIAA_FLG, parport_irq_handler, 0, p->name, |
| 246 | p); | ||
| 252 | if (err) | 247 | if (err) |
| 253 | goto out_irq; | 248 | goto out_irq; |
| 254 | 249 | ||
| 255 | this_port = p; | ||
| 256 | printk(KERN_INFO "%s: Amiga built-in port using irq\n", p->name); | 250 | printk(KERN_INFO "%s: Amiga built-in port using irq\n", p->name); |
| 257 | /* XXX: set operating mode */ | 251 | /* XXX: set operating mode */ |
| 258 | parport_announce_port(p); | 252 | parport_announce_port(p); |
| 259 | 253 | ||
| 254 | platform_set_drvdata(pdev, p); | ||
| 255 | |||
| 260 | return 0; | 256 | return 0; |
| 261 | 257 | ||
| 262 | out_irq: | 258 | out_irq: |
| 263 | parport_put_port(p); | 259 | parport_put_port(p); |
| 264 | out_port: | ||
| 265 | release_mem_region(CIAA_PHYSADDR-1+0x100, 0x100); | ||
| 266 | out_mem: | ||
| 267 | return err; | 260 | return err; |
| 268 | } | 261 | } |
| 269 | 262 | ||
| 270 | static void __exit parport_amiga_exit(void) | 263 | static int __exit amiga_parallel_remove(struct platform_device *pdev) |
| 264 | { | ||
| 265 | struct parport *port = platform_get_drvdata(pdev); | ||
| 266 | |||
| 267 | parport_remove_port(port); | ||
| 268 | if (port->irq != PARPORT_IRQ_NONE) | ||
| 269 | free_irq(IRQ_AMIGA_CIAA_FLG, port); | ||
| 270 | parport_put_port(port); | ||
| 271 | platform_set_drvdata(pdev, NULL); | ||
| 272 | return 0; | ||
| 273 | } | ||
| 274 | |||
| 275 | static struct platform_driver amiga_parallel_driver = { | ||
| 276 | .remove = __exit_p(amiga_parallel_remove), | ||
| 277 | .driver = { | ||
| 278 | .name = "amiga-parallel", | ||
| 279 | .owner = THIS_MODULE, | ||
| 280 | }, | ||
| 281 | }; | ||
| 282 | |||
| 283 | static int __init amiga_parallel_init(void) | ||
| 284 | { | ||
| 285 | return platform_driver_probe(&amiga_parallel_driver, | ||
| 286 | amiga_parallel_probe); | ||
| 287 | } | ||
| 288 | |||
| 289 | module_init(amiga_parallel_init); | ||
| 290 | |||
| 291 | static void __exit amiga_parallel_exit(void) | ||
| 271 | { | 292 | { |
| 272 | parport_remove_port(this_port); | 293 | platform_driver_unregister(&amiga_parallel_driver); |
| 273 | if (this_port->irq != PARPORT_IRQ_NONE) | ||
| 274 | free_irq(IRQ_AMIGA_CIAA_FLG, this_port); | ||
| 275 | parport_put_port(this_port); | ||
| 276 | release_mem_region(CIAA_PHYSADDR-1+0x100, 0x100); | ||
| 277 | } | 294 | } |
| 278 | 295 | ||
| 296 | module_exit(amiga_parallel_exit); | ||
| 279 | 297 | ||
| 280 | MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>"); | 298 | MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>"); |
| 281 | MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port"); | 299 | MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port"); |
| 282 | MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port"); | 300 | MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port"); |
| 283 | MODULE_LICENSE("GPL"); | 301 | MODULE_LICENSE("GPL"); |
| 284 | 302 | MODULE_ALIAS("platform:amiga-parallel"); | |
| 285 | module_init(parport_amiga_init) | ||
| 286 | module_exit(parport_amiga_exit) | ||
