From patchwork Sat May 4 11:12:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vishwanathrao Badarkhe, Manish" X-Patchwork-Id: 2520521 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork1.kernel.org (Postfix) with ESMTP id 1CA663FD1A for ; Sat, 4 May 2013 11:13:18 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r44BBB1H015755; Sat, 4 May 2013 06:11:11 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r44BBBRJ011553; Sat, 4 May 2013 06:11:11 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Sat, 4 May 2013 06:11:10 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r44BBB62002932; Sat, 4 May 2013 06:11:11 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 1175080627; Sat, 4 May 2013 06:11:11 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflxv15.itg.ti.com (dflxv15.itg.ti.com [128.247.5.124]) by linux.omap.com (Postfix) with ESMTP id 759F980626 for ; Sat, 4 May 2013 06:11:09 -0500 (CDT) Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r44BB9VM011459; Sat, 4 May 2013 06:11:09 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Sat, 4 May 2013 06:11:09 -0500 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with SMTP id r44BB51B002799; Sat, 4 May 2013 06:11:06 -0500 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id BE273158003; Sat, 4 May 2013 16:41:01 +0530 (IST) Received: from ubuntu-psp-linux.india.ext.ti.com (ubuntu-psp-linux [192.168.247.46]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r44BB1R11898; Sat, 4 May 2013 16:41:01 +0530 (IST) From: "Vishwanathrao Badarkhe, Manish" To: , , , , Subject: [PATCH V2 1/2] tps6507x-ts: Add DT support Date: Sat, 4 May 2013 16:42:30 +0530 Message-ID: <1367665951-29848-2-git-send-email-manishv.b@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1367665951-29848-1-git-send-email-manishv.b@ti.com> References: <1367665951-29848-1-git-send-email-manishv.b@ti.com> MIME-Version: 1.0 CC: , , , X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Add device tree based support for TI's tps6507x touchscreen. Tested on da850-evm. Signed-off-by: Vishwanathrao Badarkhe, Manish --- Changes since V1: - Updated documetation to specify tps6507x as multifunctional device. - return proper error value in absence of platform and DT data for touchscreen. - Updated commit message. :100755 100755 8fffa3c... cf8960c... M Documentation/devicetree/bindings/mfd/tps6507x.txt :100644 100644 65e0f9a... d5433d0... M drivers/input/touchscreen/tps6507x-ts.c Documentation/devicetree/bindings/mfd/tps6507x.txt | 28 +++++- drivers/input/touchscreen/tps6507x-ts.c | 105 ++++++++++++++------ 2 files changed, 102 insertions(+), 31 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/tps6507x.txt b/Documentation/devicetree/bindings/mfd/tps6507x.txt index 8fffa3c..cf8960c 100755 --- a/Documentation/devicetree/bindings/mfd/tps6507x.txt +++ b/Documentation/devicetree/bindings/mfd/tps6507x.txt @@ -1,4 +1,8 @@ -TPS6507x Power Management Integrated Circuit +TPS6507x Multifunctional Device. + +Features provided by TPS6507x: + 1.Power Management Integrated Circuit. + 2.Touch-Screen. Required properties: - compatible: "ti,tps6507x" @@ -23,6 +27,12 @@ Required properties: vindcdc1_2-supply: VDCDC1 and VDCDC2 input. vindcdc3-supply : VDCDC3 input. vldo1_2-supply : VLDO1 and VLDO2 input. +- tsc: This node specifies touch screen data. + ti,poll_period : Time at which touch input is getting sampled in ms. + ti,min_pressure: Minimum pressure value to trigger touch. + ti,vref : voltage reference for ADC. + 0: Reference voltage for ADC is disabled. + 1: Reference voltage for ADC is enabled. Regulator Optional properties: - defdcdc_default: It's property of DCDC2 and DCDC3 regulators. @@ -30,6 +40,14 @@ Regulator Optional properties: 1: If defdcdc pin of DCDC2/DCDC3 is driven HIGH. If this property is not defined, it defaults to 0 (not enabled). +Touchscreen Optional properties: +- ti,vendor : Touchscreen vendor id to poppulate + in sysclass interface. +- ti,product: Touchscreen product id to poppulate + in sysclass interface. +- ti,version: Touchscreen version id to poppulate + in sysclass interface. + Example: pmu: tps6507x@48 { @@ -88,4 +106,12 @@ Example: }; }; + tsc { + ti,poll_period = <30>; + ti,min_pressure = <0x30>; + ti,vref = <0>; + ti,vendor = <0>; + ti,product = <65070>; + ti,version = <0x100>; + }; }; diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index 65e0f9a..d5433d0 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #define TSC_DEFAULT_POLL_PERIOD 30 /* ms */ #define TPS_DEFAULT_MIN_PRESSURE 0x30 @@ -231,36 +233,83 @@ done: ret = tps6507x_adc_standby(tsc); } +static int tsc_init_data(struct tps6507x_dev *tps6507x_dev, + struct input_dev *input_dev) +{ + struct device_node *node = tps6507x_dev->dev->of_node; + struct tps6507x_board *tps_board = + (struct tps6507x_board *)tps6507x_dev->dev->platform_data; + struct touchscreen_init_data *init_data = NULL; + u32 val32; + int err; + + if (node) + node = of_find_node_by_name(node, "tsc"); + if (tps_board) + init_data = tps_board->tps6507x_ts_init_data; + + if (init_data) { + tps6507x_dev->ts->poll_period = init_data->poll_period; + tps6507x_dev->ts->min_pressure = init_data->min_pressure; + tps6507x_dev->ts->vref = init_data->vref; + input_dev->id.vendor = init_data->vendor; + input_dev->id.product = init_data->product; + input_dev->id.version = init_data->version; + } else if (node) { + err = of_property_read_u32(node, "ti,poll_period", &val32); + if (err < 0) + goto error_ret; + else + tps6507x_dev->ts->poll_period = val32; + + err = of_property_read_u32(node, "ti,min_pressure", &val32); + if (err < 0) + goto error_ret; + else + tps6507x_dev->ts->min_pressure = val32; + + err = of_property_read_u32(node, "ti,vref", &val32); + if (err < 0) + goto error_ret; + else + tps6507x_dev->ts->vref = val32; + + err = of_property_read_u32(node, "ti,vendor", &val32); + if (err < 0) + goto error_ret; + else + input_dev->id.vendor = val32; + + err = of_property_read_u32(node, "ti,product", &val32); + if (err < 0) + goto error_ret; + else + input_dev->id.product = val32; + + err = of_property_read_u32(node, "ti,version", &val32); + if (err < 0) + goto error_ret; + else + input_dev->id.version = val32; + } else { + err = -EINVAL; + goto error_ret; + } + + return 0; + +error_ret: + return err; +} + static int tps6507x_ts_probe(struct platform_device *pdev) { int error; struct tps6507x_ts *tsc; struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); - struct touchscreen_init_data *init_data; struct input_dev *input_dev; - struct tps6507x_board *tps_board; int schd; - /** - * tps_board points to pmic related constants - * coming from the board-evm file. - */ - - tps_board = (struct tps6507x_board *)tps6507x_dev->dev->platform_data; - - if (!tps_board) { - dev_err(tps6507x_dev->dev, - "Could not find tps6507x platform data\n"); - return -EIO; - } - - /** - * init_data points to array of regulator_init structures - * coming from the board-evm file. - */ - - init_data = tps_board->tps6507x_ts_init_data; - tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL); if (!tsc) { dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); @@ -301,14 +350,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler); - if (init_data) { - tsc->poll_period = init_data->poll_period; - tsc->vref = init_data->vref; - tsc->min_pressure = init_data->min_pressure; - input_dev->id.vendor = init_data->vendor; - input_dev->id.product = init_data->product; - input_dev->id.version = init_data->version; - } else { + error = tsc_init_data(tps6507x_dev, input_dev); + + if (error) { + dev_warn(&pdev->dev, "Use default platform data\n"); tsc->poll_period = TSC_DEFAULT_POLL_PERIOD; tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE; }