From nobody Thu Nov 14 07:54:51 2024 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 6E9C7C433FE for ; Fri, 14 Oct 2022 17:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbiJNRyt (ORCPT ); Fri, 14 Oct 2022 13:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiJNRyl (ORCPT ); Fri, 14 Oct 2022 13:54:41 -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 2D917BF75; Fri, 14 Oct 2022 10:54:40 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id q10-20020a17090a304a00b0020b1d5f6975so5446534pjl.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=pnkoXOgv/We8+nK7dWCayA+ongCjIX/WmFkBAnI+66PrTI92mHGJPQQ3GyBCN2eO6m vBi1IcKd+iHoGgnm/bvHdqYphOTMljb0v3Rk/gwL1vDpah2vnir5sa8yW1nkn74+jUyn nseqFF7LTVf9Uk6rdgub90jSOah5iIHjdWT+lF/Vrsi8VhhmFmpf+Ijx+TZrJmJ3vV8s UsbBZCz+URyyrSvGqFDQge0x4qaN6UfA/4a+p6hD1EiH9yHvG8nT30aQV/KhwBRs1M3K KkmOJu64qVhWn+ornWS8U34i1PWaCWa5ohNfvA16azhgSJ813CIkG+zIWgpqm+p2fR/U cWig== X-Gm-Message-State: ACrzQf2G5oRgwOQ4ZtKkA0iXwb4WkNf46pyUowq/oawpCusq7xbpZa/i vFpo2zzJmRRN4d/dcRMxeFs= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Dmitry Torokhov 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 devic= e_node *np, return of_get_named_gpiod_flags(np, con_id, idx, of_flags); } =20 +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 =3D=3D 0) + legacy_id =3D "i2s1-in-sel-gpio1"; + else if (idx =3D=3D 1) + legacy_id =3D "i2s1-in-sel-gpio2"; + else + return ERR_PTR(-ENOENT); + + desc =3D 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[] = =3D { of_find_regulator_gpio, of_find_arizona_gpio, of_find_usb_gpio, + of_find_mt2701_gpio, NULL }; =20 --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 DE064C4332F for ; Fri, 14 Oct 2022 17:54:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbiJNRyx (ORCPT ); Fri, 14 Oct 2022 13:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbiJNRyo (ORCPT ); Fri, 14 Oct 2022 13:54:44 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00570BF75; Fri, 14 Oct 2022 10:54:41 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id p3-20020a17090a284300b0020a85fa3ffcso8585404pjf.2; 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=1APfeq/TUYI68NoNcNcJbG9F8u4cE4N5BaxELarprN1SLanIRyrvq9g3cHmupmM5ea yIQvkKcsNXdWIH7yzBxtslLlpTJGkDuILoZg1ZKf96m4xqh/+1Y6INqBkgix9lwWOlCL mOpfkVSF/XvfKpzxcpktEdjJ0FoaoAIrHtxWh7+9P7NgUTgB9ndvvYqCerE0zwWxrdnx 7y9c+WShzupxsmGeIcBn/UBN5s40rmLP7PTVBGIU6dG2AaWPHuidtlecU1853pVGgYLg gykePC/3UyaTxu8hTOPX7RhTQZEwlJ4nBZVNxC7085VHuRBqdj9dkSQPTq2mX+ZxmBjB IVxw== X-Gm-Message-State: ACrzQf0keVr1eCeZdHC81vFugg1I0BoWfbDR5vP4XLuorRO+9w1/omg9 CkVSlewwooCLx7FqNNEDTtM= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- 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 struc= t device_node *node, } EXPORT_SYMBOL_GPL(gpiod_get_from_of_node); =20 -/* - * The SPI GPIO bindings happened before we managed to establish that GPIO - * properties should be named "foo-gpios" so we have this special kludge f= or - * 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 sele= ct - * lines rather than "cs-gpios" like all other SPI hardware. Account for t= his - * 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[] =3D { +#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) =20 - /* - * 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" }, =20 -/* - * Some regulator bindings happened before we managed to establish that GP= IO - * properties should be named "foo-gpios" so we have this special kludge f= or - * 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[] =3D { - "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; =20 if (!con_id) return ERR_PTR(-ENOENT); =20 - i =3D 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 =3D 0; i < ARRAY_SIZE(gpios); i++) { + if (strcmp(con_id, gpios[i].con_id)) + continue; =20 -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; =20 - if (!con_id || strcmp(con_id, "fcs,int_n")) - return ERR_PTR(-ENOENT); + legacy_id =3D gpios[i].legacy_id ?: gpios[i].con_id; + desc =3D 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; + } + } =20 - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); + return ERR_PTR(-ENOENT); } =20 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[] =3D { - 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 }; --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 91EDAC433FE for ; Fri, 14 Oct 2022 17:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbiJNRy6 (ORCPT ); Fri, 14 Oct 2022 13:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiJNRyp (ORCPT ); Fri, 14 Oct 2022 13:54:45 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2281A237; Fri, 14 Oct 2022 10:54:43 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id f193so4976653pgc.0; 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=M0MwgGtQckY6WlVSVW8+StNAzo9uTTvSb/vBYZkJLgYWTmlk1rd0HIm+YSB24yc+4O /yWqZkh/NQjzudGXrPlE9nyKyLytOuxZHfkuWc9H6G4JkVfiC6jOQeGfPZXzDBu8Ggni XMOR7Rz3ifJQvsma17ypYZyt7cy9paOWOOIfeNq5botf2QBVxMRPc1ZtLP3k6L2JpaF4 N3onaivtTSHaD/+q7DiULPBpYynSgcZACbulkgh2wBETVCGgeSuD/dfvicGqnAUJRln3 rHbjUqqiPK6VeQc08TqVZBGhaDKGQbdEBKby0lo7tN9+mvVtwNkIXwkCu1QrcuRWOD5E 8Zuw== X-Gm-Message-State: ACrzQf0kLhzFQzJZRiBkA1xWVRu0tZvi6w9XGf55R4sby+zHYHrNgYdk DGM/TozxeAoz/+naWH0VDyrnw4TuMhQ= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Reviewed-by: Linus Walleij --- 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 d= evice_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) =20 +#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 dev= ice_node *np, { "miso", "gpio-miso", "spi-gpio" }, { "mosi", "gpio-mosi", "spi-gpio" }, { "sck", "gpio-sck", "spi-gpio" }, +#endif =20 /* * The old Freescale bindings use simply "gpios" as name @@ -412,10 +416,14 @@ static struct gpio_desc *of_find_gpio_rename(struct d= evice_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" --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 18AD6C433FE for ; Fri, 14 Oct 2022 17:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230237AbiJNRzC (ORCPT ); Fri, 14 Oct 2022 13:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbiJNRys (ORCPT ); Fri, 14 Oct 2022 13:54:48 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 751C327143; Fri, 14 Oct 2022 10:54:45 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id 70so5563652pjo.4; 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=QzidiDYuE6LKEI2zE0VdxEZDqG0wZ5JN2kH2VDmHfo9xQZDh3n9soJhve70pp7fiKO fjPdabaKDZjoecmIsUIfe1jfRQipQdKEcc073+7kjXz7dMH8h3fAeouwKnSKNaXZrkPF 6oOdUGTMv+fhRGEih9/sAXliIzJCObZFm72VH/0Fz0MLtKg/bvJLH/bRyJJTRcalsHTt MC1fGqw262vhFjGTlnOcvzebF4hlKoE2Ufv8HbZXkRvDXhTkUxHit1oZhNMlKI8BbnVZ SC2REgRnx4prn0FDi6bRhBMSWaXizgZOBI8njtOLct16DIgLPYO8vwERMkUWmnw0HjQO p7gQ== X-Gm-Message-State: ACrzQf2EAK4tGErNKWRKAe/274uhgj2hUSvJKl0jz/zyj9ZpJ32Mmw5E CmKsajI8VpEH2hJz7SOwLZo= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Reviewed-by: Linus Walleij --- 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 de= vice_node *np, */ const char *compatible; } gpios[] =3D { +#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 =20 /* * Some regulator bindings happened before we managed to @@ -399,6 +408,13 @@ static struct gpio_desc *of_find_gpio_rename(struct de= vice_node *np, { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif =20 +#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 --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 2671EC433FE for ; Fri, 14 Oct 2022 17:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbiJNRzG (ORCPT ); Fri, 14 Oct 2022 13:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbiJNRy6 (ORCPT ); Fri, 14 Oct 2022 13:54:58 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A8052B258; Fri, 14 Oct 2022 10:54:47 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so8566142pjq.3; Fri, 14 Oct 2022 10:54:47 -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=hpPvEJFE6iuPNawyPCrOdSljGQm5fG8QsYr9yftisReSyODKH/Fy7vr4OUHeX/1CJB WgQdemtKAaPcuS/JxiJwMgmSDnO5JW5PmsVkbWwOYEeLTprMY2q8k2gNqcKEMErSTxDU 44meYj/F/lxzitwPfQxGyf75uTCHzjc+k+N5fVLtPQeqnRxk0acdVhvlLh05qsV9K2WX 9/B00mqckzX92Whny+bnbxG/nSz4VezIGdlLermWdodzu7ExgipDWCq8aKM7l8Qk6qRW WjKUGAxJnlh4w7ipxhMTedTMq+j2OEqNvy6uqXwnj292YRoH4HTRMVkZ3LxVQN8fUsQs QorQ== X-Gm-Message-State: ACrzQf0gbSYfrZIEbHM99E8WNuaJsqtnCz/IPcrPxF/PdOJf16p07Z+D vM3EEZ8XKMBh0f/nWTrqsfE= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Reviewed-by: Linus Walleij --- 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 de= vice_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" }, --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 DC3ECC4332F for ; Fri, 14 Oct 2022 17:55:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbiJNRzK (ORCPT ); Fri, 14 Oct 2022 13:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbiJNRy7 (ORCPT ); Fri, 14 Oct 2022 13:54:59 -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 D62EE2BB39; Fri, 14 Oct 2022 10:54:48 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 70so5563817pjo.4; 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=n3VmXRbRc5IAwuB7kl0ocbrIBe4y4GZv4fEade4EwsT4RT3/MxMnFsuSfChjg6e+fU XnoHfMQ6aCMTmRHhLeQFdDaEFmet6XYxWPBD6kI1SD0eSh59zWV3owUpjM76wYlDiQ4M obX6/a6R0iExgN0HPMxkgQog/ADYriDcNWqmwHjmRwN3z53JlM7wEQvVQKuKabqxAZZ/ wnUUbf8cUe9hjCgD3l+9nRxN9Y4bCgNGTfHl39AEyHtZQgYrwyUPYSM/Ql+S5R/WKMlK ocpdni+3YRuzZ5yuiecH1T3Co/UsHjtOigAnI2tbWyLvTqgbQaFo2B40GR6I7ep703md 0lYA== X-Gm-Message-State: ACrzQf2C2Jf9qwE3JFLIryYjVMub5V6/88rddtGs9Xq93wQ403zDKoMl FaFUpMyZJol4f4/WCNRcA6Y= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- 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 dev= ice_node *np, { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif =20 +#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" }, --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 C4F70C43217 for ; Fri, 14 Oct 2022 17:55:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbiJNRzV (ORCPT ); Fri, 14 Oct 2022 13:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbiJNRzD (ORCPT ); Fri, 14 Oct 2022 13:55:03 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF2D22CC9D; Fri, 14 Oct 2022 10:54:50 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id q9so4925984pgq.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=oSuZbxgttMu7inzIYGmKapBuLfSsQsYt+LIi8gIqWUKqWOrX69z6syNCPmnJqUF8FL WV1+ijPt8CgD3wBfb+ZbwAZn4eehTCO3rmhoeIcaglmP1fBV259mGKwmAkESHZ4TVMsW yAbCDM7J2ZYSFlotd8JRCxf9RCJ++8PlsXBs0HLT+U6hE9bDwZaBowGHCXYg/wQLmyp+ H81hAgolgtC6huxJQAg93A+3SYBuPehX9VyWwiHT8Yap0ZxKBwICF2uCBbacSX4Nti/I BIX7/0b09vkuKJh0fN6E4YE8fFzkf3hvZhZ/woPYxCBLxKeGK19W1Io2Fpojtq/yVLZz GdZg== X-Gm-Message-State: ACrzQf3xeBvk9UuVPK6WHmGao/ZlGJvvDwiIZ97fHfqv6M4JTDzB95q/ ND3O4LT3f0DlZnntkXbhpp4= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Reviewed-by: Linus Walleij --- 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 *g= c) return false; } =20 +/* + * 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 &=3D ~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 |=3D 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_no= de *np, (!(strcmp(propname, "enable-gpio") && strcmp(propname, "enable-gpios")) && of_device_is_compatible(np, "regulator-gpio")))) { - bool active_low =3D !of_property_read_bool(np, + bool active_high =3D 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_n= ode *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 &=3D ~OF_GPIO_ACTIVE_LOW; - } - if (active_low) - *flags |=3D 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 &=3D ~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 |=3D OF_GPIO_ACTIVE_LOW; - } + bool active_high =3D of_property_read_bool(child, + "spi-cs-high"); + of_gpio_quirk_polarity(child, active_high, + flags); of_node_put(child); break; } --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 97C71C433FE for ; Fri, 14 Oct 2022 17:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbiJNRzZ (ORCPT ); Fri, 14 Oct 2022 13:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230267AbiJNRzE (ORCPT ); Fri, 14 Oct 2022 13:55:04 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC2A2DA83; Fri, 14 Oct 2022 10:54:52 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id l1-20020a17090a72c100b0020a6949a66aso5419028pjk.1; 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=VIDa81dVaR8y4iVDftbTbDCgQ9WBpZLsQ+GeFw9DpY94zPwLxE+LQO8xC4Xlm/8Lqb zPpesD9F6g7UQPO8acvwwzX/S2WV9fojcELYkuQeVt4sKRenV0ChHZMIpMqEtY+b1lIC tdB/UxiTad0lBQOa57qyNKnpjKMpt5Els8SwiHq+ZN3ObYQck9DYNfzJVU0ESEBsOIQf XTnpq73VPWi7M68/yaMZtSdLNpk2Ryehvw77oBZCLsGkkeh66CQBbpUcZHVwomzsHXkh TWikHfRDPUhvw2gLn4PEG25IlaQI4uwMa0iFVFnNvFRTV0siHRXzzPYr8MUyGSpjsi3w 9oYQ== X-Gm-Message-State: ACrzQf2brTlxUhv9jn5oIkvAZoJKq7th+btN56FeBFN45arwpcHrTkan ZroKpyl197kf0l9Xrk0xb3A= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- 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_n= ode *np, !strcmp(propname, "snps,reset-gpio") && of_property_read_bool(np, "snps,reset-active-low")) *flags |=3D 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[] =3D { + "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 =3D of_property_read_bool(np, + "phy-reset-active-high"); + of_gpio_quirk_polarity(np, active_high, flags); + } + } } =20 /** --=20 b4 0.11.0-dev-5166b From nobody Thu Nov 14 07:54:51 2024 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 BC1F5C4332F for ; Fri, 14 Oct 2022 17:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230483AbiJNRzb (ORCPT ); Fri, 14 Oct 2022 13:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbiJNRzL (ORCPT ); Fri, 14 Oct 2022 13:55:11 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74AF42FFD1; Fri, 14 Oct 2022 10:54:53 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id y8so5545233pfp.13; 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=bOZndGjv47XomIkimGH8gTD5Pw9kyrc3tx1orQC2uo0ZTtkN+FuiZL/MB1BuxNOMO4 N1dVQlc8a2MHbAB35KG1UG++rPk9+m50HOlHRDHR+tagTeWmp65WalgGu/GO4bjafSOn gy0W0ACokyjlxrWJvhveesWeVMZEKdCcyFP3KTQQi0oM7rk6sxAhwKLyvwdud+mUEPfm H4LzBXdM7XAhE2Rrm5p/EqjJsgt6hGFOhnjhARsLEs4TqxODOhg+6CzN4CRHgKWGyFcA PphgAkGtlfHG2JmsiTEMNJd/dZBxtm6HljaAOPot4c99YkgEBLOAE31PUbWcsnQSLSJ7 evSQ== X-Gm-Message-State: ACrzQf2H7U9so8F6asWw1kBhC3Wpx34NVn0nhVVkjUFy5G3rT8qqpYoR MCp+A2JxPggsy51TxoJWozA= 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 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.11.0-dev-5166b Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Reviewed-by: Linus Walleij --- 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 devic= e_node *np, } } =20 +/* + * 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[] =3D { +#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 =3D 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. --=20 b4 0.11.0-dev-5166b