From patchwork Fri Oct 14 17:54:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp308117wrs; Fri, 14 Oct 2022 10:55:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ud7HBct9pSAnrzGYJoLSFJKw3ClHEDkHagstrb7MkqV1L0cth5UBR/nyEksDDNQlyOpsO X-Received: by 2002:a17:906:8457:b0:78d:b793:5511 with SMTP id e23-20020a170906845700b0078db7935511mr4304720ejy.393.1665770139592; Fri, 14 Oct 2022 10:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770139; cv=none; d=google.com; s=arc-20160816; b=V/v+WgUC92DPZsI/roj5q9aTMKXWAETqqbi6lHYZ+A3ydMKrRxMeYrTnD1yI1qnd7f 6JHJ4pV7y+ibqLqyzErCbqdYkT2uKEowffQ5s2bVHs+tQKHlMRtFY8h0z3W/dpIgXWj+ mCQB4kKkzbytzS5oV5VWrA1rYxCaJrVPaybXPtJWlF8sEso5LGyvzMgMEE/cjaZDrDXt O8oBhKSEDEuE3N7RRJbEaSjyy5vuKic1jsiirhDyh6bfJMkHMRpIn1JEEtryLhVWYZTQ KLFfvsDyc8tTa6GQV21NtdoUaFmE1PpVeJHSSk5F4D7IBB+JHD40Vy2gXdFaMruK7Bq4 cIzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Wmd4wvJqpqY60zoqrpnViqbsnHydL7TwQT2l6YcLmqI=; b=s8nTMEHC2uTZ3aW+eDOq2ER9wMJHqUZGoDkxWytj3oPLt/Ju7KDRsUAndg3Y20e1mb STpVwnLGyQT5MxhpsLluWIM34tRE3n+rjMG5/x7HJQl/nJ7glimUT+f8RJ9dXkoKWn9l XARST1OTuZzgyaI+rLxSNemBH1Pg501V8p+bxec3QTQYE8QwcQd2hgXkYoWY5fV5ILTN ecTfl+6g6SY2ca/OHTP+fplagL7V4b9DSV15Ophnf99NRpXZS7ED6XM9RllLE/FPiipM lWtCszcc/t4MGeK+a+/pCRsYaki2HxyBCoKSV/nFGeovVU2Cp0thSyGeZHYnPX9TPVmp VGOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iB41m4Ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l24-20020a056402231800b0045909f3bb10si2470015eda.283.2022.10.14.10.55.13; Fri, 14 Oct 2022 10:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iB41m4Ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbiJNRyq (ORCPT + 99 others); Fri, 14 Oct 2022 13:54:46 -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-Received: by 2002:a17:90b:180f:b0:20d:4e7f:5f52 with SMTP id lw15-20020a17090b180f00b0020d4e7f5f52mr18916920pjb.119.1665770079544; Fri, 14 Oct 2022 10:54:39 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:38 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 1/9] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Date: Fri, 14 Oct 2022 10:54:25 -0700 Message-Id: <20221011-gpiolib-quirks-v2-1-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746686589761253490?= X-GMAIL-MSGID: =?utf-8?q?1746686589761253490?= The driver is using non-standard "i2s1-in-sel-gpio1" and "i2s1-in-sel-gpio2" names to describe its gpios. In preparation to converting to the standard naming (i2s1-in-sel-gpios) and switching the driver to gpiod API add a quirk to gpiolib to keep compatibility with existing DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 0e4e1291604d..cef4f6634125 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -488,6 +488,38 @@ static struct gpio_desc *of_find_usb_gpio(struct device_node *np, return of_get_named_gpiod_flags(np, con_id, idx, of_flags); } +static struct gpio_desc *of_find_mt2701_gpio(struct device_node *np, + const char *con_id, + unsigned int idx, + enum of_gpio_flags *of_flags) +{ + struct gpio_desc *desc; + const char *legacy_id; + + if (!IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448)) + return ERR_PTR(-ENOENT); + + if (!of_device_is_compatible(np, "mediatek,mt2701-cs42448-machine")) + return ERR_PTR(-ENOENT); + + if (!con_id || strcmp(con_id, "i2s1-in-sel")) + return ERR_PTR(-ENOENT); + + if (idx == 0) + legacy_id = "i2s1-in-sel-gpio1"; + else if (idx == 1) + legacy_id = "i2s1-in-sel-gpio2"; + else + return ERR_PTR(-ENOENT); + + desc = of_get_named_gpiod_flags(np, legacy_id, 0, of_flags); + if (!gpiod_not_found(desc)) + pr_info("%s is using legacy gpio name '%s' instead of '%s-gpios'\n", + of_node_full_name(np), legacy_id, con_id); + + return desc; +} + typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np, const char *con_id, unsigned int idx, @@ -498,6 +530,7 @@ static const of_find_gpio_quirk of_find_gpio_quirks[] = { of_find_regulator_gpio, of_find_arizona_gpio, of_find_usb_gpio, + of_find_mt2701_gpio, NULL }; From patchwork Fri Oct 14 17:54:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp308323wrs; Fri, 14 Oct 2022 10:56:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7I4Movai1W2bbIWliFytXSsU8sB4jjGVLQkECeGFuNTBWkE4y0GOzyTWDTHapQO6zcUOpU X-Received: by 2002:a17:907:788:b0:741:4d1a:595d with SMTP id xd8-20020a170907078800b007414d1a595dmr4252101ejb.737.1665770167190; Fri, 14 Oct 2022 10:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770167; cv=none; d=google.com; s=arc-20160816; b=P21QpTI9N/1Hu/dhPJm9ZkzJVlmXDIOXr2KjC3KAYrtYypbVWW0VxwjOteLFnwN1RZ gzlsTm/91i2VoSDNdJ+ajthuCkEG/2EZmL3yoPZUtqF3h9v5p2SgDGiIzmPz3aTh3ZRz H/jGz5cIUcw914l5VhS/yZXLimc0sqeG5krog34CMhEo/QRegvQ3L2nSUyfzWvqrFzTF cjM9dJkgDgbYG34jpMFuDLsndhVKFVRh4VAmZI2l3GU87D0BgVx1By7n8HiQZ5Ajgjsu vjhdT7Wz0Cl+FIyXUWWeatCe5y95ShRyVeYSE1Z0W3ZkUmRpWtizNe5m15/lrIl4pl6p BCmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qxjJXLNZ6IucM2dfltD9zuskmixqvHxoP/aJVIhJLkg=; b=Obp3E1IM09BSaEtmI6gpIjHCeeffeNMPWU+edj7jPWFe4P4UKN8qV6VZ3nq/0h/Sy4 pS73IxeSGxeuoKZAEtNrwJxObu1NYBW4Up3P0yvSWeGHmpeYdvdB6xO/3zZk6pdW3H6I EJcRhI1yGq7Dg1Pn3NcEopadWtizZyMDRtdAqS2oMGAsUJX5A0qttEt//SIhw5SBjWOj 1tUylPjAgBYzXgr+K0eoHTbMs35W7Kzy6vjJpT+HSiSFr0G8rOEf9jcZ1Wj/JE+Xl/ZT 9LSkrmjHhkGZf2pZBjGaa95d3WcvkQ46Ajn+8r6uPYf3B6RusVLvM8WAIYKUL3LT0od3 YmAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PE9OwNQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a170906088400b0078a90aaba90si2684237eje.394.2022.10.14.10.55.40; Fri, 14 Oct 2022 10:56:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PE9OwNQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbiJNRyw (ORCPT + 99 others); Fri, 14 Oct 2022 13:54:52 -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-Received: by 2002:a17:902:e88e:b0:183:dcb7:c4fc with SMTP id w14-20020a170902e88e00b00183dcb7c4fcmr6149478plg.32.1665770081295; Fri, 14 Oct 2022 10:54:41 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:40 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 2/9] gpiolib: of: consolidate simple renames into a single quirk Date: Fri, 14 Oct 2022 10:54:26 -0700 Message-Id: <20221011-gpiolib-quirks-v2-2-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746686618494821583?= X-GMAIL-MSGID: =?utf-8?q?1746686618494821583?= This consolidates all quirks doing simple renames (either allowing suffix-less names or trivial renames, when index changes are not required) into a single quirk. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 183 ++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 112 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index cef4f6634125..63c6fa3086f3 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -365,127 +365,90 @@ struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node, } EXPORT_SYMBOL_GPL(gpiod_get_from_of_node); -/* - * The SPI GPIO bindings happened before we managed to establish that GPIO - * properties should be named "foo-gpios" so we have this special kludge for - * them. - */ -static struct gpio_desc *of_find_spi_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - char prop_name[32]; /* 32 is max size of property name */ - - /* - * Hopefully the compiler stubs the rest of the function if this - * is false. - */ - if (!IS_ENABLED(CONFIG_SPI_MASTER)) - return ERR_PTR(-ENOENT); - - /* Allow this specifically for "spi-gpio" devices */ - if (!of_device_is_compatible(np, "spi-gpio") || !con_id) - return ERR_PTR(-ENOENT); - - /* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */ - snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id); - - return of_get_named_gpiod_flags(np, prop_name, idx, of_flags); -} - -/* - * The old Freescale bindings use simply "gpios" as name for the chip select - * lines rather than "cs-gpios" like all other SPI hardware. Account for this - * with a special quirk. - */ -static struct gpio_desc *of_find_spi_cs_gpio(struct device_node *np, +static struct gpio_desc *of_find_gpio_rename(struct device_node *np, const char *con_id, unsigned int idx, enum of_gpio_flags *of_flags) { - if (!IS_ENABLED(CONFIG_SPI_MASTER)) - return ERR_PTR(-ENOENT); - - /* Allow this specifically for Freescale and PPC devices */ - if (!of_device_is_compatible(np, "fsl,spi") && - !of_device_is_compatible(np, "aeroflexgaisler,spictrl") && - !of_device_is_compatible(np, "ibm,ppc4xx-spi")) - return ERR_PTR(-ENOENT); - /* Allow only if asking for "cs-gpios" */ - if (!con_id || strcmp(con_id, "cs")) - return ERR_PTR(-ENOENT); + static const struct of_rename_gpio { + const char *con_id; + const char *legacy_id; /* NULL - same as con_id */ + /* + * Compatible string can be set to NULL in case where + * matching to a particular compatible is not practical, + * but it should only be done for gpio names that have + * vendor prefix to reduce risk of false positives. + * Addition of such entries is strongly discouraged. + */ + const char *compatible; + } gpios[] = { +#if IS_ENABLED(CONFIG_MFD_ARIZONA) + { "wlf,reset", NULL, NULL }, +#endif +#if IS_ENABLED(CONFIG_REGULATOR) + /* + * Some regulator bindings happened before we managed to + * establish that GPIO properties should be named + * "foo-gpios" so we have this special kludge for them. + */ + { "wlf,ldoena", NULL, NULL }, /* Arizona */ + { "wlf,ldo1ena", NULL, NULL }, /* WM8994 */ + { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ +#endif +#if IS_ENABLED(CONFIG_SPI_MASTER) - /* - * While all other SPI controllers use "cs-gpios" the Freescale - * uses just "gpios" so translate to that when "cs-gpios" is - * requested. - */ - return of_get_named_gpiod_flags(np, "gpios", idx, of_flags); -} + /* + * The SPI GPIO bindings happened before we managed to + * establish that GPIO properties should be named + * "foo-gpios" so we have this special kludge for them. + */ + { "miso", "gpio-miso", "spi-gpio" }, + { "mosi", "gpio-mosi", "spi-gpio" }, + { "sck", "gpio-sck", "spi-gpio" }, -/* - * Some regulator bindings happened before we managed to establish that GPIO - * properties should be named "foo-gpios" so we have this special kludge for - * them. - */ -static struct gpio_desc *of_find_regulator_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - /* These are the connection IDs we accept as legacy GPIO phandles */ - const char *whitelist[] = { - "wlf,ldoena", /* Arizona */ - "wlf,ldo1ena", /* WM8994 */ - "wlf,ldo2ena", /* WM8994 */ + /* + * The old Freescale bindings use simply "gpios" as name + * for the chip select lines rather than "cs-gpios" like + * all other SPI hardware. Allow this specifically for + * Freescale and PPC devices. + */ + { "cs", "gpios", "fsl,spi" }, + { "cs", "gpios", "aeroflexgaisler,spictrl" }, + { "cs", "gpios", "ibm,ppc4xx-spi" }, +#endif +#if IS_ENABLED(CONFIG_TYPEC_FUSB302) + /* + * Fairchild FUSB302 host is using undocumented "fcs,int_n" + * property without the compulsory "-gpios" suffix. + */ + { "fcs,int_n", NULL, "fcs,fusb302" }, +#endif }; - int i; - - if (!IS_ENABLED(CONFIG_REGULATOR)) - return ERR_PTR(-ENOENT); + struct gpio_desc *desc; + const char *legacy_id; + unsigned int i; if (!con_id) return ERR_PTR(-ENOENT); - i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id); - if (i < 0) - return ERR_PTR(-ENOENT); - - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); -} - -static struct gpio_desc *of_find_arizona_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - if (!IS_ENABLED(CONFIG_MFD_ARIZONA)) - return ERR_PTR(-ENOENT); - - if (!con_id || strcmp(con_id, "wlf,reset")) - return ERR_PTR(-ENOENT); - - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); -} + for (i = 0; i < ARRAY_SIZE(gpios); i++) { + if (strcmp(con_id, gpios[i].con_id)) + continue; -static struct gpio_desc *of_find_usb_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, - enum of_gpio_flags *of_flags) -{ - /* - * Currently this USB quirk is only for the Fairchild FUSB302 host - * which is using an undocumented DT GPIO line named "fcs,int_n" - * without the compulsory "-gpios" suffix. - */ - if (!IS_ENABLED(CONFIG_TYPEC_FUSB302)) - return ERR_PTR(-ENOENT); + if (gpios[i].compatible && + !of_device_is_compatible(np, gpios[i].compatible)) + continue; - if (!con_id || strcmp(con_id, "fcs,int_n")) - return ERR_PTR(-ENOENT); + legacy_id = gpios[i].legacy_id ?: gpios[i].con_id; + desc = of_get_named_gpiod_flags(np, legacy_id, idx, of_flags); + if (!gpiod_not_found(desc)) { + pr_info("%s uses legacy gpio name '%s' instead of '%s-gpios'\n", + of_node_full_name(np), legacy_id, con_id); + return desc; + } + } - return of_get_named_gpiod_flags(np, con_id, idx, of_flags); + return ERR_PTR(-ENOENT); } static struct gpio_desc *of_find_mt2701_gpio(struct device_node *np, @@ -525,11 +488,7 @@ typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np, unsigned int idx, enum of_gpio_flags *of_flags); static const of_find_gpio_quirk of_find_gpio_quirks[] = { - of_find_spi_gpio, - of_find_spi_cs_gpio, - of_find_regulator_gpio, - of_find_arizona_gpio, - of_find_usb_gpio, + of_find_gpio_rename, of_find_mt2701_gpio, NULL }; From patchwork Fri Oct 14 17:54:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp308897wrs; Fri, 14 Oct 2022 10:57:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Vr1JovZS0zevcA6Bt9ke7BGV/4wacmJi4POOHarir37pTmV/1NaO4UDdSSD1m/5DVjPOk X-Received: by 2002:a17:907:7d87:b0:783:fb5:1899 with SMTP id oz7-20020a1709077d8700b007830fb51899mr4345667ejc.456.1665770248014; Fri, 14 Oct 2022 10:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770248; cv=none; d=google.com; s=arc-20160816; b=GjhXNIUUYI5JwUdrU3LJ7oizW9e3JG7L2dC65UPxciXiGoJj958tVZ8fIQWWphyeVD 9BTUCpzjdoLEU2NPtmnMDNxKUSqPzTu0N/4Jw883syke4Hd9rgo3sDqy5VQ+QymzGl8F CvAW7EWnD7sTiAIJv89X5eR6jQWe2M/0UC53Ufj3Kcg/Puf3x+vloGxsZHWdxpMX3Otw JGjU+HFikAMDwY6LLZSAZFlVDusx4FuHgREEUlN3dAHe+dxC3OZUaoMZ7yrANrYHEo4b 0XGHZXpZZxLQPLYkTr79/WfthkwJ+Tc83vre/ftMOFaSenhWGN9uEWtRQZ5aWAymOhNx UrLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bWZ+aGOI9zXRffRicNGgT9n+AHk/SzmN5RkqWoKLfug=; b=sb4DZENJfrkBSEqdfe+Q6B1G+rRtVZUKD8njPPCZvnsNNby/B7dMcuf4v3s/iDha8F rZ184dS7ibv9gkqND2s9cm3iWKUhtdUE9GlXBeaNv4ur+EyBbSZLkH72YJTwcguQww2f zybZc9vuxMVKBFieoNw0kYx91CvKm8b9U5fcyHkVcpTm0whGfpiYY14V+OT1omPg7HhO l2oniyDRgtlMJm7P+M7XHJloGVoL3gvVnvNHr1Wkeq7te5JilKWQPO1AkwzXsVaNaEUl vO/23mwE5rzThaRX5kGQxtWQGmJBqe77drOWekk32M4uWQ8L2bp0zJknE0EAC+GsKQ0n Xmhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="fOuoZbM/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr8-20020a170907720800b0078b3edae43csi3381954ejc.37.2022.10.14.10.57.01; Fri, 14 Oct 2022 10:57:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="fOuoZbM/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbiJNRy5 (ORCPT + 99 others); Fri, 14 Oct 2022 13:54:57 -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-Received: by 2002:a63:4e18:0:b0:43c:2fc7:2eea with SMTP id c24-20020a634e18000000b0043c2fc72eeamr5688379pgb.119.1665770082916; Fri, 14 Oct 2022 10:54:42 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:42 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 3/9] gpiolib: of: tighten selection of gpio renaming quirks Date: Fri, 14 Oct 2022 10:54:27 -0700 Message-Id: <20221011-gpiolib-quirks-v2-3-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746686703664403857?= X-GMAIL-MSGID: =?utf-8?q?1746686703664403857?= Tighten selection of legacy gpio renaming quirks so that they only considered on more relevant configurations. Suggested-by: Daniel Thompson Signed-off-by: Dmitry Torokhov Reviewed-by: Daniel Thompson --- drivers/gpio/gpiolib-of.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 63c6fa3086f3..7d4bbf6484bc 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -385,18 +385,21 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, #if IS_ENABLED(CONFIG_MFD_ARIZONA) { "wlf,reset", NULL, NULL }, #endif -#if IS_ENABLED(CONFIG_REGULATOR) + /* * Some regulator bindings happened before we managed to * establish that GPIO properties should be named * "foo-gpios" so we have this special kludge for them. */ +#if IS_ENABLED(CONFIG_REGULATOR_ARIZONA_LDO1) { "wlf,ldoena", NULL, NULL }, /* Arizona */ +#endif +#if IS_ENABLED(CONFIG_REGULATOR_WM8994) { "wlf,ldo1ena", NULL, NULL }, /* WM8994 */ { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif -#if IS_ENABLED(CONFIG_SPI_MASTER) +#if IS_ENABLED(CONFIG_SPI_GPIO) /* * The SPI GPIO bindings happened before we managed to * establish that GPIO properties should be named @@ -405,6 +408,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "miso", "gpio-miso", "spi-gpio" }, { "mosi", "gpio-mosi", "spi-gpio" }, { "sck", "gpio-sck", "spi-gpio" }, +#endif /* * The old Freescale bindings use simply "gpios" as name @@ -412,10 +416,14 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, * all other SPI hardware. Allow this specifically for * Freescale and PPC devices. */ +#if IS_ENABLED(CONFIG_SPI_FSL_SPI) { "cs", "gpios", "fsl,spi" }, { "cs", "gpios", "aeroflexgaisler,spictrl" }, +#endif +#if IS_ENABLED(CONFIG_SPI_PPC4xx) { "cs", "gpios", "ibm,ppc4xx-spi" }, #endif + #if IS_ENABLED(CONFIG_TYPEC_FUSB302) /* * Fairchild FUSB302 host is using undocumented "fcs,int_n" From patchwork Fri Oct 14 17:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp308247wrs; Fri, 14 Oct 2022 10:55:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fE8ibPy/vJkQymbY+gLuaS20IEjvBbwq7xqUdOx0S0AqPFUOZO17BJBXqvg8gaLpCkhCW X-Received: by 2002:a17:907:2e19:b0:78e:11cc:3bc5 with SMTP id ig25-20020a1709072e1900b0078e11cc3bc5mr4396577ejc.543.1665770157774; Fri, 14 Oct 2022 10:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770157; cv=none; d=google.com; s=arc-20160816; b=iHTF7NkLXZ0xbxDbe3JFfQvuWIwywTvFVCtm5aogcgkr9sJqaQZWej+NXZsoqXUKoo GmgXn5nC05qjQAJytzYgsCPm+FH7CQrOr91d78Ua5q4dJmziwzj8NLVDHw+D3tMM/SCN zEml6qeiJUVzZWyry+ASx4+kjK76pl5LmFlu5hGkaLlr4C3psZuHbPrNbVst2QSQcUnD 2khYAC5+EeTkIAEBNpakFRoooGuZkClV9Q2Y/M9Qzg4pCXDjZgaHVLkkTrVYQioshFX8 SNUYfCtuATiTyC/hxjM6Tp+PDY3V+u9FNWuIzYnI0G+RL6GkXbzdHTxER6WZnD10tJfo 69aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YV6Nxa393Zempvv48DGSX3qqsS8tBZ+cvvfhAdg2hN8=; b=Mu6lU+FT8BpHHNwe6N+lN2ZDbvYem5oJhf6bA6mTr8EuOZvOUQKVKtEQggYXetx9qV w3eXPSLZkxmPZ/h3bu11q3JEg/lVqetAyL1xc90x2TpcOjKRwd2L/5UWIiI9woeBOxD8 QX2rd1/8pU2mHsjy9b8BWbZBTqctxOTSYeEn+ozeLLrxCuP2Qod1Fjd0G2Yoyv9GIBH5 xhTqbErco6RUqI69jQUWAUt6b5gr1PpfDdE4nwbd1tqfTYz1WuvMgZN1nUR3Y5MNLvI6 HJScw1g+NPZXF//VxWgL8TWFZlLuCpjsjJ/cTyIHD0X0F0InxmxiifW/9Gz7i7HYS9Hl OFeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hwC+mpYb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c14-20020a05640227ce00b004462de364fesi3265716ede.597.2022.10.14.10.55.32; Fri, 14 Oct 2022 10:55:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hwC+mpYb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230234AbiJNRzC (ORCPT + 99 others); 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-Received: by 2002:a17:902:ec81:b0:185:3cea:6326 with SMTP id x1-20020a170902ec8100b001853cea6326mr6596411plg.24.1665770084657; Fri, 14 Oct 2022 10:54:44 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:44 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 4/9] gpiolib: of: add quirk for locating reset lines with legacy bindings Date: Fri, 14 Oct 2022 10:54:28 -0700 Message-Id: <20221011-gpiolib-quirks-v2-4-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746686609114962308?= X-GMAIL-MSGID: =?utf-8?q?1746686609114962308?= Some legacy mappings used "gpio[s]-reset" instead of "reset-gpios", add a quirk so that gpiod API will still work on unmodified DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 7d4bbf6484bc..2b5d1b3095c7 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -382,9 +382,18 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, */ const char *compatible; } gpios[] = { +#if !IS_ENABLED(CONFIG_LCD_HX8357) + /* Himax LCD controllers used "gpios-reset" */ + { "reset", "gpios-reset", "himax,hx8357" }, + { "reset", "gpios-reset", "himax,hx8369" }, +#endif #if IS_ENABLED(CONFIG_MFD_ARIZONA) { "wlf,reset", NULL, NULL }, #endif +#if !IS_ENABLED(CONFIG_PCI_LANTIQ) + /* MIPS Lantiq PCI */ + { "reset", "gpios-reset", "lantiq,pci-xway" }, +#endif /* * Some regulator bindings happened before we managed to @@ -399,6 +408,13 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif +#if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X) + { "reset", "gpio-reset", "ti,tlv320aic3x" }, + { "reset", "gpio-reset", "ti,tlv320aic33" }, + { "reset", "gpio-reset", "ti,tlv320aic3007" }, + { "reset", "gpio-reset", "ti,tlv320aic3104" }, + { "reset", "gpio-reset", "ti,tlv320aic3106" }, +#endif #if IS_ENABLED(CONFIG_SPI_GPIO) /* * The SPI GPIO bindings happened before we managed to From patchwork Fri Oct 14 17:54:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp309274wrs; Fri, 14 Oct 2022 10:58:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jA0h8GoyhkJnYxvWzadzNGigWrdHjmwbdm8Gwb7HhxVPS/4jAo00rzcGIoe3Db7heOOIP X-Received: by 2002:a17:907:97d5:b0:782:23b0:ecb8 with SMTP id js21-20020a17090797d500b0078223b0ecb8mr4573624ejc.100.1665770303651; Fri, 14 Oct 2022 10:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770303; cv=none; d=google.com; s=arc-20160816; b=MN71kN3xHzDd0jldQSCtI2nPIT6/hZ9sWxnJdWTcIWSIsj165peExU9HpuzjQ+RU4e bJt1Dm6PJ3sQOVfl43fUlnXPp7SS1Ul5t3sA0zHU8oJIeKTEMfqIXz58NBxeJAxUkWFQ QMFzGQJrtZw5nqdHhM3ilSM7qy2zlzZa9/iWYvVOmneXMag2PHWoPmHMsw+trUH4sE3H LCUl60CrzAIlUrm4FEYFWEEUywLa4WySLsUS92b3F8H2WFOzMgUzpJqd4/Io2cvPdikr KGSkP3HA0PJiNoUQb97kSOwF7flRgb3fBm2BDiPIyEDmHygN8eaUkWBeCWljWBC9HTEV Ct2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BX6I3wxmmC2re4tlQ7azHaY51bTZUH4nJgPdj4ITZq8=; b=nd7yb16rudQeuX69CDYeRw8lzLRdtOK6aYlPKwyhAn82CGwONE7/gKkFQQ/QxQI+4A 2Y9P+RvcAopwbAnS5vYQ4pqzJp10Z2MyH2fG96Ic3EzSvSUZJHRDQX231E5HVJekg+vz BNgQHqIgFKdjhgl6h+xH7+Lr2yiQuug97aCJ0yk+GYkFIkelLCF3AT+47NEF19loncAG FZkBtZ97sSdljSNMWJAFwQMDqq5Ou1f7Bjp1wrLs4BjWQK4s9OtWL8if5fhDIdd4hVEz +vnbxmadryU5eFX9tPPXEVFfCHOFwTr40GmV0c8vtKCL0YJNEC3D1R7GYExm6nEigzmJ 28WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cyugA0yH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go6-20020a1709070d8600b007807e613e5bsi3753046ejc.933.2022.10.14.10.57.57; Fri, 14 Oct 2022 10:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cyugA0yH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbiJNRzF (ORCPT + 99 others); Fri, 14 Oct 2022 13:55:05 -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-Received: by 2002:a17:90a:4311:b0:20b:e232:5920 with SMTP id q17-20020a17090a431100b0020be2325920mr7199880pjg.190.1665770086268; Fri, 14 Oct 2022 10:54:46 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:45 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 5/9] gpiolib: of: add a quirk for reset line for Marvell NFC controller Date: Fri, 14 Oct 2022 10:54:29 -0700 Message-Id: <20221011-gpiolib-quirks-v2-5-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746686761892034159?= X-GMAIL-MSGID: =?utf-8?q?1746686761892034159?= The controller is using non-standard "reset-n-io" name for its reset gpio property, whereas gpiod API expects "-gpios". Add a quirk so that gpiod API will still work on unmodified DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 2b5d1b3095c7..5c11ee7638d1 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -390,6 +390,16 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, #if IS_ENABLED(CONFIG_MFD_ARIZONA) { "wlf,reset", NULL, NULL }, #endif + +#if IS_ENABLED(CONFIG_NFC_MRVL_I2C) + { "reset", "reset-n-io", "marvell,nfc-i2c" }, +#endif +#if IS_ENABLED(CONFIG_NFC_MRVL_SPI) + { "reset", "reset-n-io", "marvell,nfc-spi" }, +#endif +#if IS_ENABLED(CONFIG_NFC_MRVL_UART) + { "reset", "reset-n-io", "marvell,nfc-uart" }, +#endif #if !IS_ENABLED(CONFIG_PCI_LANTIQ) /* MIPS Lantiq PCI */ { "reset", "gpios-reset", "lantiq,pci-xway" }, From patchwork Fri Oct 14 17:54:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp308712wrs; Fri, 14 Oct 2022 10:57:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM619foL7geo2BAC9iLe9QOs8CvMVYAGRQZE51gWvwbVkLjAcTmuQSYuoYk6L0y9sioRJ93o X-Received: by 2002:a05:6402:ca:b0:45c:dbdd:8143 with SMTP id i10-20020a05640200ca00b0045cdbdd8143mr5189521edu.213.1665770224401; Fri, 14 Oct 2022 10:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770224; cv=none; d=google.com; s=arc-20160816; b=ZUL64QobEnS7P7blJlgHsZxif2Vbx3poEzmGLJp5roFw0Cm5aHAAa1HU2IDMJ3sFgG WC2DzdbI6J/n7sRho69YO0ctHi8kDgG19/QzujFVg3wkSQCY9kJgzLzHql3c9LqoS7WN xaLnbS8K6cpZ7fAsW0nO0R0Kxfjnm/f3wShDo5AJ+H7kYKyQcXhK6cuBXiMRRMDKt3i9 N0vOWnh5uBhLkmt3znSsw5gF+gYaiWsf9je8frppOrriWBoVrnkadSeJvU6UATBROQUz 2o0mAadhqBDMULych2iLwIv/arQ5L5fY1AZKR5QzqyKw3GVEFddjb5lcKyQNoPNieQQq jiZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hifOoY9aqLLHbcQa2d9K53VxHn7l+VlC4N3fss0zE6o=; b=VfleXHX2imwWr9MnF/UX2ShYoCxZ5vGNCl4iqQf3dZkNHskjTDLAM0UR1XI3kjUDaW YH0E521v32STZoDV1DIdbreiQFY2qfCrFVwIbp7StK1Grv4n+M9QFxy9VBYirAtI0TWs nUoPzWgCT5mahJ0Xgb6QnpXF1lfR74x1wBjUysBThMRHnabJB/NoIRHT+pHKy0XuXEID iZiJNVjxv8CmhHUONfjmC7ncOnHt/QxtkJCjoY+ivDhYTdxiDwkU6i9OQF8jruRiZwR+ cY9MiZ8CzYmh0qG6a+Hbvlx9/OczgsPJ4Z4z67Dl5/WTQjGHyMQkJ/VAZ5Vewz14OJQl df1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TrpvH1Ty; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f25-20020a50a6d9000000b00452ce356136si2561481edc.135.2022.10.14.10.56.37; Fri, 14 Oct 2022 10:57:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TrpvH1Ty; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbiJNRzJ (ORCPT + 99 others); Fri, 14 Oct 2022 13:55:09 -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-Received: by 2002:a17:90b:1804:b0:20d:a753:7d4c with SMTP id lw4-20020a17090b180400b0020da7537d4cmr11027033pjb.78.1665770087982; Fri, 14 Oct 2022 10:54:47 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:47 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 6/9] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Date: Fri, 14 Oct 2022 10:54:30 -0700 Message-Id: <20221011-gpiolib-quirks-v2-6-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746686678817514182?= X-GMAIL-MSGID: =?utf-8?q?1746686678817514182?= The controller is using non-standard "cirrus,gpio-nreset" name for its reset gpio property, whereas gpiod API expects "-gpios". Add a quirk so that gpiod API will still work on unmodified DTSes. Reviewed-by: Daniel Thompson Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 5c11ee7638d1..77cabcfb2da0 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -418,6 +418,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, { "wlf,ldo2ena", NULL, NULL }, /* WM8994 */ #endif +#if IS_ENABLED(CONFIG_SND_SOC_CS42L56) + { "reset", "cirrus,gpio-nreset", "cirrus,cs42l56" }, +#endif #if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X) { "reset", "gpio-reset", "ti,tlv320aic3x" }, { "reset", "gpio-reset", "ti,tlv320aic33" }, From patchwork Fri Oct 14 17:54:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp313365wrs; Fri, 14 Oct 2022 11:06:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40/0nQVDyP0Ft7RGR4vGvk/l9soU1WtmLHMeon1Y7aucpGFPtp41WnmNvObFcfD2sCwVsb X-Received: by 2002:a17:906:5dcc:b0:78d:e76a:ef23 with SMTP id p12-20020a1709065dcc00b0078de76aef23mr4245486ejv.317.1665770797536; Fri, 14 Oct 2022 11:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770797; cv=none; d=google.com; s=arc-20160816; b=IAp8KXyZTzdPanGVh2nqBTb9zPZcdnvMhryOA0b76MDpKBEL+UNCdx/G/1aZJKu8fO p7573Trm1k6HoE17xnx59WA3eGo7KYtx+xfIUWw5tl66uc5yK4Vtc2lZUUoTmqq9ZGBm Hzs/me4TUMcu3wujUwzb+P/G8NNEX0HEwUEUHpfHk/0ejC6juesSYiv1IQQOfIltkoak ystYVIEfG+jpvpToU8dtak4fH17u6KGZlXl/LZQZDoG82ntH928rAWBHKiG2Ju/T3W30 cJqaxkg2jxnAPZWee9F8VzIvWXezBVlnAa4KqtQ0/yEIXodWFKAPNL3yjojI/6Z0AYP2 RRhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ovCPxMNt0i2khQD9ZbKAf0f91ILluT414D5KLsvMtco=; b=xt8ZMGYjyODBvviPwZudKPAxx89fYNbfbAtUGcFQwlSW+iiL8BIIOaHJQH6Yb37dkg YkF2hBG/jlgThH6lIHaydDoRcZp+kIPb48j+x9Rxd2WBCO2gflSY2ATluhjvSB/27dus fUMB/mxln8PZnm0T2sUWWk62TBI/dWZYMeG6udBbziM/OsuEUf5nk3/HkUBstQQGtVi1 fhhUs6UbmFwTxDgD+Fp8ZvX60Me9d9e9hNnpxgCALLqIZKQJ+d1kWEg9df1F1xwF2OXN sGHxtvKsPT/9I2VfPtpCCwSI10Y+y+ci01ict937JcahbNmCgXSLT04zDg6R/MiEexcD fAZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HFcFHjwS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a05640242d100b00456662097dasi3650510edc.69.2022.10.14.11.06.10; Fri, 14 Oct 2022 11:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HFcFHjwS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbiJNRzS (ORCPT + 99 others); Fri, 14 Oct 2022 13:55:18 -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-Received: by 2002:a05:6a02:28b:b0:439:19d6:fad5 with SMTP id bk11-20020a056a02028b00b0043919d6fad5mr5672694pgb.591.1665770089619; Fri, 14 Oct 2022 10:54:49 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:49 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 7/9] gpiolib: of: factor out code overriding gpio line polarity Date: Fri, 14 Oct 2022 10:54:31 -0700 Message-Id: <20221011-gpiolib-quirks-v2-7-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746687279613299785?= X-GMAIL-MSGID: =?utf-8?q?1746687279613299785?= There are several instances where we use a separate property to override polarity specified in gpio property. Factor it out into a separate function. Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 48 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 77cabcfb2da0..da274d9adcdf 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -130,6 +130,28 @@ bool of_gpio_need_valid_mask(const struct gpio_chip *gc) return false; } +/* + * Overrides stated polarity of a gpio line and warns when there is a + * discrepancy. + */ +static void of_gpio_quirk_polarity(const struct device_node *np, + bool active_high, + enum of_gpio_flags *flags) +{ + if (active_high) { + if (*flags & OF_GPIO_ACTIVE_LOW) { + pr_warn("%s GPIO handle specifies active low - ignored\n", + of_node_full_name(np)); + *flags &= ~OF_GPIO_ACTIVE_LOW; + } + } else { + if (!(*flags & OF_GPIO_ACTIVE_LOW)) + pr_info("%s enforce active low on GPIO handle\n", + of_node_full_name(np)); + *flags |= OF_GPIO_ACTIVE_LOW; + } +} + static void of_gpio_flags_quirks(const struct device_node *np, const char *propname, enum of_gpio_flags *flags, @@ -145,7 +167,7 @@ static void of_gpio_flags_quirks(const struct device_node *np, (!(strcmp(propname, "enable-gpio") && strcmp(propname, "enable-gpios")) && of_device_is_compatible(np, "regulator-gpio")))) { - bool active_low = !of_property_read_bool(np, + bool active_high = of_property_read_bool(np, "enable-active-high"); /* * The regulator GPIO handles are specified such that the @@ -153,13 +175,7 @@ static void of_gpio_flags_quirks(const struct device_node *np, * the polarity of the GPIO line. Any phandle flags must * be actively ignored. */ - if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) { - pr_warn("%s GPIO handle specifies active low - ignored\n", - of_node_full_name(np)); - *flags &= ~OF_GPIO_ACTIVE_LOW; - } - if (active_low) - *flags |= OF_GPIO_ACTIVE_LOW; + of_gpio_quirk_polarity(np, active_high, flags); } /* * Legacy open drain handling for fixed voltage regulators. @@ -200,18 +216,10 @@ static void of_gpio_flags_quirks(const struct device_node *np, * conflict and the "spi-cs-high" flag will * take precedence. */ - if (of_property_read_bool(child, "spi-cs-high")) { - if (*flags & OF_GPIO_ACTIVE_LOW) { - pr_warn("%s GPIO handle specifies active low - ignored\n", - of_node_full_name(child)); - *flags &= ~OF_GPIO_ACTIVE_LOW; - } - } else { - if (!(*flags & OF_GPIO_ACTIVE_LOW)) - pr_info("%s enforce active low on chipselect handle\n", - of_node_full_name(child)); - *flags |= OF_GPIO_ACTIVE_LOW; - } + bool active_high = of_property_read_bool(child, + "spi-cs-high"); + of_gpio_quirk_polarity(child, active_high, + flags); of_node_put(child); break; } From patchwork Fri Oct 14 17:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp313351wrs; Fri, 14 Oct 2022 11:06:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4gGa3t1jYiVg2xM6H9bksrVlpPOc6U5qmJ08/C/NnVDLdZgQ99ZPZU8sU+Arch/0cCLpgR X-Received: by 2002:a17:907:3f92:b0:78e:2eb5:6aec with SMTP id hr18-20020a1709073f9200b0078e2eb56aecmr205290ejc.85.1665770795607; Fri, 14 Oct 2022 11:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770795; cv=none; d=google.com; s=arc-20160816; b=y1YDENvUuZHuYVqceeKAcKaReiD7uIuJOnQ6IP6HXPsG54uWxudBNbkhvoCH2fx1sQ I0qJ/sThn2hYkU7m5uzzCL3ba9MwZYsOghtT/zcfiWnoRKaQIH0Yq2nsVKXJHArh6Kdz owKi04+pma8iJyrBc151v1b14zxMnQi91BCD+AEce3/VSbjvzb78mhkjW+lFnYdYTQ5I nnvSjKgFhaTkA4Gy79zlkfEHACIyN0QWaElnJhlgwJlVgWjwc9MvzCuOgJUQ6NUhWPRm 4h8En04NPHPry5oJeOI5O0Bp8riuSAL2D7YmqabNWX9NTjANxskJPseNJ8jkK6a2FCSA NuLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ItwD3cs9eKU04Q3Z4ewr71YmDkGz4wd+DL/2Fjg5hWk=; b=lBS/1CLEassy/hRIJ84Cxz2kaeF+fdPMKcwAu2sr7cng9bowfEYbR2l7zfKsjlFy+6 G0taGbjRQOzNbcTId6+q4xBvEHo5y6BI/RI1gvOykRepOOSYhKppCVGtMG3sOgYE/sN1 tJ2ZXCcvGJkbMfG24S4g2bQ6MBXqFhbhwRD3/y/hYjqr+7OdJsEWUwCx5NGDw/Kla37H XZ+oC+yEt1IpaE0QUgNj6E7Bv+B3CTzRqNU69vVLVZ6g+Crnyjl7HnQsjHm9MbjuaHtx b1JTFsSeOfr93OsaAsea2LZ6kgMu+TikkbVWvZPmTqsAyBoExiKYOaDafXLf90aZKwlG /Vww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qrN4P68o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk38-20020a1709077fa600b0078d9be7f100si3094281ejc.852.2022.10.14.11.06.09; Fri, 14 Oct 2022 11:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qrN4P68o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230465AbiJNRzY (ORCPT + 99 others); Fri, 14 Oct 2022 13:55:24 -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-Received: by 2002:a17:902:ced2:b0:17f:5eb2:cd72 with SMTP id d18-20020a170902ced200b0017f5eb2cd72mr6277520plg.162.1665770091373; Fri, 14 Oct 2022 10:54:51 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:50 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 8/9] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Date: Fri, 14 Oct 2022 10:54:32 -0700 Message-Id: <20221011-gpiolib-quirks-v2-8-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746687278092947940?= X-GMAIL-MSGID: =?utf-8?q?1746687278092947940?= Bindings for Freescale Fast Ethernet Controller use a separate property "phy-reset-active-high" to specify polarity of its phy gpio line. To allow converting the driver to gpiod API we need to add this quirk to gpiolib. Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index da274d9adcdf..805222a2e6bc 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -231,6 +231,33 @@ static void of_gpio_flags_quirks(const struct device_node *np, !strcmp(propname, "snps,reset-gpio") && of_property_read_bool(np, "snps,reset-active-low")) *flags |= OF_GPIO_ACTIVE_LOW; + + /* + * Freescale Fast Ethernet Controller uses a separate property to + * describe polarity of the phy reset line. + */ + if (IS_ENABLED(CONFIG_FEC)) { + static const char * const fec_devices[] = { + "fsl,imx25-fec", + "fsl,imx27-fec", + "fsl,imx28-fec", + "fsl,imx6q-fec", + "fsl,mvf600-fec", + "fsl,imx6sx-fec", + "fsl,imx6ul-fec", + "fsl,imx8mq-fec", + "fsl,imx8qm-fec", + "fsl,s32v234-fec", + NULL + }; + + if (!strcmp(propname, "phy-reset-gpios") && + of_device_compatible_match(np, fec_devices)) { + bool active_high = of_property_read_bool(np, + "phy-reset-active-high"); + of_gpio_quirk_polarity(np, active_high, flags); + } + } } /** From patchwork Fri Oct 14 17:54:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 2776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp313076wrs; Fri, 14 Oct 2022 11:05:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM55muUzITyjIMrcGGafKabB1OCu0ob/iHnQQbO447gPeRVMhcJP+c6fifawVG8Fvg/Jp8r7 X-Received: by 2002:a17:907:9493:b0:78d:765:6cc9 with SMTP id dm19-20020a170907949300b0078d07656cc9mr4488457ejc.265.1665770756307; Fri, 14 Oct 2022 11:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665770756; cv=none; d=google.com; s=arc-20160816; b=I+RNsiZ2oKAF7Hi1SnU8I/EvZBG5RYUWpiviIyMf+azYIgTjxtK0E7VHyxPIFS4g6x 5f/3rXwkPYaOac1vUk/RGr+9CvJt3+VQ1O6VfECC9p1aZol5b8egomDPFcvJCuq0K9Qf BysAhaSRklQixucmDp90ODOulxywL3A9PzWuwUpHFor8Msid1XPzVoNzbijzGXBSph8T lq684Ib/mvGoN7Alb+eFhfO7rNtL1TgIDE3GJQrWJZCcr2HCTLHIXvJwvf+YIj2Jo2Vy leEN6vYzdQVlV6UU4E+m+9XPJf1zQuJYF/BbGMTLhDE3h2wj+0HuMTkuPLTkmhpWNBZf VcGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DDr9juWg3u7tqOqaJOOvY3u67HoyFj37SYo8BbenwWk=; b=WZWpCOGeoe2RdoVe4hZaIRdWzElG/RsvMgNHUcXaDKxOBzxuc7ENE0E/CcbWAFnXtD ffuhcC6rD3MwZxw3+bmUrld7T3vjnETOfajzOh3vOni5k77OEHrMMJm2PLRqG5Y0Oc4H sb4AoS07fwI0OqcZdqBsTdo+24Vi8sIOZBU2EPTtEENkwVx2oLVN7883EknvSCRs15pz PKoJi6qrPIbvqLWh1+gW8CkclRRMgmwINbifqz9Ilv7hw8hk41vTBVXn332xSJZZqamF Ff1bn1LWgxOIFFQFr5ZKDTJLU9Ay8XvqRVZs2IwjSGHkZhcKwSqSgUbzCxWebpIKd5kM Yqmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="K7/WyOZW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp14-20020a170906c14e00b00773e2e6f605si2669173ejc.930.2022.10.14.11.05.26; Fri, 14 Oct 2022 11:05:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="K7/WyOZW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbiJNRza (ORCPT + 99 others); Fri, 14 Oct 2022 13:55:30 -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-Received: by 2002:a63:1d22:0:b0:439:3e7c:8af7 with SMTP id d34-20020a631d22000000b004393e7c8af7mr5605142pgd.78.1665770092947; Fri, 14 Oct 2022 10:54:52 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:da06:5604:594f:f6af]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b0017f7819732dsm2011780plb.77.2022.10.14.10.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:54:52 -0700 (PDT) From: Dmitry Torokhov To: Bartosz Golaszewski , Linus Walleij Cc: linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Alexander Stein , linux-kernel@vger.kernel.org, Daniel Thompson , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2 9/9] gpiolib: of: add a quirk for reset line polarity for Himax LCDs Date: Fri, 14 Oct 2022 10:54:33 -0700 Message-Id: <20221011-gpiolib-quirks-v2-9-73cb7176fd94@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> References: <20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-5166b X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746687236360623768?= X-GMAIL-MSGID: =?utf-8?q?1746687236360623768?= Existing DTS that use legacy (non-standard) property name for the reset line "gpios-reset" also specify incorrect polarity (0 which maps to "active high"). Add a quirk to force polarity to "active low" so that once driver is converted to gpiod API that pays attention to line polarity it will work properly. Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpiolib-of.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 805222a2e6bc..26d57465fec9 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -152,11 +152,47 @@ static void of_gpio_quirk_polarity(const struct device_node *np, } } +/* + * This quirk does static polarity overrides in cases where existing + * DTS specified incorrect polarity. + */ +static void of_gpio_try_fixup_polarity(const struct device_node *np, + const char *propname, + enum of_gpio_flags *flags) +{ + static const struct { + const char *compatible; + const char *propname; + bool active_high; + } gpios[] = { +#if !IS_ENABLED(CONFIG_LCD_HX8357) + /* + * Himax LCD controllers used incorrectly named + * "gpios-reset" property and also specified wrong + * polarity. + */ + { "himax,hx8357", "gpios-reset", false }, + { "himax,hx8369", "gpios-reset", false }, +#endif + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gpios); i++) { + if (of_device_is_compatible(np, gpios[i].compatible) && + !strcmp(propname, gpios[i].propname)) { + of_gpio_quirk_polarity(np, gpios[i].active_high, flags); + break; + } + } +} + static void of_gpio_flags_quirks(const struct device_node *np, const char *propname, enum of_gpio_flags *flags, int index) { + of_gpio_try_fixup_polarity(np, propname, flags); + /* * Some GPIO fixed regulator quirks. * Note that active low is the default.