This series of patches adds support for an external keyboard (called mailboard) connected to the Amstrad Delta (E3) videophone.
The series is based on a patch by Matt Callow, created against linux-omap-2.6.19[1], initially submitted to the e3-hacking mailing list in April 2006[2].
Since the keyboard serial clock line is connected to a GPIO input, it generates interrupts every single bit received. In order to handle this correctly, the code makes use of a FIQ hardware feature. Since all GPIO generated interrupts would be converted to FIQ, the handler must include support for all supported GPIO connected devices: the keyboard, a modem and a hook switch.
My initial modifications to the original patch included: - split into several patches, - refresh against a recent linux version, - a lot of cleanups, mainly to get rid of checkpatch reported issues, - add support for handling interrupts generated by a GPIO line that the meanwhile activated hook switch hangs off. v2 changes: - remove scan code to key code mapping from the serio driver, that doesn't belong here and should be set up from userspace; thanks to Dmitry Torokhov for advising this[3], - no funtional changes in FIQ part (there were no comments in round 1). v3 changes: - cleanups suggested by Dmitry[4] (applied not only to serio bits), - assembly code optimizations suggested by Ralph Corderoy[5], - (re)use existing header file provided macros where applicable instead of defining new; remove a lot of unnecessary defines, - extract missing FIQ_START definition fix into an extra patch number 0.1/5(7), - modify both fiq and deferred_fiq handlers to follow default OMAP GPIO interrupt processing path more closely, - update board initialization code for complete modem IRQ GPIO line setup; this appeared essential for correct interaction with optimized FIQ handler; the change is provided as a separate patch number 2.1/5(7), - use IRQ12 (reserved on OMAP1510) for requesting deferred_fiq handler instead of TIMER32k dedicated IRQ, - more optimizations in both assembly and C code, - modify serio Kconfig for automatic AT keyboard and FIQ handler selection, - drop intermediate defconfig changes. v4 changes: - changes requested by Dmitry for his Ack to be valid[6], - correct a few occurrences of 2nd argumet missing in 3-argument assembly instruction, thanks to Ralph Corderoy for pointing them out, - remove commented out code for interrupt active edge toggling, but keep the updated comment that justifies the removal.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Compile tested with a bunch of OMAP15XX/OMAP16XX boards selected simultaneously, as requested by Tony[7].
Janusz Krzysztofik(7) OMAP: add missing FIQ_START definition required for arch/arm/kernel/fiq.c compilation OMAP1: Amstrad Delta: add FIQ handler for serial keyboard port interrupt processing OMAP1: Amstrad Delta: add a handler for processing interrupts generated by the FIQ routine OMAP1: Amstrad Delta: update board initialization code for complete modem IRQ GPIO line setup OMAP1: Amstrad Delta: use FIQ for processing GPIO interrupts input: serio: add support for Amstrad Delta serial keyboard port OMAP1: Amstrad Delta: modify defconfig for external keyboard support
arch/arm/configs/ams_delta_defconfig | 1 arch/arm/mach-omap1/Kconfig | 10 arch/arm/mach-omap1/Makefile | 3 arch/arm/mach-omap1/ams-delta-fiq-handler.S | 278 +++++++++++++++++++++++ arch/arm/mach-omap1/ams-delta-fiq.c | 155 ++++++++++++ arch/arm/mach-omap1/board-ams-delta.c | 18 + arch/arm/mach-omap1/include/mach/ams-delta-fiq.h | 79 ++++++ arch/arm/plat-omap/include/plat/irqs.h | 4 drivers/input/serio/Kconfig | 16 + drivers/input/serio/Makefile | 1 drivers/input/serio/ams_delta_serio.c | 177 ++++++++++++++ 11 files changed, 740 insertions(+), 2 deletions(-)
Thanks, Janusz
[1] http://the.earth.li/pub/e3/2.6.19/ams-delta-keyboard.patch [2] http://www.earth.li/pipermail/e3-hacking/2006-April/000453.html [3] http://www.spinics.net/lists/linux-input/msg07690.html [4] http://www.spinics.net/lists/linux-input/msg07762.html [5] http://www.spinics.net/lists/linux-omap/msg27373.html [6] http://www.spinics.net/lists/linux-input/msg08093.html [7] http://www.spinics.net/lists/linux-omap/msg28535.html
Several ARM platforms/machines that use FIQ define their value of FIQ_START. Since FIQ is not implemented for OMAP yet, this definition is missing from OMAP header files.
Put an arbitrary value for FIQ_START into plat/irqs.h for OMAP. Even if not used by the FIQ handler for Amstrad Delta, this is required for successfull compilation of arch/arm/plat-omap/fiq.c that provides several usefull functions.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- Provided as a separate patch since v3 of the patch set. v4 changes: none (refreshed)
arch/arm/plat-omap/include/plat/irqs.h | 4 ++++ 1 file changed, 4 insertions(+)
--- git.orig/arch/arm/plat-omap/include/plat/irqs.h 2010-04-27 21:40:24.000000000 +0200 +++ git/arch/arm/plat-omap/include/plat/irqs.h 2010-04-27 22:20:18.000000000 +0200 @@ -428,4 +428,8 @@ void omap3_intc_resume_idle(void);
#include <mach/hardware.h>
+#ifdef CONFIG_FIQ +#define FIQ_START 1024 +#endif + #endif
Several ARM platforms/machines that use FIQ define their value of FIQ_START. Since FIQ is not implemented for OMAP yet, this definition is missing from OMAP header files.
Put an arbitrary value for FIQ_START into plat/irqs.h for OMAP. Even if not used by the FIQ handler for Amstrad Delta, this is required for successfull compilation of arch/arm/kernel/fiq.c that provides several usefull functions.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- Affected file name was still wrong in the changelog text, sorry.
Provided as a separate patch since v3 of the patch set. v4 changes: none (refreshed)
arch/arm/plat-omap/include/plat/irqs.h | 4 ++++ 1 file changed, 4 insertions(+)
--- git.orig/arch/arm/plat-omap/include/plat/irqs.h 2010-04-27 21:40:24.000000000 +0200 +++ git/arch/arm/plat-omap/include/plat/irqs.h 2010-04-27 22:20:18.000000000 +0200 @@ -428,4 +428,8 @@ void omap3_intc_resume_idle(void);
#include <mach/hardware.h>
+#ifdef CONFIG_FIQ +#define FIQ_START 1024 +#endif + #endif
This patch introduces a Fast Interrupt Request (FIQ) handler for Amstrad Delta (E3) videophone. The handler's purpose is to process interrupts generated by a GPIO line that a serial keyboard clock hangs off. It collects consecutive bits into words, pushing them into a buffer, then requests a higher level interrupt after one or more words are ready for further processing by a keyboard port driver.
The handler also processes interrupts generated by two other GPIO lines, used by other on-board supported devices, by simply requesting a higher level interrupt, that in turn should invoke those device's specific irq handlers.
IRQ12 line, not used by OMAP1510 hardware (described as reserved), has been choosen as a higher level interrupt source.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Compiles on top of PATCH v4 0.1/5(7), "OMAP: add missing FIQ_START definition required for arch/arm/kernel/fiq.c compilation".
Compile tested with a bunch of OMAP15XX/OMAP16XX boards selected simultaneously.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- v2 changes: - no functional changes, - refresh against linux-2.6.34-rc2. v3 changes: - assembler code optimizations suggested by Ralph Corderoy, - (re)use existing header file provided macros where applicable instead of defining new (from scratch); remove a lot of unnecessary defines, - follow default OMAP GPIO interrupt processing path more closely, - prepare for choosing arbitrary IRQ for deferred_fiq handler; use IRQ12 (reserved on OMAP1510) instead of Timer 32K dedicated IRQ, - more optimizations for smaller code. v4 changes: - correct a few occurrences of 2nd argumet missing in 3-argument assembly instruction, thanks to Ralph Corderoy for pointing them out, - remove commented out code for interrupt active edge toggling, but keep the updated comment that justifies the removal.
arch/arm/mach-omap1/Kconfig | 10 arch/arm/mach-omap1/Makefile | 1 arch/arm/mach-omap1/ams-delta-fiq-handler.S | 278 +++++++++++++++++++++++ arch/arm/mach-omap1/include/mach/ams-delta-fiq.h | 72 +++++ 4 files changed, 361 insertions(+)
diff -uprN git.orig/arch/arm/mach-omap1/Kconfig git/arch/arm/mach-omap1/Kconfig --- git.orig/arch/arm/mach-omap1/Kconfig 2010-04-27 21:40:22.000000000 +0200 +++ git/arch/arm/mach-omap1/Kconfig 2010-04-27 22:23:41.000000000 +0200 @@ -152,6 +152,16 @@ config MACH_AMS_DELTA Support for the Amstrad E3 (codename Delta) videophone. Say Y here if you have such a device.
+config AMS_DELTA_FIQ + bool "Fast Interrupt Request (FIQ) support for the E3" + depends on MACH_AMS_DELTA + select FIQ + help + Provide a FIQ handler for the E3. + This allows for fast handling of interrupts generated + by the clock line of the E3 mailboard (or a PS/2 keyboard) + connected to the GPIO based external keyboard port. + config MACH_OMAP_GENERIC bool "Generic OMAP board" depends on ARCH_OMAP1 && (ARCH_OMAP15XX || ARCH_OMAP16XX) diff -uprN git.orig/arch/arm/mach-omap1/Makefile git/arch/arm/mach-omap1/Makefile --- git.orig/arch/arm/mach-omap1/Makefile 2010-04-27 21:40:22.000000000 +0200 +++ git/arch/arm/mach-omap1/Makefile 2010-04-27 22:23:41.000000000 +0200 @@ -37,6 +37,7 @@ obj-$(CONFIG_MACH_OMAP_PALMZ71) += boar obj-$(CONFIG_MACH_OMAP_PALMTT) += board-palmtt.o obj-$(CONFIG_MACH_NOKIA770) += board-nokia770.o obj-$(CONFIG_MACH_AMS_DELTA) += board-ams-delta.o +obj-$(CONFIG_AMS_DELTA_FIQ) += ams-delta-fiq-handler.o obj-$(CONFIG_MACH_SX1) += board-sx1.o board-sx1-mmc.o obj-$(CONFIG_MACH_HERALD) += board-htcherald.o
diff -uprN git.orig/arch/arm/mach-omap1/ams-delta-fiq-handler.S git/arch/arm/mach-omap1/ams-delta-fiq-handler.S --- git.orig/arch/arm/mach-omap1/ams-delta-fiq-handler.S 1970-01-01 01:00:00.000000000 +0100 +++ git/arch/arm/mach-omap1/ams-delta-fiq-handler.S 2010-04-27 22:23:41.000000000 +0200 @@ -0,0 +1,278 @@ +/* + * linux/arch/arm/mach-omap1/ams-delta-fiq-handler.S + * + * Based on linux/arch/arm/lib/floppydma.S + * Renamed and modified to work with 2.6 kernel by Matt Callow + * Copyright (C) 1995, 1996 Russell King + * Copyright (C) 2004 Pete Trapps + * Copyright (C) 2006 Matt Callow + * Copyright (C) 2010 Janusz Krzysztofik + * + * 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/linkage.h> + +#include <plat/io.h> +#include <plat/board-ams-delta.h> + +#include <mach/ams-delta-fiq.h> + +/* + * GPIO related definitions, copied from arch/arm/plat-omap/gpio.c. + * Unfortunately, those were not placed in a separate header file. + */ +#define OMAP1510_GPIO_BASE 0xFFFCE000 +#define OMAP1510_GPIO_DATA_INPUT 0x00 +#define OMAP1510_GPIO_DATA_OUTPUT 0x04 +#define OMAP1510_GPIO_DIR_CONTROL 0x08 +#define OMAP1510_GPIO_INT_CONTROL 0x0c +#define OMAP1510_GPIO_INT_MASK 0x10 +#define OMAP1510_GPIO_INT_STATUS 0x14 +#define OMAP1510_GPIO_PIN_CONTROL 0x18 + +/* GPIO register bitmasks */ +#define KEYBRD_DATA_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_DATA) +#define KEYBRD_CLK_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_CLK) +#define MODEM_IRQ_MASK (0x1 << AMS_DELTA_GPIO_PIN_MODEM_IRQ) +#define HOOK_SWITCH_MASK (0x1 << AMS_DELTA_GPIO_PIN_HOOK_SWITCH) +#define OTHERS_MASK (MODEM_IRQ_MASK | HOOK_SWITCH_MASK) + +/* IRQ handler register bitmasks */ +#define DEFERRED_FIQ_MASK (0x1 << (INT_DEFERRED_FIQ % IH2_BASE)) +#define GPIO_BANK1_MASK (0x1 << INT_GPIO_BANK1) + +/* Driver buffer byte offsets */ +#define BUF_MASK (FIQ_MASK * 4) +#define BUF_STATE (FIQ_STATE * 4) +#define BUF_KEYS_CNT (FIQ_KEYS_CNT * 4) +#define BUF_TAIL_OFFSET (FIQ_TAIL_OFFSET * 4) +#define BUF_HEAD_OFFSET (FIQ_HEAD_OFFSET * 4) +#define BUF_BUF_LEN (FIQ_BUF_LEN * 4) +#define BUF_KEY (FIQ_KEY * 4) +#define BUF_MISSED_KEYS (FIQ_MISSED_KEYS * 4) +#define BUF_BUFFER_START (FIQ_BUFFER_START * 4) +#define BUF_GPIO_INT_MASK (FIQ_GPIO_INT_MASK * 4) +#define BUF_KEYS_HICNT (FIQ_KEYS_HICNT * 4) +#define BUF_IRQ_PEND (FIQ_IRQ_PEND * 4) +#define BUF_SIR_CODE_L1 (FIQ_SIR_CODE_L1 * 4) +#define BUF_SIR_CODE_L2 (IRQ_SIR_CODE_L2 * 4) +#define BUF_CNT_INT_00 (FIQ_CNT_INT_00 * 4) +#define BUF_CNT_INT_KEY (FIQ_CNT_INT_KEY * 4) +#define BUF_CNT_INT_MDM (FIQ_CNT_INT_MDM * 4) +#define BUF_CNT_INT_03 (FIQ_CNT_INT_03 * 4) +#define BUF_CNT_INT_HSW (FIQ_CNT_INT_HSW * 4) +#define BUF_CNT_INT_05 (FIQ_CNT_INT_05 * 4) +#define BUF_CNT_INT_06 (FIQ_CNT_INT_06 * 4) +#define BUF_CNT_INT_07 (FIQ_CNT_INT_07 * 4) +#define BUF_CNT_INT_08 (FIQ_CNT_INT_08 * 4) +#define BUF_CNT_INT_09 (FIQ_CNT_INT_09 * 4) +#define BUF_CNT_INT_10 (FIQ_CNT_INT_10 * 4) +#define BUF_CNT_INT_11 (FIQ_CNT_INT_11 * 4) +#define BUF_CNT_INT_12 (FIQ_CNT_INT_12 * 4) +#define BUF_CNT_INT_13 (FIQ_CNT_INT_13 * 4) +#define BUF_CNT_INT_14 (FIQ_CNT_INT_14 * 4) +#define BUF_CNT_INT_15 (FIQ_CNT_INT_15 * 4) +#define BUF_CIRC_BUFF (FIQ_CIRC_BUFF * 4) + + +/* + * Register useage + * r8 - temporary + * r9 - the driver buffer + * r10 - temporary + * r11 - interrupts mask + * r12 - base pointers + * r13 - interrupts status + */ + + .text + + .global qwerty_fiqin_end + +ENTRY(qwerty_fiqin_start) + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @ FIQ intrrupt handler + ldr r12, omap_ih1_base @ set pointer to level1 handler + + ldr r11, [r12, #IRQ_MIR_REG_OFFSET] @ fetch interrupts mask + + ldr r13, [r12, #IRQ_ITR_REG_OFFSET] @ fetch interrupts status + bics r13, r13, r11 @ clear masked - any left? + beq exit @ none - spurious FIQ? exit + + ldr r10, [r12, #IRQ_SIR_FIQ_REG_OFFSET] @ get requested interrupt number + + mov r8, #2 @ reset FIQ agreement + str r8, [r12, #IRQ_CONTROL_REG_OFFSET] + + cmp r10, #INT_GPIO_BANK1 @ is it GPIO bank interrupt? + beq gpio @ yes - process it + + mov r8, #1 + orr r8, r11, r8, lsl r10 @ mask spurious interrupt + str r8, [r12, #IRQ_MIR_REG_OFFSET] +exit: + subs pc, lr, #4 @ return from FIQ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + + @@@@@@@@@@@@@@@@@@@@@@@@@@@ +gpio: @ GPIO bank interrupt handler + ldr r12, omap1510_gpio_base @ set base pointer to GPIO bank + + ldr r11, [r12, #OMAP1510_GPIO_INT_MASK] @ fetch GPIO interrupts mask +restart: + ldr r13, [r12, #OMAP1510_GPIO_INT_STATUS] @ fetch status bits + bics r13, r13, r11 @ clear masked - any left? + beq exit @ no - spurious interrupt? exit + + orr r11, r11, r13 @ mask all requested interrupts + str r11, [r12, #OMAP1510_GPIO_INT_MASK] + + ands r10, r13, #KEYBRD_CLK_MASK @ extract keyboard status - set? + beq hksw @ no - try next source + + + @@@@@@@@@@@@@@@@@@@@@@ + @ Keyboard clock FIQ mode interrupt handler + @ r10 now contains KEYBRD_CLK_MASK, use it + str r10, [r12, #OMAP1510_GPIO_INT_STATUS] @ ack the interrupt + bic r11, r11, r10 @ unmask it + str r11, [r12, #OMAP1510_GPIO_INT_MASK] + + @ Process keyboard data + ldr r8, [r12, #OMAP1510_GPIO_DATA_INPUT] @ fetch GPIO input + + ldr r10, [r9, #BUF_STATE] @ fetch kbd interface state + cmp r10, #0 @ are we expecting start bit? + bne data @ no - go to data processing + + ands r8, r8, #KEYBRD_DATA_MASK @ check start bit - detected? + beq hksw @ no - try next source + + @ r8 contains KEYBRD_DATA_MASK, use it + str r8, [r9, #BUF_STATE] @ enter data processing state + @ r10 already contains 0, reuse it + str r10, [r9, #BUF_KEY] @ clear keycode + mov r10, #2 @ reset input bit mask + str r10, [r9, #BUF_MASK] + + @ Mask other GPIO line interrupts till key done + str r11, [r9, #BUF_GPIO_INT_MASK] @ save mask for later restore + mvn r11, #KEYBRD_CLK_MASK @ prepare all except kbd mask + str r11, [r12, #OMAP1510_GPIO_INT_MASK] @ store into the mask register + + b restart @ restart + +data: ldr r10, [r9, #BUF_MASK] @ fetch current input bit mask + + @ r8 still contains GPIO input bits + ands r8, r8, #KEYBRD_DATA_MASK @ is keyboard data line low? + ldreq r8, [r9, #BUF_KEY] @ yes - fetch collected so far, + orreq r8, r8, r10 @ set 1 at current mask position + streq r8, [r9, #BUF_KEY] @ and save back + + mov r10, r10, lsl #1 @ shift mask left + bics r10, r10, #0x800 @ have we got all the bits? + strne r10, [r9, #BUF_MASK] @ not yet - store the mask + bne restart @ and restart + + @ r10 already contains 0, reuse it + str r10, [r9, #BUF_STATE] @ reset state to start + + @ Key done - restore interrupt mask + ldr r10, [r9, #BUF_GPIO_INT_MASK] @ fetch saved mask + and r11, r11, r10 @ unmask all saved as unmasked + str r11, [r12, #OMAP1510_GPIO_INT_MASK] @ restore into the mask register + + @ Try appending the keycode to the circular buffer + ldr r10, [r9, #BUF_KEYS_CNT] @ get saved keystrokes count + ldr r8, [r9, #BUF_BUF_LEN] @ get buffer size + cmp r10, r8 @ is buffer full? + beq hksw @ yes - key lost, next source + + add r10, r10, #1 @ incremet keystrokes counter + str r10, [r9, #BUF_KEYS_CNT] + + ldr r10, [r9, #BUF_TAIL_OFFSET] @ get buffer tail offset + @ r8 already contains buffer size + cmp r10, r8 @ end of buffer? + moveq r10, #0 @ yes - rewind to buffer start + + ldr r12, [r9, #BUF_BUFFER_START] @ get buffer start address + add r12, r12, r10, LSL #2 @ calculate buffer tail address + ldr r8, [r9, #BUF_KEY] @ get last keycode + str r8, [r12] @ append it to the buffer tail + + add r10, r10, #1 @ increment buffer tail offset + str r10, [r9, #BUF_TAIL_OFFSET] + + ldr r10, [r9, #BUF_CNT_INT_KEY] @ increment interrupts counter + add r10, r10, #1 + str r10, [r9, #BUF_CNT_INT_KEY] + @@@@@@@@@@@@@@@@@@@@@@@@ + + +hksw: @Is hook switch interrupt requested? + tst r13, #HOOK_SWITCH_MASK @ is hook switch status bit set? + beq mdm @ no - try next source + + + @@@@@@@@@@@@@@@@@@@@@@@@ + @ Hook switch interrupt FIQ mode simple handler + + @ Don't toggle active edge, the switch always bounces + + @ Increment hook switch interrupt counter + ldr r10, [r9, #BUF_CNT_INT_HSW] + add r10, r10, #1 + str r10, [r9, #BUF_CNT_INT_HSW] + @@@@@@@@@@@@@@@@@@@@@@@@ + + +mdm: @Is it a modem interrupt? + tst r13, #MODEM_IRQ_MASK @ is modem status bit set? + beq irq @ no - check for next interrupt + + + @@@@@@@@@@@@@@@@@@@@@@@@ + @ Modem FIQ mode interrupt handler stub + + @ Increment modem interrupt counter + ldr r10, [r9, #BUF_CNT_INT_MDM] + add r10, r10, #1 + str r10, [r9, #BUF_CNT_INT_MDM] + @@@@@@@@@@@@@@@@@@@@@@@@ + + +irq: @ Place deferred_fiq interrupt request + ldr r12, deferred_fiq_ih_base @ set pointer to IRQ handler + mov r10, #DEFERRED_FIQ_MASK @ set deferred_fiq bit + str r10, [r12, #IRQ_ISR_REG_OFFSET] @ place it in the ISR register + + ldr r12, omap1510_gpio_base @ set pointer back to GPIO bank + b restart @ check for next GPIO interrupt + @@@@@@@@@@@@@@@@@@@@@@@@@@@ + + +/* + * Virtual addresses for IO + */ +omap_ih1_base: + .word OMAP1_IO_ADDRESS(OMAP_IH1_BASE) +deferred_fiq_ih_base: + .word OMAP1_IO_ADDRESS(DEFERRED_FIQ_IH_BASE) +omap1510_gpio_base: + .word OMAP1_IO_ADDRESS(OMAP1510_GPIO_BASE) +qwerty_fiqin_end: + +/* + * Check the size of the FIQ, + * it cannot go beyond 0xffff0200, and is copied to 0xffff001c + */ +.if (qwerty_fiqin_end - qwerty_fiqin_start) > (0x200 - 0x1c) + .err +.endif diff -uprN git.orig/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h git/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h --- git.orig/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h 1970-01-01 01:00:00.000000000 +0100 +++ git/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h 2010-04-27 22:23:41.000000000 +0200 @@ -0,0 +1,72 @@ +/* + * arch/arm/mach-omap1/include/ams-delta-fiq.h + * + * Taken from the original Amstrad modifications to fiq.h + * + * Copyright (c) 2004 Amstrad Plc + * Copyright (c) 2006 Matt Callow + * Copyright (c) 2010 Janusz Krzysztofik + * + * 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. + */ +#ifndef __AMS_DELTA_FIQ_H +#define __AMS_DELTA_FIQ_H + +#include <plat/irqs.h> + +/* + * Interrupt number used for passing control from FIQ to IRQ. + * IRQ12, described as reserved, has been selected. + */ +#define INT_DEFERRED_FIQ INT_1510_RES12 +/* + * Base address of an interrupt handler that the INT_DEFERRED_FIQ belongs to. + */ +#if (INT_DEFERRED_FIQ < IH2_BASE) +#define DEFERRED_FIQ_IH_BASE OMAP_IH1_BASE +#else +#define DEFERRED_FIQ_IH_BASE OMAP_IH2_BASE +#endif + +/* + * These are the offsets from the begining of the fiq_buffer. They are put here + * since the buffer and header need to be accessed by drivers servicing devices + * which generate GPIO interrupts - e.g. keyboard, modem, hook switch. + */ +#define FIQ_MASK 0 +#define FIQ_STATE 1 +#define FIQ_KEYS_CNT 2 +#define FIQ_TAIL_OFFSET 3 +#define FIQ_HEAD_OFFSET 4 +#define FIQ_BUF_LEN 5 +#define FIQ_KEY 6 +#define FIQ_MISSED_KEYS 7 +#define FIQ_BUFFER_START 8 +#define FIQ_GPIO_INT_MASK 9 +#define FIQ_KEYS_HICNT 10 +#define FIQ_IRQ_PEND 11 +#define FIQ_SIR_CODE_L1 12 +#define IRQ_SIR_CODE_L2 13 + +#define FIQ_CNT_INT_00 14 +#define FIQ_CNT_INT_KEY 15 +#define FIQ_CNT_INT_MDM 16 +#define FIQ_CNT_INT_03 17 +#define FIQ_CNT_INT_HSW 18 +#define FIQ_CNT_INT_05 19 +#define FIQ_CNT_INT_06 20 +#define FIQ_CNT_INT_07 21 +#define FIQ_CNT_INT_08 22 +#define FIQ_CNT_INT_09 23 +#define FIQ_CNT_INT_10 24 +#define FIQ_CNT_INT_11 25 +#define FIQ_CNT_INT_12 26 +#define FIQ_CNT_INT_13 27 +#define FIQ_CNT_INT_14 28 +#define FIQ_CNT_INT_15 29 + +#define FIQ_CIRC_BUFF 30 /*Start of circular buffer */ + +#endif
This patch introduces an IRQ handler used for processing interrupts generated by the FIQ handler when it decides there are data ready for processing.
The handler further invokes device specific interrupt routines based on interrupt source counters passed from the FIQ handler.
The handler setup function is intended to be called from the board provided init_machine() callback.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Applies on top of PATCH v4 1/5(7), "OMAP1: Amstrad Delta: add FIQ handler for serial keyboard port interrupt processing".
Compile tested with a bunch of OMAP15XX/OMAP16XX boards selected simultaneously.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- v2 changes: - add fiq_buffer[] declaration missing from the header file, - refresh against 2.6.34-rc2. v3 changes: - follow Dmitry's serio cleanup suggestions here as well, - follow default OMAP GPIO interrupt processing path more closely, - more optimizations and cleanups. v4 changes: none.
arch/arm/mach-omap1/Makefile | 2 arch/arm/mach-omap1/ams-delta-fiq.c | 155 +++++++++++++++++++++++ arch/arm/mach-omap1/include/mach/ams-delta-fiq.h | 7 + 3 files changed, 163 insertions(+), 1 deletion(-)
diff -uprN git.orig/arch/arm/mach-omap1/Makefile git/arch/arm/mach-omap1/Makefile --- git.orig/arch/arm/mach-omap1/Makefile 2010-04-27 22:27:37.000000000 +0200 +++ git/arch/arm/mach-omap1/Makefile 2010-04-27 22:28:13.000000000 +0200 @@ -37,7 +37,7 @@ obj-$(CONFIG_MACH_OMAP_PALMZ71) += boar obj-$(CONFIG_MACH_OMAP_PALMTT) += board-palmtt.o obj-$(CONFIG_MACH_NOKIA770) += board-nokia770.o obj-$(CONFIG_MACH_AMS_DELTA) += board-ams-delta.o -obj-$(CONFIG_AMS_DELTA_FIQ) += ams-delta-fiq-handler.o +obj-$(CONFIG_AMS_DELTA_FIQ) += ams-delta-fiq.o ams-delta-fiq-handler.o obj-$(CONFIG_MACH_SX1) += board-sx1.o board-sx1-mmc.o obj-$(CONFIG_MACH_HERALD) += board-htcherald.o
diff -uprN git.orig/arch/arm/mach-omap1/ams-delta-fiq.c git/arch/arm/mach-omap1/ams-delta-fiq.c --- git.orig/arch/arm/mach-omap1/ams-delta-fiq.c 1970-01-01 01:00:00.000000000 +0100 +++ git/arch/arm/mach-omap1/ams-delta-fiq.c 2010-04-27 22:28:13.000000000 +0200 @@ -0,0 +1,155 @@ +/* + * Amstrad E3 FIQ handling + * + * Copyright (C) 2009 Janusz Krzysztofik + * Copyright (c) 2006 Matt Callow + * Copyright (c) 2004 Amstrad Plc + * Copyright (C) 2001 RidgeRun, Inc. + * + * Parts of this code are taken from linux/arch/arm/mach-omap/irq.c + * in the MontaVista 2.4 kernel (and the Amstrad changes therein) + * + * 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/gpio.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/module.h> + +#include <plat/io.h> +#include <plat/board-ams-delta.h> + +#include <asm/fiq.h> +#include <mach/ams-delta-fiq.h> + +static struct fiq_handler fh = { + .name = "ams-delta-fiq" +}; + +/* + * This buffer is shared between FIQ and IRQ contexts. + * The FIQ and IRQ isrs can both read and write it. + * It is structured as a header section several 32bit slots, + * followed by the circular buffer where the FIQ isr stores + * keystrokes received from the qwerty keyboard. + * See ams-delta-fiq.h for details of offsets. + */ +unsigned int fiq_buffer[1024]; +EXPORT_SYMBOL(fiq_buffer); + +static unsigned int irq_counter[16]; + +static irqreturn_t deferred_fiq(int irq, void *dev_id) +{ + struct irq_desc *irq_desc; + struct irq_chip *irq_chip = NULL; + int gpio, irq_num, fiq_count; + + irq_desc = irq_to_desc(IH_GPIO_BASE); + if (irq_desc) + irq_chip = irq_desc->chip; + + /* + * For each handled GPIO interrupt, keep calling its interrupt handler + * until the IRQ counter catches the FIQ incremented interrupt counter. + */ + for (gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK; + gpio <= AMS_DELTA_GPIO_PIN_HOOK_SWITCH; gpio++) { + irq_num = gpio_to_irq(gpio); + fiq_count = fiq_buffer[FIQ_CNT_INT_00 + gpio]; + + while (irq_counter[gpio] < fiq_count) { + if (gpio != AMS_DELTA_GPIO_PIN_KEYBRD_CLK) { + /* + * It looks like handle_edge_irq() that + * OMAP GPIO edge interrupts default to, + * expects interrupt already unmasked. + */ + if (irq_chip && irq_chip->unmask) + irq_chip->unmask(irq_num); + } + generic_handle_irq(irq_num); + + irq_counter[gpio]++; + } + } + return IRQ_HANDLED; +} + +void __init ams_delta_init_fiq(void) +{ + void *fiqhandler_start; + unsigned int fiqhandler_length; + struct pt_regs FIQ_regs; + unsigned long val, offset; + int i, retval; + + fiqhandler_start = &qwerty_fiqin_start; + fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start; + pr_info("Installing fiq handler from %p, length 0x%x\n", + fiqhandler_start, fiqhandler_length); + + retval = claim_fiq(&fh); + if (retval) { + pr_err("ams_delta_init_fiq(): couldn't claim FIQ, ret=%d\n", + retval); + return; + } + + retval = request_irq(INT_DEFERRED_FIQ, deferred_fiq, + IRQ_TYPE_EDGE_RISING, "deferred_fiq", 0); + if (retval < 0) { + pr_err("Failed to get deferred_fiq IRQ, ret=%d\n", retval); + release_fiq(&fh); + return; + } + /* + * Since no set_type() method is provided by OMAP irq chip, + * switch to edge triggered interrupt type manually. + */ + offset = IRQ_ILR0_REG_OFFSET + INT_DEFERRED_FIQ * 0x4; + val = omap_readl(DEFERRED_FIQ_IH_BASE + offset) & ~(1 << 1); + omap_writel(val, DEFERRED_FIQ_IH_BASE + offset); + + set_fiq_handler(fiqhandler_start, fiqhandler_length); + + /* + * Initialise the buffer which is shared + * between FIQ mode and IRQ mode + */ + fiq_buffer[FIQ_GPIO_INT_MASK] = 0; + fiq_buffer[FIQ_MASK] = 0; + fiq_buffer[FIQ_STATE] = 0; + fiq_buffer[FIQ_KEY] = 0; + fiq_buffer[FIQ_KEYS_CNT] = 0; + fiq_buffer[FIQ_KEYS_HICNT] = 0; + fiq_buffer[FIQ_TAIL_OFFSET] = 0; + fiq_buffer[FIQ_HEAD_OFFSET] = 0; + fiq_buffer[FIQ_BUF_LEN] = 256; + fiq_buffer[FIQ_MISSED_KEYS] = 0; + fiq_buffer[FIQ_BUFFER_START] = + (unsigned int) &fiq_buffer[FIQ_CIRC_BUFF]; + + for (i = FIQ_CNT_INT_00; i <= FIQ_CNT_INT_15; i++) + fiq_buffer[i] = 0; + + /* + * FIQ mode r9 always points to the fiq_buffer, becauses the FIQ isr + * will run in an unpredictable context. The fiq_buffer is the FIQ isr's + * only means of communication with the IRQ level and other kernel + * context code. + */ + FIQ_regs.ARM_r9 = (unsigned int)fiq_buffer; + set_fiq_regs(&FIQ_regs); + + pr_info("request_fiq(): fiq_buffer = %p\n", fiq_buffer); + + /* + * Redirect GPIO interrupts to FIQ + */ + offset = IRQ_ILR0_REG_OFFSET + INT_GPIO_BANK1 * 0x4; + val = omap_readl(OMAP_IH1_BASE + offset) | 1; + omap_writel(val, OMAP_IH1_BASE + offset); +} diff -uprN git.orig/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h git/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h --- git.orig/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h 2010-04-27 22:27:37.000000000 +0200 +++ git/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h 2010-04-27 22:28:13.000000000 +0200 @@ -69,4 +69,11 @@
#define FIQ_CIRC_BUFF 30 /*Start of circular buffer */
+#ifndef __ASSEMBLER__ +extern unsigned int fiq_buffer[]; +extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end; + +extern void __init ams_delta_init_fiq(void); +#endif + #endif
In case of Amstrad Delta modem utilized GPIO line, interrupt is requested from standard serial8250 driver code without first requesting the GPIO pin itself. Even if it works with default OMAP GPIO interrupt handler, it appeared not compatible with recent, optimized version of the board GPIO FIQ handler, required for fast processing of interrupts generated by other GPIO pin that a serial keyboard clock hangs off.
This patch fills the board specific modem initialization routine with common GPIO line reservation and direction setup.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- Introduced in v3 of the patch set. v4 changes: none.
arch/arm/mach-omap1/board-ams-delta.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
--- git.orig/arch/arm/mach-omap1/board-ams-delta.c 2010-04-27 21:40:22.000000000 +0200 +++ git/arch/arm/mach-omap1/board-ams-delta.c 2010-04-27 22:34:42.000000000 +0200 @@ -263,8 +263,18 @@ static struct platform_device ams_delta_
static int __init ams_delta_modem_init(void) { + int err; + omap_cfg_reg(M14_1510_GPIO2); - ams_delta_modem_ports[0].irq = gpio_to_irq(2); + ams_delta_modem_ports[0].irq = + gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); + + err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); + if (err) { + pr_err("Couldn't request gpio pin for modem\n"); + return err; + } + gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
ams_delta_latch2_write( AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
The patch adds initialization of FIQ related handlers to the Amstrad Delta videophone board code. FIQ will be used instead of a traditional IRQ for processing all GPIO generated interrupts, including a keyboard serial clock line.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Compiles and works on top of PATCH v4 2/5(7), "OMAP1: Amstrad Delta: add a handler for processing interrupts generated by the FIQ routine". Also requires PATCH v4 2.1/5(7), "OMAP1: Amstrad Delta: update board initialization code for complete modem IRQ GPIO line setup" for correct modem handling.
Compile tested with a bunch of OMAP15XX/OMAP16XX boards selected simultaneously.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- v2 changes: - no functional changes, - refreshed against linux-2.6.34-rc2. v3 changes: - drop intermediate defconfig modification. v4 changes: none.
arch/arm/mach-omap1/board-ams-delta.c | 6 ++++++ 1 file changed, 6 insertions(+)
--- git.orig/arch/arm/mach-omap1/board-ams-delta.c 2010-04-27 22:36:01.000000000 +0200 +++ git/arch/arm/mach-omap1/board-ams-delta.c 2010-04-27 22:36:18.000000000 +0200 @@ -33,6 +33,8 @@ #include <plat/board.h> #include <plat/common.h>
+#include <mach/ams-delta-fiq.h> + static u8 ams_delta_latch1_reg; static u16 ams_delta_latch2_reg;
@@ -236,6 +238,10 @@ static void __init ams_delta_init(void) omap_usb_init(&ams_delta_usb_config); platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
+#ifdef CONFIG_AMS_DELTA_FIQ + ams_delta_init_fiq(); +#endif + omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1); }
The patch introduces a serio driver that supports a keyboard serial port found on the Amstrad Delta videophone board.
After initializing the hardware, the driver reads its input data from a buffer filled in by the board FIQ (Fast Interrupt Request) handler.
Standard AT keyboard driver (atkbd) will be used on top of the serio layer for handling the E3 keyboard (called mailboard) connected to the port. Since the device generated scancodes differ from what the atkbd expects, a custom key code to scan code table must be loaded from userspace for the keyboard to be useable.
Compiles and works on top of PATCH v4 3/5(7), "OMAP1: Amstrad Delta: use FIQ for processing GPIO interrupts".
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- v2 changes: - use correct variable name for return value in ams_delta_kbd_init(), - remove scan code to key code mapping, - refreshed against linux-2.6.34-rc2. v3 changes: - cleanups suggested by Dmitry, - force using of handle_simple_irq() to avoid GPIO register manipulation, already handled at FIQ level, - modify Kconfig for automatic AT keyboard and FIQ handler selection, - misc cleanups. v4 changes: - drop automatic KEYBOARD_ATKBD selection and place the config back inside the "if SERIO"..."endif" block, - drop extra parenthesis.
drivers/input/serio/Kconfig | 16 +++ drivers/input/serio/Makefile | 1 drivers/input/serio/ams_delta_serio.c | 177 ++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+)
diff -uprN git.orig/drivers/input/serio/Kconfig git/drivers/input/serio/Kconfig --- git.orig/drivers/input/serio/Kconfig 2010-04-27 21:41:00.000000000 +0200 +++ git/drivers/input/serio/Kconfig 2010-04-27 22:38:48.000000000 +0200 @@ -209,4 +209,20 @@ config SERIO_ALTERA_PS2 To compile this driver as a module, choose M here: the module will be called altera_ps2.
+config SERIO_AMS_DELTA + tristate "Amstrad Delta (E3) mailboard support" + depends on MACH_AMS_DELTA + default y + select AMS_DELTA_FIQ + ---help--- + Say Y here if you have an E3 and want to use its mailboard, + or any standard AT keyboard connected to the mailboard port. + + When used for the E3 mailboard, a non-standard key table + must be loaded from userspace, possibly using udev extras + provided keymap helper utility. + + To compile this driver as a module, choose M here; + the module will be called ams_delta_serio. + endif diff -uprN git.orig/drivers/input/serio/Makefile git/drivers/input/serio/Makefile --- git.orig/drivers/input/serio/Makefile 2010-04-27 21:41:00.000000000 +0200 +++ git/drivers/input/serio/Makefile 2010-04-27 22:38:48.000000000 +0200 @@ -21,5 +21,6 @@ obj-$(CONFIG_SERIO_PCIPS2) += pcips2.o obj-$(CONFIG_SERIO_MACEPS2) += maceps2.o obj-$(CONFIG_SERIO_LIBPS2) += libps2.o obj-$(CONFIG_SERIO_RAW) += serio_raw.o +obj-$(CONFIG_SERIO_AMS_DELTA) += ams_delta_serio.o obj-$(CONFIG_SERIO_XILINX_XPS_PS2) += xilinx_ps2.o obj-$(CONFIG_SERIO_ALTERA_PS2) += altera_ps2.o diff -uprN git.orig/drivers/input/serio/ams_delta_serio.c git/drivers/input/serio/ams_delta_serio.c --- git.orig/drivers/input/serio/ams_delta_serio.c 1970-01-01 01:00:00.000000000 +0100 +++ git/drivers/input/serio/ams_delta_serio.c 2010-04-27 22:38:48.000000000 +0200 @@ -0,0 +1,177 @@ +/* + * Amstrad E3 (Delta) keyboard port driver + * + * Copyright (c) 2006 Matt Callow + * Copyright (c) 2010 Janusz Krzysztofik + * + * 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. + * + * Thanks to Cliff Lawson for his help + * + * The Amstrad Delta keyboard (aka mailboard) uses normal PC-AT style serial + * transmission. The keyboard port is formed of two GPIO lines, for clock + * and data. Due to strict timing requirements of the interface, + * the serial data stream is read and processed by a FIQ handler. + * The resulting words are fetched by this driver from a circular buffer. + * + * Standard AT keyboard driver (atkbd) is used for handling the keyboard data. + * However, when used with the E3 mailboard that producecs non-standard + * scancodes, a custom key table must be prepared and loaded from userspace. + */ +#include <linux/gpio.h> +#include <linux/irq.h> +#include <linux/serio.h> +#include <linux/slab.h> + +#include <asm/mach-types.h> +#include <plat/board-ams-delta.h> + +#include <mach/ams-delta-fiq.h> + +MODULE_AUTHOR("Matt Callow"); +MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); +MODULE_LICENSE("GPL"); + +static struct serio *ams_delta_serio; + +static int check_data(int data) +{ + int i, parity = 0; + + /* check valid stop bit */ + if (!(data & 0x400)) { + dev_warn(&ams_delta_serio->dev, + "invalid stop bit, data=0x%X\n", + data); + return SERIO_FRAME; + } + /* calculate the parity */ + for (i = 1; i < 10; i++) { + if (data & (1 << i)) + parity++; + } + /* it should be odd */ + if (!(parity & 0x01)) { + dev_warn(&ams_delta_serio->dev, + "paritiy check failed, data=0x%X parity=0x%X\n", + data, parity); + return SERIO_PARITY; + } + return 0; +} + +static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) +{ + int *circ_buff = &fiq_buffer[FIQ_CIRC_BUFF]; + int data, dfl; + u8 scancode; + + fiq_buffer[FIQ_IRQ_PEND] = 0; + + /* + * Read data from the circular buffer, check it + * and then pass it on the serio + */ + while (fiq_buffer[FIQ_KEYS_CNT] > 0) { + + data = circ_buff[fiq_buffer[FIQ_HEAD_OFFSET]++]; + fiq_buffer[FIQ_KEYS_CNT]--; + if (fiq_buffer[FIQ_HEAD_OFFSET] == fiq_buffer[FIQ_BUF_LEN]) + fiq_buffer[FIQ_HEAD_OFFSET] = 0; + + dfl = check_data(data); + scancode = (u8) (data >> 1) & 0xFF; + serio_interrupt(ams_delta_serio, scancode, dfl); + } + return IRQ_HANDLED; +} + +static int ams_delta_serio_open(struct serio *serio) +{ + /* enable keyboard */ + ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, + AMD_DELTA_LATCH2_KEYBRD_PWR); + + return 0; +} + +static void ams_delta_serio_close(struct serio *serio) +{ + /* disable keyboard */ + ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0); +} + +static int __init ams_delta_serio_init(void) +{ + int err; + + if (!machine_is_ams_delta()) + return -ENODEV; + + ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + if (!ams_delta_serio) + return -ENOMEM; + + ams_delta_serio->id.type = SERIO_8042; + ams_delta_serio->open = ams_delta_serio_open; + ams_delta_serio->close = ams_delta_serio_close; + strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter", + sizeof(ams_delta_serio->name)); + strlcpy(ams_delta_serio->phys, "GPIO/serio0", + sizeof(ams_delta_serio->phys)); + + err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data"); + if (err) { + pr_err("ams_delta_serio: Couldn't request gpio pin for data\n"); + goto serio; + } + gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA); + + err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock"); + if (err) { + pr_err("ams_delta_serio: couldn't request gpio pin for clock\n"); + goto gpio_data; + } + gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); + + err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), + ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, + "ams-delta-serio", 0); + if (err < 0) { + pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", + gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); + goto gpio_clk; + } + /* + * Since GPIO register handling for keyboard clock pin is performed + * at FIQ level, switch back from edge to simple interrupt handler + * to avoid bad interaction. + */ + set_irq_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), + handle_simple_irq); + + serio_register_port(ams_delta_serio); + dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name); + + return 0; +gpio_clk: + gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); +gpio_data: + gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA); +serio: + kfree(ams_delta_serio); + return err; +} +module_init(ams_delta_serio_init); + +static void __exit ams_delta_serio_exit(void) +{ + serio_unregister_port(ams_delta_serio); + free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); + gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); + gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA); + kfree(ams_delta_serio); +} +module_exit(ams_delta_serio_exit);
* Janusz Krzysztofik jkrzyszt@tis.icnet.pl [100427 18:09]:
The patch introduces a serio driver that supports a keyboard serial port found on the Amstrad Delta videophone board.
After initializing the hardware, the driver reads its input data from a buffer filled in by the board FIQ (Fast Interrupt Request) handler.
Standard AT keyboard driver (atkbd) will be used on top of the serio layer for handling the E3 keyboard (called mailboard) connected to the port. Since the device generated scancodes differ from what the atkbd expects, a custom key code to scan code table must be loaded from userspace for the keyboard to be useable.
Compiles and works on top of PATCH v4 3/5(7), "OMAP1: Amstrad Delta: use FIQ for processing GPIO interrupts".
I'll add this series into omap for-next. Will also add Dmitry's ack from the earlier series to this patch.
Regards,
Tony
On Tue, May 04, 2010 at 01:40:41PM -0700, Tony Lindgren wrote:
- Janusz Krzysztofik jkrzyszt@tis.icnet.pl [100427 18:09]:
The patch introduces a serio driver that supports a keyboard serial port found on the Amstrad Delta videophone board.
After initializing the hardware, the driver reads its input data from a buffer filled in by the board FIQ (Fast Interrupt Request) handler.
Standard AT keyboard driver (atkbd) will be used on top of the serio layer for handling the E3 keyboard (called mailboard) connected to the port. Since the device generated scancodes differ from what the atkbd expects, a custom key code to scan code table must be loaded from userspace for the keyboard to be useable.
What's the rationale for this approach? There's no requirement for the atkbd driver to be used for all keyboards. It seems very obscure (and backward) way to do things.
Why not implement the serio driver for the IO level, and a separate keyboard driver which can handle the protocol and interpret the scancodes?
On Tue, May 04, 2010 at 09:48:36PM +0100, Russell King - ARM Linux wrote:
On Tue, May 04, 2010 at 01:40:41PM -0700, Tony Lindgren wrote:
- Janusz Krzysztofik jkrzyszt@tis.icnet.pl [100427 18:09]:
The patch introduces a serio driver that supports a keyboard serial port found on the Amstrad Delta videophone board.
After initializing the hardware, the driver reads its input data from a buffer filled in by the board FIQ (Fast Interrupt Request) handler.
Standard AT keyboard driver (atkbd) will be used on top of the serio layer for handling the E3 keyboard (called mailboard) connected to the port. Since the device generated scancodes differ from what the atkbd expects, a custom key code to scan code table must be loaded from userspace for the keyboard to be useable.
What's the rationale for this approach? There's no requirement for the atkbd driver to be used for all keyboards. It seems very obscure (and backward) way to do things.
Why not implement the serio driver for the IO level, and a separate keyboard driver which can handle the protocol and interpret the scancodes?
Because it is AT-like keyboard with messed up scancodes, it responds to our probes as a regular keyboard so we can't auto-select proper keymap. If you were to connect a standard PS/2 keyboard to E3 port it would work without any special keymap.
The patch adds a CONFIG directive required for supporting the Amstrad Delta connected external keyboard by default.
Created and tested against linux-omap master, commit 104a77440f05430f29f9d3f4ecb88c1536819585 dated 2010-04-27.
Works on top of PATCH v4 4/5(7), "input: serio: add support for Amstrad Delta serial keyboard port".
Signed-off-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl --- v2 changes: - no functional changes, - refreshed against linux-2.6.34-rc2. v3 changes: - since CONFIG_KEYBOARD_ATKBD and CONFIG_AMS_DELTA_FIQ are now selected automatically, limit defconfig changes to CONFIG_SERIO_AMS_DELTA selection. v4 changes: none (CONFIG_KEYBOARD_ATKBD=y already present in defconfig).
arch/arm/configs/ams_delta_defconfig | 1 + 1 file changed, 1 insertion(+)
--- git.orig/arch/arm/configs/ams_delta_defconfig 2010-04-27 21:40:18.000000000 +0200 +++ git/arch/arm/configs/ams_delta_defconfig 2010-04-27 22:50:58.000000000 +0200 @@ -699,6 +699,7 @@ CONFIG_SERIO=y CONFIG_SERIO_SERPORT=y CONFIG_SERIO_LIBPS2=y # CONFIG_SERIO_RAW is not set +CONFIG_SERIO_AMS_DELTA=y # CONFIG_GAMEPORT is not set
#