i2c port expanders support for nomadik nhk8815
Subsystems (5)
cover i2c port expanders support for nomadik nhk8815
From: Alessandro Rubini <[email protected]>
The first patch adds a driver for STMPE2401, an i2c port expander with keypad and pwm support, as well as irq capabilities. The driver currently only supports gpio, I'll add keypad later. The device is used in the nomadik evaluation kit (already upstream) and in the U8500 evaluation kit, which is goint to be upstreamed soon. There are no dependencies on PLAT_NOMADIK as the driver is generic and other boards may mount the chip.
The second patch fixes NR_IRQS for the nhk8815 board, as some devices use STMPE2401-driven GPIO pins.
The third patch adds platform data for nhk8815 so the expanders actually work on the board.
Alessandro Rubini (3):
i2c: added stmpe2401 port extender with irq support
nhk8815: add port expander to NR_IRQS
nhk8815: add platform data for port expanders
arch/arm/mach-nomadik/i2c-8815nhk.c | 33 ++ arch/arm/mach-nomadik/include/mach/irqs.h | 27 ++- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/stmpe2401.c | 571 +++++++++++++++++++++++++++++ include/linux/i2c/stmpe2401.h | 145 ++++++++ 6 files changed, 783 insertions(+), 1 deletions(-) create mode 100644 drivers/gpio/stmpe2401.c create mode 100644 include/linux/i2c/stmpe2401.h
PATCH 1/3 i2c: added stmpe2401 port extender with irq support
From: Alessandro Rubini <[email protected]>
The "STM Port Expander" is a device with 24 gpio lines and a few alternate functions associated to each of them. It includes 32 interrupt sources, which are handled through in irq_chip structure. This patch only registers the GPIO lines, but non-gpio interrupts are working as well. A keypad driver based on this chip will follow.
--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/stmpe2401.c | 571 +++++++++++++++++++++++++++++++++++++++++ include/linux/i2c/stmpe2401.h | 145 +++++++++++ 4 files changed, 724 insertions(+), 0 deletions(-) create mode 100644 drivers/gpio/stmpe2401.c create mode 100644 include/linux/i2c/stmpe2401.h
drivers/gpio/Kconfig +7 -0
@@ -148,6 +148,13 @@ config GPIO_PCF857X This driver provides an in-kernel interface to those GPIOs using platform-neutral GPIO calls. +config GPIO_STMPE2401 + depends on I2C + tristate "STM Port Expander with Keypad and PWM" + help + Say y if you want support for the STMPE2401, found for example + in the nhk8815 board. + config GPIO_TWL4030 tristate "TWL4030, TWL5030, and TPS659x0 GPIOs" depends on TWL4030_CORE
drivers/gpio/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o obj-$(CONFIG_GPIO_PCA953X) += pca953x.o obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o obj-$(CONFIG_GPIO_PL061) += pl061.o +obj-$(CONFIG_GPIO_STMPE2401) += stmpe2401.o obj-$(CONFIG_GPIO_TIMBERDALE) += timbgpio.o obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o obj-$(CONFIG_GPIO_UCB1400) += ucb1400_gpio.o
drivers/gpio/stmpe2401.c new file +571 -0
571 lines not on this page · raw message
include/linux/i2c/stmpe2401.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH 2/3 nhk8815: add port expander to NR_IRQS
In reply to Alessandro RubiniFrom: Alessandro Rubini <[email protected]>
The board has several devices connected to the stmpe2401 expanders, so this patch adds their interrupts to machine ones. In this was normal driver (like touchscreen controller) can work on the nhk without special casing the connection to i2c-driven gpio bits.
--- arch/arm/mach-nomadik/include/mach/irqs.h | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-)
arch/arm/mach-nomadik/include/mach/irqs.h +26 -1
@@ -21,6 +21,7 @@#define __ASM_ARCH_IRQS_H#include <mach/hardware.h> +#include <linux/i2c/stmpe2401.h> #define IRQ_VIC_START 0/* first VIC interrupt is 0 */
@@ -72,11 +73,35 @@#define NOMADIK_NR_GPIO 128/* last 4 not wired to pins */ #define NOMADIK_GPIO_TO_IRQ (gpio) ((gpio) + NOMADIK_SOC_NR_IRQS)#define NOMADIK_IRQ_TO_GPIO (irq) ((irq) - NOMADIK_SOC_NR_IRQS) -#define NR_IRQS NOMADIK_GPIO_TO_IRQ(NOMADIK_NR_GPIO) +#define IRQ_BOARD_START NOMADIK_GPIO_TO_IRQ(NOMADIK_NR_GPIO) +#define NR_IRQS IRQ_BOARD_START/* Following two are used by entry_macro.S, to access our dual-vic */ #define VIC_REG_IRQSR0 0#define VIC_REG_IRQSR1 0x20 +/*************************************************************************** +* Board specific IRQs. Define them here. Do not surround them with ifdefs. +* NR_IRQS is undefined and redefined to be the max possibile value. +* (This approach is taken from mach-pxa). +*/ + +/* +* nhk8815: we have 2 STMPE2401, called EGPIO throughout board docs. +* Please note that the 32 interrupts are 8 functions + 24 gpio bits: +* pdata should use irq NHK8815_EGPIO0_IRQ(STMPE2401_IRQ_GPIO(chip_gpionr)) +*/ +#define NHK8815_EGPIO0_IRQ (x) (IRQ_BOARD_START + (x)) +#define NHK8815_EGPIO1_IRQ (x) (IRQ_BOARD_START + STMPE2401_NIRQ + (x)) +#define NHK8815_NR_IRQS (IRQ_BOARD_START + 2 * STMPE2401_NIRQ) +#if NHK8815_NR_IRQS >NR_IRQS +# undef NR_IRQS +# define NR_IRQS NHK8815_NR_IRQS +#endif + +/* +* Other boards definining interrupts should define theme here below +*/ +#endif /* __ASM_ARCH_IRQS_H */
Signature · 1 line
1.6.0.2
PATCH 3/3 nhk8815: add platform data for port expanders
In reply to Alessandro RubiniFrom: Alessandro Rubini <[email protected]>
--- arch/arm/mach-nomadik/i2c-8815nhk.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)
arch/arm/mach-nomadik/i2c-8815nhk.c +33 -0
@@ -1,10 +1,12 @@#include <linux/module.h> #include <linux/init.h> #include <linux/i2c.h> +#include <linux/i2c/stmpe2401.h> #include <linux/i2c-algo-bit.h> #include <linux/i2c-gpio.h> #include <linux/gpio.h> #include <linux/platform_device.h> +#include <mach/irqs.h> /* * There are two busses in the 8815NHK.
@@ -41,6 +43,34 @@ static struct platform_device nhk8815_i2c_dev1 = { }, }; +/* +* Data for the GPIO expanders +*/ +static struct stmpe2401_platform_data nmk_egpio0_data = { + .gpio_base =NOMADIK_NR_GPIO , + .irq_base =NHK8815_EGPIO0_IRQ (0 ), + .parent_irq =NOMADIK_GPIO_TO_IRQ (76 ), +}; + +static struct stmpe2401_platform_data nmk_egpio1_data = { + .gpio_base =NOMADIK_NR_GPIO +STMPE2401_NGPIO , + .irq_base =NHK8815_EGPIO1_IRQ (0 ), + .parent_irq =NOMADIK_GPIO_TO_IRQ (78 ), +}; + +static struct i2c_board_info nhk8815_i2c_board_info[] = { + { + .type ="stmpe2401" , + .addr =0x43 , + .platform_data = &nmk_egpio0_data, + }, + { + .type ="stmpe2401" , + .addr =0x44 , + .platform_data = &nmk_egpio1_data, + }, +}; +static int __init nhk8815_i2c_init (void ) {/* i2c-gpio switches from out to in and back, so force out data to 0 */
@@ -56,6 +86,9 @@ static int __init nhk8815_i2c_init(void)gpio_set_value (nhk8815_i2c_data1.scl_pin,0 );platform_device_register (&nhk8815_i2c_dev1); +/* The stmpe2401 devices live on bus 0 */ +i2c_register_board_info (0 , nhk8815_i2c_board_info, +ARRAY_SIZE (nhk8815_i2c_board_info));return 0 ; }
Signature · 1 line
1.6.0.2