diff options
| -rw-r--r-- | arch/m68k/amiga/platform.c | 3 | ||||
| -rw-r--r-- | drivers/input/mouse/amimouse.c | 98 |
2 files changed, 66 insertions, 35 deletions
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index d427de23c02e..269bafc8da17 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c | |||
| @@ -165,6 +165,9 @@ static int __init amiga_init_devices(void) | |||
| 165 | if (AMIGAHW_PRESENT(AMI_KEYBOARD)) | 165 | if (AMIGAHW_PRESENT(AMI_KEYBOARD)) |
| 166 | platform_device_register_simple("amiga-keyboard", -1, NULL, 0); | 166 | platform_device_register_simple("amiga-keyboard", -1, NULL, 0); |
| 167 | 167 | ||
| 168 | if (AMIGAHW_PRESENT(AMI_MOUSE)) | ||
| 169 | platform_device_register_simple("amiga-mouse", -1, NULL, 0); | ||
| 170 | |||
| 168 | return 0; | 171 | return 0; |
| 169 | } | 172 | } |
| 170 | 173 | ||
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index a185ac78a42c..ff5f61a0fd3a 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
| 22 | #include <linux/input.h> | 22 | #include <linux/input.h> |
| 23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/platform_device.h> | ||
| 24 | 25 | ||
| 25 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
| 26 | #include <asm/setup.h> | 27 | #include <asm/setup.h> |
| @@ -34,10 +35,10 @@ MODULE_DESCRIPTION("Amiga mouse driver"); | |||
| 34 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
| 35 | 36 | ||
| 36 | static int amimouse_lastx, amimouse_lasty; | 37 | static int amimouse_lastx, amimouse_lasty; |
| 37 | static struct input_dev *amimouse_dev; | ||
| 38 | 38 | ||
| 39 | static irqreturn_t amimouse_interrupt(int irq, void *dummy) | 39 | static irqreturn_t amimouse_interrupt(int irq, void *data) |
| 40 | { | 40 | { |
| 41 | struct input_dev *dev = data; | ||
| 41 | unsigned short joy0dat, potgor; | 42 | unsigned short joy0dat, potgor; |
| 42 | int nx, ny, dx, dy; | 43 | int nx, ny, dx, dy; |
| 43 | 44 | ||
| @@ -59,14 +60,14 @@ static irqreturn_t amimouse_interrupt(int irq, void *dummy) | |||
| 59 | 60 | ||
| 60 | potgor = amiga_custom.potgor; | 61 | potgor = amiga_custom.potgor; |
| 61 | 62 | ||
| 62 | input_report_rel(amimouse_dev, REL_X, dx); | 63 | input_report_rel(dev, REL_X, dx); |
| 63 | input_report_rel(amimouse_dev, REL_Y, dy); | 64 | input_report_rel(dev, REL_Y, dy); |
| 64 | 65 | ||
| 65 | input_report_key(amimouse_dev, BTN_LEFT, ciaa.pra & 0x40); | 66 | input_report_key(dev, BTN_LEFT, ciaa.pra & 0x40); |
| 66 | input_report_key(amimouse_dev, BTN_MIDDLE, potgor & 0x0100); | 67 | input_report_key(dev, BTN_MIDDLE, potgor & 0x0100); |
| 67 | input_report_key(amimouse_dev, BTN_RIGHT, potgor & 0x0400); | 68 | input_report_key(dev, BTN_RIGHT, potgor & 0x0400); |
| 68 | 69 | ||
| 69 | input_sync(amimouse_dev); | 70 | input_sync(dev); |
| 70 | 71 | ||
| 71 | return IRQ_HANDLED; | 72 | return IRQ_HANDLED; |
| 72 | } | 73 | } |
| @@ -74,63 +75,90 @@ static irqreturn_t amimouse_interrupt(int irq, void *dummy) | |||
| 74 | static int amimouse_open(struct input_dev *dev) | 75 | static int amimouse_open(struct input_dev *dev) |
| 75 | { | 76 | { |
| 76 | unsigned short joy0dat; | 77 | unsigned short joy0dat; |
| 78 | int error; | ||
| 77 | 79 | ||
| 78 | joy0dat = amiga_custom.joy0dat; | 80 | joy0dat = amiga_custom.joy0dat; |
| 79 | 81 | ||
| 80 | amimouse_lastx = joy0dat & 0xff; | 82 | amimouse_lastx = joy0dat & 0xff; |
| 81 | amimouse_lasty = joy0dat >> 8; | 83 | amimouse_lasty = joy0dat >> 8; |
| 82 | 84 | ||
| 83 | if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { | 85 | error = request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", |
| 84 | printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); | 86 | dev); |
| 85 | return -EBUSY; | 87 | if (error) |
| 86 | } | 88 | dev_err(&dev->dev, "Can't allocate irq %d\n", IRQ_AMIGA_VERTB); |
| 87 | 89 | ||
| 88 | return 0; | 90 | return error; |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | static void amimouse_close(struct input_dev *dev) | 93 | static void amimouse_close(struct input_dev *dev) |
| 92 | { | 94 | { |
| 93 | free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); | 95 | free_irq(IRQ_AMIGA_VERTB, dev); |
| 94 | } | 96 | } |
| 95 | 97 | ||
| 96 | static int __init amimouse_init(void) | 98 | static int __init amimouse_probe(struct platform_device *pdev) |
| 97 | { | 99 | { |
| 98 | int err; | 100 | int err; |
| 101 | struct input_dev *dev; | ||
| 99 | 102 | ||
| 100 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) | 103 | dev = input_allocate_device(); |
| 101 | return -ENODEV; | 104 | if (!dev) |
| 102 | |||
| 103 | amimouse_dev = input_allocate_device(); | ||
| 104 | if (!amimouse_dev) | ||
| 105 | return -ENOMEM; | 105 | return -ENOMEM; |
| 106 | 106 | ||
| 107 | amimouse_dev->name = "Amiga mouse"; | 107 | dev->name = pdev->name; |
| 108 | amimouse_dev->phys = "amimouse/input0"; | 108 | dev->phys = "amimouse/input0"; |
| 109 | amimouse_dev->id.bustype = BUS_AMIGA; | 109 | dev->id.bustype = BUS_AMIGA; |
| 110 | amimouse_dev->id.vendor = 0x0001; | 110 | dev->id.vendor = 0x0001; |
| 111 | amimouse_dev->id.product = 0x0002; | 111 | dev->id.product = 0x0002; |
| 112 | amimouse_dev->id.version = 0x0100; | 112 | dev->id.version = 0x0100; |
| 113 | 113 | ||
| 114 | amimouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); | 114 | dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
| 115 | amimouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | 115 | dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
| 116 | amimouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | | 116 | dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
| 117 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | 117 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
| 118 | amimouse_dev->open = amimouse_open; | 118 | dev->open = amimouse_open; |
| 119 | amimouse_dev->close = amimouse_close; | 119 | dev->close = amimouse_close; |
| 120 | dev->dev.parent = &pdev->dev; | ||
| 120 | 121 | ||
| 121 | err = input_register_device(amimouse_dev); | 122 | err = input_register_device(dev); |
| 122 | if (err) { | 123 | if (err) { |
| 123 | input_free_device(amimouse_dev); | 124 | input_free_device(dev); |
| 124 | return err; | 125 | return err; |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 128 | platform_set_drvdata(pdev, dev); | ||
| 129 | |||
| 127 | return 0; | 130 | return 0; |
| 128 | } | 131 | } |
| 129 | 132 | ||
| 130 | static void __exit amimouse_exit(void) | 133 | static int __exit amimouse_remove(struct platform_device *pdev) |
| 131 | { | 134 | { |
| 132 | input_unregister_device(amimouse_dev); | 135 | struct input_dev *dev = platform_get_drvdata(pdev); |
| 136 | |||
| 137 | platform_set_drvdata(pdev, NULL); | ||
| 138 | input_unregister_device(dev); | ||
| 139 | return 0; | ||
| 140 | } | ||
| 141 | |||
| 142 | static struct platform_driver amimouse_driver = { | ||
| 143 | .remove = __exit_p(amimouse_remove), | ||
| 144 | .driver = { | ||
| 145 | .name = "amiga-mouse", | ||
| 146 | .owner = THIS_MODULE, | ||
| 147 | }, | ||
| 148 | }; | ||
| 149 | |||
| 150 | static int __init amimouse_init(void) | ||
| 151 | { | ||
| 152 | return platform_driver_probe(&amimouse_driver, amimouse_probe); | ||
| 133 | } | 153 | } |
| 134 | 154 | ||
| 135 | module_init(amimouse_init); | 155 | module_init(amimouse_init); |
| 156 | |||
| 157 | static void __exit amimouse_exit(void) | ||
| 158 | { | ||
| 159 | platform_driver_unregister(&amimouse_driver); | ||
| 160 | } | ||
| 161 | |||
| 136 | module_exit(amimouse_exit); | 162 | module_exit(amimouse_exit); |
| 163 | |||
| 164 | MODULE_ALIAS("platform:amiga-mouse"); | ||
