mfd/stmpe: Add SPI interface support
Subsystems (2)
cover mfd/stmpe: Add SPI interface support
Few STMPE controller can have register interface over SPI or I2C. Current implementation only supports I2C and all code is present in a single file stmpe.c.
This patchset separates out code into three files
- stmpe: specific to controller only
- stmpe-i2c: specific to i2c interface
- stmpe-spi: specific to spi interface
In order to rebase it cleanly, please apply earlier floated patch
"mfd/stmpe: Add support for irq over gpio pin"
Viresh Kumar (2):
mfd/stmpe: separate out controller and interface specific code mfd/stmpe: Add support for SPI interface
drivers/mfd/Kconfig | 19 ++++++- drivers/mfd/Makefile | 2 + drivers/mfd/stmpe-i2c.c | 116 +++++++++++++++++++++++++++++++++++ drivers/mfd/stmpe-spi.c | 147 +++++++++++++++++++++++++++++++++++++++++++++ drivers/mfd/stmpe.c | 128 ++++++++++++--------------------------- drivers/mfd/stmpe.h | 34 ++++++++++ include/linux/mfd/stmpe.h | 7 ++- 7 files changed, 361 insertions(+), 92 deletions(-) create mode 100644 drivers/mfd/stmpe-i2c.c create mode 100644 drivers/mfd/stmpe-spi.c
Signature · 1 line
1.7.2.2
PATCH 1/2 mfd/stmpe: separate out controller and interface specific code
Few STMPE controller can have register interface over SPI or I2C. Current implementation only supports I2C and all code is present in a single file stmpe.c. It would be better to separate out I2C interface specific code from controller specific code. Later SPI specific code can be added in a separate file.
This patch separates out I2C and controller specific code into separate files, making stmpe.c independent of I2C.
--- drivers/mfd/Kconfig | 11 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/stmpe-i2c.c | 116 ++++++++++++++++++++++++++++++++++++++++ drivers/mfd/stmpe.c | 128 ++++++++++++++------------------------------- drivers/mfd/stmpe.h | 33 ++++++++++++ include/linux/mfd/stmpe.h | 7 ++- 6 files changed, 205 insertions(+), 91 deletions(-) create mode 100644 drivers/mfd/stmpe-i2c.c
drivers/mfd/Kconfig +11 -0
@@ -293,6 +293,17 @@ config MFD_STMPE Keypad: stmpe-keypad Touchscreen: stmpe-ts +menu "STMPE Interface Drivers" +depends on MFD_STMPE + +config STMPE_I2C + bool "STMPE I2C Inteface" + depends on I2C + default y + help + This is used to enable I2C interface of STMPE +endmenu + config MFD_TC3589X bool "Support Toshiba TC35892 and variants" depends on I2C=y && GENERIC_HARDIRQS
drivers/mfd/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o obj-$(CONFIG_MFD_STMPE) += stmpe.o +obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o obj-$(CONFIG_MFD_TC3589X) += tc3589x.o obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o
drivers/mfd/stmpe-i2c.c new file +116 -0
116 lines not on this page · raw message
drivers/mfd/stmpe.c +39 -89
219 lines not on this page · raw message
drivers/mfd/stmpe.h +33 -0
@@ -8,6 +8,14 @@#ifndef __STMPE_H#define __STMPE_H +#include <linux/device.h> +#include <linux/mfd/core.h> +#include <linux/mfd/stmpe.h> +#include <linux/printk.h> +#include <linux/types.h> + +extern const struct dev_pm_ops stmpe_dev_pm_ops; +#ifdef STMPE_DUMP_BYTES static inline void stmpe_dump_bytes (const char *str,const void *buf,size_t len)
@@ -67,6 +75,31 @@ struct stmpe_variant_info {int (*enable_autosleep)(struct stmpe *stmpe,int autosleep_timeout); }; +/** +* struct stmpe_client_info - i2c or spi specific routines/info +* @data: client specific data +* @read_byte: read single byte +* @write_byte: write single byte +* @read_block: read block or multiple bytes +* @write_block: write block or multiple bytes +* @init: client init routine, called during probe +*/ +struct stmpe_client_info { +void *data; +int irq; +void *client; +struct device *dev; +int (*read_byte)(struct stmpe *stmpe,u8 reg); +int (*write_byte)(struct stmpe *stmpe,u8 reg,u8 val); +int (*read_block)(struct stmpe *stmpe,u8 reg,u8 len,u8 *values); +int (*write_block)(struct stmpe *stmpe,u8 reg,u8 len, +const u8 *values); +void (*init)(struct stmpe *stmpe); +}; + +int stmpe_probe (struct stmpe_client_info *ci); +int stmpe_remove (struct stmpe *stmpe); +#define STMPE_ICR_LSB_HIGH (1 << 2)#define STMPE_ICR_LSB_EDGE (1 << 1)#define STMPE_ICR_LSB_GIM (1 << 0)
include/linux/mfd/stmpe.h +5 -2
@@ -50,13 +50,15 @@ enum {struct stmpe_variant_info ; +struct stmpe_client_info ;/** * struct stmpe - STMPE MFD structure * @lock: lock protecting I/O operations * @irq_lock: IRQ bus lock * @dev: device, mostly for dev_dbg() -* @i2c: i2c client +* @client: client - i2c or spi +* @ci: client specific information * @partnum: part number * @variant: the detected STMPE model number * @regs: list of addresses of registers which are at different addresses on
@@ -72,7 +74,8 @@ struct stmpe {struct mutex lock;struct mutex irq_lock;struct device *dev; -struct i2c_client *i2c; +void *client; +struct stmpe_client_info *ci;enum stmpe_partnum partnum;struct stmpe_variant_info *variant;const u8 *regs;
Signature · 1 line
1.7.2.2
PATCH 2/2 mfd/stmpe: Add support for SPI interface
In reply to Viresh KumarFew STMPE controller can have register interface over SPI or I2C. Current implementation only supports I2C.
This patch adds support for SPI interface for accessing STMPE's address space.
--- drivers/mfd/Kconfig | 8 ++- drivers/mfd/Makefile | 1 + drivers/mfd/stmpe-spi.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/mfd/stmpe.h | 1 + 4 files changed, 156 insertions(+), 1 deletions(-) create mode 100644 drivers/mfd/stmpe-spi.c
drivers/mfd/Kconfig +7 -1
@@ -272,7 +272,7 @@ config TWL6040_CORE config MFD_STMPE bool "Support STMicroelectronics STMPE" - depends on I2C=y && GENERIC_HARDIRQS + depends on (I2C=y || SPI_MASTER=y) && GENERIC_HARDIRQS select MFD_CORE help Support for the STMPE family of I/O Expanders from
@@ -302,6 +302,12 @@ config STMPE_I2C default y help This is used to enable I2C interface of STMPE + +config STMPE_SPI + bool "STMPE SPI Inteface" + depends on SPI_MASTER + help + This is used to enable SPI interface of STMPE endmenu config MFD_TC3589X
drivers/mfd/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o obj-$(CONFIG_MFD_STMPE) += stmpe.o obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o +obj-$(CONFIG_STMPE_SPI) += stmpe-spi.o obj-$(CONFIG_MFD_TC3589X) += tc3589x.o obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o
drivers/mfd/stmpe-spi.c new file +147 -0
147 lines not on this page · raw message
drivers/mfd/stmpe.h +1 -0
@@ -120,6 +120,7 @@ int stmpe_remove(struct stmpe *stmpe);#define STMPE811_REG_CHIP_ID 0x00#define STMPE811_REG_SYS_CTRL2 0x04 +#define STMPE811_REG_SPI_CFG 0x08#define STMPE811_REG_INT_CTRL 0x09#define STMPE811_REG_INT_EN 0x0A#define STMPE811_REG_INT_STA 0x0B
Signature · 1 line
1.7.2.2
Quoted 11 lines · Viresh Kumar
Few STMPE controller can have register interface over SPI or I2C. Current implementation only supports I2C and all code is present in a single file
stmpe.c.This patchset separates out code into three files
- stmpe: specific to controller only
- stmpe-i2c: specific to i2c interface
- stmpe-spi: specific to spi interfaceIn order to rebase it cleanly, please apply earlier floated patch "mfd/stmpe: Add support for irq over gpio pin"
Patches look clean and nice to me.
Yours,
Linus Walleij
Quoted 9 lines · Viresh Kumar
Few STMPE controller can have register interface over SPI or I2C. Current implementation only supports I2C and all code is present in a single file
stmpe.c.This patchset separates out code into three files
- stmpe: specific to controller only
- stmpe-i2c: specific to i2c interface
- stmpe-spi: specific to spi interface
Quoted 6 lines
In order to rebase it cleanly, please apply earlier floated patch "mfd/stmpe: Add support for irq over gpio pin"
Viresh Kumar (2):
mfd/stmpe: separate out controller and interface specific code mfd/stmpe: Add support for SPI interface
Could you instead convert stmpe to use the register map API, and then add the SPI interface? Converting to regmap should both simplify the existing code as well as make it possible to add the second interface with fewer lines of code.
Quoted 4 lines · Rabin Vincent
Could you instead convert stmpe to use the register map API, and then add the SPI interface? Converting to regmap should both simplify the existing code as well as make it possible to add the second interface with fewer lines of code.
Sorry Rabin, but i couldn't get your comment completely. :( Can you please spend few lines on "what do you mean by register map API"?
Signature · 1 line
viresh
Quoted 8 lines · Viresh Kumar
Quoted 4 lines · Rabin Vincent
Could you instead convert stmpe to use the register map API, and then add the SPI interface? Converting to regmap should both simplify the existing code as well as make it possible to add the second interface with fewer lines of code.
Sorry Rabin, but i couldn't get your comment completely. :( Can you please spend few lines on "what do you mean by register map API"?
drivers/base/regmap, added in b83a313bf25 ("regmap: Add generic non-memory mapped register access API").
Several MFDs are already using it (git grep regmap drivers/mfd/), and patches to convert more are making the rounds on the lists.
Quoted 7 lines · Rabin Vincent
Quoted 6 lines · Viresh Kumar
Quoted 4 lines · Rabin Vincent
Could you instead convert stmpe to use the register map API, and then add the SPI interface? Converting to regmap should both simplify the existing code as well as make it possible to add the second interface with fewer lines of code.
Quoted 8 lines
Quoted 2 lines
Sorry Rabin, but i couldn't get your comment completely. :( Can you please spend few lines on "what do you mean by register map API"?
drivers/base/regmap, added inb83a313bf25("regmap: Add generic non-memory mapped register access API").Several MFDs are already using it (git grep regmap
drivers/mfd/), and patches to convert more are making the rounds on the lists.
Ok. Got it now. :)
Can we get this patchset pushed as it is and i will do this regmap stuff later in a separate patchset? Actually i am a bit busy currently with some other activities and can come back to it after some time.
Signature · 1 line
viresh
Hi Viresh,
Quoted 14 lines · Viresh Kumar
Quoted 13 lines · Rabin Vincent
Quoted 8 lines · Viresh Kumar
Quoted 4 lines · Rabin Vincent
Could you instead convert stmpe to use the register map API, and then add the SPI interface? Converting to regmap should both simplify the existing code as well as make it possible to add the second interface with fewer lines of code.
Sorry Rabin, but i couldn't get your comment completely. :( Can you please spend few lines on "what do you mean by register map API"?
drivers/base/regmap, added inb83a313bf25("regmap: Add generic non-memory mapped register access API").
Quoted 8 lines
Quoted 2 lines
Several MFDs are already using it (git grep regmap
drivers/mfd/), and patches to convert more are making the rounds on the lists.Ok. Got it now. :)
Can we get this patchset pushed as it is and i will do this regmap stuff later in a separate patchset? Actually i am a bit busy currently with some other activities and can come back to it after some time.
Ok, but I really hope you will be able to get back at it. I applied your patchset to my for-next branch for now.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Quoted 2 lines · Samuel Ortiz
Ok, but I really hope you will be able to get back at it. I applied your patchset to my for-next branch for now.
I will surely like to do it as soon as i get some time.
Signature · 1 line
viresh