* [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data
@ 2010-04-30 12:23 Anatolij Gustschin
2010-04-30 12:23 ` [PATCH 2/2] Input: ads7846 - extend the driver for ads7845 controller support Anatolij Gustschin
2010-05-31 19:28 ` [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in " Anatolij Gustschin
0 siblings, 2 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2010-04-30 12:23 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov; +Cc: Detlev Zundel
On some platforms, for example with GPIO interrupts
on mpc5121, it is not possible to configure falling edge
interrupts.
Specifying irq trigger type in platform data structure
allows using ads7846 driver on such platforms.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
drivers/input/touchscreen/ads7846.c | 5 ++++-
include/linux/spi/ads7846.h | 1 +
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 532279c..9cfc865 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1174,7 +1174,10 @@ static int __devinit ads7846_probe(struct spi_device *spi)
goto err_put_regulator;
}
- if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
+ if (!pdata->irq_trigger)
+ pdata->irq_trigger = IRQF_TRIGGER_FALLING;
+
+ if (request_irq(spi->irq, ads7846_irq, pdata->irq_trigger,
spi->dev.driver->name, ts)) {
dev_info(&spi->dev,
"trying pin change workaround on irq %d\n", spi->irq);
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index b4ae570..32e34ba 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -54,5 +54,6 @@ struct ads7846_platform_data {
void (*filter_cleanup)(void *filter_data);
void (*wait_for_sync)(void);
bool wakeup;
+ u8 irq_trigger;
};
--
1.6.3.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] Input: ads7846 - extend the driver for ads7845 controller support
2010-04-30 12:23 [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data Anatolij Gustschin
@ 2010-04-30 12:23 ` Anatolij Gustschin
2010-06-29 9:29 ` [PATCH v2 " Anatolij Gustschin
2010-05-31 19:28 ` [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in " Anatolij Gustschin
1 sibling, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2010-04-30 12:23 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov; +Cc: Detlev Zundel
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
drivers/input/touchscreen/ads7846.c | 173 +++++++++++++++++++++++++++--------
1 files changed, 136 insertions(+), 37 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 9cfc865..1dd5c79 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -68,6 +68,8 @@ struct ts_event {
u16 y;
u16 z1, z2;
int ignore;
+ u8 x_buf[3];
+ u8 y_buf[3];
};
/*
@@ -79,6 +81,8 @@ struct ads7846_packet {
u8 read_x, read_y, read_z1, read_z2, pwrdown;
u16 dummy; /* for the pwrdown read */
struct ts_event tc;
+ /* for ads7845 with mpc5121 psc spi we use 3-byte buffers */
+ u8 read_x_cmd[3], read_y_cmd[3], pwrdown_cmd[3];
};
struct ads7846 {
@@ -207,6 +211,14 @@ struct ser_req {
struct spi_transfer xfer[6];
};
+struct ads7845_ser_req {
+ u8 command[3];
+ u8 pwrdown[3];
+ u8 sample[3];
+ struct spi_message msg;
+ struct spi_transfer xfer[2];
+};
+
static void ads7846_enable(struct ads7846 *ts);
static void ads7846_disable(struct ads7846 *ts);
@@ -287,6 +299,41 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
return status;
}
+static int ads7845_read12_ser(struct device *dev, unsigned command)
+{
+ struct spi_device *spi = to_spi_device(dev);
+ struct ads7846 *ts = dev_get_drvdata(dev);
+ struct ads7845_ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
+ int status;
+
+ if (!req)
+ return -ENOMEM;
+
+ spi_message_init(&req->msg);
+
+ req->command[0] = (u8) command;
+ req->xfer[0].tx_buf = req->command;
+ req->xfer[0].rx_buf = req->sample;
+ req->xfer[0].len = 3;
+ spi_message_add_tail(&req->xfer[0], &req->msg);
+
+ ts->irq_disabled = 1;
+ disable_irq(spi->irq);
+ status = spi_sync(spi, &req->msg);
+ ts->irq_disabled = 0;
+ enable_irq(spi->irq);
+
+ if (status == 0) {
+ /* BE12 value, then padding */
+ status = be16_to_cpu(*((u16 *)&req->sample[1]));
+ status = status >> 3;
+ status &= 0x0fff;
+ }
+
+ kfree(req);
+ return status;
+}
+
#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
#define SHOW(name, var, adjust) static ssize_t \
@@ -540,10 +587,17 @@ static void ads7846_rx(void *ads)
/* ads7846_rx_val() did in-place conversion (including byteswap) from
* on-the-wire format as part of debouncing to get stable readings.
*/
- x = packet->tc.x;
- y = packet->tc.y;
- z1 = packet->tc.z1;
- z2 = packet->tc.z2;
+ if (ts->model == 7845) {
+ x = *(u16 *)packet->tc.x_buf;
+ y = *(u16 *)packet->tc.y_buf;
+ z1 = 0;
+ z2 = 0;
+ } else {
+ x = packet->tc.x;
+ y = packet->tc.y;
+ z1 = packet->tc.z1;
+ z2 = packet->tc.z2;
+ }
/* range filtering */
if (x == MAX_12BIT)
@@ -551,6 +605,12 @@ static void ads7846_rx(void *ads)
if (ts->model == 7843) {
Rt = ts->pressure_max / 2;
+ } else if (ts->model == 7845) {
+ if (get_pendown_state(ts))
+ Rt = ts->pressure_max / 2;
+ else
+ Rt = 0;
+ dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt);
} else if (likely(x && z1)) {
/* compute touch pressure resistance using equation #2 */
Rt = z2;
@@ -671,10 +731,14 @@ static void ads7846_rx_val(void *ads)
m = &ts->msg[ts->msg_idx];
t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
- /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
- * built from two 8 bit values written msb-first.
- */
- val = be16_to_cpup((__be16 *)t->rx_buf) >> 3;
+ if (ts->model == 7845) {
+ val = be16_to_cpup((__be16 *)&(((char*)t->rx_buf)[1])) >> 3;
+ } else {
+ /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
+ * built from two 8 bit values written msb-first.
+ */
+ val = be16_to_cpup((__be16 *)t->rx_buf) >> 3;
+ }
action = ts->filter(ts->filter_data, ts->msg_idx, &val);
switch (action) {
@@ -1008,16 +1072,26 @@ static int __devinit ads7846_probe(struct spi_device *spi)
spi_message_init(m);
- /* y- still on; turn on only y+ (and ADC) */
- packet->read_y = READ_Y(vref);
- x->tx_buf = &packet->read_y;
- x->len = 1;
- spi_message_add_tail(x, m);
+ if (ts->model == 7845) {
+ packet->read_y_cmd[0] = READ_Y(vref);
+ packet->read_y_cmd[1] = 0;
+ packet->read_y_cmd[2] = 0;
+ x->tx_buf = &packet->read_y_cmd[0];
+ x->rx_buf = &packet->tc.y_buf[0];
+ x->len = 3;
+ spi_message_add_tail(x, m);
+ } else {
+ /* y- still on; turn on only y+ (and ADC) */
+ packet->read_y = READ_Y(vref);
+ x->tx_buf = &packet->read_y;
+ x->len = 1;
+ spi_message_add_tail(x, m);
- x++;
- x->rx_buf = &packet->tc.y;
- x->len = 2;
- spi_message_add_tail(x, m);
+ x++;
+ x->rx_buf = &packet->tc.y;
+ x->len = 2;
+ spi_message_add_tail(x, m);
+ }
/* the first sample after switching drivers can be low quality;
* optionally discard it, using a second one after the signals
@@ -1043,17 +1117,28 @@ static int __devinit ads7846_probe(struct spi_device *spi)
m++;
spi_message_init(m);
- /* turn y- off, x+ on, then leave in lowpower */
- x++;
- packet->read_x = READ_X(vref);
- x->tx_buf = &packet->read_x;
- x->len = 1;
- spi_message_add_tail(x, m);
+ if (ts->model == 7845) {
+ x++;
+ packet->read_x_cmd[0] = READ_X(vref);
+ packet->read_x_cmd[1] = 0;
+ packet->read_x_cmd[2] = 0;
+ x->tx_buf = &packet->read_x_cmd[0];
+ x->rx_buf = &packet->tc.x_buf[0];
+ x->len = 3;
+ spi_message_add_tail(x, m);
+ } else {
+ /* turn y- off, x+ on, then leave in lowpower */
+ x++;
+ packet->read_x = READ_X(vref);
+ x->tx_buf = &packet->read_x;
+ x->len = 1;
+ spi_message_add_tail(x, m);
- x++;
- x->rx_buf = &packet->tc.x;
- x->len = 2;
- spi_message_add_tail(x, m);
+ x++;
+ x->rx_buf = &packet->tc.x;
+ x->len = 2;
+ spi_message_add_tail(x, m);
+ }
/* ... maybe discard first sample ... */
if (pdata->settle_delay_usecs) {
@@ -1144,15 +1229,25 @@ static int __devinit ads7846_probe(struct spi_device *spi)
m++;
spi_message_init(m);
- x++;
- packet->pwrdown = PWRDOWN;
- x->tx_buf = &packet->pwrdown;
- x->len = 1;
- spi_message_add_tail(x, m);
+ if (ts->model == 7845) {
+ x++;
+ packet->pwrdown_cmd[0] = PWRDOWN;
+ packet->pwrdown_cmd[1] = 0;
+ packet->pwrdown_cmd[2] = 0;
+ x->tx_buf = &packet->pwrdown_cmd[0];
+ x->len = 3;
+ } else {
+ x++;
+ packet->pwrdown = PWRDOWN;
+ x->tx_buf = &packet->pwrdown;
+ x->len = 1;
+ spi_message_add_tail(x, m);
+
+ x++;
+ x->rx_buf = &packet->dummy;
+ x->len = 2;
+ }
- x++;
- x->rx_buf = &packet->dummy;
- x->len = 2;
CS_CHANGE(*x);
spi_message_add_tail(x, m);
@@ -1199,8 +1294,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
/* take a first sample, leaving nPENIRQ active and vREF off; avoid
* the touchscreen, in case it's not connected.
*/
- (void) ads7846_read12_ser(&spi->dev,
- READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
+ if (ts->model == 7845) {
+ ads7845_read12_ser(&spi->dev, PWRDOWN);
+ } else {
+ (void) ads7846_read12_ser(&spi->dev,
+ READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
+ }
err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
if (err)
--
1.6.3.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data
2010-04-30 12:23 [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data Anatolij Gustschin
2010-04-30 12:23 ` [PATCH 2/2] Input: ads7846 - extend the driver for ads7845 controller support Anatolij Gustschin
@ 2010-05-31 19:28 ` Anatolij Gustschin
2010-06-25 9:35 ` Anatolij Gustschin
1 sibling, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2010-05-31 19:28 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Detlev Zundel
Hi Dmitry,
On Fri, 30 Apr 2010 14:23:00 +0200
Anatolij Gustschin <agust@denx.de> wrote:
> On some platforms, for example with GPIO interrupts
> on mpc5121, it is not possible to configure falling edge
> interrupts.
>
> Specifying irq trigger type in platform data structure
> allows using ads7846 driver on such platforms.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> drivers/input/touchscreen/ads7846.c | 5 ++++-
> include/linux/spi/ads7846.h | 1 +
> 2 files changed, 5 insertions(+), 1 deletions(-)
Any comments on these patches?
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data
2010-05-31 19:28 ` [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in " Anatolij Gustschin
@ 2010-06-25 9:35 ` Anatolij Gustschin
2010-06-28 8:32 ` Dmitry Torokhov
0 siblings, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2010-06-25 9:35 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Anatolij Gustschin, linux-input, Detlev Zundel
On Mon, 31 May 2010 21:28:20 +0200
Anatolij Gustschin <agust@denx.de> wrote:
> Hi Dmitry,
>
> On Fri, 30 Apr 2010 14:23:00 +0200
> Anatolij Gustschin <agust@denx.de> wrote:
>
> > On some platforms, for example with GPIO interrupts
> > on mpc5121, it is not possible to configure falling edge
> > interrupts.
> >
> > Specifying irq trigger type in platform data structure
> > allows using ads7846 driver on such platforms.
> >
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > ---
> > drivers/input/touchscreen/ads7846.c | 5 ++++-
> > include/linux/spi/ads7846.h | 1 +
> > 2 files changed, 5 insertions(+), 1 deletions(-)
>
> Any comments on these patches?
Ping? The patches still apply on top of the input.git/next branch.
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data
2010-06-25 9:35 ` Anatolij Gustschin
@ 2010-06-28 8:32 ` Dmitry Torokhov
2010-06-29 7:24 ` Anatolij Gustschin
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2010-06-28 8:32 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: linux-input, Detlev Zundel
On Fri, Jun 25, 2010 at 11:35:34AM +0200, Anatolij Gustschin wrote:
> On Mon, 31 May 2010 21:28:20 +0200
> Anatolij Gustschin <agust@denx.de> wrote:
>
> > Hi Dmitry,
> >
> > On Fri, 30 Apr 2010 14:23:00 +0200
> > Anatolij Gustschin <agust@denx.de> wrote:
> >
> > > On some platforms, for example with GPIO interrupts
> > > on mpc5121, it is not possible to configure falling edge
> > > interrupts.
> > >
> > > Specifying irq trigger type in platform data structure
> > > allows using ads7846 driver on such platforms.
> > >
> > > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > > ---
> > > drivers/input/touchscreen/ads7846.c | 5 ++++-
> > > include/linux/spi/ads7846.h | 1 +
> > > 2 files changed, 5 insertions(+), 1 deletions(-)
> >
> > Any comments on these patches?
>
> Ping? The patches still apply on top of the input.git/next branch.
>
I applied the first one (however changed irq_trigger to be unsigned
long) however I'd like better changelog for 7845 changes.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data
2010-06-28 8:32 ` Dmitry Torokhov
@ 2010-06-29 7:24 ` Anatolij Gustschin
0 siblings, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2010-06-29 7:24 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Detlev Zundel
On Mon, 28 Jun 2010 01:32:08 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Fri, Jun 25, 2010 at 11:35:34AM +0200, Anatolij Gustschin wrote:
> > On Mon, 31 May 2010 21:28:20 +0200
> > Anatolij Gustschin <agust@denx.de> wrote:
> >
> > > Hi Dmitry,
> > >
> > > On Fri, 30 Apr 2010 14:23:00 +0200
> > > Anatolij Gustschin <agust@denx.de> wrote:
> > >
> > > > On some platforms, for example with GPIO interrupts
> > > > on mpc5121, it is not possible to configure falling edge
> > > > interrupts.
> > > >
> > > > Specifying irq trigger type in platform data structure
> > > > allows using ads7846 driver on such platforms.
> > > >
> > > > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > > > ---
> > > > drivers/input/touchscreen/ads7846.c | 5 ++++-
> > > > include/linux/spi/ads7846.h | 1 +
> > > > 2 files changed, 5 insertions(+), 1 deletions(-)
> > >
> > > Any comments on these patches?
> >
> > Ping? The patches still apply on top of the input.git/next branch.
> >
>
> I applied the first one (however changed irq_trigger to be unsigned
> long) however I'd like better changelog for 7845 changes.
Thanks. I'll submit v2 patch for 7845 changes with a better
changelog soon.
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 2/2] Input: ads7846 - extend the driver for ads7845 controller support
2010-04-30 12:23 ` [PATCH 2/2] Input: ads7846 - extend the driver for ads7845 controller support Anatolij Gustschin
@ 2010-06-29 9:29 ` Anatolij Gustschin
2010-06-30 8:18 ` Dmitry Torokhov
0 siblings, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2010-06-29 9:29 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov; +Cc: Detlev Zundel, Anatolij Gustschin
ADS7845 is a controller for 5-wire touch screens and
somewhat different from 7846. It requires three serial
communications to accomplish one complete conversion.
Unlike 7846 it doesn't allow Z1-/Z2- position measurement.
The patch extends the ads7846 driver to also support
ads7845. The packet struct is extended to contain
needed command and conversion buffers. ads7846_rx()
and ads7846_rx_val() now differentiate between 7845
and 7846 case. ads7846_probe() is modified to setup
ads7845 specific command and conversion messages and
to switch ads7845 into power-down mode, since this is
needed to be prepared to respond to pendown interrupts.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
Changes since first version:
- provide better changelog as requested by Dmitry
- fix to long comment line (it was over 80 characters)
drivers/input/touchscreen/ads7846.c | 173 +++++++++++++++++++++++++++--------
1 files changed, 136 insertions(+), 37 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 69210cb..8ab90dd 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -68,6 +68,8 @@ struct ts_event {
u16 y;
u16 z1, z2;
int ignore;
+ u8 x_buf[3];
+ u8 y_buf[3];
};
/*
@@ -79,6 +81,8 @@ struct ads7846_packet {
u8 read_x, read_y, read_z1, read_z2, pwrdown;
u16 dummy; /* for the pwrdown read */
struct ts_event tc;
+ /* for ads7845 with mpc5121 psc spi we use 3-byte buffers */
+ u8 read_x_cmd[3], read_y_cmd[3], pwrdown_cmd[3];
};
struct ads7846 {
@@ -207,6 +211,14 @@ struct ser_req {
struct spi_transfer xfer[6];
};
+struct ads7845_ser_req {
+ u8 command[3];
+ u8 pwrdown[3];
+ u8 sample[3];
+ struct spi_message msg;
+ struct spi_transfer xfer[2];
+};
+
static void ads7846_enable(struct ads7846 *ts);
static void ads7846_disable(struct ads7846 *ts);
@@ -287,6 +299,41 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
return status;
}
+static int ads7845_read12_ser(struct device *dev, unsigned command)
+{
+ struct spi_device *spi = to_spi_device(dev);
+ struct ads7846 *ts = dev_get_drvdata(dev);
+ struct ads7845_ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
+ int status;
+
+ if (!req)
+ return -ENOMEM;
+
+ spi_message_init(&req->msg);
+
+ req->command[0] = (u8) command;
+ req->xfer[0].tx_buf = req->command;
+ req->xfer[0].rx_buf = req->sample;
+ req->xfer[0].len = 3;
+ spi_message_add_tail(&req->xfer[0], &req->msg);
+
+ ts->irq_disabled = 1;
+ disable_irq(spi->irq);
+ status = spi_sync(spi, &req->msg);
+ ts->irq_disabled = 0;
+ enable_irq(spi->irq);
+
+ if (status == 0) {
+ /* BE12 value, then padding */
+ status = be16_to_cpu(*((u16 *)&req->sample[1]));
+ status = status >> 3;
+ status &= 0x0fff;
+ }
+
+ kfree(req);
+ return status;
+}
+
#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
#define SHOW(name, var, adjust) static ssize_t \
@@ -540,10 +587,17 @@ static void ads7846_rx(void *ads)
/* ads7846_rx_val() did in-place conversion (including byteswap) from
* on-the-wire format as part of debouncing to get stable readings.
*/
- x = packet->tc.x;
- y = packet->tc.y;
- z1 = packet->tc.z1;
- z2 = packet->tc.z2;
+ if (ts->model == 7845) {
+ x = *(u16 *)packet->tc.x_buf;
+ y = *(u16 *)packet->tc.y_buf;
+ z1 = 0;
+ z2 = 0;
+ } else {
+ x = packet->tc.x;
+ y = packet->tc.y;
+ z1 = packet->tc.z1;
+ z2 = packet->tc.z2;
+ }
/* range filtering */
if (x == MAX_12BIT)
@@ -551,6 +605,12 @@ static void ads7846_rx(void *ads)
if (ts->model == 7843) {
Rt = ts->pressure_max / 2;
+ } else if (ts->model == 7845) {
+ if (get_pendown_state(ts))
+ Rt = ts->pressure_max / 2;
+ else
+ Rt = 0;
+ dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt);
} else if (likely(x && z1)) {
/* compute touch pressure resistance using equation #2 */
Rt = z2;
@@ -671,10 +731,14 @@ static void ads7846_rx_val(void *ads)
m = &ts->msg[ts->msg_idx];
t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
- /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
- * built from two 8 bit values written msb-first.
- */
- val = be16_to_cpup((__be16 *)t->rx_buf) >> 3;
+ if (ts->model == 7845) {
+ val = be16_to_cpup((__be16 *)&(((char*)t->rx_buf)[1])) >> 3;
+ } else {
+ /* adjust: on-wire is a must-ignore bit, a BE12 value, then
+ * padding; built from two 8 bit values written msb-first.
+ */
+ val = be16_to_cpup((__be16 *)t->rx_buf) >> 3;
+ }
action = ts->filter(ts->filter_data, ts->msg_idx, &val);
switch (action) {
@@ -1008,16 +1072,26 @@ static int __devinit ads7846_probe(struct spi_device *spi)
spi_message_init(m);
- /* y- still on; turn on only y+ (and ADC) */
- packet->read_y = READ_Y(vref);
- x->tx_buf = &packet->read_y;
- x->len = 1;
- spi_message_add_tail(x, m);
+ if (ts->model == 7845) {
+ packet->read_y_cmd[0] = READ_Y(vref);
+ packet->read_y_cmd[1] = 0;
+ packet->read_y_cmd[2] = 0;
+ x->tx_buf = &packet->read_y_cmd[0];
+ x->rx_buf = &packet->tc.y_buf[0];
+ x->len = 3;
+ spi_message_add_tail(x, m);
+ } else {
+ /* y- still on; turn on only y+ (and ADC) */
+ packet->read_y = READ_Y(vref);
+ x->tx_buf = &packet->read_y;
+ x->len = 1;
+ spi_message_add_tail(x, m);
- x++;
- x->rx_buf = &packet->tc.y;
- x->len = 2;
- spi_message_add_tail(x, m);
+ x++;
+ x->rx_buf = &packet->tc.y;
+ x->len = 2;
+ spi_message_add_tail(x, m);
+ }
/* the first sample after switching drivers can be low quality;
* optionally discard it, using a second one after the signals
@@ -1043,17 +1117,28 @@ static int __devinit ads7846_probe(struct spi_device *spi)
m++;
spi_message_init(m);
- /* turn y- off, x+ on, then leave in lowpower */
- x++;
- packet->read_x = READ_X(vref);
- x->tx_buf = &packet->read_x;
- x->len = 1;
- spi_message_add_tail(x, m);
+ if (ts->model == 7845) {
+ x++;
+ packet->read_x_cmd[0] = READ_X(vref);
+ packet->read_x_cmd[1] = 0;
+ packet->read_x_cmd[2] = 0;
+ x->tx_buf = &packet->read_x_cmd[0];
+ x->rx_buf = &packet->tc.x_buf[0];
+ x->len = 3;
+ spi_message_add_tail(x, m);
+ } else {
+ /* turn y- off, x+ on, then leave in lowpower */
+ x++;
+ packet->read_x = READ_X(vref);
+ x->tx_buf = &packet->read_x;
+ x->len = 1;
+ spi_message_add_tail(x, m);
- x++;
- x->rx_buf = &packet->tc.x;
- x->len = 2;
- spi_message_add_tail(x, m);
+ x++;
+ x->rx_buf = &packet->tc.x;
+ x->len = 2;
+ spi_message_add_tail(x, m);
+ }
/* ... maybe discard first sample ... */
if (pdata->settle_delay_usecs) {
@@ -1144,15 +1229,25 @@ static int __devinit ads7846_probe(struct spi_device *spi)
m++;
spi_message_init(m);
- x++;
- packet->pwrdown = PWRDOWN;
- x->tx_buf = &packet->pwrdown;
- x->len = 1;
- spi_message_add_tail(x, m);
+ if (ts->model == 7845) {
+ x++;
+ packet->pwrdown_cmd[0] = PWRDOWN;
+ packet->pwrdown_cmd[1] = 0;
+ packet->pwrdown_cmd[2] = 0;
+ x->tx_buf = &packet->pwrdown_cmd[0];
+ x->len = 3;
+ } else {
+ x++;
+ packet->pwrdown = PWRDOWN;
+ x->tx_buf = &packet->pwrdown;
+ x->len = 1;
+ spi_message_add_tail(x, m);
+
+ x++;
+ x->rx_buf = &packet->dummy;
+ x->len = 2;
+ }
- x++;
- x->rx_buf = &packet->dummy;
- x->len = 2;
CS_CHANGE(*x);
spi_message_add_tail(x, m);
@@ -1199,8 +1294,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
/* take a first sample, leaving nPENIRQ active and vREF off; avoid
* the touchscreen, in case it's not connected.
*/
- (void) ads7846_read12_ser(&spi->dev,
- READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
+ if (ts->model == 7845) {
+ ads7845_read12_ser(&spi->dev, PWRDOWN);
+ } else {
+ (void) ads7846_read12_ser(&spi->dev,
+ READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
+ }
err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
if (err)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/2] Input: ads7846 - extend the driver for ads7845 controller support
2010-06-29 9:29 ` [PATCH v2 " Anatolij Gustschin
@ 2010-06-30 8:18 ` Dmitry Torokhov
2010-06-30 8:45 ` Anatolij Gustschin
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2010-06-30 8:18 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: linux-input, Detlev Zundel
On Tue, Jun 29, 2010 at 11:29:53AM +0200, Anatolij Gustschin wrote:
> ADS7845 is a controller for 5-wire touch screens and
> somewhat different from 7846. It requires three serial
> communications to accomplish one complete conversion.
> Unlike 7846 it doesn't allow Z1-/Z2- position measurement.
>
> The patch extends the ads7846 driver to also support
> ads7845. The packet struct is extended to contain
> needed command and conversion buffers. ads7846_rx()
> and ads7846_rx_val() now differentiate between 7845
> and 7846 case. ads7846_probe() is modified to setup
> ads7845 specific command and conversion messages and
> to switch ads7845 into power-down mode, since this is
> needed to be prepared to respond to pendown interrupts.
>
Thank you for making changes Anatolij, I iwll be applying the patch to
my 2.6.36 queue.
I just noticed that your previous patch alters pdata which I belive is
wrong thing to do. Could you please try the following patch and let me
know if I broke anything?
Thanks!
--
Dmitry
Input: ads7846 - do not allow altering platform data
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/touchscreen/ads7846.c | 35 +++++++++++++++++++----------------
include/linux/spi/ads7846.h | 2 +-
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 69210cb..8c9b316 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -878,14 +878,15 @@ static int __devinit setup_pendown(struct spi_device *spi, struct ads7846 *ts)
static int __devinit ads7846_probe(struct spi_device *spi)
{
- struct ads7846 *ts;
- struct ads7846_packet *packet;
- struct input_dev *input_dev;
- struct ads7846_platform_data *pdata = spi->dev.platform_data;
- struct spi_message *m;
- struct spi_transfer *x;
- int vref;
- int err;
+ struct ads7846 *ts;
+ struct ads7846_packet *packet;
+ struct input_dev *input_dev;
+ const struct ads7846_platform_data *pdata = spi->dev.platform_data;
+ struct spi_message *m;
+ struct spi_transfer *x;
+ unsigned long irq_flags;
+ int vref;
+ int err;
if (!spi->irq) {
dev_dbg(&spi->dev, "no IRQ?\n");
@@ -1174,20 +1175,22 @@ static int __devinit ads7846_probe(struct spi_device *spi)
goto err_put_regulator;
}
- if (!pdata->irq_flags)
- pdata->irq_flags = IRQF_TRIGGER_FALLING;
+ irq_flags = pdata->irq_flags ? : IRQF_TRIGGER_FALLING;
- if (request_irq(spi->irq, ads7846_irq, pdata->irq_flags,
- spi->dev.driver->name, ts)) {
+ err = request_irq(spi->irq, ads7846_irq, pdata->irq_flags,
+ spi->dev.driver->name, ts);
+
+ if (err && !pdata->irq_flags) {
dev_info(&spi->dev,
"trying pin change workaround on irq %d\n", spi->irq);
err = request_irq(spi->irq, ads7846_irq,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
spi->dev.driver->name, ts);
- if (err) {
- dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
- goto err_disable_regulator;
- }
+ }
+
+ if (err) {
+ dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
+ goto err_disable_regulator;
}
err = ads784x_hwmon_register(spi, ts);
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 95d36bf..92bd083 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -48,7 +48,7 @@ struct ads7846_platform_data {
* state if get_pendown_state == NULL
*/
int (*get_pendown_state)(void);
- int (*filter_init) (struct ads7846_platform_data *pdata,
+ int (*filter_init) (const struct ads7846_platform_data *pdata,
void **filter_data);
int (*filter) (void *filter_data, int data_idx, int *val);
void (*filter_cleanup)(void *filter_data);
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/2] Input: ads7846 - extend the driver for ads7845 controller support
2010-06-30 8:18 ` Dmitry Torokhov
@ 2010-06-30 8:45 ` Anatolij Gustschin
2010-07-01 11:23 ` Anatolij Gustschin
2010-07-01 11:26 ` [PATCH] Input: ads7846 - do not allow altering platform data Anatolij Gustschin
2 siblings, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2010-06-30 8:45 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Detlev Zundel
On Wed, 30 Jun 2010 01:18:05 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
...
> I just noticed that your previous patch alters pdata which I belive is
> wrong thing to do. Could you please try the following patch and let me
> know if I broke anything?
Yes, altering pdata isn't a good idea. I can't try the patch just now
but will test it this evening.
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/2] Input: ads7846 - extend the driver for ads7845 controller support
2010-06-30 8:18 ` Dmitry Torokhov
2010-06-30 8:45 ` Anatolij Gustschin
@ 2010-07-01 11:23 ` Anatolij Gustschin
2010-07-01 11:26 ` [PATCH] Input: ads7846 - do not allow altering platform data Anatolij Gustschin
2 siblings, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2010-07-01 11:23 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Detlev Zundel
On Wed, 30 Jun 2010 01:18:05 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Tue, Jun 29, 2010 at 11:29:53AM +0200, Anatolij Gustschin wrote:
> > ADS7845 is a controller for 5-wire touch screens and
> > somewhat different from 7846. It requires three serial
> > communications to accomplish one complete conversion.
> > Unlike 7846 it doesn't allow Z1-/Z2- position measurement.
> >
> > The patch extends the ads7846 driver to also support
> > ads7845. The packet struct is extended to contain
> > needed command and conversion buffers. ads7846_rx()
> > and ads7846_rx_val() now differentiate between 7845
> > and 7846 case. ads7846_probe() is modified to setup
> > ads7845 specific command and conversion messages and
> > to switch ads7845 into power-down mode, since this is
> > needed to be prepared to respond to pendown interrupts.
> >
>
> Thank you for making changes Anatolij, I iwll be applying the patch to
> my 2.6.36 queue.
>
> I just noticed that your previous patch alters pdata which I belive is
> wrong thing to do. Could you please try the following patch and let me
> know if I broke anything?
The patch needs a small fix, please see below.
...
> - if (!pdata->irq_flags)
> - pdata->irq_flags = IRQF_TRIGGER_FALLING;
> + irq_flags = pdata->irq_flags ? : IRQF_TRIGGER_FALLING;
>
> - if (request_irq(spi->irq, ads7846_irq, pdata->irq_flags,
> - spi->dev.driver->name, ts)) {
> + err = request_irq(spi->irq, ads7846_irq, pdata->irq_flags,
> + spi->dev.driver->name, ts);
We should pass previously obtained 'irq_flags' to request_irq(),
not the original 'pdata->irq_flags'. I fixed this and tested the
corrected patch with ads7845, it is okay now. I'll submit the
corrected patch shortly.
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] Input: ads7846 - do not allow altering platform data
2010-06-30 8:18 ` Dmitry Torokhov
2010-06-30 8:45 ` Anatolij Gustschin
2010-07-01 11:23 ` Anatolij Gustschin
@ 2010-07-01 11:26 ` Anatolij Gustschin
2010-07-01 16:10 ` Dmitry Torokhov
2 siblings, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2010-07-01 11:26 UTC (permalink / raw)
To: linux-input; +Cc: Detlev Zundel, Dmitry Torokhov, Dmitry Torokhov
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Tested-by: Anatolij Gustschin <agust@denx.de>
---
drivers/input/touchscreen/ads7846.c | 35 +++++++++++++++++++----------------
include/linux/spi/ads7846.h | 2 +-
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 8ab90dd..82290ff 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -942,14 +942,15 @@ static int __devinit setup_pendown(struct spi_device *spi, struct ads7846 *ts)
static int __devinit ads7846_probe(struct spi_device *spi)
{
- struct ads7846 *ts;
- struct ads7846_packet *packet;
- struct input_dev *input_dev;
- struct ads7846_platform_data *pdata = spi->dev.platform_data;
- struct spi_message *m;
- struct spi_transfer *x;
- int vref;
- int err;
+ struct ads7846 *ts;
+ struct ads7846_packet *packet;
+ struct input_dev *input_dev;
+ const struct ads7846_platform_data *pdata = spi->dev.platform_data;
+ struct spi_message *m;
+ struct spi_transfer *x;
+ unsigned long irq_flags;
+ int vref;
+ int err;
if (!spi->irq) {
dev_dbg(&spi->dev, "no IRQ?\n");
@@ -1269,20 +1270,22 @@ static int __devinit ads7846_probe(struct spi_device *spi)
goto err_put_regulator;
}
- if (!pdata->irq_flags)
- pdata->irq_flags = IRQF_TRIGGER_FALLING;
+ irq_flags = pdata->irq_flags ? : IRQF_TRIGGER_FALLING;
- if (request_irq(spi->irq, ads7846_irq, pdata->irq_flags,
- spi->dev.driver->name, ts)) {
+ err = request_irq(spi->irq, ads7846_irq, irq_flags,
+ spi->dev.driver->name, ts);
+
+ if (err && !pdata->irq_flags) {
dev_info(&spi->dev,
"trying pin change workaround on irq %d\n", spi->irq);
err = request_irq(spi->irq, ads7846_irq,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
spi->dev.driver->name, ts);
- if (err) {
- dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
- goto err_disable_regulator;
- }
+ }
+
+ if (err) {
+ dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
+ goto err_disable_regulator;
}
err = ads784x_hwmon_register(spi, ts);
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 95d36bf..92bd083 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -48,7 +48,7 @@ struct ads7846_platform_data {
* state if get_pendown_state == NULL
*/
int (*get_pendown_state)(void);
- int (*filter_init) (struct ads7846_platform_data *pdata,
+ int (*filter_init) (const struct ads7846_platform_data *pdata,
void **filter_data);
int (*filter) (void *filter_data, int data_idx, int *val);
void (*filter_cleanup)(void *filter_data);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] Input: ads7846 - do not allow altering platform data
2010-07-01 11:26 ` [PATCH] Input: ads7846 - do not allow altering platform data Anatolij Gustschin
@ 2010-07-01 16:10 ` Dmitry Torokhov
0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2010-07-01 16:10 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: linux-input, Detlev Zundel
On Thu, Jul 01, 2010 at 01:26:45PM +0200, Anatolij Gustschin wrote:
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> Tested-by: Anatolij Gustschin <agust@denx.de>
Applied, thanks Anatolij.
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-07-01 16:10 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-30 12:23 [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in platform data Anatolij Gustschin
2010-04-30 12:23 ` [PATCH 2/2] Input: ads7846 - extend the driver for ads7845 controller support Anatolij Gustschin
2010-06-29 9:29 ` [PATCH v2 " Anatolij Gustschin
2010-06-30 8:18 ` Dmitry Torokhov
2010-06-30 8:45 ` Anatolij Gustschin
2010-07-01 11:23 ` Anatolij Gustschin
2010-07-01 11:26 ` [PATCH] Input: ads7846 - do not allow altering platform data Anatolij Gustschin
2010-07-01 16:10 ` Dmitry Torokhov
2010-05-31 19:28 ` [PATCH 1/2] Input: ads7846 - allow specifying irq trigger type in " Anatolij Gustschin
2010-06-25 9:35 ` Anatolij Gustschin
2010-06-28 8:32 ` Dmitry Torokhov
2010-06-29 7:24 ` Anatolij Gustschin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).