xref: /linux/drivers/input/keyboard/locomokbd.c (revision 78f50c246f4286d40a1f42fecc779d47e40503a2)
11da177e4SLinus Torvalds /*
2e6cdd156SHelge Deller  * LoCoMo keyboard driver for Linux-based ARM PDAs:
3e6cdd156SHelge Deller  * 	- SHARP Zaurus Collie (SL-5500)
4e6cdd156SHelge Deller  * 	- SHARP Zaurus Poodle (SL-5600)
51da177e4SLinus Torvalds  *
6e6cdd156SHelge Deller  * Copyright (c) 2005 John Lenz
71da177e4SLinus Torvalds  * Based on from xtkbd.c
8e6cdd156SHelge Deller  *
9e6cdd156SHelge Deller  *
101da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or modify
111da177e4SLinus Torvalds  * it under the terms of the GNU General Public License as published by
121da177e4SLinus Torvalds  * the Free Software Foundation; either version 2 of the License, or
131da177e4SLinus Torvalds  * (at your option) any later version.
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  * This program is distributed in the hope that it will be useful,
161da177e4SLinus Torvalds  * but WITHOUT ANY WARRANTY; without even the implied warranty of
171da177e4SLinus Torvalds  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
181da177e4SLinus Torvalds  * GNU General Public License for more details.
191da177e4SLinus Torvalds  *
201da177e4SLinus Torvalds  * You should have received a copy of the GNU General Public License
211da177e4SLinus Torvalds  * along with this program; if not, write to the Free Software
221da177e4SLinus Torvalds  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
231da177e4SLinus Torvalds  *
241da177e4SLinus Torvalds  */
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds #include <linux/slab.h>
271da177e4SLinus Torvalds #include <linux/module.h>
281da177e4SLinus Torvalds #include <linux/init.h>
291da177e4SLinus Torvalds #include <linux/input.h>
301da177e4SLinus Torvalds #include <linux/delay.h>
311da177e4SLinus Torvalds #include <linux/device.h>
321da177e4SLinus Torvalds #include <linux/interrupt.h>
331da177e4SLinus Torvalds #include <linux/ioport.h>
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds #include <asm/hardware/locomo.h>
361da177e4SLinus Torvalds #include <asm/irq.h>
371da177e4SLinus Torvalds 
381da177e4SLinus Torvalds MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
391da177e4SLinus Torvalds MODULE_DESCRIPTION("LoCoMo keyboard driver");
401da177e4SLinus Torvalds MODULE_LICENSE("GPL");
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds #define LOCOMOKBD_NUMKEYS	128
431da177e4SLinus Torvalds 
441da177e4SLinus Torvalds #define KEY_ACTIVITY		KEY_F16
451da177e4SLinus Torvalds #define KEY_CONTACT		KEY_F18
461da177e4SLinus Torvalds #define KEY_CENTER		KEY_F15
471da177e4SLinus Torvalds 
48e6cdd156SHelge Deller static const unsigned char
49*78f50c24SBill Pemberton locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
501da177e4SLinus Torvalds 	0, KEY_ESC, KEY_ACTIVITY, 0, 0, 0, 0, 0, 0, 0,				/* 0 - 9 */
511da177e4SLinus Torvalds 	0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_HOME, KEY_CONTACT,			/* 10 - 19 */
521da177e4SLinus Torvalds 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,						/* 20 - 29 */
531da177e4SLinus Torvalds 	0, 0, 0, KEY_CENTER, 0, KEY_MAIL, 0, 0, 0, 0,				/* 30 - 39 */
541da177e4SLinus Torvalds 	0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_RIGHT,					/* 40 - 49 */
551da177e4SLinus Torvalds 	KEY_UP, KEY_LEFT, 0, 0, KEY_P, 0, KEY_O, KEY_I, KEY_Y, KEY_T,		/* 50 - 59 */
561da177e4SLinus Torvalds 	KEY_E, KEY_W, 0, 0, 0, 0, KEY_DOWN, KEY_ENTER, 0, 0,			/* 60 - 69 */
571da177e4SLinus Torvalds 	KEY_BACKSPACE, 0, KEY_L, KEY_U, KEY_H, KEY_R, KEY_D, KEY_Q, 0, 0,	/* 70 - 79 */
581da177e4SLinus Torvalds 	0, 0, 0, 0, 0, 0, KEY_ENTER, KEY_RIGHTSHIFT, KEY_K, KEY_J,		/* 80 - 89 */
591da177e4SLinus Torvalds 	KEY_G, KEY_F, KEY_X, KEY_S, 0, 0, 0, 0, 0, 0,				/* 90 - 99 */
601da177e4SLinus Torvalds 	0, 0, KEY_DOT, 0, KEY_COMMA, KEY_N, KEY_B, KEY_C, KEY_Z, KEY_A,		/* 100 - 109 */
611da177e4SLinus Torvalds 	KEY_LEFTSHIFT, KEY_TAB, KEY_LEFTCTRL, 0, 0, 0, 0, 0, 0, 0,		/* 110 - 119 */
621da177e4SLinus Torvalds 	KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0		/* 120 - 128 */
631da177e4SLinus Torvalds };
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds #define KB_ROWS			16
661da177e4SLinus Torvalds #define KB_COLS			8
671da177e4SLinus Torvalds #define KB_ROWMASK(r)		(1 << (r))
681da177e4SLinus Torvalds #define SCANCODE(c,r)		( ((c)<<4) + (r) + 1 )
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds #define KB_DELAY		8
711da177e4SLinus Torvalds #define SCAN_INTERVAL		(HZ/10)
721da177e4SLinus Torvalds 
731da177e4SLinus Torvalds struct locomokbd {
741da177e4SLinus Torvalds 	unsigned char keycode[LOCOMOKBD_NUMKEYS];
75438c9da5SDmitry Torokhov 	struct input_dev *input;
761da177e4SLinus Torvalds 	char phys[32];
771da177e4SLinus Torvalds 
781da177e4SLinus Torvalds 	unsigned long base;
791da177e4SLinus Torvalds 	spinlock_t lock;
801da177e4SLinus Torvalds 
811da177e4SLinus Torvalds 	struct timer_list timer;
82e6cdd156SHelge Deller 	unsigned long suspend_jiffies;
83e6cdd156SHelge Deller 	unsigned int count_cancel;
841da177e4SLinus Torvalds };
851da177e4SLinus Torvalds 
861da177e4SLinus Torvalds /* helper functions for reading the keyboard matrix */
871da177e4SLinus Torvalds static inline void locomokbd_charge_all(unsigned long membase)
881da177e4SLinus Torvalds {
891da177e4SLinus Torvalds 	locomo_writel(0x00FF, membase + LOCOMO_KSC);
901da177e4SLinus Torvalds }
911da177e4SLinus Torvalds 
921da177e4SLinus Torvalds static inline void locomokbd_activate_all(unsigned long membase)
931da177e4SLinus Torvalds {
941da177e4SLinus Torvalds 	unsigned long r;
951da177e4SLinus Torvalds 
961da177e4SLinus Torvalds 	locomo_writel(0, membase + LOCOMO_KSC);
971da177e4SLinus Torvalds 	r = locomo_readl(membase + LOCOMO_KIC);
981da177e4SLinus Torvalds 	r &= 0xFEFF;
991da177e4SLinus Torvalds 	locomo_writel(r, membase + LOCOMO_KIC);
1001da177e4SLinus Torvalds }
1011da177e4SLinus Torvalds 
1021da177e4SLinus Torvalds static inline void locomokbd_activate_col(unsigned long membase, int col)
1031da177e4SLinus Torvalds {
1041da177e4SLinus Torvalds 	unsigned short nset;
1051da177e4SLinus Torvalds 	unsigned short nbset;
1061da177e4SLinus Torvalds 
1071da177e4SLinus Torvalds 	nset = 0xFF & ~(1 << col);
1081da177e4SLinus Torvalds 	nbset = (nset << 8) + nset;
1091da177e4SLinus Torvalds 	locomo_writel(nbset, membase + LOCOMO_KSC);
1101da177e4SLinus Torvalds }
1111da177e4SLinus Torvalds 
1121da177e4SLinus Torvalds static inline void locomokbd_reset_col(unsigned long membase, int col)
1131da177e4SLinus Torvalds {
1141da177e4SLinus Torvalds 	unsigned short nbset;
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds 	nbset = ((0xFF & ~(1 << col)) << 8) + 0xFF;
1171da177e4SLinus Torvalds 	locomo_writel(nbset, membase + LOCOMO_KSC);
1181da177e4SLinus Torvalds }
1191da177e4SLinus Torvalds 
1201da177e4SLinus Torvalds /*
1211da177e4SLinus Torvalds  * The LoCoMo keyboard only generates interrupts when a key is pressed.
1221da177e4SLinus Torvalds  * So when a key is pressed, we enable a timer.  This timer scans the
1231da177e4SLinus Torvalds  * keyboard, and this is how we detect when the key is released.
1241da177e4SLinus Torvalds  */
1251da177e4SLinus Torvalds 
1261da177e4SLinus Torvalds /* Scan the hardware keyboard and push any changes up through the input layer */
1277d12e780SDavid Howells static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
1281da177e4SLinus Torvalds {
129e6cdd156SHelge Deller 	unsigned int row, col, rowd;
1301da177e4SLinus Torvalds 	unsigned long flags;
1311da177e4SLinus Torvalds 	unsigned int num_pressed;
1321da177e4SLinus Torvalds 	unsigned long membase = locomokbd->base;
1331da177e4SLinus Torvalds 
1341da177e4SLinus Torvalds 	spin_lock_irqsave(&locomokbd->lock, flags);
1351da177e4SLinus Torvalds 
1361da177e4SLinus Torvalds 	locomokbd_charge_all(membase);
1371da177e4SLinus Torvalds 
1381da177e4SLinus Torvalds 	num_pressed = 0;
1391da177e4SLinus Torvalds 	for (col = 0; col < KB_COLS; col++) {
1401da177e4SLinus Torvalds 
1411da177e4SLinus Torvalds 		locomokbd_activate_col(membase, col);
1421da177e4SLinus Torvalds 		udelay(KB_DELAY);
1431da177e4SLinus Torvalds 
1441da177e4SLinus Torvalds 		rowd = ~locomo_readl(membase + LOCOMO_KIB);
1451da177e4SLinus Torvalds 		for (row = 0; row < KB_ROWS; row++) {
146e6cdd156SHelge Deller 			unsigned int scancode, pressed, key;
147e6cdd156SHelge Deller 
1481da177e4SLinus Torvalds 			scancode = SCANCODE(col, row);
149e6cdd156SHelge Deller 			pressed = rowd & KB_ROWMASK(row);
150e6cdd156SHelge Deller 			key = locomokbd->keycode[scancode];
151e6cdd156SHelge Deller 
152e6cdd156SHelge Deller 			input_report_key(locomokbd->input, key, pressed);
153e6cdd156SHelge Deller 			if (likely(!pressed))
154e6cdd156SHelge Deller 				continue;
155e6cdd156SHelge Deller 
156e6cdd156SHelge Deller 			num_pressed++;
157e6cdd156SHelge Deller 
158e6cdd156SHelge Deller 			/* The "Cancel/ESC" key is labeled "On/Off" on
159e6cdd156SHelge Deller 			 * Collie and Poodle and should suspend the device
160e6cdd156SHelge Deller 			 * if it was pressed for more than a second. */
161e6cdd156SHelge Deller 			if (unlikely(key == KEY_ESC)) {
162e6cdd156SHelge Deller 				if (!time_after(jiffies,
163e6cdd156SHelge Deller 					locomokbd->suspend_jiffies + HZ))
164e6cdd156SHelge Deller 					continue;
165e6cdd156SHelge Deller 				if (locomokbd->count_cancel++
166e6cdd156SHelge Deller 					!= (HZ/SCAN_INTERVAL + 1))
167e6cdd156SHelge Deller 					continue;
168e6cdd156SHelge Deller 				input_event(locomokbd->input, EV_PWR,
169e6cdd156SHelge Deller 					KEY_SUSPEND, 1);
170e6cdd156SHelge Deller 				locomokbd->suspend_jiffies = jiffies;
171e6cdd156SHelge Deller 			} else
172e6cdd156SHelge Deller 				locomokbd->count_cancel = 0;
1731da177e4SLinus Torvalds 		}
1741da177e4SLinus Torvalds 		locomokbd_reset_col(membase, col);
1751da177e4SLinus Torvalds 	}
1761da177e4SLinus Torvalds 	locomokbd_activate_all(membase);
1771da177e4SLinus Torvalds 
178438c9da5SDmitry Torokhov 	input_sync(locomokbd->input);
1791da177e4SLinus Torvalds 
1801da177e4SLinus Torvalds 	/* if any keys are pressed, enable the timer */
1811da177e4SLinus Torvalds 	if (num_pressed)
1821da177e4SLinus Torvalds 		mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL);
183e6cdd156SHelge Deller 	else
184e6cdd156SHelge Deller 		locomokbd->count_cancel = 0;
1851da177e4SLinus Torvalds 
1861da177e4SLinus Torvalds 	spin_unlock_irqrestore(&locomokbd->lock, flags);
1871da177e4SLinus Torvalds }
1881da177e4SLinus Torvalds 
1891da177e4SLinus Torvalds /*
1901da177e4SLinus Torvalds  * LoCoMo keyboard interrupt handler.
1911da177e4SLinus Torvalds  */
1927d12e780SDavid Howells static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
1931da177e4SLinus Torvalds {
1941da177e4SLinus Torvalds 	struct locomokbd *locomokbd = dev_id;
195da8065acSEric Miao 	u16 r;
196da8065acSEric Miao 
197da8065acSEric Miao 	r = locomo_readl(locomokbd->base + LOCOMO_KIC);
198da8065acSEric Miao 	if ((r & 0x0001) == 0)
199da8065acSEric Miao 		return IRQ_HANDLED;
200da8065acSEric Miao 
201da8065acSEric Miao 	locomo_writel(r & ~0x0100, locomokbd->base + LOCOMO_KIC); /* Ack */
202da8065acSEric Miao 
2031da177e4SLinus Torvalds 	/** wait chattering delay **/
2041da177e4SLinus Torvalds 	udelay(100);
2051da177e4SLinus Torvalds 
2067d12e780SDavid Howells 	locomokbd_scankeyboard(locomokbd);
2071da177e4SLinus Torvalds 	return IRQ_HANDLED;
2081da177e4SLinus Torvalds }
2091da177e4SLinus Torvalds 
2101da177e4SLinus Torvalds /*
2111da177e4SLinus Torvalds  * LoCoMo timer checking for released keys
2121da177e4SLinus Torvalds  */
2131da177e4SLinus Torvalds static void locomokbd_timer_callback(unsigned long data)
2141da177e4SLinus Torvalds {
2151da177e4SLinus Torvalds 	struct locomokbd *locomokbd = (struct locomokbd *) data;
216e6cdd156SHelge Deller 
21736bd262bSRussell King 	locomokbd_scankeyboard(locomokbd);
2181da177e4SLinus Torvalds }
2191da177e4SLinus Torvalds 
220da8065acSEric Miao static int locomokbd_open(struct input_dev *dev)
221da8065acSEric Miao {
222da8065acSEric Miao 	struct locomokbd *locomokbd = input_get_drvdata(dev);
223da8065acSEric Miao 	u16 r;
224da8065acSEric Miao 
225da8065acSEric Miao 	r = locomo_readl(locomokbd->base + LOCOMO_KIC) | 0x0010;
226da8065acSEric Miao 	locomo_writel(r, locomokbd->base + LOCOMO_KIC);
227da8065acSEric Miao 	return 0;
228da8065acSEric Miao }
229da8065acSEric Miao 
230da8065acSEric Miao static void locomokbd_close(struct input_dev *dev)
231da8065acSEric Miao {
232da8065acSEric Miao 	struct locomokbd *locomokbd = input_get_drvdata(dev);
233da8065acSEric Miao 	u16 r;
234da8065acSEric Miao 
235da8065acSEric Miao 	r = locomo_readl(locomokbd->base + LOCOMO_KIC) & ~0x0010;
236da8065acSEric Miao 	locomo_writel(r, locomokbd->base + LOCOMO_KIC);
237da8065acSEric Miao }
238da8065acSEric Miao 
239e6cdd156SHelge Deller static int __devinit locomokbd_probe(struct locomo_dev *dev)
2401da177e4SLinus Torvalds {
2411da177e4SLinus Torvalds 	struct locomokbd *locomokbd;
242438c9da5SDmitry Torokhov 	struct input_dev *input_dev;
2432b03b60eSDmitry Torokhov 	int i, err;
2441da177e4SLinus Torvalds 
245438c9da5SDmitry Torokhov 	locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL);
246438c9da5SDmitry Torokhov 	input_dev = input_allocate_device();
247438c9da5SDmitry Torokhov 	if (!locomokbd || !input_dev) {
2482b03b60eSDmitry Torokhov 		err = -ENOMEM;
2492b03b60eSDmitry Torokhov 		goto err_free_mem;
250438c9da5SDmitry Torokhov 	}
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds 	/* try and claim memory region */
2531da177e4SLinus Torvalds 	if (!request_mem_region((unsigned long) dev->mapbase,
2541da177e4SLinus Torvalds 				dev->length,
2551da177e4SLinus Torvalds 				LOCOMO_DRIVER_NAME(dev))) {
2562b03b60eSDmitry Torokhov 		err = -EBUSY;
2571da177e4SLinus Torvalds 		printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n");
2582b03b60eSDmitry Torokhov 		goto err_free_mem;
2591da177e4SLinus Torvalds 	}
2601da177e4SLinus Torvalds 
2611da177e4SLinus Torvalds 	locomo_set_drvdata(dev, locomokbd);
2621da177e4SLinus Torvalds 
2631da177e4SLinus Torvalds 	locomokbd->base = (unsigned long) dev->mapbase;
2641da177e4SLinus Torvalds 
2651da177e4SLinus Torvalds 	spin_lock_init(&locomokbd->lock);
2661da177e4SLinus Torvalds 
2671da177e4SLinus Torvalds 	init_timer(&locomokbd->timer);
2681da177e4SLinus Torvalds 	locomokbd->timer.function = locomokbd_timer_callback;
2691da177e4SLinus Torvalds 	locomokbd->timer.data = (unsigned long) locomokbd;
2701da177e4SLinus Torvalds 
271e6cdd156SHelge Deller 	locomokbd->suspend_jiffies = jiffies;
272e6cdd156SHelge Deller 
273438c9da5SDmitry Torokhov 	locomokbd->input = input_dev;
274438c9da5SDmitry Torokhov 	strcpy(locomokbd->phys, "locomokbd/input0");
2751da177e4SLinus Torvalds 
276438c9da5SDmitry Torokhov 	input_dev->name = "LoCoMo keyboard";
277438c9da5SDmitry Torokhov 	input_dev->phys = locomokbd->phys;
278d7a767ddSPavel Machek 	input_dev->id.bustype = BUS_HOST;
279438c9da5SDmitry Torokhov 	input_dev->id.vendor = 0x0001;
280438c9da5SDmitry Torokhov 	input_dev->id.product = 0x0001;
281438c9da5SDmitry Torokhov 	input_dev->id.version = 0x0100;
282da8065acSEric Miao 	input_dev->open = locomokbd_open;
283da8065acSEric Miao 	input_dev->close = locomokbd_close;
284469ba4dfSDmitry Torokhov 	input_dev->dev.parent = &dev->dev;
285438c9da5SDmitry Torokhov 
286e6cdd156SHelge Deller 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
287e6cdd156SHelge Deller 				BIT_MASK(EV_PWR);
288438c9da5SDmitry Torokhov 	input_dev->keycode = locomokbd->keycode;
289e6cdd156SHelge Deller 	input_dev->keycodesize = sizeof(locomokbd_keycode[0]);
290438c9da5SDmitry Torokhov 	input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);
2911da177e4SLinus Torvalds 
292da8065acSEric Miao 	input_set_drvdata(input_dev, locomokbd);
293da8065acSEric Miao 
2941da177e4SLinus Torvalds 	memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
2951da177e4SLinus Torvalds 	for (i = 0; i < LOCOMOKBD_NUMKEYS; i++)
296438c9da5SDmitry Torokhov 		set_bit(locomokbd->keycode[i], input_dev->keybit);
297438c9da5SDmitry Torokhov 	clear_bit(0, input_dev->keybit);
2981da177e4SLinus Torvalds 
2991da177e4SLinus Torvalds 	/* attempt to get the interrupt */
3002b03b60eSDmitry Torokhov 	err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd);
3012b03b60eSDmitry Torokhov 	if (err) {
3021da177e4SLinus Torvalds 		printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n");
3032b03b60eSDmitry Torokhov 		goto err_release_region;
3041da177e4SLinus Torvalds 	}
3051da177e4SLinus Torvalds 
3062b03b60eSDmitry Torokhov 	err = input_register_device(locomokbd->input);
3072b03b60eSDmitry Torokhov 	if (err)
3082b03b60eSDmitry Torokhov 		goto err_free_irq;
3091da177e4SLinus Torvalds 
3101da177e4SLinus Torvalds 	return 0;
3111da177e4SLinus Torvalds 
3122b03b60eSDmitry Torokhov  err_free_irq:
3132b03b60eSDmitry Torokhov 	free_irq(dev->irq[0], locomokbd);
3142b03b60eSDmitry Torokhov  err_release_region:
3151da177e4SLinus Torvalds 	release_mem_region((unsigned long) dev->mapbase, dev->length);
3161da177e4SLinus Torvalds 	locomo_set_drvdata(dev, NULL);
3172b03b60eSDmitry Torokhov  err_free_mem:
318438c9da5SDmitry Torokhov 	input_free_device(input_dev);
3191da177e4SLinus Torvalds 	kfree(locomokbd);
3201da177e4SLinus Torvalds 
3212b03b60eSDmitry Torokhov 	return err;
3221da177e4SLinus Torvalds }
3231da177e4SLinus Torvalds 
324e6cdd156SHelge Deller static int __devexit locomokbd_remove(struct locomo_dev *dev)
3251da177e4SLinus Torvalds {
3261da177e4SLinus Torvalds 	struct locomokbd *locomokbd = locomo_get_drvdata(dev);
3271da177e4SLinus Torvalds 
3281da177e4SLinus Torvalds 	free_irq(dev->irq[0], locomokbd);
3291da177e4SLinus Torvalds 
3301da177e4SLinus Torvalds 	del_timer_sync(&locomokbd->timer);
3311da177e4SLinus Torvalds 
332438c9da5SDmitry Torokhov 	input_unregister_device(locomokbd->input);
3331da177e4SLinus Torvalds 	locomo_set_drvdata(dev, NULL);
3341da177e4SLinus Torvalds 
3351da177e4SLinus Torvalds 	release_mem_region((unsigned long) dev->mapbase, dev->length);
3361da177e4SLinus Torvalds 
3371da177e4SLinus Torvalds 	kfree(locomokbd);
3381da177e4SLinus Torvalds 
3391da177e4SLinus Torvalds 	return 0;
3401da177e4SLinus Torvalds }
3411da177e4SLinus Torvalds 
3421da177e4SLinus Torvalds static struct locomo_driver keyboard_driver = {
3431da177e4SLinus Torvalds 	.drv = {
3441da177e4SLinus Torvalds 		.name = "locomokbd"
3451da177e4SLinus Torvalds 	},
3461da177e4SLinus Torvalds 	.devid	= LOCOMO_DEVID_KEYBOARD,
3471da177e4SLinus Torvalds 	.probe	= locomokbd_probe,
3481cb0aa88SBill Pemberton 	.remove	= locomokbd_remove,
3491da177e4SLinus Torvalds };
3501da177e4SLinus Torvalds 
3511da177e4SLinus Torvalds static int __init locomokbd_init(void)
3521da177e4SLinus Torvalds {
3531da177e4SLinus Torvalds 	return locomo_driver_register(&keyboard_driver);
3541da177e4SLinus Torvalds }
3551da177e4SLinus Torvalds 
3561da177e4SLinus Torvalds static void __exit locomokbd_exit(void)
3571da177e4SLinus Torvalds {
3581da177e4SLinus Torvalds 	locomo_driver_unregister(&keyboard_driver);
3591da177e4SLinus Torvalds }
3601da177e4SLinus Torvalds 
3611da177e4SLinus Torvalds module_init(locomokbd_init);
3621da177e4SLinus Torvalds module_exit(locomokbd_exit);
363