Commit 5121c717 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

m68k: amiga - Keyboard platform device conversion

Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent 9aed2302
...@@ -160,6 +160,11 @@ static int __init amiga_init_devices(void) ...@@ -160,6 +160,11 @@ static int __init amiga_init_devices(void)
sizeof(a4000_ide_pdata)); sizeof(a4000_ide_pdata));
} }
/* other I/O hardware */
if (AMIGAHW_PRESENT(AMI_KEYBOARD))
platform_device_register_simple("amiga-keyboard", -1, NULL, 0);
return 0; return 0;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/keyboard.h> #include <linux/keyboard.h>
#include <linux/platform_device.h>
#include <asm/amigaints.h> #include <asm/amigaints.h>
#include <asm/amigahw.h> #include <asm/amigahw.h>
...@@ -154,10 +155,9 @@ static const char *amikbd_messages[8] = { ...@@ -154,10 +155,9 @@ static const char *amikbd_messages[8] = {
[7] = KERN_WARNING "amikbd: keyboard interrupt\n" [7] = KERN_WARNING "amikbd: keyboard interrupt\n"
}; };
static struct input_dev *amikbd_dev; static irqreturn_t amikbd_interrupt(int irq, void *data)
static irqreturn_t amikbd_interrupt(int irq, void *dummy)
{ {
struct input_dev *dev = data;
unsigned char scancode, down; unsigned char scancode, down;
scancode = ~ciaa.sdr; /* get and invert scancode (keyboard is active low) */ scancode = ~ciaa.sdr; /* get and invert scancode (keyboard is active low) */
...@@ -170,47 +170,42 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy) ...@@ -170,47 +170,42 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy)
if (scancode < 0x78) { /* scancodes < 0x78 are keys */ if (scancode < 0x78) { /* scancodes < 0x78 are keys */
if (scancode == 98) { /* CapsLock is a toggle switch key on Amiga */ if (scancode == 98) { /* CapsLock is a toggle switch key on Amiga */
input_report_key(amikbd_dev, scancode, 1); input_report_key(dev, scancode, 1);
input_report_key(amikbd_dev, scancode, 0); input_report_key(dev, scancode, 0);
} else { } else {
input_report_key(amikbd_dev, scancode, down); input_report_key(dev, scancode, down);
} }
input_sync(amikbd_dev); input_sync(dev);
} else /* scancodes >= 0x78 are error codes */ } else /* scancodes >= 0x78 are error codes */
printk(amikbd_messages[scancode - 0x78]); printk(amikbd_messages[scancode - 0x78]);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int __init amikbd_init(void) static int __init amikbd_probe(struct platform_device *pdev)
{ {
struct input_dev *dev;
int i, j, err; int i, j, err;
if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) dev = input_allocate_device();
return -ENODEV; if (!dev) {
dev_err(&pdev->dev, "Not enough memory for input device\n");
if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) return -ENOMEM;
return -EBUSY;
amikbd_dev = input_allocate_device();
if (!amikbd_dev) {
printk(KERN_ERR "amikbd: not enough memory for input device\n");
err = -ENOMEM;
goto fail1;
} }
amikbd_dev->name = "Amiga Keyboard"; dev->name = pdev->name;
amikbd_dev->phys = "amikbd/input0"; dev->phys = "amikbd/input0";
amikbd_dev->id.bustype = BUS_AMIGA; dev->id.bustype = BUS_AMIGA;
amikbd_dev->id.vendor = 0x0001; dev->id.vendor = 0x0001;
amikbd_dev->id.product = 0x0001; dev->id.product = 0x0001;
amikbd_dev->id.version = 0x0100; dev->id.version = 0x0100;
dev->dev.parent = &pdev->dev;
amikbd_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
for (i = 0; i < 0x78; i++) for (i = 0; i < 0x78; i++)
set_bit(i, amikbd_dev->keybit); set_bit(i, dev->keybit);
for (i = 0; i < MAX_NR_KEYMAPS; i++) { for (i = 0; i < MAX_NR_KEYMAPS; i++) {
static u_short temp_map[NR_KEYS] __initdata; static u_short temp_map[NR_KEYS] __initdata;
...@@ -229,30 +224,54 @@ static int __init amikbd_init(void) ...@@ -229,30 +224,54 @@ static int __init amikbd_init(void)
memcpy(key_maps[i], temp_map, sizeof(temp_map)); memcpy(key_maps[i], temp_map, sizeof(temp_map));
} }
ciaa.cra &= ~0x41; /* serial data in, turn off TA */ ciaa.cra &= ~0x41; /* serial data in, turn off TA */
if (request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd",
amikbd_interrupt)) { dev);
err = -EBUSY; if (err)
goto fail2; goto fail2;
}
err = input_register_device(amikbd_dev); err = input_register_device(dev);
if (err) if (err)
goto fail3; goto fail3;
platform_set_drvdata(pdev, dev);
return 0; return 0;
fail3: free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); fail3: free_irq(IRQ_AMIGA_CIAA_SP, dev);
fail2: input_free_device(amikbd_dev); fail2: input_free_device(dev);
fail1: release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
return err; return err;
} }
static void __exit amikbd_exit(void) static int __exit amikbd_remove(struct platform_device *pdev)
{
struct input_dev *dev = platform_get_drvdata(pdev);
platform_set_drvdata(pdev, NULL);
free_irq(IRQ_AMIGA_CIAA_SP, dev);
input_unregister_device(dev);
return 0;
}
static struct platform_driver amikbd_driver = {
.remove = __exit_p(amikbd_remove),
.driver = {
.name = "amiga-keyboard",
.owner = THIS_MODULE,
},
};
static int __init amikbd_init(void)
{ {
free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); return platform_driver_probe(&amikbd_driver, amikbd_probe);
input_unregister_device(amikbd_dev);
release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
} }
module_init(amikbd_init); module_init(amikbd_init);
static void __exit amikbd_exit(void)
{
platform_driver_unregister(&amikbd_driver);
}
module_exit(amikbd_exit); module_exit(amikbd_exit);
MODULE_ALIAS("platform:amiga-keyboard");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment