Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3683748rwb; Fri, 30 Sep 2022 07:03:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47E76HiiT1V2zjxWZtG8sKjWH0s5+eeGcWwlecBiCCCi4RPYHxtDpKWxdW4LZgobcxjg0O X-Received: by 2002:a17:907:7fa0:b0:782:9713:1e with SMTP id qk32-20020a1709077fa000b007829713001emr6707387ejc.394.1664546604956; Fri, 30 Sep 2022 07:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664546604; cv=none; d=google.com; s=arc-20160816; b=knbluOL1X1q9IkThgupGYkc366zBfS1brSikIh9HtloOnirm/p2Qxwls7mmfODmb0s 1koIqVluKQNRcjWheCT0NRu2u0oTd7PhNJ5N9bOCokeJ9ySPQJBcDd4+FEHH7sFsfLPN YBfCDsYsvJ6p5Ykz99hvAHziATBKo8GuVuIi6+HCPIRZewfrIdqsG6L0iQGA2a9leiJ5 vErkqFYc/MvIPxXUBU4LLmrZYEq8PR96PlijVP86kz3cNb8vEgBiSfK7SuMGaieh4Dsi j/U1H+YJMoWfzAtQtoXaArMzTgrGHXQLHyWowgTBmLl491aDgtB9UcqXOfqR1tBSqp4C vQtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=QCDqUbozRtW6tJXIT64BXDrAjp3WyLJ2GS6vDabv15c=; b=0+ZRwxcEgfiGgqPu0yv3ppbWTbV54ai7Un2q6Jwm/iolYEsq80oBapxsH8lDLNghmt bSSGS4Nntx3cIzCG92nagbrL67OCtU3QXdD2R7M2H464itPRwj7xtUx9O5Yk1UNs/d63 WTgcj10g/E/e1URuMeTdWFJ418N+C5tZI6X8Mu2zhEpYPslHpUwk2Im2b21ouBnho2E2 OqK0MtsFO1fgseYs6kODwaAmUHxC5HfbQLjwqrNSfO2ypyiapV6SQuduzYnAEimaipkm YanOLfK36BSBcj82QyUBUf25bWEAcGtwixM5iPkeBAQ/O21m3zdcy3MO7cslhkFzHgbO 4kxg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a056402129600b00450c1de6234si1931309edv.587.2022.09.30.07.02.51; Fri, 30 Sep 2022 07:03:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbiI3NVG (ORCPT + 99 others); Fri, 30 Sep 2022 09:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbiI3NU6 (ORCPT ); Fri, 30 Sep 2022 09:20:58 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BA5A4B2E; Fri, 30 Sep 2022 06:20:56 -0700 (PDT) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 2CB0020005; Fri, 30 Sep 2022 13:20:51 +0000 (UTC) From: Quentin Schulz Cc: linus.walleij@linaro.org, brgl@bgdev.pl, heiko@sntech.de, jay.xu@rock-chips.com, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, foss+kernel@0leil.net, Quentin Schulz , stable@vger.kernel.org Subject: [PATCH v2 2/2] gpio: rockchip: request GPIO mux to pinctrl when setting direction Date: Fri, 30 Sep 2022 15:20:33 +0200 Message-Id: <20220930132033.4003377-3-foss+kernel@0leil.net> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220930132033.4003377-1-foss+kernel@0leil.net> References: <20220930132033.4003377-1-foss+kernel@0leil.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Quentin Schulz Before the split of gpio and pinctrl sections in their own driver, rockchip_set_mux was called in pinmux_ops.gpio_set_direction for configuring a pin in its GPIO function. This is essential for cases where pinctrl is "bypassed" by gpio consumers otherwise the GPIO function is not configured for the pin and it does not work. Such was the case for the sysfs/libgpiod userspace GPIO handling. Let's call pinctrl_gpio_direction_input/output when setting the direction of a GPIO so that the pinctrl core requests from the rockchip pinctrl driver to put the pin in its GPIO function. Fixes: 9ce9a02039de ("pinctrl/rockchip: drop the gpio related codes") Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio") Cc: stable@vger.kernel.org Reviewed-by: Heiko Stuebner Signed-off-by: Quentin Schulz --- v2: - added Reviewed-by, - added missing linux/pinctrl/consumer.h header, drivers/gpio/gpio-rockchip.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index bb50335239ac8..9c976ad7208ef 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -156,6 +157,12 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip, unsigned long flags; u32 data = input ? 0 : 1; + + if (input) + pinctrl_gpio_direction_input(bank->pin_base + offset); + else + pinctrl_gpio_direction_output(bank->pin_base + offset); + raw_spin_lock_irqsave(&bank->slock, flags); rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr); raw_spin_unlock_irqrestore(&bank->slock, flags); -- 2.37.3