From patchwork Wed Oct 23 16:28:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Badarkhe X-Patchwork-Id: 3089231 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 167A49F372 for ; Wed, 23 Oct 2013 16:30:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C51E20328 for ; Wed, 23 Oct 2013 16:30:21 +0000 (UTC) Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5265202C8 for ; Wed, 23 Oct 2013 16:30:19 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r9NGT55f011822; Wed, 23 Oct 2013 11:29:05 -0500 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 r9NGT5hE032473; Wed, 23 Oct 2013 11:29:05 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Wed, 23 Oct 2013 11:29:05 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id r9NGT5U1001491; Wed, 23 Oct 2013 11:29:05 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 1FAFE80627; Wed, 23 Oct 2013 11:29:05 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 4EE7A80627 for ; Wed, 23 Oct 2013 11:29:03 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r9NGT3VG026506 for ; Wed, 23 Oct 2013 11:29:03 -0500 (CDT) Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id r9NGT2IY001369 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Oct 2013 11:29:02 -0500 Received: from [216.82.250.51:23432] by server-17.bemta-12.messagelabs.com id 95/4D-22351-E49F7625; Wed, 23 Oct 2013 16:29:02 +0000 X-Env-Sender: badarkhe.manish@gmail.com X-Msg-Ref: server-2.tower-108.messagelabs.com!1382545740!12045487!1 X-Originating-IP: [209.85.160.52] X-SpamReason: INFO: max file limit 5000 X-SpamReason: No, hits=0.0 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22042 invoked from network); 23 Oct 2013 16:29:01 -0000 Received: from mail-pb0-f52.google.com (HELO mail-pb0-f52.google.com) (209.85.160.52) by server-2.tower-108.messagelabs.com with RC4-SHA encrypted SMTP; 23 Oct 2013 16:29:01 -0000 Received: by mail-pb0-f52.google.com with SMTP id wy17so1192986pbc.11 for ; Wed, 23 Oct 2013 09:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZbpcPfei7T0TX0XBRRHeJeOQ92s71vfeohbLdvYX/hQ=; b=IgN6DrowRRqu8BOAE4zTWkPjdM807ti8mx6sfz871Lmu4MmVJm9r2rx0N9/K+lhUuL o/uz485lfRvyRXzp1Dzg/Csc1Q4LaomIEGSV6ya1ADZnZMcTi6XBRZVeFvXKyHKiD6s8 QqsqHiYSlrC1Vmxo0Vh1C45Grp9E/9F9W6M9j/s4BgQ8PVnd5jVjbUCSMoRlFjhs+YPi paBaEO8UnwqNYZVJsPBAjkNHmUMbdpJTL6Uw8nVZPdMKn++WhA02JKep+1FZ6l5oCrGE 7E9Zb3bWoWfSka26eWaSpXSNpx/FoiXCh/1DQSsnd7Gic8OHSrqkj6fhoLzqT0fJaXlT eRZw== X-Received: by 10.68.98.101 with SMTP id eh5mr2467606pbb.65.1382545740518; Wed, 23 Oct 2013 09:29:00 -0700 (PDT) Received: from localhost.localdomain ([113.193.146.20]) by mx.google.com with ESMTPSA id hw10sm5556554pbc.24.2013.10.23.09.28.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 09:29:00 -0700 (PDT) From: Manish Badarkhe To: , , , , , Subject: [PATCH V4 1/2] tps6507x-ts: Add DT support Date: Wed, 23 Oct 2013 21:58:52 +0530 Message-ID: <1382545733-8865-2-git-send-email-badarkhe.manish@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1382545733-8865-1-git-send-email-badarkhe.manish@gmail.com> References: <1382545733-8865-1-git-send-email-badarkhe.manish@gmail.com> 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: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add device tree based support for TI's tps6507x touchscreen. Signed-off-by: Manish Badarkhe --- Changes since V3: - Rebased on top of Dmitry's changes - Removed error handling for optional DT properties Changes since V2: - Removed unnecessary code. - Updated Documentation to provide proper names of devicetree properties. Changes since V1: - Updated documentation 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... e1b9cfd... M Documentation/devicetree/bindings/mfd/tps6507x.txt :100644 100644 db604e0... 0cf0eb1... M drivers/input/touchscreen/tps6507x-ts.c Documentation/devicetree/bindings/mfd/tps6507x.txt | 24 ++++++- drivers/input/touchscreen/tps6507x-ts.c | 72 ++++++++++++-------- 2 files changed, 67 insertions(+), 29 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/tps6507x.txt b/Documentation/devicetree/bindings/mfd/tps6507x.txt index 8fffa3c..e1b9cfd 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,9 @@ 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. Regulator Optional properties: - defdcdc_default: It's property of DCDC2 and DCDC3 regulators. @@ -30,6 +37,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 populate + in sysclass interface. +- ti,product: Touchscreen product id to populate + in sysclass interface. +- ti,version: Touchscreen version id to populate + in sysclass interface. + Example: pmu: tps6507x@48 { @@ -88,4 +103,11 @@ Example: }; }; + tsc { + ti,poll-period = <30>; + ti,min-pressure = <0x30>; + 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 db604e0..0cf0eb1 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #define TSC_DEFAULT_POLL_PERIOD 30 /* ms */ #define TPS_DEFAULT_MIN_PRESSURE 0x30 @@ -206,33 +208,54 @@ done: tps6507x_adc_standby(tsc); } +static void tsc_init_data(struct tps6507x_ts *tsc, + struct input_dev *input_dev) +{ + struct device_node *node = tsc->dev->of_node; + const struct tps6507x_board *tps_board = + dev_get_platdata(tsc->dev); + const struct touchscreen_init_data *init_data = NULL; + + if (node) + node = of_find_node_by_name(node, "tsc"); + if (tps_board) + /* + * init_data points to array of touchscreen_init structure + * coming from the board-evm file. + */ + init_data = tps_board->tps6507x_ts_init_data; + + if (node == NULL || init_data == NULL) { + tsc->poll_dev->poll_interval = TSC_DEFAULT_POLL_PERIOD; + tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE; + } else if (init_data) { + tsc->poll_dev->poll_interval = init_data->poll_period; + 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 if (node) { + of_property_read_u32(node, "ti,poll-period", + &tsc->poll_dev->poll_interval); + of_property_read_u16(node, "ti,min-pressure", + &tsc->min_pressure); + of_property_read_u16(node, "ti,vendor", + &input_dev->id.vendor); + of_property_read_u16(node, "ti,product", + &input_dev->id.product); + of_property_read_u16(node, "ti,version", + &input_dev->id.version); + } +} + static int tps6507x_ts_probe(struct platform_device *pdev) { struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); - const struct tps6507x_board *tps_board; - const struct touchscreen_init_data *init_data; struct tps6507x_ts *tsc; struct input_polled_dev *poll_dev; struct input_dev *input_dev; int error; - /* - * tps_board points to pmic related constants - * coming from the board-evm file. - */ - tps_board = dev_get_platdata(tps6507x_dev->dev); - if (!tps_board) { - dev_err(tps6507x_dev->dev, - "Could not find tps6507x platform data\n"); - return -ENODEV; - } - - /* - * 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"); @@ -241,8 +264,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) tsc->mfd = tps6507x_dev; tsc->dev = tps6507x_dev->dev; - tsc->min_pressure = init_data ? - init_data->min_pressure : TPS_DEFAULT_MIN_PRESSURE; snprintf(tsc->phys, sizeof(tsc->phys), "%s/input0", dev_name(tsc->dev)); @@ -258,8 +279,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) poll_dev->private = tsc; poll_dev->poll = tps6507x_ts_poll; - poll_dev->poll_interval = init_data ? - init_data->poll_period : TSC_DEFAULT_POLL_PERIOD; input_dev = poll_dev->input; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); @@ -273,11 +292,8 @@ static int tps6507x_ts_probe(struct platform_device *pdev) input_dev->phys = tsc->phys; input_dev->dev.parent = tsc->dev; input_dev->id.bustype = BUS_I2C; - if (init_data) { - input_dev->id.vendor = init_data->vendor; - input_dev->id.product = init_data->product; - input_dev->id.version = init_data->version; - } + + tsc_init_data(tsc, input_dev); error = tps6507x_adc_standby(tsc); if (error)