From patchwork Tue Sep 6 18:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12968012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26528ECAAA1 for ; Tue, 6 Sep 2022 18:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=shEH9DHkEJfiG5cI+/rZLzFsxkKJ4IvvnhFlqgNmKCg=; b=Hz36lV8uGIZO/d V/tlt2KEw32fYgK3VGuX+3ir1G3BQWNXYeQmPt8OdkSFD3QI6zvQz8BiBXkQMvEnqxKccuFIXKmdx At2vnaNoSstvBl7gpqGhg0UeRC4l7AtwzxkZc/18m19X/f9kutGyycGoFC5Johuvnr2I6819wlWnB +wODBRl3/WJuXf+mPvPKprd4LSSripL+y9ctCB5wNSbjFGgOevk0BPsDlHcNWZTFHbbG+PeWyIb3f h1DS5T7DTNPWSH4aYJ3vYVt8wIaWDp2p19EH0uRpu8YPtMn0yZNVukzdEzU/GtmUrBUxYRrwF5hk3 hVqNusn1TnvvH5WUKB9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVdPl-00GO5T-Sr; Tue, 06 Sep 2022 18:35:14 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVdPg-00GO1j-TQ for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2022 18:35:10 +0000 Received: by mail-pj1-x102f.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso7384414pjd.4 for ; Tue, 06 Sep 2022 11:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=Qv7vr9hnlWPJCQbWCubbxvr7dX1UFw3F8MYYEI1by0g=; b=Mz0MdMZDEGT5vR197DGR6zwttYMpvkEWvq22F7MToy76uIYP2muNZ0snvsZHaVgv7P jV2aRPG3FFPyrbGrJHgjBmWkKzmYjauq2uKEVplqOnFi8jY+MLqWwWHhp5Dueuwiul4A mvL5fmXV6WAOHtYR6MXd/sJSqp8NctJCC2Mj0uTQFp6b8XdOtViLHQSF5fWoKXeN0biW VlVRDMi/MCtGvXYiwEieDCHDbNw5WTTB2W5xzVPvN6orARGRUrwheYouCPto0cfbIC8m TlxNb1fjlTrcBDqXrib1IKv1FwFsrYxAiiLGHYhiKhTLkP/9ITr1JdeUx3nTl5I7IYgl uNZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=Qv7vr9hnlWPJCQbWCubbxvr7dX1UFw3F8MYYEI1by0g=; b=1Wj9LtEn3orDhHXlnf5NOEhphX9ZK+ytVJMf3XZDhZYHv1FAeo4eRQ5aS/Fo/i4TN7 LyIFWdg/AJCz6ljlL3/rekS9qzCv7rbIM9X4qzgF6jA5ecSPaPGVn/bZQzYeyOBSx40C wCNb16gzqquUIE7+iS8MZ9jiLbcAx1XrczgEOTosHwkIOMpVy2tIzMpc5UkInS1kAcr8 9YNai0Pjkf7KWiatxj4+wyELiY/weJweI/P/P8UdsACMhX+B0L5Qq93Fa4CAaGsCuXat DJ4Pe4/ynggiLG6qHN1f9uauZC8VqaSYnxz7SLFo13HJlBHY/fWx2hbik2gzkF8pcl0R 3hCA== X-Gm-Message-State: ACgBeo3HuDbLuf16vdP0Zx4lle/RJrRL2xkO9S3kPAFvdUpfMnQ8ttjh 2kxfR7QSiTt+hQeCb+GtEgM= X-Google-Smtp-Source: AA6agR61r4MuX3r6sIQoB66/rvq8hkX+StGN4IgVkM4CTKlkH4yuvF8dXMVkTHOZMgfR9c3r94IJkQ== X-Received: by 2002:a17:90b:3144:b0:1f5:2c6d:7dea with SMTP id ip4-20020a17090b314400b001f52c6d7deamr25642211pjb.220.1662489304003; Tue, 06 Sep 2022 11:35:04 -0700 (PDT) Received: from google.com ([2620:15c:202:201:1190:fbfa:ae95:111c]) by smtp.gmail.com with ESMTPSA id w128-20020a626286000000b0053dc56afd3csm4807504pfb.219.2022.09.06.11.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 11:35:03 -0700 (PDT) Date: Tue, 6 Sep 2022 11:35:00 -0700 From: Dmitry Torokhov To: Lee Jones , Thierry Reding , Jonathan Hunter Cc: Rob Herring , Krzysztof Kozlowski , Maxime Coquelin , Alexandre Torgue , Francesco Dolcini , Linus Walleij , devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] mfd: stmpe: switch to using gpiod API Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_113509_000768_4207EEAD X-CRM114-Status: GOOD ( 22.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib. We also need to patch relevant DTS files, as the original code relied on the fact that of_get_named_gpio_flags() would fetch any data encoded in GPIO flags, even if it does not reflect valid flags for a GPIO. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- v1->v2: - add DTS changes, as noticed by Francesco Dolcini. I guess we could do a dance of changing stmpe to check the flags coming from DTS and try to distinguish IRQ flags from proper GPIO flags, then have a separate patch changing DTSes, and finally a 2nd patch to stmpe to use GPIOD API, but I am hoping we could apply this in one go... arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi | 2 +- arch/arm/boot/dts/tegra30-apalis.dtsi | 2 +- arch/arm/boot/dts/tegra30-colibri.dtsi | 2 +- drivers/mfd/stmpe.c | 36 ++++++++-------------- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi b/arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi index 380f22a35821..a1bcd67fa505 100644 --- a/arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi +++ b/arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi @@ -993,7 +993,7 @@ ldo8_reg: ldo8 { touchscreen@41 { compatible = "st,stmpe811"; reg = <0x41>; - irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>; + irq-gpio = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>; interrupt-controller; id = <0>; blocks = <0x5>; diff --git a/arch/arm/boot/dts/tegra30-apalis.dtsi b/arch/arm/boot/dts/tegra30-apalis.dtsi index 9bdc4cb71449..99d7dad72d29 100644 --- a/arch/arm/boot/dts/tegra30-apalis.dtsi +++ b/arch/arm/boot/dts/tegra30-apalis.dtsi @@ -976,7 +976,7 @@ ldo8_reg: ldo8 { touchscreen@41 { compatible = "st,stmpe811"; reg = <0x41>; - irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>; + irq-gpio = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>; interrupt-controller; id = <0>; blocks = <0x5>; diff --git a/arch/arm/boot/dts/tegra30-colibri.dtsi b/arch/arm/boot/dts/tegra30-colibri.dtsi index 310dff05910d..2867a138e011 100644 --- a/arch/arm/boot/dts/tegra30-colibri.dtsi +++ b/arch/arm/boot/dts/tegra30-colibri.dtsi @@ -849,7 +849,7 @@ ldo8_reg: ldo8 { touchscreen@41 { compatible = "st,stmpe811"; reg = <0x41>; - irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>; + irq-gpio = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>; interrupt-controller; id = <0>; blocks = <0x5>; diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 987e251d90ae..0c4f74197d3e 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -8,14 +8,13 @@ */ #include -#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -30,17 +29,12 @@ * @irq_trigger: IRQ trigger to use for the interrupt to the host * @autosleep: bool to enable/disable stmpe autosleep * @autosleep_timeout: inactivity timeout in milliseconds for autosleep - * @irq_over_gpio: true if gpio is used to get irq - * @irq_gpio: gpio number over which irq will be requested (significant only if - * irq_over_gpio is true) */ struct stmpe_platform_data { int id; unsigned int blocks; unsigned int irq_trigger; bool autosleep; - bool irq_over_gpio; - int irq_gpio; int autosleep_timeout; }; @@ -1349,13 +1343,6 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata, if (pdata->id < 0) pdata->id = -1; - pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0, - &pdata->irq_trigger); - if (gpio_is_valid(pdata->irq_gpio)) - pdata->irq_over_gpio = 1; - else - pdata->irq_trigger = IRQF_TRIGGER_NONE; - of_property_read_u32(np, "st,autosleep-timeout", &pdata->autosleep_timeout); @@ -1381,6 +1368,7 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum) struct stmpe_platform_data *pdata; struct device_node *np = ci->dev->of_node; struct stmpe *stmpe; + struct gpio_desc *irq_gpio; int ret; u32 val; @@ -1434,18 +1422,20 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum) if (ci->init) ci->init(stmpe); - if (pdata->irq_over_gpio) { - ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio, - GPIOF_DIR_IN, "stmpe"); - if (ret) { - dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", - ret); - return ret; - } + irq_gpio = devm_gpiod_get_optional(ci->dev, "irq", GPIOD_ASIS); + ret = PTR_ERR_OR_ZERO(irq_gpio); + if (ret) { + dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", ret); + return ret; + } - stmpe->irq = gpio_to_irq(pdata->irq_gpio); + if (irq_gpio) { + stmpe->irq = gpiod_to_irq(irq_gpio); + pdata->irq_trigger = gpiod_is_active_low(irq_gpio) ? + IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH; } else { stmpe->irq = ci->irq; + pdata->irq_trigger = IRQF_TRIGGER_NONE; } if (stmpe->irq < 0) {