[parisc-linux-cvs] hilkbd and hil_kbd changes
Helge Deller
deller@gmx.de
Sun, 7 Jul 2002 15:19:41 +0200
--Boundary-00=_t/DK9lajeN41SGC
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
On Sunday 07 July 2002 15:20, Helge Deller wrote:
> CVSROOT: /var/cvs
> Module name: linux
> Changes by: deller 02/07/07 07:20:47
>
> Modified files:
> drivers/hil : Config.in hil_kbd.c hilkbd.c
>
> Log message:
> - rewrite of hilkbd (old HIL keyboard driver) to use the input layer too,
> - hilkbd is now also available as module (wasn't possible before!)
> - converted the hil_kbd_set3 table in hil_kbd.c to use symbolic keynames,
> - Try to enable "Keyswitch Autorepeat 1" which doesn't seem to work for me
> yet :-(
>
> The License of hilkbd isn't clear yet. I need to get an OK from
> Philip Blundell <philb@gnu.org> first.
--Boundary-00=_t/DK9lajeN41SGC
Content-Type: text/plain;
charset="iso-8859-1";
name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="diff"
Index: Config.in
===================================================================
RCS file: /var/cvs/linux/drivers/hil/Config.in,v
retrieving revision 1.2
diff -u -p -r1.2 Config.in
--- Config.in 2002/07/06 17:37:07 1.2
+++ Config.in 2002/07/07 13:16:26
@@ -8,7 +8,7 @@ comment 'HIL support'
tristate 'HIL core support' CONFIG_HIL
if [ "$CONFIG_HIL" != "n" ]; then
- bool ' HIL Keyboard (basic) support' CONFIG_HIL_KBD_BASIC
+ dep_tristate ' HIL Keyboard (basic) support' CONFIG_HIL_KBD_BASIC $CONFIG_INPUT_KEYBDEV $CONFIG_HIL
if [ "$CONFIG_INPUT" = "n" -o "$CONFIG_INPUT_EVDEV" = "n" ]; then
comment 'Input support needed for full HIL support'
Index: hil_kbd.c
===================================================================
RCS file: /var/cvs/linux/drivers/hil/hil_kbd.c,v
retrieving revision 1.5
diff -u -p -r1.5 hil_kbd.c
--- hil_kbd.c 2002/07/04 22:41:50 1.5
+++ hil_kbd.c 2002/07/07 13:16:28
@@ -56,7 +56,7 @@ MODULE_LICENSE("Dual BSD/GPL");
#define HIL_KBD_SET1_UPBIT 0x01
#define HIL_KBD_SET1_SHIFT 1
-uint8_t hil_kbd_set1[128] = {
+static uint8_t hil_kbd_set1[128] = {
KEY_5, KEY_RESERVED, KEY_RIGHTALT, KEY_LEFTALT,
KEY_RIGHTSHIFT, KEY_LEFTSHIFT, KEY_LEFTCTRL, KEY_SYSRQ,
KEY_KP4, KEY_KP8, KEY_KP5, KEY_KP9,
@@ -99,23 +99,39 @@ uint8_t hil_kbd_set1[128] = {
#define HIL_KBD_SET3_UPBIT 0x80
#define HIL_KBD_SET3_SHIFT 0
-uint8_t hil_kbd_set3[128] = {
- 0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,
- 8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,
- 16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,
- 24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,
- 32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,
- 40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,
- 48 ,49 ,50 ,51 ,52 ,53 ,54 ,55 ,
- 56 ,57 ,58 ,59 ,60 ,61 ,62 ,63 ,
- 64 ,65 ,66 ,67 ,68 ,69 ,70 ,71 ,
- 72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,
- 80 ,81 ,82 ,83 ,99 ,0 ,0 ,0 ,
- 0 ,0 ,0 ,0 ,0 ,0 ,220,220,
- 103,105,108,106,102,104,107,109,
- 110,111,86 ,0 ,0 ,0 ,0 ,0 ,
- 59 ,60 ,61 ,62 ,63 ,64 ,65 ,66 ,
- 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0
+static uint8_t hil_kbd_set3[128] = {
+ KEY_RESERVED, KEY_ESC, KEY_1, KEY_2,
+ KEY_3, KEY_4, KEY_5, KEY_6,
+ KEY_7, KEY_8, KEY_9, KEY_0,
+ KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_TAB,
+ KEY_Q, KEY_W, KEY_E, KEY_R,
+ KEY_T, KEY_Y, KEY_U, KEY_I,
+ KEY_O, KEY_P, KEY_LEFTBRACE, KEY_RIGHTBRACE,
+ KEY_ENTER, KEY_LEFTCTRL, KEY_A, KEY_S,
+ KEY_D, KEY_F, KEY_G, KEY_H,
+ KEY_J, KEY_K, KEY_L, KEY_SEMICOLON,
+ KEY_APOSTROPHE,KEY_GRAVE, KEY_LEFTSHIFT, KEY_BACKSLASH,
+ KEY_Z, KEY_X, KEY_C, KEY_V,
+ KEY_B, KEY_N, KEY_M, KEY_COMMA,
+ KEY_DOT, KEY_SLASH, KEY_RIGHTSHIFT, KEY_KPASTERISK,
+ KEY_LEFTALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
+ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
+ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
+ KEY_F10, KEY_NUMLOCK, KEY_SCROLLLOCK, KEY_KP7,
+ KEY_KP8, KEY_KP9, KEY_KPMINUS, KEY_KP4,
+ KEY_KP5, KEY_KP6, KEY_KPPLUS, KEY_KP1,
+ KEY_KP2, KEY_KP3, KEY_KP0, KEY_KPDOT,
+ KEY_SYSRQ, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
+ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
+ KEY_RESERVED, KEY_RESERVED, KEY_UNKNOWN, KEY_UNKNOWN,
+ KEY_UP, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
+ KEY_HOME, KEY_PAGEUP, KEY_END, KEY_PAGEDOWN,
+ KEY_INSERT, KEY_DELETE, KEY_102ND, KEY_RESERVED,
+ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
+ KEY_F1, KEY_F2, KEY_F3, KEY_F4,
+ KEY_F5, KEY_F6, KEY_F7, KEY_F8,
+ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
+ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED
};
static char *hil_language[] = { HIL_LOCALE_MAP };
@@ -397,6 +413,13 @@ static void hil_kbd_connect(struct serio
* make the keypad work at expected. */
input_report_key(&kbd->dev, KEY_NUMLOCK, 1);
/* input_report_key(&kbd->dev, KEY_NUMLOCK, 0); */
+
+ serio->write(serio, 0);
+ serio->write(serio, 0);
+ serio->write(serio, HIL_PKT_CMD >> 8);
+ serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */
+ down(&(kbd->sem));
+ up(&(kbd->sem));
return;
bail1:
Index: hilkbd.c
===================================================================
RCS file: /var/cvs/linux/drivers/hil/hilkbd.c,v
retrieving revision 1.1
diff -u -p -r1.1 hilkbd.c
--- hilkbd.c 2002/06/25 19:53:07 1.1
+++ hilkbd.c 2002/07/07 13:16:28
@@ -1,59 +1,72 @@
/*
- * linux/drivers/char/hilkbd.c
+ * linux/drivers/hil/hilkbd.c
*
* Copyright (C) 1998 Philip Blundell <philb@gnu.org>
* Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai>
- * Copyright (C) 1999-2001 Helge Deller <deller@gmx.de>
+ * Copyright (C) 1999-2002 Helge Deller <deller@gmx.de>
*
- * HP Human Interface Loop driver. This handles the keyboard and mouse
- * on the HP300 series and keyboards on some of the HP700 series machines.
+ * Very basic HP Human Interface Loop (HIL) driver.
+ * This driver handles the keyboard on HP300 (m68k) and on some
+ * HP700 (parisc) series machines.
+ *
*/
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/keyboard.h>
-#include <linux/kbd_ll.h>
+#include <linux/pci_ids.h>
#include <linux/ioport.h>
-#include <linux/config.h>
#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/input.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/hil.h>
-#include <asm/io.h>
-#include <asm/ptrace.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-#include <asm/gsc.h>
-#include <asm/hardware.h>
-#if defined(CONFIG_PARISC)
+MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller");
+MODULE_DESCRIPTION("HIL driver (basic functionality)");
+MODULE_LICENSE("Hopefully GPL, but I need feedback from Philip first...");
+EXPORT_NO_SYMBOLS;
+
-#include <asm/hil.h>
-#include <asm/keyboard.h>
+#if defined(CONFIG_PARISC)
-unsigned long hil_base; /* HPA for the HIL device */
-unsigned int hil_irq;
+ #include <asm/gsc.h>
+ #include <asm/hardware.h>
+ static unsigned long hil_base; /* HPA for the HIL device */
+ static unsigned int hil_irq;
+ #define HILBASE hil_base /* HPPA (parisc) port address */
+ #define HIL_DATA 0x800
+ #define HIL_CMD 0x801
+ #define HIL_IRQ hil_irq
+ #define hil_readb(p) gsc_readb(p)
+ #define hil_writeb(v,p) gsc_writeb((v),(p))
#elif defined(CONFIG_HP300)
-#define HILBASE 0xf0428000 /* HP300 (m86k) specific */
-#define HIL_DATA 0x1
-#define HIL_CMD 0x3
-#define HIL_IRQ 2
-#define hil_busy() (readb(HILBASE + HIL_CMD) & HIL_BUSY)
-#define hil_data_available() (readb(HILBASE + HIL_CMD) & HIL_DATA_RDY)
-#define hil_status() (readb(HILBASE + HIL_CMD))
-#define hil_command(x) do { writeb((x), HILBASE + HIL_CMD); } while (0)
-#define hil_read_data() (readb(HILBASE + HIL_DATA))
-#define hil_write_data(x) do { writeb((x), HILBASE + HIL_DATA); } while (0)
+ #define HILBASE 0xf0428000 /* HP300 (m86k) port address */
+ #define HIL_DATA 0x1
+ #define HIL_CMD 0x3
+ #define HIL_IRQ 2
+ #define hil_readb(p) readb(p)
+ #define hil_writeb(v,p) writeb((v),(p))
+#else
+#error "HIL is not supported on this platform"
#endif
+
+/* HIL helper functions */
+
+#define hil_busy() (hil_readb(HILBASE + HIL_CMD) & HIL_BUSY)
+#define hil_data_available() (hil_readb(HILBASE + HIL_CMD) & HIL_DATA_RDY)
+#define hil_status() (hil_readb(HILBASE + HIL_CMD))
+#define hil_command(x) do { hil_writeb((x), HILBASE + HIL_CMD); } while (0)
+#define hil_read_data() (hil_readb(HILBASE + HIL_DATA))
+#define hil_write_data(x) do { hil_writeb((x), HILBASE + HIL_DATA); } while (0)
+
+/* HIL constants */
+
#define HIL_BUSY 0x02
#define HIL_DATA_RDY 0x01
@@ -77,201 +90,75 @@ unsigned int hil_irq;
#define HIL_READLPCTRL 0xFB
#define HIL_WRITELPCTRL 0xEB
-#define plain_map __initdata hp_plain_map
-#define shift_map __initdata hp_shift_map
-#define altgr_map __initdata hp_altgr_map
-#define ctrl_map __initdata hp_ctrl_map
-#define shift_ctrl_map __initdata hp_shift_ctrl_map
-#define alt_map __initdata hp_alt_map
-#define ctrl_alt_map __initdata hp_ctrl_alt_map
-
-/*
- * US standard HIL keymap,
- * generated with "loadkeys --mktable key.map > key.c"
- */
-
-u_short plain_map[NR_KEYS] = {
- 0xf200, 0xf200, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf205,
- 0xf304, 0xf308, 0xf305, 0xf309, 0xf306, 0xf307, 0xf30f, 0xf311,
- 0xf301, 0xf30d, 0xf302, 0xf30a, 0xf303, 0xf30c, 0xf300, 0xf30b,
- 0xfb62, 0xfb76, 0xfb63, 0xfb78, 0xfb7a, 0xf200, 0xf200, 0xf01b,
- 0xf200, 0xf109, 0xf200, 0xf10a, 0xf02e, 0xf108, 0xf30e, 0xf10b,
- 0xfb68, 0xfb67, 0xfb66, 0xfb64, 0xfb73, 0xfb61, 0xf200, 0xf207,
- 0xfb75, 0xfb79, 0xfb74, 0xfb72, 0xfb65, 0xfb77, 0xfb71, 0xf009,
- 0xf037, 0xf036, 0xf035, 0xf034, 0xf033, 0xf032, 0xf031, 0xf060,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf103, 0xf102, 0xf101, 0xf100, 0xf200, 0xf209, 0xf200,
- 0xf208, 0xf104, 0xf105, 0xf106, 0xf107, 0xf200, 0xf200, 0xf200,
- 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf200, 0xf200,
- 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf05c, 0xf115, 0xf116,
- 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf201, 0xf114, 0xf118,
- 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf200, 0xf117, 0xf200, 0xf119,
- 0xfb6e, 0xf020, 0xf200, 0xf200, 0xf601, 0xf600, 0xf603, 0xf602,
-};
-
-static u_short shift_map[NR_KEYS] = {
- 0xf200, 0xf200, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf003,
- 0xf304, 0xf308, 0xf305, 0xf309, 0xf306, 0xf307, 0xf02e, 0xf311,
- 0xf301, 0xf30d, 0xf302, 0xf30a, 0xf303, 0xf208, 0xf300, 0xf30b,
- 0xfb42, 0xfb56, 0xfb43, 0xfb58, 0xfb5a, 0xf200, 0xf200, 0xf87f,
- 0xf200, 0xf11f, 0xf200, 0xf120, 0xf30f, 0xf11e, 0xf809, 0xf121,
- 0xfb48, 0xfb47, 0xfb46, 0xfb44, 0xfb53, 0xfb41, 0xf200, 0xf207,
- 0xfb55, 0xfb59, 0xfb54, 0xfb52, 0xfb45, 0xfb57, 0xfb51, 0xf009,
- 0xf026, 0xf05e, 0xf025, 0xf024, 0xf023, 0xf040, 0xf021, 0xf07e,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf10f, 0xf10e, 0xf10d, 0xf10c, 0xf200, 0xf209, 0xf200,
- 0xf204, 0xf110, 0xf111, 0xf112, 0xf113, 0xf200, 0xf200, 0xf200,
- 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf200, 0xf200,
- 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf07c, 0xf115, 0xf116,
- 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf201, 0xf114, 0xf118,
- 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf200, 0xf117, 0xf200, 0xf119,
- 0xfb4e, 0xf020, 0xf200, 0xf200, 0xf601, 0xf600, 0xf603, 0xf602,
-};
-
-static u_short altgr_map[NR_KEYS] = {
- 0xf200, 0xf200, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf205,
- 0xf90e, 0xf912, 0xf90f, 0xf913, 0xf910, 0xf911, 0xf200, 0xf311,
- 0xf90b, 0xf915, 0xf90c, 0xf30a, 0xf90d, 0xf30c, 0xf90a, 0xf917,
- 0xf915, 0xf200, 0xf916, 0xf200, 0xf200, 0xf702, 0xf914, 0xf01b,
- 0xf917, 0xf515, 0xfb67, 0xf516, 0xf02e, 0xf514, 0xf919, 0xf517,
- 0xf200, 0xf200, 0xf919, 0xf917, 0xfb7a, 0xf914, 0xf916, 0xf207,
- 0xf915, 0xfb6e, 0xfb6d, 0xf200, 0xf918, 0xf200, 0xf700, 0xf009,
- 0xf07b, 0xf200, 0xf200, 0xf024, 0xf200, 0xf040, 0xf0b9, 0xf200,
- 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf200, 0xf202, 0xf200,
- 0xf200, 0xf50f, 0xf50e, 0xf50d, 0xf50c, 0xf910, 0xf209, 0xf90b,
- 0xf202, 0xf510, 0xf511, 0xf512, 0xf513, 0xf200, 0xf200, 0xf200,
- 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf702, 0xf200, 0xf200, 0xf07e, 0xf200, 0xf115, 0xf116,
- 0xf118, 0xf601, 0xf602, 0xf117, 0xf200, 0xf201, 0xf114, 0xf118,
- 0xf11a, 0xf200, 0xf200, 0xf200, 0xf200, 0xf117, 0xf311, 0xf119,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf601, 0xf600, 0xf603, 0xf602,
-};
-
-static u_short ctrl_map[NR_KEYS] = {
- 0xf200, 0xf200, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf205,
- 0xf304, 0xf308, 0xf305, 0xf309, 0xf306, 0xf307, 0xf200, 0xf311,
- 0xf301, 0xf30d, 0xf302, 0xf30a, 0xf303, 0xf213, 0xf300, 0xf30b,
- 0xf200, 0xf200, 0xf003, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
- 0xf200, 0xf12b, 0xf200, 0xf12c, 0xf02e, 0xf12a, 0xf009, 0xf12d,
- 0xf008, 0xf000, 0xf200, 0xf004, 0xf013, 0xf001, 0xf200, 0xf207,
- 0xf015, 0xf019, 0xf014, 0xf012, 0xf005, 0xf017, 0xf011, 0xf009,
- 0xf01f, 0xf01e, 0xf01d, 0xf01c, 0xf01b, 0xf200, 0xf0a1, 0xf200,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf125, 0xf124, 0xf123, 0xf122, 0xf200, 0xf209, 0xf200,
- 0xf203, 0xf126, 0xf127, 0xf128, 0xf129, 0xf200, 0xf200, 0xf200,
- 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200, 0xf200,
- 0xf200, 0xf00f, 0xf200, 0xf01b, 0xf01d, 0xf01c, 0xf115, 0xf116,
- 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf007, 0xf201, 0xf114, 0xf118,
- 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf200, 0xf117, 0xf200, 0xf119,
- 0xf00e, 0xf000, 0xf200, 0xf200, 0xf601, 0xf600, 0xf603, 0xf602,
-};
-
-static u_short shift_ctrl_map[NR_KEYS] = {
- 0xf200, 0xf200, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf205,
- 0xf304, 0xf308, 0xf305, 0xf309, 0xf306, 0xf307, 0xf200, 0xf311,
- 0xf301, 0xf30d, 0xf302, 0xf30a, 0xf303, 0xf30c, 0xf300, 0xf30b,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf702, 0xf001, 0xf01b,
- 0xf004, 0xf109, 0xf007, 0xf10a, 0xf02e, 0xf108, 0xf30e, 0xf10b,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf207,
- 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf009,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf103, 0xf102, 0xf101, 0xf100, 0xf306, 0xf209, 0xf301,
- 0xf208, 0xf104, 0xf105, 0xf106, 0xf107, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf702, 0xf200, 0xf200, 0xf200, 0xf200, 0xf115, 0xf116,
- 0xf118, 0xf601, 0xf602, 0xf117, 0xf200, 0xf201, 0xf114, 0xf118,
- 0xf11a, 0xf200, 0xf200, 0xf200, 0xf200, 0xf117, 0xf311, 0xf119,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf601, 0xf600, 0xf603, 0xf602,
-};
-
-static u_short alt_map[NR_KEYS] = {
- 0xf200, 0xf81b, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf205,
- 0xf904, 0xf908, 0xf905, 0xf909, 0xf906, 0xf907, 0xf82c, 0xf311,
- 0xf901, 0xf30d, 0xf902, 0xf30a, 0xf903, 0xf208, 0xf900, 0xf30b,
- 0xf200, 0xf200, 0xf85b, 0xf85d, 0xf200, 0xf702, 0xf861, 0xf81b,
- 0xf864, 0xf509, 0xf867, 0xf50a, 0xf82c, 0xf508, 0xf30e, 0xf50b,
- 0xf827, 0xf860, 0xf200, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf207,
- 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf809,
- 0xf837, 0xf836, 0xf835, 0xf834, 0xf833, 0xf832, 0xf831, 0xf200,
- 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf200, 0xf209, 0xf200,
- 0xf200, 0xf503, 0xf502, 0xf501, 0xf500, 0xf906, 0xf209, 0xf901,
- 0xf202, 0xf504, 0xf505, 0xf506, 0xf507, 0xf200, 0xf200, 0xf200,
- 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf200, 0xf200,
- 0xf200, 0xf702, 0xf200, 0xf85b, 0xf85d, 0xf85c, 0xf115, 0xf116,
- 0xf118, 0xf210, 0xf211, 0xf117, 0xf827, 0xf80d, 0xf114, 0xf20b,
- 0xf11a, 0xf82c, 0xf82e, 0xf82f, 0xf200, 0xf117, 0xf311, 0xf20a,
- 0xf200, 0xf820, 0xf200, 0xf200, 0xf210, 0xf600, 0xf212, 0xf211,
-};
-static u_short ctrl_alt_map[NR_KEYS] = {
- 0xf200, 0xf200, 0xf701, 0xf703, 0xf700, 0xf700, 0xf702, 0xf205,
- 0xf304, 0xf308, 0xf305, 0xf309, 0xf306, 0xf307, 0xf200, 0xf311,
- 0xf301, 0xf30d, 0xf302, 0xf30a, 0xf303, 0xf30c, 0xf300, 0xf30b,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf702, 0xf801, 0xf01b,
- 0xf804, 0xf509, 0xf807, 0xf50a, 0xf02e, 0xf508, 0xf30e, 0xf50b,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf207,
- 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf009,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf503, 0xf502, 0xf501, 0xf500, 0xf306, 0xf209, 0xf301,
- 0xf208, 0xf504, 0xf505, 0xf506, 0xf507, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
- 0xf200, 0xf702, 0xf200, 0xf200, 0xf200, 0xf200, 0xf115, 0xf20c,
- 0xf118, 0xf601, 0xf602, 0xf117, 0xf200, 0xf201, 0xf114, 0xf118,
- 0xf11a, 0xf200, 0xf200, 0xf200, 0xf200, 0xf117, 0xf311, 0xf119,
- 0xf200, 0xf200, 0xf200, 0xf200, 0xf601, 0xf600, 0xf603, 0xf602,
+static unsigned char hil_kbd_set1[128] = {
+ KEY_5, KEY_RESERVED, KEY_RIGHTALT, KEY_LEFTALT,
+ KEY_RIGHTSHIFT, KEY_LEFTSHIFT, KEY_LEFTCTRL, KEY_SYSRQ,
+ KEY_KP4, KEY_KP8, KEY_KP5, KEY_KP9,
+ KEY_KP6, KEY_KP7, KEY_KPCOMMA, KEY_KPENTER,
+ KEY_KP1, KEY_KPSLASH, KEY_KP2, KEY_KPPLUS,
+ KEY_KP3, KEY_KPASTERISK, KEY_KP0, KEY_KPMINUS,
+ KEY_B, KEY_V, KEY_C, KEY_X,
+ KEY_Z, KEY_UNKNOWN, KEY_RESERVED, KEY_ESC,
+ KEY_6, KEY_F10, KEY_3, KEY_F11,
+ KEY_KPDOT, KEY_F9, KEY_TAB /*KP*/, KEY_F12,
+ KEY_H, KEY_G, KEY_F, KEY_D,
+ KEY_S, KEY_A, KEY_RESERVED, KEY_CAPSLOCK,
+ KEY_U, KEY_Y, KEY_T, KEY_R,
+ KEY_E, KEY_W, KEY_Q, KEY_TAB,
+ KEY_7, KEY_6, KEY_5, KEY_4,
+ KEY_3, KEY_2, KEY_1, KEY_GRAVE,
+ KEY_INTL1, KEY_INTL2, KEY_INTL3, KEY_INTL4, /*Buttons*/
+ KEY_INTL5, KEY_INTL6, KEY_INTL7, KEY_INTL8,
+ KEY_MENU, KEY_F4, KEY_F3, KEY_F2,
+ KEY_F1, KEY_VOLUMEUP, KEY_STOP, KEY_SENDFILE/*Enter/Print*/,
+ KEY_SYSRQ, KEY_F5, KEY_F6, KEY_F7,
+ KEY_F8, KEY_VOLUMEDOWN, KEY_CUT /*CLEAR_LINE*/, KEY_REFRESH /*CLEAR_DISPLAY*/,
+ KEY_8, KEY_9, KEY_0, KEY_MINUS,
+ KEY_EQUAL, KEY_BACKSPACE, KEY_INSERT/*KPINSERT_LINE*/, KEY_DELETE /*KPDELETE_LINE*/,
+ KEY_I, KEY_O, KEY_P, KEY_LEFTBRACE,
+ KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_INSERT, KEY_DELETE,
+ KEY_J, KEY_K, KEY_L, KEY_SEMICOLON,
+ KEY_APOSTROPHE, KEY_ENTER, KEY_HOME, KEY_SCROLLUP,
+ KEY_M, KEY_COMMA, KEY_DOT, KEY_SLASH,
+ KEY_RESERVED, KEY_OPEN/*Select*/,KEY_RESERVED,KEY_SCROLLDOWN/*KPNEXT*/,
+ KEY_N, KEY_SPACE, KEY_SCROLLDOWN/*Next*/, KEY_UNKNOWN,
+ KEY_LEFT, KEY_DOWN, KEY_UP, KEY_RIGHT
};
-#undef plain_map
-#undef shift_map
-#undef altgr_map
-#undef ctrl_map
-#undef shift_ctrl_map
-#undef alt_map
-#undef ctrl_alt_map
-
-
-/* standard HP specific HIL keymaps */
-static ushort * __initdata hp_key_maps[MAX_NR_KEYMAPS] = {
- hp_plain_map, hp_shift_map, hp_altgr_map, 0,
- hp_ctrl_map, hp_shift_ctrl_map, 0, 0,
- hp_alt_map, 0, 0, 0,
- hp_ctrl_alt_map, 0, 0, 0
-};
+/* HIL structure */
+static struct {
+ struct input_dev dev;
-struct {
- unsigned char s, c;
+ unsigned int curdev;
+
+ unsigned char s;
+ unsigned char c;
int valid;
-} hil_last;
-
-#define hil_getlast(s,c) do { s = hil_last.s; c = hil_last.c; hil_last.valid = 0; } while (0)
-
-struct {
+
unsigned char data[16];
unsigned int ptr;
-} poll;
+
+ void *dev_id; /* native bus device */
+} hil_dev;
-unsigned char curdev;
static void poll_finished(void)
{
- switch (poll.data[0])
- {
+ int down;
+ int key;
+ unsigned char scode;
+
+ switch (hil_dev.data[0]) {
case 0x40:
- {
- int down = (poll.data[1] & 1) == 0;
- unsigned char scode = poll.data[1] >> 1;
-#if 0
- if (down)
- printk(KERN_DEBUG "[%d]", scode);
-#endif
- handle_scancode(scode, down);
- }
+ down = (hil_dev.data[1] & 1) == 0;
+ scode = hil_dev.data[1] >> 1;
+ key = hil_kbd_set1[scode & 0x7f];
+ input_report_key(&hil_dev.dev, key, down);
break;
}
- curdev = 0;
+ hil_dev.curdev = 0;
}
static inline void handle_status(unsigned char s, unsigned char c)
@@ -282,28 +169,33 @@ static inline void handle_status(unsigne
poll_finished();
} else {
if (c & 0x10) {
- if (curdev)
- poll_finished(); /* just in case */
- curdev = c & 7;
- poll.ptr = 0;
+ if (hil_dev.curdev)
+ poll_finished(); /* just in case */
+ hil_dev.curdev = c & 7;
+ hil_dev.ptr = 0;
}
}
}
static inline void handle_data(unsigned char s, unsigned char c)
{
- if (curdev)
- poll.data[poll.ptr++] = c;
+ if (hil_dev.curdev) {
+ hil_dev.data[hil_dev.ptr++] = c;
+ hil_dev.ptr &= 15;
+ }
}
+
/*
* Handle HIL interrupts.
*/
-
static void hil_interrupt(int irq, void *handle, struct pt_regs *regs)
{
unsigned char s, c;
- s = hil_status(); c = hil_read_data();
+
+ s = hil_status();
+ c = hil_read_data();
+
switch (s >> 4) {
case 0x5:
handle_status(s, c);
@@ -312,10 +204,10 @@ static void hil_interrupt(int irq, void
handle_data(s, c);
break;
case 0x4:
- hil_last.s = s;
- hil_last.c = c;
+ hil_dev.s = s;
+ hil_dev.c = c;
mb();
- hil_last.valid = 1;
+ hil_dev.valid = 1;
break;
}
}
@@ -327,135 +219,123 @@ static void hil_interrupt(int irq, void
static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
{
unsigned long flags;
- save_flags(flags); cli();
- while (hil_busy());
+
+ save_flags(flags);
+ cli();
+ while (hil_busy())
+ /* wait */;
hil_command(cmd);
while (len--) {
- while (hil_busy());
+ while (hil_busy())
+ /* wait */;
hil_write_data(*(data++));
}
restore_flags(flags);
}
-#if defined(CONFIG_PARISC)
-
-extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
-extern int pckbd_getkeycode(unsigned int scancode);
-extern int pckbd_pretranslate(unsigned char scancode, char raw_mode);
-extern int pckbd_translate(unsigned char scancode, unsigned char *keycode, char raw_mode);
-extern char pckbd_unexpected_up(unsigned char keycode);
-
-static int def_translate(unsigned char scancode, unsigned char *keycode, char raw)
-{
- *keycode = scancode;
- return 1;
-}
-
-static char def_unexpected_up(unsigned char c)
-{
- return 128;
-}
-
-static void def_leds(unsigned char leds)
-{
-}
-
-static void def_init_hw(void)
-{
-}
-
-
-static struct kbd_ops hil_kbd_ops = {
- setkeycode: pckbd_setkeycode,
- getkeycode: pckbd_getkeycode,
- translate: def_translate, // pckbd_translate, /* ?? */
- unexpected_up: def_unexpected_up, // pckbd_unexpected_up,
- leds: def_leds, /* do we have LED's on HIL ? - me not ! */
- init_hw: def_init_hw,
-
-#ifdef CONFIG_MAGIC_SYSRQ
- sysrq_key: 0x48, /* "Menu" key */
- sysrq_xlate: hp_ps2kbd_sysrq_xlate,
-#endif /* CONFIG_MAGIC_SYSRQ */
-};
-
-#endif /* CONFIG_PARISC */
-
/*
* Initialise HIL.
*/
-int __init hil_keyb_init(void)
+static int __init
+hil_keyb_init(void)
{
- unsigned char s, c, kbid;
- unsigned int n = 0;
+ unsigned char c;
+ unsigned int i, kbid, n = 0;
+ if (hil_dev.dev.idbus) {
+ printk("HIL: already initialized\n");
+ return -ENODEV;
+ }
+
#if defined(CONFIG_HP300)
if (!hwreg_present((void *)(HILBASE + HIL_DATA)))
- return 1; /* maybe this can happen */
-#endif /* CONFIG_HP300 */
-
- request_irq(HIL_IRQ, hil_interrupt, 0, "hil", (void*) HILBASE);
+ return -ENODEV;
+
+ request_region(HILBASE+HIL_DATA, 2, "hil");
+#endif
+
+ request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id);
/* Turn on interrupts */
hil_do(HIL_INTON, NULL, 0);
/* Look for keyboards */
- hil_getlast(s, c); /* clear any pending data */
+ hil_dev.valid = 0; /* clear any pending data */
hil_do(HIL_READKBDSADR, NULL, 0);
- while (!hil_last.valid) {
+ while (!hil_dev.valid) {
if (n++ > 100000) {
printk(KERN_DEBUG "HIL: timed out, assuming no keyboard present.\n");
- return 1;
+ break;
}
mb();
}
- hil_getlast(s, c);
+ c = hil_dev.c;
+ hil_dev.valid = 0;
if (c == 0) {
+ kbid = -1;
printk(KERN_WARNING "HIL: no keyboard present.\n");
- return 1;
+ } else {
+ kbid = ffz(~c);
+ printk(KERN_INFO "HIL: keyboard found at id %d\n", kbid);
}
- kbid = ffz(~c);
- printk(KERN_INFO "HIL: keyboard found at id %d\n", kbid);
-
- for (n=0; n<MAX_NR_KEYMAPS; n++)
- if (key_maps[n] && hp_key_maps[n])
- memcpy(key_maps[n], hp_key_maps[n], sizeof(plain_map));
- printk(KERN_INFO "HIL: keymap loaded.\n");
-
-#if defined(CONFIG_PARISC)
- register_kbd_ops(&hil_kbd_ops);
-#endif
-
- request_region(HILBASE+HIL_DATA, 2, "hil");
-
/* set it to raw mode */
c = 0;
hil_do(HIL_WRITEKBDSADR, &c, 1);
+
+ /* register input interface */
+ hil_dev.dev.name = "HIL keyboard";
+ hil_dev.dev.idbus = BUS_HIL;
+ hil_dev.dev.idvendor = PCI_VENDOR_ID_HP;
+ hil_dev.dev.idproduct = 0x0001;
+ hil_dev.dev.idversion = 0x0100;
+
+ hil_dev.dev.evbit[0] |= BIT(EV_KEY);
+ for (i = 0; i < 128; i++)
+ set_bit(hil_kbd_set1[i], hil_dev.dev.keybit);
+ clear_bit(0, hil_dev.dev.keybit);
+
+#if 1
+ /* XXX: HACK !!!
+ * remove this call if hp_psaux.c/hp_keyb.c is converted
+ * to the input layer... */
+ register_ps2_keybfuncs();
+#endif
+
+ input_register_device(&hil_dev.dev);
+ printk(KERN_INFO "input%d: %s on hil%d (id %d)\n",
+ hil_dev.dev.number, hil_dev.dev.name, 0, kbid);
+
+ /* HIL keyboards don't have a numlock key,
+ * simulate a up-down sequence of numlock to
+ * make the keypad work at expected. */
+ input_report_key(&hil_dev.dev, KEY_NUMLOCK, 1);
+
return 0;
}
+#if defined(CONFIG_PARISC)
static int __init
hil_init_chip(struct parisc_device *dev)
{
if (!dev->irq) {
- printk(KERN_WARNING __FILE__ ": IRQ not found for HIL at 0x%lx\n", dev->hpa);
+ printk(KERN_WARNING "HIL: IRQ not found for HIL at 0x%lx\n", dev->hpa);
return -ENODEV;
}
hil_base = dev->hpa;
hil_irq = dev->irq;
+ hil_dev.dev_id = dev;
printk(KERN_INFO "Found HIL at 0x%lx, IRQ %d\n", hil_base, hil_irq);
return hil_keyb_init();
}
-
static struct parisc_device_id hil_tbl[] = {
{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00073 },
{ 0, }
@@ -468,23 +348,36 @@ static struct parisc_driver hil_driver =
id_table: hil_tbl,
probe: hil_init_chip,
};
+#endif /* CONFIG_PARISC */
+
+
+
+
static int __init hil_init(void)
{
+#if defined(CONFIG_PARISC)
return register_parisc_driver(&hil_driver);
+#else
+ return hil_keyb_init();
+#endif
}
-static int __exit hil_exit(void)
+static void __exit hil_exit(void)
{
- unregister_parisc_driver(&hil_driver);
+ if (HIL_IRQ) {
+ disable_irq(HIL_IRQ);
+ free_irq(HIL_IRQ, hil_dev.dev_id);
+ }
-#if defined(CONFIG_PARISC)
- unregister_kbd_ops();
-#endif
+ input_unregister_device(&hil_dev.dev);
+#if defined(CONFIG_PARISC)
+ unregister_parisc_driver(&hil_driver);
+#else
release_region(HILBASE+HIL_DATA, 2);
- free_irq(HIL_IRQ, hil_interrupt);
+#endif
}
module_init(hil_init);
--Boundary-00=_t/DK9lajeN41SGC--