clps711x_keyb.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:16k
- /*
- * drivers/char/clps711x_keyb.c
- *
- * Copyright (C) 2001 Thomas Gleixner <gleixner@autronix.de>
- *
- * based on drivers/edb7211_keyb.c, which is copyright (C) 2000 Bluemug Inc.
- *
- * Keyboard driver for ARM Linux on EP7xxx and CS89712 processors
- *
- * 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 the Free Software Foundation. See the file COPYING
- * in the main directory of this archive for more details.
- *
- *
- * Hardware:
- *
- * matrix scan keyboards based on EP7209,7211,7212,7312 and CS89712
- * on chip keyboard scanner.
- * Adaption for different machines is done in init function.
- *
- * Basic Function:
- *
- * Basicly the driver is interrupt driven. It sets all column drivers
- * high. If any key is pressed, a interrupt occures. Now a seperate scan of
- * each column is done. This scan is timer based, because we use a keyboard
- * interface with decoupling capacitors (neccecary if you want to survive
- * EMC compliance tests). Always one line is set high. When next timer event
- * occures the scan data on port A are valid. This makes also sure, that no
- * spurious keys are scanned. The kbd int on these CPU's is not deglitched!
- * After scanning all columns, we switch back to int mode, if no key is
- * pressed. If any is pressed we reschedule the scan within a programmable
- * delay. If we would switch back to interrupt mode as long as a key is pressed,
- * we come right back to the interrupt, because the int. is level triggered !
- * The timer based scan of the seperate columns can also be done in one
- * timer event (set fastscan to 1).
- *
- * Summary:
- * The design of this keyboard controller chip is stupid at all !
- *
- * Matrix translation:
- * The matrix translation table is based on standard XT scancodes. Maybe
- * you have to adjust the KEYISPRINTABLE macro if you set other codes.
- *
- * HandyKey:
- *
- * On small matrix keyboards you don't have enough keys for operation.
- * The intention was to implement a operation mode as it's used on handys.
- * You can rotate trough four scancode levels and produce e.g. with a 4x3
- * matrix 4*3*4 = 48 different keycodes. That's basicly enough for editing
- * filenames or things like that. The HandyKey function takes care about
- * nonprintable keys like cursors, backspace, del ...
- * If a key is pressed and is a printable keycode, the code is put to the
- * main keyboard handler and a cursor left is applied. If you press the same
- * key again, the current character is deleted and the next level character
- * is applied. (e.g. 1, a, b, c, 1 ....). If you press a different key, the
- * driver applies cursor right, before processing the new key.
- * The autocomplete feature moves the cursor right, if you do not press a
- * key within a programmable time.
- * If HandyKey is off, the keyboard behaviour is that of a standard keyboard
- * HandyKey can be en/disabled from userspace with the proc/keyboard entry
- *
- * proc/keyboard:
- *
- * Read access gives back the actual state of the HandyKey function
- * h:0 Disabled
- * h:1 Enabled
- * Write access has two functions. Changing the HandyKey mode and applying
- * a different scancode translation table.
- * Syntax is: h:0 disable Handykey
- * h:1 enabled Handykey
- * t:array[256] of bytes Transfer translation table
- */
- #include <linux/config.h>
- #include <linux/sched.h>
- #include <linux/interrupt.h>
- #include <linux/tty.h>
- #include <linux/tty_flip.h>
- #include <linux/mm.h>
- #include <linux/slab.h>
- #include <linux/ptrace.h>
- #include <linux/signal.h>
- #include <linux/timer.h>
- #include <linux/tqueue.h>
- #include <linux/random.h>
- #include <linux/ctype.h>
- #include <linux/init.h>
- #include <linux/kbd_ll.h>
- #include <linux/kbd_kern.h>
- #include <linux/delay.h>
- #include <linux/proc_fs.h>
- #include <asm/bitops.h>
- #include <asm/keyboard.h>
- #include <asm/irq.h>
- #include <asm/hardware.h>
- #include <asm/uaccess.h>
- #include <asm/io.h>
- #include <asm/system.h>
- void clps711x_kbd_init_hw(void);
- /*
- * Values for the keyboard column scan control register.
- */
- #define KBSC_HI 0x0 /* All driven high */
- #define KBSC_LO 0x1 /* All driven low */
- #define KBSC_X 0x2 /* All high impedance */
- #define KBSC_COL0 0x8 /* Column 0 high, others high impedance */
- #define KBSC_COL1 0x9 /* Column 1 high, others high impedance */
- #define KBSC_COL2 0xa /* Column 2 high, others high impedance */
- #define KBSC_COL3 0xb /* Column 3 high, others high impedance */
- #define KBSC_COL4 0xc /* Column 4 high, others high impedance */
- #define KBSC_COL5 0xd /* Column 5 high, others high impedance */
- #define KBSC_COL6 0xe /* Column 6 high, others high impedance */
- #define KBSC_COL7 0xf /* Column 7 high, others high impedance */
- /*
- * Keycodes for cursor left/right and delete (used by HandyKey)
- */
- #define KEYCODE_CLEFT 0x4b
- #define KEYCODE_CRIGHT 0x4d
- #define KEYCODE_DEL 0x53
- #define KEYISPRINTABLE(code) ( (code > 0x01 && code < 0x37 && code != 0x1c
- && code != 0x0e) || code == 0x39)
- /* Simple translation table for the SysRq keys */
- #ifdef CONFIG_MAGIC_SYSRQ
- unsigned char clps711x_kbd_sysrq_xlate[128] =
- "