All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests
@ 2019-05-22  4:27 Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 1/8] firmware: ti_sci: Allow for device shared and exclusive requests Lokesh Vutla
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

Sysfw provides an option for requesting exclusive access for a
device using the flags MSG_FLAG_DEVICE_EXCLUSIVE. If this flag is
not used, the device is meant to be shared across hosts. Once a device
is requested from a host with this flag set, any request to this
device from a different host will be nacked by sysfw.

Current tisci firmware and pm drivers always requests for device with
exclusive permissions set. But this is not be true for certain devices
that are expcted to be shared across different host contexts.
So add support for getting the shared or exclusive permissions from DT
and request firmware accordingly.

Same bindings are acked in kernel: https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=103447

Also this series adds support for shutting down cores so that R5 cores
can be shutdown right after jumping to ATF.

Andreas Dannenberg (2):
  firmware: ti_sci: Add processor shutdown API method
  armv7R: K3: am654: Shut down R5 core after ATF startup on A53

Lokesh Vutla (6):
  firmware: ti_sci: Allow for device shared and exclusive requests
  power-domain: Add private data to power domain
  dt-bindings: ti_sci_pm_domains: Add support for exclusive and shared
    access
  power: domain: ti_sci_power_domains: Add support for exclusive and
    shared access
  armv7R: dts: k3-am654: Update power-domains property for each node
  cmd: remoteproc: Add support for initializing devices individually

 arch/arm/dts/k3-am65-wakeup.dtsi              |   2 +-
 arch/arm/dts/k3-am65.dtsi                     |   1 +
 arch/arm/dts/k3-am654-base-board-u-boot.dtsi  |   2 +-
 arch/arm/dts/k3-am654-ddr.dtsi                |   4 +-
 arch/arm/dts/k3-am654-r5-base-board.dts       |   8 +-
 arch/arm/mach-k3/am6_init.c                   |  62 +++++
 arch/arm/mach-k3/common.c                     |   6 +-
 arch/arm/mach-k3/include/mach/sys_proto.h     |   1 +
 cmd/remoteproc.c                              |  23 +-
 .../power/ti,sci-pm-domain.txt                |  11 +-
 drivers/firmware/ti_sci.c                     | 216 +++++++++++++++++-
 drivers/firmware/ti_sci.h                     |  50 ++++
 drivers/power/domain/ti-sci-power-domain.c    |  31 ++-
 include/dt-bindings/soc/ti,sci_pm_domain.h    |   9 +
 include/linux/soc/ti/ti_sci_protocol.h        |   7 +
 include/power-domain.h                        |  15 +-
 16 files changed, 411 insertions(+), 37 deletions(-)
 create mode 100644 include/dt-bindings/soc/ti,sci_pm_domain.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/8] firmware: ti_sci: Allow for device shared and exclusive requests
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 2/8] firmware: ti_sci: Add processor shutdown API method Lokesh Vutla
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

Sysfw provides an option for requesting exclusive access for a
device using the flags MSG_FLAG_DEVICE_EXCLUSIVE. If this flag is
not used, the device is meant to be shared across hosts. Once a device
is requested from a host with this flag set, any request to this
device from a different host will be nacked by sysfw. Current tisci
driver enables this flag for every device requests. But this may not
be true for all the devices. So provide a separate commands in driver
for exclusive and shared device requests.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/firmware/ti_sci.c              | 25 ++++++++++++++++++++-----
 include/linux/soc/ti/ti_sci_protocol.h |  3 +++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 303aa6a631..eadb91e107 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -547,8 +547,14 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
  */
 static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
 {
-	return ti_sci_set_device_state(handle, id,
-				       MSG_FLAG_DEVICE_EXCLUSIVE,
+	return ti_sci_set_device_state(handle, id, 0,
+				       MSG_DEVICE_SW_STATE_ON);
+}
+
+static int ti_sci_cmd_get_device_exclusive(const struct ti_sci_handle *handle,
+					   u32 id)
+{
+	return ti_sci_set_device_state(handle, id, MSG_FLAG_DEVICE_EXCLUSIVE,
 				       MSG_DEVICE_SW_STATE_ON);
 }
 
@@ -566,7 +572,14 @@ static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
 static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id)
 {
 	return ti_sci_set_device_state(handle, id,
-				       MSG_FLAG_DEVICE_EXCLUSIVE,
+				       0,
+				       MSG_DEVICE_SW_STATE_RETENTION);
+}
+
+static int ti_sci_cmd_idle_device_exclusive(const struct ti_sci_handle *handle,
+					    u32 id)
+{
+	return ti_sci_set_device_state(handle, id, MSG_FLAG_DEVICE_EXCLUSIVE,
 				       MSG_DEVICE_SW_STATE_RETENTION);
 }
 
@@ -583,8 +596,8 @@ static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id)
  */
 static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id)
 {
-	return ti_sci_set_device_state(handle, id,
-				       0, MSG_DEVICE_SW_STATE_AUTO_OFF);
+	return ti_sci_set_device_state(handle, id, 0,
+				       MSG_DEVICE_SW_STATE_AUTO_OFF);
 }
 
 /**
@@ -2632,7 +2645,9 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
 	bops->board_config_pm = ti_sci_cmd_set_board_config_pm;
 
 	dops->get_device = ti_sci_cmd_get_device;
+	dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive;
 	dops->idle_device = ti_sci_cmd_idle_device;
+	dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive;
 	dops->put_device = ti_sci_cmd_put_device;
 	dops->is_valid = ti_sci_cmd_dev_is_valid;
 	dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt;
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index c57802f293..842fb596f7 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -117,7 +117,10 @@ struct ti_sci_board_ops {
  */
 struct ti_sci_dev_ops {
 	int (*get_device)(const struct ti_sci_handle *handle, u32 id);
+	int (*get_device_exclusive)(const struct ti_sci_handle *handle, u32 id);
 	int (*idle_device)(const struct ti_sci_handle *handle, u32 id);
+	int (*idle_device_exclusive)(const struct ti_sci_handle *handle,
+				     u32 id);
 	int (*put_device)(const struct ti_sci_handle *handle, u32 id);
 	int (*is_valid)(const struct ti_sci_handle *handle, u32 id);
 	int (*get_context_loss_count)(const struct ti_sci_handle *handle,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/8] firmware: ti_sci: Add processor shutdown API method
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 1/8] firmware: ti_sci: Allow for device shared and exclusive requests Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 3/8] armv7R: K3: am654: Shut down R5 core after ATF startup on A53 Lokesh Vutla
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

From: Andreas Dannenberg <dannenberg@ti.com>

Add and expose a new processor shutdown API that wraps the two TISCI
messages involved in initiating a core shutdown. The API will first
queue a message to have the DMSC wait for a certain processor boot
status to happen followed by a message to trigger the actual shutdown-
with both messages being sent without waiting or requesting for a
response. Note that the processor shutdown API call will need to be
followed up by user software placing the respective core into either
WFE or WFI mode.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
---
 drivers/firmware/ti_sci.c              | 191 ++++++++++++++++++++++++-
 drivers/firmware/ti_sci.h              |  50 +++++++
 include/linux/soc/ti/ti_sci_protocol.h |   4 +
 3 files changed, 241 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index eadb91e107..8c68f98788 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -101,7 +101,8 @@ struct ti_sci_info {
  * @msg_flags:	Flag to set for the message
  * @buf:	Buffer to be send to mailbox channel
  * @tx_message_size: transmit message size
- * @rx_message_size: receive message size
+ * @rx_message_size: receive message size. may be set to zero for send-only
+ *		     transactions.
  *
  * Helper function which is used by various command functions that are
  * exposed to clients of this driver for allocating a message traffic event.
@@ -121,7 +122,8 @@ static struct ti_sci_xfer *ti_sci_setup_one_xfer(struct ti_sci_info *info,
 	/* Ensure we have sane transfer sizes */
 	if (rx_message_size > info->desc->max_msg_size ||
 	    tx_message_size > info->desc->max_msg_size ||
-	    rx_message_size < sizeof(*hdr) || tx_message_size < sizeof(*hdr))
+	    (rx_message_size > 0 && rx_message_size < sizeof(*hdr)) ||
+	    tx_message_size < sizeof(*hdr))
 		return ERR_PTR(-ERANGE);
 
 	info->seq = ~info->seq;
@@ -219,7 +221,9 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
 
 		xfer->tx_message.buf = (u32 *)secure_buf;
 		xfer->tx_message.len += sizeof(secure_hdr);
-		xfer->rx_len += sizeof(secure_hdr);
+
+		if (xfer->rx_len)
+			xfer->rx_len += sizeof(secure_hdr);
 	}
 
 	/* Send the message */
@@ -230,7 +234,11 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
 		return ret;
 	}
 
-	return ti_sci_get_response(info, xfer, &info->chan_rx);
+	/* Get response if requested */
+	if (xfer->rx_len)
+		ret = ti_sci_get_response(info, xfer, &info->chan_rx);
+
+	return ret;
 }
 
 /**
@@ -469,6 +477,49 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,
 	return ret;
 }
 
+/**
+ * ti_sci_set_device_state_no_wait() - Set device state helper without
+ *				       requesting or waiting for a response.
+ * @handle:	pointer to TI SCI handle
+ * @id:		Device identifier
+ * @flags:	flags to setup for the device
+ * @state:	State to move the device to
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_set_device_state_no_wait(const struct ti_sci_handle *handle,
+					   u32 id, u32 flags, u8 state)
+{
+	struct ti_sci_msg_req_set_device_state req;
+	struct ti_sci_info *info;
+	struct ti_sci_xfer *xfer;
+	int ret = 0;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+	if (!handle)
+		return -EINVAL;
+
+	info = handle_to_ti_sci_info(handle);
+
+	xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_DEVICE_STATE,
+				     flags | TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
+				     (u32 *)&req, sizeof(req), 0);
+	if (IS_ERR(xfer)) {
+		ret = PTR_ERR(xfer);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
+		return ret;
+	}
+	req.id = id;
+	req.state = state;
+
+	ret = ti_sci_do_xfer(info, xfer);
+	if (ret)
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
+
+	return ret;
+}
+
 /**
  * ti_sci_get_device_state() - Get device state helper
  * @handle:	Handle to the device
@@ -2039,6 +2090,137 @@ static int ti_sci_cmd_get_proc_boot_status(const struct ti_sci_handle *handle,
 	return ret;
 }
 
+/**
+ * ti_sci_proc_wait_boot_status_no_wait() - Helper function to wait for a
+ *				processor boot status without requesting or
+ *				waiting for a response.
+ * @proc_id:			Processor ID this request is for
+ * @num_wait_iterations:	Total number of iterations we will check before
+ *				we will timeout and give up
+ * @num_match_iterations:	How many iterations should we have continued
+ *				status to account for status bits glitching.
+ *				This is to make sure that match occurs for
+ *				consecutive checks. This implies that the
+ *				worst case should consider that the stable
+ *				time should at the worst be num_wait_iterations
+ *				num_match_iterations to prevent timeout.
+ * @delay_per_iteration_us:	Specifies how long to wait (in micro seconds)
+ *				between each status checks. This is the minimum
+ *				duration, and overhead of register reads and
+ *				checks are on top of this and can vary based on
+ *				varied conditions.
+ * @delay_before_iterations_us:	Specifies how long to wait (in micro seconds)
+ *				before the very first check in the first
+ *				iteration of status check loop. This is the
+ *				minimum duration, and overhead of register
+ *				reads and checks are.
+ * @status_flags_1_set_all_wait:If non-zero, Specifies that all bits of the
+ *				status matching this field requested MUST be 1.
+ * @status_flags_1_set_any_wait:If non-zero, Specifies that at least one of the
+ *				bits matching this field requested MUST be 1.
+ * @status_flags_1_clr_all_wait:If non-zero, Specifies that all bits of the
+ *				status matching this field requested MUST be 0.
+ * @status_flags_1_clr_any_wait:If non-zero, Specifies that at least one of the
+ *				bits matching this field requested MUST be 0.
+ *
+ * Return: 0 if all goes well, else appropriate error message
+ */
+static int
+ti_sci_proc_wait_boot_status_no_wait(const struct ti_sci_handle *handle,
+				     u8 proc_id,
+				     u8 num_wait_iterations,
+				     u8 num_match_iterations,
+				     u8 delay_per_iteration_us,
+				     u8 delay_before_iterations_us,
+				     u32 status_flags_1_set_all_wait,
+				     u32 status_flags_1_set_any_wait,
+				     u32 status_flags_1_clr_all_wait,
+				     u32 status_flags_1_clr_any_wait)
+{
+	struct ti_sci_msg_req_wait_proc_boot_status req;
+	struct ti_sci_info *info;
+	struct ti_sci_xfer *xfer;
+	int ret = 0;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+	if (!handle)
+		return -EINVAL;
+
+	info = handle_to_ti_sci_info(handle);
+
+	xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_WAIT_PROC_BOOT_STATUS,
+				     TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
+				     (u32 *)&req, sizeof(req), 0);
+	if (IS_ERR(xfer)) {
+		ret = PTR_ERR(xfer);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
+		return ret;
+	}
+	req.processor_id = proc_id;
+	req.num_wait_iterations = num_wait_iterations;
+	req.num_match_iterations = num_match_iterations;
+	req.delay_per_iteration_us = delay_per_iteration_us;
+	req.delay_before_iterations_us = delay_before_iterations_us;
+	req.status_flags_1_set_all_wait = status_flags_1_set_all_wait;
+	req.status_flags_1_set_any_wait = status_flags_1_set_any_wait;
+	req.status_flags_1_clr_all_wait = status_flags_1_clr_all_wait;
+	req.status_flags_1_clr_any_wait = status_flags_1_clr_any_wait;
+
+	ret = ti_sci_do_xfer(info, xfer);
+	if (ret)
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
+
+	return ret;
+}
+
+/**
+ * ti_sci_cmd_proc_shutdown_no_wait() - Command to shutdown a core without
+ *		requesting or waiting for a response. Note that this API call
+ *		should be followed by placing the respective processor into
+ *		either WFE or WFI mode.
+ * @handle:	Pointer to TI SCI handle
+ * @proc_id:	Processor ID this request is for
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_proc_shutdown_no_wait(const struct ti_sci_handle *handle,
+					    u8 proc_id)
+{
+	int ret;
+
+	/*
+	 * Send the core boot status wait message waiting for either WFE or
+	 * WFI without requesting or waiting for a TISCI response with the
+	 * maximum wait time to give us the best chance to get to the WFE/WFI
+	 * command that should follow the invocation of this API before the
+	 * DMSC-internal processing of this command times out. Note that
+	 * waiting for the R5 WFE/WFI flags will also work on an ARMV8 type
+	 * core as the related flag bit positions are the same.
+	 */
+	ret = ti_sci_proc_wait_boot_status_no_wait(handle, proc_id,
+		U8_MAX, 100, U8_MAX, U8_MAX,
+		0, PROC_BOOT_STATUS_FLAG_R5_WFE | PROC_BOOT_STATUS_FLAG_R5_WFI,
+		0, 0);
+	if (ret) {
+		dev_err(info->dev, "Sending core %u wait message fail %d\n",
+			proc_id, ret);
+		return ret;
+	}
+
+	/*
+	 * Release a processor managed by TISCI without requesting or waiting
+	 * for a response.
+	 */
+	ret = ti_sci_set_device_state_no_wait(handle, proc_id, 0,
+					      MSG_DEVICE_SW_STATE_AUTO_OFF);
+	if (ret)
+		dev_err(info->dev, "Sending core %u shutdown message fail %d\n",
+			proc_id, ret);
+
+	return ret;
+}
+
 /**
  * ti_sci_cmd_ring_config() - configure RA ring
  * @handle:	pointer to TI SCI handle
@@ -2687,6 +2869,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
 	pops->set_proc_boot_ctrl = ti_sci_cmd_set_proc_boot_ctrl;
 	pops->proc_auth_boot_image = ti_sci_cmd_proc_auth_boot_image;
 	pops->get_proc_boot_status = ti_sci_cmd_get_proc_boot_status;
+	pops->proc_shutdown_no_wait = ti_sci_cmd_proc_shutdown_no_wait;
 
 	rops->config = ti_sci_cmd_ring_config;
 	rops->get_config = ti_sci_cmd_ring_get_config;
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index a484b1fa40..69ff74d6a9 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -50,6 +50,7 @@
 #define TISCI_MSG_SET_PROC_BOOT_CTRL	0xc101
 #define TISCI_MSG_PROC_AUTH_BOOT_IMIAGE	0xc120
 #define TISCI_MSG_GET_PROC_BOOT_STATUS	0xc400
+#define TISCI_MSG_WAIT_PROC_BOOT_STATUS	0xc401
 
 /* Resource Management Requests */
 #define TI_SCI_MSG_GET_RESOURCE_RANGE	0x1500
@@ -772,6 +773,55 @@ struct ti_sci_msg_resp_get_proc_boot_status {
 	u32 status_flags;
 } __packed;
 
+/**
+ * struct ti_sci_msg_req_wait_proc_boot_status - Wait for a processor
+ *						 boot status
+ * @hdr:			Generic Header
+ * @processor_id:		ID of processor
+ * @num_wait_iterations:	Total number of iterations we will check before
+ *				we will timeout and give up
+ * @num_match_iterations:	How many iterations should we have continued
+ *				status to account for status bits glitching.
+ *				This is to make sure that match occurs for
+ *				consecutive checks. This implies that the
+ *				worst case should consider that the stable
+ *				time should at the worst be num_wait_iterations
+ *				num_match_iterations to prevent timeout.
+ * @delay_per_iteration_us:	Specifies how long to wait (in micro seconds)
+ *				between each status checks. This is the minimum
+ *				duration, and overhead of register reads and
+ *				checks are on top of this and can vary based on
+ *				varied conditions.
+ * @delay_before_iterations_us:	Specifies how long to wait (in micro seconds)
+ *				before the very first check in the first
+ *				iteration of status check loop. This is the
+ *				minimum duration, and overhead of register
+ *				reads and checks are.
+ * @status_flags_1_set_all_wait:If non-zero, Specifies that all bits of the
+ *				status matching this field requested MUST be 1.
+ * @status_flags_1_set_any_wait:If non-zero, Specifies that at least one of the
+ *				bits matching this field requested MUST be 1.
+ * @status_flags_1_clr_all_wait:If non-zero, Specifies that all bits of the
+ *				status matching this field requested MUST be 0.
+ * @status_flags_1_clr_any_wait:If non-zero, Specifies that at least one of the
+ *				bits matching this field requested MUST be 0.
+ *
+ * Request type is TISCI_MSG_WAIT_PROC_BOOT_STATUS, response is appropriate
+ * message, or NACK in case of inability to satisfy request.
+ */
+struct ti_sci_msg_req_wait_proc_boot_status {
+	struct ti_sci_msg_hdr hdr;
+	u8 processor_id;
+	u8 num_wait_iterations;
+	u8 num_match_iterations;
+	u8 delay_per_iteration_us;
+	u8 delay_before_iterations_us;
+	u32 status_flags_1_set_all_wait;
+	u32 status_flags_1_set_any_wait;
+	u32 status_flags_1_clr_all_wait;
+	u32 status_flags_1_clr_any_wait;
+} __packed;
+
 /**
  * struct ti_sci_msg_rm_ring_cfg_req - Configure a Navigator Subsystem ring
  *
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index 842fb596f7..cd6e5853b4 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -266,6 +266,8 @@ struct ti_sci_core_ops {
  * @set_proc_boot_ctrl: Setup limited control flags in specific cases.
  * @proc_auth_boot_image:
  * @get_proc_boot_status: Get the state of physical processor
+ * @proc_shutdown_no_wait: Shutdown a core without requesting or waiting for a
+ *			   response.
  *
  * NOTE: for all these functions, the following parameters are generic in
  * nature:
@@ -287,6 +289,8 @@ struct ti_sci_proc_ops {
 	int (*get_proc_boot_status)(const struct ti_sci_handle *handle, u8 pid,
 				    u64 *bv, u32 *cfg_flags, u32 *ctrl_flags,
 				    u32 *sts_flags);
+	int (*proc_shutdown_no_wait)(const struct ti_sci_handle *handle,
+				     u8 pid);
 };
 
 #define TI_SCI_RING_MODE_RING			(0)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 3/8] armv7R: K3: am654: Shut down R5 core after ATF startup on A53
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 1/8] firmware: ti_sci: Allow for device shared and exclusive requests Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 2/8] firmware: ti_sci: Add processor shutdown API method Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 4/8] power-domain: Add private data to power domain Lokesh Vutla
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

From: Andreas Dannenberg <dannenberg@ti.com>

Rather than simply parking the R5 core in WFE after starting up ATF
on A53 instead use SYSFW API to properly shut down the R5 CPU cores
as well as associated timer resources that were pre-allocated. This
allows software further downstream to properly and gracefully bring
the R5 cores back online if desired.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 arch/arm/mach-k3/am6_init.c               | 62 +++++++++++++++++++++++
 arch/arm/mach-k3/common.c                 |  6 ++-
 arch/arm/mach-k3/include/mach/sys_proto.h |  1 +
 3 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
index 60a580305d..922bd95580 100644
--- a/arch/arm/mach-k3/am6_init.c
+++ b/arch/arm/mach-k3/am6_init.c
@@ -12,6 +12,7 @@
 #include <asm/arch/hardware.h>
 #include "common.h"
 #include <dm.h>
+#include <linux/soc/ti/ti_sci_protocol.h>
 
 #ifdef CONFIG_SPL_BUILD
 static void mmr_unlock(u32 base, u32 partition)
@@ -185,3 +186,64 @@ void reset_cpu(ulong ignored)
 {
 }
 #endif
+
+#ifdef CONFIG_SYS_K3_SPL_ATF
+
+#define AM6_DEV_MCU_RTI0			134
+#define AM6_DEV_MCU_RTI1			135
+#define AM6_DEV_MCU_ARMSS0_CPU0			159
+#define AM6_DEV_MCU_ARMSS0_CPU1			245
+
+void release_resources_for_core_shutdown(void)
+{
+	struct udevice *dev;
+	struct ti_sci_handle *ti_sci;
+	struct ti_sci_dev_ops *dev_ops;
+	struct ti_sci_proc_ops *proc_ops;
+	int ret;
+	u32 i;
+
+	const u32 put_device_ids[] = {
+		AM6_DEV_MCU_RTI0,
+		AM6_DEV_MCU_RTI1,
+	};
+
+	/* Get handle to Device Management and Security Controller (SYSFW) */
+	ret = uclass_get_device_by_name(UCLASS_FIRMWARE, "dmsc", &dev);
+	if (ret)
+		panic("Failed to get handle to SYSFW (%d)\n", ret);
+
+	ti_sci = (struct ti_sci_handle *)(ti_sci_get_handle_from_sysfw(dev));
+	dev_ops = &ti_sci->ops.dev_ops;
+	proc_ops = &ti_sci->ops.proc_ops;
+
+	/* Iterate through list of devices to put (shutdown) */
+	for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) {
+		u32 id = put_device_ids[i];
+
+		ret = dev_ops->put_device(ti_sci, id);
+		if (ret)
+			panic("Failed to put device %u (%d)\n", id, ret);
+	}
+
+	const u32 put_core_ids[] = {
+		AM6_DEV_MCU_ARMSS0_CPU1,
+		AM6_DEV_MCU_ARMSS0_CPU0,	/* Handle CPU0 after CPU1 */
+	};
+
+	/* Iterate through list of cores to put (shutdown) */
+	for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) {
+		u32 id = put_core_ids[i];
+
+		/*
+		 * Queue up the core shutdown request. Note that this call
+		 * needs to be followed up by an actual invocation of an WFE
+		 * or WFI CPU instruction.
+		 */
+		ret = proc_ops->proc_shutdown_no_wait(ti_sci, id);
+		if (ret)
+			panic("Failed sending core %u shutdown message (%d)\n",
+			      id, ret);
+	}
+}
+#endif
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 03f01d07ea..ee84d44de8 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -13,6 +13,7 @@
 #include <remoteproc.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <fdt_support.h>
+#include <asm/arch/sys_proto.h>
 
 struct ti_sci_handle *get_ti_sci_handle(void)
 {
@@ -51,7 +52,10 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 	if (ret)
 		panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret);
 
-	debug("ATF started. Waiting indefinitely...\n");
+	debug("Releasing resources...\n");
+	release_resources_for_core_shutdown();
+
+	debug("Finalizing core shutdown...\n");
 	while (1)
 		asm volatile("wfe");
 }
diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h b/arch/arm/mach-k3/include/mach/sys_proto.h
index 018725b4d1..2fa53682ad 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -12,4 +12,5 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
 		  u32 bound);
 struct ti_sci_handle *get_ti_sci_handle(void);
 int fdt_fixup_msmc_ram(void *blob, char *parent_path, char *node_name);
+void release_resources_for_core_shutdown(void);
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 4/8] power-domain: Add private data to power domain
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
                   ` (2 preceding siblings ...)
  2019-05-22  4:27 ` [U-Boot] [PATCH 3/8] armv7R: K3: am654: Shut down R5 core after ATF startup on A53 Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 5/8] dt-bindings: ti_sci_pm_domains: Add support for exclusive and shared access Lokesh Vutla
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

Certain drivers want to attach private data corresponding to each
power domain. This data might be specific be to the drvier. So add
a priv entry into the power_domain structure.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 include/power-domain.h | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/include/power-domain.h b/include/power-domain.h
index 00996057b0..ec2b70e0b5 100644
--- a/include/power-domain.h
+++ b/include/power-domain.h
@@ -55,23 +55,12 @@ struct udevice;
  *
  * @dev: The device which implements the power domain.
  * @id: The power domain ID within the provider.
- *
- * Currently, the power domain API assumes that a single integer ID is enough
- * to identify and configure any power domain for any power domain provider. If
- * this assumption becomes invalid in the future, the struct could be expanded
- * to either (a) add more fields to allow power domain providers to store
- * additional information, or (b) replace the id field with an opaque pointer,
- * which the provider would dynamically allocate during its .of_xlate op, and
- * process during is .request op. This may require the addition of an extra op
- * to clean up the allocation.
+ * @priv: Private data corresponding to each power domain.
  */
 struct power_domain {
 	struct udevice *dev;
-	/*
-	 * Written by of_xlate. We assume a single id is enough for now. In the
-	 * future, we might add more fields here.
-	 */
 	unsigned long id;
+	void *priv;
 };
 
 /**
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 5/8] dt-bindings: ti_sci_pm_domains: Add support for exclusive and shared access
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
                   ` (3 preceding siblings ...)
  2019-05-22  4:27 ` [U-Boot] [PATCH 4/8] power-domain: Add private data to power domain Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 6/8] power: domain: ti_sci_power_domains: " Lokesh Vutla
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

TISCI protocol supports for enabling the device either with exclusive
permissions for the requesting host or with sharing across the hosts.
There are certain devices which are exclusive to Linux context and
there are certain devices that are shared across different host contexts.
So add support for getting this information from DT by increasing
the power-domain cells to 2.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 doc/device-tree-bindings/power/ti,sci-pm-domain.txt | 11 +++++++++--
 include/dt-bindings/soc/ti,sci_pm_domain.h          |  9 +++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 include/dt-bindings/soc/ti,sci_pm_domain.h

diff --git a/doc/device-tree-bindings/power/ti,sci-pm-domain.txt b/doc/device-tree-bindings/power/ti,sci-pm-domain.txt
index 0e190e20fe..72d9fbc833 100644
--- a/doc/device-tree-bindings/power/ti,sci-pm-domain.txt
+++ b/doc/device-tree-bindings/power/ti,sci-pm-domain.txt
@@ -17,8 +17,15 @@ child of the sysfw node.
 Required Properties:
 --------------------
 - compatible: Must be "ti,sci-pm-domain"
-- #power-domain-cells: Must be 1 so that an id can be provided in each
-		       device node.
+- #power-domain-cells: Can be one of the following:
+			1: Containing the device id of each node
+			2: First entry should be device id
+			   Second entry should be one of the floowing:
+			   TI_SCI_PD_EXCLUSIVE: To allow device to be
+						exclusively controlled by
+						the requesting hosts.
+			   TI_SCI_PD_SHARED: To allow device to be shared
+					     by multiple hosts.
 
 Example (AM65x):
 ----------------
diff --git a/include/dt-bindings/soc/ti,sci_pm_domain.h b/include/dt-bindings/soc/ti,sci_pm_domain.h
new file mode 100644
index 0000000000..8f2a7360b6
--- /dev/null
+++ b/include/dt-bindings/soc/ti,sci_pm_domain.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __DT_BINDINGS_TI_SCI_PM_DOMAIN_H
+#define __DT_BINDINGS_TI_SCI_PM_DOMAIN_H
+
+#define TI_SCI_PD_EXCLUSIVE	1
+#define TI_SCI_PD_SHARED	0
+
+#endif /* __DT_BINDINGS_TI_SCI_PM_DOMAIN_H */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 6/8] power: domain: ti_sci_power_domains: Add support for exclusive and shared access
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
                   ` (4 preceding siblings ...)
  2019-05-22  4:27 ` [U-Boot] [PATCH 5/8] dt-bindings: ti_sci_pm_domains: Add support for exclusive and shared access Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 7/8] armv7R: dts: k3-am654: Update power-domains property for each node Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 8/8] cmd: remoteproc: Add support for initializing devices individually Lokesh Vutla
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

TISCI protocol supports for enabling the device either with exclusive
permissions for the requesting host or with sharing across the hosts.
There are certain devices which are exclusive to Linux context and
there are certain devices that are shared across different host contexts.
So add support for getting this information from DT by increasing
the power-domain cells to 2.

For keeping the DT backward compatibility intact, defaulting the
device permissions to set the exclusive flag set. In this case the
power-domain-cells is 1.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/power/domain/ti-sci-power-domain.c | 31 +++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/power/domain/ti-sci-power-domain.c b/drivers/power/domain/ti-sci-power-domain.c
index aafde62cbf..b9cd37b612 100644
--- a/drivers/power/domain/ti-sci-power-domain.c
+++ b/drivers/power/domain/ti-sci-power-domain.c
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <power-domain-uclass.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
+#include <dt-bindings/soc/ti,sci_pm_domain.h>
 
 /**
  * struct ti_sci_power_domain_data - pm domain controller information structure
@@ -56,11 +57,16 @@ static int ti_sci_power_domain_on(struct power_domain *pd)
 	struct ti_sci_power_domain_data *data = dev_get_priv(pd->dev);
 	const struct ti_sci_handle *sci = data->sci;
 	const struct ti_sci_dev_ops *dops = &sci->ops.dev_ops;
+	u8 flags = (uintptr_t)pd->priv;
 	int ret;
 
 	debug("%s(pd=%p)\n", __func__, pd);
 
-	ret = dops->get_device(sci, pd->id);
+	if (flags & TI_SCI_PD_EXCLUSIVE)
+		ret = dops->get_device_exclusive(sci, pd->id);
+	else
+		ret = dops->get_device(sci, pd->id);
+
 	if (ret)
 		dev_err(power_domain->dev, "%s: get_device failed (%d)\n",
 			__func__, ret);
@@ -85,6 +91,28 @@ static int ti_sci_power_domain_off(struct power_domain *pd)
 	return ret;
 }
 
+static int ti_sci_power_domain_of_xlate(struct power_domain *pd,
+					struct ofnode_phandle_args *args)
+{
+	u8 flags;
+
+	debug("%s(power_domain=%p)\n", __func__, pd);
+
+	if (args->args_count < 1) {
+		debug("Invalid args_count: %d\n", args->args_count);
+		return -EINVAL;
+	}
+
+	pd->id = args->args[0];
+	/* By default request for device exclusive */
+	flags = TI_SCI_PD_EXCLUSIVE;
+	if (args->args_count == 2)
+		flags = args->args[1] & TI_SCI_PD_EXCLUSIVE;
+	pd->priv = (void *)(uintptr_t)flags;
+
+	return 0;
+}
+
 static const struct udevice_id ti_sci_power_domain_of_match[] = {
 	{ .compatible = "ti,sci-pm-domain" },
 	{ /* sentinel */ }
@@ -95,6 +123,7 @@ static struct power_domain_ops ti_sci_power_domain_ops = {
 	.free = ti_sci_power_domain_free,
 	.on = ti_sci_power_domain_on,
 	.off = ti_sci_power_domain_off,
+	.of_xlate = ti_sci_power_domain_of_xlate,
 };
 
 U_BOOT_DRIVER(ti_sci_pm_domains) = {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 7/8] armv7R: dts: k3-am654: Update power-domains property for each node
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
                   ` (5 preceding siblings ...)
  2019-05-22  4:27 ` [U-Boot] [PATCH 6/8] power: domain: ti_sci_power_domains: " Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:27 ` [U-Boot] [PATCH 8/8] cmd: remoteproc: Add support for initializing devices individually Lokesh Vutla
  7 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

Update the power-domain-cells to 2 and add the permissions
to each node. Mark all the nodes accessed by r5 as shared
in r5 dts.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 arch/arm/dts/k3-am65-wakeup.dtsi             | 2 +-
 arch/arm/dts/k3-am65.dtsi                    | 1 +
 arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 2 +-
 arch/arm/dts/k3-am654-ddr.dtsi               | 4 ++--
 arch/arm/dts/k3-am654-r5-base-board.dts      | 8 ++++++--
 5 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/arm/dts/k3-am65-wakeup.dtsi b/arch/arm/dts/k3-am65-wakeup.dtsi
index 1f591ef8bb..9eaecf4cfc 100644
--- a/arch/arm/dts/k3-am65-wakeup.dtsi
+++ b/arch/arm/dts/k3-am65-wakeup.dtsi
@@ -20,7 +20,7 @@
 
 		k3_pds: power-controller {
 			compatible = "ti,sci-pm-domain";
-			#power-domain-cells = <1>;
+			#power-domain-cells = <2>;
 		};
 
 		k3_clks: clocks {
diff --git a/arch/arm/dts/k3-am65.dtsi b/arch/arm/dts/k3-am65.dtsi
index 3d4bf369d0..145e4d219a 100644
--- a/arch/arm/dts/k3-am65.dtsi
+++ b/arch/arm/dts/k3-am65.dtsi
@@ -8,6 +8,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/soc/ti,sci_pm_domain.h>
 
 / {
 	model = "Texas Instruments K3 AM654 SoC";
diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi
index 5eaf208e0e..80a04dc1bc 100644
--- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi
@@ -32,7 +32,7 @@
 		reg = <0x0 0x4FA0000 0x0 0x1000>,
 		      <0x0 0x4FB0000 0x0 0x400>;
 		clocks = <&k3_clks 48 1>;
-		power-domains = <&k3_pds 48>;
+		power-domains = <&k3_pds 48 TI_SCI_PD_SHARED>;
 		max-frequency = <25000000>;
 		ti,otap-del-sel = <0x2>;
 		ti,trm-icp = <0x8>;
diff --git a/arch/arm/dts/k3-am654-ddr.dtsi b/arch/arm/dts/k3-am654-ddr.dtsi
index 964eb173eb..622a3edb61 100644
--- a/arch/arm/dts/k3-am654-ddr.dtsi
+++ b/arch/arm/dts/k3-am654-ddr.dtsi
@@ -11,8 +11,8 @@
 		      <0x0 0x02988000 0x0 0x2000>;
 		reg-names = "ss", "ctl", "phy";
 		clocks = <&k3_clks 20 0>;
-		power-domains = <&k3_pds 20>,
-				<&k3_pds 244>;
+		power-domains = <&k3_pds 20 TI_SCI_PD_SHARED>,
+				<&k3_pds 244 TI_SCI_PD_SHARED>;
 		assigned-clocks = <&k3_clks 20 1>;
 		assigned-clock-rates = <DDR_PLL_FREQUENCY>;
 		u-boot,dm-spl;
diff --git a/arch/arm/dts/k3-am654-r5-base-board.dts b/arch/arm/dts/k3-am654-r5-base-board.dts
index a07038be70..9458e4bf0d 100644
--- a/arch/arm/dts/k3-am654-r5-base-board.dts
+++ b/arch/arm/dts/k3-am654-r5-base-board.dts
@@ -32,8 +32,8 @@
 	a53_0: a53 at 0 {
 		compatible = "ti,am654-rproc";
 		reg = <0x0 0x00a90000 0x0 0x10>;
-		power-domains = <&k3_pds 61>,
-				<&k3_pds 202>;
+		power-domains = <&k3_pds 61 TI_SCI_PD_SHARED>,
+				<&k3_pds 202 TI_SCI_PD_SHARED>;
 		resets = <&k3_reset 202 0>;
 		assigned-clocks = <&k3_clks 202 0>;
 		assigned-clock-rates = <800000000>;
@@ -112,6 +112,10 @@
 	status = "okay";
 };
 
+&main_uart0 {
+	power-domains = <&k3_pds 146 TI_SCI_PD_SHARED>;
+};
+
 &wkup_pmx0 {
 	u-boot,dm-spl;
 	wkup_uart0_pins_default: wkup_uart0_pins_default {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 8/8] cmd: remoteproc: Add support for initializing devices individually
  2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
                   ` (6 preceding siblings ...)
  2019-05-22  4:27 ` [U-Boot] [PATCH 7/8] armv7R: dts: k3-am654: Update power-domains property for each node Lokesh Vutla
@ 2019-05-22  4:27 ` Lokesh Vutla
  2019-05-22  4:29   ` Lokesh Vutla
  7 siblings, 1 reply; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:27 UTC (permalink / raw)
  To: u-boot

'rproc init' does the probe and initialization of all the available
remoteproc devices in the system. This doesn't allow the flexibility
to initialize the remote cores needed as per use case. In order
to provide flexibility, update 'rproc init' command to accept one
more parameter with rproc id which when passed initializes only
that specific core. If no id is passed, command will initializes
all the cores which is compatible with the existing behaviour.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 cmd/remoteproc.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
index 81463f36b6..689e1a6a1d 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -68,12 +68,22 @@ static int print_remoteproc_list(void)
 static int do_rproc_init(cmd_tbl_t *cmdtp, int flag, int argc,
 			 char *const argv[])
 {
+	int id;
+
 	if (rproc_is_initialized()) {
 		printf("\tRemote Processors are already initialized\n");
-	} else {
+		return CMD_RET_FAILURE;
+	}
+
+	if (argc == 1) {
 		if (!rproc_init())
 			return 0;
-		printf("Few Remote Processors failed to be initalized\n");
+		printf("Few Remote Processors failed to be initialized\n");
+	} else if (argc == 2) {
+		id = (int)simple_strtoul(argv[1], NULL, 10);
+		if (!rproc_dev_init(id))
+			return 0;
+		printf("Remote Processor %d failed to be initialized\n", id);
 	}
 
 	return CMD_RET_FAILURE;
@@ -203,8 +213,10 @@ static int do_remoteproc_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
 }
 
 static cmd_tbl_t cmd_remoteproc_sub[] = {
-	U_BOOT_CMD_MKENT(init, 0, 1, do_rproc_init,
-			 "Enumerate and initialize all processors", ""),
+	U_BOOT_CMD_MKENT(init, 1, 1, do_rproc_init,
+			 "Enumerate and initialize the remote processor(s)",
+			 "id - ID of the remote processor\n"
+			 "If id is not passed, initialize all the remote processors"),
 	U_BOOT_CMD_MKENT(list, 0, 1, do_remoteproc_list,
 			 "list remote processors", ""),
 	U_BOOT_CMD_MKENT(load, 5, 1, do_remoteproc_load,
@@ -270,7 +282,8 @@ U_BOOT_CMD(rproc, 5, 1, do_remoteproc,
 	   "\t\tNote: Services are dependent on the driver capability\n"
 	   "\t\t      'list' command shows the capability of each device\n"
 	   "\n\tSubcommands:\n"
-	   "\tinit   - Enumerate and initalize the remote processors\n"
+	   "\tinit <id> - Enumerate and initalize the remote processor.\n"
+	   "\t		  if id is not passed, initialize all the remote prcessors\n"
 	   "\tlist   - list available remote processors\n"
 	   "\tload <id> [addr] [size]- Load the remote processor with binary\n"
 	   "\t		  image stored at address [addr] in memory\n"
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 8/8] cmd: remoteproc: Add support for initializing devices individually
  2019-05-22  4:27 ` [U-Boot] [PATCH 8/8] cmd: remoteproc: Add support for initializing devices individually Lokesh Vutla
@ 2019-05-22  4:29   ` Lokesh Vutla
  0 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2019-05-22  4:29 UTC (permalink / raw)
  To: u-boot



On 21/05/19 11:27 PM, Lokesh Vutla wrote:
> 'rproc init' does the probe and initialization of all the available
> remoteproc devices in the system. This doesn't allow the flexibility
> to initialize the remote cores needed as per use case. In order
> to provide flexibility, update 'rproc init' command to accept one
> more parameter with rproc id which when passed initializes only
> that specific core. If no id is passed, command will initializes
> all the cores which is compatible with the existing behaviour.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Oops. This should be part of my next series. Will re send the series by dropping
the patch.

Thanks and regards,
Lokesh

> ---
>  cmd/remoteproc.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
> index 81463f36b6..689e1a6a1d 100644
> --- a/cmd/remoteproc.c
> +++ b/cmd/remoteproc.c
> @@ -68,12 +68,22 @@ static int print_remoteproc_list(void)
>  static int do_rproc_init(cmd_tbl_t *cmdtp, int flag, int argc,
>  			 char *const argv[])
>  {
> +	int id;
> +
>  	if (rproc_is_initialized()) {
>  		printf("\tRemote Processors are already initialized\n");
> -	} else {
> +		return CMD_RET_FAILURE;
> +	}
> +
> +	if (argc == 1) {
>  		if (!rproc_init())
>  			return 0;
> -		printf("Few Remote Processors failed to be initalized\n");
> +		printf("Few Remote Processors failed to be initialized\n");
> +	} else if (argc == 2) {
> +		id = (int)simple_strtoul(argv[1], NULL, 10);
> +		if (!rproc_dev_init(id))
> +			return 0;
> +		printf("Remote Processor %d failed to be initialized\n", id);
>  	}
>  
>  	return CMD_RET_FAILURE;
> @@ -203,8 +213,10 @@ static int do_remoteproc_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
>  }
>  
>  static cmd_tbl_t cmd_remoteproc_sub[] = {
> -	U_BOOT_CMD_MKENT(init, 0, 1, do_rproc_init,
> -			 "Enumerate and initialize all processors", ""),
> +	U_BOOT_CMD_MKENT(init, 1, 1, do_rproc_init,
> +			 "Enumerate and initialize the remote processor(s)",
> +			 "id - ID of the remote processor\n"
> +			 "If id is not passed, initialize all the remote processors"),
>  	U_BOOT_CMD_MKENT(list, 0, 1, do_remoteproc_list,
>  			 "list remote processors", ""),
>  	U_BOOT_CMD_MKENT(load, 5, 1, do_remoteproc_load,
> @@ -270,7 +282,8 @@ U_BOOT_CMD(rproc, 5, 1, do_remoteproc,
>  	   "\t\tNote: Services are dependent on the driver capability\n"
>  	   "\t\t      'list' command shows the capability of each device\n"
>  	   "\n\tSubcommands:\n"
> -	   "\tinit   - Enumerate and initalize the remote processors\n"
> +	   "\tinit <id> - Enumerate and initalize the remote processor.\n"
> +	   "\t		  if id is not passed, initialize all the remote prcessors\n"
>  	   "\tlist   - list available remote processors\n"
>  	   "\tload <id> [addr] [size]- Load the remote processor with binary\n"
>  	   "\t		  image stored at address [addr] in memory\n"
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-22  4:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22  4:27 [U-Boot] [PATCH 0/8] arm: k3: Allow for exclusive and shared device requests Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 1/8] firmware: ti_sci: Allow for device shared and exclusive requests Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 2/8] firmware: ti_sci: Add processor shutdown API method Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 3/8] armv7R: K3: am654: Shut down R5 core after ATF startup on A53 Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 4/8] power-domain: Add private data to power domain Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 5/8] dt-bindings: ti_sci_pm_domains: Add support for exclusive and shared access Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 6/8] power: domain: ti_sci_power_domains: " Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 7/8] armv7R: dts: k3-am654: Update power-domains property for each node Lokesh Vutla
2019-05-22  4:27 ` [U-Boot] [PATCH 8/8] cmd: remoteproc: Add support for initializing devices individually Lokesh Vutla
2019-05-22  4:29   ` Lokesh Vutla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.