From patchwork Tue Oct 18 05:41:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 616281 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26AE2C4332F for ; Tue, 18 Oct 2022 05:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiJRFlU (ORCPT ); Tue, 18 Oct 2022 01:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbiJRFlT (ORCPT ); Tue, 18 Oct 2022 01:41:19 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825769DFBA; Mon, 17 Oct 2022 22:41:18 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id c24so12849533plo.3; Mon, 17 Oct 2022 22:41:18 -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=jTn1dphwNOkdUyNvDetLqqezFlO3LTymy8eZ70ptOU4=; b=lz0HD8RW5uepcDP4ExPxobkGeybyVM1a/aLHa5C8LHvYddXJ4DPGBq5N3gTF0xUkdT 5r+Y/MijFhpqdp9ZYE5yZJGylo3K+DSYD69+IuGZnJni/FEyqZe9sO79SZmNUCSPO1L7 VXglj6d4U3yuIqtRjTnzn/KYrpjkL4fG6yRwUN3mbojj3elf0Wtr/vELfeGOYgbAF+3B nKDRrddxLyXbKnN92Cw09Z8lDqxi4s5Kxmi48bGQWeWrqsTpB7m/iFg8qRjp2gbiaVSd lsdjBpgKqsmTW51CbYyK2OOZi888FUKFR9KT4555diSCxYJPobkBmP4kY4mlJWaOKXtr lpJg== 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=jTn1dphwNOkdUyNvDetLqqezFlO3LTymy8eZ70ptOU4=; b=bL8P92BPaem95UHz+/iLBsRLc54wTozKU2SWw7d5n5Sad1bttG/8Yz/l0F0v5D7c5W tFdV0bhw+E7gPxEZx4S26GvFJy21It/PmLLPP3Tm8umWPDRF5k3paXeMqwUvtabwCa7i rTZL1NKvs9KIkeEfhlDLpuNr94XXNLy305TkNh0bvdpeazHO08uB5BTM4emsTbPPyY60 TfDKeQcVzEF+m75JufesPEic+KEVUp5Utf5Ji0Tpvbp9E5/BApOkHMEUk5FE0n6omRUi wGHyIWz9+p7T1S1qgSb/LGhmXjEWcPHarS96x3kc0R3YK/i0bvjL7Wy7atFZuKuCXHFT QS/g== X-Gm-Message-State: ACrzQf3JyZA5I9k1QLjnO8ywsSe2dUHH1P76R5MB95X1ibxzM0rzmSO/ uRusPuhBrk0woGlIIYflJtAeHQjm09niHQ== X-Google-Smtp-Source: AMsMyM5rs1kB4rFeIfAfMs/wl4emcwgpOJcxfI8D4+foneG1Oqh62ltVnNeCS1hPaOOZKRp3wXqlkA== X-Received: by 2002:a17:90b:48c9:b0:20a:e225:1afd with SMTP id li9-20020a17090b48c900b0020ae2251afdmr36387992pjb.21.1666071677837; Mon, 17 Oct 2022 22:41:17 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:f7bc:1bb5:e0b1:92cb]) by smtp.gmail.com with ESMTPSA id z7-20020a1709027e8700b00172f4835f53sm7597435pla.192.2022.10.17.22.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:41:17 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Andy Shevchenko , Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 01/10] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Date: Mon, 17 Oct 2022 22:41:02 -0700 Message-Id: <20221011-gpiolib-quirks-v3-1-eae9cc2ed0a1@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> References: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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 Reviewed-by: Linus Walleij 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 Tue Oct 18 05:41:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 616280 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EB87C4332F for ; Tue, 18 Oct 2022 05:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbiJRFlf (ORCPT ); Tue, 18 Oct 2022 01:41:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbiJRFlZ (ORCPT ); Tue, 18 Oct 2022 01:41:25 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A62B9E2F6; Mon, 17 Oct 2022 22:41:21 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id z20so12799393plb.10; Mon, 17 Oct 2022 22:41:21 -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=irh82m/Qp0GNkDByM4lA7WDy1dQieqAl2YHxexC44Os=; b=qM+7dUmyLkuLDovXyoDzXR4ZJpAmZEdJGbZmluNHy9gwL9ovsevbMseXwDgIpDBLyJ OZxzyzDmo1EDoIj/aW9A1oqy+N21Qkye+klde2LrJ6uWjtC3qpnnEDvasVjjKEf3NuUM yUeiw5Csgwv7NOsE+dF3orUttQy43BtzBpu4ioNjBBDvrKfBg7J0n0QVPKEn75jnJT5J fDOsFzSJnLNppTx+HtbLp/PyXmCfSivMTsfPryuqO211YBvr+qf5IRg3MEGtT1Q2khGG snrOs178pvUx1AVkNeSz6hhXFu4Uq3doCNrG6OhyBeXPDw/nY/cKN12J0zpBC/k9YvLi FDDw== 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=irh82m/Qp0GNkDByM4lA7WDy1dQieqAl2YHxexC44Os=; b=XGja31BhtAdVg0zjACPqvSYTD/dsSwST2wRQ5RcjHJkOO7ntXeXORvJr8divPikFw8 US5mpkFdUUNjBzUGpnVUVzGWsIH2sQp8MayJwEfhxEIXRxkxISMo6d04FPptX37tgcGO P+YvjQsU5tkYsiXkhWCuZ/gzXlvcxdnqQKGTE8fri9C6sieRNbTsZ/ZHKpwj4KefZZRK 2lKnb6Pd1+IX1MkRbAEwUpyLcGMCDouogn3vh8Hj2VKff0Cr5mYtl4fVyzTD8VdPL102 M8F74EGCMiY/DzfF4tcLyUbW5BomD1aY+ZIXfsizoqVJfPkxr0FsiyywJrvZ3GFBxfi6 Y6OQ== X-Gm-Message-State: ACrzQf1/3KXwtH/MSbxxFN1HeVpLRqaWQx6tmLcab1SY0UMg+Aqw0e32 Nxx4+Xo5iI8UpM058YNSJf0= X-Google-Smtp-Source: AMsMyM44JNbRgjz/ycKNs7oGzL14JzEH+ynshgXTVlDVyeaouBVbIzDLES45gV0ttfgxsmviubHGbg== X-Received: by 2002:a17:90b:33cf:b0:20d:981a:a5b4 with SMTP id lk15-20020a17090b33cf00b0020d981aa5b4mr34749058pjb.137.1666071679676; Mon, 17 Oct 2022 22:41:19 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:f7bc:1bb5:e0b1:92cb]) by smtp.gmail.com with ESMTPSA id z7-20020a1709027e8700b00172f4835f53sm7597435pla.192.2022.10.17.22.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:41:18 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Andy Shevchenko , Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 02/10] gpiolib: of: consolidate simple renames into a single quirk Date: Mon, 17 Oct 2022 22:41:03 -0700 Message-Id: <20221011-gpiolib-quirks-v3-2-eae9cc2ed0a1@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> References: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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 Reviewed-by: Linus Walleij 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 Tue Oct 18 05:41:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 616279 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3346EC43217 for ; Tue, 18 Oct 2022 05:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbiJRFli (ORCPT ); Tue, 18 Oct 2022 01:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbiJRFle (ORCPT ); Tue, 18 Oct 2022 01:41:34 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E90949E2EB; Mon, 17 Oct 2022 22:41:26 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id b2so12825237plc.7; Mon, 17 Oct 2022 22:41:26 -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=8DMgKUA1ndW99FtkgK7fFtqDLzR447NcQVyF5tYxkvo=; b=Mlfgrqkvj70vbejMKTCGMp9GJ3gaaUYU2AlqRY+VhyqGg6D1JLN0HUd/z3p1RhbjYA qKTm6/8A7q0//QibXBHZ/htlvYzCq4TaldEc4XHw7CViZCvb8xbfGIIkQTFt648ancWP ApQ5j5FmpBzZ/HcXdZigRmLted9Ydib9kYLTdgTYfiaHLXEGhlUpp0Zvfhj85HfaSJii GRlbrM+XZHKiQUgHKBrwMovQuWt7uncd3+kDmAn6fJgoyUD/k6I/GLLP8z6YuKkj13zS LNrkr2xF/J1ZwPe06l0GZlJGBysiHgLQvDhLFXZ3o1wUoFXpaYhGJaV2wykb62sZnjyv 4+nQ== 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=8DMgKUA1ndW99FtkgK7fFtqDLzR447NcQVyF5tYxkvo=; b=tqUjlPSnOY8kgbUr14lFA5TF3au7RX4NYtqSYVMOcA9lqD9reMehk8ZVbR97HCRTYh VrsGAGWh2U2Y64DlT0jkwj47A7+H9vvYH7WmEOLbuQW/YcShcN/DIuV+0nSxA98edT7T 95wPr6r1Mq8aLR5GQtaefoKbC3AmnddNgNgIgHWLh0rOFd8Cc64GysweNaF5CvitLLue h9zzZi+8MMwNGj5comaPg13f1ZFLLQkUo6NLPnVZK0f0iMcfyhJl+tHYuwbGhaMAhqtx DdQR1TCBqobF0Td9mQkKLt7oAHQcCGzQQM4TqHozQBAPuVkOaHJdZkx0PRuLwVVuJ4tI 3B9Q== X-Gm-Message-State: ACrzQf0LC8K7gIkxS/aCLWv7DTuiPxm2txgQbIq03zDUSOvDWjIeJMAF 821EE0F8cm9NCSzih6d+KnM= X-Google-Smtp-Source: AMsMyM4APqjmpfE8dbaBzrp0RzRGgW+hybGoL45HKLrtC/NaYxPDQ1SgvY67ey1Va7pYiWzVz1nvvg== X-Received: by 2002:a17:90b:4c04:b0:20d:4ef6:aacc with SMTP id na4-20020a17090b4c0400b0020d4ef6aaccmr37879621pjb.199.1666071685218; Mon, 17 Oct 2022 22:41:25 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:f7bc:1bb5:e0b1:92cb]) by smtp.gmail.com with ESMTPSA id z7-20020a1709027e8700b00172f4835f53sm7597435pla.192.2022.10.17.22.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:41:24 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Andy Shevchenko , Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 05/10] gpiolib: of: add a quirk for reset line for Marvell NFC controller Date: Mon, 17 Oct 2022 22:41:06 -0700 Message-Id: <20221011-gpiolib-quirks-v3-5-eae9cc2ed0a1@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> References: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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..a9cedc39a245 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" }, + { "reset", "reset-n-io", "mrvl,nfc-uart" }, +#endif #if !IS_ENABLED(CONFIG_PCI_LANTIQ) /* MIPS Lantiq PCI */ { "reset", "gpios-reset", "lantiq,pci-xway" }, From patchwork Tue Oct 18 05:41:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 616278 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 009D3C433FE for ; Tue, 18 Oct 2022 05:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230310AbiJRFl7 (ORCPT ); Tue, 18 Oct 2022 01:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbiJRFli (ORCPT ); Tue, 18 Oct 2022 01:41:38 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ABB2A4857; Mon, 17 Oct 2022 22:41:28 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 70so12977103pjo.4; Mon, 17 Oct 2022 22:41:28 -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=/Iq5wXewW+3MLQ47QaRSsdQhrIqjL73N0jwmptRfg2I=; b=JQB+eZ4i05NAahlAWprnOds04fTCwA66xi1PBCvw2NsAD8IJGCoC03i4GSFNm5yadT FcBha25882OHsG44R9qqRzBjDU8V6yiJphui8DvrJE2VWzWRHTH2PtAml+vDOXmI+HAH 0BRxMcBqGj4GPM5FgMS94xP5gLNiGpGa9hYpBTAETp6KMSh0uKbODdUKLZIuCfwLwibj tSA9REgAVhA10Mu6VLAH3HPgmOy/r/2cQ6K7y45shGOARzDZafsWzMzxXZu7ivqD37y1 pFfOP+H7Z6EfGIfSRE2fHOQFfL1V5LAlyELPuzSEPSHGRphzr9fABIfNGKHZZ/1a7cHc h0ww== 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=/Iq5wXewW+3MLQ47QaRSsdQhrIqjL73N0jwmptRfg2I=; b=RZ/B+vS+QGezZezttfQmq6K2vJsI5ZiHgEQ2kn8NJAHPBrsZL6bpAWepJHV7Ob5rq1 8SOsjzDI6FOJxqTPoAPVipd3N+Skqp1uW8RjQXW1P8rE8MwXrWArPYKydFyzvOWkz6gs 5Nmx8XkpWOSo0EiLDA/RoyS4VWJQKBtZFGBs5EDWUv8Mh1Ej9zooxsmGKip0ST0rNId9 yI84ryfCXBY7VDN+41CZwAMrLegeFJ60V6POlXUcp/gsCjlVWDYuBRXkBDYx1PL4NjSv PPhLxfUpYQUw0bX6MJCwG7a5B/EU7fgaUR0ZnXLL+UUsR2Za2tYpwmGYe9xtddWUYkMw RiYw== X-Gm-Message-State: ACrzQf0ryj+fZvEndHFLAiL9J2Ku9MCf27x4uT4rR9aAUAl+u4XkHCxe qGJhVqaJDeSyZnuqpXI+Jrg= X-Google-Smtp-Source: AMsMyM5gBeGncCbF84yTFH4n1ABrlLB8WKM8Ryt93L29N3lO44OWDACsNtGrHRQRXDcKIK2MujAfpQ== X-Received: by 2002:a17:90a:1a43:b0:20a:ea98:b962 with SMTP id 3-20020a17090a1a4300b0020aea98b962mr37411322pjl.118.1666071687002; Mon, 17 Oct 2022 22:41:27 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:f7bc:1bb5:e0b1:92cb]) by smtp.gmail.com with ESMTPSA id z7-20020a1709027e8700b00172f4835f53sm7597435pla.192.2022.10.17.22.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:41:26 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Andy Shevchenko , Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 06/10] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Date: Mon, 17 Oct 2022 22:41:07 -0700 Message-Id: <20221011-gpiolib-quirks-v3-6-eae9cc2ed0a1@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> References: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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 Reviewed-by: Linus Walleij 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 a9cedc39a245..ffdbac2eeaa6 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 Tue Oct 18 05:41:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 616277 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B37DDC43219 for ; Tue, 18 Oct 2022 05:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbiJRFmC (ORCPT ); Tue, 18 Oct 2022 01:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiJRFlo (ORCPT ); Tue, 18 Oct 2022 01:41:44 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14F3AA344C; Mon, 17 Oct 2022 22:41:33 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id 70so12977283pjo.4; Mon, 17 Oct 2022 22:41:33 -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=QaKCpTaQOM7oy+irhSb/L7sMiah4MLH0I+sgYpZFdYA=; b=YZNP16yD09yoREPsWOruNPclr4jdwc2OvyEtL+Q/xMqzBvIrpr3WxzzAwOPLbp4e7L eefS9hRfZcfgMrZP47TIwnO/C0aOPslNe5DPDfWxS37bzccir2OFPHNwGgZUIubcIFnc nhjGKqgSpnJDGy8rKC8bpolKaHqfT6o71TCXMnmidh1JJCpdyTBhrsBENtuqWLh6Ud6g 4u5D4nG/JVx003mINsDiyaBR1LH2OpOl35AeNOJ7Qismy8SixfjVhmeUxBOtTIwViKBE njHD2kw4FHEoWZwjYBCs7xmHJoF/5xkglS+/xto323zYrhBpzTYsQztXVDK3xasTeb/c t3Tw== 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=QaKCpTaQOM7oy+irhSb/L7sMiah4MLH0I+sgYpZFdYA=; b=E5s+UfZVJ+cy8h36BLbxosIsT+GZBPfbrgluydgKJiXgmPemwQbWAAEzIwOWuCEMC2 SvHDNsQH35IE9EMKsEtgBw5S8ClQlpPCPxZV/A2i30VlXmCv2Qkpx5q36xj2+QBNCgIZ BW6zNT5tif2goMEfC/K2/wwp0KhEM5nq7bI3gZ8CAR1z2tWfsKG27xAVs5BgvcQIKwT0 /NSn7dTTkPbKxaARB3mG8id4YRCRQ2Txx5rvT7AFju6Sina9XKXLE9Oel9oEdj/O+SZh Q+CAxTWFWgwi5zcRJA1JFckXYfcgFRUaPpEXxyGGYee3+hyoc9uGznMw0Y8EOPrY6yUa smJw== X-Gm-Message-State: ACrzQf3lB/UWd9OIpXc1NOoR3LSr/9SAOLgCXPregUZGUDV7Im0PvINn u92BS+VQPOfIKQTVt8kxNdheDhxm9xjX0Q== X-Google-Smtp-Source: AMsMyM5fllnPD7r8O0aTtwSrfbMe9atjxB7xfGjnHWOFmMUSWnF5KjSvkJlnzTVHw09BY7+BGejjcw== X-Received: by 2002:a17:903:200a:b0:184:1881:bfd1 with SMTP id s10-20020a170903200a00b001841881bfd1mr1545243pla.95.1666071692411; Mon, 17 Oct 2022 22:41:32 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:f7bc:1bb5:e0b1:92cb]) by smtp.gmail.com with ESMTPSA id z7-20020a1709027e8700b00172f4835f53sm7597435pla.192.2022.10.17.22.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:41:31 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Andy Shevchenko , Daniel Thompson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 09/10] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Date: Mon, 17 Oct 2022 22:41:10 -0700 Message-Id: <20221011-gpiolib-quirks-v3-9-eae9cc2ed0a1@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> References: <20221011-gpiolib-quirks-v3-0-eae9cc2ed0a1@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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. Reviewed-by: Linus Walleij 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 6faf0dc7bc31..c2a55ffb2b20 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); + } + } } /**