* [PATCH] input/mc13783-ts: add pdata to set conversion delay
@ 2012-01-11 8:18 Michael Thalmeier
2012-01-11 8:36 ` Uwe Kleine-König
2012-02-20 11:13 ` Samuel Ortiz
0 siblings, 2 replies; 4+ messages in thread
From: Michael Thalmeier @ 2012-01-11 8:18 UTC (permalink / raw)
To: Dmitry Torokhov, Samuel Ortiz, Uwe Kleine-König
Cc: Michael Thalmeier, linux-kernel, linux-input, michael
MC13783 can be programmed to wait some clock cycles between the touch screen
polarization and the resistance conversion. This is needed to adjust for
touchscreens with high capacitance between plates.
Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
---
drivers/hwmon/mc13783-adc.c | 2 +-
drivers/input/touchscreen/mc13783_ts.c | 6 +++++-
drivers/mfd/mc13xxx-core.c | 11 +++++++++--
include/linux/mfd/mc13xxx.h | 16 +++++++++++++++-
4 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/mc13783-adc.c b/drivers/hwmon/mc13783-adc.c
index ef65ab5..6acd044 100644
--- a/drivers/hwmon/mc13783-adc.c
+++ b/drivers/hwmon/mc13783-adc.c
@@ -53,7 +53,7 @@ static int mc13783_adc_read(struct device *dev,
ret = mc13xxx_adc_do_conversion(priv->mc13xxx,
MC13XXX_ADC_MODE_MULT_CHAN,
- channel, sample);
+ channel, 0, 0, sample);
if (ret)
return ret;
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index 68f86f7..d71f45a 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -39,6 +39,7 @@ struct mc13783_ts_priv {
struct delayed_work work;
struct workqueue_struct *workq;
unsigned int sample[4];
+ struct mc13xxx_ts_platform_data *touch;
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -125,7 +126,9 @@ static void mc13783_ts_work(struct work_struct *work)
unsigned int channel = 12;
if (mc13xxx_adc_do_conversion(priv->mc13xxx,
- mode, channel, priv->sample) == 0)
+ mode, channel,
+ priv->touch->ato, priv->touch->atox,
+ priv->sample) == 0)
mc13783_ts_report_sample(priv);
}
@@ -179,6 +182,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
+ priv->touch = dev_get_platdata(&pdev->dev);
/*
* We need separate workqueue because mc13783_adc_do_conversion
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index e9619ac..222d947 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -559,6 +559,8 @@ EXPORT_SYMBOL(mc13xxx_get_flags);
#define MC13XXX_ADC1_CHAN0_SHIFT 5
#define MC13XXX_ADC1_CHAN1_SHIFT 8
+#define MC13783_ADC1_ATO_SHIFT 11
+#define MC13783_ADC1_ATOX (1 << 19)
struct mc13xxx_adcdone_data {
struct mc13xxx *mc13xxx;
@@ -579,7 +581,8 @@ static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data)
#define MC13XXX_ADC_WORKING (1 << 0)
int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
- unsigned int channel, unsigned int *sample)
+ unsigned int channel, char ato, char atox,
+ unsigned int *sample)
{
u32 adc0, adc1, old_adc0;
int i, ret;
@@ -630,6 +633,9 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
return -EINVAL;
}
+ adc1 |= ato << MC13783_ADC1_ATO_SHIFT;
+ if (atox)
+ adc1 |= MC13783_ADC1_ATOX;
dev_dbg(&mc13xxx->spidev->dev, "%s: request irq\n", __func__);
mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE,
mc13xxx_handler_adcdone, __func__, &adcdone_data);
@@ -762,7 +768,8 @@ err_revision:
mc13xxx_add_subdevice(mc13xxx, "%s-rtc");
if (pdata->flags & MC13XXX_USE_TOUCHSCREEN)
- mc13xxx_add_subdevice(mc13xxx, "%s-ts");
+ mc13xxx_add_subdevice_pdata(mc13xxx, "%s-ts",
+ &pdata->touch, sizeof(pdata->touch));
if (pdata->leds)
mc13xxx_add_subdevice_pdata(mc13xxx, "%s-led",
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index a98e2a3..01a3fa1 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -38,7 +38,8 @@ int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
- unsigned int mode, unsigned int channel, unsigned int *sample);
+ unsigned int mode, unsigned int channel,
+ char ato, char atox, unsigned int *sample);
#define MC13XXX_IRQ_ADCDONE 0
#define MC13XXX_IRQ_ADCBISDONE 1
@@ -157,6 +158,18 @@ struct mc13xxx_buttons_platform_data {
unsigned short b3on_key;
};
+struct mc13xxx_ts_platform_data {
+ /* Delay between Touchscreen polarization and ADC Conversion.
+ * Given in clock ticks of a 32 kHz clock which gives a granularity of
+ * about 30.5ms */
+ char ato;
+
+#define MC13783_TS_ATO_FIRST 0
+#define MC13783_TS_ATO_EACH 1
+ /* Use the ATO delay only for the first conversion or for each one */
+ char atox;
+};
+
struct mc13xxx_platform_data {
#define MC13XXX_USE_TOUCHSCREEN (1 << 0)
#define MC13XXX_USE_CODEC (1 << 1)
@@ -167,6 +180,7 @@ struct mc13xxx_platform_data {
struct mc13xxx_regulator_platform_data regulators;
struct mc13xxx_leds_platform_data *leds;
struct mc13xxx_buttons_platform_data *buttons;
+ struct mc13xxx_ts_platform_data touch;
};
#define MC13XXX_ADC_MODE_TS 1
--
1.7.7.5
--
Scanned by MailScanner.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] input/mc13783-ts: add pdata to set conversion delay
2012-01-11 8:18 [PATCH] input/mc13783-ts: add pdata to set conversion delay Michael Thalmeier
@ 2012-01-11 8:36 ` Uwe Kleine-König
2012-02-20 11:13 ` Samuel Ortiz
1 sibling, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2012-01-11 8:36 UTC (permalink / raw)
To: Michael Thalmeier
Cc: Dmitry Torokhov, Samuel Ortiz, linux-kernel, linux-input, michael
Hello Michael,
On Wed, Jan 11, 2012 at 09:18:23AM +0100, Michael Thalmeier wrote:
> MC13783 can be programmed to wait some clock cycles between the touch screen
> polarization and the resistance conversion. This is needed to adjust for
> touchscreens with high capacitance between plates.
>
> Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
> ---
> drivers/hwmon/mc13783-adc.c | 2 +-
> drivers/input/touchscreen/mc13783_ts.c | 6 +++++-
> drivers/mfd/mc13xxx-core.c | 11 +++++++++--
> include/linux/mfd/mc13xxx.h | 16 +++++++++++++++-
> 4 files changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/mc13783-adc.c b/drivers/hwmon/mc13783-adc.c
> index ef65ab5..6acd044 100644
> --- a/drivers/hwmon/mc13783-adc.c
> +++ b/drivers/hwmon/mc13783-adc.c
> @@ -53,7 +53,7 @@ static int mc13783_adc_read(struct device *dev,
>
> ret = mc13xxx_adc_do_conversion(priv->mc13xxx,
> MC13XXX_ADC_MODE_MULT_CHAN,
> - channel, sample);
> + channel, 0, 0, sample);
> if (ret)
> return ret;
>
> diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
> index 68f86f7..d71f45a 100644
> --- a/drivers/input/touchscreen/mc13783_ts.c
> +++ b/drivers/input/touchscreen/mc13783_ts.c
> @@ -39,6 +39,7 @@ struct mc13783_ts_priv {
> struct delayed_work work;
> struct workqueue_struct *workq;
> unsigned int sample[4];
> + struct mc13xxx_ts_platform_data *touch;
> };
>
> static irqreturn_t mc13783_ts_handler(int irq, void *data)
> @@ -125,7 +126,9 @@ static void mc13783_ts_work(struct work_struct *work)
> unsigned int channel = 12;
>
> if (mc13xxx_adc_do_conversion(priv->mc13xxx,
> - mode, channel, priv->sample) == 0)
> + mode, channel,
> + priv->touch->ato, priv->touch->atox,
> + priv->sample) == 0)
> mc13783_ts_report_sample(priv);
> }
>
> @@ -179,6 +182,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
> INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
> priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
> priv->idev = idev;
> + priv->touch = dev_get_platdata(&pdev->dev);
This cannot fail in practice unless the device isn't created via
mc13xxx_probe. Still it would feel a tad better to have error detection
here or at least a comment saying why it doesn't fail.
Other than that:
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] input/mc13783-ts: add pdata to set conversion delay
2012-01-11 8:18 [PATCH] input/mc13783-ts: add pdata to set conversion delay Michael Thalmeier
2012-01-11 8:36 ` Uwe Kleine-König
@ 2012-02-20 11:13 ` Samuel Ortiz
2012-02-20 11:20 ` Samuel Ortiz
1 sibling, 1 reply; 4+ messages in thread
From: Samuel Ortiz @ 2012-02-20 11:13 UTC (permalink / raw)
To: Michael Thalmeier
Cc: Dmitry Torokhov, Uwe Kleine-König, linux-kernel,
linux-input, michael
Hi Michael,
On Wed, Jan 11, 2012 at 09:18:23AM +0100, Michael Thalmeier wrote:
> MC13783 can be programmed to wait some clock cycles between the touch screen
> polarization and the resistance conversion. This is needed to adjust for
> touchscreens with high capacitance between plates.
I applied (manually) this one to my for-next branch, thanks.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] input/mc13783-ts: add pdata to set conversion delay
2012-02-20 11:13 ` Samuel Ortiz
@ 2012-02-20 11:20 ` Samuel Ortiz
0 siblings, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2012-02-20 11:20 UTC (permalink / raw)
To: Michael Thalmeier
Cc: Dmitry Torokhov, Uwe Kleine-König, linux-kernel,
linux-input, michael
On Mon, Feb 20, 2012 at 12:13:26PM +0100, Samuel Ortiz wrote:
> Hi Michael,
>
> On Wed, Jan 11, 2012 at 09:18:23AM +0100, Michael Thalmeier wrote:
> > MC13783 can be programmed to wait some clock cycles between the touch screen
> > polarization and the resistance conversion. This is needed to adjust for
> > touchscreens with high capacitance between plates.
> I applied (manually) this one to my for-next branch, thanks.
I actually applied v3.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-20 11:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-11 8:18 [PATCH] input/mc13783-ts: add pdata to set conversion delay Michael Thalmeier
2012-01-11 8:36 ` Uwe Kleine-König
2012-02-20 11:13 ` Samuel Ortiz
2012-02-20 11:20 ` Samuel Ortiz
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).