From: Dan Carpenter <dan.carpenter@linaro.org>
To: Sudeep Holla <sudeep.holla@arm.com>,
AKASHI Takahiro <takahiro.akashi@linaro.org>,
Michal Simek <michal.simek@amd.com>
Cc: Cristian Marussi <cristian.marussi@arm.com>,
arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH RFC v2 2/7] firmware: arm_scmi: add is_gpio() function
Date: Sun, 20 Jul 2025 14:38:42 -0500 [thread overview]
Message-ID: <fbcf6cca-784e-47bb-9b61-3028f59a92ba@sabinyo.mountain> (raw)
In-Reply-To: <cover.1753039612.git.dan.carpenter@linaro.org>
Parse the GPIO response in scmi_pinctrl_attributes(), set the gpio
flag, and create an is_gpio() function pointer so that it can be queried.
In SCMI only functions and pins have a GPIO flag so that's why groups are
not handled here.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/firmware/arm_scmi/pinctrl.c | 34 +++++++++++++++++++++++++----
include/linux/scmi_protocol.h | 2 ++
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scmi/pinctrl.c
index d18c2d248f04..10c92007bc1b 100644
--- a/drivers/firmware/arm_scmi/pinctrl.c
+++ b/drivers/firmware/arm_scmi/pinctrl.c
@@ -28,6 +28,7 @@
#define EXT_NAME_FLAG(x) le32_get_bits((x), BIT(31))
#define NUM_ELEMS(x) le32_get_bits((x), GENMASK(15, 0))
+#define GPIO_FUNC(x) le32_get_bits((x), BIT(17))
#define REMAINING(x) le32_get_bits((x), GENMASK(31, 16))
#define RETURNED(x) le32_get_bits((x), GENMASK(11, 0))
@@ -107,6 +108,7 @@ struct scmi_group_info {
struct scmi_function_info {
char name[SCMI_MAX_STR_SIZE];
bool present;
+ bool gpio;
u32 *groups;
u32 nr_groups;
};
@@ -114,6 +116,7 @@ struct scmi_function_info {
struct scmi_pin_info {
char name[SCMI_MAX_STR_SIZE];
bool present;
+ bool gpio;
};
struct scmi_pinctrl_info {
@@ -189,7 +192,7 @@ static int scmi_pinctrl_validate_id(const struct scmi_protocol_handle *ph,
static int scmi_pinctrl_attributes(const struct scmi_protocol_handle *ph,
enum scmi_pinctrl_selector_type type,
- u32 selector, char *name,
+ u32 selector, char *name, bool *gpio,
u32 *n_elems)
{
int ret;
@@ -217,6 +220,8 @@ static int scmi_pinctrl_attributes(const struct scmi_protocol_handle *ph,
ret = ph->xops->do_xfer(ph, t);
if (!ret) {
+ if (gpio)
+ *gpio = GPIO_FUNC(rx->attributes);
if (n_elems)
*n_elems = NUM_ELEMS(rx->attributes);
@@ -610,7 +615,7 @@ static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *ph,
return 0;
ret = scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, group->name,
- &group->nr_pins);
+ NULL, &group->nr_pins);
if (ret)
return ret;
@@ -689,7 +694,7 @@ static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handle *ph,
return 0;
ret = scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, func->name,
- &func->nr_groups);
+ &func->gpio, &func->nr_groups);
if (ret)
return ret;
@@ -772,7 +777,8 @@ static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph,
if (pin->present)
return 0;
- ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL);
+ ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name,
+ &pin->gpio, NULL);
if (ret)
return ret;
@@ -815,9 +821,29 @@ static int scmi_pinctrl_name_get(const struct scmi_protocol_handle *ph,
}
}
+static int scmi_pinctrl_is_gpio(const struct scmi_protocol_handle *ph,
+ u32 selector,
+ enum scmi_pinctrl_selector_type type)
+{
+ struct scmi_pinctrl_info *pi = ph->get_priv(ph);
+ int ret;
+
+ ret = scmi_pinctrl_get_pin_info(ph, selector);
+ if (ret)
+ return ret;
+
+ if (type == PIN_TYPE)
+ return pi->pins[selector].gpio;
+ if (type == FUNCTION_TYPE)
+ return pi->functions[selector].gpio;
+
+ return -EINVAL;
+}
+
static const struct scmi_pinctrl_proto_ops pinctrl_proto_ops = {
.count_get = scmi_pinctrl_count_get,
.name_get = scmi_pinctrl_name_get,
+ .is_gpio = scmi_pinctrl_is_gpio,
.group_pins_get = scmi_pinctrl_group_pins_get,
.function_groups_get = scmi_pinctrl_function_groups_get,
.mux_set = scmi_pinctrl_mux_set,
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 688466a0e816..b4ad32067fc4 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -792,6 +792,8 @@ struct scmi_pinctrl_proto_ops {
int (*name_get)(const struct scmi_protocol_handle *ph, u32 selector,
enum scmi_pinctrl_selector_type type,
const char **name);
+ int (*is_gpio)(const struct scmi_protocol_handle *ph, u32 selector,
+ enum scmi_pinctrl_selector_type type);
int (*group_pins_get)(const struct scmi_protocol_handle *ph,
u32 selector, const unsigned int **pins,
unsigned int *nr_pins);
--
2.47.2
next prev parent reply other threads:[~2025-07-20 19:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-20 19:38 [PATCH RFC v2 0/7] pinctrl-scmi: Add GPIO support Dan Carpenter
2025-07-20 19:38 ` [PATCH RFC v2 1/7] firmware: arm_scmi: move boiler plate code into the get info functions Dan Carpenter
2025-08-21 8:09 ` Cristian Marussi
2025-07-20 19:38 ` Dan Carpenter [this message]
2025-08-21 8:19 ` [PATCH RFC v2 2/7] firmware: arm_scmi: add is_gpio() function Cristian Marussi
2025-07-20 19:38 ` [PATCH RFC v2 4/7] pinctrl-scmi: add PIN_CONFIG_INPUT_VALUE Dan Carpenter
2025-08-21 8:38 ` Cristian Marussi
2025-09-05 8:27 ` Linus Walleij
2025-09-05 8:31 ` Linus Walleij
2025-09-05 9:24 ` Linus Walleij
2025-07-20 19:39 ` [PATCH RFC v2 6/7] pinctrl-scmi: Add GPIO support Dan Carpenter
2025-08-14 8:39 ` Linus Walleij
2025-07-20 19:39 ` [PATCH RFC v2 5/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
2025-08-21 8:48 ` Cristian Marussi
2025-07-20 19:39 ` [PATCH RFC v2 7/7] pinctrl-scmi: remove unused struct member Dan Carpenter
2025-08-21 8:50 ` Cristian Marussi
2025-08-18 9:03 ` [PATCH RFC v2 0/7] pinctrl-scmi: Add GPIO support Linus Walleij
2025-09-04 8:49 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fbcf6cca-784e-47bb-9b61-3028f59a92ba@sabinyo.mountain \
--to=dan.carpenter@linaro.org \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=sudeep.holla@arm.com \
--cc=takahiro.akashi@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox