From patchwork Fri Nov 11 07:58:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mugunthan V N X-Patchwork-Id: 9424571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B25B60484 for ; Sun, 13 Nov 2016 05:33:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CC1828DB3 for ; Sun, 13 Nov 2016 05:33:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F5CE28DB1; Sun, 13 Nov 2016 05:33:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8FA428DB1 for ; Sun, 13 Nov 2016 05:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932268AbcKMFcv (ORCPT ); Sun, 13 Nov 2016 00:32:51 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:41903 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751201AbcKMFct (ORCPT ); Sun, 13 Nov 2016 00:32:49 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id uAB7wSjG023068; Fri, 11 Nov 2016 01:58:28 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id uAB7wSPJ013374; Fri, 11 Nov 2016 01:58:28 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Fri, 11 Nov 2016 01:58:27 -0600 Received: from a0131834lt.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id uAB7wN0c000883; Fri, 11 Nov 2016 01:58:24 -0600 From: Mugunthan V N To: CC: Dmitry Torokhov , Jonathan Cameron , Rob Herring , Mark Rutland , Lee Jones , Sekhar Nori , Vignesh R , , , , Mugunthan V N Subject: [PATCH v2 2/3] Input: ti_am335x_tsc: Add support for ti, charge-delay-ns Date: Fri, 11 Nov 2016 13:28:19 +0530 Message-ID: <20161111075819.5760-1-mugunthanvnm@ti.com> X-Mailer: git-send-email 2.11.0.rc0.7.gbe5a750 In-Reply-To: <20161110163515.27598-1-mugunthanvnm@ti.com> References: <20161110163515.27598-1-mugunthanvnm@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Dmitry Torokhov --- 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",