diff mbox

[v3,3/3] Input: cyttsp - add default init function

Message ID 01aa2661875444ecc771dfce1f466b6846ac5eea.1452447124.git.oreste.salerno@tomtom.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Oreste Salerno Jan. 10, 2016, 5:36 p.m. UTC
When using device trees, it's not possible to assign an init()
function in the platform data.
In case the init function has not been assigned, attempt to
perform a hard reset of the chip, using reset gpio defined in the
platform data / device tree.

Signed-off-by: Oreste Salerno <oreste.salerno@tomtom.com>
---
 drivers/input/touchscreen/cyttsp_core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Dmitry Torokhov Jan. 11, 2016, 8:02 p.m. UTC | #1
On Sun, Jan 10, 2016 at 06:36:09PM +0100, Oreste Salerno wrote:
> When using device trees, it's not possible to assign an init()
> function in the platform data.
> In case the init function has not been assigned, attempt to
> perform a hard reset of the chip, using reset gpio defined in the
> platform data / device tree.

Hmm, I do not see any users of cyttsp platform data in mainline, so
let's kill init/exit and just do GPIO toggle for everyone. We might need
to add regulator support as well, but that's when someone will need it.

Thanks.

> 
> Signed-off-by: Oreste Salerno <oreste.salerno@tomtom.com>
> ---
>  drivers/input/touchscreen/cyttsp_core.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
> index 5dc6bf6..baf0fd5 100644
> --- a/drivers/input/touchscreen/cyttsp_core.c
> +++ b/drivers/input/touchscreen/cyttsp_core.c
> @@ -239,6 +239,16 @@ static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
>  	return retval;
>  }
>  
> +static void cyttsp_hard_reset(struct cyttsp *ts)
> +{
> +	if (ts->pdata->reset_gpio) {
> +		gpiod_set_value_cansleep(ts->pdata->reset_gpio, 1);
> +		msleep(CY_DELAY_DFLT);
> +		gpiod_set_value_cansleep(ts->pdata->reset_gpio, 0);
> +		msleep(CY_DELAY_DFLT);
> +	}
> +}
> +
>  static int cyttsp_soft_reset(struct cyttsp *ts)
>  {
>  	unsigned long timeout;
> @@ -685,6 +695,8 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
>  				error);
>  			goto err_free_mem;
>  		}
> +	} else {
> +		cyttsp_hard_reset(ts);
>  	}
>  
>  	input_dev->name = pdata->name;
> -- 
> 1.9.1
>
diff mbox

Patch

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 5dc6bf6..baf0fd5 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -239,6 +239,16 @@  static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
 	return retval;
 }
 
+static void cyttsp_hard_reset(struct cyttsp *ts)
+{
+	if (ts->pdata->reset_gpio) {
+		gpiod_set_value_cansleep(ts->pdata->reset_gpio, 1);
+		msleep(CY_DELAY_DFLT);
+		gpiod_set_value_cansleep(ts->pdata->reset_gpio, 0);
+		msleep(CY_DELAY_DFLT);
+	}
+}
+
 static int cyttsp_soft_reset(struct cyttsp *ts)
 {
 	unsigned long timeout;
@@ -685,6 +695,8 @@  struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 				error);
 			goto err_free_mem;
 		}
+	} else {
+		cyttsp_hard_reset(ts);
 	}
 
 	input_dev->name = pdata->name;