From patchwork Sun Sep 24 14:56:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114127 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1642479qgf; Sun, 24 Sep 2017 07:58:53 -0700 (PDT) X-Received: by 10.99.117.81 with SMTP id f17mr5059148pgn.314.1506265133699; Sun, 24 Sep 2017 07:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265133; cv=none; d=google.com; s=arc-20160816; b=oUdrhP2P3brZ+hN6ikId7aEQ8prdF+um02MRtWBQ/vbPCZ7tCS27RuCXqQdRxZxoRR 7XhHGot56Wt+EeNxC63FOEppTd++tgOs5m9bkg2tQsCCO+65eRdprLN7pZ5HyFnsUCWo oY0F1GCQZkFJWzo+/rUikKXBDy97QwDQ3mbZQYO0o0MK+pqtYyuA8nQlftRORdHWqShy 8rPmYOFKprzwnkUn4AvtaSOdafEAttDFRkgPI5+3wfPa0B36NzVaOR2WYf90ab/j6dqW J3mslhC8dFr0OWCwddS0Qn+SFnDZymkpXtvxiF+1E5CkjMAvS3n2btXE47Vklp86pw5p SHsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=SlTwv5Y1OiiDe+40Wl8rw7HABGPhZRcjy/1MPTFGaV8=; b=nf0afit/EejnAzCnJPlm1DdrzHuN/Yo94KgDKWw2yAWf7eLdL3pJWyZ3Z/FGD8py0z a+Sj1tXGSj/RZnijP/UGf52SKiPuS9CUeOjhjQeXwEbngFZr+jPhwxmDQcPrEJPG1Rnw LGTdnHA8gkNmF8hr2suDc1+i59nZW5zZ8/9Jcw49iUWlFge1DdTqxSLWSONSyINpiLsc hYQSnwPvjAj19WxIQtH24UElZEqwQ2A/J64CR+YtEFV8NFh3DE4EtR6EmJfeb1n04BZi Uujygyhx2NhFYYoeSEE53I5awlN8FXQ8KCxDodgTWxRI0TOgC+v/4il0mOZmvse4p4ah WYOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OuCTgCaU; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10si2689776plr.829.2017.09.24.07.58.53; Sun, 24 Sep 2017 07:58:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OuCTgCaU; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbdIXO6w (ORCPT + 5 others); Sun, 24 Sep 2017 10:58:52 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:44971 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752540AbdIXO6v (ORCPT ); Sun, 24 Sep 2017 10:58:51 -0400 Received: by mail-pg0-f52.google.com with SMTP id j16so2734207pga.1 for ; Sun, 24 Sep 2017 07:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2jxVPCIRGO5yXL+LoQ5MNlE1/0+ir58BOeJARm/WmNs=; b=OuCTgCaUrdhTuOrEw8p3bJjJuxWxLcEqy9kZUzapJ7EoLC2VG7IFH3JN9++HiOrHKQ 94ru1IIzq81tV2dnX4iLCBR3NjRxT4OOUydIkTEgqS2eX8x66zY/0AITVedPzJsZPQSS QLP1JE2shYWO7a9Sf99KLz0QY5fv/HMNTiEhM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2jxVPCIRGO5yXL+LoQ5MNlE1/0+ir58BOeJARm/WmNs=; b=AsS/Qz5dfNx2yypxANZWFTub21KBDyPlZWOi/qAV/bWPGlz1UdonB1tJpcAqgK0qH1 9KoGLYyK3j8tTnEtsEi9IWHhx2qViu3sgFZgWegBnke5VwaNkrjLvDVgF154TopVq+gG 5LVXRUaQmFVdYRM1iLH2sFyjTzFR74RN7mpWlYN5h5I2LBIJqRFf843J8I1Xg6+uXXFW a9CMtFhldMOGLWsE6kVSi+prxpHswkHQP1OwRrUp9cjBvpj9Fnu0LWLIVPdpm1Zh0gkp iVkoktDnnrwSiQ8bOdU4DZxro4ew/kmXKvVDhvyp8ULdht9AtsmOlOeH8PIgnL6tN3LF VyIg== X-Gm-Message-State: AHPjjUg4TQGtnKmM42gcu2UqP6Bu94fxZt1WixN2cRfAaCPNWDJAzuds Y+m5lBtga5QZbvCkYQTfWmGA5BvuKUs= X-Google-Smtp-Source: AOwi7QBWv+wvMYdaJG2LwJB2uhPh+onR6YJcSU8M3a8+toqjpNnzi0/R9K1yrgfnxwXYvu/ef3IxZA== X-Received: by 10.98.35.209 with SMTP id q78mr4981419pfj.36.1506265131223; Sun, 24 Sep 2017 07:58:51 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.07.58.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 07:58:50 -0700 (PDT) From: Linus Walleij To: MyungJoo Ham , Chanwoo Choi Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Stultz , Mike Lockwood , Guenter Roeck , Linus Walleij Subject: [PATCH 2/8] extcon: gpio: Localize platform data Date: Sun, 24 Sep 2017 16:56:16 +0200 Message-Id: <20170924145622.4031-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170924145622.4031-1-linus.walleij@linaro.org> References: <20170924145622.4031-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Nothing in the entire kernel #includes so move the platform data declaration inside of the driver. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 22 +++++++++++++++++- include/linux/extcon/extcon-gpio.h | 47 -------------------------------------- 2 files changed, 21 insertions(+), 48 deletions(-) delete mode 100644 include/linux/extcon/extcon-gpio.h -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index ebed22f22d75..6abf5f70fdbf 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -29,6 +28,27 @@ #include #include +/** + * struct gpio_extcon_pdata - A simple GPIO-controlled extcon device. + * @extcon_id: The unique id of specific external connector. + * @gpio: Corresponding GPIO. + * @gpio_active_low: Boolean describing whether gpio active state is 1 or 0 + * If true, low state of gpio means active. + * If false, high state of gpio means active. + * @debounce: Debounce time for GPIO IRQ in ms. + * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW). + * @check_on_resume: Boolean describing whether to check the state of gpio + * while resuming from sleep. + */ +struct gpio_extcon_pdata { + unsigned int extcon_id; + unsigned gpio; + bool gpio_active_low; + unsigned long debounce; + unsigned long irq_flags; + bool check_on_resume; +}; + struct gpio_extcon_data { struct extcon_dev *edev; int irq; diff --git a/include/linux/extcon/extcon-gpio.h b/include/linux/extcon/extcon-gpio.h deleted file mode 100644 index 7cacafb78b09..000000000000 --- a/include/linux/extcon/extcon-gpio.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Single-state GPIO extcon driver based on extcon class - * - * Copyright (C) 2012 Samsung Electronics - * Author: MyungJoo Ham - * - * based on switch class driver - * Copyright (C) 2008 Google, Inc. - * Author: Mike Lockwood - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef __EXTCON_GPIO_H__ -#define __EXTCON_GPIO_H__ __FILE__ - -#include - -/** - * struct gpio_extcon_pdata - A simple GPIO-controlled extcon device. - * @extcon_id: The unique id of specific external connector. - * @gpio: Corresponding GPIO. - * @gpio_active_low: Boolean describing whether gpio active state is 1 or 0 - * If true, low state of gpio means active. - * If false, high state of gpio means active. - * @debounce: Debounce time for GPIO IRQ in ms. - * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW). - * @check_on_resume: Boolean describing whether to check the state of gpio - * while resuming from sleep. - */ -struct gpio_extcon_pdata { - unsigned int extcon_id; - unsigned gpio; - bool gpio_active_low; - unsigned long debounce; - unsigned long irq_flags; - - bool check_on_resume; -}; - -#endif /* __EXTCON_GPIO_H__ */ From patchwork Sun Sep 24 14:56:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114131 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1644878qgf; Sun, 24 Sep 2017 08:01:29 -0700 (PDT) X-Received: by 10.84.218.71 with SMTP id f7mr4872912plm.145.1506265288823; Sun, 24 Sep 2017 08:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265288; cv=none; d=google.com; s=arc-20160816; b=VoaT9RyfMk2q1nDs8nXjrc8S154ZYHu/bN7ppgsN1t5NyCsC8ud7W3JdKi8rDRxND6 NlMhSurfSZfwnS4qrzcaYq7sAmM8wkAZwj61G3tvF34kOSxpfFNJTSDRIdHuklhaJaCI hS9WVy/UATQSSYUN9A+lPtbDMciKGXDIk3aha+rgYHr2NzTS2t+xGSza8kI9dLg7qomI e1GO3HZRjE2HST/4Tsaf8n5rUWyyyFIOtAd7ipi+1nUWVf5wF1t3k+rEf5iF9eQzUERT GS3sXUI3DjZsgeD7fbtYtVKsIN+PsZ49Cxbt7KrqUB3UmU5yAM1izTVI2JmhddEVBn0e QuoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=C0aF5SXNxs9r/RIQU+HmWMsxLjQkWWmL1d3e0Y54mKg=; b=LfpTkDwaXTYDNCb6BXN5QRm+iFr2uKWghO4gVt9QARxQSeykxA/cgFZ9wRLGKfzlLv I4PYXbSE46Vmkt76xS24uNVQf+oDcHkBx1pIkBzjM70kb7iQiNQN/QmFsvmbspO+biqT fMQ++CkIjkHnutJUokuc36dp1UeUvFayoJnyStXul7QiHS9FA1Y5rAw37zr20ZHZzkrU xOYJGMaHZVnIZUzXlofpeOktEnx/X8IqFluLdMCRLP+93BbnvSs5K8uHYnGpj6t6aCN/ pGm0kNytVc/K2R8u/a4HnJQdO6V5DKqKGc1NofncFJxHSIM72b8iNC1t6cYk30HTxaiP Q+SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GbGj0DDq; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z31si2743608plb.732.2017.09.24.08.01.28; Sun, 24 Sep 2017 08:01:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GbGj0DDq; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752510AbdIXPB2 (ORCPT + 5 others); Sun, 24 Sep 2017 11:01:28 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:46449 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbdIXPB1 (ORCPT ); Sun, 24 Sep 2017 11:01:27 -0400 Received: by mail-pg0-f42.google.com with SMTP id i130so2732497pgc.3 for ; Sun, 24 Sep 2017 08:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/9fxiD6ys0Hzzn3dJW1TOtNYjkdHftdU0/8lE6VRkvg=; b=GbGj0DDquQMc1XUW7vc+p3k4scsM8/AYScpVRpSlplm/UML60npVKMdgrcb8QyksSB wQMo19A9tEN+3FD8ev0GMgjPx7t5DbI4SDWzJ6LZHg4HcVOPzn0tGa2vGqZ7KS46zcmj bdySTQ4YNj3BxX+ewwKPVk1Fcs/reSAVuVQ/U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/9fxiD6ys0Hzzn3dJW1TOtNYjkdHftdU0/8lE6VRkvg=; b=UkiX6FRjigzfp0/B69U3KNGxEj/Ur6yPGrohbWF09ndfB43PukZrJHOy98BJSdblfC XImuk/zLsgKmLDHSssBQ0E0HHmtZpYOMzZ3JMQe1qvAmZHS2LOQGHMykakwBoEnYdyAW ACMhG8mwUxvvW+HVMQAmKVSHN8iBcDWaQbMmFC3wQCxOGTxZeBlm8qTPyCfFlrD8X/7g 26Ka6fJjkn/cR8B279fCrhdfRjt3sVTaURjW0eaTYsYDUho70cPLM68vq0jQj+CxKhc+ DCVwtc/mGw9WHpq0EXmVRmEqg1AKwTQOEGcNRda1guzwUCgq6gXvR0PWT6E8WoQ9oJ6W MthA== X-Gm-Message-State: AHPjjUiXW7cqQS17h8rBIis9BJwBAauUJ7ChYIfdg7d+i3rakw3xFnzl 1sTVf4R+hhYhjHZvGuHiP8jSuA== X-Google-Smtp-Source: AOwi7QA+qWxXrWIN34W0uqFLcrJjKl3yGIKVrQJe5CsE7z3L75AdhvW6Z57eveWedQG+ltfh7mdfEA== X-Received: by 10.84.128.69 with SMTP id 63mr5025606pla.119.1506265286876; Sun, 24 Sep 2017 08:01:26 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.08.00.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:01:26 -0700 (PDT) From: Linus Walleij To: MyungJoo Ham , Chanwoo Choi Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Stultz , Mike Lockwood , Guenter Roeck , Linus Walleij Subject: [PATCH 6/8] extcon: gpio: Get debounce setting from device property Date: Sun, 24 Sep 2017 16:56:20 +0200 Message-Id: <20170924145622.4031-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170924145622.4031-1-linus.walleij@linaro.org> References: <20170924145622.4031-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Look up the debouncing value using the device property that will pick it from device tree or ACPI DSDT or whatever is available. Reintroduce the debounce handling previously deleted in the series, setting the delayed worker to delay 0 ms if the GPIO driver supports debouncing for us, else just delay the reading of the value delayed by jiffies. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Chanwoo Choi diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 6d9cb4ed11c2..8fc52631c8a2 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -35,7 +36,6 @@ * value. * @gpiod: GPIO descriptor for this external connector. * @extcon_id: The unique id of specific external connector. - * @debounce: Debounce time for GPIO IRQ in ms. * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ @@ -45,7 +45,6 @@ struct gpio_extcon_data { unsigned long debounce_jiffies; struct gpio_desc *gpiod; unsigned int extcon_id; - unsigned long debounce; bool check_on_resume; }; @@ -74,6 +73,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) struct gpio_extcon_data *data; struct device *dev = &pdev->dev; unsigned long irq_flags; + u32 debounce_usecs; int irq; int ret; @@ -109,6 +109,15 @@ static int gpio_extcon_probe(struct platform_device *pdev) return -ENOMEM; } + ret = device_property_read_u32(dev, "input-debounce", &debounce_usecs); + if (ret || !debounce_usecs) { + dev_err(dev, "illegal debounce value, set to 20 ms\n"); + debounce_usecs = 20000; + } + ret = gpiod_set_debounce(data->gpiod, debounce_usecs); + if (ret) + data->debounce_jiffies = msecs_to_jiffies(debounce_usecs * 1000); + ret = devm_extcon_dev_register(dev, data->edev); if (ret < 0) return ret;