OMAP1: Amstrad Delta: add FIQ based support for external keyboard
Subsystems (4)
PATCH v4 1/1 OMAP1: Amstrad Delta: add FIQ based support for external keyboard
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
PATCH v4 1/1 OMAP: add missing FIQ_START definition required for arch/arm/kernel/fiq.c compilation
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.
---
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(+)
arch/arm/plat-omap/include/plat/irqs.h +4 -0
@@ -428,4 +428,8 @@ void omap3_intc_resume_idle(void);#include <mach/hardware.h> +#ifdef CONFIG_FIQ +#define FIQ_START 1024 +#endif +#endif
PATCH v4 1/1 OMAP: add missing FIQ_START definition required for arch/arm/kernel/fiq.c compilation
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.
---
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(+)
arch/arm/plat-omap/include/plat/irqs.h +4 -0
@@ -428,4 +428,8 @@ void omap3_intc_resume_idle(void);#include <mach/hardware.h> +#ifdef CONFIG_FIQ +#define FIQ_START 1024 +#endif +#endif
PATCH v4 1/1 OMAP1: Amstrad Delta: add FIQ handler for serial keyboard port interrupt processing
In reply to Janusz KrzysztofikThis 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.
---
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(+)
arch/arm/mach-omap1/Kconfig +10 -0
@@ -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)
arch/arm/mach-omap1/Makefile +1 -0
@@ -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
arch/arm/mach-omap1/ams-delta-fiq-handler.S +278 -0
278 lines not on this page · raw message
arch/arm/mach-omap1/include/mach/ams-delta-fiq.h +72 -0
72 lines not on this page · raw message
PATCH v4 1/1 OMAP1: Amstrad Delta: add a handler for processing interrupts generated by the FIQ routine
In reply to Janusz KrzysztofikThis 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.
---
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(-)
arch/arm/mach-omap1/Makefile +1 -1
@@ -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
arch/arm/mach-omap1/ams-delta-fiq.c +155 -0
155 lines not on this page · raw message
arch/arm/mach-omap1/include/mach/ams-delta-fiq.h +7 -0
@@ -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
PATCH v4 1/1 OMAP1: Amstrad Delta: update board initialization code for complete modem IRQ GPIO line setup
In reply to Janusz KrzysztofikIn 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.
---
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(-)
arch/arm/mach-omap1/board-ams-delta.c +11 -1
@@ -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,
PATCH v4 1/1 OMAP1: Amstrad Delta: use FIQ for processing GPIO interrupts
In reply to Janusz KrzysztofikThe 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.
---
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(+)
arch/arm/mach-omap1/board-ams-delta.c +6 -0
@@ -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 ); }
PATCH v4 1/1 input: serio: add support for Amstrad Delta serial keyboard port
In reply to Janusz KrzysztofikThe 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.
---
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(+)
drivers/input/serio/Kconfig +16 -0
@@ -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
drivers/input/serio/Makefile +1 -0
@@ -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
drivers/input/serio/ams_delta_serio.c +177 -0
177 lines not on this page · raw message
Tony Lindgren
reviewerPATCH v4 1/1 input: serio: add support for Amstrad Delta serial keyboard port
Quoted 6 lines · Janusz Krzysztofik
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.
Quoted 8 lines
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
PATCH v4 1/1 input: serio: add support for Amstrad Delta serial keyboard port
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Janusz Krzysztofik
The patch introduces a serio driver that supports a keyboard serial port found on the Amstrad Delta videophone board.
Quoted 8 lines
Quoted 8 lines
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?
Dmitry Torokhov
maintainerPATCH v4 1/1 input: serio: add support for Amstrad Delta serial keyboard port
Quoted 14 lines · Russell King - ARM Linux
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Janusz Krzysztofik
The patch introduces a serio driver that supports a keyboard serial port found on the Amstrad Delta videophone board.
Quoted 8 lines
Quoted 8 lines
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.
Quoted 7 lines
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.
Signature · 1 line
Dmitry
PATCH v4 1/1 OMAP1: Amstrad Delta: modify defconfig for external keyboard support
In reply to Janusz KrzysztofikThe 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".
---
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(+)
arch/arm/configs/ams_delta_defconfig +1 -0
@@ -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 #