SPI: tsc2xxx core
Subsystems (5)
PATCH 1/4 SPI: tsc2xxx core
From: Ragner Magalhaes <[email protected]>
This is the start to build tsc2xxx core with all sharable routines between tsc2101, tsc2102, tsc2301 ... and more later tsc2100, tsc2111, etc.
---
drivers/spi/Kconfig | 4 + drivers/spi/Makefile | 1 drivers/spi/tsc2xxx.c | 227 +++++++++++++++++++++++++++++++++++++++++++ include/linux/spi/tsc2xxx.h | 40 ++++++++ 4 files changed, 272 insertions(+), 0 deletions(-)
drivers/spi/Kconfig +4 -0
@@ -212,6 +212,10 @@ config SPI_AT25 This driver can also be built as a module. If so, the module will be called at25. +config SPI_TSC2XXX + tristate + default n + config SPI_TSC2101 depends on SPI_MASTER tristate "TSC2101 chip support"
drivers/spi/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o obj-$(CONFIG_SPI_AT25) += at25.o obj-$(CONFIG_SPI_SPIDEV) += spidev.o obj-$(CONFIG_SPI_TLE62X0) += tle62x0.o +obj-$(CONFIG_SPI_TSC2XXX) += tsc2xxx.o obj-$(CONFIG_SPI_TSC2101) += tsc2101.o obj-$(CONFIG_SPI_TSC2102) += tsc2102.o obj-$(CONFIG_SPI_TSC210X) += tsc210x.o
drivers/spi/tsc2xxx.c new file +227 -0
227 lines not on this page · raw message
include/linux/spi/tsc2xxx.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* include/linux/spi/tsc2xxx.h +* +* Copyright (C) 2007, Ragner Magalhaes <[email protected]> +* +* TSC2xxx core. +* +* Sharable core routines (tsc2101, tsc2102 and tsc2301). +* +* Licensed under the GPLv2 only. +*/ + +#ifndef _LINUX_SPI_TSC2XXX_H +#define _LINUX_SPI_TSC2XXX_H + +struct tsc210x_spi_req { +struct spi_device *dev; +u16 command; +u16 data; +struct spi_message message; +}; + +#define TSC2XXX_REG (page, addr) (((page) << 11) | ((addr) << 5)) +#define TSC2XXX_REG_TO_PAGE (reg) (((reg) >> 11) & 0x03) +#define TSC2XXX_REG_TO_ADDR (reg) (((reg) >> 5) & 0x1f) + +extern u16 tsc2xxx_read_sync (struct spi_device *spi,u32 reg); +extern int tsc2xxx_write_sync (struct spi_device *spi,u32 reg,u16 val); + +extern u16 tsc2xxx_read_async (struct spi_device *spi,u32 reg, +void (*complete)(void *context)); +extern int tsc2xxx_write_async (struct spi_device *spi,u32 reg,u16 val, +void (*complete)(void *context)); + +extern int tsc2xxx_read_buf_sync (struct spi_device *spi,u32 reg,u16 *buf, +u32 len); +extern int tsc2xxx_read_buf_async (struct spi_device *spi,u32 reg,u16 *buf, +u32 len,void (*complete)(void *context)); + +#endif /* _LINUX_SPI_TSC2XXX_H */
PATCH 2/4 SPI: tsc2301 support for tsc2xxx core
From: Ragner Magalhaes <[email protected]>
Add support for tsc2xxx core api
---
drivers/spi/Kconfig | 1 drivers/spi/tsc2301-core.c | 94 ++++--------------------------------------- include/linux/spi/tsc2301.h | 50 +++++++++++------------ 3 files changed, 32 insertions(+), 113 deletions(-)
drivers/spi/Kconfig +1 -0
@@ -246,6 +246,7 @@ config SPI_TSC210X config SPI_TSC2301 tristate "TSC2301 driver" depends on SPI_MASTER + select SPI_TSC2XXX help Say Y here if you have a TSC2301 chip connected to an SPI bus on your board.
drivers/spi/tsc2301-core.c +8 -86
144 lines not on this page · raw message
include/linux/spi/tsc2301.h +23 -27
56 lines not on this page · raw message
PATCH 3/4 SPI: tsc2101 support for tsc2xxx core
In reply to Ragner MagalhaesFrom: Ragner Magalhaes <[email protected]>
Add support for tsc2xxx core api
---
arch/arm/mach-omap1/board-h2.c | 1 drivers/spi/Kconfig | 5 +- drivers/spi/tsc2101.c | 94 ++++------------------------------------ drivers/video/omap/lcd_h2.c | 10 +++- include/linux/spi/tsc2101.h | 10 ++-- 5 files changed, 26 insertions(+), 94 deletions(-)
arch/arm/mach-omap1/board-h2.c +1 -0
@@ -29,6 +29,7 @@#include <linux/input.h> #include <linux/workqueue.h> #include <linux/spi/spi.h> +#include <linux/spi/tsc2xxx.h> #include <linux/spi/tsc2101.h> #include <linux/clk.h>
drivers/spi/Kconfig +3 -2
@@ -217,8 +217,9 @@ config SPI_TSC2XXX default n config SPI_TSC2101 - depends on SPI_MASTER - tristate "TSC2101 chip support" + depends on SPI_MASTER + tristate "TSC2101 chip support" + select SPI_TSC2XXX ---help--- Say Y here if you want support for the TSC2101 chip. At the moment it provides basic register read / write interface
drivers/spi/tsc2101.c +9 -85
121 lines not on this page · raw message
drivers/video/omap/lcd_h2.c +8 -2
@@ -21,6 +21,8 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <linux/spi/spi.h> +#include <linux/spi/tsc2xxx.h> #include <linux/spi/tsc2101.h> #include <asm/arch/mux.h>
@@ -48,7 +50,8 @@ static int h2_panel_enable(struct lcd_panel *panel)* Assert LCD_EN, BKLIGHT_EN pins on LCD panel * page2, GPIO config reg, GPIO(0,1) to out and asserted */ - r =tsc2101_write_sync (h2_panel_dev.tsc2101_dev,2 ,0x23 ,0xcc00 ); + r =tsc2101_write_sync (h2_panel_dev.tsc2101_dev, +TSC2XXX_REG (2 ,0x23 ),0xcc00 );if (r <0 )dev_err (&h2_panel_dev.lcd_dev->dev,"failed to enable LCD panel\n" );
@@ -58,11 +61,14 @@ static int h2_panel_enable(struct lcd_panel *panel)static void h2_panel_disable (struct lcd_panel *panel) { +int r;/* * Deassert LCD_EN and BKLIGHT_EN pins on LCD panel * page2, GPIO config reg, GPIO(0,1) to out and deasserted */ -if (tsc2101_write_sync (h2_panel_dev.tsc2101_dev,2 ,0x23 ,0x8800 )) + r =tsc2101_write_sync (h2_panel_dev.tsc2101_dev, +TSC2XXX_REG (2 ,0x23 ),0x8800 ); +if (r <0 )dev_err (&h2_panel_dev.lcd_dev->dev,"failed to disable LCD panel\n" ); }
include/linux/spi/tsc2101.h +5 -5
@@ -30,11 +30,11 @@ struct tsc2101_platform_data {void (*disable_mclk)(struct spi_device *spi); }; -extern int tsc2101_read_sync (struct spi_device *spi,int page,u8 address); -extern int tsc2101_reads_sync (struct spi_device *spi,int page, -u8 startaddress,u16 * data,int numregs); -extern int tsc2101_write_sync (struct spi_device *spi,int page,u8 address, -u16 data); +extern u16 tsc2101_read_sync (struct spi_device *spi,u32 reg); +extern int tsc2101_reads_sync (struct spi_device *spi,u32 reg, +u16 *data,int numregs); +extern int tsc2101_write_sync (struct spi_device *spi,u32 reg, +u16 data);extern int tsc2101_enable_mclk (struct spi_device *spi);extern void tsc2101_disable_mclk (struct spi_device *spi);
PATCH 4/4 SPI: tsc2102 support for tsc2xxx core
In reply to Ragner MagalhaesFrom: Ragner Magalhaes <[email protected]>
Add support for tsc2xxx core api
---
drivers/spi/Kconfig | 5 - drivers/spi/tsc2102.c | 343 +++++++++++++------------------------------ include/linux/spi/tsc2102.h | 95 ++++++------ 3 files changed, 150 insertions(+), 293 deletions(-)
drivers/spi/Kconfig +3 -2
@@ -226,8 +226,9 @@ config SPI_TSC2101 as well as a way to enable the MCLK clock. config SPI_TSC2102 - depends on SPI_MASTER - tristate "TSC2102 codec support" + depends on SPI_MASTER + tristate "TSC2102 codec support" + select SPI_TSC2XXX ---help--- Say Y here if you want support for the TSC2102 chip. It will be needed for the touchscreen driver on some boards.
drivers/spi/tsc2102.c +100 -243
628 lines not on this page · raw message
include/linux/spi/tsc2102.h +47 -48
112 lines not on this page · raw message
Quoted 2 lines · Ragner Magalhaes
This is the start to build tsc2xxx core with all sharable routines between tsc2101, tsc2102, tsc2301 ... and more later tsc2100, tsc2111, etc.
I'm getting confused here. What's the plan? Is this an entirely different approach from the tsc210x stuff ... and if so, why?
I took a look at the tsc2101 bits, and I'm puzzled by why the original "int tsc2101_read_sync()" became "u16 tsc2101_read_sync()".
First, why return "int" instead of "negative erno or value"? Not that errors will be common, but returning "u16" means they can't ever be reported or handled...
Second, since that just wraps tsc2xxx_read_sync(), why even bother wrapping it? Better to call that directly ... more efficient and easier to understand/follow.
... and for that matter, the single-register read/write commands seem like they'd best use spi_write_then_read(), since DMA to stacks is unsafe and nonportable.
I certainly like the idea of having *one* core for all these TSC chips ... with reusable bits on top. And I know that audio will be one of the nastier bits, so being able to reuse e.g. the H2 (and H3?) audio support right away seems like a win. Do your patches also give us shared tsc2101/2102 touchscreen and hwmon support?
I just don't see how these parts are expected to fit together yet. The patch from Andrzej seemed a bit more clear, although it did not cover as much ground at the beginning. I suspect you have a plan, but it's just not yet apparent to me...
- Dave
Quoted 6 lines · ext David Brownell
Quoted 2 lines · Ragner Magalhaes
This is the start to build tsc2xxx core with all sharable routines between tsc2101, tsc2102, tsc2301 ... and more later tsc2100, tsc2111, etc.
I'm getting confused here. What's the plan? Is this an entirely different approach from the tsc210x stuff ... and if so, why?
I think we could to have a tsc2xxx core with all main sharable routines by tsc2xxx family ... and Chip-specific calling this core routines ...
And "[PATCH 1/4] SPI: tsc2xxx core" could to be the start ...
Quoted 8 lines
I took a look at the tsc2101 bits, and I'm puzzled by why the original "int
tsc2101_read_sync()" became "u16tsc2101_read_sync()".First, why return "int" instead of "negative erno or value"? Not that errors will be common, but returning "u16" means they can't ever be reported or handled...
Ok, I do not saw at the kernel's code some thing as
w = tsc2101_read_sync(spi, 1, 0);
if (w < 0) {
dev_err(&spi->dev, "Error or invalid anything \n");
goto err;
}I saw ...
w = tsc2101_read_sync(spi, 1, 0);
if (!(w & (1 << 14))) {
dev_err(&spi->dev, "Error or invalid anything \n");
goto err;
}I think my solution is not a mistake about this ...
Quoted 4 lines
Second, since that just wraps
tsc2xxx_read_sync(), why even bother wrapping it? Better to call that directly ... more efficient and easier to understand/follow.
Ok, thanks ...
Quoted 14 lines
... and for that matter, the single-register read/write commands seem like they'd best use
spi_write_then_read(), since DMA to stacks is unsafe and nonportable.I certainly like the idea of having *one* core for all these TSC chips ... with reusable bits on top. And I know that audio will be one of the nastier bits, so being able to reuse e.g. the H2 (and H3?) audio support right away seems like a win. Do your patches also give us shared tsc2101/2102 touchscreen and hwmon support?
Quoted 6 lines
I just don't see how these parts are expected to fit together yet. The patch from Andrzej seemed a bit more clear, although it did not cover as much ground at the beginning. I suspect you have a plan, but it's just not yet apparent to me...
- Dave
Ok, David
Thanks for yours comments ...
I go to continue working about this ... to find a better solution ..
Quoted 2 lines
Signature · 1 line
Ragner Magalhaes
Quoted 5 lines · Ragner Magalhaes
Quoted 4 lines · ext David Brownell
Quoted 2 lines · Ragner Magalhaes
This is the start to build tsc2xxx core with all sharable routines between tsc2101, tsc2102, tsc2301 ... and more later tsc2100, tsc2111, etc.
Quoted 7 lines
Quoted 2 lines
I'm getting confused here. What's the plan? Is this an entirely different approach from the tsc210x stuff ... and if so, why?
I think we could to have a tsc2xxx core with all main sharable routines by tsc2xxx family ... and Chip-specific calling this core routines ...
And "[PATCH 1/4] SPI: tsc2xxx core" could to be the start ...
Yes, but we also want other sharable code too. In most cases it seems that the touchscreen and sensor code is sharable -- modulo the "what sensors are valid on this system" issue -- and the audio code isn't. Plus tsc2301 has keypad support, etc.
Quoted 14 lines
Quoted 6 lines
I took a look at the tsc2101 bits, and I'm puzzled by why the original "int
tsc2101_read_sync()" became "u16tsc2101_read_sync()".First, why return "int" instead of "negative erno or value"? Not that errors will be common, but returning "u16" means they can't ever be reported or handled...
Ok, I do not saw at the kernel's code some thing as
w =
tsc2101_read_sync(spi, 1, 0);if (w < 0) { dev_err(&spi->dev, "Error or invalid anything \n"); goto err; }
Quoted 8 lines
I saw ...
w =tsc2101_read_sync(spi, 1, 0);if (!(w & (1 << 14))) { dev_err(&spi->dev, "Error or invalid anything \n"); goto err; }I think my solution is not a mistake about this ...
But, did yoou see the patch I posted yesterday? It fixes that. I had a similar patch for the old tsc2101 code too.
Quoted 10 lines
Quoted 6 lines
I just don't see how these parts are expected to fit together yet. The patch from Andrzej seemed a bit more clear, although it did not cover as much ground at the beginning. I suspect you have a plan, but it's just not yet apparent to me...
- Dave
Ok, David
Thanks for yours comments ...
I go to continue working about this ... to find a better solution ..