From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Lee Jones <lee.jones@linaro.org>, Samuel Ortiz <sameo@linux.intel.com>
Cc: "Benoît Cousson" <b-cousson@ti.com>,
"Tony Lindgren" <tony@atomide.com>,
"Jonathan Cameron" <jic23@cam.ac.uk>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Felipe Balbi" <balbi@ti.com>,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
linux-iio@vger.kernel.org, linux-input@vger.kernel.org, "Patil,
Rachna" <rachna@ti.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Subject: [PATCH 04/22] input/ti_am33x_tsc: Order of TSC wires, made configurable
Date: Tue, 11 Jun 2013 13:30:50 +0200 [thread overview]
Message-ID: <1370950268-7224-5-git-send-email-bigeasy@linutronix.de> (raw)
In-Reply-To: <1370950268-7224-1-git-send-email-bigeasy@linutronix.de>
From: "Patil, Rachna" <rachna@ti.com>
The current driver expected touchscreen input
wires(XP,XN,YP,YN) to be connected in a particular order.
Making changes to accept this as platform data.
Signed-off-by: Patil, Rachna <rachna@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
[bigeasy: larger rework of the patch, no config[4][4] array, smaller
sized config_inp, no regbit_map(), shrinked
titsc_config_wires(), no config redo on resume, config_inp and
friends are now u32]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/input/touchscreen/ti_am335x_tsc.c | 102 ++++++++++++++++++++++++-----
include/linux/input/ti_am335x_tsc.h | 12 ++++
include/linux/mfd/ti_am335x_tscadc.h | 10 ++-
3 files changed, 105 insertions(+), 19 deletions(-)
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 23d6a4d..56c6220 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -33,6 +33,13 @@
#define SEQ_SETTLE 275
#define MAX_12BIT ((1 << 12) - 1)
+static const int config_pins[] = {
+ XPP,
+ XNN,
+ YPP,
+ YNN,
+};
+
struct titsc {
struct input_dev *input;
struct ti_tscadc_dev *mfd_tscadc;
@@ -41,6 +48,9 @@ struct titsc {
unsigned int x_plate_resistance;
bool pen_down;
int steps_to_configure;
+ u32 config_inp[4];
+ u32 bit_xp, bit_xn, bit_yp, bit_yn;
+ u32 inp_xp, inp_xn, inp_yp, inp_yn;
};
static unsigned int titsc_readl(struct titsc *ts, unsigned int reg)
@@ -54,6 +64,58 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg,
writel(val, tsc->mfd_tscadc->tscadc_base + reg);
}
+static int titsc_config_wires(struct titsc *ts_dev)
+{
+ u32 analog_line[4];
+ u32 wire_order[4];
+ int i, bit_cfg;
+
+ for (i = 0; i < 4; i++) {
+ /*
+ * Get the order in which TSC wires are attached
+ * w.r.t. each of the analog input lines on the EVM.
+ */
+ analog_line[i] = (ts_dev->config_inp[i] & 0xF0) >> 4;
+ wire_order[i] = ts_dev->config_inp[i] & 0x0F;
+ if (WARN_ON(analog_line[i] > 7))
+ return -EINVAL;
+ if (WARN_ON(wire_order[i] > ARRAY_SIZE(config_pins)))
+ return -EINVAL;
+ }
+
+ for (i = 0; i < 4; i++) {
+ int an_line;
+ int wi_order;
+
+ an_line = analog_line[i];
+ wi_order = wire_order[i];
+ bit_cfg = config_pins[wi_order];
+ if (bit_cfg == 0)
+ return -EINVAL;
+ switch (wi_order) {
+ case 0:
+ ts_dev->bit_xp = bit_cfg;
+ ts_dev->inp_xp = an_line;
+ break;
+
+ case 1:
+ ts_dev->bit_xn = bit_cfg;
+ ts_dev->inp_xn = an_line;
+ break;
+
+ case 2:
+ ts_dev->bit_yp = bit_cfg;
+ ts_dev->inp_yp = an_line;
+ break;
+ case 3:
+ ts_dev->bit_yn = bit_cfg;
+ ts_dev->inp_yn = an_line;
+ break;
+ }
+ }
+ return 0;
+}
+
static void titsc_step_config(struct titsc *ts_dev)
{
unsigned int config;
@@ -64,18 +126,18 @@ static void titsc_step_config(struct titsc *ts_dev)
total_steps = 2 * ts_dev->steps_to_configure;
config = STEPCONFIG_MODE_HWSYNC |
- STEPCONFIG_AVG_16 | STEPCONFIG_XPP;
+ STEPCONFIG_AVG_16 | ts_dev->bit_xp;
switch (ts_dev->wires) {
case 4:
- config |= STEPCONFIG_INP_AN2 | STEPCONFIG_XNN;
+ config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn;
break;
case 5:
- config |= STEPCONFIG_YNN |
- STEPCONFIG_INP_AN4 | STEPCONFIG_XNN |
- STEPCONFIG_YPP;
+ config |= ts_dev->bit_yn |
+ STEPCONFIG_INP_AN4 | ts_dev->bit_xn |
+ ts_dev->bit_yp;
break;
case 8:
- config |= STEPCONFIG_INP_AN2 | STEPCONFIG_XNN;
+ config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn;
break;
}
@@ -86,18 +148,18 @@ static void titsc_step_config(struct titsc *ts_dev)
config = 0;
config = STEPCONFIG_MODE_HWSYNC |
- STEPCONFIG_AVG_16 | STEPCONFIG_YNN |
+ STEPCONFIG_AVG_16 | ts_dev->bit_yn |
STEPCONFIG_INM_ADCREFM | STEPCONFIG_FIFO1;
switch (ts_dev->wires) {
case 4:
- config |= STEPCONFIG_YPP;
+ config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp);
break;
case 5:
- config |= STEPCONFIG_XPP | STEPCONFIG_INP_AN4 |
- STEPCONFIG_XNP | STEPCONFIG_YPN;
+ config |= ts_dev->bit_xp | STEPCONFIG_INP_AN4 |
+ ts_dev->bit_xn | ts_dev->bit_yp;
break;
case 8:
- config |= STEPCONFIG_YPP;
+ config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp);
break;
}
@@ -108,9 +170,9 @@ static void titsc_step_config(struct titsc *ts_dev)
config = 0;
/* Charge step configuration */
- config = STEPCONFIG_XPP | STEPCONFIG_YNN |
+ config = ts_dev->bit_xp | ts_dev->bit_yn |
STEPCHARGE_RFP_XPUL | STEPCHARGE_RFM_XNUR |
- STEPCHARGE_INM_AN1 | STEPCHARGE_INP_AN1;
+ STEPCHARGE_INM_AN1 | STEPCHARGE_INP(ts_dev->inp_yp);
titsc_writel(ts_dev, REG_CHARGECONFIG, config);
titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
@@ -118,13 +180,14 @@ static void titsc_step_config(struct titsc *ts_dev)
config = 0;
/* Configure to calculate pressure */
config = STEPCONFIG_MODE_HWSYNC |
- STEPCONFIG_AVG_16 | STEPCONFIG_YPP |
- STEPCONFIG_XNN | STEPCONFIG_INM_ADCREFM;
+ STEPCONFIG_AVG_16 | ts_dev->bit_yp |
+ ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM |
+ STEPCONFIG_INP(ts_dev->inp_xp);
titsc_writel(ts_dev, REG_STEPCONFIG(total_steps + 1), config);
titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 1),
STEPCONFIG_OPENDLY);
- config |= STEPCONFIG_INP_AN3 | STEPCONFIG_FIFO1;
+ config |= STEPCONFIG_INP(ts_dev->inp_yn) | STEPCONFIG_FIFO1;
titsc_writel(ts_dev, REG_STEPCONFIG(total_steps + 2), config);
titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 2),
STEPCONFIG_OPENDLY);
@@ -292,6 +355,8 @@ static int titsc_probe(struct platform_device *pdev)
ts_dev->wires = pdata->tsc_init->wires;
ts_dev->x_plate_resistance = pdata->tsc_init->x_plate_resistance;
ts_dev->steps_to_configure = pdata->tsc_init->steps_to_configure;
+ memcpy(ts_dev->config_inp, pdata->tsc_init->wire_config,
+ sizeof(pdata->tsc_init->wire_config));
err = request_irq(ts_dev->irq, titsc_irq,
0, pdev->dev.driver->name, ts_dev);
@@ -301,6 +366,11 @@ static int titsc_probe(struct platform_device *pdev)
}
titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
+ err = titsc_config_wires(ts_dev);
+ if (err) {
+ dev_err(&pdev->dev, "wrong i/p wire configuration\n");
+ goto err_free_irq;
+ }
titsc_step_config(ts_dev);
titsc_writel(ts_dev, REG_FIFO0THR, ts_dev->steps_to_configure);
diff --git a/include/linux/input/ti_am335x_tsc.h b/include/linux/input/ti_am335x_tsc.h
index 49269a2..6a66b4d 100644
--- a/include/linux/input/ti_am335x_tsc.h
+++ b/include/linux/input/ti_am335x_tsc.h
@@ -12,12 +12,24 @@
* A step configured to read a single
* co-ordinate value, can be applied
* more number of times for better results.
+ * @wire_config: Different EVM's could have a different order
+ * for connecting wires on touchscreen.
+ * We need to provide an 8 bit number where in
+ * the 1st four bits represent the analog lines
+ * and the next 4 bits represent positive/
+ * negative terminal on that input line.
+ * Notations to represent the input lines and
+ * terminals resoectively is as follows:
+ * AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
+ * XP = 0, XN = 1, YP = 2, YN = 3.
+ *
*/
struct tsc_data {
int wires;
int x_plate_resistance;
int steps_to_configure;
+ int wire_config[10];
};
#endif
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index eeead15..2d78af8 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -71,8 +71,6 @@
#define STEPCONFIG_INM_ADCREFM STEPCONFIG_INM(8)
#define STEPCONFIG_INP_MASK (0xF << 19)
#define STEPCONFIG_INP(val) ((val) << 19)
-#define STEPCONFIG_INP_AN2 STEPCONFIG_INP(2)
-#define STEPCONFIG_INP_AN3 STEPCONFIG_INP(3)
#define STEPCONFIG_INP_AN4 STEPCONFIG_INP(4)
#define STEPCONFIG_INP_ADCREFM STEPCONFIG_INP(8)
#define STEPCONFIG_FIFO1 BIT(26)
@@ -94,7 +92,6 @@
#define STEPCHARGE_INM_AN1 STEPCHARGE_INM(1)
#define STEPCHARGE_INP_MASK (0xF << 19)
#define STEPCHARGE_INP(val) ((val) << 19)
-#define STEPCHARGE_INP_AN1 STEPCHARGE_INP(1)
#define STEPCHARGE_RFM_MASK (3 << 23)
#define STEPCHARGE_RFM(val) ((val) << 23)
#define STEPCHARGE_RFM_XNUR STEPCHARGE_RFM(1)
@@ -116,6 +113,13 @@
#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3)
#define CNTRLREG_TSCENB BIT(7)
+#define XPP STEPCONFIG_XPP
+#define XNP STEPCONFIG_XNP
+#define XNN STEPCONFIG_XNN
+#define YPP STEPCONFIG_YPP
+#define YPN STEPCONFIG_YPN
+#define YNN STEPCONFIG_YNN
+
#define ADC_CLK 3000000
#define MAX_CLK_DIV 7
#define TOTAL_STEPS 16
--
1.7.10.4
next prev parent reply other threads:[~2013-06-11 11:30 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-11 11:30 am335x: TSC & ADC reworking including DT pieces, take 4 Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 01/22] mfd/ti_am335x_tscadc: remove regmap Sebastian Andrzej Siewior
2013-06-11 14:23 ` Samuel Ortiz
2013-06-11 14:34 ` Sebastian Andrzej Siewior
[not found] ` <51B7358D.7000605-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-14 13:53 ` Mark Brown
[not found] ` <20130614135358.GR1403-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-06-17 11:41 ` Sebastian Andrzej Siewior
[not found] ` <51BEF5F4.4090600-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-17 16:03 ` Mark Brown
2013-07-04 9:02 ` Sebastian Andrzej Siewior
2013-07-04 10:45 ` Mark Brown
[not found] ` <20130704104511.GU27646-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-07-04 11:15 ` Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 02/22] mfd & input & iio/ti_am335x_adc: use one structure for ti_tscadc_dev Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 03/22] input/ti_am33x_tsc: Step enable bits made configurable Sebastian Andrzej Siewior
2013-06-11 11:30 ` Sebastian Andrzej Siewior [this message]
[not found] ` <1370950268-7224-5-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-11 14:23 ` [PATCH 04/22] input/ti_am33x_tsc: Order of TSC wires, " Samuel Ortiz
2013-06-11 14:35 ` Sebastian Andrzej Siewior
2013-07-04 11:14 ` Sekhar Nori
[not found] ` <51D5592F.6050208-l0cyMroinI0@public.gmane.org>
2013-07-04 11:33 ` Sebastian Andrzej Siewior
[not found] ` <51D55D80.6080803-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-07-04 13:39 ` Sekhar Nori
2013-07-04 13:50 ` Sebastian Andrzej Siewior
2013-07-04 14:27 ` Sekhar Nori
2013-06-11 11:30 ` [PATCH 05/22] input/ti_am33x_tsc: remove unwanted fifo flush Sebastian Andrzej Siewior
[not found] ` <1370950268-7224-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-11 11:30 ` [PATCH 06/22] input/ti_am33x_tsc: Add DT support Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 17/22] mfd & iio/ti_am335x_adc: rename device from tiadc to TI-am335x-adc Sebastian Andrzej Siewior
2013-06-11 12:05 ` am335x: TSC & ADC reworking including DT pieces, take 4 Lee Jones
2013-06-11 13:53 ` Lars-Peter Clausen
2013-06-11 11:30 ` [PATCH 07/22] input/ti_am33x_tsc: remove platform_data support Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 08/22] iio/ti_am335x_adc: Add DT support Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 09/22] iio/ti_am335x_adc: remove platform_data support Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 10/22] mfd/ti_am335x_tscadc: Add DT support Sebastian Andrzej Siewior
2013-06-11 14:23 ` Samuel Ortiz
2013-06-11 14:42 ` Sebastian Andrzej Siewior
2013-06-11 15:05 ` Samuel Ortiz
2013-06-11 15:41 ` Sebastian Andrzej Siewior
2013-06-11 18:42 ` Lee Jones
[not found] ` <51B73756.5010004-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-11 17:10 ` Lee Jones
2013-06-11 11:30 ` [PATCH 11/22] mfd/ti_am335x_tscadc: remove platform_data support Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 12/22] iio/ti_tscadc: provide datasheet_name and scan_type Sebastian Andrzej Siewior
2013-06-11 11:30 ` [PATCH 13/22] mfd/ti_tscadc: deal with partial activation Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 14/22] arm/am33xx: add TSC/ADC mfd device support Sebastian Andrzej Siewior
[not found] ` <1370950268-7224-15-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-07-04 13:49 ` Sekhar Nori
[not found] ` <51D57D4F.30905-l0cyMroinI0@public.gmane.org>
2013-07-04 13:51 ` Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 15/22] input & mfd: ti_am335x_tsc remove remaining platform data pieces Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 16/22] mfd & input/ti_am335x_tsc: rename device from tsc to TI-am335x-tsc Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 18/22] input/ti_am335x_adc: use only FIFO0 and clean up a little Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 19/22] input/ti_am335x_tsc: ACK the HW_PEN irq in ISR Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 20/22] input/ti_am335x_tsc: return IRQ_NONE if there was no IRQ for us Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 21/22] iio/ti_am335x_adc: Allow to specify input line Sebastian Andrzej Siewior
2013-06-11 11:31 ` [PATCH 22/22] iio/ti_am335x_adc: check if we found the value Sebastian Andrzej Siewior
2013-06-11 14:23 ` am335x: TSC & ADC reworking including DT pieces, take 4 Samuel Ortiz
2013-06-11 15:29 ` Sebastian Andrzej Siewior
[not found] ` <51B74252.5090906-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-11 16:10 ` Samuel Ortiz
2013-06-11 16:18 ` Sebastian Andrzej Siewior
2013-06-14 13:57 ` Mark Brown
2013-06-11 16:04 ` Dmitry Torokhov
[not found] ` <20130611160415.GA379-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2013-06-11 16:15 ` Samuel Ortiz
2013-06-11 16:27 ` Jonathan Cameron
[not found] ` <1565f2fb-7f16-4910-8fa2-cd5700e8986d-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2013-06-11 17:01 ` Lars-Peter Clausen
2013-06-11 17:55 ` Samuel Ortiz
2013-06-12 13:29 ` Sebastian Andrzej Siewior
[not found] ` <51B877C7.8080001-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-12 13:50 ` Samuel Ortiz
2013-06-12 14:02 ` Sebastian Andrzej Siewior
2013-06-12 14:41 ` Samuel Ortiz
2013-06-12 15:00 ` Sebastian Andrzej Siewior
2013-06-11 18:02 ` Jonathan Cameron
-- strict thread matches above, loose matches on Subject: below --
2013-06-05 16:24 AM335x tsc & adc, dt + cleanup take 3 Sebastian Andrzej Siewior
[not found] ` <1370449495-29981-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-05 16:24 ` [PATCH 04/22] input/ti_am33x_tsc: Order of TSC wires, made configurable Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370950268-7224-5-git-send-email-bigeasy@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=b-cousson@ti.com \
--cc=balbi@ti.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jic23@cam.ac.uk \
--cc=lee.jones@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=rachna@ti.com \
--cc=sameo@linux.intel.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).