From patchwork Wed Jun 8 13:48:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9164711 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 E373F60467 for ; Wed, 8 Jun 2016 13:49:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4EDF25D91 for ; Wed, 8 Jun 2016 13:49:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C826B2810E; Wed, 8 Jun 2016 13:49:24 +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=ham 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 5008825D91 for ; Wed, 8 Jun 2016 13:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754228AbcFHNsu (ORCPT ); Wed, 8 Jun 2016 09:48:50 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:51303 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752836AbcFHNs1 (ORCPT ); Wed, 8 Jun 2016 09:48:27 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O8G001XKH0MNB30@mailout4.w1.samsung.com>; Wed, 08 Jun 2016 14:48:22 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-9a-5758222649d8 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 64.8D.05254.62228575; Wed, 8 Jun 2016 14:48:22 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O8G00M68H0F9I60@eusync1.samsung.com>; Wed, 08 Jun 2016 14:48:22 +0100 (BST) From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Mark Rutland , Kukjin Kim , Krzysztof Kozlowski , Marek Szyprowski , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: rogerq@ti.com, Peter Chen , "Ivan T. Ivanov" , balbi@ti.com, kishon@ti.com, Bartlomiej Zolnierkiewicz Subject: [RFC v4 5/7] extcon: usb-gpio: make debounce value configurable in devicetree Date: Wed, 08 Jun 2016 15:48:04 +0200 Message-id: <1465393686-16644-6-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1465393686-16644-1-git-send-email-k.kozlowski@samsung.com> References: <1465393686-16644-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xy7pqShHhBq/Xm1hsnLGe1eLg/XqL 61+es1rMP3KO1eLZxIeMFq9fGFr0P37NbHHhaQ+bxabH11gtLu+aw2Yx4/w+Jou1R+6yWyy9 fpHJ4nbjCjaLY7P/Mlm07j3CbtHzSMtB0GPNvDWMHv8O9zN5bFrVyeaxeUm9x6b905g9+ras YvQ4fmM7k8fnTXIBHFFcNimpOZllqUX6dglcGddv72UvWClQ0d15h7mB8SJvFyMnh4SAicTv /uVsELaYxIV764FsLg4hgaWMEofvLmOBcBqZJM787QerYhMwlti8fAlYlYjAImaJ4509TCAO s8A2RokbvT+YQaqEBSIkbs9+DGazCKhKtE3YBGbzCrhLLDq+BGqfnMTJY5NZQWxOAQ+Ji9uX MYLYQkA1vz9PZJnAyLuAkWEVo2hqaXJBcVJ6rqFecWJucWleul5yfu4mRkhQf9nBuPiY1SFG AQ5GJR5eBcPwcCHWxLLiytxDjBIczEoivDoyEeFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeefu eh8iJJCeWJKanZpakFoEk2Xi4JRqYCyWf9p1fXej/OWnHxPi5Fbnh+44LBl7bMkPZZGGHMGZ H4QXfvmev/vV82SV41l7na6sE3/BEd8k9+nPhEViJe2SJ8SLPorGGJqfW/3lUtX1aGXO7DeH /hxS2/f04KkO8xv2wu8PngkIKMzNvKb43DCh0iEjQaF0gtliRp/vjKcbD0haa4uknVRiKc5I NNRiLipOBACWJg4aZgIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Robert Baldyga This patch adds devicetree property for setting debounce value. It allows to set debounce time shorter or longer depending on the needs of given platform. Signed-off-by: Robert Baldyga Acked-by: Roger Quadros Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-usb-gpio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c index 85b8a0ce5731..e1d5929bca81 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c @@ -103,6 +103,7 @@ static int usb_extcon_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct usb_extcon_info *info; + u32 debounce; int ret; if (!np && !ACPI_HANDLE(dev)) @@ -113,6 +114,11 @@ static int usb_extcon_probe(struct platform_device *pdev) return -ENOMEM; info->dev = dev; + + ret = of_property_read_u32(np, "debounce", &debounce); + if (ret < 0) + debounce = USB_GPIO_DEBOUNCE_MS; + info->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id", GPIOD_IN); info->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus", GPIOD_IN); @@ -134,16 +140,14 @@ static int usb_extcon_probe(struct platform_device *pdev) } if (info->id_gpiod) - ret = gpiod_set_debounce(info->id_gpiod, - USB_GPIO_DEBOUNCE_MS * 1000); + ret = gpiod_set_debounce(info->id_gpiod, debounce * 1000); if (!ret && info->vbus_gpiod) { - ret = gpiod_set_debounce(info->vbus_gpiod, - USB_GPIO_DEBOUNCE_MS * 1000); + ret = gpiod_set_debounce(info->vbus_gpiod, debounce * 1000); if (ret < 0 && info->id_gpiod) gpiod_set_debounce(info->vbus_gpiod, 0); } if (ret < 0) - info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS); + info->debounce_jiffies = msecs_to_jiffies(debounce); INIT_DELAYED_WORK(&info->wq_detcable, usb_extcon_detect_cable);