From patchwork Thu Oct 5 02:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 13409722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD222E936F8 for ; Thu, 5 Oct 2023 02:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wRjYAPpzZhCF17TstlRBG5DBGsh/uLq94zKvz1+167U=; b=1lktU1b+LqLx0A 5X2WOfsL+G4DnhMNzZbqdjC0y6OCl/Ck6iDwiXpx2lSdeQhd70kp5xYxXnQnEqmGfCL+slEslqA+J FJa1d9v++pxCR1fHXnzqU/iZfNKRr8Zhh26ffj6Ahkg9IUSd4j1B0Sk+oheUSRqtACoiUXMCDrwf+ 5krtvUQY8CzkXBL/oBAEeDoMtamr7ImeDErq4ri40ilZopAyNvq1KWtYMCcdAoRlhBNS3HGoeTS0l RHDd2GmADMpwO72jSVuqcT+zUNszxFPRPcrIWg9xGrXzl4ya+wmlByHjvkNdwoDgVPNIAj81j1dN4 OdD0J3SsKuZJIQ7FME/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoEaN-001Grc-1y; Thu, 05 Oct 2023 02:59:35 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoEaJ-001Gpb-2s for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 02:59:34 +0000 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6c61dd1c229so94852a34.0 for ; Wed, 04 Oct 2023 19:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696474770; x=1697079570; darn=lists.infradead.org; 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=10JswCDtKjfsgUgjTt05ZkVWjMO4ZebDQWE8d7lo6tc=; b=e7m+IslFzwMjjOrbECji0eHoHtL6BTjgrKFtyBcVJ8A3OPAyPdIMR/I1ddLZdEd8bm bDQY8K9rKJktm6Sxaq0zQKPgwMa+f2ExoQHi/qeMWjw/aXXDtZ0Sy/jCrCxNsIfHnpl1 KSAtxCk5ohd1QakguBhHZpcJGjU3xM7izaJKqeREn9Kxt7dzW/o+EcYstjAvTvqwlVSm CXTyfTSpgSMO5izBs4EazF0dAN3g3F18qZmVrygjlJuQT0xaR1/kly7rmOiZQ95p/dlN onpdXuX5n64S7HCiKyMTWd1QHeG4j28JIbTdbZPX8GL+17sPhiY+TXjo0QhW8DdNa95O 2RdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696474770; x=1697079570; 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=10JswCDtKjfsgUgjTt05ZkVWjMO4ZebDQWE8d7lo6tc=; b=OLv5rxnBXDz7FxDk5lQcGII2O7z0yo/SeoBGwYhRjVlQ2uceGGtxsl0aaVzJ0dfYqM v88qeQyJKUyXOrlSJ9B0WOLFSPqMHpDpOYH+CFyCmrav8jrF/O82utFAEHhD6XcwpLpY SlNwCvLxPSyVxRF1HRJVIsO/rBAowv4egnKMXho+URi8+oRVXuz1b7MQ+LD9jhRPuTQZ +x7PpibDhpV/xkLXDne8ooHay6MfZ2fpfSXXems2NdCpQMWYMN02q60/h3qZRRU232ue JKXNHNynzMhMpC4WfkuNJkUbIu4oDo1HpYi3EpSigCvCvp5vsHuT/qeqE0TRbVOpiWB2 f64Q== X-Gm-Message-State: AOJu0YyhZb6Q7vpgommI+oFWGBZ08uw/7bMMN0de+R3YOKVAqcq5FXPM fur+E1qGPtt4HhAWUEipPpNJTg== X-Google-Smtp-Source: AGHT+IFVHEUYGWZTaKBOTIg0Zt8j6bgzzj5zfngX59+MW1xuz8QaG4UOkQ4Qt1xPSuv/ln7C4yvMeg== X-Received: by 2002:a05:6808:15a8:b0:3ad:f3c0:5da3 with SMTP id t40-20020a05680815a800b003adf3c05da3mr4643158oiw.3.1696474770489; Wed, 04 Oct 2023 19:59:30 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:a16d:fce2:497:afb7]) by smtp.gmail.com with ESMTPSA id b18-20020a637152000000b005782ad723casm269265pgn.27.2023.10.04.19.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 19:59:30 -0700 (PDT) From: AKASHI Takahiro To: sudeep.holla@arm.com, cristian.marussi@arm.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linus.walleij@linaro.org Cc: Oleksii_Moisieiev@epam.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, AKASHI Takahiro Subject: [RFC v2 3/5] pinctrl: add pinctrl_gpio_get_config() Date: Thu, 5 Oct 2023 11:58:41 +0900 Message-Id: <20231005025843.508689-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005025843.508689-1-takahiro.akashi@linaro.org> References: <20231005025843.508689-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231004_195931_930000_782FF0C4 X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is a counterpart of pinctrl_gpio_set_config() which will be used, at least initially, to implement gpio_get interface in pin controller based generic gpio driver. Signed-off-by: AKASHI Takahiro Reviewed-by: Linus Walleij --- RFC (Oct 2, 2023) --- drivers/pinctrl/core.c | 19 +++++++++++++++++++ include/linux/pinctrl/consumer.h | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index e9dc9638120a..2f9c2efdfe0e 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -926,6 +926,25 @@ int pinctrl_gpio_set_config(unsigned gpio, unsigned long config) } EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config); +int pinctrl_gpio_get_config(unsigned int gpio, unsigned long *config) +{ + struct pinctrl_gpio_range *range; + struct pinctrl_dev *pctldev; + int ret, pin; + + ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); + if (ret) + return ret; + + mutex_lock(&pctldev->mutex); + pin = gpio_to_pin(range, gpio); + ret = pin_config_get_for_pin(pctldev, pin, config); + mutex_unlock(&pctldev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(pinctrl_gpio_get_config); + static struct pinctrl_state *find_state(struct pinctrl *p, const char *name) { diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 4729d54e8995..852fac97a79b 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h @@ -31,6 +31,8 @@ extern void pinctrl_gpio_free(unsigned gpio); extern int pinctrl_gpio_direction_input(unsigned gpio); extern int pinctrl_gpio_direction_output(unsigned gpio); extern int pinctrl_gpio_set_config(unsigned gpio, unsigned long config); +extern int pinctrl_gpio_get_config(unsigned int gpio, + unsigned long *config); extern struct pinctrl * __must_check pinctrl_get(struct device *dev); extern void pinctrl_put(struct pinctrl *p); @@ -92,6 +94,12 @@ static inline int pinctrl_gpio_set_config(unsigned gpio, unsigned long config) return 0; } +static inline int pinctrl_gpio_get_config(unsigned int gpio, + unsigned long *config) +{ + return 0; +} + static inline struct pinctrl * __must_check pinctrl_get(struct device *dev) { return NULL;