From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 15/20] firmware: ti_sci: add function to get global handle
Date: Fri, 29 Nov 2024 12:44:30 +0100 [thread overview]
Message-ID: <20241129-k3-r5-v1-15-67c4bb42a5c7@pengutronix.de> (raw)
In-Reply-To: <20241129-k3-r5-v1-0-67c4bb42a5c7@pengutronix.de>
Most users access the ti_sci interface by ti,sci phandles in their
device nodes. The code setting up the images on the A53 cores doesn't
have a device node though, so add a function for accessing the ti_sci
without having a phandle.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/firmware/ti_sci.c | 59 ++++++++++++++--------------------------
include/soc/ti/ti_sci_protocol.h | 7 -----
2 files changed, 21 insertions(+), 45 deletions(-)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 9047f84434..b2cd369bd5 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -277,7 +277,7 @@ static int ti_sci_do_xfer(struct ti_sci_info *info,
*
* Return: 0 if all went fine, else return appropriate error.
*/
-static int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
+static __maybe_unused int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
{
struct ti_sci_msg_resp_version *rev_info;
struct ti_sci_version_info *ver;
@@ -2650,29 +2650,20 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
fwl_ops->change_fwl_owner = ti_sci_cmd_change_fwl_owner;
}
-/**
- * ti_sci_get_handle_from_sysfw() - Get the TI SCI handle of the SYSFW
- * @dev: Pointer to the SYSFW device
- *
- * Return: pointer to handle if successful, else EINVAL if invalid conditions
- * are encountered.
- */
-const
-struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct device *sci_dev)
+static struct ti_sci_handle *ti_sci_get_by_node(struct device_node *np)
{
- struct ti_sci_info *info;
- int ret;
+ struct ti_sci_info *entry, *info = NULL;
- if (!sci_dev)
- return ERR_PTR(-EINVAL);
+ of_device_ensure_probed(np);
- info = dev_get_priv(sci_dev);
- if (!info)
- return ERR_PTR(-EINVAL);
+ list_for_each_entry(entry, &ti_sci_list, list)
+ if (dev_of_node(entry->dev) == np) {
+ info = entry;
+ break;
+ }
- ret = ti_sci_cmd_get_revision(&info->handle);
- if (ret)
- return ERR_PTR(-EINVAL);
+ if (!info)
+ return ERR_PTR(-ENODEV);
return &info->handle;
}
@@ -2686,14 +2677,17 @@ struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct device *sci_dev)
*/
const struct ti_sci_handle *ti_sci_get_handle(struct device *dev)
{
- struct device *sci_dev;
-
- if (!dev)
- return ERR_PTR(-EINVAL);
+ struct device_node *np;
- sci_dev = dev->parent;
+ if (dev) {
+ np = dev->parent->of_node;
+ } else {
+ np = of_find_compatible_node(NULL, NULL, "ti,k2g-sci");
+ if (!np)
+ return ERR_PTR(-ENODEV);
+ }
- return ti_sci_get_handle_from_sysfw(sci_dev);
+ return ti_sci_get_by_node(np);
}
/**
@@ -2706,25 +2700,14 @@ const struct ti_sci_handle *ti_sci_get_handle(struct device *dev)
const struct ti_sci_handle *ti_sci_get_by_phandle(struct device *dev,
const char *property)
{
- struct ti_sci_info *entry, *info = NULL;
struct device_node *np;
np = of_parse_phandle(dev->of_node, property, 0);
if (!np)
return ERR_PTR(-EINVAL);
- of_device_ensure_probed(np);
-
- list_for_each_entry(entry, &ti_sci_list, list)
- if (dev_of_node(entry->dev) == np) {
- info = entry;
- break;
- }
-
- if (!info)
- return ERR_PTR(-ENODEV);
- return &info->handle;
+ return ti_sci_get_by_node(np);
}
/**
diff --git a/include/soc/ti/ti_sci_protocol.h b/include/soc/ti/ti_sci_protocol.h
index f41ed82b91..e1c9956eb1 100644
--- a/include/soc/ti/ti_sci_protocol.h
+++ b/include/soc/ti/ti_sci_protocol.h
@@ -654,7 +654,6 @@ struct ti_sci_resource {
#if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL)
-const struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct device *dev);
const struct ti_sci_handle *ti_sci_get_handle(struct device *dev);
const struct ti_sci_handle *ti_sci_get_by_phandle(struct device *dev,
const char *property);
@@ -663,12 +662,6 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
struct device *dev, u32 dev_id, char *of_prop);
#else /* CONFIG_TI_SCI_PROTOCOL */
-static inline
-const struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct device *dev)
-{
- return ERR_PTR(-EINVAL);
-}
-
static inline const struct ti_sci_handle *ti_sci_get_handle(struct device *dev)
{
return ERR_PTR(-EINVAL);
--
2.39.5
next prev parent reply other threads:[~2024-11-29 12:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 11:44 [PATCH 00/20] ARM: K3: Add R5 boot support Sascha Hauer
2024-11-29 11:44 ` [PATCH 01/20] ARM: add ARMv7R MPU support Sascha Hauer
2024-11-29 11:44 ` [PATCH 02/20] lib/rationale: compile for pbl Sascha Hauer
2024-11-29 11:44 ` [PATCH 03/20] DDR: Add k3 DDR driver Sascha Hauer
2024-11-29 11:44 ` [PATCH 04/20] ARM: move ARM_CPU_PART_* defines to header Sascha Hauer
2024-11-29 11:44 ` [PATCH 05/20] nommu_v7_vectors_init: disable for r5 Sascha Hauer
2024-11-29 11:44 ` [PATCH 06/20] clocksource: timer-ti-dm: add support for K3 SoCs Sascha Hauer
2024-11-29 11:44 ` [PATCH 07/20] ARM: K3: mount /boot even with env handling disabled Sascha Hauer
2024-11-29 11:44 ` [PATCH 08/20] clk: add K3 clk driver Sascha Hauer
2024-11-29 11:44 ` [PATCH 09/20] pmdomain: add K3 driver Sascha Hauer
2024-11-29 11:44 ` [PATCH 10/20] rproc: add K3 arm64 rproc driver Sascha Hauer
2024-11-29 11:44 ` [PATCH 11/20] ARM: k3: add k3_debug_ll_init() Sascha Hauer
2024-11-29 11:44 ` [PATCH 12/20] ARM: K3: use debug_ll code for regular PBL console Sascha Hauer
2024-11-29 11:44 ` [PATCH 13/20] elf: use iomem regions as fallback when loading to non-sdram memory Sascha Hauer
2024-11-29 11:44 ` [PATCH 14/20] rproc: add K3 system_controller Sascha Hauer
2024-11-29 11:44 ` Sascha Hauer [this message]
2024-11-29 11:44 ` [PATCH 16/20] ARM: k3: Add initial r5 support Sascha Hauer
2024-11-29 11:44 ` [PATCH 17/20] ARM: k3: Add k3img tool Sascha Hauer
2024-11-29 11:44 ` [PATCH 18/20] ARM: beagleplay: add binary files Sascha Hauer
2024-11-29 11:44 ` [PATCH 19/20] ARM: beagleplay: add Cortex-R5 boot support Sascha Hauer
2024-11-29 11:44 ` [PATCH 20/20] Documentation: add build documentation for TI K3 SoCs Sascha Hauer
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=20241129-k3-r5-v1-15-67c4bb42a5c7@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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