* [PATCH] Input: da9052_tsi: make TSI reference regulator configurable
@ 2013-03-22 14:55 Philipp Zabel
2013-03-22 15:51 ` Fabio Estevam
0 siblings, 1 reply; 4+ messages in thread
From: Philipp Zabel @ 2013-03-22 14:55 UTC (permalink / raw)
To: linux-input, devicetree-discuss
Cc: Dmitry Torokhov, Fabio Estevam, Ashish Jangam, Philipp Zabel
This patch allows to use a different regulator than LDO9 as TSIREF.
It also only turns on the regulator when there are actual measurements
to be done. It is not needed for pen detection.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
.../devicetree/bindings/mfd/da9052-i2c.txt | 10 ++++++
drivers/input/touchscreen/da9052_tsi.c | 38 +++++++++++++++++-----
2 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
index 1857f4a..807eb63 100644
--- a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
+++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
@@ -4,6 +4,10 @@ Required properties:
- compatible : Should be "dlg,da9052", "dlg,da9053-aa",
"dlg,da9053-ab", or "dlg,da9053-bb"
+Optional properties:
+- tsiref-supply : Touch screen interface reference voltage regulator.
+ This is usually LDO9.
+
Sub-nodes:
- regulators : Contain the regulator nodes. The DA9052/53 regulators are
bound using their names as listed below:
@@ -34,6 +38,7 @@ i2c@63fc8000 { /* I2C1 */
pmic: dialog@48 {
compatible = "dlg,da9053-aa";
reg = <0x48>;
+ tsiref-supply = <®_ldo9>;
regulators {
buck0 {
@@ -55,6 +60,11 @@ i2c@63fc8000 { /* I2C1 */
regulator-min-microvolt = <925000>;
regulator-max-microvolt = <2500000>;
};
+
+ reg_ldo9: ldo9 {
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <3300000>;
+ };
};
};
};
diff --git a/drivers/input/touchscreen/da9052_tsi.c b/drivers/input/touchscreen/da9052_tsi.c
index 8f561e2..1eb323f 100644
--- a/drivers/input/touchscreen/da9052_tsi.c
+++ b/drivers/input/touchscreen/da9052_tsi.c
@@ -11,10 +11,12 @@
* option) any later version.
*
*/
+#include <linux/errno.h>
#include <linux/module.h>
#include <linux/input.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
#include <linux/interrupt.h>
#include <linux/mfd/da9052/reg.h>
@@ -25,6 +27,7 @@
struct da9052_tsi {
struct da9052 *da9052;
struct input_dev *dev;
+ struct regulator *tsiref;
struct delayed_work ts_pen_work;
struct mutex mutex;
bool stopped;
@@ -40,8 +43,17 @@ static void da9052_ts_adc_toggle(struct da9052_tsi *tsi, bool on)
static irqreturn_t da9052_ts_pendwn_irq(int irq, void *data)
{
struct da9052_tsi *tsi = data;
+ int error;
if (!tsi->stopped) {
+ error = regulator_enable(tsi->tsiref);
+ if (error < 0) {
+ dev_err(tsi->da9052->dev,
+ "Failed to enable TSIREF regualtor: %d\n",
+ error);
+ return IRQ_HANDLED;
+ }
+
/* Mask PEN_DOWN event and unmask TSI_READY event */
da9052_disable_irq_nosync(tsi->da9052, DA9052_IRQ_PENDOWN);
da9052_enable_irq(tsi->da9052, DA9052_IRQ_TSIREADY);
@@ -137,6 +149,12 @@ static void da9052_ts_pen_work(struct work_struct *work)
/* Mask TSI_READY event and unmask PEN_DOWN event */
da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY);
da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN);
+
+ ret = regulator_disable(tsi->tsiref);
+ if (ret < 0)
+ dev_err(tsi->da9052->dev,
+ "Failed to disable TSIREF regulator: %d\n",
+ ret);
}
}
}
@@ -179,11 +197,6 @@ static int da9052_configure_tsi(struct da9052_tsi *tsi)
if (error < 0)
return error;
- /* Supply TSIRef through LD09 */
- error = da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x59);
- if (error < 0)
- return error;
-
return 0;
}
@@ -274,12 +287,20 @@ static int da9052_ts_probe(struct platform_device *pdev)
/* Disable ADC */
da9052_ts_adc_toggle(tsi, false);
+ tsi->tsiref = regulator_get(tsi->da9052->dev, "tsiref");
+ if (IS_ERR(tsi->tsiref)) {
+ dev_err(tsi->da9052->dev,
+ "Failed to get TSIREF regulator: %ld\n",
+ PTR_ERR(tsi->tsiref));
+ goto err_free_mem;
+ }
+
error = da9052_request_irq(tsi->da9052, DA9052_IRQ_PENDOWN,
"pendown-irq", da9052_ts_pendwn_irq, tsi);
if (error) {
dev_err(tsi->da9052->dev,
"Failed to register PENDWN IRQ: %d\n", error);
- goto err_free_mem;
+ goto err_put_reg;
}
error = da9052_request_irq(tsi->da9052, DA9052_IRQ_TSIREADY,
@@ -310,6 +331,8 @@ err_free_datardy_irq:
da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
err_free_pendwn_irq:
da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
+err_put_reg:
+ regulator_put(tsi->tsiref);
err_free_mem:
kfree(tsi);
input_free_device(input_dev);
@@ -321,10 +344,9 @@ static int da9052_ts_remove(struct platform_device *pdev)
{
struct da9052_tsi *tsi = platform_get_drvdata(pdev);
- da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19);
-
da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
+ regulator_put(tsi->tsiref);
input_unregister_device(tsi->dev);
kfree(tsi);
--
1.8.2.rc2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: da9052_tsi: make TSI reference regulator configurable
2013-03-22 14:55 [PATCH] Input: da9052_tsi: make TSI reference regulator configurable Philipp Zabel
@ 2013-03-22 15:51 ` Fabio Estevam
2013-03-22 15:55 ` Philipp Zabel
[not found] ` <514C7DFB.8000708-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
0 siblings, 2 replies; 4+ messages in thread
From: Fabio Estevam @ 2013-03-22 15:51 UTC (permalink / raw)
To: Philipp Zabel
Cc: linux-input, devicetree-discuss, Dmitry Torokhov, festevam,
Ashish Jangam
Philipp Zabel wrote:
> if (!tsi->stopped) {
> + error = regulator_enable(tsi->tsiref);
> + if (error < 0) {
> + dev_err(tsi->da9052->dev,
> + "Failed to enable TSIREF regualtor: %d\n",
s/regualtor/regulator
> @@ -274,12 +287,20 @@ static int da9052_ts_probe(struct platform_device *pdev)
> /* Disable ADC */
> da9052_ts_adc_toggle(tsi, false);
>
> + tsi->tsiref = regulator_get(tsi->da9052->dev, "tsiref");
You could use devm_regulator_get here ...
> + if (IS_ERR(tsi->tsiref)) {
> + dev_err(tsi->da9052->dev,
> + "Failed to get TSIREF regulator: %ld\n",
> + PTR_ERR(tsi->tsiref));
> + goto err_free_mem;
> + }
> +
> error = da9052_request_irq(tsi->da9052, DA9052_IRQ_PENDOWN,
> "pendown-irq", da9052_ts_pendwn_irq, tsi);
> if (error) {
> dev_err(tsi->da9052->dev,
> "Failed to register PENDWN IRQ: %d\n", error);
> - goto err_free_mem;
> + goto err_put_reg;
> }
>
> error = da9052_request_irq(tsi->da9052, DA9052_IRQ_TSIREADY,
> @@ -310,6 +331,8 @@ err_free_datardy_irq:
> da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
> err_free_pendwn_irq:
> da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
> +err_put_reg:
> + regulator_put(tsi->tsiref);
> err_free_mem:
> kfree(tsi);
> input_free_device(input_dev);
> @@ -321,10 +344,9 @@ static int da9052_ts_remove(struct platform_device *pdev)
> {
> struct da9052_tsi *tsi = platform_get_drvdata(pdev);
>
> - da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19);
> -
> da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
> da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
> + regulator_put(tsi->tsiref);
and then no need to use the regulator_put.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: da9052_tsi: make TSI reference regulator configurable
2013-03-22 15:51 ` Fabio Estevam
@ 2013-03-22 15:55 ` Philipp Zabel
[not found] ` <514C7DFB.8000708-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
1 sibling, 0 replies; 4+ messages in thread
From: Philipp Zabel @ 2013-03-22 15:55 UTC (permalink / raw)
To: Fabio Estevam
Cc: linux-input, devicetree-discuss, Dmitry Torokhov, festevam,
Ashish Jangam
Hi Fabio,
thank you for the comments.
Am Freitag, den 22.03.2013, 12:51 -0300 schrieb Fabio Estevam:
> Philipp Zabel wrote:
>
> > if (!tsi->stopped) {
> > + error = regulator_enable(tsi->tsiref);
> > + if (error < 0) {
> > + dev_err(tsi->da9052->dev,
> > + "Failed to enable TSIREF regualtor: %d\n",
>
> s/regualtor/regulator
I'll correct that.
> > @@ -274,12 +287,20 @@ static int da9052_ts_probe(struct platform_device *pdev)
> > /* Disable ADC */
> > da9052_ts_adc_toggle(tsi, false);
> >
> > + tsi->tsiref = regulator_get(tsi->da9052->dev, "tsiref");
>
> You could use devm_regulator_get here ...
I chose not to use devm_... because tsi->da9052->dev is not pdev->dev
here, but thinking about it, no harm will be done if regulator_put is
only called by the parent device's remove function. I'll switch to
devm_regulator_get if nobody minds.
> > + if (IS_ERR(tsi->tsiref)) {
> > + dev_err(tsi->da9052->dev,
> > + "Failed to get TSIREF regulator: %ld\n",
> > + PTR_ERR(tsi->tsiref));
> > + goto err_free_mem;
> > + }
> > +
> > error = da9052_request_irq(tsi->da9052, DA9052_IRQ_PENDOWN,
> > "pendown-irq", da9052_ts_pendwn_irq, tsi);
> > if (error) {
> > dev_err(tsi->da9052->dev,
> > "Failed to register PENDWN IRQ: %d\n", error);
> > - goto err_free_mem;
> > + goto err_put_reg;
> > }
> >
> > error = da9052_request_irq(tsi->da9052, DA9052_IRQ_TSIREADY,
> > @@ -310,6 +331,8 @@ err_free_datardy_irq:
> > da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
> > err_free_pendwn_irq:
> > da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
> > +err_put_reg:
> > + regulator_put(tsi->tsiref);
> > err_free_mem:
> > kfree(tsi);
> > input_free_device(input_dev);
> > @@ -321,10 +344,9 @@ static int da9052_ts_remove(struct platform_device *pdev)
> > {
> > struct da9052_tsi *tsi = platform_get_drvdata(pdev);
> >
> > - da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19);
> > -
> > da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
> > da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
> > + regulator_put(tsi->tsiref);
>
> and then no need to use the regulator_put.
regards
Philipp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: da9052_tsi: make TSI reference regulator configurable
[not found] ` <514C7DFB.8000708-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2013-03-22 15:58 ` Dmitry Torokhov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2013-03-22 15:58 UTC (permalink / raw)
To: Fabio Estevam
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
festevam-Re5JQEeQqe8AvxtiuMwx3w, Ashish Jangam, Philipp Zabel,
linux-input-u79uwXL29TY76Z2rM5mHXA
On Friday, March 22, 2013 12:51:23 PM Fabio Estevam wrote:
> Philipp Zabel wrote:
> > if (!tsi->stopped) {
> >
> > + error = regulator_enable(tsi->tsiref);
> > + if (error < 0) {
> > + dev_err(tsi->da9052->dev,
> > + "Failed to enable TSIREF regualtor: %d\n",
>
> s/regualtor/regulator
>
> > @@ -274,12 +287,20 @@ static int da9052_ts_probe(struct platform_device
> > *pdev)>
> > /* Disable ADC */
> > da9052_ts_adc_toggle(tsi, false);
> >
> > + tsi->tsiref = regulator_get(tsi->da9052->dev, "tsiref");
>
> You could use devm_regulator_get here ...
The rest of the driver does not use managed resources. Mixing styles is not
the best idea.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-22 15:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-22 14:55 [PATCH] Input: da9052_tsi: make TSI reference regulator configurable Philipp Zabel
2013-03-22 15:51 ` Fabio Estevam
2013-03-22 15:55 ` Philipp Zabel
[not found] ` <514C7DFB.8000708-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-03-22 15:58 ` Dmitry Torokhov
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).