| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/drivers/hil/hilkbd.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 1998 Philip Blundell <philb@gnu.org> | 
|  | 5 | *  Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai> | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 6 | *  Copyright (C) 1999-2006 Helge Deller <deller@gmx.de> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * | 
|  | 8 | *  Very basic HP Human Interface Loop (HIL) driver. | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 9 | *  This driver handles the keyboard on HP300 (m68k) and on some | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | *  HP700 (parisc) series machines. | 
|  | 11 | * | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 12 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * This file is subject to the terms and conditions of the GNU General Public | 
|  | 14 | * License version 2.  See the file COPYING in the main directory of this | 
|  | 15 | * archive for more details. | 
|  | 16 | */ | 
|  | 17 |  | 
|  | 18 | #include <linux/pci_ids.h> | 
|  | 19 | #include <linux/ioport.h> | 
|  | 20 | #include <linux/module.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/errno.h> | 
|  | 22 | #include <linux/input.h> | 
|  | 23 | #include <linux/init.h> | 
| Matthew Wilcox | 6ab0f5c | 2005-10-21 22:58:51 -0400 | [diff] [blame] | 24 | #include <linux/interrupt.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/hil.h> | 
| Al Viro | db71b7f | 2006-12-13 00:35:01 -0800 | [diff] [blame] | 26 | #include <linux/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/spinlock.h> | 
| Al Viro | db71b7f | 2006-12-13 00:35:01 -0800 | [diff] [blame] | 28 | #include <asm/irq.h> | 
|  | 29 | #ifdef CONFIG_HP300 | 
|  | 30 | #include <asm/hwtest.h> | 
|  | 31 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 |  | 
|  | 33 |  | 
|  | 34 | MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller"); | 
|  | 35 | MODULE_DESCRIPTION("HIL keyboard driver (basic functionality)"); | 
|  | 36 | MODULE_LICENSE("GPL v2"); | 
|  | 37 |  | 
|  | 38 |  | 
|  | 39 | #if defined(CONFIG_PARISC) | 
|  | 40 |  | 
|  | 41 | #include <asm/io.h> | 
|  | 42 | #include <asm/hardware.h> | 
|  | 43 | #include <asm/parisc-device.h> | 
|  | 44 | static unsigned long hil_base;	/* HPA for the HIL device */ | 
|  | 45 | static unsigned int hil_irq; | 
|  | 46 | #define HILBASE		hil_base /* HPPA (parisc) port address */ | 
|  | 47 | #define HIL_DATA		0x800 | 
|  | 48 | #define HIL_CMD		0x801 | 
|  | 49 | #define HIL_IRQ		hil_irq | 
|  | 50 | #define hil_readb(p)		gsc_readb(p) | 
|  | 51 | #define hil_writeb(v,p)	gsc_writeb((v),(p)) | 
|  | 52 |  | 
|  | 53 | #elif defined(CONFIG_HP300) | 
|  | 54 |  | 
|  | 55 | #define HILBASE		0xf0428000 /* HP300 (m86k) port address */ | 
|  | 56 | #define HIL_DATA		0x1 | 
|  | 57 | #define HIL_CMD		0x3 | 
|  | 58 | #define HIL_IRQ		2 | 
|  | 59 | #define hil_readb(p)		readb(p) | 
|  | 60 | #define hil_writeb(v,p)	writeb((v),(p)) | 
|  | 61 |  | 
|  | 62 | #else | 
|  | 63 | #error "HIL is not supported on this platform" | 
|  | 64 | #endif | 
|  | 65 |  | 
|  | 66 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 67 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | /* HIL helper functions */ | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 69 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define hil_busy()              (hil_readb(HILBASE + HIL_CMD) & HIL_BUSY) | 
|  | 71 | #define hil_data_available()    (hil_readb(HILBASE + HIL_CMD) & HIL_DATA_RDY) | 
|  | 72 | #define hil_status()            (hil_readb(HILBASE + HIL_CMD)) | 
|  | 73 | #define hil_command(x)          do { hil_writeb((x), HILBASE + HIL_CMD); } while (0) | 
|  | 74 | #define hil_read_data()         (hil_readb(HILBASE + HIL_DATA)) | 
|  | 75 | #define hil_write_data(x)       do { hil_writeb((x), HILBASE + HIL_DATA); } while (0) | 
|  | 76 |  | 
|  | 77 | /* HIL constants */ | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 78 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #define	HIL_BUSY		0x02 | 
|  | 80 | #define	HIL_DATA_RDY		0x01 | 
|  | 81 |  | 
|  | 82 | #define	HIL_SETARD		0xA0		/* set auto-repeat delay */ | 
|  | 83 | #define	HIL_SETARR		0xA2		/* set auto-repeat rate */ | 
|  | 84 | #define	HIL_SETTONE		0xA3		/* set tone generator */ | 
|  | 85 | #define	HIL_CNMT		0xB2		/* clear nmi */ | 
|  | 86 | #define	HIL_INTON		0x5C		/* Turn on interrupts. */ | 
|  | 87 | #define	HIL_INTOFF		0x5D		/* Turn off interrupts. */ | 
|  | 88 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 89 | #define	HIL_READKBDSADR		0xF9 | 
|  | 90 | #define	HIL_WRITEKBDSADR	0xE9 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 92 | static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | { HIL_KEYCODES_SET1 }; | 
|  | 94 |  | 
|  | 95 | /* HIL structure */ | 
|  | 96 | static struct { | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 97 | struct input_dev *dev; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 |  | 
|  | 99 | unsigned int curdev; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 100 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | unsigned char s; | 
|  | 102 | unsigned char c; | 
|  | 103 | int valid; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 104 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | unsigned char data[16]; | 
|  | 106 | unsigned int ptr; | 
|  | 107 | spinlock_t lock; | 
|  | 108 |  | 
|  | 109 | void *dev_id;	/* native bus device */ | 
|  | 110 | } hil_dev; | 
|  | 111 |  | 
|  | 112 |  | 
|  | 113 | static void poll_finished(void) | 
|  | 114 | { | 
|  | 115 | int down; | 
|  | 116 | int key; | 
|  | 117 | unsigned char scode; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 118 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | switch (hil_dev.data[0]) { | 
|  | 120 | case 0x40: | 
|  | 121 | down = (hil_dev.data[1] & 1) == 0; | 
|  | 122 | scode = hil_dev.data[1] >> 1; | 
|  | 123 | key = hphilkeyb_keycode[scode]; | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 124 | input_report_key(hil_dev.dev, key, down); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | break; | 
|  | 126 | } | 
|  | 127 | hil_dev.curdev = 0; | 
|  | 128 | } | 
|  | 129 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 130 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | static inline void handle_status(unsigned char s, unsigned char c) | 
|  | 132 | { | 
|  | 133 | if (c & 0x8) { | 
|  | 134 | /* End of block */ | 
|  | 135 | if (c & 0x10) | 
|  | 136 | poll_finished(); | 
|  | 137 | } else { | 
|  | 138 | if (c & 0x10) { | 
|  | 139 | if (hil_dev.curdev) | 
|  | 140 | poll_finished();  /* just in case */ | 
|  | 141 | hil_dev.curdev = c & 7; | 
|  | 142 | hil_dev.ptr = 0; | 
|  | 143 | } | 
|  | 144 | } | 
|  | 145 | } | 
|  | 146 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 147 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | static inline void handle_data(unsigned char s, unsigned char c) | 
|  | 149 | { | 
|  | 150 | if (hil_dev.curdev) { | 
|  | 151 | hil_dev.data[hil_dev.ptr++] = c; | 
|  | 152 | hil_dev.ptr &= 15; | 
|  | 153 | } | 
|  | 154 | } | 
|  | 155 |  | 
|  | 156 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 157 | /* handle HIL interrupts */ | 
| David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 158 | static irqreturn_t hil_interrupt(int irq, void *handle) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | { | 
|  | 160 | unsigned char s, c; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 161 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | s = hil_status(); | 
|  | 163 | c = hil_read_data(); | 
|  | 164 |  | 
|  | 165 | switch (s >> 4) { | 
|  | 166 | case 0x5: | 
|  | 167 | handle_status(s, c); | 
|  | 168 | break; | 
|  | 169 | case 0x6: | 
|  | 170 | handle_data(s, c); | 
|  | 171 | break; | 
|  | 172 | case 0x4: | 
|  | 173 | hil_dev.s = s; | 
|  | 174 | hil_dev.c = c; | 
|  | 175 | mb(); | 
|  | 176 | hil_dev.valid = 1; | 
|  | 177 | break; | 
|  | 178 | } | 
|  | 179 | return IRQ_HANDLED; | 
|  | 180 | } | 
|  | 181 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 183 | /* send a command to the HIL */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len) | 
|  | 185 | { | 
|  | 186 | unsigned long flags; | 
|  | 187 |  | 
|  | 188 | spin_lock_irqsave(&hil_dev.lock, flags); | 
|  | 189 | while (hil_busy()) | 
|  | 190 | /* wait */; | 
|  | 191 | hil_command(cmd); | 
|  | 192 | while (len--) { | 
|  | 193 | while (hil_busy()) | 
|  | 194 | /* wait */; | 
|  | 195 | hil_write_data(*(data++)); | 
|  | 196 | } | 
|  | 197 | spin_unlock_irqrestore(&hil_dev.lock, flags); | 
|  | 198 | } | 
|  | 199 |  | 
|  | 200 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 201 | /* initialise HIL */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | static int __init | 
|  | 203 | hil_keyb_init(void) | 
|  | 204 | { | 
|  | 205 | unsigned char c; | 
|  | 206 | unsigned int i, kbid; | 
|  | 207 | wait_queue_head_t hil_wait; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 208 | int err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 |  | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 210 | if (hil_dev.dev) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | return -ENODEV; /* already initialized */ | 
|  | 212 | } | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 213 |  | 
|  | 214 | hil_dev.dev = input_allocate_device(); | 
|  | 215 | if (!hil_dev.dev) | 
|  | 216 | return -ENOMEM; | 
|  | 217 | hil_dev.dev->private = &hil_dev; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 218 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | #if defined(CONFIG_HP300) | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 220 | if (!hwreg_present((void *)(HILBASE + HIL_DATA))) { | 
|  | 221 | printk(KERN_ERR "HIL: hardware register was not found\n"); | 
|  | 222 | err = -ENODEV; | 
|  | 223 | goto err1; | 
|  | 224 | } | 
|  | 225 | if (!request_region(HILBASE + HIL_DATA, 2, "hil")) { | 
|  | 226 | printk(KERN_ERR "HIL: IOPORT region already used\n"); | 
|  | 227 | err = -EIO; | 
|  | 228 | goto err1; | 
|  | 229 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | #endif | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 231 |  | 
|  | 232 | err = request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id); | 
|  | 233 | if (err) { | 
|  | 234 | printk(KERN_ERR "HIL: Can't get IRQ\n"); | 
|  | 235 | goto err2; | 
|  | 236 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 |  | 
|  | 238 | /* Turn on interrupts */ | 
|  | 239 | hil_do(HIL_INTON, NULL, 0); | 
|  | 240 |  | 
|  | 241 | /* Look for keyboards */ | 
|  | 242 | hil_dev.valid = 0;	/* clear any pending data */ | 
|  | 243 | hil_do(HIL_READKBDSADR, NULL, 0); | 
|  | 244 |  | 
|  | 245 | init_waitqueue_head(&hil_wait); | 
|  | 246 | wait_event_interruptible_timeout(hil_wait, hil_dev.valid, 3*HZ); | 
|  | 247 | if (!hil_dev.valid) { | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 248 | printk(KERN_WARNING "HIL: timed out, assuming no keyboard present\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } | 
|  | 250 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 251 | c = hil_dev.c; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | hil_dev.valid = 0; | 
|  | 253 | if (c == 0) { | 
|  | 254 | kbid = -1; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 255 | printk(KERN_WARNING "HIL: no keyboard present\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } else { | 
|  | 257 | kbid = ffz(~c); | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 258 | printk(KERN_INFO "HIL: keyboard found at id %d\n", kbid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } | 
|  | 260 |  | 
|  | 261 | /* set it to raw mode */ | 
|  | 262 | c = 0; | 
|  | 263 | hil_do(HIL_WRITEKBDSADR, &c, 1); | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 264 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++) | 
|  | 266 | if (hphilkeyb_keycode[i] != KEY_RESERVED) | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 267 | set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 269 | hil_dev.dev->evbit[0]	= BIT(EV_KEY) | BIT(EV_REP); | 
|  | 270 | hil_dev.dev->ledbit[0]	= BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 
|  | 271 | hil_dev.dev->keycodemax	= HIL_KEYCODES_SET1_TBLSIZE; | 
|  | 272 | hil_dev.dev->keycodesize= sizeof(hphilkeyb_keycode[0]); | 
|  | 273 | hil_dev.dev->keycode	= hphilkeyb_keycode; | 
|  | 274 | hil_dev.dev->name	= "HIL keyboard"; | 
|  | 275 | hil_dev.dev->phys	= "hpkbd/input0"; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 |  | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 277 | hil_dev.dev->id.bustype	= BUS_HIL; | 
|  | 278 | hil_dev.dev->id.vendor	= PCI_VENDOR_ID_HP; | 
|  | 279 | hil_dev.dev->id.product	= 0x0001; | 
|  | 280 | hil_dev.dev->id.version	= 0x0010; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 282 | err = input_register_device(hil_dev.dev); | 
|  | 283 | if (err) { | 
|  | 284 | printk(KERN_ERR "HIL: Can't register device\n"); | 
|  | 285 | goto err3; | 
|  | 286 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n", | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 288 | hil_dev.dev->name, kbid, HILBASE, HIL_IRQ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 |  | 
|  | 290 | return 0; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 291 |  | 
|  | 292 | err3: | 
|  | 293 | hil_do(HIL_INTOFF, NULL, 0); | 
|  | 294 | disable_irq(HIL_IRQ); | 
|  | 295 | free_irq(HIL_IRQ, hil_dev.dev_id); | 
|  | 296 | err2: | 
| Cyrill V. Gorcunov | 2a575f1 | 2007-02-18 01:44:02 -0500 | [diff] [blame] | 297 | #if defined(CONFIG_HP300) | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 298 | release_region(HILBASE + HIL_DATA, 2); | 
|  | 299 | err1: | 
| Cyrill V. Gorcunov | 2a575f1 | 2007-02-18 01:44:02 -0500 | [diff] [blame] | 300 | #endif | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 301 | input_free_device(hil_dev.dev); | 
|  | 302 | hil_dev.dev = NULL; | 
|  | 303 | return err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | } | 
|  | 305 |  | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 306 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | #if defined(CONFIG_PARISC) | 
|  | 308 | static int __init | 
|  | 309 | hil_init_chip(struct parisc_device *dev) | 
|  | 310 | { | 
|  | 311 | if (!dev->irq) { | 
| Matthew Wilcox | 53f01bb | 2005-10-21 22:36:40 -0400 | [diff] [blame] | 312 | printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%08lx\n", dev->hpa.start); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | return -ENODEV; | 
|  | 314 | } | 
|  | 315 |  | 
| Matthew Wilcox | 53f01bb | 2005-10-21 22:36:40 -0400 | [diff] [blame] | 316 | hil_base = dev->hpa.start; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | hil_irq  = dev->irq; | 
|  | 318 | hil_dev.dev_id = dev; | 
| Cyrill V. Gorcunov | b350620 | 2007-02-10 01:29:19 -0500 | [diff] [blame] | 319 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | printk(KERN_INFO "Found HIL bus at 0x%08lx, IRQ %d\n", hil_base, hil_irq); | 
|  | 321 |  | 
|  | 322 | return hil_keyb_init(); | 
|  | 323 | } | 
|  | 324 |  | 
|  | 325 | static struct parisc_device_id hil_tbl[] = { | 
|  | 326 | { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00073 }, | 
|  | 327 | { 0, } | 
|  | 328 | }; | 
|  | 329 |  | 
|  | 330 | MODULE_DEVICE_TABLE(parisc, hil_tbl); | 
|  | 331 |  | 
|  | 332 | static struct parisc_driver hil_driver = { | 
| Matthew Wilcox | bdad1f8 | 2005-10-21 22:36:23 -0400 | [diff] [blame] | 333 | .name =		"hil", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | .id_table =	hil_tbl, | 
|  | 335 | .probe =	hil_init_chip, | 
|  | 336 | }; | 
|  | 337 | #endif /* CONFIG_PARISC */ | 
|  | 338 |  | 
|  | 339 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | static int __init hil_init(void) | 
|  | 341 | { | 
|  | 342 | #if defined(CONFIG_PARISC) | 
|  | 343 | return register_parisc_driver(&hil_driver); | 
|  | 344 | #else | 
|  | 345 | return hil_keyb_init(); | 
|  | 346 | #endif | 
|  | 347 | } | 
|  | 348 |  | 
|  | 349 |  | 
|  | 350 | static void __exit hil_exit(void) | 
|  | 351 | { | 
|  | 352 | if (HIL_IRQ) { | 
|  | 353 | disable_irq(HIL_IRQ); | 
|  | 354 | free_irq(HIL_IRQ, hil_dev.dev_id); | 
|  | 355 | } | 
|  | 356 |  | 
|  | 357 | /* Turn off interrupts */ | 
|  | 358 | hil_do(HIL_INTOFF, NULL, 0); | 
|  | 359 |  | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 360 | input_unregister_device(hil_dev.dev); | 
|  | 361 |  | 
| Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 362 | hil_dev.dev = NULL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 |  | 
|  | 364 | #if defined(CONFIG_PARISC) | 
|  | 365 | unregister_parisc_driver(&hil_driver); | 
|  | 366 | #else | 
|  | 367 | release_region(HILBASE+HIL_DATA, 2); | 
|  | 368 | #endif | 
|  | 369 | } | 
|  | 370 |  | 
|  | 371 | module_init(hil_init); | 
|  | 372 | module_exit(hil_exit); |