diff mbox

[3/5] Input: zforce_ts: Add device tree support for scanning frequency

Message ID 1461135285-17582-3-git-send-email-dirk.behme@de.bosch.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dirk Behme April 20, 2016, 6:54 a.m. UTC
From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>

Add device tree support for idle and finger scanning frequency.

Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
---
 .../devicetree/bindings/input/touchscreen/zforce_ts.txt   |  4 ++++
 drivers/input/touchscreen/zforce_ts.c                     | 15 ++++++++++++++-
 include/linux/platform_data/zforce_ts.h                   |  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)

Comments

Dmitry Torokhov April 25, 2016, 9:11 p.m. UTC | #1
Adding devicetree overlords...

On Wed, Apr 20, 2016 at 08:54:43AM +0200, Dirk Behme wrote:
> From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
> 
> Add device tree support for idle and finger scanning frequency.
> 
> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
> ---
>  .../devicetree/bindings/input/touchscreen/zforce_ts.txt   |  4 ++++
>  drivers/input/touchscreen/zforce_ts.c                     | 15 ++++++++++++++-
>  include/linux/platform_data/zforce_ts.h                   |  2 ++
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> index e3c27c4..09ead84 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> @@ -11,6 +11,8 @@ Required properties:
>  Optional properties:
>  - irq-gpios : interrupt gpio the chip is connected to
>  - vdd-supply: Regulator controlling the controller supply
> +- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
> +- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)

Should we cal it scan-freq-active instead?

>  
>  Example:
>  
> @@ -28,6 +30,8 @@ Example:
>  
>  			x-size = <800>;
>  			y-size = <600>;
> +			scan-freq-idle = <50>;
> +			scan-freq-finger = <250>;
>  		};
>  
>  		/* ... */
> diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
> index ddfc120..51fe2de 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -87,6 +87,9 @@
>  
>  #define SETCONFIG_DUALTOUCH		(1 << 0)
>  
> +#define SCAN_FREQ_DEFAULT_IDLE		10
> +#define SCAN_FREQ_DEFAULT_FINGER	50
> +
>  struct zforce_point {
>  	int coord_x;
>  	int coord_y;
> @@ -304,7 +307,9 @@ static int zforce_start(struct zforce_ts *ts)
>  		goto error;
>  	}
>  
> -	ret = zforce_scan_frequency(ts, 10, 50, 50);
> +	ret = zforce_scan_frequency(ts, pdata->scan_freq_idle,
> +				    pdata->scan_freq_finger,
> +				    pdata->scan_freq_finger);
>  	if (ret) {
>  		dev_err(&client->dev, "Unable to set scan frequency, %d\n",
>  			ret);
> @@ -839,6 +844,14 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> +	if (of_property_read_u16(np, "scan-freq-idle",
> +				 &pdata->scan_freq_idle))
> +		pdata->scan_freq_idle = SCAN_FREQ_DEFAULT_IDLE;
> +
> +	if (of_property_read_u16(np, "scan-freq-finger",
> +				 &pdata->scan_freq_finger))
> +		pdata->scan_freq_finger = SCAN_FREQ_DEFAULT_FINGER;
> +
>  	return pdata;
>  }
>  
> diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h
> index 7bdece8..90a1181 100644
> --- a/include/linux/platform_data/zforce_ts.h
> +++ b/include/linux/platform_data/zforce_ts.h
> @@ -18,6 +18,8 @@
>  struct zforce_ts_platdata {
>  	unsigned int x_max;
>  	unsigned int y_max;
> +	u16 scan_freq_idle;
> +	u16 scan_freq_finger;
>  };
>  
>  #endif /* _LINUX_INPUT_ZFORCE_TS_H */
> -- 
> 2.8.0
>
Rob Herring (Arm) April 27, 2016, 2:44 p.m. UTC | #2
On Mon, Apr 25, 2016 at 4:11 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Adding devicetree overlords...
>
> On Wed, Apr 20, 2016 at 08:54:43AM +0200, Dirk Behme wrote:
>> From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>>
>> Add device tree support for idle and finger scanning frequency.
>>
>> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
>> ---
>>  .../devicetree/bindings/input/touchscreen/zforce_ts.txt   |  4 ++++
>>  drivers/input/touchscreen/zforce_ts.c                     | 15 ++++++++++++++-
>>  include/linux/platform_data/zforce_ts.h                   |  2 ++
>>  3 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
>> index e3c27c4..09ead84 100644
>> --- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
>> @@ -11,6 +11,8 @@ Required properties:
>>  Optional properties:
>>  - irq-gpios : interrupt gpio the chip is connected to

BTW, this should really be an "interrupts" property

>>  - vdd-supply: Regulator controlling the controller supply
>> +- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
>> +- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)

I use my toes for touchscreens.

Can you really scan at 65kHz?

a typo here as well.

> Should we cal it scan-freq-active instead?

Don't we have a standard property for this?  These should really have
-hz appended. So scan-idle-hz and scan-active-hz, but at least the
active case should be common IMO. Idle scan seems a bit unusual unless
you don't have an interrupt.

Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
index e3c27c4..09ead84 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
@@ -11,6 +11,8 @@  Required properties:
 Optional properties:
 - irq-gpios : interrupt gpio the chip is connected to
 - vdd-supply: Regulator controlling the controller supply
+- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
+- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
 
 Example:
 
@@ -28,6 +30,8 @@  Example:
 
 			x-size = <800>;
 			y-size = <600>;
+			scan-freq-idle = <50>;
+			scan-freq-finger = <250>;
 		};
 
 		/* ... */
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index ddfc120..51fe2de 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -87,6 +87,9 @@ 
 
 #define SETCONFIG_DUALTOUCH		(1 << 0)
 
+#define SCAN_FREQ_DEFAULT_IDLE		10
+#define SCAN_FREQ_DEFAULT_FINGER	50
+
 struct zforce_point {
 	int coord_x;
 	int coord_y;
@@ -304,7 +307,9 @@  static int zforce_start(struct zforce_ts *ts)
 		goto error;
 	}
 
-	ret = zforce_scan_frequency(ts, 10, 50, 50);
+	ret = zforce_scan_frequency(ts, pdata->scan_freq_idle,
+				    pdata->scan_freq_finger,
+				    pdata->scan_freq_finger);
 	if (ret) {
 		dev_err(&client->dev, "Unable to set scan frequency, %d\n",
 			ret);
@@ -839,6 +844,14 @@  static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
 		return ERR_PTR(-EINVAL);
 	}
 
+	if (of_property_read_u16(np, "scan-freq-idle",
+				 &pdata->scan_freq_idle))
+		pdata->scan_freq_idle = SCAN_FREQ_DEFAULT_IDLE;
+
+	if (of_property_read_u16(np, "scan-freq-finger",
+				 &pdata->scan_freq_finger))
+		pdata->scan_freq_finger = SCAN_FREQ_DEFAULT_FINGER;
+
 	return pdata;
 }
 
diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h
index 7bdece8..90a1181 100644
--- a/include/linux/platform_data/zforce_ts.h
+++ b/include/linux/platform_data/zforce_ts.h
@@ -18,6 +18,8 @@ 
 struct zforce_ts_platdata {
 	unsigned int x_max;
 	unsigned int y_max;
+	u16 scan_freq_idle;
+	u16 scan_freq_finger;
 };
 
 #endif /* _LINUX_INPUT_ZFORCE_TS_H */