Skip to contentSkip to conversation

add support for PC-9800 architecture (11/26) input

RFC PATCH In review Osamu Tomita 2 participants 2 messages Oct 17, 2002 – Oct 22, 2002 Input drivers

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 add support for PC-9800 architecture (11/26) input

This is part 11/26 of patchset for add support NEC PC-9800 architecture, against 2.5.43.

Summary:
input modules
- add new driver for PC-9800 standard keyboard and mouse.

input.h changes are temporally hack.
I'll remove this hack using propery keycode.
To do this, I need "kbd" utility that can make keymap even if keycode > 127.

diffstat:

 drivers/input/keyboard/98kbd.c   |  359 +++++++++++++++++++++++++++++++++++++++
 drivers/input/keyboard/Config.in |    4 
 drivers/input/keyboard/Makefile  |    1 
 drivers/input/misc/pcspkr.c      |   24 ++
 drivers/input/mouse/Config.in    |    7 
 drivers/input/mouse/logibm.c     |   48 +++++
 drivers/input/serio/Config.in    |    3 
 drivers/input/serio/Makefile     |    1 
 drivers/input/serio/i8042-98.c   |  346 +++++++++++++++++++++++++++++++++++++
 drivers/input/serio/i8042-98io.h |   74 ++++++++
 drivers/input/serio/i8042.h      |    2 
 include/linux/input.h            |   21 ++
 12 files changed, 890 insertions(+)

patch:

drivers/input/keyboard/Config.in +4 -0
diff -urN linux/drivers/input/keyboard/Config.in linux98/drivers/input/keyboard/Config.in
@@ -9,6 +9,10 @@
 dep_tristate '  XT Keyboard support' CONFIG_KEYBOARD_XTKBD $CONFIG_INPUT $CONFIG_INPUT_KEYBOARD $CONFIG_SERIO
 dep_tristate '  Newton keyboard' CONFIG_KEYBOARD_NEWTON $CONFIG_INPUT $CONFIG_INPUT_KEYBOARD $CONFIG_SERIO
 
+if [ "$CONFIG_PC9800" = "y" ]; then
+   dep_tristate '  NEC PC-9801 keyboard support' CONFIG_KEYBOARD_98KBD $CONFIG_INPUT $CONFIG_INPUT_KEYBOARD $CONFIG_SERIO
+fi
+
 if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then
    dep_tristate '  Maple bus keyboard support' CONFIG_KEYBOARD_MAPLE $CONFIG_INPUT $CONFIG_INPUT_KEYBOARD $CONFIG_MAPLE
 fi
drivers/input/keyboard/Makefile +1 -0
diff -urN linux/drivers/input/keyboard/Makefile linux98/drivers/input/keyboard/Makefile
@@ -10,6 +10,7 @@
 obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
 obj-$(CONFIG_KEYBOARD_AMIGA)		+= amikbd.o
 obj-$(CONFIG_KEYBOARD_NEWTON)		+= newtonkbd.o
+obj-$(CONFIG_KEYBOARD_98KBD)		+= 98kbd.o
 
 # The global Rules.make.
 
drivers/input/keyboard/98kbd.c +359 -0

359 lines not on this page · raw message

drivers/input/misc/pcspkr.c +24 -0
diff -urN linux/drivers/input/misc/pcspkr.c linux98/drivers/input/misc/pcspkr.c
@@ -12,6 +12,7 @@
  * the Free Software Foundation
  */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -23,7 +24,11 @@
 MODULE_LICENSE("GPL");
 
 static char pcspkr_name[] = "PC Speaker";
+#ifndef CONFIG_PC9800
 static char pcspkr_phys[] = "isa0061/input0";
+#else
+static char pcspkr_phys[] = "isa3fdb/input0";
+#endif
 static struct input_dev pcspkr_dev;
 
 spinlock_t i8253_beep_lock = SPIN_LOCK_UNLOCKED;
@@ -43,11 +48,16 @@
 	} 
 
 	if (value > 20 && value < 32767)
+#ifndef CONFIG_PC9800
 		count = 1193182 / value;
+#else
+		count = CLOCK_TICK_RATE / value;
+#endif
 	
 	spin_lock_irqsave(&i8253_beep_lock, flags);
 
 	if (count) {
+#ifndef CONFIG_PC9800
 		/* enable counter 2 */
 		outb_p(inb_p(0x61) | 3, 0x61);
 		/* set command for counter 2, 2 byte write */
@@ -55,9 +65,23 @@
 		/* select desired HZ */
 		outb_p(count & 0xff, 0x42);
 		outb((count >> 8) & 0xff, 0x42);
+#else /* CONFIG_PC9800 */
+		outb(0x76, 0x3fdf);
+		outb(0, 0x5f);
+		outb(count & 0xff, 0x3fdb);
+		outb(0, 0x5f);
+		outb((count >> 8) & 0xff, 0x3fdb);
+		/* beep on */
+		outb(6, 0x37);
+#endif /* !CONFIG_PC9800 */
 	} else {
 		/* disable counter 2 */
+#ifndef CONFIG_PC9800
 		outb(inb_p(0x61) & 0xFC, 0x61);
+#else
+		/* beep off */
+		outb(7, 0x37);
+#endif
 	}
 
 	spin_unlock_irqrestore(&i8253_beep_lock, flags);
drivers/input/mouse/Config.in +7 -0
diff -urN linux/drivers/input/mouse/Config.in linux98/drivers/input/mouse/Config.in
@@ -7,6 +7,12 @@
 dep_tristate '  PS/2 mouse' CONFIG_MOUSE_PS2 $CONFIG_INPUT $CONFIG_INPUT_MOUSE $CONFIG_SERIO
 dep_tristate '  Serial mouse' CONFIG_MOUSE_SERIAL $CONFIG_INPUT $CONFIG_INPUT_MOUSE $CONFIG_SERIO
 
+if [ "$CONFIG_PC9800" = "y" ]; then
+   dep_tristate '  NEC PC-9801 busmouse' CONFIG_MOUSE_LOGIBM $CONFIG_INPUT $CONFIG_INPUT_MOUSE $CONFIG_ISA
+   if [ "$CONFIG_MOUSE_LOGIBM" != "n" ]; then
+      define_bool CONFIG_LOGIBUSMOUSE_PC9800 y
+   fi
+else
 dep_tristate '  InPort/MS/ATIXL busmouse' CONFIG_MOUSE_INPORT $CONFIG_INPUT $CONFIG_INPUT_MOUSE $CONFIG_ISA
 if [ "$CONFIG_MOUSE_INPORT" != "n" ]; then
    bool '  ATI XL variant' CONFIG_MOUSE_ATIXL
@@ -22,3 +28,4 @@
 if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
    dep_tristate '  Acorn RiscPC mouse' CONFIG_MOUSE_ACORN $CONFIG_INPUT $CONFIG_INPUT_MOUSE
 fi
+fi
drivers/input/mouse/logibm.c +48 -0

106 lines not on this page · raw message

drivers/input/serio/Config.in +3 -0
diff -urN linux/drivers/input/serio/Config.in linux98/drivers/input/serio/Config.in
@@ -21,3 +21,6 @@
 if [ "$CONFIG_SA1111" = "y" ]; then
    dep_tristate '  Intel SA1111 keyboard controller' CONFIG_SERIO_SA1111 $CONFIG_SERIO
 fi
+if [ "$CONFIG_PC9800" = "y" ]; then
+   dep_tristate '  NEC PC-9801 keyboard controller' CONFIG_SERIO_98KBD $CONFIG_SERIO
+fi
drivers/input/serio/Makefile +1 -0
diff -urN linux/drivers/input/serio/Makefile linux98/drivers/input/serio/Makefile
@@ -17,6 +17,7 @@
 obj-$(CONFIG_SERIO_SA1111)	+= sa1111ps2.o
 obj-$(CONFIG_SERIO_AMBAKMI)	+= ambakmi.o
 obj-$(CONFIG_SERIO_Q40KBD)	+= q40kbd.o
+obj-$(CONFIG_SERIO_98KBD)	+= i8042-98.o
 
 # The global Rules.make.
 
drivers/input/serio/i8042-98.c +346 -0

346 lines not on this page · raw message

drivers/input/serio/i8042-98io.h +74 -0

74 lines not on this page · raw message

drivers/input/serio/i8042.h +2 -0
diff -urN linux/drivers/input/serio/i8042.h linux98/drivers/input/serio/i8042.h
@@ -17,6 +17,8 @@
 #include "i8042-ppcio.h"
 #elif defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)
 #include "i8042-sparcio.h"
+#elif defined(CONFIG_PC9800)
+#include "i8042-98io.h"
 #else
 #include "i8042-io.h"
 #endif
include/linux/input.h +21 -0
diff -urN linux/include/linux/input.h linux98/include/linux/input.h
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  */
 
+#include <linux/config.h>
 #ifdef __KERNEL__
 #include <linux/time.h>
 #include <linux/list.h>
@@ -134,7 +135,11 @@
 #define KEY_LEFTBRACE		26
 #define KEY_RIGHTBRACE		27
 #define KEY_ENTER		28
+#ifndef CONFIG_PC9800
 #define KEY_LEFTCTRL		29
+#else
+#define KEY_LEFTCTRL		116
+#endif
 #define KEY_A			30
 #define KEY_S			31
 #define KEY_D			32
@@ -147,7 +152,11 @@
 #define KEY_SEMICOLON		39
 #define KEY_APOSTROPHE		40
 #define KEY_GRAVE		41
+#ifndef CONFIG_PC9800
 #define KEY_LEFTSHIFT		42
+#else
+#define KEY_LEFTSHIFT		112
+#endif
 #define KEY_BACKSLASH		43
 #define KEY_Z			44
 #define KEY_X			45
@@ -161,9 +170,17 @@
 #define KEY_SLASH		53
 #define KEY_RIGHTSHIFT		54
 #define KEY_KPASTERISK		55
+#ifndef CONFIG_PC9800
 #define KEY_LEFTALT		56
+#else
+#define KEY_LEFTALT		115
+#endif
 #define KEY_SPACE		57
+#ifndef CONFIG_PC9800
 #define KEY_CAPSLOCK		58
+#else
+#define KEY_CAPSLOCK		113
+#endif
 #define KEY_F1			59
 #define KEY_F2			60
 #define KEY_F3			61
@@ -204,7 +221,11 @@
 #define KEY_KPENTER		96
 #define KEY_RIGHTCTRL		97
 #define KEY_KPSLASH		98
+#ifndef CONFIG_PC9800
 #define KEY_SYSRQ		99
+#else
+#define KEY_SYSRQ		96
+#endif
 #define KEY_RIGHTALT		100
 #define KEY_LINEFEED		101
 #define KEY_HOME		102
#1 lore raw
Quoted 6 lines · Osamu Tomita

This is part 11/26 of patchset for add support NEC PC-9800 architecture, against 2.5.43.

Summary:
input modules
- add new driver for PC-9800 standard keyboard and mouse.

Before I'll think of merging this, it has to be seriously cleaned up. Comments below.

(Summary: use your own SERIO_TYPE for the PC-98 keyboard, remove dead code and definitions, fix naming, make as little #ifdefs as possible, and maybe you can put the PC-98 keyboard code into xtkbd.c (in which case you may get away with SERIO_XT).

Quoted 3 lines

input.h changes are temporally hack.
I'll remove this hack using propery keycode.
To do this, I need "kbd" utility that can make keymap even if keycode > 127.

Fix the 'kbd' package first, then. No way I'm going to merge the patches to input.h.

drivers/input/keyboard/98kbd.c line 44

Quoted 9 lines
drivers/input/keyboard/98kbd.c +9 -0
+static unsigned char atkbd_set2_keycode[512] = {
+	  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 43, 14, 15,
+	 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32,
+	 33, 34, 35, 36, 37, 38, 39, 40, 84, 44, 45, 46, 47, 48, 49, 50,
+	 51, 52, 53,181, 57,184,109,104,110,111,103,105,106,108,102,107,
+	 74, 98, 71, 72, 73, 55, 75, 76, 77, 78, 79, 80, 81,117, 82,124,
+	 83,185, 87, 88, 85, 89, 90,  0,  0,  0,  0,  0,  0,  0,102,  0,
+	 99,133, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,  0,  0,  0,  0,
+	 42, 58,190, 56, 29

This either is AT keyboard set2 keycode table or it is not. And looking at the numbers, it obviously is not. It might be something like set1 ...? So, call it the right name then!

Same applies for all the other identifiers - if it is not AT keyboard, don't call it ATKBD.

You may as well be able to extend xtkbd.c instead for your use - it's much more similar to the PC-98 keyboard than atkbd.c.

drivers/input/keyboard/98kbd.c line 72

Quoted 6 lines
drivers/input/keyboard/98kbd.c +6 -0
+#define ATKBD_KEY_UNKNOWN	  0
+#define ATKBD_KEY_BAT		251
+#define ATKBD_KEY_EMUL0		252
+#define ATKBD_KEY_EMUL1		253
+#define ATKBD_KEY_RELEASE	254
+#define ATKBD_KEY_NULL		255

Where are you using these?

drivers/input/keyboard/98kbd.c line 251

Quoted 8 lines
drivers/input/keyboard/98kbd.c +8 -0
+/*
+ * atkbd_cleanup() restores the keyboard state so that BIOS is happy after a
+ * reboot.
+ */
+
+static void atkbd_cleanup(struct serio *serio)
+{
+}

Why do you define the function at all?

Quoted 5 lines
drivers/input/keyboard/98kbd.c +5 -0
+/*
+ * atkbd_connect() is called when the serio module finds and interface
+ * that isn't handled yet by an appropriate device driver. We check if
+ * there is an AT keyboard out there and if yes, we register ourselves
+ * to the input module.

drivers/input/keyboard/98kbd.c line 279

Quoted 10 lines
drivers/input/keyboard/98kbd.c +10 -0
+ */
+
+static void atkbd_connect(struct serio *serio, struct serio_dev *dev)
+{
+	struct atkbd *atkbd;
+	int i;
+
+	if ((serio->type & SERIO_TYPE) != SERIO_8042 &&
+		(((serio->type & SERIO_TYPE) != SERIO_RS232) || (serio->type & SERIO_PROTO) != SERIO_PS2SER))
+		        return;

Gee, this just doesn't make sense at all here!

Quoted 22 lines

diff -urN linux/drivers/input/mouse/logibm.c linux98/drivers/input/mouse/logibm.c

drivers/input/mouse/logibm.c +2 -0
@@ -38,6 +38,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
@@ -48,6 +49,7 @@
 MODULE_DESCRIPTION("Logitech busmouse driver");
 MODULE_LICENSE("GPL");
 
+#ifndef CONFIG_LOGIBUSMOUSE_PC9800
 #define	LOGIBM_BASE		0x23c
 #define	LOGIBM_EXTENT		4
 
@@ -55,6 +57,15 @@
 #define	LOGIBM_SIGNATURE_PORT	LOGIBM_BASE + 1
 #define	LOGIBM_CONTROL_PORT	LOGIBM_BASE + 2

drivers/input/mouse/logibm.c line 68

Quoted 10 lines
drivers/input/mouse/logibm.c +9 -0
 #define	LOGIBM_CONFIG_PORT	LOGIBM_BASE + 3
+#else /* CONFIG_LOGIBUSMOUSE_PC9800 */
+#define	LOGIBM_BASE		0x7fd9
+#define	LOGIBM_DATA_PORT	LOGIBM_BASE + 0
+/*	LOGIBM_SIGNATURE_PORT	does not exist */
+#define	LOGIBM_CONTROL_PORT	LOGIBM_BASE + 4
+/*	LOGIBM_INTERRUPT_PORT	does not exist */
+#define	LOGIBM_CONFIG_PORT	LOGIBM_BASE + 6
+#define	LOGIBM_EXTENT		(-7)
+#endif /* !CONFIG_LOGIBUSMOUSE_PC9800 */

Same comments as Russell had for the serial driver.

Quoted 10 lines

diff -urN linux/drivers/input/serio/i8042-98.c linux98/drivers/input/serio/i8042-98.c

drivers/input/serio/i8042-98.c +6 -0
@@ -0,0 +1,346 @@
+/*
+ *  NEC PC-9801 keyboard controller driver for Linux
+ *
+ *  Copyright (c) 1999-2002 Vojtech Pavlik
+ *  Modify for NEC PC-9801 by Osamu Tomita <[email protected]>
+ */

drivers/input/serio/i8042-98.c line 16

Quoted 10 lines
drivers/input/serio/i8042-98.c +10 -0
+
+struct i8042_values {
+	int irq;
+	unsigned char disable;
+	unsigned char irqen;
+	unsigned char exists;
+	signed char mux;
+	unsigned char *name;
+	unsigned char *phys;
+};

Don't call it i8042, when it ain't no i8042 ... again.

drivers/input/serio/i8042-98.c line 81

Quoted 11 lines
drivers/input/serio/i8042-98.c +11 -0
+static int i8042_wait_write(void)
+{
+	outb_p(0x00, 0x5f);
+	outb_p(0x00, 0x5f);
+	outb_p(0x00, 0x5f);
+	outb_p(0x00, 0x5f);
+	outb_p(0x00, 0x5f);
+	outb_p(0x00, 0x5f);
+	outb_p(0x00, 0x5f);
+	return 0;
+}

This doesn't look very good, either.

drivers/input/serio/i8042-98.c line 227

Quoted 11 lines
drivers/input/serio/i8042-98.c +11 -0
+static int __init i8042_controller_init(void)
+{
+
+/*
+ * Test the i8042. We need to know if it thinks it's working correctly
+ * before doing anything else.
+ */
+
+	i8042_flush();
+
+	i8042_initial_ctr = i8042_ctr;

This is completely useless.

Quoted 6 lines
drivers/input/serio/i8042-98.c +6 -0
+
+/*
+ * Disable the keyboard interface and interrupt. 
+ */
+
+	i8042_ctr |= I8042_CTR_KBDDIS;

drivers/input/serio/i8042-98.c line 243

Quoted 10 lines
drivers/input/serio/i8042-98.c +10 -0
+	i8042_ctr &= ~I8042_CTR_KBDINT;
+
+/*
+ * Set nontranslated mode for the kbd interface if requested by an option.
+ * After this the kbd interface becomes a simple serial in/out, like the aux
+ * interface is. We don't do this by default, since it can confuse notebook
+ * BIOSes.
+ */
+
+	i8042_ctr &= ~I8042_CTR_XLATE;	/* i8042_direct = 1; */

As is all this, when you don't ever set the CTR ... ? I assume the chip doesn't have a CTR at all?

Quoted 4 lines
drivers/input/serio/i8042-98.c +4 -0
+ * Here we try to reset everything back to a state in which the BIOS will be
+ * able to talk to the hardware when rebooting.
+ */
+

drivers/input/serio/i8042-98.c line 262

Quoted 10 lines
drivers/input/serio/i8042-98.c +10 -0
+void i8042_controller_cleanup(void)
+{
+	i8042_flush();
+
+/*
+ * Reset anything that is connected to the ports.
+ */
+
+	if (i8042_kbd_values.exists)
+		serio_cleanup(&i8042_kbd_port);

Why?

drivers/input/serio/i8042-98.c line 270

Quoted 7 lines
drivers/input/serio/i8042-98.c +7 -0
+/*
+ * Restore the original control register setting.
+ */
+
+	i8042_ctr = i8042_initial_ctr;
+
+}

Oh, my.

Quoted 4 lines
drivers/input/serio/i8042-98.c +4 -0
+static int i8042_notify_sys(struct notifier_block *this, unsigned long code,
+        		    void *unused)
+{
+        if (code==SYS_DOWN || code==SYS_HALT) 

drivers/input/serio/i8042-98.c line 312

Quoted 10 lines
drivers/input/serio/i8042-98.c +10 -0
+        	i8042_controller_cleanup();
+        return NOTIFY_DONE;
+}
+
+static struct notifier_block i8042_notifier=
+{
+        i8042_notify_sys,
+        NULL,
+        0
+};

Again, completely unnecessary.

drivers/input/serio/i8042-98.c line 319

Quoted 2 lines
drivers/input/serio/i8042-98.c +2 -0
+	if (i8042_platform_init())
+		return -EBUSY;

platform_init ... ?!?!? You expect this to run on something else than a pc-98?

Quoted 10 lines

diff -urN linux/drivers/input/serio/i8042-98io.h linux98/drivers/input/serio/i8042-98io.h

drivers/input/serio/i8042-98io.h +6 -0
@@ -0,0 +1,74 @@
+#ifndef _I8042_IO_H
+#define _I8042_IO_H
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by 

drivers/input/serio/i8042-98io.h line 16

Quoted 10 lines
drivers/input/serio/i8042-98io.h +10 -0
+ * the Free Software Foundation.
+ */
+
+/*
+ * Names.
+ */
+
+#define I8042_KBD_PHYS_DESC "isa0041/serio0"
+#define I8042_AUX_PHYS_DESC "isa0041/serio1"
+#define I8042_MUX_PHYS_DESC "isa0041/serio%d"

You're not using these. Why are you defining them. Ahh, cut'n'paste ...

drivers/input/serio/i8042-98io.h line 23

Quoted 7 lines
drivers/input/serio/i8042-98io.h +7 -0
+
+/*
+ * IRQs.
+ */
+
+#define I8042_KBD_IRQ	1
+#define I8042_AUX_IRQ	0	/* nothing */

Cool. We don't have an AUX port, but we keep the definitions.

drivers/input/serio/i8042.h line 24

Quoted 12 lines

diff -urN linux/drivers/input/serio/i8042.h linux98/drivers/input/serio/i8042.h

drivers/input/serio/i8042.h +2 -0
@@ -17,6 +17,8 @@
 #include "i8042-ppcio.h"
 #elif defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)
 #include "i8042-sparcio.h"
+#elif defined(CONFIG_PC9800)
+#include "i8042-98io.h"
 #else
 #include "i8042-io.h"
 #endif

Why are you changing i8042.h, when you don't need it at all?

Quoted 12 lines

diff -urN linux/include/linux/input.h linux98/include/linux/input.h

include/linux/input.h +1 -0
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  */
 
+#include <linux/config.h>
 #ifdef __KERNEL__
 #include <linux/time.h>
 #include <linux/list.h>

include/linux/input.h line 142

Quoted 8 lines
include/linux/input.h +4 -0
@@ -134,7 +135,11 @@
 #define KEY_LEFTBRACE		26
 #define KEY_RIGHTBRACE		27
 #define KEY_ENTER		28
+#ifndef CONFIG_PC9800
 #define KEY_LEFTCTRL		29
+#else
+#define KEY_LEFTCTRL		116
+#endif

No way are these ever going to change depending on the architecture. They are defined to be constant. I don't like variable constants.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs