From patchwork Tue Oct 11 22:19: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: 13004482 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 32E13C4332F for ; Tue, 11 Oct 2022 22:21:03 +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=iZsrqa2Gnmuo77ozaA6COWeIsPwrd7DUxquXL7DfaOk=; b=mETMSCpcDZdOni en4pxnzuVcNJdiwWrqQrX/RzgX1EXBmIITsP+P//5hg5uKsd5knxmL/Ogf9uEXCJUSZUu91QAJmqS pZrzxDFdo2DkQYYwPDIqc+yM3nj20YkQLaxa04HsrjzwLKJp7mr1MTca2i8SCuDMAaLIXAe21LiDm xYHZrWa5tkJelIiZ14ogvZ11yLk1hmJN+NjgGmZmv4/oi07P4HxiBGu4PPS3cT0PoiYYkEyy4w2xo fQvF7jyqp/vnDMAHFu61gyyyuHQG0FeACuixestmt0nXD1+YkJUKYgQMkWuL2xuRRNz3ybPvYZ0/q vWHQLrZ2Yz55xJu+AKTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbR-0060R8-00; Tue, 11 Oct 2022 22:19:57 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbD-0060L7-LB; Tue, 11 Oct 2022 22:19:44 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 128so6230400pga.1; Tue, 11 Oct 2022 15:19: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=nhyRfNRLvXdJqTEKmbHvJb0Krk3UyiSQItTbwFfBY0Q=; b=jekSfU6bSssvmSN6shHkFWzrkqwUP6Dh/I247pcSVjamDvq77Ri2F9VMB/FIyTDdU/ w0sU/ojt3oZmKldccy4LMbsGFnOzpO5ycXuU3U7Qx+8NMcuNz7qV8uvgzCYxBLr5lnZ0 kh397lLEPgMfrGz3Gv3JGpMrS5JvyMfMg2xj2KtgWiRelv0vlPbiIZx4W2EDhKe2KeAI qQ+t2OUCyW6ZmkjXGirtbFHctLXhqnZlNAx7EwIh/7SKTIs8vwioNVeObW5JcKoXXQBc 13p8PQBW6YqrxYpNqBSniLLbFiNNcgsCa49FEhitXvBMudkU907TTa+zp87QM1kVNj5X cagQ== 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=nhyRfNRLvXdJqTEKmbHvJb0Krk3UyiSQItTbwFfBY0Q=; b=b3g45Sl+YgRjvYBUyHE8DcL7TiAoA/N2ysCegd5Vnty7Q8ELBrAAmUtpXQlhHhhOHJ 87slUqcA/j5/hSCilqeiSaAQOlbZTktgMtuVHn5vZgNdOjJ3T4T0KQU92EEVWbZdNcWi 0jZVwpohmuyJBGy2PR3ULxP0nMauaX8xsjtMwi7p9AIqRnf2old6D9FDdilNdKf0n+Ir rbyO4stCoY/9GXMIwXj/8i2P/fjiTjQ6tYXZ8nErDMINo8FvyWCG9iK/0mfmwk1BWZnH CNi7oItVohkZVZ9T9WXGkHwwHrBxU6Aioivf5/+7x6IQc+8ApViuY3sYvKQtYM9fa5m2 WLAw== X-Gm-Message-State: ACrzQf0WW6xgbLbZEtsGaSgjZSNQ4lVtL6zBRGH1441TtTzTPH//ZC9z 0SeD6UvJwNwOZVbwq9eWocw= X-Google-Smtp-Source: AMsMyM6LQqmkoRXYQmKJL9XWaaA+rIB+jKj+cYC4OTvZazSGvk1PtVlLhh+08LP/j2Coex+D1iWRHw== X-Received: by 2002:a05:6a00:2392:b0:549:be0:cd3c with SMTP id f18-20020a056a00239200b005490be0cd3cmr27346862pfc.8.1665526781095; Tue, 11 Oct 2022 15:19:41 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:40 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 1/7] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Date: Tue, 11 Oct 2022 15:19:29 -0700 Message-Id: <20221011-gpiolib-quirks-v1-1-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151943_711873_A3FF5D34 X-CRM114-Status: GOOD ( 13.88 ) 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. Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson Reviewed-by: Linus Walleij --- 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 Tue Oct 11 22:19: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: 13004483 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 56ED3C43217 for ; Tue, 11 Oct 2022 22:21:09 +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=0A68gqxAINGlpP6/JZgoYOeJbp0y3I+HEx2BEbZs8Jw=; b=HkqL2POirn0Rrs ntOi1cYSxRzV9VHOuVkddO0jEDehdd2BrqajF45r4e144poN3FxDoG/Ww7nt5RJhZMq/ARFTERQsC z4V0fk3pttvYHQGi9UOOOjvTWzLkHACS3RFvtwwSY/k84XJvd1EOo+aQDBmbjCxdPoExnXR04fPTx g6Lz2mjlOfFn5Gk+fu6kC3wEqXRGbBQO7d3Qqd4LjeowHvu0SwIew5bg+Sq00tdd6zU/+fCsege2E hfb3owXABLQbqh5rntWadxLeFXZfWLb5D9+6hVTyd6DWaFYGdfSgWjwqfK2LPxTg88tRUspD/j6ob yC3eLULXL8kXljwKCIqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbb-0060VS-EK; Tue, 11 Oct 2022 22:20:07 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbF-0060LL-Q9; Tue, 11 Oct 2022 22:19:47 +0000 Received: by mail-pl1-x632.google.com with SMTP id c24so14514682pls.9; Tue, 11 Oct 2022 15:19: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=ZwnaXCxUHw/pDFGM82u7rAsDp6VoYC273VUZqkeLBvA=; b=JqiV2UsuEvzkU3JGSCFbS7pqYjkpSPMJtXpHwIAYCTLBflCoLy5Bgwe/LLzpTe1oou iGKUUo7edg3rs028AofuMh6Inia6fDJjjBzpt7ZEAgCyTFt5Z2G1cUk4UD4+cPQUMKcy CCgfumGrjzcSRwElNYDQuCR+f7HvJCG8oC8Uuv2R+hdLLYsZGJQxwLjv5MDcoSRbBuC5 IVSdC65ngzuHLeiMVqdVLbt2ETY0GzMlmPho1fOFgW35LpC2o55Fas55vH22g9uTQyMc g9U1ifp573wWd5TBGGQFQk6aITak1nPDESWfe2lIK/EcdSHalTsKV2KIhHhDVdRrlI0x pj5Q== 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=ZwnaXCxUHw/pDFGM82u7rAsDp6VoYC273VUZqkeLBvA=; b=KwOzJNBIqS+xUR9+wesIR6V00Kb5lQFliXDIXZ/osDr9THrEPbH9RrM58ErbrCNBpa vPi9Zcwuo8g120FkoBrSUfGzq1HxrQOGTCDNIEW/ut2Lp7HqjtowuOeemFingB9G31w6 vTNH2B6aikDRkzdHAw/aR9+NF6XxrN0hVNDYKPHSWfeHJOCQwlAPzF1EyfbnWl8LCopm mA6hLinNAbN1ENY6r/1RMVg4gCUWKaYHZAlDRkdyD2y2RHKj1zV76ceFr14TRVZdsrH2 tWHnMLfQJBAmJxe69UKie+TIEsmybb/ToKMcFnRInOpUqqnFkDdzblajVsAwqVZRIBdO Gb/A== X-Gm-Message-State: ACrzQf3ezrzEuv/QNrEl7uZbWBF4h1Xw/06C7ioEYkJ1n8kOzQn17Bx8 pDWCVcfy7yXNryU2zZHzHo/0UNoVrXQ= X-Google-Smtp-Source: AMsMyM6CBhzwUNnE45hKHUnLSlf6DbALwhzI18cG3CaCg7Kl/0eFPEfjbq96yDq7vJQPYCC2vkLVqQ== X-Received: by 2002:a17:902:70c4:b0:178:54cf:d397 with SMTP id l4-20020a17090270c400b0017854cfd397mr25533511plt.24.1665526782811; Tue, 11 Oct 2022 15:19:42 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:42 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 2/7] gpiolib: of: consolidate simple renames into a single quirk Date: Tue, 11 Oct 2022 15:19:30 -0700 Message-Id: <20221011-gpiolib-quirks-v1-2-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151945_873057_1630FE9A X-CRM114-Status: GOOD ( 21.55 ) 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. Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson --- drivers/gpio/gpiolib-of.c | 176 +++++++++++++++++----------------------------- 1 file changed, 64 insertions(+), 112 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index cef4f6634125..619aae0c5476 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -365,127 +365,83 @@ 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 */ + const char *compatible; /* NULL - don't check */ + } 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 +481,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 Tue Oct 11 22:19: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: 13004485 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 B81D8C433FE for ; Tue, 11 Oct 2022 22:21:31 +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=iDZMzR+NwIlGHWT+t351LCFz+QFNwIuJ3LRjelJaW70=; b=QaBdx9U8OomZmX adTprIgT4SY7qmtexE3mrjHWYaxy0JbouvCddoy2WScKaPopC2qmUCt9rXxA/ygPQixK+QPs/Xhru pQwLc5yDxJFoazzzHxCzStv1Gtdar1Nzr3HDu/TXZhPUxweQlyxHwi4k8bnASe52b5LfETIpDc/3f MtkxNdqNa0xy/d5RDpJOqYP8r+q2ECLsQ9o6OL4SdOqP/xIH6hTcoAUpL30bR5n49mX5UDTPivowB vEkjWppEVA0PgsovEvtCnG1J5fGlyzzgqtmJzuBLTwJrZ1r5hzriD3pwOGYpX6wBvkwwU+ruhaNFM wP6kvxloJgO5XmFC4Nhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbw-0060fJ-2f; Tue, 11 Oct 2022 22:20:28 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbH-0060Lr-BB; Tue, 11 Oct 2022 22:19:49 +0000 Received: by mail-pl1-x630.google.com with SMTP id b2so14513622plc.7; Tue, 11 Oct 2022 15:19:44 -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=i1NwOj/1yvWDq1i4eyj2xHmv/XFz6FaWZBWaVM7wyu0=; b=QnJ3DkOqZb9+TAxfrrY/yJZgX9BlizlN23aZk0peWJQqkfSjwVYTilHLwwz7eotgFD pLfAIPuEbODQpFNZsGYpKFM+/imh52QZn4ifSgqOX0ZsbSBUHoE/7aq6UkFHB22bJ/tk QGtuYF6dQO1UNw8I3BiH3OBnrcg3N/oZwx01p6yX/uwbyOM8qfhj0BxpqESpbyyj/p9R 7KrvKjUyZuGhKyXNttL3he42d3+LE4smfpiw9NY8ycWBFcWJFGGtvq6rE0FDVY0Mm3R6 vFvAdEwJgP4bRnHkHjsm5Dj0iJNv/WQyAvkCDi/Q/VhTO/ViNodqPd1fKcBjJEhA+Iqi LDsA== 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=i1NwOj/1yvWDq1i4eyj2xHmv/XFz6FaWZBWaVM7wyu0=; b=uDf5U0AGjN4wJnTC2xySDdD0bl8zSasoYckkDCqaZV/aPIOy/LJbuDsogqnSsKokC8 LxeSMlerXB1v4IR9zAdtQP2gs+CrdJwhnnlT+WOfSVstoeOIFjXc8CSnKrLWvlmOO7D2 X30JCzWSl7zWSw3b0/tMQNU72W22C554MuHHJ+BdTJUCeKnhdpq8/lFbA4CLF1qPkLnU IkCebdQ1fXe9GRrzB9yUfSAU9Qe3khOgnjT4xxBZUbReR7UDgHpq+wXWIn7DUobFSRLD y//FYxZlF43IfuCgpiFsup54gOkB0CAZLVG1VRZbsNOk4KOcuUydyEV5leP1/cIYyWNd Sm/w== X-Gm-Message-State: ACrzQf1gE563YSQoEbhMlLWb2LiG0Cmf0m5nXY+A3VkPBJOeKn210zu8 GU7X8mAZFDOUGkYUoal44mw= X-Google-Smtp-Source: AMsMyM67VBVHeAxNNooJjkK0PyaA6elXhQFtVi8kxrLNLHJe9zDpYIGxr6dY/4+x2BRZV8n5mJwFrA== X-Received: by 2002:a17:902:d4ce:b0:178:1e39:3218 with SMTP id o14-20020a170902d4ce00b001781e393218mr26303122plg.144.1665526784393; Tue, 11 Oct 2022 15:19:44 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:43 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 3/7] gpiolib: of: add quirk for locating reset lines with legacy bindings Date: Tue, 11 Oct 2022 15:19:31 -0700 Message-Id: <20221011-gpiolib-quirks-v1-3-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151947_415883_C385CC1C X-CRM114-Status: GOOD ( 11.88 ) 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. Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson --- drivers/gpio/gpiolib-of.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 619aae0c5476..576f2f0c3432 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -375,9 +375,18 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, const char *legacy_id; /* NULL - same as con_id */ const char *compatible; /* NULL - don't check */ } 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 #if IS_ENABLED(CONFIG_REGULATOR) /* * Some regulator bindings happened before we managed to @@ -388,8 +397,14 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "wlf,ldo1ena", NULL, NULL }, /* WM8994 */ { "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_MASTER) - /* * The SPI GPIO bindings happened before we managed to * establish that GPIO properties should be named From patchwork Tue Oct 11 22:19: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: 13004484 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 EA023C4332F for ; Tue, 11 Oct 2022 22:21:17 +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=rAey6RnGmO9l+ZNc3oapzo/YBCqaiJXU7BPD5Vbc2Mk=; b=OtWhTiHbRdLNed noYJwWdmWMhZH5vK+SEuZhrtBfI1I0CyCqj+h4SQWJgTjSyWO0BzIHt9xnHsvv2i8xpz9+FsZMiCe emk8teI2XZQQsa3Gp8FpRIzlkYXKsW+mqLcA3DcrYEXoybvGJbqpzSnqBXocNqQL/nK8St/9phfTx mKxDFyIoGrGszB0q4yYUZ2N1jdAdaPmC3QL3UvLNbLilk1tmY7756c1Dw7y5a3ngPneMR4DwQtkUE lBcB+9HnCVrSLFn+y0F5zEoDsQi86P3NiLp1UF+ZrZLnHWLxs0JnZHIlg1UWN4c7VZq/+d+37XzRi 8XnyN1lF42tsV8pOfQXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbl-0060ZZ-4N; Tue, 11 Oct 2022 22:20:17 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbG-0060MV-L5; Tue, 11 Oct 2022 22:19:47 +0000 Received: by mail-pf1-x42a.google.com with SMTP id w2so14852995pfb.0; Tue, 11 Oct 2022 15:19: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=sP4CVLuIUUqGyDN5WgNcl+HHfO20Zq1pEkrf2HVCvvk=; b=fcOv/f56EIKFARHyO8xbxa7fok8UbyeXvggYNyWObyTtGnqVjpIr5M/LlKIqa8Jo50 KE3k/UahcKbfOjKREk6Len+MyCOJMsO7K3bVdedPZsFkz2NA060/Uwx7OFLtdEUEaZVX FcXuqxexqMz0VcSW6/3ykBqarEX78X9TwUfQDfvtQV/7ceIguG3H+Abj7D49IbV62M2X fD1JoEAHMl0T2cdqrGfl6Cc1v0WDP2gEWaLjR4fVDbMoOjB5qB0pccUHihLlcrZ/NBeC u2k+NbDk6RLeNyrEUPOzA7tGvQmLN2Gi/4+JiqMIs+e6D+F2ANtvV/S1lfQ8K4C6MJHP aRDQ== 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=sP4CVLuIUUqGyDN5WgNcl+HHfO20Zq1pEkrf2HVCvvk=; b=7AmueFydFPjW5EDPawProldsgSHFmpFNvefFcLDee1skzQ6W2ffVb/65sjTtcrcnD9 Yk2rOXPtu0z/wg7UEPmftLZTumJ9lWTA57qZhoaanRcYOvDUOt7CWbTtxwygXlaOJ9vQ UTlhIxiGSZHPXohYZOePmw5Jy1eQas6ix0uPUdwvUmmzUG2oJ4TMI1DZkc3RCijoG84J lA9cpQMvlEyE6+PW7KJ3atxe+M/JBLuNyttLi7nCV4Odg58qB6jBujTDQbE+N3+pxdTU wJPwYPjXzHJRI1dOaMMv8WjRFD7Reskr59yeQbALNMaUDoOpjqfwMT+3FBnz5qV/nUne ZJVA== X-Gm-Message-State: ACrzQf0HWBwuu1EVLbpDhCjLTOEnMIF2gan/Mn0y3VelCYtlzA0eJERF 4MYRjvcu6/a49fnziZIUeow= X-Google-Smtp-Source: AMsMyM7JyTtqCtUz4oGyeYuC82Zq4iMUrxtYt5rjUJ/2CibmiDuwu5AZH0jMv5c0Qxd84MuJz5BDNg== X-Received: by 2002:a63:106:0:b0:460:64ce:51c4 with SMTP id 6-20020a630106000000b0046064ce51c4mr15846958pgb.17.1665526786033; Tue, 11 Oct 2022 15:19:46 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:45 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 4/7] gpiolib: of: add a quirk for reset line for Marvell NFC controller Date: Tue, 11 Oct 2022 15:19:32 -0700 Message-Id: <20221011-gpiolib-quirks-v1-4-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151946_717374_99DD2F0A X-CRM114-Status: GOOD ( 10.59 ) 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. Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson --- 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 576f2f0c3432..7d4193fe36e5 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -383,6 +383,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 Tue Oct 11 22:19: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: 13004486 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 31E2AC43217 for ; Tue, 11 Oct 2022 22:21:46 +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=esyeMFM2qzXX5fDYVRz/LrNDfAIykLU6wO4wLnDveTM=; b=cgMRsCUEtegisQ tiOV5KjsR497W6iuRCY/eIKLdMEB0irllpbvaI0izmtZ5byECJm13vDQye2prRpN2eDu3vuKsclhv YdqJvek79y1VglXZQDi8jXDcZxax2i3Dvt5nNOK7VDPAEQvhYdyy8Aq4G+9LKSrtACqA8gHYd/hxc 4MxIPcTCEuw+XHzq2sPwcL2FSdJqiuo4BYBEms9j26wTLESHh7yZ9gqeg2W2sIYZup+gecloJNJIL Wq282MZdLwn1xVSpu07mInZ35eTpRDleJJMUM2lAbEOvCbXG6nS0Hglry/40wfzImD5Pfx/kBp/M4 4CiTfAye1chvqX0HYTVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNcE-0060pe-JE; Tue, 11 Oct 2022 22:20:46 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbJ-0060Nj-O3; Tue, 11 Oct 2022 22:19:51 +0000 Received: by mail-pl1-x62c.google.com with SMTP id c24so14551048plo.3; Tue, 11 Oct 2022 15:19: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=9gDfnfolyPIiLoZMfrzrbPqoZrA52wx7/qfIWAlJm1I=; b=IwSJt27h8PVkrQYaH8qScEO9APBnjLfs46Cz1k15mBQMKZ7yOOzw0B8AA7LGRkpHKR LONSMzjFDbYkfvh8t6F1XJyZDo0UkJZYG1kYGMKNC76J7Ol2BwcOxjo1JNChA9KJwymy GVbCcD4HGQcEX/V9InKcFZOso7iCfLJUNYY7Cvt2mbClIqVvbp+BMC6ewUqjCRmGLMCi SKb4hXI/DuMbjB9SgIhMbEI9KfOKyBKJYBqBlxSESjDMTFooIQHm2Wt88DewR619vwgI ar8Aw7Qeme/yhGs5UWzeQL5SGD8xyNuOi/rgit/xD16Zslz2Y2FqnFxdZPXByX5vpixF v04g== 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=9gDfnfolyPIiLoZMfrzrbPqoZrA52wx7/qfIWAlJm1I=; b=RXp8+nyL0n9ztwyrivPNWgCXVLuegkU3XIS6pvIOzXLh/G7AwqqlRfp4E4JuesMZwO v1U+PL1/N8ghFPWEMsG9sK/GdxzStNYa3aK7zx6Y4Tpvly2zH6duMjDoogVuQjaq1MQT TKM7hGudRy8+m4mLtvZND7LcAfE5DKRYCMAn+0yTrOnDQ7sBtxbvTkrRolYByUISyGZy Y74v5HlluCSzMm27IbXdU3Uv9MwDfgO8pz6hR43jbsRidHUQWWBmdgrObNupu3wrsrjh Mp5FMI6hb1f8eaCjaN5ZqGu1sOIOObX7IgEb/HPfNGW66t3Zdo2pzqKKFpmvNtQw+QxB InBA== X-Gm-Message-State: ACrzQf0TGPu8ib5ho5p9sKtJc4yDxHf59ZaCH2pwFkLM1Ahx6xWY6hAf s+oat5v4EKabmLKOTypdvdE= X-Google-Smtp-Source: AMsMyM43bMnQePWNIYfL+kjn2ma7R4LVxExmEkZSq5CfjI94HAHswoD0kp04cKyT4G6RRD3P1ITxNA== X-Received: by 2002:a17:90b:3ec6:b0:20a:eb6b:c832 with SMTP id rm6-20020a17090b3ec600b0020aeb6bc832mr1526920pjb.22.1665526787668; Tue, 11 Oct 2022 15:19:47 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:47 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 5/7] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Date: Tue, 11 Oct 2022 15:19:33 -0700 Message-Id: <20221011-gpiolib-quirks-v1-5-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151949_810608_DD6187A0 X-CRM114-Status: GOOD ( 11.46 ) 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. Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson --- 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 7d4193fe36e5..953d1c23950a 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -407,6 +407,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "wlf,ldo1ena", NULL, NULL }, /* WM8994 */ { "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 Tue Oct 11 22:19:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13004495 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 3B7C9C433FE for ; Tue, 11 Oct 2022 22:22:14 +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=3kAKQ9u/kWILoqFAPS3o/ii/Bc913aN8H0OSXoMoVZg=; b=FYrwY/rED6AXQ7 ZXjUVO00ySjt3XiXy9ZQvDb6+A6/BYIx07G2Wwhd8oUonvfbWkvUPgu11ovnNWLcTuSN4Ts48Y2nE NmzH/u+lw8MVmwKKqPWDCTIPWFI57U5l0YwwA+vlB+Nd4eQkh1wS/bO1lF8bvhkvgCPPQMeIkMOAc hRyMK9aImCa0C3WY3C9HfthZND+9Ojj6S3Its3ypNe5tbrn/06TxYB/St8Iu40mwYkeR6yfEoFU7Q AUkMDEIjmqG4Sq63d///9sq9CpOzMjKRhkJH0+B8fnruQKpaAFnI5eKL7IOyiUKzgK4xj+PwRQ0vW Dipv0B9RmLvXsHMB9sXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNca-00612n-Oj; Tue, 11 Oct 2022 22:21:09 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbJ-0060OM-Vr; Tue, 11 Oct 2022 22:19:51 +0000 Received: by mail-pl1-x632.google.com with SMTP id l1so14499615pld.13; Tue, 11 Oct 2022 15:19:49 -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=fh3v3yhN+2E5ygCgfV0BTHYUwG2aM97Wp0EcHi2gxlg=; b=O51pSS8/2qIEK3GhD0my1EHHUGlySin6EdmCRqCNr0sJOYKtpeXbjdAguScQCm9F8L jCBKghQYusOrqscaGpmphibwIrx9cSaxtm86FOg9U9kfLOD2Vy0YTSCPZEE59X/cPviB wJiYxhqtnfbBe3gzk02/jGzcdReijX3pm28iLyy8rHd/R3MLL94GhL/KnVvIFeDDYKac JOssavR2Xi7QXNbTVDX4txQNWE+xr4C/jRnEkXblJYAL85yTIeNPt9C1NE4PHJI/EvBq mpVB/W4kGp4erxK4iWcOWwNeEFK5jJZ0mEBVhuvchBKLhUDD9F15AfDX/Q+zRQdWSXkG 6abA== 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=fh3v3yhN+2E5ygCgfV0BTHYUwG2aM97Wp0EcHi2gxlg=; b=TYqw8Lz2QuUQII21CklEbkX0lK3k1py3/JwJLaC0WsCWkuUcHSjIEtK47QteIYNVu7 f7QQcKn4p8MNWuZ3E679lmq8gU3tn8ZRdjiZjJ/y7TNz9nMtPmcqwuR4CcFbhwqIGmmH jJPf/GFwvgisLNApOgUDjDyr6oFUCZ4/jpDgXVdhjw/9YLweBB38AR6qncJ58zI7dUKE 0Fdj1FxEQFjftvv99Knnlgbhe3pgvVGqmpXqohLaySlQz+wGEuhoaISOt19XEra29Oei jf1uwtcRr+7xaG95IIi0h8HL+kRm9KCTUFkOQPfllgXkNpVO4egutnBLqQ5gt/iWuoio ZxXw== X-Gm-Message-State: ACrzQf37LeN2j22hVkW2Aif17EuJsDlHw50T6rN//S7UDHTi1ktaxPSy RWRaDv6na10CdRnOKv21d6U= X-Google-Smtp-Source: AMsMyM5MwcBpgl/QmYTxnPgIwc8Ka6MfCq+pFUcwBI+LjlTQ/Qeb+hLI8u+4VZU7BazFQ98PYUkatw== X-Received: by 2002:a17:902:f689:b0:179:fdac:c4e2 with SMTP id l9-20020a170902f68900b00179fdacc4e2mr26995320plg.119.1665526789337; Tue, 11 Oct 2022 15:19:49 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:48 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 6/7] gpiolib: of: factor out code overriding gpio line polarity Date: Tue, 11 Oct 2022 15:19:34 -0700 Message-Id: <20221011-gpiolib-quirks-v1-6-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151950_058899_A546054C X-CRM114-Status: GOOD ( 14.54 ) 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 953d1c23950a..3200d705fbe3 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 Tue Oct 11 22:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13004496 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 16532C4332F for ; Tue, 11 Oct 2022 22:22:49 +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=tLXfiMWzAImBXOGzxUO4PacDk1SwJXctJaK+AqP2vsg=; b=XAVmkbUKWo7vYw fxCZ+dWy2ackoblyKlQ94V8612HKvV6fyaGtKd08bv/ADiXJE8wwGII6IzK4AmI3UDHOBvGGow1Gs YDj9dMdrMWp5X07ru8pQ87OmN9ocvNrHxDnLTL8vRy+/y6OBoP955TZKdZeQAuYNUmLEhCcJZ2C+2 Qsw9U2QoiMRdILmSm/mxRAVvMPwj9p32taNH85rF7+MpFMoptab8uXZBm4u4qwrCETizdBrWKXNAv OhTRmSYNpP0ceJZC4pBVUL6+60fFKZcxxhOVyWhJ1HAYTRurSLRaebyynLN1vS3Tu/9RUXMrj5b++ kCAO9kNHbN7s23qNcNzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNd6-0061Lv-2Y; Tue, 11 Oct 2022 22:21:40 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiNbO-0060PJ-WB; Tue, 11 Oct 2022 22:19:56 +0000 Received: by mail-pj1-x1033.google.com with SMTP id fw14so13682180pjb.3; Tue, 11 Oct 2022 15:19:51 -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=jmBiYRqhYAVz/iDBLu767wNTrndRtXfULgkers/pTPY=; b=LzE6t/3cYXnz2rTGxT9MEheD177QZHKBRMNwdbzh2qcf6GTNoab8z2SXezuoF/pr9E SrA8lRn5sGGBsjyEJ7gU+PIcdNT7XJvt6ijJLSbYqBfwtEi2omKfkkI1/DfR8X4bmgE/ 8sUYIQ4/L45L7wmSRObPBjq0cYMXzoqenO1YEu+uw7tN5hMtcDs5QNlxSNj703ocl9jf +vyCjPwKcdqgubHQUZqmPgts3J29IZ7TosjSSMdOTHR7L6idZvlF2Vs3ZfIUuyrEwssp ob/VDLP11hZtizqNHa9ahkaRTl1FKIEwyTF05BWFy3nFdwT3I8xdORUzKyR2xxky2q6Z xqSA== 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=jmBiYRqhYAVz/iDBLu767wNTrndRtXfULgkers/pTPY=; b=8GNF0GR4bLBsrSHjtCewVZ1OMWMaWwsS6e1n/pq97fa6XM+BAlZBbBcxxTEMrJ3UM7 DvPx0fciquYm+NaT4BvCSg0jxLMDauD8RXRXGnEgX0WR+PETlGFlI/G5PNjrUOcUwNIB sUKSHecbmtmqFfj9SqN5x1A7rdvTwp/jKaLO3GHrngewNSTx44c684phMsx26o1sow6u nRDxJKEJUVjdcXUabaaaLW2damDtXwySs4dNZMAQih4sdvdOcQfbNxsSPok4NKhl9Y18 e1pT/uNbf+VK5daAUObfFuHfiwzmmM+fIiGAJWu6qv+oi4FYGp6ZVP5o/LETUG8W+qFD CRAQ== X-Gm-Message-State: ACrzQf3QZOfY3uxQ1q6mHak/6Ar78EuLUVgxsg49WWoZLBGlOeHrxR17 NtC+a3UAlRGdXb1U3qEbtPI= X-Google-Smtp-Source: AMsMyM725fhf87/+WnaBpOk4R+NTkdn8r6+mCYjks1ooHWHnlSaf2qQoW6rM0O/XPoNgCLcuRPbkWw== X-Received: by 2002:a17:90b:1b0b:b0:20d:7c31:e75d with SMTP id nu11-20020a17090b1b0b00b0020d7c31e75dmr1440019pjb.101.1665526791137; Tue, 11 Oct 2022 15:19:51 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:becc:db10:eb45:dc35]) by smtp.gmail.com with ESMTPSA id l6-20020a17090ab70600b0020d39ffe987sm60151pjr.50.2022.10.11.15.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 15:19:50 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , Bartosz Golaszewski Cc: Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH 7/7] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Date: Tue, 11 Oct 2022 15:19:35 -0700 Message-Id: <20221011-gpiolib-quirks-v1-7-e01d9d3e7b29@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com> References: <20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@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-20221011_151955_066457_DF899E26 X-CRM114-Status: GOOD ( 12.20 ) 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 3200d705fbe3..c3d3fe4d927c 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,imx6mq-fec", + "fsl,imx6qm-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); + } + } } /**