* [PATCH] Tosa keyboard support
@ 2007-12-11 15:23 Dmitry Baryshkov
2007-12-11 15:38 ` Dmitry Baryshkov
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Baryshkov @ 2007-12-11 15:23 UTC (permalink / raw)
To: linux-input
Cc: linux-kernel, dirk, dmitry.torokhov, linux-arm-kernel,
Marcin Juszkiewicz
Support keyboard on tosa (Sharp Zaurus SL-6000x).
Largely based on patch by Dirk Opfer.
Todo: EAR_IN event support
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Index: linux-test/drivers/input/keyboard/Kconfig
===================================================================
--- linux-test.orig/drivers/input/keyboard/Kconfig 2007-12-10 18:31:15.279700301 +0300
+++ linux-test/drivers/input/keyboard/Kconfig 2007-12-10 18:31:23.903469072 +0300
@@ -154,6 +154,16 @@ config KEYBOARD_SPITZ
To compile this driver as a module, choose M here: the
module will be called spitzkbd.
+config KEYBOARD_TOSA
+ tristate "Tosa keyboard"
+ depends on MACH_TOSA
+ default y
+ help
+ Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
+
+ To compile this driver as a module, choose M here: the
+ module will be called tosakbd.
+
config KEYBOARD_AMIGA
tristate "Amiga keyboard"
depends on AMIGA
Index: linux-test/drivers/input/keyboard/Makefile
===================================================================
--- linux-test.orig/drivers/input/keyboard/Makefile 2007-12-10 18:31:15.291700345 +0300
+++ linux-test/drivers/input/keyboard/Makefile 2007-12-10 18:31:23.903469072 +0300
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newton
obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
+obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
Index: linux-test/drivers/input/keyboard/tosakbd.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-test/drivers/input/keyboard/tosakbd.c 2007-12-10 18:51:22.521513076 +0300
@@ -0,0 +1,415 @@
+/*
+ * Keyboard driver for Sharp Tosa models (SL-6000x)
+ *
+ * Copyright (c) 2005 Dirk Opfer
+ * Copyright (c) 2007 Dmitry Baryshkov
+ *
+ * Based on xtkbd.c/locomkbd.c/corgikbd.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <linux/input_pda.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/tosa.h>
+
+#define KB_ROWMASK(r) (1 << (r))
+#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
+#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1
+
+#define SCAN_INTERVAL (HZ/10)
+
+#define KB_DISCHARGE_DELAY 10
+#define KB_ACTIVATE_DELAY 10
+
+static unsigned int tosakbd_keycode[NR_SCANCODES] = {
+0,
+0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Z, KEY_C, KEY_V, KEY_J, _KEY_CONTACTS, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK,
+KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
+KEY_S, KEY_R, KEY_B, KEY_N, _KEY_CALENDAR, _KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT,
+0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
+KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0,
+0, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0,
+KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
+0, 0, 0,
+};
+
+struct tosakbd {
+ unsigned int keycode[ARRAY_SIZE(tosakbd_keycode)];
+ struct input_dev *input;
+
+ spinlock_t lock; /* protect kbd scanning */
+ struct timer_list timer;
+};
+
+
+/* Helper functions for reading the keyboard matrix
+ * Note: We should really be using pxa_gpio_mode to alter GPDR but it
+ * requires a function call per GPIO bit which is excessive
+ * when we need to access 12 bits at once, multiple times.
+ * These functions must be called within local_irq_save()/local_irq_restore()
+ * or similar.
+ */
+#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT)
+
+static inline void tosakbd_discharge_all(void)
+{
+ /* STROBE All HiZ */
+ GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
+ GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
+}
+
+static inline void tosakbd_activate_all(void)
+{
+ /* STROBE ALL -> High */
+ GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
+ GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
+
+ udelay(KB_DISCHARGE_DELAY);
+
+ /* STATE CLEAR */
+ GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
+}
+
+static inline void tosakbd_activate_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR1 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR2 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+
+static inline void tosakbd_reset_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> Low */
+ GPCR1 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> Low */
+ GPCR2 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+/*
+ * The tosa keyboard only generates interrupts when a key is pressed.
+ * So when a key is pressed, we enable a timer. This timer scans the
+ * keyboard, and this is how we detect when the key is released.
+ */
+
+/* Scan the hardware keyboard and push any changes up through the input layer */
+static void tosakbd_scankeyboard(struct platform_device *dev)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+ unsigned int row, col, rowd;
+ unsigned long flags;
+ unsigned int num_pressed = 0;
+
+ spin_lock_irqsave(&tosakbd->lock, flags);
+
+ for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
+ /*
+ * Discharge the output driver capacitatance
+ * in the keyboard matrix. (Yes it is significant..)
+ */
+ tosakbd_discharge_all();
+ udelay(KB_DISCHARGE_DELAY);
+
+ tosakbd_activate_col(col);
+ udelay(KB_ACTIVATE_DELAY);
+
+ rowd = GET_ROWS_STATUS(col);
+
+ for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
+ unsigned int scancode, pressed;
+ scancode = SCANCODE(row, col);
+ pressed = rowd & KB_ROWMASK(row);
+
+ if (pressed && !tosakbd->keycode[scancode])
+ dev_warn(&dev->dev,
+ "unhandled scancode: 0x%02x\n",
+ scancode);
+
+ input_report_key(tosakbd->input,
+ tosakbd->keycode[scancode],
+ pressed);
+ if (pressed)
+ num_pressed++;
+ }
+
+ tosakbd_reset_col(col);
+ }
+
+ tosakbd_activate_all();
+
+ input_sync(tosakbd->input);
+
+ /* if any keys are pressed, enable the timer */
+ if (num_pressed)
+ mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
+
+ spin_unlock_irqrestore(&tosakbd->lock, flags);
+}
+
+/*
+ * tosa keyboard interrupt handler.
+ */
+static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
+{
+ struct platform_device *dev = __dev;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ if (!timer_pending(&tosakbd->timer)) {
+ /** wait chattering delay **/
+ udelay(20);
+ tosakbd_scankeyboard(dev);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * tosa timer checking for released keys
+ */
+static void tosakbd_timer_callback(unsigned long __dev)
+{
+ struct platform_device *dev = (struct platform_device *)__dev;
+ tosakbd_scankeyboard(dev);
+}
+
+#ifdef CONFIG_PM
+static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+
+static int tosakbd_resume(struct platform_device *dev)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+#else
+#define tosakbd_suspend NULL
+#define tosakbd_resume NULL
+#endif
+
+static int __devinit tosakbd_probe(struct platform_device *pdev) {
+
+ int i;
+ struct tosakbd *tosakbd;
+ struct input_dev *input_dev;
+ int error;
+
+ tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
+ if (!tosakbd)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(tosakbd);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, tosakbd);
+
+ spin_lock_init(&tosakbd->lock);
+
+ /* Init Keyboard rescan timer */
+ init_timer(&tosakbd->timer);
+ tosakbd->timer.function = tosakbd_timer_callback;
+ tosakbd->timer.data = (unsigned long) pdev;
+
+ tosakbd->input = input_dev;
+
+ input_dev->private = tosakbd;
+ input_dev->name = "Tosa Keyboard";
+ input_dev->phys = "tosakbd/input0";
+ input_dev->cdev.dev = &pdev->dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = tosakbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned int);
+ input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
+
+ memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
+
+ for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
+ set_bit(tosakbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_SENSE(i);
+ int irq;
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail;
+ }
+
+ error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ irq = gpio_to_irq(gpio);
+ if (irq < 0) {
+ error = irq;
+ printk(KERN_ERR "gpio-keys: Unable to get irq number"
+ " for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ error = request_irq(irq, tosakbd_interrupt,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING,
+ "tosakbd", pdev);
+
+ if (error) {
+ printk("tosakbd: Can't get IRQ: %d: error %d!\n",
+ irq, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+ }
+
+ /* Set Strobe lines as outputs - set high */
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_STROBE(i);
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail2;
+ }
+
+ error = gpio_direction_output(gpio, 1);
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ printk(KERN_ERR "tosakbd: Unable to register input device, "
+ "error: %d\n", error);
+ goto fail;
+ }
+
+ printk(KERN_INFO "input: Tosa Keyboard Registered\n");
+
+ return 0;
+
+fail2:
+ while (--i >= 0)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ i = TOSA_KEY_SENSE_NUM;
+fail:
+ while (--i >= 0) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ platform_set_drvdata(pdev, NULL);
+ input_free_device(input_dev);
+ kfree(tosakbd);
+
+ return error;
+}
+
+static int __devexit tosakbd_remove(struct platform_device *dev) {
+
+ int i;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ del_timer_sync(&tosakbd->timer);
+
+ input_unregister_device(tosakbd->input);
+
+ kfree(tosakbd);
+
+ return 0;
+}
+
+static struct platform_driver tosakbd_driver = {
+ .probe = tosakbd_probe,
+ .remove = __devexit_p(tosakbd_remove),
+ .suspend = tosakbd_suspend,
+ .resume = tosakbd_resume,
+ .driver = {
+ .name = "tosa-keyboard",
+ },
+};
+
+static int __devinit tosakbd_init(void)
+{
+ return platform_driver_register(&tosakbd_driver);
+}
+
+static void __exit tosakbd_exit(void)
+{
+ platform_driver_unregister(&tosakbd_driver);
+}
+
+module_init(tosakbd_init);
+module_exit(tosakbd_exit);
+
+MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
+MODULE_DESCRIPTION("Tosa Keyboard Driver");
+MODULE_LICENSE("GPL v2");
Index: linux-test/arch/arm/mach-pxa/tosa.c
===================================================================
--- linux-test.orig/arch/arm/mach-pxa/tosa.c 2007-12-09 14:18:57.530296394 +0300
+++ linux-test/arch/arm/mach-pxa/tosa.c 2007-12-10 18:34:51.438565401 +0300
@@ -27,6 +27,9 @@
#include <linux/pm.h>
#include <linux/delay.h>
#include <linux/fb.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
+#include <linux/input_pda.h>
#include <asm/setup.h>
#include <asm/memory.h>
@@ -434,6 +437,45 @@ static struct tc6393xb_platform_data tos
.fb_data = &tosa_tc6393xb_fb_config,
};
+static struct gpio_keys_button tosa_gpio_keys[] = {
+ {
+ .type = EV_PWR,
+ .code = KEY_SUSPEND,
+ .gpio = TOSA_GPIO_ON_KEY,
+ .desc = "On key",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = _KEY_RECORD,
+ .gpio = TOSA_GPIO_RECORD_BTN,
+ .desc = "Record Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_SYNC,
+ .gpio = TOSA_GPIO_SYNC,
+ .desc = "Sync Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
+ .buttons = tosa_gpio_keys,
+ .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
+};
+
+static struct platform_device tosa_gpio_keys_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = {
+ .platform_data = &tosa_gpio_keys_platform_data,
+ },
+};
struct platform_device tc6393xb_device = {
.name = "tc6393xb",
@@ -450,6 +492,7 @@ static struct platform_device *devices[]
&tosascoop_device,
&tosascoop_jc_device,
&tosakbd_device,
+ &tosa_gpio_keys_device,
&tosaled_device,
&tosa_bluetooth_device,
&tc6393xb_device,
Index: linux-test/include/asm-arm/arch-pxa/tosa.h
===================================================================
--- linux-test.orig/include/asm-arm/arch-pxa/tosa.h 2007-12-10 18:32:50.547713109 +0300
+++ linux-test/include/asm-arm/arch-pxa/tosa.h 2007-12-10 19:13:30.451457377 +0300
@@ -187,4 +187,13 @@
extern struct platform_device tosascoop_jc_device;
extern struct platform_device tosascoop_device;
extern struct platform_device tc6393xb_device;
+
+#define TOSA_KEY_SYNC KEY_F1 /* ??? */
+#define TOSA_KEY_OK KEY_F2 /* KEY_OK */
+#define TOSA_KEY_FN KEY_F3 /* KEY_FN */
+#define TOSA_KEY_CANCEL KEY_F4 /* KEY_CANCEL */
+#define TOSA_KEY_CENTER KEY_F5 /* ??? */
+#define TOSA_KEY_MENU KEY_F6 /* KEY_MENU */
+#define TOSA_KEY_LIGHT KEY_F7 /* KEY_SWITCHVIDEOMODE */
+
#endif /* _ASM_ARCH_TOSA_H_ */
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2007-12-11 15:23 [PATCH] Tosa keyboard support Dmitry Baryshkov
@ 2007-12-11 15:38 ` Dmitry Baryshkov
2007-12-16 10:29 ` Russell King - ARM Linux
2007-12-16 10:51 ` Dmitry
0 siblings, 2 replies; 12+ messages in thread
From: Dmitry Baryshkov @ 2007-12-11 15:38 UTC (permalink / raw)
To: linux-input
Cc: linux-kernel, dirk, dmitry.torokhov, linux-arm-kernel,
Marcin Juszkiewicz
Hi,
Sorry, posted wrong version of patch. Here is correct version:
Support keyboard on tosa (Sharp Zaurus SL-6000x).
Largely based on patches by Dirk Opfer.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Index: tosa-tree/drivers/input/keyboard/Kconfig
===================================================================
--- tosa-tree.orig/drivers/input/keyboard/Kconfig 2007-12-06 02:50:47.718066027 +0300
+++ tosa-tree/drivers/input/keyboard/Kconfig 2007-12-11 18:20:44.740234154 +0300
@@ -154,6 +154,16 @@ config KEYBOARD_SPITZ
To compile this driver as a module, choose M here: the
module will be called spitzkbd.
+config KEYBOARD_TOSA
+ tristate "Tosa keyboard"
+ depends on MACH_TOSA
+ default y
+ help
+ Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
+
+ To compile this driver as a module, choose M here: the
+ module will be called tosakbd.
+
config KEYBOARD_AMIGA
tristate "Amiga keyboard"
depends on AMIGA
Index: tosa-tree/drivers/input/keyboard/Makefile
===================================================================
--- tosa-tree.orig/drivers/input/keyboard/Makefile 2007-12-06 02:50:47.718066027 +0300
+++ tosa-tree/drivers/input/keyboard/Makefile 2007-12-11 18:20:44.752234128 +0300
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newton
obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
+obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
Index: tosa-tree/drivers/input/keyboard/tosakbd.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ tosa-tree/drivers/input/keyboard/tosakbd.c 2007-12-11 18:34:22.050680080 +0300
@@ -0,0 +1,413 @@
+/*
+ * Keyboard driver for Sharp Tosa models (SL-6000x)
+ *
+ * Copyright (c) 2005 Dirk Opfer
+ * Copyright (c) 2007 Dmitry Baryshkov
+ *
+ * Based on xtkbd.c/locomkbd.c/corgikbd.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/tosa.h>
+
+#define KB_ROWMASK(r) (1 << (r))
+#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
+#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1
+
+#define SCAN_INTERVAL (HZ/10)
+
+#define KB_DISCHARGE_DELAY 10
+#define KB_ACTIVATE_DELAY 10
+
+static unsigned int tosakbd_keycode[NR_SCANCODES] = {
+0,
+0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Z, KEY_C, KEY_V, KEY_J, KEY_ADDRESSBOOK, KEY_CANCEL, TOSA_KEY_CENTER, KEY_OK,
+KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
+KEY_S, KEY_R, KEY_B, KEY_N, KEY_CALENDAR, KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT,
+0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
+KEY_TAB, KEY_SLASH, KEY_H, KEY_M, KEY_MENU, 0, KEY_UP, 0,
+0, 0, KEY_FN, 0, 0, 0, 0, 0,
+KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
+0, 0, 0,
+};
+
+struct tosakbd {
+ unsigned int keycode[ARRAY_SIZE(tosakbd_keycode)];
+ struct input_dev *input;
+
+ spinlock_t lock; /* protect kbd scanning */
+ struct timer_list timer;
+};
+
+
+/* Helper functions for reading the keyboard matrix
+ * Note: We should really be using pxa_gpio_mode to alter GPDR but it
+ * requires a function call per GPIO bit which is excessive
+ * when we need to access 12 bits at once, multiple times.
+ * These functions must be called within local_irq_save()/local_irq_restore()
+ * or similar.
+ */
+#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT)
+
+static inline void tosakbd_discharge_all(void)
+{
+ /* STROBE All HiZ */
+ GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
+ GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
+}
+
+static inline void tosakbd_activate_all(void)
+{
+ /* STROBE ALL -> High */
+ GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
+ GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
+
+ udelay(KB_DISCHARGE_DELAY);
+
+ /* STATE CLEAR */
+ GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
+}
+
+static inline void tosakbd_activate_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR1 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR2 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+
+static inline void tosakbd_reset_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> Low */
+ GPCR1 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> Low */
+ GPCR2 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+/*
+ * The tosa keyboard only generates interrupts when a key is pressed.
+ * So when a key is pressed, we enable a timer. This timer scans the
+ * keyboard, and this is how we detect when the key is released.
+ */
+
+/* Scan the hardware keyboard and push any changes up through the input layer */
+static void tosakbd_scankeyboard(struct platform_device *dev)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+ unsigned int row, col, rowd;
+ unsigned long flags;
+ unsigned int num_pressed = 0;
+
+ spin_lock_irqsave(&tosakbd->lock, flags);
+
+ for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
+ /*
+ * Discharge the output driver capacitatance
+ * in the keyboard matrix. (Yes it is significant..)
+ */
+ tosakbd_discharge_all();
+ udelay(KB_DISCHARGE_DELAY);
+
+ tosakbd_activate_col(col);
+ udelay(KB_ACTIVATE_DELAY);
+
+ rowd = GET_ROWS_STATUS(col);
+
+ for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
+ unsigned int scancode, pressed;
+ scancode = SCANCODE(row, col);
+ pressed = rowd & KB_ROWMASK(row);
+
+ if (pressed && !tosakbd->keycode[scancode])
+ dev_warn(&dev->dev,
+ "unhandled scancode: 0x%02x\n",
+ scancode);
+
+ input_report_key(tosakbd->input,
+ tosakbd->keycode[scancode],
+ pressed);
+ if (pressed)
+ num_pressed++;
+ }
+
+ tosakbd_reset_col(col);
+ }
+
+ tosakbd_activate_all();
+
+ input_sync(tosakbd->input);
+
+ /* if any keys are pressed, enable the timer */
+ if (num_pressed)
+ mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
+
+ spin_unlock_irqrestore(&tosakbd->lock, flags);
+}
+
+/*
+ * tosa keyboard interrupt handler.
+ */
+static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
+{
+ struct platform_device *dev = __dev;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ if (!timer_pending(&tosakbd->timer)) {
+ /** wait chattering delay **/
+ udelay(20);
+ tosakbd_scankeyboard(dev);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * tosa timer checking for released keys
+ */
+static void tosakbd_timer_callback(unsigned long __dev)
+{
+ struct platform_device *dev = (struct platform_device *)__dev;
+ tosakbd_scankeyboard(dev);
+}
+
+#ifdef CONFIG_PM
+static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+
+static int tosakbd_resume(struct platform_device *dev)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+#else
+#define tosakbd_suspend NULL
+#define tosakbd_resume NULL
+#endif
+
+static int __devinit tosakbd_probe(struct platform_device *pdev) {
+
+ int i;
+ struct tosakbd *tosakbd;
+ struct input_dev *input_dev;
+ int error;
+
+ tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
+ if (!tosakbd)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(tosakbd);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, tosakbd);
+
+ spin_lock_init(&tosakbd->lock);
+
+ /* Init Keyboard rescan timer */
+ init_timer(&tosakbd->timer);
+ tosakbd->timer.function = tosakbd_timer_callback;
+ tosakbd->timer.data = (unsigned long) pdev;
+
+ tosakbd->input = input_dev;
+
+ input_dev->private = tosakbd;
+ input_dev->name = "Tosa Keyboard";
+ input_dev->phys = "tosakbd/input0";
+ input_dev->cdev.dev = &pdev->dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = tosakbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned int);
+ input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
+
+ memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
+
+ for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
+ set_bit(tosakbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_SENSE(i);
+ int irq;
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail;
+ }
+
+ error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ irq = gpio_to_irq(gpio);
+ if (irq < 0) {
+ error = irq;
+ printk(KERN_ERR "gpio-keys: Unable to get irq number"
+ " for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ error = request_irq(irq, tosakbd_interrupt,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING,
+ "tosakbd", pdev);
+
+ if (error) {
+ printk("tosakbd: Can't get IRQ: %d: error %d!\n",
+ irq, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+ }
+
+ /* Set Strobe lines as outputs - set high */
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_STROBE(i);
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail2;
+ }
+
+ error = gpio_direction_output(gpio, 1);
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ printk(KERN_ERR "tosakbd: Unable to register input device, "
+ "error: %d\n", error);
+ goto fail;
+ }
+
+ printk(KERN_INFO "input: Tosa Keyboard Registered\n");
+
+ return 0;
+
+fail2:
+ while (--i >= 0)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ i = TOSA_KEY_SENSE_NUM;
+fail:
+ while (--i >= 0) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ platform_set_drvdata(pdev, NULL);
+ input_free_device(input_dev);
+ kfree(tosakbd);
+
+ return error;
+}
+
+static int __devexit tosakbd_remove(struct platform_device *dev) {
+
+ int i;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ del_timer_sync(&tosakbd->timer);
+
+ input_unregister_device(tosakbd->input);
+
+ kfree(tosakbd);
+
+ return 0;
+}
+
+static struct platform_driver tosakbd_driver = {
+ .probe = tosakbd_probe,
+ .remove = __devexit_p(tosakbd_remove),
+ .suspend = tosakbd_suspend,
+ .resume = tosakbd_resume,
+ .driver = {
+ .name = "tosa-keyboard",
+ },
+};
+
+static int __devinit tosakbd_init(void)
+{
+ return platform_driver_register(&tosakbd_driver);
+}
+
+static void __exit tosakbd_exit(void)
+{
+ platform_driver_unregister(&tosakbd_driver);
+}
+
+module_init(tosakbd_init);
+module_exit(tosakbd_exit);
+
+MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
+MODULE_DESCRIPTION("Tosa Keyboard Driver");
+MODULE_LICENSE("GPL v2");
Index: tosa-tree/arch/arm/mach-pxa/tosa.c
===================================================================
--- tosa-tree.orig/arch/arm/mach-pxa/tosa.c 2007-12-09 14:21:21.621301924 +0300
+++ tosa-tree/arch/arm/mach-pxa/tosa.c 2007-12-11 18:30:21.576224368 +0300
@@ -27,6 +27,8 @@
#include <linux/pm.h>
#include <linux/delay.h>
#include <linux/fb.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <asm/setup.h>
#include <asm/memory.h>
@@ -426,6 +428,45 @@ static struct tc6393xb_platform_data tos
.fb_data = &tosa_tc6393xb_fb_config,
};
+static struct gpio_keys_button tosa_gpio_keys[] = {
+ {
+ .type = EV_PWR,
+ .code = KEY_SUSPEND,
+ .gpio = TOSA_GPIO_ON_KEY,
+ .desc = "On key",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = KEY_RECORD,
+ .gpio = TOSA_GPIO_RECORD_BTN,
+ .desc = "Record Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_SYNC,
+ .gpio = TOSA_GPIO_SYNC,
+ .desc = "Sync Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
+ .buttons = tosa_gpio_keys,
+ .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
+};
+
+static struct platform_device tosa_gpio_keys_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = {
+ .platform_data = &tosa_gpio_keys_platform_data,
+ },
+};
struct platform_device tc6393xb_device = {
.name = "tc6393xb",
@@ -442,6 +483,7 @@ static struct platform_device *devices[]
&tosascoop_device,
&tosascoop_jc_device,
&tosakbd_device,
+ &tosa_gpio_keys_device,
&tosaled_device,
&tc6393xb_device,
};
Index: tosa-tree/include/asm-arm/arch-pxa/tosa.h
===================================================================
--- tosa-tree.orig/include/asm-arm/arch-pxa/tosa.h 2007-12-09 14:21:21.657311276 +0300
+++ tosa-tree/include/asm-arm/arch-pxa/tosa.h 2007-12-11 18:34:49.423778408 +0300
@@ -187,4 +187,9 @@
extern struct platform_device tosascoop_jc_device;
extern struct platform_device tosascoop_device;
extern struct platform_device tc6393xb_device;
+
+#define TOSA_KEY_SYNC KEY_F1 /* ??? */
+#define TOSA_KEY_CENTER KEY_SELECT /* ??? */
+#define TOSA_KEY_LIGHT KEY_SWITCHVIDEOMODE /* ??? */
+
#endif /* _ASM_ARCH_TOSA_H_ */
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2007-12-11 15:38 ` Dmitry Baryshkov
@ 2007-12-16 10:29 ` Russell King - ARM Linux
2007-12-16 10:52 ` Dmitry
2007-12-16 10:51 ` Dmitry
1 sibling, 1 reply; 12+ messages in thread
From: Russell King - ARM Linux @ 2007-12-16 10:29 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: linux-input, Marcin Juszkiewicz, dmitry.torokhov, linux-kernel,
linux-arm-kernel
On Tue, Dec 11, 2007 at 06:38:51PM +0300, Dmitry Baryshkov wrote:
> Sorry, posted wrong version of patch. Here is correct version:
>
> Support keyboard on tosa (Sharp Zaurus SL-6000x).
> Largely based on patches by Dirk Opfer.
Looks fine to me, but Dmitry Torokhov needs to look at it; he maintains
the input subsystem. Note that the current input subsystem mailing list
is not the one you have in the CC line - please always check MAINTAINERS
for the correct addresses.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] Tosa keyboard support
2007-12-11 15:38 ` Dmitry Baryshkov
2007-12-16 10:29 ` Russell King - ARM Linux
@ 2007-12-16 10:51 ` Dmitry
1 sibling, 0 replies; 12+ messages in thread
From: Dmitry @ 2007-12-16 10:51 UTC (permalink / raw)
To: linux-input
Hi,
Sorry, posted wrong version of patch. Here is correct version:
Support keyboard on tosa (Sharp Zaurus SL-6000x).
Largely based on patches by Dirk Opfer.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Index: tosa-tree/drivers/input/keyboard/Kconfig
===================================================================
--- tosa-tree.orig/drivers/input/keyboard/Kconfig 2007-12-06
02:50:47.718066027 +0300
+++ tosa-tree/drivers/input/keyboard/Kconfig 2007-12-11
18:20:44.740234154 +0300
@@ -154,6 +154,16 @@ config KEYBOARD_SPITZ
To compile this driver as a module, choose M here: the
module will be called spitzkbd.
+config KEYBOARD_TOSA
+ tristate "Tosa keyboard"
+ depends on MACH_TOSA
+ default y
+ help
+ Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
+
+ To compile this driver as a module, choose M here: the
+ module will be called tosakbd.
+
config KEYBOARD_AMIGA
tristate "Amiga keyboard"
depends on AMIGA
Index: tosa-tree/drivers/input/keyboard/Makefile
===================================================================
--- tosa-tree.orig/drivers/input/keyboard/Makefile 2007-12-06
02:50:47.718066027 +0300
+++ tosa-tree/drivers/input/keyboard/Makefile 2007-12-11
18:20:44.752234128 +0300
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newton
obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
+obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
Index: tosa-tree/drivers/input/keyboard/tosakbd.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ tosa-tree/drivers/input/keyboard/tosakbd.c 2007-12-11
18:34:22.050680080 +0300
@@ -0,0 +1,413 @@
+/*
+ * Keyboard driver for Sharp Tosa models (SL-6000x)
+ *
+ * Copyright (c) 2005 Dirk Opfer
+ * Copyright (c) 2007 Dmitry Baryshkov
+ *
+ * Based on xtkbd.c/locomkbd.c/corgikbd.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/tosa.h>
+
+#define KB_ROWMASK(r) (1 << (r))
+#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
+#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1,
TOSA_KEY_STROBE_NUM - 1) + 1
+
+#define SCAN_INTERVAL (HZ/10)
+
+#define KB_DISCHARGE_DELAY 10
+#define KB_ACTIVATE_DELAY 10
+
+static unsigned int tosakbd_keycode[NR_SCANCODES] = {
+0,
+0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Z, KEY_C, KEY_V, KEY_J, KEY_ADDRESSBOOK, KEY_CANCEL,
TOSA_KEY_CENTER, KEY_OK,
+KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
+KEY_S, KEY_R, KEY_B, KEY_N, KEY_CALENDAR, KEY_HOMEPAGE, KEY_LEFTCTRL,
TOSA_KEY_LIGHT,
+0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
+KEY_TAB, KEY_SLASH, KEY_H, KEY_M, KEY_MENU, 0, KEY_UP, 0,
+0, 0, KEY_FN, 0, 0, 0, 0, 0,
+KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, KEY_MAIL, KEY_LEFT,
KEY_DOWN, KEY_RIGHT,
+0, 0, 0,
+};
+
+struct tosakbd {
+ unsigned int keycode[ARRAY_SIZE(tosakbd_keycode)];
+ struct input_dev *input;
+
+ spinlock_t lock; /* protect kbd scanning */
+ struct timer_list timer;
+};
+
+
+/* Helper functions for reading the keyboard matrix
+ * Note: We should really be using pxa_gpio_mode to alter GPDR but it
+ * requires a function call per GPIO bit which is excessive
+ * when we need to access 12 bits at once, multiple times.
+ * These functions must be called within local_irq_save()/local_irq_restore()
+ * or similar.
+ */
+#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >>
TOSA_GPIO_ALL_SENSE_RSHIFT)
+
+static inline void tosakbd_discharge_all(void)
+{
+ /* STROBE All HiZ */
+ GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
+ GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
+}
+
+static inline void tosakbd_activate_all(void)
+{
+ /* STROBE ALL -> High */
+ GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
+ GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
+
+ udelay(KB_DISCHARGE_DELAY);
+
+ /* STATE CLEAR */
+ GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
+}
+
+static inline void tosakbd_activate_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR1 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) |
TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR2 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) |
TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+
+static inline void tosakbd_reset_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> Low */
+ GPCR1 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) |
TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> Low */
+ GPCR2 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) |
TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+/*
+ * The tosa keyboard only generates interrupts when a key is pressed.
+ * So when a key is pressed, we enable a timer. This timer scans the
+ * keyboard, and this is how we detect when the key is released.
+ */
+
+/* Scan the hardware keyboard and push any changes up through the
input layer */
+static void tosakbd_scankeyboard(struct platform_device *dev)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+ unsigned int row, col, rowd;
+ unsigned long flags;
+ unsigned int num_pressed = 0;
+
+ spin_lock_irqsave(&tosakbd->lock, flags);
+
+ for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
+ /*
+ * Discharge the output driver capacitatance
+ * in the keyboard matrix. (Yes it is significant..)
+ */
+ tosakbd_discharge_all();
+ udelay(KB_DISCHARGE_DELAY);
+
+ tosakbd_activate_col(col);
+ udelay(KB_ACTIVATE_DELAY);
+
+ rowd = GET_ROWS_STATUS(col);
+
+ for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
+ unsigned int scancode, pressed;
+ scancode = SCANCODE(row, col);
+ pressed = rowd & KB_ROWMASK(row);
+
+ if (pressed && !tosakbd->keycode[scancode])
+ dev_warn(&dev->dev,
+ "unhandled scancode: 0x%02x\n",
+ scancode);
+
+ input_report_key(tosakbd->input,
+ tosakbd->keycode[scancode],
+ pressed);
+ if (pressed)
+ num_pressed++;
+ }
+
+ tosakbd_reset_col(col);
+ }
+
+ tosakbd_activate_all();
+
+ input_sync(tosakbd->input);
+
+ /* if any keys are pressed, enable the timer */
+ if (num_pressed)
+ mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
+
+ spin_unlock_irqrestore(&tosakbd->lock, flags);
+}
+
+/*
+ * tosa keyboard interrupt handler.
+ */
+static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
+{
+ struct platform_device *dev = __dev;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ if (!timer_pending(&tosakbd->timer)) {
+ /** wait chattering delay **/
+ udelay(20);
+ tosakbd_scankeyboard(dev);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * tosa timer checking for released keys
+ */
+static void tosakbd_timer_callback(unsigned long __dev)
+{
+ struct platform_device *dev = (struct platform_device *)__dev;
+ tosakbd_scankeyboard(dev);
+}
+
+#ifdef CONFIG_PM
+static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+
+static int tosakbd_resume(struct platform_device *dev)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+#else
+#define tosakbd_suspend NULL
+#define tosakbd_resume NULL
+#endif
+
+static int __devinit tosakbd_probe(struct platform_device *pdev) {
+
+ int i;
+ struct tosakbd *tosakbd;
+ struct input_dev *input_dev;
+ int error;
+
+ tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
+ if (!tosakbd)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(tosakbd);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, tosakbd);
+
+ spin_lock_init(&tosakbd->lock);
+
+ /* Init Keyboard rescan timer */
+ init_timer(&tosakbd->timer);
+ tosakbd->timer.function = tosakbd_timer_callback;
+ tosakbd->timer.data = (unsigned long) pdev;
+
+ tosakbd->input = input_dev;
+
+ input_dev->private = tosakbd;
+ input_dev->name = "Tosa Keyboard";
+ input_dev->phys = "tosakbd/input0";
+ input_dev->cdev.dev = &pdev->dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = tosakbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned int);
+ input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
+
+ memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
+
+ for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
+ set_bit(tosakbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_SENSE(i);
+ int irq;
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail;
+ }
+
+ error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ irq = gpio_to_irq(gpio);
+ if (irq < 0) {
+ error = irq;
+ printk(KERN_ERR "gpio-keys: Unable to get irq number"
+ " for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ error = request_irq(irq, tosakbd_interrupt,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING,
+ "tosakbd", pdev);
+
+ if (error) {
+ printk("tosakbd: Can't get IRQ: %d: error %d!\n",
+ irq, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+ }
+
+ /* Set Strobe lines as outputs - set high */
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_STROBE(i);
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail2;
+ }
+
+ error = gpio_direction_output(gpio, 1);
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ printk(KERN_ERR "tosakbd: Unable to register input device, "
+ "error: %d\n", error);
+ goto fail;
+ }
+
+ printk(KERN_INFO "input: Tosa Keyboard Registered\n");
+
+ return 0;
+
+fail2:
+ while (--i >= 0)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ i = TOSA_KEY_SENSE_NUM;
+fail:
+ while (--i >= 0) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ platform_set_drvdata(pdev, NULL);
+ input_free_device(input_dev);
+ kfree(tosakbd);
+
+ return error;
+}
+
+static int __devexit tosakbd_remove(struct platform_device *dev) {
+
+ int i;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ del_timer_sync(&tosakbd->timer);
+
+ input_unregister_device(tosakbd->input);
+
+ kfree(tosakbd);
+
+ return 0;
+}
+
+static struct platform_driver tosakbd_driver = {
+ .probe = tosakbd_probe,
+ .remove = __devexit_p(tosakbd_remove),
+ .suspend = tosakbd_suspend,
+ .resume = tosakbd_resume,
+ .driver = {
+ .name = "tosa-keyboard",
+ },
+};
+
+static int __devinit tosakbd_init(void)
+{
+ return platform_driver_register(&tosakbd_driver);
+}
+
+static void __exit tosakbd_exit(void)
+{
+ platform_driver_unregister(&tosakbd_driver);
+}
+
+module_init(tosakbd_init);
+module_exit(tosakbd_exit);
+
+MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
+MODULE_DESCRIPTION("Tosa Keyboard Driver");
+MODULE_LICENSE("GPL v2");
Index: tosa-tree/arch/arm/mach-pxa/tosa.c
===================================================================
--- tosa-tree.orig/arch/arm/mach-pxa/tosa.c 2007-12-09
14:21:21.621301924 +0300
+++ tosa-tree/arch/arm/mach-pxa/tosa.c 2007-12-11 18:30:21.576224368 +0300
@@ -27,6 +27,8 @@
#include <linux/pm.h>
#include <linux/delay.h>
#include <linux/fb.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <asm/setup.h>
#include <asm/memory.h>
@@ -426,6 +428,45 @@ static struct tc6393xb_platform_data tos
.fb_data = &tosa_tc6393xb_fb_config,
};
+static struct gpio_keys_button tosa_gpio_keys[] = {
+ {
+ .type = EV_PWR,
+ .code = KEY_SUSPEND,
+ .gpio = TOSA_GPIO_ON_KEY,
+ .desc = "On key",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = KEY_RECORD,
+ .gpio = TOSA_GPIO_RECORD_BTN,
+ .desc = "Record Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_SYNC,
+ .gpio = TOSA_GPIO_SYNC,
+ .desc = "Sync Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
+ .buttons = tosa_gpio_keys,
+ .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
+};
+
+static struct platform_device tosa_gpio_keys_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = {
+ .platform_data = &tosa_gpio_keys_platform_data,
+ },
+};
struct platform_device tc6393xb_device = {
.name = "tc6393xb",
@@ -442,6 +483,7 @@ static struct platform_device *devices[]
&tosascoop_device,
&tosascoop_jc_device,
&tosakbd_device,
+ &tosa_gpio_keys_device,
&tosaled_device,
&tc6393xb_device,
};
Index: tosa-tree/include/asm-arm/arch-pxa/tosa.h
===================================================================
--- tosa-tree.orig/include/asm-arm/arch-pxa/tosa.h 2007-12-09
14:21:21.657311276 +0300
+++ tosa-tree/include/asm-arm/arch-pxa/tosa.h 2007-12-11
18:34:49.423778408 +0300
@@ -187,4 +187,9 @@
extern struct platform_device tosascoop_jc_device;
extern struct platform_device tosascoop_device;
extern struct platform_device tc6393xb_device;
+
+#define TOSA_KEY_SYNC KEY_F1 /* ??? */
+#define TOSA_KEY_CENTER KEY_SELECT /* ??? */
+#define TOSA_KEY_LIGHT KEY_SWITCHVIDEOMODE /* ??? */
+
#endif /* _ASM_ARCH_TOSA_H_ */
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2007-12-16 10:29 ` Russell King - ARM Linux
@ 2007-12-16 10:52 ` Dmitry
0 siblings, 0 replies; 12+ messages in thread
From: Dmitry @ 2007-12-16 10:52 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-input, Marcin Juszkiewicz, dmitry.torokhov, linux-kernel,
linux-arm-kernel
Hi,
2007/12/16, Russell King - ARM Linux <linux@arm.linux.org.uk>:
> On Tue, Dec 11, 2007 at 06:38:51PM +0300, Dmitry Baryshkov wrote:
> > Sorry, posted wrong version of patch. Here is correct version:
> >
> > Support keyboard on tosa (Sharp Zaurus SL-6000x).
> > Largely based on patches by Dirk Opfer.
>
> Looks fine to me, but Dmitry Torokhov needs to look at it; he maintains
> the input subsystem. Note that the current input subsystem mailing list
> is not the one you have in the CC line - please always check MAINTAINERS
> for the correct addresses.
>
Ok, thanks,
resent to linux-input.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] Tosa keyboard support
@ 2007-12-23 23:29 Dmitry Baryshkov
2008-01-03 16:51 ` Dmitry Torokhov
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Baryshkov @ 2007-12-23 23:29 UTC (permalink / raw)
To: linux-arm-kernel, linux-input, dmitry.torokhov
> From b213bef91e3f98c6104138050ad4eaa0a54e765d Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
Date: Mon, 24 Dec 2007 02:15:34 +0300
Subject: [PATCH] Tosa keyboard support
Support keyboard on tosa (Sharp Zaurus SL-6000x).
Largely based on patches by Dirk Opfer.
This is the final version that supports switching between
full keycode range and range available to the console and
keyb Kdrive driver.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
---
arch/arm/mach-pxa/tosa.c | 43 ++++
drivers/input/keyboard/Kconfig | 21 ++
drivers/input/keyboard/Makefile | 1 +
drivers/input/keyboard/tosakbd.c | 413 ++++++++++++++++++++++++++++++++++++++
include/asm-arm/arch-pxa/tosa.h | 30 +++
5 files changed, 508 insertions(+), 0 deletions(-)
create mode 100644 drivers/input/keyboard/tosakbd.c
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 240fd04..e7e0f52 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -21,6 +21,8 @@
#include <linux/mmc/host.h>
#include <linux/pm.h>
#include <linux/delay.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <asm/setup.h>
#include <asm/memory.h>
@@ -253,6 +255,46 @@ static struct platform_device tosakbd_device = {
.id = -1,
};
+static struct gpio_keys_button tosa_gpio_keys[] = {
+ {
+ .type = EV_PWR,
+ .code = KEY_SUSPEND,
+ .gpio = TOSA_GPIO_ON_KEY,
+ .desc = "On key",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_RECORD,
+ .gpio = TOSA_GPIO_RECORD_BTN,
+ .desc = "Record Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_SYNC,
+ .gpio = TOSA_GPIO_SYNC,
+ .desc = "Sync Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
+ .buttons = tosa_gpio_keys,
+ .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
+};
+
+static struct platform_device tosa_gpio_keys_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = {
+ .platform_data = &tosa_gpio_keys_platform_data,
+ },
+};
+
/*
* Tosa LEDs
*/
@@ -265,6 +307,7 @@ static struct platform_device *devices[] __initdata = {
&tosascoop_device,
&tosascoop_jc_device,
&tosakbd_device,
+ &tosa_gpio_keys_device,
&tosaled_device,
};
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index dfa6592..a60d43a 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -154,6 +154,27 @@ config KEYBOARD_SPITZ
To compile this driver as a module, choose M here: the
module will be called spitzkbd.
+config KEYBOARD_TOSA
+ tristate "Tosa keyboard"
+ depends on MACH_TOSA
+ default y
+ help
+ Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
+
+ To compile this driver as a module, choose M here: the
+ module will be called tosakbd.
+
+config KEYBOARD_TOSA_USE_EXT_KEYCODES
+ bool "Tosa keyboard: use extended keycodes"
+ depends on KEYBOARD_TOSA
+ default n
+ help
+ Say Y here to enable the tosa keyboard driver to generate extended
+ (>= 127) keycodes. Be aware, that they can't be correctly interpreted
+ by either console keyboard driver or by Kdrive keybd driver.
+
+ Say Y only if you know, what you are doing!
+
config KEYBOARD_AMIGA
tristate "Amiga keyboard"
depends on AMIGA
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e97455f..6caa065 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
+obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
diff --git a/drivers/input/keyboard/tosakbd.c b/drivers/input/keyboard/tosakbd.c
new file mode 100644
index 0000000..67c74d2
--- /dev/null
+++ b/drivers/input/keyboard/tosakbd.c
@@ -0,0 +1,413 @@
+/*
+ * Keyboard driver for Sharp Tosa models (SL-6000x)
+ *
+ * Copyright (c) 2005 Dirk Opfer
+ * Copyright (c) 2007 Dmitry Baryshkov
+ *
+ * Based on xtkbd.c/locomkbd.c/corgikbd.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/tosa.h>
+
+#define KB_ROWMASK(r) (1 << (r))
+#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
+#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1
+
+#define SCAN_INTERVAL (HZ/10)
+
+#define KB_DISCHARGE_DELAY 10
+#define KB_ACTIVATE_DELAY 10
+
+static unsigned int tosakbd_keycode[NR_SCANCODES] = {
+0,
+0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Z, KEY_C, KEY_V, KEY_J, TOSA_KEY_ADDRESSBOOK, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK,
+KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
+KEY_S, KEY_R, KEY_B, KEY_N, TOSA_KEY_CALENDAR, TOSA_KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT,
+0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
+KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0,
+0, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0,
+KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, TOSA_KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
+0, 0, 0,
+};
+
+struct tosakbd {
+ unsigned int keycode[ARRAY_SIZE(tosakbd_keycode)];
+ struct input_dev *input;
+
+ spinlock_t lock; /* protect kbd scanning */
+ struct timer_list timer;
+};
+
+
+/* Helper functions for reading the keyboard matrix
+ * Note: We should really be using pxa_gpio_mode to alter GPDR but it
+ * requires a function call per GPIO bit which is excessive
+ * when we need to access 12 bits at once, multiple times.
+ * These functions must be called within local_irq_save()/local_irq_restore()
+ * or similar.
+ */
+#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT)
+
+static inline void tosakbd_discharge_all(void)
+{
+ /* STROBE All HiZ */
+ GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
+ GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
+}
+
+static inline void tosakbd_activate_all(void)
+{
+ /* STROBE ALL -> High */
+ GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
+ GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
+
+ udelay(KB_DISCHARGE_DELAY);
+
+ /* STATE CLEAR */
+ GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
+}
+
+static inline void tosakbd_activate_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR1 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR2 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+
+static inline void tosakbd_reset_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> Low */
+ GPCR1 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> Low */
+ GPCR2 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+/*
+ * The tosa keyboard only generates interrupts when a key is pressed.
+ * So when a key is pressed, we enable a timer. This timer scans the
+ * keyboard, and this is how we detect when the key is released.
+ */
+
+/* Scan the hardware keyboard and push any changes up through the input layer */
+static void tosakbd_scankeyboard(struct platform_device *dev)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+ unsigned int row, col, rowd;
+ unsigned long flags;
+ unsigned int num_pressed = 0;
+
+ spin_lock_irqsave(&tosakbd->lock, flags);
+
+ for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
+ /*
+ * Discharge the output driver capacitatance
+ * in the keyboard matrix. (Yes it is significant..)
+ */
+ tosakbd_discharge_all();
+ udelay(KB_DISCHARGE_DELAY);
+
+ tosakbd_activate_col(col);
+ udelay(KB_ACTIVATE_DELAY);
+
+ rowd = GET_ROWS_STATUS(col);
+
+ for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
+ unsigned int scancode, pressed;
+ scancode = SCANCODE(row, col);
+ pressed = rowd & KB_ROWMASK(row);
+
+ if (pressed && !tosakbd->keycode[scancode])
+ dev_warn(&dev->dev,
+ "unhandled scancode: 0x%02x\n",
+ scancode);
+
+ input_report_key(tosakbd->input,
+ tosakbd->keycode[scancode],
+ pressed);
+ if (pressed)
+ num_pressed++;
+ }
+
+ tosakbd_reset_col(col);
+ }
+
+ tosakbd_activate_all();
+
+ input_sync(tosakbd->input);
+
+ /* if any keys are pressed, enable the timer */
+ if (num_pressed)
+ mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
+
+ spin_unlock_irqrestore(&tosakbd->lock, flags);
+}
+
+/*
+ * tosa keyboard interrupt handler.
+ */
+static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
+{
+ struct platform_device *dev = __dev;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ if (!timer_pending(&tosakbd->timer)) {
+ /** wait chattering delay **/
+ udelay(20);
+ tosakbd_scankeyboard(dev);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * tosa timer checking for released keys
+ */
+static void tosakbd_timer_callback(unsigned long __dev)
+{
+ struct platform_device *dev = (struct platform_device *)__dev;
+ tosakbd_scankeyboard(dev);
+}
+
+#ifdef CONFIG_PM
+static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+
+static int tosakbd_resume(struct platform_device *dev)
+{
+ /* Nothing yet */
+
+ return 0;
+}
+#else
+#define tosakbd_suspend NULL
+#define tosakbd_resume NULL
+#endif
+
+static int __devinit tosakbd_probe(struct platform_device *pdev) {
+
+ int i;
+ struct tosakbd *tosakbd;
+ struct input_dev *input_dev;
+ int error;
+
+ tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
+ if (!tosakbd)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(tosakbd);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, tosakbd);
+
+ spin_lock_init(&tosakbd->lock);
+
+ /* Init Keyboard rescan timer */
+ init_timer(&tosakbd->timer);
+ tosakbd->timer.function = tosakbd_timer_callback;
+ tosakbd->timer.data = (unsigned long) pdev;
+
+ tosakbd->input = input_dev;
+
+ input_dev->private = tosakbd;
+ input_dev->name = "Tosa Keyboard";
+ input_dev->phys = "tosakbd/input0";
+ input_dev->cdev.dev = &pdev->dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = tosakbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned int);
+ input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
+
+ memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
+
+ for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
+ set_bit(tosakbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_SENSE(i);
+ int irq;
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail;
+ }
+
+ error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ irq = gpio_to_irq(gpio);
+ if (irq < 0) {
+ error = irq;
+ printk(KERN_ERR "gpio-keys: Unable to get irq number"
+ " for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ error = request_irq(irq, tosakbd_interrupt,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING,
+ "tosakbd", pdev);
+
+ if (error) {
+ printk("tosakbd: Can't get IRQ: %d: error %d!\n",
+ irq, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+ }
+
+ /* Set Strobe lines as outputs - set high */
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_STROBE(i);
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail2;
+ }
+
+ error = gpio_direction_output(gpio, 1);
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ printk(KERN_ERR "tosakbd: Unable to register input device, "
+ "error: %d\n", error);
+ goto fail;
+ }
+
+ printk(KERN_INFO "input: Tosa Keyboard Registered\n");
+
+ return 0;
+
+fail2:
+ while (--i >= 0)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ i = TOSA_KEY_SENSE_NUM;
+fail:
+ while (--i >= 0) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ platform_set_drvdata(pdev, NULL);
+ input_free_device(input_dev);
+ kfree(tosakbd);
+
+ return error;
+}
+
+static int __devexit tosakbd_remove(struct platform_device *dev) {
+
+ int i;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ del_timer_sync(&tosakbd->timer);
+
+ input_unregister_device(tosakbd->input);
+
+ kfree(tosakbd);
+
+ return 0;
+}
+
+static struct platform_driver tosakbd_driver = {
+ .probe = tosakbd_probe,
+ .remove = __devexit_p(tosakbd_remove),
+ .suspend = tosakbd_suspend,
+ .resume = tosakbd_resume,
+ .driver = {
+ .name = "tosa-keyboard",
+ },
+};
+
+static int __devinit tosakbd_init(void)
+{
+ return platform_driver_register(&tosakbd_driver);
+}
+
+static void __exit tosakbd_exit(void)
+{
+ platform_driver_unregister(&tosakbd_driver);
+}
+
+module_init(tosakbd_init);
+module_exit(tosakbd_exit);
+
+MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
+MODULE_DESCRIPTION("Tosa Keyboard Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h
index c3364a2..fdd9b31 100644
--- a/include/asm-arm/arch-pxa/tosa.h
+++ b/include/asm-arm/arch-pxa/tosa.h
@@ -163,4 +163,34 @@
extern struct platform_device tosascoop_jc_device;
extern struct platform_device tosascoop_device;
+
+#define TOSA_KEY_SYNC KEY_102ND /* ??? */
+
+
+#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES
+#define TOSA_KEY_RECORD KEY_YEN
+#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA
+#define TOSA_KEY_CANCEL KEY_ESC
+#define TOSA_KEY_CENTER KEY_HIRAGANA
+#define TOSA_KEY_OK KEY_HENKAN
+#define TOSA_KEY_CALENDAR KEY_KATAKANAHIRAGANA
+#define TOSA_KEY_HOMEPAGE KEY_HANGEUL
+#define TOSA_KEY_LIGHT KEY_MUHENKAN
+#define TOSA_KEY_MENU KEY_HANJA
+#define TOSA_KEY_FN KEY_RIGHTALT
+#define TOSA_KEY_MAIL KEY_ZENKAKUHANKAKU
+#else
+#define TOSA_KEY_RECORD KEY_RECORD
+#define TOSA_KEY_ADDRESSBOOK KEY_ADDRESSBOOK
+#define TOSA_KEY_CANCEL KEY_CANCEL
+#define TOSA_KEY_CENTER KEY_SELECT /* ??? */
+#define TOSA_KEY_OK KEY_OK
+#define TOSA_KEY_CALENDAR KEY_CALENDAR
+#define TOSA_KEY_HOMEPAGE KEY_HOMEPAGE
+#define TOSA_KEY_LIGHT KEY_SWITCHVIDEOMODE /* ??? */
+#define TOSA_KEY_MENU KEY_MENU
+#define TOSA_KEY_FN KEY_FN
+#define TOSA_KEY_MAIL KEY_MAIL
+#endif
+
#endif /* _ASM_ARCH_TOSA_H_ */
--
1.5.3.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2007-12-23 23:29 Dmitry Baryshkov
@ 2008-01-03 16:51 ` Dmitry Torokhov
2008-01-03 23:01 ` Dmitry Baryshkov
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2008-01-03 16:51 UTC (permalink / raw)
To: Dmitry Baryshkov; +Cc: linux-arm-kernel, linux-input
Hi Dmitry,
Sorry for the slow response.
On Dec 23, 2007 6:29 PM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
> > From b213bef91e3f98c6104138050ad4eaa0a54e765d Mon Sep 17 00:00:00 2001
> From: Dmitry Baryshkov <dbaryshkov@gmail.com>
> Date: Mon, 24 Dec 2007 02:15:34 +0300
> Subject: [PATCH] Tosa keyboard support
>
> Support keyboard on tosa (Sharp Zaurus SL-6000x).
> Largely based on patches by Dirk Opfer.
> This is the final version that supports switching between
> full keycode range and range available to the console and
> keyb Kdrive driver.
>
The driver looks very nice, just a couple minor comments:
> +
> +#ifdef CONFIG_PM
> +static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
> +{
> + /* Nothing yet */
Stop the polling timer here?
> +
> + return 0;
> +}
> +
...
> +
> + tosakbd->input = input_dev;
> +
> + input_dev->private = tosakbd;
Please use input_set_drvdata(). I am about to commit the change
removing private from input_dev structure.
> + input_dev->name = "Tosa Keyboard";
> + input_dev->phys = "tosakbd/input0";
> + input_dev->cdev.dev = &pdev->dev;
Please use input_dev->dev.parent. cdev is going away.
> +
> + input_dev->id.bustype = BUS_HOST;
> + input_dev->id.vendor = 0x0001;
> + input_dev->id.product = 0x0001;
> + input_dev->id.version = 0x0100;
> +
> + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
> + input_dev->keycode = tosakbd->keycode;
> + input_dev->keycodesize = sizeof(unsigned int);
> + input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
> +
> + memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
> +
> + for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
> + set_bit(tosakbd->keycode[i], input_dev->keybit);
> + clear_bit(0, input_dev->keybit);
Might want to switch to __set_bit to save couple of bytes. We dont
need atomicity here.
> +
> +#define TOSA_KEY_SYNC KEY_102ND /* ??? */
> +
> +
> +#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES
> +#define TOSA_KEY_RECORD KEY_YEN
> +#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA
> +#define TOSA_KEY_CANCEL KEY_ESC
> +#define TOSA_KEY_CENTER KEY_HIRAGANA
> +#define TOSA_KEY_OK KEY_HENKAN
> +#define TOSA_KEY_CALENDAR KEY_KATAKANAHIRAGANA
> +#define TOSA_KEY_HOMEPAGE KEY_HANGEUL
> +#define TOSA_KEY_LIGHT KEY_MUHENKAN
> +#define TOSA_KEY_MENU KEY_HANJA
> +#define TOSA_KEY_FN KEY_RIGHTALT
> +#define TOSA_KEY_MAIL KEY_ZENKAKUHANKAKU
> +#else
> +#define TOSA_KEY_RECORD KEY_RECORD
> +#define TOSA_KEY_ADDRESSBOOK KEY_ADDRESSBOOK
> +#define TOSA_KEY_CANCEL KEY_CANCEL
> +#define TOSA_KEY_CENTER KEY_SELECT /* ??? */
> +#define TOSA_KEY_OK KEY_OK
> +#define TOSA_KEY_CALENDAR KEY_CALENDAR
> +#define TOSA_KEY_HOMEPAGE KEY_HOMEPAGE
> +#define TOSA_KEY_LIGHT KEY_SWITCHVIDEOMODE /* ??? */
KEY_ILLUMTOGGLE maybe? SWITCHWIDEOMODE is for cycling between outputs...
Also, I'd put these defines rigth in tosakbd.c.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2008-01-03 16:51 ` Dmitry Torokhov
@ 2008-01-03 23:01 ` Dmitry Baryshkov
2008-01-03 23:08 ` Dmitry Baryshkov
2008-01-11 14:56 ` Dmitry Torokhov
0 siblings, 2 replies; 12+ messages in thread
From: Dmitry Baryshkov @ 2008-01-03 23:01 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: linux-input
Hi, Dmitry,
Dmitry Torokhov wrote:
> Hi Dmitry,
>
> Sorry for the slow response.
Hah, that's ok. Thank you for your comments.
>
> On Dec 23, 2007 6:29 PM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
>> > From b213bef91e3f98c6104138050ad4eaa0a54e765d Mon Sep 17 00:00:00
>> > 2001
>> From: Dmitry Baryshkov <dbaryshkov@gmail.com> Date: Mon, 24 Dec 2007
>> 02:15:34 +0300 Subject: [PATCH] Tosa keyboard support
>>
>> Support keyboard on tosa (Sharp Zaurus SL-6000x). Largely based on
>> patches by Dirk Opfer. This is the final version that supports
>> switching between full keycode range and range available to the console
>> and keyb Kdrive driver.
>>
>>
> The driver looks very nice, just a couple minor comments:
>
[skipped]
Fixed. See below
>
>> +
>> +#define TOSA_KEY_SYNC KEY_102ND /* ??? */ +
>> +
>> +#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES +#define TOSA_KEY_RECORD
>> KEY_YEN +#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA
>> +#define TOSA_KEY_CANCEL KEY_ESC +#define
>> TOSA_KEY_CENTER KEY_HIRAGANA +#define TOSA_KEY_OK
>> KEY_HENKAN +#define TOSA_KEY_CALENDAR KEY_KATAKANAHIRAGANA
>> +#define TOSA_KEY_HOMEPAGE KEY_HANGEUL +#define TOSA_KEY_LIGHT
>> KEY_MUHENKAN +#define TOSA_KEY_MENU KEY_HANJA +#define
>> TOSA_KEY_FN KEY_RIGHTALT +#define TOSA_KEY_MAIL
>> KEY_ZENKAKUHANKAKU +#else
>> +#define TOSA_KEY_RECORD KEY_RECORD +#define
>> TOSA_KEY_ADDRESSBOOK KEY_ADDRESSBOOK +#define TOSA_KEY_CANCEL
>> KEY_CANCEL +#define TOSA_KEY_CENTER KEY_SELECT /*
>> ??? */ +#define TOSA_KEY_OK KEY_OK +#define
>> TOSA_KEY_CALENDAR KEY_CALENDAR +#define TOSA_KEY_HOMEPAGE
>> KEY_HOMEPAGE +#define TOSA_KEY_LIGHT KEY_SWITCHVIDEOMODE /* ???
>> */
>
> KEY_ILLUMTOGGLE maybe? SWITCHWIDEOMODE is for cycling between outputs...
OK. I used SWITCHVIDEOMODE because it's another symbol near that key.
>
> Also, I'd put these defines rigth in tosakbd.c.
The TOSA_KEY_RECORD and SYNC are used inside arch/arm/mach-pxa/tosa.c
(for gpio-keys declaration). So I would prefer to place all such defines here.
When the Kdrive would be fixed, I would drop KEY_RECORD and happily move
that defines to tosakbd.c
--
With best wishes
Dmitry
Tosa keyboard support
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
Support keyboard on tosa (Sharp Zaurus SL-6000x).
Largely based on patches by Dirk Opfer.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 240fd04..e7e0f52 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -21,6 +21,8 @@
#include <linux/mmc/host.h>
#include <linux/pm.h>
#include <linux/delay.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <asm/setup.h>
#include <asm/memory.h>
@@ -253,6 +255,46 @@ static struct platform_device tosakbd_device = {
.id = -1,
};
+static struct gpio_keys_button tosa_gpio_keys[] = {
+ {
+ .type = EV_PWR,
+ .code = KEY_SUSPEND,
+ .gpio = TOSA_GPIO_ON_KEY,
+ .desc = "On key",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_RECORD,
+ .gpio = TOSA_GPIO_RECORD_BTN,
+ .desc = "Record Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_SYNC,
+ .gpio = TOSA_GPIO_SYNC,
+ .desc = "Sync Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
+ .buttons = tosa_gpio_keys,
+ .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
+};
+
+static struct platform_device tosa_gpio_keys_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = {
+ .platform_data = &tosa_gpio_keys_platform_data,
+ },
+};
+
/*
* Tosa LEDs
*/
@@ -265,6 +307,7 @@ static struct platform_device *devices[] __initdata = {
&tosascoop_device,
&tosascoop_jc_device,
&tosakbd_device,
+ &tosa_gpio_keys_device,
&tosaled_device,
};
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index dfa6592..a60d43a 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -154,6 +154,27 @@ config KEYBOARD_SPITZ
To compile this driver as a module, choose M here: the
module will be called spitzkbd.
+config KEYBOARD_TOSA
+ tristate "Tosa keyboard"
+ depends on MACH_TOSA
+ default y
+ help
+ Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
+
+ To compile this driver as a module, choose M here: the
+ module will be called tosakbd.
+
+config KEYBOARD_TOSA_USE_EXT_KEYCODES
+ bool "Tosa keyboard: use extended keycodes"
+ depends on KEYBOARD_TOSA
+ default n
+ help
+ Say Y here to enable the tosa keyboard driver to generate extended
+ (>= 127) keycodes. Be aware, that they can't be correctly interpreted
+ by either console keyboard driver or by Kdrive keybd driver.
+
+ Say Y only if you know, what you are doing!
+
config KEYBOARD_AMIGA
tristate "Amiga keyboard"
depends on AMIGA
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e97455f..6caa065 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
+obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
diff --git a/drivers/input/keyboard/tosakbd.c b/drivers/input/keyboard/tosakbd.c
new file mode 100644
index 0000000..fb672c4
--- /dev/null
+++ b/drivers/input/keyboard/tosakbd.c
@@ -0,0 +1,413 @@
+/*
+ * Keyboard driver for Sharp Tosa models (SL-6000x)
+ *
+ * Copyright (c) 2005 Dirk Opfer
+ * Copyright (c) 2007 Dmitry Baryshkov
+ *
+ * Based on xtkbd.c/locomkbd.c/corgikbd.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/tosa.h>
+
+#define KB_ROWMASK(r) (1 << (r))
+#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
+#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1
+
+#define SCAN_INTERVAL (HZ/10)
+
+#define KB_DISCHARGE_DELAY 10
+#define KB_ACTIVATE_DELAY 10
+
+static unsigned int tosakbd_keycode[NR_SCANCODES] = {
+0,
+0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Z, KEY_C, KEY_V, KEY_J, TOSA_KEY_ADDRESSBOOK, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK,
+KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
+KEY_S, KEY_R, KEY_B, KEY_N, TOSA_KEY_CALENDAR, TOSA_KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT,
+0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
+KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0,
+0, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0,
+KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, TOSA_KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
+0, 0, 0,
+};
+
+struct tosakbd {
+ unsigned int keycode[ARRAY_SIZE(tosakbd_keycode)];
+ struct input_dev *input;
+
+ spinlock_t lock; /* protect kbd scanning */
+ struct timer_list timer;
+};
+
+
+/* Helper functions for reading the keyboard matrix
+ * Note: We should really be using pxa_gpio_mode to alter GPDR but it
+ * requires a function call per GPIO bit which is excessive
+ * when we need to access 12 bits at once, multiple times.
+ * These functions must be called within local_irq_save()/local_irq_restore()
+ * or similar.
+ */
+#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT)
+
+static inline void tosakbd_discharge_all(void)
+{
+ /* STROBE All HiZ */
+ GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
+ GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
+}
+
+static inline void tosakbd_activate_all(void)
+{
+ /* STROBE ALL -> High */
+ GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
+ GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
+
+ udelay(KB_DISCHARGE_DELAY);
+
+ /* STATE CLEAR */
+ GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
+}
+
+static inline void tosakbd_activate_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR1 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR2 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+
+static inline void tosakbd_reset_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> Low */
+ GPCR1 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> Low */
+ GPCR2 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+/*
+ * The tosa keyboard only generates interrupts when a key is pressed.
+ * So when a key is pressed, we enable a timer. This timer scans the
+ * keyboard, and this is how we detect when the key is released.
+ */
+
+/* Scan the hardware keyboard and push any changes up through the input layer */
+static void tosakbd_scankeyboard(struct platform_device *dev)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+ unsigned int row, col, rowd;
+ unsigned long flags;
+ unsigned int num_pressed = 0;
+
+ spin_lock_irqsave(&tosakbd->lock, flags);
+
+ for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
+ /*
+ * Discharge the output driver capacitatance
+ * in the keyboard matrix. (Yes it is significant..)
+ */
+ tosakbd_discharge_all();
+ udelay(KB_DISCHARGE_DELAY);
+
+ tosakbd_activate_col(col);
+ udelay(KB_ACTIVATE_DELAY);
+
+ rowd = GET_ROWS_STATUS(col);
+
+ for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
+ unsigned int scancode, pressed;
+ scancode = SCANCODE(row, col);
+ pressed = rowd & KB_ROWMASK(row);
+
+ if (pressed && !tosakbd->keycode[scancode])
+ dev_warn(&dev->dev,
+ "unhandled scancode: 0x%02x\n",
+ scancode);
+
+ input_report_key(tosakbd->input,
+ tosakbd->keycode[scancode],
+ pressed);
+ if (pressed)
+ num_pressed++;
+ }
+
+ tosakbd_reset_col(col);
+ }
+
+ tosakbd_activate_all();
+
+ input_sync(tosakbd->input);
+
+ /* if any keys are pressed, enable the timer */
+ if (num_pressed)
+ mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
+
+ spin_unlock_irqrestore(&tosakbd->lock, flags);
+}
+
+/*
+ * tosa keyboard interrupt handler.
+ */
+static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
+{
+ struct platform_device *dev = __dev;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ if (!timer_pending(&tosakbd->timer)) {
+ /** wait chattering delay **/
+ udelay(20);
+ tosakbd_scankeyboard(dev);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * tosa timer checking for released keys
+ */
+static void tosakbd_timer_callback(unsigned long __dev)
+{
+ struct platform_device *dev = (struct platform_device *)__dev;
+ tosakbd_scankeyboard(dev);
+}
+
+#ifdef CONFIG_PM
+static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
+{
+ del_timer(&tosakbd->timer);
+
+ return 0;
+}
+
+static int tosakbd_resume(struct platform_device *dev)
+{
+ tosakbd_scankeyboard(dev);
+
+ return 0;
+}
+#else
+#define tosakbd_suspend NULL
+#define tosakbd_resume NULL
+#endif
+
+static int __devinit tosakbd_probe(struct platform_device *pdev) {
+
+ int i;
+ struct tosakbd *tosakbd;
+ struct input_dev *input_dev;
+ int error;
+
+ tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
+ if (!tosakbd)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(tosakbd);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, tosakbd);
+
+ spin_lock_init(&tosakbd->lock);
+
+ /* Init Keyboard rescan timer */
+ init_timer(&tosakbd->timer);
+ tosakbd->timer.function = tosakbd_timer_callback;
+ tosakbd->timer.data = (unsigned long) pdev;
+
+ tosakbd->input = input_dev;
+
+ input_set_drvdata(input_dev, tosakbd);
+ input_dev->name = "Tosa Keyboard";
+ input_dev->phys = "tosakbd/input0";
+ input_dev->dev.parent = &pdev->dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = tosakbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned int);
+ input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
+
+ memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
+
+ for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
+ __set_bit(tosakbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_SENSE(i);
+ int irq;
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail;
+ }
+
+ error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ irq = gpio_to_irq(gpio);
+ if (irq < 0) {
+ error = irq;
+ printk(KERN_ERR "gpio-keys: Unable to get irq number"
+ " for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ error = request_irq(irq, tosakbd_interrupt,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING,
+ "tosakbd", pdev);
+
+ if (error) {
+ printk("tosakbd: Can't get IRQ: %d: error %d!\n",
+ irq, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+ }
+
+ /* Set Strobe lines as outputs - set high */
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_STROBE(i);
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail2;
+ }
+
+ error = gpio_direction_output(gpio, 1);
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ printk(KERN_ERR "tosakbd: Unable to register input device, "
+ "error: %d\n", error);
+ goto fail;
+ }
+
+ printk(KERN_INFO "input: Tosa Keyboard Registered\n");
+
+ return 0;
+
+fail2:
+ while (--i >= 0)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ i = TOSA_KEY_SENSE_NUM;
+fail:
+ while (--i >= 0) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ platform_set_drvdata(pdev, NULL);
+ input_free_device(input_dev);
+ kfree(tosakbd);
+
+ return error;
+}
+
+static int __devexit tosakbd_remove(struct platform_device *dev) {
+
+ int i;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ del_timer_sync(&tosakbd->timer);
+
+ input_unregister_device(tosakbd->input);
+
+ kfree(tosakbd);
+
+ return 0;
+}
+
+static struct platform_driver tosakbd_driver = {
+ .probe = tosakbd_probe,
+ .remove = __devexit_p(tosakbd_remove),
+ .suspend = tosakbd_suspend,
+ .resume = tosakbd_resume,
+ .driver = {
+ .name = "tosa-keyboard",
+ },
+};
+
+static int __devinit tosakbd_init(void)
+{
+ return platform_driver_register(&tosakbd_driver);
+}
+
+static void __exit tosakbd_exit(void)
+{
+ platform_driver_unregister(&tosakbd_driver);
+}
+
+module_init(tosakbd_init);
+module_exit(tosakbd_exit);
+
+MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
+MODULE_DESCRIPTION("Tosa Keyboard Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h
index c3364a2..c05e4fa 100644
--- a/include/asm-arm/arch-pxa/tosa.h
+++ b/include/asm-arm/arch-pxa/tosa.h
@@ -163,4 +163,34 @@
extern struct platform_device tosascoop_jc_device;
extern struct platform_device tosascoop_device;
+
+#define TOSA_KEY_SYNC KEY_102ND /* ??? */
+
+
+#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES
+#define TOSA_KEY_RECORD KEY_YEN
+#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA
+#define TOSA_KEY_CANCEL KEY_ESC
+#define TOSA_KEY_CENTER KEY_HIRAGANA
+#define TOSA_KEY_OK KEY_HENKAN
+#define TOSA_KEY_CALENDAR KEY_KATAKANAHIRAGANA
+#define TOSA_KEY_HOMEPAGE KEY_HANGEUL
+#define TOSA_KEY_LIGHT KEY_MUHENKAN
+#define TOSA_KEY_MENU KEY_HANJA
+#define TOSA_KEY_FN KEY_RIGHTALT
+#define TOSA_KEY_MAIL KEY_ZENKAKUHANKAKU
+#else
+#define TOSA_KEY_RECORD KEY_RECORD
+#define TOSA_KEY_ADDRESSBOOK KEY_ADDRESSBOOK
+#define TOSA_KEY_CANCEL KEY_CANCEL
+#define TOSA_KEY_CENTER KEY_SELECT /* ??? */
+#define TOSA_KEY_OK KEY_OK
+#define TOSA_KEY_CALENDAR KEY_CALENDAR
+#define TOSA_KEY_HOMEPAGE KEY_HOMEPAGE
+#define TOSA_KEY_LIGHT KEY_KBDILLUMTOGGLE
+#define TOSA_KEY_MENU KEY_MENU
+#define TOSA_KEY_FN KEY_FN
+#define TOSA_KEY_MAIL KEY_MAIL
+#endif
+
#endif /* _ASM_ARCH_TOSA_H_ */
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2008-01-03 23:01 ` Dmitry Baryshkov
@ 2008-01-03 23:08 ` Dmitry Baryshkov
2008-01-11 14:56 ` Dmitry Torokhov
1 sibling, 0 replies; 12+ messages in thread
From: Dmitry Baryshkov @ 2008-01-03 23:08 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: linux-input
Hi,
Dmitry Baryshkov wrote:
> Hi, Dmitry,
>
> Dmitry Torokhov wrote:
>
>> Hi Dmitry,
>>
>> Sorry for the slow response.
>
> Hah, that's ok. Thank you for your comments.
>
>
>> On Dec 23, 2007 6:29 PM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
>>> > From b213bef91e3f98c6104138050ad4eaa0a54e765d Mon Sep 17 00:00:00
>>> > 2001
>>> From: Dmitry Baryshkov <dbaryshkov@gmail.com> Date: Mon, 24 Dec 2007
>>> 02:15:34 +0300 Subject: [PATCH] Tosa keyboard support
>>>
>>> Support keyboard on tosa (Sharp Zaurus SL-6000x). Largely based on
>>> patches by Dirk Opfer. This is the final version that supports
>>> switching between full keycode range and range available to the
>>> console and keyb Kdrive driver.
>>>
>>>
>> The driver looks very nice, just a couple minor comments:
>>
>>
> [skipped]
>
> Fixed. See below
Oops. Please use this patch:
Tosa keyboard support
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
Support keyboard on tosa (Sharp Zaurus SL-6000x).
Largely based on patches by Dirk Opfer.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 240fd04..e7e0f52 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -21,6 +21,8 @@
#include <linux/mmc/host.h>
#include <linux/pm.h>
#include <linux/delay.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <asm/setup.h>
#include <asm/memory.h>
@@ -253,6 +255,46 @@ static struct platform_device tosakbd_device = {
.id = -1,
};
+static struct gpio_keys_button tosa_gpio_keys[] = {
+ {
+ .type = EV_PWR,
+ .code = KEY_SUSPEND,
+ .gpio = TOSA_GPIO_ON_KEY,
+ .desc = "On key",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_RECORD,
+ .gpio = TOSA_GPIO_RECORD_BTN,
+ .desc = "Record Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+ {
+ .type = EV_KEY,
+ .code = TOSA_KEY_SYNC,
+ .gpio = TOSA_GPIO_SYNC,
+ .desc = "Sync Button",
+ .wakeup = 1,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
+ .buttons = tosa_gpio_keys,
+ .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
+};
+
+static struct platform_device tosa_gpio_keys_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = {
+ .platform_data = &tosa_gpio_keys_platform_data,
+ },
+};
+
/*
* Tosa LEDs
*/
@@ -265,6 +307,7 @@ static struct platform_device *devices[] __initdata = {
&tosascoop_device,
&tosascoop_jc_device,
&tosakbd_device,
+ &tosa_gpio_keys_device,
&tosaled_device,
};
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index dfa6592..a60d43a 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -154,6 +154,27 @@ config KEYBOARD_SPITZ
To compile this driver as a module, choose M here: the
module will be called spitzkbd.
+config KEYBOARD_TOSA
+ tristate "Tosa keyboard"
+ depends on MACH_TOSA
+ default y
+ help
+ Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
+
+ To compile this driver as a module, choose M here: the
+ module will be called tosakbd.
+
+config KEYBOARD_TOSA_USE_EXT_KEYCODES
+ bool "Tosa keyboard: use extended keycodes"
+ depends on KEYBOARD_TOSA
+ default n
+ help
+ Say Y here to enable the tosa keyboard driver to generate extended
+ (>= 127) keycodes. Be aware, that they can't be correctly interpreted
+ by either console keyboard driver or by Kdrive keybd driver.
+
+ Say Y only if you know, what you are doing!
+
config KEYBOARD_AMIGA
tristate "Amiga keyboard"
depends on AMIGA
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e97455f..6caa065 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
+obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
diff --git a/drivers/input/keyboard/tosakbd.c b/drivers/input/keyboard/tosakbd.c
new file mode 100644
index 0000000..3884d1e
--- /dev/null
+++ b/drivers/input/keyboard/tosakbd.c
@@ -0,0 +1,415 @@
+/*
+ * Keyboard driver for Sharp Tosa models (SL-6000x)
+ *
+ * Copyright (c) 2005 Dirk Opfer
+ * Copyright (c) 2007 Dmitry Baryshkov
+ *
+ * Based on xtkbd.c/locomkbd.c/corgikbd.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/tosa.h>
+
+#define KB_ROWMASK(r) (1 << (r))
+#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
+#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1
+
+#define SCAN_INTERVAL (HZ/10)
+
+#define KB_DISCHARGE_DELAY 10
+#define KB_ACTIVATE_DELAY 10
+
+static unsigned int tosakbd_keycode[NR_SCANCODES] = {
+0,
+0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
+0, 0, 0, 0, 0, 0, 0, 0,
+KEY_Z, KEY_C, KEY_V, KEY_J, TOSA_KEY_ADDRESSBOOK, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK,
+KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
+KEY_S, KEY_R, KEY_B, KEY_N, TOSA_KEY_CALENDAR, TOSA_KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT,
+0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
+KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0,
+0, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0,
+KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, TOSA_KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
+0, 0, 0,
+};
+
+struct tosakbd {
+ unsigned int keycode[ARRAY_SIZE(tosakbd_keycode)];
+ struct input_dev *input;
+
+ spinlock_t lock; /* protect kbd scanning */
+ struct timer_list timer;
+};
+
+
+/* Helper functions for reading the keyboard matrix
+ * Note: We should really be using pxa_gpio_mode to alter GPDR but it
+ * requires a function call per GPIO bit which is excessive
+ * when we need to access 12 bits at once, multiple times.
+ * These functions must be called within local_irq_save()/local_irq_restore()
+ * or similar.
+ */
+#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT)
+
+static inline void tosakbd_discharge_all(void)
+{
+ /* STROBE All HiZ */
+ GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
+ GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
+}
+
+static inline void tosakbd_activate_all(void)
+{
+ /* STROBE ALL -> High */
+ GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
+ GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
+ GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
+ GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
+
+ udelay(KB_DISCHARGE_DELAY);
+
+ /* STATE CLEAR */
+ GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
+}
+
+static inline void tosakbd_activate_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR1 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> High, not col -> HiZ */
+ GPSR2 = TOSA_GPIO_STROBE_BIT(col);
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+
+static inline void tosakbd_reset_col(int col)
+{
+ if (col <= 5) {
+ /* STROBE col -> Low */
+ GPCR1 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ } else {
+ /* STROBE col -> Low */
+ GPCR2 = TOSA_GPIO_STROBE_BIT(col);
+ /* STROBE col -> out, not col -> HiZ */
+ GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
+ }
+}
+/*
+ * The tosa keyboard only generates interrupts when a key is pressed.
+ * So when a key is pressed, we enable a timer. This timer scans the
+ * keyboard, and this is how we detect when the key is released.
+ */
+
+/* Scan the hardware keyboard and push any changes up through the input layer */
+static void tosakbd_scankeyboard(struct platform_device *dev)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+ unsigned int row, col, rowd;
+ unsigned long flags;
+ unsigned int num_pressed = 0;
+
+ spin_lock_irqsave(&tosakbd->lock, flags);
+
+ for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
+ /*
+ * Discharge the output driver capacitatance
+ * in the keyboard matrix. (Yes it is significant..)
+ */
+ tosakbd_discharge_all();
+ udelay(KB_DISCHARGE_DELAY);
+
+ tosakbd_activate_col(col);
+ udelay(KB_ACTIVATE_DELAY);
+
+ rowd = GET_ROWS_STATUS(col);
+
+ for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
+ unsigned int scancode, pressed;
+ scancode = SCANCODE(row, col);
+ pressed = rowd & KB_ROWMASK(row);
+
+ if (pressed && !tosakbd->keycode[scancode])
+ dev_warn(&dev->dev,
+ "unhandled scancode: 0x%02x\n",
+ scancode);
+
+ input_report_key(tosakbd->input,
+ tosakbd->keycode[scancode],
+ pressed);
+ if (pressed)
+ num_pressed++;
+ }
+
+ tosakbd_reset_col(col);
+ }
+
+ tosakbd_activate_all();
+
+ input_sync(tosakbd->input);
+
+ /* if any keys are pressed, enable the timer */
+ if (num_pressed)
+ mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
+
+ spin_unlock_irqrestore(&tosakbd->lock, flags);
+}
+
+/*
+ * tosa keyboard interrupt handler.
+ */
+static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
+{
+ struct platform_device *dev = __dev;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ if (!timer_pending(&tosakbd->timer)) {
+ /** wait chattering delay **/
+ udelay(20);
+ tosakbd_scankeyboard(dev);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * tosa timer checking for released keys
+ */
+static void tosakbd_timer_callback(unsigned long __dev)
+{
+ struct platform_device *dev = (struct platform_device *)__dev;
+ tosakbd_scankeyboard(dev);
+}
+
+#ifdef CONFIG_PM
+static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
+{
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ del_timer_sync(&tosakbd->timer);
+
+ return 0;
+}
+
+static int tosakbd_resume(struct platform_device *dev)
+{
+ tosakbd_scankeyboard(dev);
+
+ return 0;
+}
+#else
+#define tosakbd_suspend NULL
+#define tosakbd_resume NULL
+#endif
+
+static int __devinit tosakbd_probe(struct platform_device *pdev) {
+
+ int i;
+ struct tosakbd *tosakbd;
+ struct input_dev *input_dev;
+ int error;
+
+ tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
+ if (!tosakbd)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ kfree(tosakbd);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, tosakbd);
+
+ spin_lock_init(&tosakbd->lock);
+
+ /* Init Keyboard rescan timer */
+ init_timer(&tosakbd->timer);
+ tosakbd->timer.function = tosakbd_timer_callback;
+ tosakbd->timer.data = (unsigned long) pdev;
+
+ tosakbd->input = input_dev;
+
+ input_set_drvdata(input_dev, tosakbd);
+ input_dev->name = "Tosa Keyboard";
+ input_dev->phys = "tosakbd/input0";
+ input_dev->dev.parent = &pdev->dev;
+
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0100;
+
+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ input_dev->keycode = tosakbd->keycode;
+ input_dev->keycodesize = sizeof(unsigned int);
+ input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
+
+ memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
+
+ for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
+ __set_bit(tosakbd->keycode[i], input_dev->keybit);
+ clear_bit(0, input_dev->keybit);
+
+ /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_SENSE(i);
+ int irq;
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail;
+ }
+
+ error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ irq = gpio_to_irq(gpio);
+ if (irq < 0) {
+ error = irq;
+ printk(KERN_ERR "gpio-keys: Unable to get irq number"
+ " for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ error = request_irq(irq, tosakbd_interrupt,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING,
+ "tosakbd", pdev);
+
+ if (error) {
+ printk("tosakbd: Can't get IRQ: %d: error %d!\n",
+ irq, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+ }
+
+ /* Set Strobe lines as outputs - set high */
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
+ int gpio = TOSA_GPIO_KEY_STROBE(i);
+ error = gpio_request(gpio, "tosakbd");
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
+ " error %d\n", gpio, error);
+ goto fail2;
+ }
+
+ error = gpio_direction_output(gpio, 1);
+ if (error < 0) {
+ printk(KERN_ERR "tosakbd: failed to configure input"
+ " direction for GPIO %d, error %d\n",
+ gpio, error);
+ gpio_free(gpio);
+ goto fail;
+ }
+
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ printk(KERN_ERR "tosakbd: Unable to register input device, "
+ "error: %d\n", error);
+ goto fail;
+ }
+
+ printk(KERN_INFO "input: Tosa Keyboard Registered\n");
+
+ return 0;
+
+fail2:
+ while (--i >= 0)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ i = TOSA_KEY_SENSE_NUM;
+fail:
+ while (--i >= 0) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ platform_set_drvdata(pdev, NULL);
+ input_free_device(input_dev);
+ kfree(tosakbd);
+
+ return error;
+}
+
+static int __devexit tosakbd_remove(struct platform_device *dev) {
+
+ int i;
+ struct tosakbd *tosakbd = platform_get_drvdata(dev);
+
+ for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
+ gpio_free(TOSA_GPIO_KEY_STROBE(i));
+
+ for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
+ free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
+ gpio_free(TOSA_GPIO_KEY_SENSE(i));
+ }
+
+ del_timer_sync(&tosakbd->timer);
+
+ input_unregister_device(tosakbd->input);
+
+ kfree(tosakbd);
+
+ return 0;
+}
+
+static struct platform_driver tosakbd_driver = {
+ .probe = tosakbd_probe,
+ .remove = __devexit_p(tosakbd_remove),
+ .suspend = tosakbd_suspend,
+ .resume = tosakbd_resume,
+ .driver = {
+ .name = "tosa-keyboard",
+ },
+};
+
+static int __devinit tosakbd_init(void)
+{
+ return platform_driver_register(&tosakbd_driver);
+}
+
+static void __exit tosakbd_exit(void)
+{
+ platform_driver_unregister(&tosakbd_driver);
+}
+
+module_init(tosakbd_init);
+module_exit(tosakbd_exit);
+
+MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
+MODULE_DESCRIPTION("Tosa Keyboard Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h
index c3364a2..c05e4fa 100644
--- a/include/asm-arm/arch-pxa/tosa.h
+++ b/include/asm-arm/arch-pxa/tosa.h
@@ -163,4 +163,34 @@
extern struct platform_device tosascoop_jc_device;
extern struct platform_device tosascoop_device;
+
+#define TOSA_KEY_SYNC KEY_102ND /* ??? */
+
+
+#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES
+#define TOSA_KEY_RECORD KEY_YEN
+#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA
+#define TOSA_KEY_CANCEL KEY_ESC
+#define TOSA_KEY_CENTER KEY_HIRAGANA
+#define TOSA_KEY_OK KEY_HENKAN
+#define TOSA_KEY_CALENDAR KEY_KATAKANAHIRAGANA
+#define TOSA_KEY_HOMEPAGE KEY_HANGEUL
+#define TOSA_KEY_LIGHT KEY_MUHENKAN
+#define TOSA_KEY_MENU KEY_HANJA
+#define TOSA_KEY_FN KEY_RIGHTALT
+#define TOSA_KEY_MAIL KEY_ZENKAKUHANKAKU
+#else
+#define TOSA_KEY_RECORD KEY_RECORD
+#define TOSA_KEY_ADDRESSBOOK KEY_ADDRESSBOOK
+#define TOSA_KEY_CANCEL KEY_CANCEL
+#define TOSA_KEY_CENTER KEY_SELECT /* ??? */
+#define TOSA_KEY_OK KEY_OK
+#define TOSA_KEY_CALENDAR KEY_CALENDAR
+#define TOSA_KEY_HOMEPAGE KEY_HOMEPAGE
+#define TOSA_KEY_LIGHT KEY_KBDILLUMTOGGLE
+#define TOSA_KEY_MENU KEY_MENU
+#define TOSA_KEY_FN KEY_FN
+#define TOSA_KEY_MAIL KEY_MAIL
+#endif
+
#endif /* _ASM_ARCH_TOSA_H_ */
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2008-01-03 23:01 ` Dmitry Baryshkov
2008-01-03 23:08 ` Dmitry Baryshkov
@ 2008-01-11 14:56 ` Dmitry Torokhov
2008-01-11 16:38 ` Dmitry Baryshkov
1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2008-01-11 14:56 UTC (permalink / raw)
To: Dmitry Baryshkov; +Cc: linux-input, linux-arm-kernel
Hi,
On Jan 3, 2008 6:01 PM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
>
> >
> > Also, I'd put these defines rigth in tosakbd.c.
>
> The TOSA_KEY_RECORD and SYNC are used inside arch/arm/mach-pxa/tosa.c
> (for gpio-keys declaration). So I would prefer to place all such defines here.
> When the Kdrive would be fixed, I would drop KEY_RECORD and happily move
> that defines to tosakbd.c
>
Ok, fair enough. Because driver touches arch-specific arm parts it
does not apply cleanly to my tree. I think the best way would be to
merge it through arm side, this will minimize merge efforts Feel free
to add:
Acked-by: Dmitry Torokhov <dtor@mail.ru>
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2008-01-11 14:56 ` Dmitry Torokhov
@ 2008-01-11 16:38 ` Dmitry Baryshkov
2008-01-11 20:52 ` Dmitry Torokhov
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Baryshkov @ 2008-01-11 16:38 UTC (permalink / raw)
To: linux-input; +Cc: linux-arm-kernel
Hi,
Dmitry Torokhov wrote:
> Hi,
>
> On Jan 3, 2008 6:01 PM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
>>
>>
>> > Also, I'd put these defines rigth in tosakbd.c.
>>
>> The TOSA_KEY_RECORD and SYNC are used inside arch/arm/mach-pxa/tosa.c
>> (for gpio-keys declaration). So I would prefer to place all such
>> defines here. When the Kdrive would be fixed, I would drop KEY_RECORD
>> and happily move that defines to tosakbd.c
>>
>>
> Ok, fair enough. Because driver touches arch-specific arm parts it does
> not apply cleanly to my tree. I think the best way would be to merge it
> through arm side, this will minimize merge efforts Feel free to add:
Strange. The patch is against 2.6.24-rc7 and applies cleanly to both
for-linus and master branches of .../dtor/input.git
> Acked-by: Dmitry Torokhov <dtor@mail.ru>
Russell, do I need to resent patch?
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Tosa keyboard support
2008-01-11 16:38 ` Dmitry Baryshkov
@ 2008-01-11 20:52 ` Dmitry Torokhov
0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2008-01-11 20:52 UTC (permalink / raw)
To: Dmitry Baryshkov; +Cc: linux-input, linux-arm-kernel
On Jan 11, 2008 11:38 AM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
> Hi,
>
>
> Dmitry Torokhov wrote:
>
> > Hi,
> >
> > On Jan 3, 2008 6:01 PM, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
> >>
> >>
> >> > Also, I'd put these defines rigth in tosakbd.c.
> >>
> >> The TOSA_KEY_RECORD and SYNC are used inside arch/arm/mach-pxa/tosa.c
> >> (for gpio-keys declaration). So I would prefer to place all such
> >> defines here. When the Kdrive would be fixed, I would drop KEY_RECORD
> >> and happily move that defines to tosakbd.c
> >>
> >>
> > Ok, fair enough. Because driver touches arch-specific arm parts it does
> > not apply cleanly to my tree. I think the best way would be to merge it
> > through arm side, this will minimize merge efforts Feel free to add:
>
> Strange. The patch is against 2.6.24-rc7 and applies cleanly to both
> for-linus and master branches of .../dtor/input.git
Hmm, I think the version I originally tried did not... Anyway, my
concern is that when flood gates for .25 are opened there will be alot
of changes in PXA land. However changes to input side are trivial
(Kconfig and Makefile) and are resolved much easier so if you
coordinate with Russel it will work much better.
> > Acked-by: Dmitry Torokhov <dtor@mail.ru>
>
> Russell, do I need to resent patch?
>
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-01-11 20:52 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11 15:23 [PATCH] Tosa keyboard support Dmitry Baryshkov
2007-12-11 15:38 ` Dmitry Baryshkov
2007-12-16 10:29 ` Russell King - ARM Linux
2007-12-16 10:52 ` Dmitry
2007-12-16 10:51 ` Dmitry
-- strict thread matches above, loose matches on Subject: below --
2007-12-23 23:29 Dmitry Baryshkov
2008-01-03 16:51 ` Dmitry Torokhov
2008-01-03 23:01 ` Dmitry Baryshkov
2008-01-03 23:08 ` Dmitry Baryshkov
2008-01-11 14:56 ` Dmitry Torokhov
2008-01-11 16:38 ` Dmitry Baryshkov
2008-01-11 20:52 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).