intel_mid: Keypad Driver (Current snapshot for reference)
Subsystems (4)
PATCH 1/1 intel_mid: Keypad Driver (Current snapshot for reference)
From: Zheng Ba <[email protected]>
This is a single patch of the Intel Moorestown keypad driver made up from the following
Zheng Ba <[email protected]>
This patch adds the keypad support for the MID platform keypad interfaces.
Changes from Alpha2: solved "CRITICAL" issues marked by Klocwork
HSD sighting 3469242
(some tidying Alan Cox)
Jekyll Lai <[email protected]>
Rewrite keypad driver to keep only one default matrix keymap. Also add an interface to pass the platform data via "mrst_keypad_set_pdata." Howerver, this keypad controller also provides direct key function. That one matrix keymap is not enough in this driver. It's necessary that adding another default keymap for direct key. So, there would be two default keymaps. One for the keypad matrix; one for direct keys.
Alan Cox <[email protected]>
Fix abuse of disable_irq/enable_irq on a shared IRQ line. Clean up some problems noted by Dmitry - add a gpio clearing helper etc
Kristen Carlson Accardi <[email protected]>
We already free the gpios in close(), we don't need to free them
again in remove().
IRQ will never be negative.
Switch to using pci_ioremap.
Add basic power management so we can wake off the keypad interrupt. Remove rotary support as no hardware actually needs it. Remove direct key handling as this is now handled (better) by gpio-keys.
Send out the scancode value in addition to the keycode so that userspace may use the scancode to remap keys if they want.
Add PCI passed configuration information:
Right now the driver programs the number of matrix rows, cols, debounce interval, direct key nums and rotary info. This information is passed into the driver from pdata, a new platform data structure. This information should really be programmed into the KPC register by firmware, and then read by the driver via the pci shim layer. This patch removes this info from the pdata structure and implements the code to read this info from the KPC register. Because firmware doesn't actually behave the way it should right now, this patch creates a pci quirk for the langwell keypad which programs the KPC register. Document the KPC register setting
Allow input and output GPIO ranges to be separate
---
arch/x86/pci/mrst.c | 63 ++++ arch/x86/platform/mrst/mrst.c | 19 + drivers/input/keyboard/Kconfig | 10 + drivers/input/keyboard/Makefile | 1 drivers/input/keyboard/intel_mid_keypad.c | 457 +++++++++++++++++++++++++++++ include/linux/input/intel_mid_keypad.h | 29 ++ 6 files changed, 579 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/intel_mid_keypad.c create mode 100644 include/linux/input/intel_mid_keypad.h
arch/x86/pci/mrst.c +63 -0
@@ -265,3 +265,66 @@ static void __devinit pci_fixed_bar_fixup(struct pci_dev *dev) } }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,PCI_ANY_ID , pci_fixed_bar_fixup); + +/* +* The Firmware should program the Langwell keypad registers to indicate +* system specific configuration. This quirk can be removed when firmware +* actually does this properly. +*/ +static void __devinit langwell_keypad_fixup (struct pci_dev *dev) +{ +void __iomem *base; +u32 val; + + base =pci_ioremap_bar (dev,0 ); + +if (base ==NULL ) +return ; + + val =readl (base); + +/* +* set the KPC register. Please see the Langwell Docs +* for more detail. +* +* Bit 31: Reserved +* Bit 30: Automatic Scan Bit +* Bit 29: Automatic Scan on Activity bit +* Bit 28:26 : Matrix keypad row number +* 000 == 1, 001 == 2, ... 111 == 8 +* Bit 25:23 : Matrix keypad column number +* 000 ==1, 001 == 2, ... 111 == 8 +* Bit 22: Matrix Interrupt Bit +* Bit 21: Ignore Multiple Key Press +* Bit 20: Manual Matrix Scan line 7 +* Bit 19: Manual Matrix Scan line 6 +* Bit 18: Manual Matrix Scan line 5 +* Bit 17: Manual Matrix Scan line 4 +* Bit 16: Manual Matrix Scan line 3 +* Bit 15: Manual Matrix Scan line 2 +* Bit 14: Manual Matrix Scan line 1 +* Bit 13: Manual Matrix Scan line 0 +* Bit 12: Matrix Keypad Enable +* Bit 11: Matrix Interrupt Enable +* Bit 10:9 : Reserved +* Bit 8:6 : Direct Key Number + Roatry encoder sensor input +* 000 == 1, 001 == 2, ... 111 == 8 +* Bit 5: Direct Interrupt bit +* Bit 4: Reserved +* Bit 3: Rotary Encoder 1 enable +* Bit 2: Rotary Encoder 0 enable +* Bit 1: Direct Keypad enable +* Bit 0: Direct Keypad Interrupt enable +*/ +if (val ==0 ) +writel (0x3f9ff800 , base); + + val =readl (base +0x24 ); + +/* set the debounce interval (KPKDI) to 100ms */ +if (val ==0 ) +writel (100 , base +0x24 ); + +iounmap (base); +} +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0805 , langwell_keypad_fixup);
arch/x86/platform/mrst/mrst.c +19 -0
@@ -21,6 +21,7 @@#include <linux/i2c/pca953x.h> #include <linux/gpio_keys.h> #include <linux/input.h> +#include <linux/input/intel_mid_keypad.h> #include <linux/platform_device.h> #include <linux/irq.h> #include <linux/module.h>
@@ -809,3 +810,21 @@ static int __init pb_keys_init(void)return 0 ; }late_initcall (pb_keys_init); + +/* +* Mininal initial implementation of the mrst keypad hooks. We need this +* to merge the keypad drivers and can then tweak this for the platforms +* that are different +*/ + +int mrst_keypad_enabled (void ) +{ +return 1 ; +} +EXPORT_SYMBOL_GPL (mrst_keypad_enabled); + +struct mrst_keypad_platform_data *mrst_keypad_platform_data (void ) +{ +return NULL ; +} +EXPORT_SYMBOL_GPL (mrst_keypad_platform_data);
drivers/input/keyboard/Kconfig +10 -0
@@ -324,6 +324,16 @@ config KEYBOARD_IMX To compile this driver as a module, choose M here: the module will be called imx_keypad. +config KEYBOARD_INTEL_MID + tristate "Intel MID keypad support" + depends on GPIO_LANGWELL + help + Say Y if you want support for Intel MID keypad devices + depends on GPIO_LANGWELL + + To compile this driver as a module, choose M here: the + module will be called intel_mid_keypad. + config KEYBOARD_NEWTON tristate "Newton keyboard" select SERIO
drivers/input/keyboard/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o +obj-$(CONFIG_KEYBOARD_INTEL_MID) += intel_mid_keypad.o obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o obj-$(CONFIG_KEYBOARD_GPIO_POLLED) += gpio_keys_polled.o obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o
drivers/input/keyboard/intel_mid_keypad.c new file +457 -0
457 lines not on this page · raw message
include/linux/input/intel_mid_keypad.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2010 Jekyll Lai, Wistron <[email protected]> +* +* 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. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#include <linux/platform_device.h> +#include <linux/input/matrix_keypad.h> + +struct mrst_keypad_platform_data { +const struct matrix_keymap_data *keymap_data; +}; + +extern int mrst_keypad_enabled (void ); +extern struct mrst_keypad_platform_data *mrst_keypad_platform_data (void ); +
Dmitry Torokhov
maintainerdrivers/input/keyboard/intel_mid_keypad.c line 304
Quoted 5 lines · Alan Cox
drivers/input/keyboard/intel_mid_keypad.c new file +5
-0+ +/* Check with the firmware if the keypad is enabled */ +if (!mrst_keypad_enabled ()) +return 0 ; +
-ENXIO;
Signature · 1 line
Dmitry