From patchwork Mon Oct 2 02:15:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 13405501 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 51B1DE784A7 for ; Mon, 2 Oct 2023 02:17:50 +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=SfLM1O4xqv1mTUTSOFseUcY2WPelxH3iN0JilwwbJg4=; b=p3p8nq7xRer2mf OxMreqzktxuzC/8chYQnJ1FCESuSEXGvEbzNtYbhi11bY3LZ+xpNIuOV+Ra0Rsu/e9HWrVFatLN0r x1VJtB8IMMzHPSqELQGBC0uK7sly7b5gY+4gsa52YPv23fbL0jpiyaDSiXri88dzye0pRMRlF9h0K kuVVkN6O2xGrAIAX2uZaWgFmUryRyr56nwWXFrFSzWwRjsH3vLDA0B7NkgkOQBIHOPYZXjQbkf9B1 I9ptqWAAJ6vCA92dtxqSuqbf2Y3E7EMOK8fGyPmBMAZWDoqNDQgyS3KSXDoAuc3hYCHvnKdvnWXdI Gdrsqk4Mmkc05FEg+E8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qn8Uu-00BqLA-2G; Mon, 02 Oct 2023 02:17:24 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qn8Ur-00BqK8-1H for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2023 02:17:22 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2739c8862d2so3432170a91.1 for ; Sun, 01 Oct 2023 19:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696213040; x=1696817840; 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=OqXtc+pvir/IxuRnJD6IqOJ/WGP90gqy5QBVu45Fdzc=; b=R0353sGaZShYD+B3Vg4zhRvQQllQuDxKHl9dN6QC0tE+2PzXIqLTR6M29VqpZZuBtB zf5eS1ZGG64YEaFBKIx3wjw+eX8Q6Zwgaifz1snusx3i4cjRRxSoxs9gjP4LhgkikyhT 9LsAgxF6Np2uZQ+CqOlbyBd36QLPARC8CAU8JXD72N54DN7oYJ8rjBkxIUtPLjJLAGa+ Wy0q9H05SEcLDWCT0Dssb1AlsY9WvbJZHEdwSvovFVvelJsxEQ1GrkUCRENGnGwc+H71 PTODWRJEP4Sws3RtA/40oZ2p9gu69PTCmuFa4sz3zV0Mk0GXlOxVlPHPXO2MTPeruK5R UmBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696213040; x=1696817840; 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=OqXtc+pvir/IxuRnJD6IqOJ/WGP90gqy5QBVu45Fdzc=; b=XI6VDcTkfBb10LjCgRJJYHvx9okizjG4tAu1nB9cfJN2vPAyuy8LZuDcsBW9Dbv3Pt fhpkLyfKYQT9P08a/jiFR9beYUTDJB99WW3qN9amzD5tlQCeH1wphHLXPNe0oJKQvyAV FZvgknRGODGB1jlF8zrBuT7aV9Y1jGBfHHP+kXT0XT7V0xSHzM92X3edE5QASrFowZMQ oKbAVK+PYAjJRtI95zS5rj5idSXvjkX04/SwLoLJNjiKakD00NtIVuXQAtuTy7V0p1n/ 6lYpmIhFpwfVcoDR3ZGI5JKzlz6q3qKivB+H+PfniyUG+JELNKM7NFambGQNz85Rdyql Dzqw== X-Gm-Message-State: AOJu0YwrXOZKehmNEGB60M9pEnt8odi5/bvoNdx4eStfnJA22V+TyCKp 3dpgAAmh1VDizgRK0T3SkJVCrw== X-Google-Smtp-Source: AGHT+IEusTnW4378lO9AUwQdv9HFrR0OPNAAVojwLcl5rMvEgnFubpbvDWr1u456gCLJfr4DyaWHaA== X-Received: by 2002:a17:90a:1383:b0:274:60c7:e15a with SMTP id i3-20020a17090a138300b0027460c7e15amr9153621pja.4.1696213039746; Sun, 01 Oct 2023 19:17:19 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 19:17:19 -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 1/4] pinctrl: define PIN_CONFIG_INPUT Date: Mon, 2 Oct 2023 11:15:59 +0900 Message-Id: <20231002021602.260100-2-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_191721_434083_FB19F692 X-CRM114-Status: GOOD ( 11.31 ) 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 allows for enabling SCMI pinctrl based GPIO driver to obtain an input gpio pin. Signed-off-by: AKASHI Takahiro --- include/linux/pinctrl/pinconf-generic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h index d74b7a4ea154..842b328ea504 100644 --- a/include/linux/pinctrl/pinconf-generic.h +++ b/include/linux/pinctrl/pinconf-generic.h @@ -67,6 +67,8 @@ struct pinctrl_map; * passed as argument. The argument is in mA. * @PIN_CONFIG_DRIVE_STRENGTH_UA: the pin will sink or source at most the current * passed as argument. The argument is in uA. + * @PIN_CONFIG_INPUT: This will obtain a value on an input pin. The returned + * argument indicates the value. * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode, * which means it will wait for signals to settle when reading inputs. The * argument gives the debounce time in usecs. Setting the @@ -128,6 +130,7 @@ enum pin_config_param { PIN_CONFIG_DRIVE_PUSH_PULL, PIN_CONFIG_DRIVE_STRENGTH, PIN_CONFIG_DRIVE_STRENGTH_UA, + PIN_CONFIG_INPUT, PIN_CONFIG_INPUT_DEBOUNCE, PIN_CONFIG_INPUT_ENABLE, PIN_CONFIG_INPUT_SCHMITT, 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; From patchwork Mon Oct 2 02:16:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 13405503 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 C8BDCE784A7 for ; Mon, 2 Oct 2023 02:17:57 +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=VZfVgnTIOBSlH/IwmjrFbt3y+a2jpFGfWyvH4yQwmmc=; b=hPtBQo2lQv0ej5 aGrf6aJs1lRx3J1z/b7b0C/RU9fyXd3qHxlAYF7p31Ntx9+jDIUcl3praFtFGgFJqk/Liuk6Y9wsP 6WTizhnbpYHD++qDmRk5zhw1rwAJ7We9DAxk8mrny1qDnQ/CCI+IWTf0nLHmcqOJPyA4IUJtLWCH5 helWcOsk8dD/+SmPUc4sI3BKyE9qA1ug1XxuGmvCcLNV4rlwmtxxfzpztYVe19ImtU+GOXPg+EHeE jQ5i+X2r0F3msRmKybmIRmtcF2QZuoDQBBMS3mL4UNTaV+2eph4UDi4lFGcMrc2XxHOfrZwH1ZXd+ yfnYnuWqfJlrLxuCgcog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qn8V1-00BqNS-34; Mon, 02 Oct 2023 02:17:31 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qn8Uz-00BqLv-0x for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2023 02:17:31 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2739c8862d2so3432191a91.1 for ; Sun, 01 Oct 2023 19:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696213046; x=1696817846; 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=0lhRzM6KnB/PywI33Jm04a+skJPYEHXmin9uZYbICJM=; b=ZYY92LgxfYR/PYeIHlG7S3kilrDvErSi/uT/Z+5go2soJkZ/c+sdELueZHZFDosimk goft4vyPuWUPsYWSlNi+24mN3Jt2wjMLIjVm5tBM8EbNUTfnOM1AKQlJJy7mV/lVboQ8 rmDehOJRwgkOYBJiHoVRbN/YZC7uGO0PL7gMs97E+W0i7INF7AthDf9zGAF5eKbT22vY GZByBYWxpTTYiLj7ATvmbKdqIGaaJheLXvhFNHawoPv0lFe6KAvj0AW5eiP+vrCUZFNc SF1QUcvH7hAIZ02IBn4PzMYkYdtVJRMObDnIWgEGy9qO3nmVQvLPsxCcUNET+jaMAyqi MMfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696213046; x=1696817846; 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=0lhRzM6KnB/PywI33Jm04a+skJPYEHXmin9uZYbICJM=; b=cC/OPpuyYKV49lUkiC3ijjIyDNszYRxoiuFogoKdTxmYs9L8XvyZgSVhfc5EG7O12E SmjGGkOYOR3UgQ51FufxjUlf8p2tldUs0jXl1DA4nCm7jCh7XdEUo2DVIJ36bummc69j w102s/GtZzxTNltafLzgeq43tvmE5lU7sM7JMdmF63PMFP8/kIr5XASGlkPnO5fG7go5 0aTcpb56ZDo9kpMp1DtfktxNGm7lkZete9h4Rc2oVifYWn1HWpcpzeifS1PPUyWdjTZP 1h0+N+OLDG76p/+GrNei0y5bSaF4CZNMgqMkDQlFmcjjVNhQoAoYsGbCIjCbY+3htbIm OfPw== X-Gm-Message-State: AOJu0YykezDShYDMYVXYeEA3piHWnOo8uVnRs1IJ0IrybPjLllkplIdE m/O/K+6nO8XoB1q+2ai9q4n3Sw== X-Google-Smtp-Source: AGHT+IG3u8rwKFBxmfqf4kdkOvutNf56z/KpgPe2CDRNonX06xQsHrHs0e6xhBmsWB2SL+EDWAuH3g== X-Received: by 2002:a17:90a:1383:b0:274:60c7:e15a with SMTP id i3-20020a17090a138300b0027460c7e15amr9153743pja.4.1696213046246; Sun, 01 Oct 2023 19:17:26 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 19:17:25 -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 3/4] gpio: scmi: add SCMI pinctrl based gpio driver Date: Mon, 2 Oct 2023 11:16:01 +0900 Message-Id: <20231002021602.260100-4-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_191729_627765_1BB72DD0 X-CRM114-Status: GOOD ( 22.32 ) 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 SCMI pin control protocol supports not only pin controllers, but also gpio controllers by design. This patch includes a generic gpio driver which allows consumer drivers to access gpio pins that are handled through SCMI interfaces. Signed-off-by: AKASHI Takahiro --- drivers/gpio/Kconfig | 8 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-scmi.c | 154 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 drivers/gpio/gpio-scmi.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 673bafb8be58..1a968b950f3a 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -566,6 +566,14 @@ config GPIO_SAMA5D2_PIOBU The difference from regular GPIOs is that they maintain their value during backup/self-refresh. +config GPIO_SCMI + tristate "GPIO support based on SCMI pinctrl" + depends on OF_GPIO + depends on PINCTRL_SCMI + help + Select this option to support GPIO devices based on SCMI pin + control protocol. + config GPIO_SIFIVE tristate "SiFive GPIO support" depends on OF_GPIO diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index eb73b5d633eb..2abe1e9d5e77 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -141,6 +141,7 @@ obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o obj-$(CONFIG_GPIO_SAMA5D2_PIOBU) += gpio-sama5d2-piobu.o obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o obj-$(CONFIG_GPIO_SCH) += gpio-sch.o +obj-$(CONFIG_GPIO_SCMI) += gpio-scmi.o obj-$(CONFIG_GPIO_SIFIVE) += gpio-sifive.o obj-$(CONFIG_GPIO_SIM) += gpio-sim.o obj-$(CONFIG_GPIO_SIOX) += gpio-siox.o diff --git a/drivers/gpio/gpio-scmi.c b/drivers/gpio/gpio-scmi.c new file mode 100644 index 000000000000..ece63ea62b70 --- /dev/null +++ b/drivers/gpio/gpio-scmi.c @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2023 Linaro Inc. +// Author: AKASHI takahiro + +#include +#include +#include +#include +#include +#include +#include +#include "gpiolib.h" + +struct scmi_gpio_priv { + struct gpio_chip chip; +}; + +static int scmi_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) +{ + unsigned long config; + + config = PIN_CONFIG_OUTPUT_ENABLE; + if (pinctrl_gpio_get_config(chip->gpiodev->base + offset, &config)) + return -1; + if (config) + return GPIO_LINE_DIRECTION_OUT; + + config = PIN_CONFIG_INPUT_ENABLE; + if (pinctrl_gpio_get_config(chip->gpiodev->base + offset, &config)) + return -1; + if (config) + return GPIO_LINE_DIRECTION_IN; + + return -1; +} + +static int scmi_gpio_direction_input(struct gpio_chip *chip, + unsigned int offset) +{ + return pinctrl_gpio_direction_input(chip->gpiodev->base + offset); +} + +static int scmi_gpio_direction_output(struct gpio_chip *chip, + unsigned int offset, int val) +{ + return pinctrl_gpio_direction_output(chip->gpiodev->base + offset); +} + +static int scmi_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + unsigned long config; + + /* FIXME: currently, PIN_CONFIG_INPUT not defined */ + config = PIN_CONFIG_INPUT; + if (pinctrl_gpio_get_config(chip->gpiodev->base + offset, &config)) + return -1; + + /* FIXME: the packed format not defined */ + if (config >> 8) + return 1; + + return 0; +} + +static void scmi_gpio_set(struct gpio_chip *chip, unsigned int offset, int val) +{ + unsigned long config; + + config = PIN_CONF_PACKED(PIN_CONFIG_OUTPUT, val & 0x1); +; + pinctrl_gpio_set_config(chip->gpiodev->base + offset, config); +} + +static u16 sum_up_ngpios(struct gpio_chip *chip) +{ + struct gpio_pin_range *range; + struct gpio_device *gdev = chip->gpiodev; + u16 ngpios = 0; + + list_for_each_entry(range, &gdev->pin_ranges, node) { + ngpios += range->range.npins; + } + + return ngpios; +} + +static int scmi_gpio_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *parent_np; + struct scmi_gpio_priv *priv; + struct gpio_chip *chip; + int ret; + + /* FIXME: who should be the parent */ + parent_np = NULL; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + chip = &priv->chip; + chip->label = dev_name(dev); + chip->parent = dev; + chip->base = -1; + + chip->request = gpiochip_generic_request; + chip->free = gpiochip_generic_free; + chip->get_direction = scmi_gpio_get_direction; + chip->direction_input = scmi_gpio_direction_input; + chip->direction_output = scmi_gpio_direction_output; + chip->get = scmi_gpio_get; + chip->set = scmi_gpio_set; + + ret = devm_gpiochip_add_data(dev, chip, priv); + if (ret) + return ret; + + chip->ngpio = sum_up_ngpios(chip); + + platform_set_drvdata(pdev, priv); + + return 0; +} + +static int scmi_gpio_remove(struct platform_device *pdev) +{ + struct scmi_gpio_priv *priv = platform_get_drvdata(pdev); + + gpiochip_remove(&priv->chip); + + return 0; +} + +static const struct of_device_id scmi_gpio_match[] = { + { .compatible = "arm,scmi-gpio-generic" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, scmi_gpio_match); + +static struct platform_driver scmi_gpio_driver = { + .probe = scmi_gpio_probe, + .remove = scmi_gpio_remove, + .driver = { + .name = "scmi-gpio", + .of_match_table = scmi_gpio_match, + }, +}; +module_platform_driver(scmi_gpio_driver); + +MODULE_AUTHOR("AKASHI Takahiro "); +MODULE_DESCRIPTION("SCMI Pinctrl based GPIO driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Oct 2 02:16:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 13405504 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 EDF5CE784A7 for ; Mon, 2 Oct 2023 02:18:00 +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=hhm8IqK33aD9XenqMIP1Hys2iREGjGNFiryYK9e9ho0=; b=b8T11BMpGx7wqO ySXez4gwTXepXeA7mXfmu6v21i2qzoex7RERokFivgyDvdJtw/NjQGtrIO4xRzixVz/f86wlj6Edz 7jr9G2mqAymqy+dqCa7UIEjaB9/THzaYg8KJU0SuciwEM2DYCJRPP26m7IOA3H+XL0U5HF++OL3Ug WFjH7cfBjnHYaPtBKXOYgLCW0ZKUUlYSIMpkJjUdJsaPSrD6CZNO9edyU2+jfaFTbQh5dFz5pEx/C TquNOhBWKkoHP4TDEQMH0JRZ9HnQliyTWcBnSjpr6syZxU2fI/Fdbz6vxOnffSyhexD86YsFlc1XA nMYeZOyUUaqdRTrvC+Fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qn8V4-00BqPE-0v; Mon, 02 Oct 2023 02:17:34 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qn8V1-00BqMo-2W for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2023 02:17:33 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1dd4115b369so1159518fac.1 for ; Sun, 01 Oct 2023 19:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696213050; x=1696817850; 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=RPOWcZHTqmoq/zqsh7e1DQOIHdOfQaJNQbue+Ak7Pz4=; b=DIDYV+VjEgRFz1xxOEe/3I9m8DrePNwK2SPxbNDq+Pw68wa/pbEd7SCFR733yUEcYm 01EbzzyehSyHOY9rgFWyyC695J5NjsZvlF6Fh7CHFz0w7i+Q8aDD4K9eSocfaXsn6v5R Z1LEGJbRngJfWC0WnrijUTo7Jz4E4NE/I77YzlCc+yPh4+yvpISl/Kxw5SLLDvdckD4o m9fkXgm6BCSZmDHYy+3iEtB0WeKbAdp983YfsWRHvR4Mc5PWsJefR9kCW7z2xXku86xi AaspA4t0miW9fa7qa8BJFCayD21Ic0xgYXO5NnidlTkzk0H1Uf2BhPpyn3NbbLwLwrWV 5+BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696213050; x=1696817850; 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=RPOWcZHTqmoq/zqsh7e1DQOIHdOfQaJNQbue+Ak7Pz4=; b=g2acLIaz4dUJ0XQr0pp/IfRZOsi9Z6+ZqMpgi6Fb3zHusDTkP8tNKufDlxLIfep3Et MgVfpNOMLs8uEJ/w9WBXgUyFgLwe6mREMYSGatBnaaOXd/iIHl1DPJUz02RUxrF1Vwrk l8ApdiPlsA497vgTUSQ77eLfYoHQ5HsyFKkHQbGVO9x4jQP4fymtxWo+rYWyDjmocsfP y2iBdAVJ1Z2S0e90V1wVIrP3WtcEjtHzZfcJ1ToQFsQ0VJ3+Rwf/iPh0kjnpNmXKvKzl sWM+KaaLDjo7TxIcrxIdc+m83SLqzOXi68v/ZWt8JEoyHmL1kA0SzkohCkZ/zTfPf+jF ZAQg== X-Gm-Message-State: AOJu0YzMmQn+joJ+9NonA8I8jfOmtnvxv4rlHTeIBCdZQZ41Wh9NrlsO 7sdNcIkql4jVSV4Viw0awfeIzw== X-Google-Smtp-Source: AGHT+IGpOuQGzvtGHKgSr/mxvP55UKAmUGYnrFTePhofwASv4SkD/NQd9nZ9IBhVQqqOhXeqb9otNw== X-Received: by 2002:a05:6808:2123:b0:3a9:f25d:d917 with SMTP id r35-20020a056808212300b003a9f25dd917mr13656079oiw.4.1696213049725; Sun, 01 Oct 2023 19:17:29 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 19:17:29 -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 4/4] dt-bindings: gpio: Add bindings for SCMI pinctrl based gpio Date: Mon, 2 Oct 2023 11:16:02 +0900 Message-Id: <20231002021602.260100-5-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_191731_817420_B1955FB7 X-CRM114-Status: GOOD ( 12.88 ) 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 A dt binding for SCMI pinctrl based gpio driver is defined in this commit. It basically conforms to generic pinctrl-gpio mapping framework. Signed-off-by: AKASHI Takahiro --- .../bindings/gpio/arm,scmi-gpio.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/arm,scmi-gpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/arm,scmi-gpio.yaml b/Documentation/devicetree/bindings/gpio/arm,scmi-gpio.yaml new file mode 100644 index 000000000000..2601c5594567 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/arm,scmi-gpio.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/arm,scmi-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SCMI pinctrl based generic GPIO controller + +maintainers: + - AKASHI Takahiro + +properties: + $nodename: + pattern: "^scmi_gpio(@[0-9a-f]+)$" + + compatible: + const: arm,scmi-gpio-generic + + gpio-controller: true + + "#gpio-cells": + const: 2 + + gpio-ranges: true + + gpio-ranges-group-names: true + +patternProperties: + "^.+-hog(-[0-9]+)?$": + type: object + properties: + gpio-hog: true + gpios: true + input: true + output-high: true + output-low: true + line-name: true + + required: + - gpio-hog + - gpios + + additionalProperties: false + +required: + - compatible + - gpio-controller + - "#gpio-cells" + - gpio-ranges + +additionalProperties: false + +examples: + - | + #include + + scmi_gpio_0: scmi_gpio@0 { + compatible = "arm,scmi-gpio"; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&scmi_pinctrl 0 10 5>, + <&scmi_pinctrl 5 0 0>; + gpio-ranges-group-names = "", + "pinmux_gpio"; + }; + + // Consumer: + sdhci0_pwrseq { + compatible = "mmc-pwrseq-emmc"; + reset-gpios = <&scmi_gpio_0 0 GPIO_ACTIVE_LOW>; + };