diff mbox

[v2,2/3] Input: ti_am335x_tsc: Add support for ti,charge-delay-ns

Message ID 20161111075819.5760-1-mugunthanvnm@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mugunthan V N Nov. 11, 2016, 7:58 a.m. UTC
ti,charge-delay will be deprecated as it represents number of
clock cycles and the DT entries are done in assumption of 3MHz
TSCADC clock, but clock can be set upto 24MHz. So driver add
support for ti,charge-delay-ns and do not drop support for
ti,charge-delay to support old dtbs and it will be assumed that
it is for 3MHz TSCADC clock and will be calculated as per current
clock speed.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 drivers/input/touchscreen/ti_am335x_tsc.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

Comments

Dmitry Torokhov Nov. 29, 2016, 9:09 p.m. UTC | #1
On Fri, Nov 11, 2016 at 01:28:19PM +0530, Mugunthan V N wrote:
> ti,charge-delay will be deprecated as it represents number of
> clock cycles and the DT entries are done in assumption of 3MHz
> TSCADC clock, but clock can be set upto 24MHz. So driver add
> support for ti,charge-delay-ns and do not drop support for
> ti,charge-delay to support old dtbs and it will be assumed that
> it is for 3MHz TSCADC clock and will be calculated as per current
> clock speed.
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/input/touchscreen/ti_am335x_tsc.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index 7953381d939a..104b3640f728 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -379,15 +379,30 @@ static int titsc_parse_dt(struct platform_device *pdev,
>  		ts_dev->coordinate_readouts = 5;
>  	}
>  
> -	err = of_property_read_u32(node, "ti,charge-delay",
> +	err = of_property_read_u32(node, "ti,charge-delay-ns",
>  				   &ts_dev->charge_delay);
> -	/*
> -	 * If ti,charge-delay value is not specified, then use
> -	 * CHARGEDLY_OPENDLY as the default value.
> -	 */
> -	if (err < 0) {
> -		ts_dev->charge_delay = CHARGEDLY_OPENDLY;
> -		dev_warn(&pdev->dev, "ti,charge-delay not specified\n");
> +	if (err >= 0) {
> +		u64 charge_delay = ts_dev->charge_delay;
> +
> +		charge_delay *= ADC_CLK;
> +		do_div(charge_delay, 1E9);
> +		ts_dev->charge_delay = (u32)charge_delay;
> +	} else {
> +		err = of_property_read_u32(node, "ti,charge-delay",
> +					   &ts_dev->charge_delay);
> +		/*
> +		 * If ti,charge-delay value is not specified, then use
> +		 * CHARGEDLY_OPENDLY as the default value.
> +		 */
> +		if (err < 0) {
> +			ts_dev->charge_delay = CHARGEDLY_OPENDLY;
> +			dev_warn(&pdev->dev, "ti,charge-delay not specified\n");
> +		}
> +		/*
> +		 * ti,charge-delay is specified with referrence to 3MHz,
> +		 * so convert it to in referrence to current clock
> +		 */
> +		ts_dev->charge_delay *= ADC_CLK / 3000000;
>  	}
>  
>  	return of_property_read_u32_array(node, "ti,wire-config",
> -- 
> 2.11.0.rc0.7.gbe5a750
>
diff mbox

Patch

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 7953381d939a..104b3640f728 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -379,15 +379,30 @@  static int titsc_parse_dt(struct platform_device *pdev,
 		ts_dev->coordinate_readouts = 5;
 	}
 
-	err = of_property_read_u32(node, "ti,charge-delay",
+	err = of_property_read_u32(node, "ti,charge-delay-ns",
 				   &ts_dev->charge_delay);
-	/*
-	 * If ti,charge-delay value is not specified, then use
-	 * CHARGEDLY_OPENDLY as the default value.
-	 */
-	if (err < 0) {
-		ts_dev->charge_delay = CHARGEDLY_OPENDLY;
-		dev_warn(&pdev->dev, "ti,charge-delay not specified\n");
+	if (err >= 0) {
+		u64 charge_delay = ts_dev->charge_delay;
+
+		charge_delay *= ADC_CLK;
+		do_div(charge_delay, 1E9);
+		ts_dev->charge_delay = (u32)charge_delay;
+	} else {
+		err = of_property_read_u32(node, "ti,charge-delay",
+					   &ts_dev->charge_delay);
+		/*
+		 * If ti,charge-delay value is not specified, then use
+		 * CHARGEDLY_OPENDLY as the default value.
+		 */
+		if (err < 0) {
+			ts_dev->charge_delay = CHARGEDLY_OPENDLY;
+			dev_warn(&pdev->dev, "ti,charge-delay not specified\n");
+		}
+		/*
+		 * ti,charge-delay is specified with referrence to 3MHz,
+		 * so convert it to in referrence to current clock
+		 */
+		ts_dev->charge_delay *= ADC_CLK / 3000000;
 	}
 
 	return of_property_read_u32_array(node, "ti,wire-config",