From patchwork Fri Oct 14 17:54:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007238 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 DDCC2C4332F for ; Fri, 14 Oct 2022 17:55:58 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y9n+NB4Nx9EVELLp22CvK19Ps0WU1vwQd0MRUimtaaE=; b=3RlHugojZj6AEl azg184zFPmsg553+TZh67EKa1k1x795sKIxA2IjGtJnLHGgYPr9Ow56laXmj4XDbxRRgoh4bfbPw4 F3n68Lep4zL0tFobG+vvr5VVJVzckWd+kqp9qhxlaa92xqUsZ/hBMYj1Tc2pjLJOsDDAmf2a3INA4 ozbquRbdedZkN5kcT9t4n+K0mN2UdIKTlDH2uWK3rEjMCEuIRl0WXI+/fIETtwu/pwANi2FOGwKur 7siIQaWrupdZLCfDFOqoLjGjy2zZ7jD2TaiQNE+mmB6FRNApySaMfy3LKTm4/J3tAeSfjwqTmvfif suMEoObQhc3BX9fCkdjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtb-00FX5M-67; Fri, 14 Oct 2022 17:54:55 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtO-00FWza-EZ; Fri, 14 Oct 2022 17:54:43 +0000 Received: by mail-pj1-x1035.google.com with SMTP id a6-20020a17090abe0600b0020d7c0c6650so8626251pjs.0; Fri, 14 Oct 2022 10:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wmd4wvJqpqY60zoqrpnViqbsnHydL7TwQT2l6YcLmqI=; b=iB41m4KyiYjsuc0dggnZ35JbaHLv98PAwYo8Dm1EjKVq8/SmkHlFEq5GwQxCep3pyP /4w9dg8LhXRLtkK/0zUurv/wXpJ3m4Rl9xWVRpFHMnuQlrTzJKSa2GMOXDUKn0VJlqwZ SzEh3cAK2YSOQ60lUJ76mDVN99dTaYgD0YGfMuUS2/T3IMGByqtsM6gCKSuSjoXqKuye gzT18bhQSFBO6cOTYzBgCPyoi9oldutWo/xoD2XCrUXFKL0iYocMSLU1BKJfeHZAosPq Pg4HxTHPciq3P4bg2XUSoSxupEGZ7JvCr+mamCNfPPN7BvPLvhk4unO8uRKSL9n6iI4W ZhfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wmd4wvJqpqY60zoqrpnViqbsnHydL7TwQT2l6YcLmqI=; b=s7ZC2raTws27OeQIsl8wrohyDHgbWzFT+LbfyapIIi99X+WZnOez8Osc4fsm8VoJgW wF4QHJnJy8FAlh0gKEpkt7LZkQhiZm7VRx2XbQlMwmxtP6C7ANHAVUXeagD1h8WEYXUm dHiPVI8EcynL9i1AJ+317wWOtIf8qvqxT7ZlZzbWSBXOmfNGqDIm84cjvSxF/MIjzVzM BXuDCcqY54g7tSyACBymvm9+5Yauv9zCduh1KRTgxWFweBcXZ4Opqs/oHCjQoTQ5y6Hu i61mGx+UOiKGEES5ak6lpoPlEeKelfAy1JluFM6MT9hRVCbplgT5XhTOVYMM+2jNFqq6 geAw== X-Gm-Message-State: ACrzQf3ZGbvtLLoZ1vl7UHNfJ1blqUkqwwdVzCwsb6KWCK6MQBRY0iu6 i5v0LnxD0UGZaoWDguEmBn0= X-Google-Smtp-Source: AMsMyM7+cfeaKStMmEYIJgtZWE7XxOm7MMWidoPBdz07y9AY5W+pmzz3i8S+tPtip9lhdmoNqWvQRQ== X-Received: by 2002:a17:90b:180f:b0:20d:4e7f:5f52 with SMTP id lw15-20020a17090b180f00b0020d4e7f5f52mr18916920pjb.119.1665770079544; Fri, 14 Oct 2022 10:54:39 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:38 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 1/9] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Date: Fri, 14 Oct 2022 10:54:25 -0700 Message-Id: <20221011-gpiolib-quirks-v2-1-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105442_507552_B953F079 X-CRM114-Status: GOOD ( 14.01 ) 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 The driver is using non-standard "i2s1-in-sel-gpio1" and "i2s1-in-sel-gpio2" names to describe its gpios. In preparation to converting to the standard naming (i2s1-in-sel-gpios) and switching the driver to gpiod API add a quirk to gpiolib to keep compatibility with existing DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 0e4e1291604d..cef4f6634125 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -488,6 +488,38 @@ static struct gpio_desc *of_find_usb_gpio(struct device_node *np, return of_get_named_gpiod_flags(np, con_id, idx, of_flags); } +static struct gpio_desc *of_find_mt2701_gpio(struct device_node *np, + const char *con_id, + unsigned int idx, + enum of_gpio_flags *of_flags) +{ + struct gpio_desc *desc; + const char *legacy_id; + + if (!IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448)) + return ERR_PTR(-ENOENT); + + if (!of_device_is_compatible(np, "mediatek,mt2701-cs42448-machine")) + return ERR_PTR(-ENOENT); + + if (!con_id || strcmp(con_id, "i2s1-in-sel")) + return ERR_PTR(-ENOENT); + + if (idx == 0) + legacy_id = "i2s1-in-sel-gpio1"; + else if (idx == 1) + legacy_id = "i2s1-in-sel-gpio2"; + else + return ERR_PTR(-ENOENT); + + desc = of_get_named_gpiod_flags(np, legacy_id, 0, of_flags); + if (!gpiod_not_found(desc)) + pr_info("%s is using legacy gpio name '%s' instead of '%s-gpios'\n", + of_node_full_name(np), legacy_id, con_id); + + return desc; +} + typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np, const char *con_id, unsigned int idx, @@ -498,6 +530,7 @@ static const of_find_gpio_quirk of_find_gpio_quirks[] = { of_find_regulator_gpio, of_find_arizona_gpio, of_find_usb_gpio, + of_find_mt2701_gpio, NULL }; From patchwork Fri Oct 14 17:54:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007240 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 AD96FC433FE for ; Fri, 14 Oct 2022 17:56:27 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SyzH5Y/qpxVzRUdvFZavdbp1t36ZaJL49pC4rANaHA0=; b=S6pkjqIQqBi0am ffem+6avQoOE8ACu3GPu2EByK3iS+joaK+ZQOTLNl2350233FhqRs1nmesfh+1Fp5pyyEWhnXpQhm 89jIaMU/a0UD9lErUrd8GkaT9lOBkvBAeImCC26irnIeFDfHcDSBowOjfGJUYUQy4qmQYuw43Isur bpyVvgXk5cpjQMHBYyDCFOi9SRDd27+N7iaiOdYag3Ob+Wl3OuUMaJENiZRez/YtcY12SoPW6Sf2F uahJNiJwm5O8dwjmR4G46oDHQ8VRuUv/s79yYeVOxYVwv6SDDQtr0oabQjH5lSuzmu10002wuUCei tSB3oj0gpgzxdgAm4mmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOu0-00FXHi-5x; Fri, 14 Oct 2022 17:55:20 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtQ-00FWzs-AY; Fri, 14 Oct 2022 17:54:46 +0000 Received: by mail-pj1-x1036.google.com with SMTP id a6-20020a17090abe0600b0020d7c0c6650so8626327pjs.0; Fri, 14 Oct 2022 10:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qxjJXLNZ6IucM2dfltD9zuskmixqvHxoP/aJVIhJLkg=; b=PE9OwNQLQpHoGYLBtHk/ON6mSmoyJz0RhYICqP0Nc6rePnfMM1ZuS61w7Cc6H2O8FM 1bDW+Fpzq1WezRyAlTSJHX0AQf/shwuN7m6N3QZDnZTqp51HjuqswuuYtEj/s7/T8c6Z RkjdAc4bDkd5xZKF7bx9/jQfuMbNCSFPeGJT4G6OrXGixLw0foH1zTvuGfVK/cKIX0NO SzbjQOTnC7qCos63KXxu7LWTgxcmwR9Yph9kGpPu/rOWie7/ydVpDlFS98at/O9kqSHC 5RoqMKJ/HNnemVZZIAU8lDLVzzUyNCrRpx09so+szSy+2ONzAfjFGXuX+1i5Jg6+bFqB GGZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxjJXLNZ6IucM2dfltD9zuskmixqvHxoP/aJVIhJLkg=; b=ssb3ypdatNCaKhm9hCK69U6c80CK4u8doCp6IuYEx1NK5z5qDk3fd8IFdSzsvjeB+e zYnFHtOf5VI6E38/2gWAn/hwbfmGXlCaHmsg4Hc68BFH94ZHm6qmP44r/x94thmzTpW+ xM/jC+e76cNcCIEH+/2K1Y6Gra/O9D/Jg1nNiZnBWVv/pWuIsacpgWuPvf6Z+ALipy4S n25NaqhPH79t6Sws0lv5mZabmovrfVx3BkjZXPB7LE3K0Ns1bQQOCJX1pz4P24X4KjdT 8Me0wzI+HhKpov16I3u/Qi2D0rXrbEBKWlbmhvlZRF+dPNkI7bEDoYxsGUplkkuwaUi0 GEww== X-Gm-Message-State: ACrzQf0ESC9aMZJ1r+YHJUb+jeJPXWm3/i5EcDLN0CsYhIbc9QumRGld PZenpX6YnjXa/Gfj4OAfnAi7Cw7gP98= X-Google-Smtp-Source: AMsMyM47G1JV0zQkUIqQi7w9F+Nyb9Aip+rQziDqknn4FhOr21ryVwJNkD01g5NhWL4CRyFqq/w3jw== X-Received: by 2002:a17:902:e88e:b0:183:dcb7:c4fc with SMTP id w14-20020a170902e88e00b00183dcb7c4fcmr6149478plg.32.1665770081295; Fri, 14 Oct 2022 10:54:41 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:40 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 2/9] gpiolib: of: consolidate simple renames into a single quirk Date: Fri, 14 Oct 2022 10:54:26 -0700 Message-Id: <20221011-gpiolib-quirks-v2-2-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105444_389824_827CC4FF X-CRM114-Status: GOOD ( 23.28 ) 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 consolidates all quirks doing simple renames (either allowing suffix-less names or trivial renames, when index changes are not required) into a single quirk. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 183 ++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 112 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index cef4f6634125..63c6fa3086f3 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -365,127 +365,90 @@ struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node, } EXPORT_SYMBOL_GPL(gpiod_get_from_of_node); -/* - * The SPI GPIO bindings happened before we managed to establish that GPIO - * properties should be named "foo-gpios" so we have this special kludge for - * them. - */ -static struct gpio_desc *of_find_spi_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - char prop_name[32]; /* 32 is max size of property name */ - - /* - * Hopefully the compiler stubs the rest of the function if this - * is false. - */ - if (!IS_ENABLED(CONFIG_SPI_MASTER)) - return ERR_PTR(-ENOENT); - - /* Allow this specifically for "spi-gpio" devices */ - if (!of_device_is_compatible(np, "spi-gpio") || !con_id) - return ERR_PTR(-ENOENT); - - /* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */ - snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id); - - return of_get_named_gpiod_flags(np, prop_name, idx, of_flags); -} - -/* - * The old Freescale bindings use simply "gpios" as name for the chip select - * lines rather than "cs-gpios" like all other SPI hardware. Account for this - * with a special quirk. - */ -static struct gpio_desc *of_find_spi_cs_gpio(struct device_node *np, +static struct gpio_desc *of_find_gpio_rename(struct device_node *np, const char *con_id, unsigned int idx, enum of_gpio_flags *of_flags) { - if (!IS_ENABLED(CONFIG_SPI_MASTER)) - return ERR_PTR(-ENOENT); - - /* Allow this specifically for Freescale and PPC devices */ - if (!of_device_is_compatible(np, "fsl,spi") && - !of_device_is_compatible(np, "aeroflexgaisler,spictrl") && - !of_device_is_compatible(np, "ibm,ppc4xx-spi")) - return ERR_PTR(-ENOENT); - /* Allow only if asking for "cs-gpios" */ - if (!con_id || strcmp(con_id, "cs")) - return ERR_PTR(-ENOENT); + static const struct of_rename_gpio { + const char *con_id; + const char *legacy_id; /* NULL - same as con_id */ + /* + * Compatible string can be set to NULL in case where + * matching to a particular compatible is not practical, + * but it should only be done for gpio names that have + * vendor prefix to reduce risk of false positives. + * Addition of such entries is strongly discouraged. + */ + const char *compatible; + } gpios[] = { +#if IS_ENABLED(CONFIG_MFD_ARIZONA) + { "wlf,reset", NULL, NULL }, +#endif +#if IS_ENABLED(CONFIG_REGULATOR) + /* + * Some regulator bindings happened before we managed to + * establish that GPIO properties should be named + * "foo-gpios" so we have this special kludge for them. + */ + { "wlf,ldoena", NULL, NULL }, /* Arizona */ + { "wlf,ldo1ena", NULL, NULL }, /* WM8994 */ + { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ +#endif +#if IS_ENABLED(CONFIG_SPI_MASTER) - /* - * While all other SPI controllers use "cs-gpios" the Freescale - * uses just "gpios" so translate to that when "cs-gpios" is - * requested. - */ - return of_get_named_gpiod_flags(np, "gpios", idx, of_flags); -} + /* + * The SPI GPIO bindings happened before we managed to + * establish that GPIO properties should be named + * "foo-gpios" so we have this special kludge for them. + */ + { "miso", "gpio-miso", "spi-gpio" }, + { "mosi", "gpio-mosi", "spi-gpio" }, + { "sck", "gpio-sck", "spi-gpio" }, -/* - * Some regulator bindings happened before we managed to establish that GPIO - * properties should be named "foo-gpios" so we have this special kludge for - * them. - */ -static struct gpio_desc *of_find_regulator_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - /* These are the connection IDs we accept as legacy GPIO phandles */ - const char *whitelist[] = { - "wlf,ldoena", /* Arizona */ - "wlf,ldo1ena", /* WM8994 */ - "wlf,ldo2ena", /* WM8994 */ + /* + * The old Freescale bindings use simply "gpios" as name + * for the chip select lines rather than "cs-gpios" like + * all other SPI hardware. Allow this specifically for + * Freescale and PPC devices. + */ + { "cs", "gpios", "fsl,spi" }, + { "cs", "gpios", "aeroflexgaisler,spictrl" }, + { "cs", "gpios", "ibm,ppc4xx-spi" }, +#endif +#if IS_ENABLED(CONFIG_TYPEC_FUSB302) + /* + * Fairchild FUSB302 host is using undocumented "fcs,int_n" + * property without the compulsory "-gpios" suffix. + */ + { "fcs,int_n", NULL, "fcs,fusb302" }, +#endif }; - int i; - - if (!IS_ENABLED(CONFIG_REGULATOR)) - return ERR_PTR(-ENOENT); + struct gpio_desc *desc; + const char *legacy_id; + unsigned int i; if (!con_id) return ERR_PTR(-ENOENT); - i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id); - if (i < 0) - return ERR_PTR(-ENOENT); - - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); -} - -static struct gpio_desc *of_find_arizona_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - if (!IS_ENABLED(CONFIG_MFD_ARIZONA)) - return ERR_PTR(-ENOENT); - - if (!con_id || strcmp(con_id, "wlf,reset")) - return ERR_PTR(-ENOENT); - - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); -} + for (i = 0; i < ARRAY_SIZE(gpios); i++) { + if (strcmp(con_id, gpios[i].con_id)) + continue; -static struct gpio_desc *of_find_usb_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - /* - * Currently this USB quirk is only for the Fairchild FUSB302 host - * which is using an undocumented DT GPIO line named "fcs,int_n" - * without the compulsory "-gpios" suffix. - */ - if (!IS_ENABLED(CONFIG_TYPEC_FUSB302)) - return ERR_PTR(-ENOENT); + if (gpios[i].compatible && + !of_device_is_compatible(np, gpios[i].compatible)) + continue; - if (!con_id || strcmp(con_id, "fcs,int_n")) - return ERR_PTR(-ENOENT); + legacy_id = gpios[i].legacy_id ?: gpios[i].con_id; + desc = of_get_named_gpiod_flags(np, legacy_id, idx, of_flags); + if (!gpiod_not_found(desc)) { + pr_info("%s uses legacy gpio name '%s' instead of '%s-gpios'\n", + of_node_full_name(np), legacy_id, con_id); + return desc; + } + } - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); + return ERR_PTR(-ENOENT); } static struct gpio_desc *of_find_mt2701_gpio(struct device_node *np, @@ -525,11 +488,7 @@ typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np, unsigned int idx, enum of_gpio_flags *of_flags); static const of_find_gpio_quirk of_find_gpio_quirks[] = { - of_find_spi_gpio, - of_find_spi_cs_gpio, - of_find_regulator_gpio, - of_find_arizona_gpio, - of_find_usb_gpio, + of_find_gpio_rename, of_find_mt2701_gpio, NULL }; From patchwork Fri Oct 14 17:54:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007239 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 AFE65C4332F for ; Fri, 14 Oct 2022 17:56:13 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oGlpfTPRyT9fHSQclBfvz4kAq0LGhaXdDzqqg/8Iz5A=; b=LEsZhbDzYWOUFD SoHE+95Xn0JkZVXQBGtP5Nr4UQs5HcjXieiGb1ljOacnArQlaZP8oBYhmOLGHOdrz4v3CSR5xuGSL KU9tMHU1UubSeRkICNIDnDGRARadKGba8ZySjTsrXhPANuAljl1qPsqZm/U9nil7Ug01A+AyO3iMC e7OnyMEqJq/Guz6dCwyfj4szI12pcZyzyKCom5d2XD7ISU4QJOvV5jwa0bMoCrN8sZIWHzAXebPzV YJFt74xhinSJJY8dOHM5GjGGvrlHxqJxTm6TCbA5EZlV7SavJZu0Nqd+K81nTulTa2vF/JLlBoy4x 5982qNQe257TTeWEfd+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOto-00FXBu-5Y; Fri, 14 Oct 2022 17:55:08 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtQ-00FX0H-Rd; Fri, 14 Oct 2022 17:54:46 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d10so5581184pfh.6; Fri, 14 Oct 2022 10:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bWZ+aGOI9zXRffRicNGgT9n+AHk/SzmN5RkqWoKLfug=; b=fOuoZbM/KjXQtLJpXmlUZdf0h5Nn6/Px2oC5XUiQn9ZydwR3x4nYk6bH+rwzR5dPbm SgLxRAhCzrDPIM3ABgllWBkdEDMqpe5P1q/j05LWtiH0IfnlVlLfJHV/CEKctMuVLmBX lljNk27Nac8Jm7tB01ebLFIokCWjW11F5iEqF9Zuk+LBAhVz3BCQoeoPTYRVPS66tSoO LvzjCgHO1oX1UamlmU1uoelQkiPDHKmsc37EsElMWeAigXtFJivGPnFeO2fgDpAR0byB rqNp0sp1B8ZTfSi9hmmlN16nYt5/899wmkZgmqHf4qC65cD5+UsaCrhffmMgJK3cDIa/ PD6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bWZ+aGOI9zXRffRicNGgT9n+AHk/SzmN5RkqWoKLfug=; b=gkXY88IJXIguX947zC+L2zAcnt+kCKG1K68ihlJjvTG5mB+CNy82R9Y8G09n6kDhES G+v01JBgSCkKfL5/TVuCZmLN8LkH6xX8pUlz9S/K01KDx1bcKiwyvOT5hEqQfsOVS9U0 hcX9omT7QUn/oRAA4/gL9H31HklWNDLl+BI8CM2d5JimtmjSVUvXB0IPy7dMaR8YAfxM jxuXz6hw8za6BqUMy5hD+F3v/jlXbfXLfQj7uZT3XogSXX3wLYu8nCvykpvdVfpQduGt Dai8Ny7ZIIniD2iTCo22zcSYHb9VORkuDW8qmaEVOcmCosFRLSuVDdJGfgGoJ/Bcmer/ Kffw== X-Gm-Message-State: ACrzQf1CAMaPh4y0jzghUATw5vUKXeqOZZFx74oXC3k3xvuMKRUe9pV6 XXFdOCXM/hozZl1CnKln/z8= X-Google-Smtp-Source: AMsMyM4bLYjTWsvcYEUC1J7AnVhPw7i51eFEiThG8nor2ElbLxXeKrJsQH1s4tSLb7eLWUt1sd3vtg== X-Received: by 2002:a63:4e18:0:b0:43c:2fc7:2eea with SMTP id c24-20020a634e18000000b0043c2fc72eeamr5688379pgb.119.1665770082916; Fri, 14 Oct 2022 10:54:42 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:42 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 3/9] gpiolib: of: tighten selection of gpio renaming quirks Date: Fri, 14 Oct 2022 10:54:27 -0700 Message-Id: <20221011-gpiolib-quirks-v2-3-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105444_928757_C0F9B874 X-CRM114-Status: GOOD ( 11.03 ) 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 Tighten selection of legacy gpio renaming quirks so that they only considered on more relevant configurations. Suggested-by: Daniel Thompson Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson --- drivers/gpio/gpiolib-of.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 63c6fa3086f3..7d4bbf6484bc 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -385,18 +385,21 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, #if IS_ENABLED(CONFIG_MFD_ARIZONA) { "wlf,reset", NULL, NULL }, #endif -#if IS_ENABLED(CONFIG_REGULATOR) + /* * Some regulator bindings happened before we managed to * establish that GPIO properties should be named * "foo-gpios" so we have this special kludge for them. */ +#if IS_ENABLED(CONFIG_REGULATOR_ARIZONA_LDO1) { "wlf,ldoena", NULL, NULL }, /* Arizona */ +#endif +#if IS_ENABLED(CONFIG_REGULATOR_WM8994) { "wlf,ldo1ena", NULL, NULL }, /* WM8994 */ { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif -#if IS_ENABLED(CONFIG_SPI_MASTER) +#if IS_ENABLED(CONFIG_SPI_GPIO) /* * The SPI GPIO bindings happened before we managed to * establish that GPIO properties should be named @@ -405,6 +408,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "miso", "gpio-miso", "spi-gpio" }, { "mosi", "gpio-mosi", "spi-gpio" }, { "sck", "gpio-sck", "spi-gpio" }, +#endif /* * The old Freescale bindings use simply "gpios" as name @@ -412,10 +416,14 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, * all other SPI hardware. Allow this specifically for * Freescale and PPC devices. */ +#if IS_ENABLED(CONFIG_SPI_FSL_SPI) { "cs", "gpios", "fsl,spi" }, { "cs", "gpios", "aeroflexgaisler,spictrl" }, +#endif +#if IS_ENABLED(CONFIG_SPI_PPC4xx) { "cs", "gpios", "ibm,ppc4xx-spi" }, #endif + #if IS_ENABLED(CONFIG_TYPEC_FUSB302) /* * Fairchild FUSB302 host is using undocumented "fcs,int_n" From patchwork Fri Oct 14 17:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007241 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 BBA7CC433FE for ; Fri, 14 Oct 2022 17:56:35 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hJozvPqpiCUBN1g+MeE+op84cqS9Tv/VV6XexSwYzRw=; b=TsdGAzqyQBwZmx hn5e80onsst2JWPoIYTkdxLMkGXq25FvYzjrz2OaeVZZNjRtIquZnj3jCy31/ptkmeMXR0al2Jhfz A/gTIzO7C7TMVtw6qLDVkA6xKfWUfCstt8bKzGF6of75O87YRFAshmakhc8pij9grDUrXz3Heg2m9 A1i4n0pK/Qke/a1u9uWPya1dRtDlncUzdO42D1gU4ruDp5fzvRxFmBC9+HMJulpMV7t68XZ5xrDUP 0DkVri+gKF7DZ3xaDTg5vHPqGfzviAxh6Dm2N3Gi/WM+r395q4cAJZYAXlNrPbKvtKf/a5S+JQlIy SFJuq8+PsLc2yU0Cn9MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOuG-00FXPY-6n; Fri, 14 Oct 2022 17:55:36 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtR-00FWzL-6N; Fri, 14 Oct 2022 17:54:47 +0000 Received: by mail-pl1-x62a.google.com with SMTP id l1so5396410pld.13; Fri, 14 Oct 2022 10:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YV6Nxa393Zempvv48DGSX3qqsS8tBZ+cvvfhAdg2hN8=; b=hwC+mpYbil+uUfrrGEvi6q5Oh8PUE3JdtPxYi+K/8CTb842BUQ8RKXbwcPRmk6LcLE 06fqPcitEvEnh1os3P0z6agizAe9Deq4xAZ30T2wH647kIPkjh5I44n16FDPadB1H1rD w5MaAbTRkAi8LbHFtGq/8NUJl4plyS2YhyMaVepHko7xDpJljO6CyjzDS73F4tHyDCUL Lq6XZJGEC0IKVDNqAfBksg8iZwwj8AI4F9UehOCtO3lNFWrbxthPLbiknRH9Fq+wwsXQ QK4GxMso3gnnhY9NLG/v9bnDG+eqNEHjut2fJPEVCvczUSc/EcJsFwVGCzV8RFhgpD4e 6NCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YV6Nxa393Zempvv48DGSX3qqsS8tBZ+cvvfhAdg2hN8=; b=U6aVCHat/v/NC87/mWsWzDoT6Yb1YjQYARvwAmLsDWRTZWzk+7nyHyhiScCFahAWF8 Kg+K53k8KzjZSGG6S9hszNA5AWNnZr+pi7NbD9hqPJfg7fACffKukS2jXYkhRLVOVI/Z jq60hOdSeX9v3lMQOyM0r1uUwRvoguBMaHmLGQ+84pkYCHnYpCfs0TQWz4dB9qaQqbUF nBgcySQuocsvi9oi5RybSSof2hgXjSLZUIhxSZlkVm67XunYxVfCo+mjPA4ng0uvMA4I jeZiGdtUT7Q7QiG1qnQXmnyduOtHEn26pxsJEL+pjH17wBCho7rczBTvDqhv4REO5Wd+ qd1g== X-Gm-Message-State: ACrzQf3zNKupWlx4x4IQiN9QszmS0GaomQQ1Qpa5G/VIK9DiXkYU3gHW KsdS9zyRuiayJzUDA4OuP8M= X-Google-Smtp-Source: AMsMyM4UJN/MfIJhz+fb45nTKPD8eMsnAGrApUkaCX+Tmu1QtkZTx79R7xkFMxVviLuT0TKQANgcvQ== X-Received: by 2002:a17:902:ec81:b0:185:3cea:6326 with SMTP id x1-20020a170902ec8100b001853cea6326mr6596411plg.24.1665770084657; Fri, 14 Oct 2022 10:54:44 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:44 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 4/9] gpiolib: of: add quirk for locating reset lines with legacy bindings Date: Fri, 14 Oct 2022 10:54:28 -0700 Message-Id: <20221011-gpiolib-quirks-v2-4-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105445_301337_397832F6 X-CRM114-Status: GOOD ( 10.43 ) 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 Some legacy mappings used "gpio[s]-reset" instead of "reset-gpios", add a quirk so that gpiod API will still work on unmodified DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 7d4bbf6484bc..2b5d1b3095c7 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -382,9 +382,18 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, */ const char *compatible; } gpios[] = { +#if !IS_ENABLED(CONFIG_LCD_HX8357) + /* Himax LCD controllers used "gpios-reset" */ + { "reset", "gpios-reset", "himax,hx8357" }, + { "reset", "gpios-reset", "himax,hx8369" }, +#endif #if IS_ENABLED(CONFIG_MFD_ARIZONA) { "wlf,reset", NULL, NULL }, #endif +#if !IS_ENABLED(CONFIG_PCI_LANTIQ) + /* MIPS Lantiq PCI */ + { "reset", "gpios-reset", "lantiq,pci-xway" }, +#endif /* * Some regulator bindings happened before we managed to @@ -399,6 +408,13 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif +#if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X) + { "reset", "gpio-reset", "ti,tlv320aic3x" }, + { "reset", "gpio-reset", "ti,tlv320aic33" }, + { "reset", "gpio-reset", "ti,tlv320aic3007" }, + { "reset", "gpio-reset", "ti,tlv320aic3104" }, + { "reset", "gpio-reset", "ti,tlv320aic3106" }, +#endif #if IS_ENABLED(CONFIG_SPI_GPIO) /* * The SPI GPIO bindings happened before we managed to From patchwork Fri Oct 14 17:54:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007242 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 A9EFAC433FE for ; Fri, 14 Oct 2022 17:57:07 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iJqWWW8ReYC6tTQIj4vmZSHkuvqsoiuJuC5oyjlWC94=; b=DTaXIN+Y0cS12R 2zaYTw7oCH1cED3z+9jNQuRCu3uGzEHjnzD4ctgS57Io2INprsCp/9/RK2ha5oyNEIvdxZDPtbZC9 gdLB8bhzAJW05UcrBZ0QbU90kHI5E4NVfNqJmvWaZshNP7uR034BKZQlt1Z82wIocZsZaeGaXgui7 tc/x1NblcONNI4UaFmDzan01QDTtYPQCfr6gMwgiYcaIebSNkdtIHaBp8V3i2s787LOBBnTC21JSX pUdwYMEzdC8EkQmtcBJPcCM3oG6bUqgwsbohb/zD/xSvH1Wo9zj5CT9tyB6t2IXht8Jp8E7wWJur3 3wYiC142sc3ok5wtnDoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOuc-00FXcK-Mm; Fri, 14 Oct 2022 17:55:58 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtV-00FX1z-7d; Fri, 14 Oct 2022 17:54:50 +0000 Received: by mail-pj1-x102d.google.com with SMTP id o17-20020a17090aac1100b0020d98b0c0f4so7203448pjq.4; Fri, 14 Oct 2022 10:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BX6I3wxmmC2re4tlQ7azHaY51bTZUH4nJgPdj4ITZq8=; b=cyugA0yHJUN3qAYBEX22+gvLsKzT0Qskj8CNA+ZBQPAmGtgf7tK+Sy7JA8OTpXVWB9 YXCtr/IhxkTKGg6wXcjDhbXvGxTbLTOZI43n2iC2HOissspE74cppc0sruSR9JwaR+Vz Eoc1W/ULVDcc5A7omUhw68ovv7kBCrPWVoPjH4eiFFybdVWKDgTTp/IqST7suQo+y58g MeR1NqyDiYNodnBCHIGpogo+vlERi25f/glW2sbIkJC+RsL+O6Dc0JqqixOttVYHuVzn hPVgOV7m0N/1sNNDaKuOtKopFleKiT9qgs1E45fHsq6jbfTzWqe69zPvrCMo/fl4TqzN DbkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BX6I3wxmmC2re4tlQ7azHaY51bTZUH4nJgPdj4ITZq8=; b=XlV9jcbqu8xSrki55kZLkyn7rSjbowrgDpu0/9oSPauWV/k/v1zFJRqDRRi4C1bMyz MnnAW4eaY3t1K7GRsSx6YN9QbNrArNg0Ek9Lcl7pCjQ/4bnsLi2UU+Q9W3Hcw02aT7oq eALuY5K5K3zxxCnhKb4qfUEckXYNZ7vKjX27/2TZGHjuhtVTVyGqpVA8DTNYvVn+wBWs P4PTDV/otAEEL9db7tQzLvOfwWR5F0rbRyswtKPXjTJSo81tyEKcZ2oqWL6SwBftG3/O aYxADIMLPl0FBID2z83mnym4nIxHOJ9qo9fbiIqzoUCwZzbqJ6vaqvPUz3gwQuYZP6Xz 7ZfQ== X-Gm-Message-State: ACrzQf1j4ExGzp//9LMv5u7CVelCqRjj+9JnpH32GqdTLeVcKvJFJzTY DSyfLWtQhNvivu3l+8O4aGc= X-Google-Smtp-Source: AMsMyM6HJMSW8eaOV/L8mdLS4/siuzIHXjCFIiLCzS5TaBfYxq818U8i5HSUDm/flCBDm5MDoy8urA== X-Received: by 2002:a17:90a:4311:b0:20b:e232:5920 with SMTP id q17-20020a17090a431100b0020be2325920mr7199880pjg.190.1665770086268; Fri, 14 Oct 2022 10:54:46 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:45 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 5/9] gpiolib: of: add a quirk for reset line for Marvell NFC controller Date: Fri, 14 Oct 2022 10:54:29 -0700 Message-Id: <20221011-gpiolib-quirks-v2-5-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105449_294959_1B407BFA X-CRM114-Status: GOOD ( 10.81 ) 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 The controller is using non-standard "reset-n-io" name for its reset gpio property, whereas gpiod API expects "-gpios". Add a quirk so that gpiod API will still work on unmodified DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 2b5d1b3095c7..5c11ee7638d1 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -390,6 +390,16 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, #if IS_ENABLED(CONFIG_MFD_ARIZONA) { "wlf,reset", NULL, NULL }, #endif + +#if IS_ENABLED(CONFIG_NFC_MRVL_I2C) + { "reset", "reset-n-io", "marvell,nfc-i2c" }, +#endif +#if IS_ENABLED(CONFIG_NFC_MRVL_SPI) + { "reset", "reset-n-io", "marvell,nfc-spi" }, +#endif +#if IS_ENABLED(CONFIG_NFC_MRVL_UART) + { "reset", "reset-n-io", "marvell,nfc-uart" }, +#endif #if !IS_ENABLED(CONFIG_PCI_LANTIQ) /* MIPS Lantiq PCI */ { "reset", "gpios-reset", "lantiq,pci-xway" }, From patchwork Fri Oct 14 17:54:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007253 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 99DADC433FE for ; Fri, 14 Oct 2022 17:57:57 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0sMbB3pvD4UPvgqcnE3MTCiPkLJKo/RRLfnfApBUTNc=; b=giceUBP5RNEijE dqhUtdqQmWqyxeS1dN6xU9zIX3ToF0AVBI35FnfOc/ETK16K2tgbVpPAtpkH4OyLlMSME2JqdbLN5 Jm7zSQYRZvlmFy5z2kpj0wTA44h5+iyTKe4NdDqORnjxNs9I0RLuQLQ/c3sfMwCamjywaTh8Fa2fF yi4iRdfPRTvI1X2+3GfPdurjtktZ/3becwC7fX0Z769DUgqZ2Gw3aFDHQpyzHJN44fX8Xz90XCyl8 NGe0/87v26zLr2I8FVlgFsVXpAcPBlY2fCF5FJWuFvUlPlQ1e7qIIYRmtc5/fQzn5C5pPyr+z0rc/ MrCC/bfysdDoyavUBwLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOvO-00FY2K-2y; Fri, 14 Oct 2022 17:56:46 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtX-00FX2d-RU; Fri, 14 Oct 2022 17:54:53 +0000 Received: by mail-pj1-x1034.google.com with SMTP id t10-20020a17090a4e4a00b0020af4bcae10so5395597pjl.3; Fri, 14 Oct 2022 10:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hifOoY9aqLLHbcQa2d9K53VxHn7l+VlC4N3fss0zE6o=; b=TrpvH1TyIPvuJXDWY1g6ts8rJV3gvM9Nm0JNTBhFYpx2VK44z8Rht7w/Ag7is45ey3 5ezFxZHhpI1YuXCQLbvQ5ecv06+V+SpA8r3lf/wFqfbcgHg5EQdjS2WVhz1pQNfTH8mw 66b2PU7ve2MOYaj8Nme0hrcf44ijbJ7sLBuHf9KH/FcrhkMupMn0xH7cQ80fAJa1R7uo AJ0nAeFYhJKaANAWnQj8t4Ny1oxgPj9ldWk8x9jBk/mz5+5Uh893cGshBAVNMPpVORGV Vnbw5tMxeBSEBR0PeLMJWfW7uuE7fsZLMNQrIgS7369saBkiEQeJV6Y5zPq0r3LNSy6l ahqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hifOoY9aqLLHbcQa2d9K53VxHn7l+VlC4N3fss0zE6o=; b=bV+BJ2E6eysYg4OZF2G/R5d4/ub3qC90uHXZVQlUsZA45lHfTSdrPxuBysJzlVBrcu Xn5d2F85okh7zvWChGh6pR2D1rBNktWPB+7kwgC9hS/RaKDNhNwqrZkm6tNWs9EGlha3 xvF7DX3x65UL2z83pYi9lQ+hafi7WrulTIsKs7OSWGUl7hhGp8BmtbWZwTCR0EEvi4py H7IY4GqC/lJt8zRAUdoNOYhaHNiAYq7pdvErxDMCLV9A6VHQWOzMIOc9EY5pvYkZQ+j2 L9LypqhkJ7UJV0XICQ/Ms2dtB984wDvwqMbFP9xpr9cbIVsa1OcV7TEdrn2dyppcafFp PW2A== X-Gm-Message-State: ACrzQf3plsMj9o5bH9cjFpUUsjnn/WwC/enhEXgNrSmebmITd2LVSFPS JaSjS5T6DBVY/TvP3wvckIs= X-Google-Smtp-Source: AMsMyM7wLkfeK7I1F9q2E31QSGa2I946SkJ4WKVNKK++Nlyyi1mDDFQDfViwRLKauuXRwbgorVoV9Q== X-Received: by 2002:a17:90b:1804:b0:20d:a753:7d4c with SMTP id lw4-20020a17090b180400b0020da7537d4cmr11027033pjb.78.1665770087982; Fri, 14 Oct 2022 10:54:47 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:47 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 6/9] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Date: Fri, 14 Oct 2022 10:54:30 -0700 Message-Id: <20221011-gpiolib-quirks-v2-6-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105451_913416_933C4082 X-CRM114-Status: GOOD ( 10.49 ) 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 The controller is using non-standard "cirrus,gpio-nreset" name for its reset gpio property, whereas gpiod API expects "-gpios". Add a quirk so that gpiod API will still work on unmodified DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 5c11ee7638d1..77cabcfb2da0 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -418,6 +418,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif +#if IS_ENABLED(CONFIG_SND_SOC_CS42L56) + { "reset", "cirrus,gpio-nreset", "cirrus,cs42l56" }, +#endif #if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X) { "reset", "gpio-reset", "ti,tlv320aic3x" }, { "reset", "gpio-reset", "ti,tlv320aic33" }, From patchwork Fri Oct 14 17:54:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007252 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 A32C9C4332F for ; Fri, 14 Oct 2022 17:57:32 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bl27woHTflCuADlLjGEXmM3ZV6bwZ0WUHiZHOCz5yLA=; b=HYwmyfSowaI0Y/ pvzuW+FK5GhNW4747me/WIA+wQ5WusgYq6ChhHQbgwT0eTLzHGdB/HUpAgby7QEDF0loCdfduzu4K ItprU4UH11Y68XFkTHMPF0sXfrE+fQNtdV9C6RcX7Vuup76IjTM+dbsQChBU+RZSMX5qTKugrhkGy TwvO1IvU2XMLXaSED5EM8Gqoq/AtL6BBNk6/ju67WqXAkcdGKr5Hikw5FfVu7+PPSVyWAimwgf+3M m75rKARkYCVbaoiCIJGsQ6zlKkR7WXX1ffb0nvMPyZH8oYE7lA4bevl8R1DT/AKtjzZ5AmpSO9co3 2kGxutz/f123eK4Mb7ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOv2-00FXr3-H4; Fri, 14 Oct 2022 17:56:24 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtX-00FX34-Er; Fri, 14 Oct 2022 17:54:52 +0000 Received: by mail-pf1-x42d.google.com with SMTP id g28so5564336pfk.8; Fri, 14 Oct 2022 10:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ovCPxMNt0i2khQD9ZbKAf0f91ILluT414D5KLsvMtco=; b=HFcFHjwS441SSkOj2EJ1i/jFRuzEakkG04P1ZVLhsWdMbttmks0f9yASxRbQ+IxNaE ggb3CdzaZiF/gVxcQBPV3QBVIKdyiCHTe/Nly27/svHyG7uLM/9OhOyd+HoZ15xDXlaD iBI2BGmq08sbu7um1fTyd/8xp0UtGkVbN0csB9w48mZqveth8tibXU/H5lgv2WUm50sA zPbnn5qnr1C6sIsWxG3Nw7728oBpZ6wF2vGQVylCqAou7OxRxyCIVnc7kxkDgW0//+by 2oG9ckqMUXCWzlxA2cm/wq1N1z/l+MA5/iB6X3lTJj2JA7TU/QxRGA9+38YDJwMLsIJA tBmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ovCPxMNt0i2khQD9ZbKAf0f91ILluT414D5KLsvMtco=; b=Dep+qPVxvvABT9IL3vR9H8VYvshlDSHbDElQEIiBWOoTTXUnxgkuuPJq93pR2R7ocH S9uDpZd7Tlf8EnM0WGL3ZJcxpL6dW0KA2dQEDAzKZWCmoqL9YH7ls7GeaGhBopyQoofB vjjDyLLhd0EHHGD4DliqclPRPardiniO25iNMe1iKcTZHL7jV4hS3f3vIrW8zXhuTIIl Fzat8a2BhSkFUS9q61gBySF7+wky10GlRNsQbDUA3rM6e0MQYt4H22keBDfXgEcFaT4W tY9zAe+hMDXDPZJ409skq1nRnK7qGX5uFx//OTxshZAT84g68O/cqLkaBSfIDNvjAYRw 4ipw== X-Gm-Message-State: ACrzQf2o8sY1jkrbyf3C6yghkhXZd2WWF/bM7Z1iBsQNNSNMEtredLf8 PsIWoIv3y5EJyqbq358grfo= X-Google-Smtp-Source: AMsMyM6YUtWU5/7XIn6e546c/3iIZbpvRvrknueJ+/lzyJPczhtaZQfwcuNJEVFLnkVq/P2M3qeC8w== X-Received: by 2002:a05:6a02:28b:b0:439:19d6:fad5 with SMTP id bk11-20020a056a02028b00b0043919d6fad5mr5672694pgb.591.1665770089619; Fri, 14 Oct 2022 10:54:49 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:49 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 7/9] gpiolib: of: factor out code overriding gpio line polarity Date: Fri, 14 Oct 2022 10:54:31 -0700 Message-Id: <20221011-gpiolib-quirks-v2-7-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105451_527142_A8D88F5E X-CRM114-Status: GOOD ( 14.16 ) 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 There are several instances where we use a separate property to override polarity specified in gpio property. Factor it out into a separate function. Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 48 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 77cabcfb2da0..da274d9adcdf 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -130,6 +130,28 @@ bool of_gpio_need_valid_mask(const struct gpio_chip *gc) return false; } +/* + * Overrides stated polarity of a gpio line and warns when there is a + * discrepancy. + */ +static void of_gpio_quirk_polarity(const struct device_node *np, + bool active_high, + enum of_gpio_flags *flags) +{ + if (active_high) { + if (*flags & OF_GPIO_ACTIVE_LOW) { + pr_warn("%s GPIO handle specifies active low - ignored\n", + of_node_full_name(np)); + *flags &= ~OF_GPIO_ACTIVE_LOW; + } + } else { + if (!(*flags & OF_GPIO_ACTIVE_LOW)) + pr_info("%s enforce active low on GPIO handle\n", + of_node_full_name(np)); + *flags |= OF_GPIO_ACTIVE_LOW; + } +} + static void of_gpio_flags_quirks(const struct device_node *np, const char *propname, enum of_gpio_flags *flags, @@ -145,7 +167,7 @@ static void of_gpio_flags_quirks(const struct device_node *np, (!(strcmp(propname, "enable-gpio") && strcmp(propname, "enable-gpios")) && of_device_is_compatible(np, "regulator-gpio")))) { - bool active_low = !of_property_read_bool(np, + bool active_high = of_property_read_bool(np, "enable-active-high"); /* * The regulator GPIO handles are specified such that the @@ -153,13 +175,7 @@ static void of_gpio_flags_quirks(const struct device_node *np, * the polarity of the GPIO line. Any phandle flags must * be actively ignored. */ - if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) { - pr_warn("%s GPIO handle specifies active low - ignored\n", - of_node_full_name(np)); - *flags &= ~OF_GPIO_ACTIVE_LOW; - } - if (active_low) - *flags |= OF_GPIO_ACTIVE_LOW; + of_gpio_quirk_polarity(np, active_high, flags); } /* * Legacy open drain handling for fixed voltage regulators. @@ -200,18 +216,10 @@ static void of_gpio_flags_quirks(const struct device_node *np, * conflict and the "spi-cs-high" flag will * take precedence. */ - if (of_property_read_bool(child, "spi-cs-high")) { - if (*flags & OF_GPIO_ACTIVE_LOW) { - pr_warn("%s GPIO handle specifies active low - ignored\n", - of_node_full_name(child)); - *flags &= ~OF_GPIO_ACTIVE_LOW; - } - } else { - if (!(*flags & OF_GPIO_ACTIVE_LOW)) - pr_info("%s enforce active low on chipselect handle\n", - of_node_full_name(child)); - *flags |= OF_GPIO_ACTIVE_LOW; - } + bool active_high = of_property_read_bool(child, + "spi-cs-high"); + of_gpio_quirk_polarity(child, active_high, + flags); of_node_put(child); break; } From patchwork Fri Oct 14 17:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007254 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 98001C433FE for ; Fri, 14 Oct 2022 17:58:23 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rVKAE+krjMc/NR/fxlmJQe/7YumejDlV4diNWPTp4Pk=; b=c7evDLSoaX0ezi XOE9DSpuz9IY1uaBtQgwVkd2pCqd1N6WiVeVni+7e+wIQJui10UNZlDavAyaowQbGUqIOfMocyWQQ yy5w0DbKyGBtln9wauFwfBev7CPPA6DNkVJQcUAh43yg4vMOyawfuHXnlwViZcfXnE3M+FVeIMPHe at2/nOdbpUb/ePPdRBY3Ur14J7vQRB+IL5LaqEf/hY58lAS0surAZ3gRuHob1OkoPqmnMIaycHgjZ p5ywf0CUv6P029vFmlC06M5mX3az4MFlLQRuAchg6AJSbuNvbGRv5PWK2xaBtJxjvlP7ZZzCJKOZo b18n+iKieudSGDdpJ8fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOvp-00FYFq-Sy; Fri, 14 Oct 2022 17:57:15 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOta-00FX41-DD; Fri, 14 Oct 2022 17:54:55 +0000 Received: by mail-pl1-x62f.google.com with SMTP id c24so5413601pls.9; Fri, 14 Oct 2022 10:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ItwD3cs9eKU04Q3Z4ewr71YmDkGz4wd+DL/2Fjg5hWk=; b=qrN4P68onQDZsUtaXu/yhnboZR61v4aI0p4hv6B8PSm6Qxn0fOoSKoWHQxyw+tbOpf fmCFR20jX80FgTYk1BJSbrGyTxEoKkwt1SD/FyN2jTj1YWZqpLu6GW42zQjYb6xdcWe/ tsNA2gGGmbJW+SsAdU3tq5p40BmHJZSxcgQObb6bQQothniQbLmsMn4ia0nvyZmVJRWK NHCQgAGBG+zOwUYxO9181oLcE0KCcM+si+09N8pLU5yrX+LkEcCY/8kMe4ymQdJcywIP eEZf8ToJR0AA0yLP6uz6Fz3vqlZVg4/xWhPK1mzsIqofcqFTn3cz/zYmjok2MhzEEx6F JHAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ItwD3cs9eKU04Q3Z4ewr71YmDkGz4wd+DL/2Fjg5hWk=; b=wHg83bf63RtRjl6OQ00AUt2SeLQONFktZrDj6f15T3w+g+raiCb3XcpwNiZdEEj0gK hXuKVIR/IcFwnwxkfVjjG4Q7QhniDnwgFbZEQsttpGHkN+4pPV23c+MyzYi5mhOEEFP/ Jq65cVHY7UovqG2myJjk1iskIgjx17kD+jn5jj7Ho15DuYe4/e/Mi8/evLHRQnf4Vj0J 2oAwlNm//n7PLVmjANCkhkJWbSAgyyGcnqE0Z9Sq0tyV8hzQKaFoCeaO0M5KPUhlybI6 5EAtfRdLam3ofS4USkAyWp9YBOkFj5ALT/4C578Na0xH+CRcpXGbfNJ3V6PmSij7HxZU aPAg== X-Gm-Message-State: ACrzQf318GuVTXuNcjJYBXHVwuISfJB3UBagbaKICaUBZbzo+DwDdJFQ jwHhKpJktO5OjGmjYPcx9e8= X-Google-Smtp-Source: AMsMyM7G6avsisY9dI9QyeETgZIog9Vw/1K3JMS6R5u6NAboiuA4lkzcXvuoyaM2vIsJndlNcEyA7Q== X-Received: by 2002:a17:902:ced2:b0:17f:5eb2:cd72 with SMTP id d18-20020a170902ced200b0017f5eb2cd72mr6277520plg.162.1665770091373; Fri, 14 Oct 2022 10:54:51 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:50 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 8/9] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Date: Fri, 14 Oct 2022 10:54:32 -0700 Message-Id: <20221011-gpiolib-quirks-v2-8-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105454_473746_A9070CC3 X-CRM114-Status: GOOD ( 12.06 ) 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 Bindings for Freescale Fast Ethernet Controller use a separate property "phy-reset-active-high" to specify polarity of its phy gpio line. To allow converting the driver to gpiod API we need to add this quirk to gpiolib. Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index da274d9adcdf..805222a2e6bc 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -231,6 +231,33 @@ static void of_gpio_flags_quirks(const struct device_node *np, !strcmp(propname, "snps,reset-gpio") && of_property_read_bool(np, "snps,reset-active-low")) *flags |= OF_GPIO_ACTIVE_LOW; + + /* + * Freescale Fast Ethernet Controller uses a separate property to + * describe polarity of the phy reset line. + */ + if (IS_ENABLED(CONFIG_FEC)) { + static const char * const fec_devices[] = { + "fsl,imx25-fec", + "fsl,imx27-fec", + "fsl,imx28-fec", + "fsl,imx6q-fec", + "fsl,mvf600-fec", + "fsl,imx6sx-fec", + "fsl,imx6ul-fec", + "fsl,imx8mq-fec", + "fsl,imx8qm-fec", + "fsl,s32v234-fec", + NULL + }; + + if (!strcmp(propname, "phy-reset-gpios") && + of_device_compatible_match(np, fec_devices)) { + bool active_high = of_property_read_bool(np, + "phy-reset-active-high"); + of_gpio_quirk_polarity(np, active_high, flags); + } + } } /** From patchwork Fri Oct 14 17:54:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13007255 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 035C6C4332F for ; Fri, 14 Oct 2022 17:58:57 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DzP1OMBkEChLIkJEPVbey3BC7TAy69CNC/6GV1RMM8M=; b=IrK6or9ailPFsn 9YgXZJ69G6noK70CRZD2sRxf1ZEyTQVsVl4CzOMaDuIVl6I7AIT+NPExKR33emOwRtTYFLjV8hk8R plxxEoxroejMb7De8B/71fCeE4PVToGsD3zD6m2aa8i9CS5O7F5kMz7s6OzJaXgnh2suaan0tb/q8 xeH7ey8IE2slVdGUVHohkeq2Ls08Ytf3ROErgb3pWuEO6rkypCY5OdfT7sHqruvNL0Km9oZsKQQzd TBdNVR6Qo7oyfg2zr3azFRsRyV8Kc2kCcaaK490oLDab6BQFKLUxsHGAwPE7110fiMKGYhj8HBfK8 G1kjShiYFhY74cDmZK2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOwT-00FYai-Bp; Fri, 14 Oct 2022 17:57:53 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojOtc-00FX4e-1D; Fri, 14 Oct 2022 17:54:57 +0000 Received: by mail-pf1-x435.google.com with SMTP id y191so5597861pfb.2; Fri, 14 Oct 2022 10:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DDr9juWg3u7tqOqaJOOvY3u67HoyFj37SYo8BbenwWk=; b=K7/WyOZWPb1Rs6hBURYIqASCfJWT2Ypv8TwWdxwKsLl76h3ZM8LE9cDiE5sYUXXgED ypzOhURY5d09mWMjlYXc+SII8+wsHvMD0gUy/765T0ggM48TQeRCi2+CiNUwNMaSdFku noZF0GhcUdMc3nnH5TB3bLmnSRcg5QqRVQNtPJi2ZTTQhL0YHsV+H0wnGfopeE+nioAb UGmP8/p89sY7HGR6q8RjE92cv/+mU4BSXLJ2ODAfJG8ZlKLXp+F7ni24WTCFu3JqhHn8 PKB83IW8xGp0+2jZiGDFfWo0PHN41mnnCau1ep5hAiJ0GbxMfviZTW0IF77tiTyxu4Ye U92g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DDr9juWg3u7tqOqaJOOvY3u67HoyFj37SYo8BbenwWk=; b=YREThcdIIVGxh5f+WZc7vIvf9vM1pxbyJs6S7wKeQCTxJnOzuF5bdnwSlCwnX5g+8L 3b2IFZm5KT6N9oaUCT03RbIohUaW05GqDt9L1wzLoPeTBrKl9sFL2hUYDaCNWLb5HYwL OJliWlVsGwGfru8/GRAz+MQqoXh7TA50QHzFdCR5xHbh4P2xDjOlFvr0Ex3unV9vRIhx jH/qT240fodqvEc6yzZFvwQISpMlqd4ndi+7jY8CSxvLMhcmQCwyGnBBYp28xpongGsF 0NZLcnbzbR9QNlybupuSlKY2yHLZnSuYnlFCZVl+I+mx8HUinyKHNvpPucwU3KzIYi/Z 7YHA== X-Gm-Message-State: ACrzQf3wDRrXT32Ik/vE+p6z1eIw95iKo8UR1RxAloTRMdFUmwRWHA3V GsSxNbyjv6ToMS14EyY8/Uk= X-Google-Smtp-Source: AMsMyM66Ubh6jeHbtdegqbobjzrs9/DILurRSxW9pjZiIKKLcEoBNq3fQp7n84VpA3gI2fuXewHT1A== X-Received: by 2002:a63:1d22:0:b0:439:3e7c:8af7 with SMTP id d34-20020a631d22000000b004393e7c8af7mr5605142pgd.78.1665770092947; Fri, 14 Oct 2022 10:54:52 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:52 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 9/9] gpiolib: of: add a quirk for reset line polarity for Himax LCDs Date: Fri, 14 Oct 2022 10:54:33 -0700 Message-Id: <20221011-gpiolib-quirks-v2-9-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_105456_108022_2C880442 X-CRM114-Status: GOOD ( 14.85 ) 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 Existing DTS that use legacy (non-standard) property name for the reset line "gpios-reset" also specify incorrect polarity (0 which maps to "active high"). Add a quirk to force polarity to "active low" so that once driver is converted to gpiod API that pays attention to line polarity it will work properly. Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 805222a2e6bc..26d57465fec9 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -152,11 +152,47 @@ static void of_gpio_quirk_polarity(const struct device_node *np, } } +/* + * This quirk does static polarity overrides in cases where existing + * DTS specified incorrect polarity. + */ +static void of_gpio_try_fixup_polarity(const struct device_node *np, + const char *propname, + enum of_gpio_flags *flags) +{ + static const struct { + const char *compatible; + const char *propname; + bool active_high; + } gpios[] = { +#if !IS_ENABLED(CONFIG_LCD_HX8357) + /* + * Himax LCD controllers used incorrectly named + * "gpios-reset" property and also specified wrong + * polarity. + */ + { "himax,hx8357", "gpios-reset", false }, + { "himax,hx8369", "gpios-reset", false }, +#endif + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gpios); i++) { + if (of_device_is_compatible(np, gpios[i].compatible) && + !strcmp(propname, gpios[i].propname)) { + of_gpio_quirk_polarity(np, gpios[i].active_high, flags); + break; + } + } +} + static void of_gpio_flags_quirks(const struct device_node *np, const char *propname, enum of_gpio_flags *flags, int index) { + of_gpio_try_fixup_polarity(np, propname, flags); + /* * Some GPIO fixed regulator quirks. * Note that active low is the default.