From patchwork Mon Oct 2 02:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 13405502 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 9F0ADE784A6 for ; Mon, 2 Oct 2023 02:17:54 +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=onsOMaddIDqA8vVTWVuJTVQB0VICEmBo95zMkhhSe1E=; b=A6KKWsp/7xb41U qMoD36k1qNnibFDM9vrqDV/O7xMnb3UKSmHcS4PW0p+ZHcJCjwAmO+GEzfzHcY+dOMeNuF/FF364Q jnTTp0BjLOpmB5myWN3F2pMVgDWmfhugU65ZCB9tj7QLiWcHwKuUKwOZfsG0WGfwfqfEJNaUMN0A8 6ENZB0es/1ud6kR3QoXfaEtbKuEvNnGaS75rBGJ5+BxhdVJT0ts+/5HWGpI4prp+soGiJtzUhGnzT t8BGfmxlBda3S7OcRKI92a1LqSwn5TkmFzUXU72bprMxT569el90fCIj0onnnMAXSkWzccXkyb/k/ K1FvyQNCxL0x3sa1A1wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qn8Uy-00BqMD-0w; Mon, 02 Oct 2023 02:17:28 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qn8Uv-00BqKo-0w for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2023 02:17:27 +0000 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6bc9353be9bso2154026a34.1 for ; Sun, 01 Oct 2023 19:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696213043; x=1696817843; 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=BpQqEZJbjzE/OtRVWr6AW4/d2IDgozzxIJunGcQEruc=; b=amdCfB4VSOkyhvLB16uMiU8Qhpuk//Cbx7IFscCRoZnAxif/XPIJ+Scr5v/+OZhXrM fRGGaAvdaMjlpcfXhtBHbXo9o+aUhoXIrvclzhUPTiSIgmjLy9csjshF+GSGvQTUvwAE mU7rZIns7ePS0OmMEZX5rP+Np8OchfR04IHTJy1AsfaIl1E3iGug8Fmfnmh+K7eBnxfz mflKbmMzvoCdWl+H8yL4Zm1yFRQwFcvyS0M7H/FPuVXOIFy28Gm6XFEpk/k93PMXpIHb DCJp8Al6cdeuD6MiJ9JEiukwQFmIPBGSzt1jL7VwsEgdrOLzAyqY779IWOq02i9LMiwu H1ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696213043; x=1696817843; 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=BpQqEZJbjzE/OtRVWr6AW4/d2IDgozzxIJunGcQEruc=; b=sXgbgp8cW+it0BRo8e9TwLplCRST2yaDJMhHZZWP3fnWOKDSDDp8qT0xekIBpA2l+U a5YDhJFzl7u4PTG/KYoHZ0Anb56908+jRsIes4ps8JySIXx0IUwQ7xlj2coMf86wndXK BAdshKCY7H8RqE1KQnfV7ap++P0mFK9QaInKc5wnoaB4AEjIuglWxtu1Hi+8h0Xy8oCk SEfhmnthRPUix+OtrqCEy99OaTUJd/c49ls5eWDnvTo4gxZ21Zy0jCr21GF3RkUfX5bh FKMIkUaN6mZ8mr4CpEIsp8Ys7/78kLAHJIYv70y+ckrRjKFEBxIBgA0KssYzfFEXC1Gc GcDg== X-Gm-Message-State: AOJu0YzYIBr8XCMdidU4/3vX4aeJnUEyhhLqgpKfqp7okXgDxBqjSAz8 r12/kFg/qcrOPnzoyBHYc6LCIQ== X-Google-Smtp-Source: AGHT+IF9a5sDpJduGBa9qTDU8td8zTYfrA9e7KFY0KVMdTtzUgrxfXt6AqoHwiWtGvtE6xmSHQMtnQ== X-Received: by 2002:a05:6808:3613:b0:3ae:108d:acee with SMTP id ct19-20020a056808361300b003ae108daceemr9410319oib.1.1696213042996; Sun, 01 Oct 2023 19:17:22 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:7ab1:199:d138:f054]) by smtp.gmail.com with ESMTPSA id mg11-20020a17090b370b00b002609cadc56esm5278319pjb.11.2023.10.01.19.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 19:17:22 -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 2/4] pinctrl: add pinctrl_gpio_get_config() Date: Mon, 2 Oct 2023 11:16:00 +0900 Message-Id: <20231002021602.260100-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231002021602.260100-1-takahiro.akashi@linaro.org> References: <20231002021602.260100-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-20231001_191725_331485_6834581B X-CRM114-Status: GOOD ( 12.59 ) 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 initially be used to implement gpio_get interface in SCMI pinctrl based GPIO driver. Signed-off-by: AKASHI Takahiro Reviewed-by: Linus Walleij --- 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;