m68k: amiga - Parallel port platform device conversion

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
Geert Uytterhoeven 2009-04-05 13:13:20 +02:00
parent 826e8c8c80
commit 6f8221c26b
2 changed files with 43 additions and 24 deletions

View File

@ -171,6 +171,9 @@ static int __init amiga_init_devices(void)
if (AMIGAHW_PRESENT(AMI_SERIAL)) if (AMIGAHW_PRESENT(AMI_SERIAL))
platform_device_register_simple("amiga-serial", -1, NULL, 0); platform_device_register_simple("amiga-serial", -1, NULL, 0);
if (AMIGAHW_PRESENT(AMI_PARALLEL))
platform_device_register_simple("amiga-parallel", -1, NULL, 0);
return 0; return 0;
} }

View File

@ -18,6 +18,8 @@
#include <linux/parport.h> #include <linux/parport.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/amigahw.h> #include <asm/amigahw.h>
#include <asm/irq.h> #include <asm/irq.h>
@ -31,7 +33,6 @@
#define DPRINTK(x...) do { } while (0) #define DPRINTK(x...) do { } while (0)
#endif #endif
static struct parport *this_port = NULL;
static void amiga_write_data(struct parport *p, unsigned char data) static void amiga_write_data(struct parport *p, unsigned char data)
{ {
@ -227,18 +228,11 @@ static struct parport_operations pp_amiga_ops = {
/* ----------- Initialisation code --------------------------------- */ /* ----------- Initialisation code --------------------------------- */
static int __init parport_amiga_init(void) static int __init amiga_parallel_probe(struct platform_device *pdev)
{ {
struct parport *p; struct parport *p;
int err; int err;
if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_PARALLEL))
return -ENODEV;
err = -EBUSY;
if (!request_mem_region(CIAA_PHYSADDR-1+0x100, 0x100, "parallel"))
goto out_mem;
ciaa.ddrb = 0xff; ciaa.ddrb = 0xff;
ciab.ddra &= 0xf8; ciab.ddra &= 0xf8;
mb(); mb();
@ -246,41 +240,63 @@ static int __init parport_amiga_init(void)
p = parport_register_port((unsigned long)&ciaa.prb, IRQ_AMIGA_CIAA_FLG, p = parport_register_port((unsigned long)&ciaa.prb, IRQ_AMIGA_CIAA_FLG,
PARPORT_DMA_NONE, &pp_amiga_ops); PARPORT_DMA_NONE, &pp_amiga_ops);
if (!p) if (!p)
goto out_port; return -EBUSY;
err = request_irq(IRQ_AMIGA_CIAA_FLG, parport_irq_handler, 0, p->name, p); err = request_irq(IRQ_AMIGA_CIAA_FLG, parport_irq_handler, 0, p->name,
p);
if (err) if (err)
goto out_irq; goto out_irq;
this_port = p;
printk(KERN_INFO "%s: Amiga built-in port using irq\n", p->name); printk(KERN_INFO "%s: Amiga built-in port using irq\n", p->name);
/* XXX: set operating mode */ /* XXX: set operating mode */
parport_announce_port(p); parport_announce_port(p);
platform_set_drvdata(pdev, p);
return 0; return 0;
out_irq: out_irq:
parport_put_port(p); parport_put_port(p);
out_port:
release_mem_region(CIAA_PHYSADDR-1+0x100, 0x100);
out_mem:
return err; return err;
} }
static void __exit parport_amiga_exit(void) static int __exit amiga_parallel_remove(struct platform_device *pdev)
{ {
parport_remove_port(this_port); struct parport *port = platform_get_drvdata(pdev);
if (this_port->irq != PARPORT_IRQ_NONE)
free_irq(IRQ_AMIGA_CIAA_FLG, this_port); parport_remove_port(port);
parport_put_port(this_port); if (port->irq != PARPORT_IRQ_NONE)
release_mem_region(CIAA_PHYSADDR-1+0x100, 0x100); free_irq(IRQ_AMIGA_CIAA_FLG, port);
parport_put_port(port);
platform_set_drvdata(pdev, NULL);
return 0;
} }
static struct platform_driver amiga_parallel_driver = {
.remove = __exit_p(amiga_parallel_remove),
.driver = {
.name = "amiga-parallel",
.owner = THIS_MODULE,
},
};
static int __init amiga_parallel_init(void)
{
return platform_driver_probe(&amiga_parallel_driver,
amiga_parallel_probe);
}
module_init(amiga_parallel_init);
static void __exit amiga_parallel_exit(void)
{
platform_driver_unregister(&amiga_parallel_driver);
}
module_exit(amiga_parallel_exit);
MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>"); MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port"); MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port");
MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port"); MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:amiga-parallel");
module_init(parport_amiga_init)
module_exit(parport_amiga_exit)