U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 02/25] firmware: ti_sci: Add support for board configuration
Date: Tue, 21 Aug 2018 20:01:40 +0530	[thread overview]
Message-ID: <20180821143203.29142-3-lokeshvutla@ti.com> (raw)
In-Reply-To: <20180821143203.29142-1-lokeshvutla@ti.com>

From: Andreas Dannenberg <dannenberg@ti.com>

TI-SCI message protocol provides support for board configuration
to assign resources and other board related operations.
Introduce the board configuration capability support to the driver protocol
as part of this change.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/firmware/ti_sci.c              | 137 +++++++++++++++++++++++++
 drivers/firmware/ti_sci.h              |  21 ++++
 include/linux/soc/ti/ti_sci_protocol.h |  38 +++++++
 3 files changed, 196 insertions(+)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index c1169987ad..ce7483307e 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -275,6 +275,142 @@ static inline bool ti_sci_is_response_ack(void *r)
 	return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false;
 }
 
+/**
+ * cmd_set_board_config_using_msg() - Common command to send board configuration
+ *                                    message
+ * @handle:	pointer to TI SCI handle
+ * @msg_type:	One of the TISCI message types to set board configuration
+ * @addr:	Address where the board config structure is located
+ * @size:	Size of the board config structure
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int cmd_set_board_config_using_msg(const struct ti_sci_handle *handle,
+					  u16 msg_type, u64 addr, u32 size)
+{
+	struct ti_sci_msg_board_config req;
+	struct ti_sci_msg_hdr *resp;
+	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, msg_type,
+				     TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+				     (u32 *)&req, sizeof(req), sizeof(*resp));
+	if (IS_ERR(xfer)) {
+		ret = PTR_ERR(xfer);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
+		return ret;
+	}
+	req.boardcfgp_high = (addr >> 32) & 0xffffffff;
+	req.boardcfgp_low = addr & 0xffffffff;
+	req.boardcfg_size = size;
+
+	ret = ti_sci_do_xfer(info, xfer);
+	if (ret) {
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
+		return ret;
+	}
+
+	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
+
+	if (!ti_sci_is_response_ack(resp))
+		return -ENODEV;
+
+	return ret;
+}
+
+/**
+ * ti_sci_cmd_set_board_config() - Command to send board configuration message
+ * @handle:	pointer to TI SCI handle
+ * @addr:	Address where the board config structure is located
+ * @size:	Size of the board config structure
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_set_board_config(const struct ti_sci_handle *handle,
+				       u64 addr, u32 size)
+{
+	return cmd_set_board_config_using_msg(handle,
+					      TI_SCI_MSG_BOARD_CONFIG,
+					      addr, size);
+}
+
+/**
+ * ti_sci_cmd_set_board_config_rm() - Command to send board resource
+ *				      management configuration
+ * @handle:	pointer to TI SCI handle
+ * @addr:	Address where the board RM config structure is located
+ * @size:	Size of the RM config structure
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static
+int ti_sci_cmd_set_board_config_rm(const struct ti_sci_handle *handle,
+				   u64 addr, u32 size)
+{
+	return cmd_set_board_config_using_msg(handle,
+					      TI_SCI_MSG_BOARD_CONFIG_RM,
+					      addr, size);
+}
+
+/**
+ * ti_sci_cmd_set_board_config_security() - Command to send board security
+ *					    configuration message
+ * @handle:	pointer to TI SCI handle
+ * @addr:	Address where the board security config structure is located
+ * @size:	Size of the security config structure
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static
+int ti_sci_cmd_set_board_config_security(const struct ti_sci_handle *handle,
+					 u64 addr, u32 size)
+{
+	return cmd_set_board_config_using_msg(handle,
+					      TI_SCI_MSG_BOARD_CONFIG_SECURITY,
+					      addr, size);
+}
+
+/**
+ * ti_sci_cmd_set_board_config_pm() - Command to send board power and clock
+ *				      configuration message
+ * @handle:	pointer to TI SCI handle
+ * @addr:	Address where the board PM config structure is located
+ * @size:	Size of the PM config structure
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_set_board_config_pm(const struct ti_sci_handle *handle,
+					  u64 addr, u32 size)
+{
+	return cmd_set_board_config_using_msg(handle,
+					      TI_SCI_MSG_BOARD_CONFIG_PM,
+					      addr, size);
+}
+
+/*
+ * ti_sci_setup_ops() - Setup the operations structures
+ * @info:	pointer to TISCI pointer
+ */
+static void ti_sci_setup_ops(struct ti_sci_info *info)
+{
+	struct ti_sci_ops *ops = &info->handle.ops;
+	struct ti_sci_board_ops *bops = &ops->board_ops;
+
+	bops->board_config = ti_sci_cmd_set_board_config;
+	bops->board_config_rm = ti_sci_cmd_set_board_config_rm;
+	bops->board_config_security = ti_sci_cmd_set_board_config_security;
+	bops->board_config_pm = ti_sci_cmd_set_board_config_pm;
+}
+
 /**
  * ti_sci_get_handle_from_sysfw() - Get the TI SCI handle of the SYSFW
  * @dev:	Pointer to the SYSFW device
@@ -418,6 +554,7 @@ static int ti_sci_probe(struct udevice *dev)
 	info->seq = 0xA;
 
 	list_add_tail(&info->list, &ti_sci_list);
+	ti_sci_setup_ops(info);
 
 	ret = ti_sci_cmd_get_revision(&info->handle);
 
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index 0f81da9ecd..4377665d65 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -22,6 +22,9 @@
 #define TI_SCI_MSG_GOODBYE		0x0004
 #define TI_SCI_MSG_SYS_RESET		0x0005
 #define TI_SCI_MSG_BOARD_CONFIG		0x000b
+#define TI_SCI_MSG_BOARD_CONFIG_RM	0x000c
+#define TI_SCI_MSG_BOARD_CONFIG_SECURITY  0x000d
+#define TI_SCI_MSG_BOARD_CONFIG_PM	0x000e
 
 /**
  * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
@@ -77,4 +80,22 @@ struct ti_sci_msg_resp_version {
 	u8 abi_minor;
 } __packed;
 
+/**
+ * struct ti_sci_msg_board_config - Board configuration message
+ * @hdr:		Generic Header
+ * @boardcfgp_low:	Lower 32 bit of the pointer pointing to the board
+ *			configuration data
+ * @boardcfgp_high:	Upper 32 bit of the pointer pointing to the board
+ *			configuration data
+ * @boardcfg_size:	Size of board configuration data object
+ * Request type is TI_SCI_MSG_BOARD_CONFIG, responded with a generic
+ * ACK/NACK message.
+ */
+struct ti_sci_msg_board_config {
+	struct ti_sci_msg_hdr hdr;
+	u32 boardcfgp_low;
+	u32 boardcfgp_high;
+	u16 boardcfg_size;
+} __packed;
+
 #endif /* __TI_SCI_H */
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index 7ab141049a..88b940fb8e 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -30,11 +30,49 @@ struct ti_sci_version_info {
 
 struct ti_sci_handle;
 
+/**
+ * struct ti_sci_board_ops - Board config operations
+ * @board_config: Command to set the board configuration
+ *		  Returns 0 for successful exclusive request, else returns
+ *		  corresponding error message.
+ * @board_config_rm: Command to set the board resource management
+ *		  configuration
+ *		  Returns 0 for successful exclusive request, else returns
+ *		  corresponding error message.
+ * @board_config_security: Command to set the board security configuration
+ *		  Returns 0 for successful exclusive request, else returns
+ *		  corresponding error message.
+ * @board_config_pm: Command to trigger and set the board power and clock
+ *		  management related configuration
+ *		  Returns 0 for successful exclusive request, else returns
+ *		  corresponding error message.
+ */
+struct ti_sci_board_ops {
+	int (*board_config)(const struct ti_sci_handle *handle,
+			    u64 addr, u32 size);
+	int (*board_config_rm)(const struct ti_sci_handle *handle,
+			       u64 addr, u32 size);
+	int (*board_config_security)(const struct ti_sci_handle *handle,
+				     u64 addr, u32 size);
+	int (*board_config_pm)(const struct ti_sci_handle *handle,
+			       u64 addr, u32 size);
+};
+
+/**
+ * struct ti_sci_ops - Function support for TI SCI
+ * @board_ops:	Miscellaneous operations
+ */
+struct ti_sci_ops {
+	struct ti_sci_board_ops board_ops;
+};
+
 /**
  * struct ti_sci_handle - Handle returned to TI SCI clients for usage.
+ * @ops:	operations that are made available to TI SCI clients
  * @version:	structure containing version information
  */
 struct ti_sci_handle {
+	struct ti_sci_ops ops;
 	struct ti_sci_version_info version;
 };
 
-- 
2.18.0

  parent reply	other threads:[~2018-08-21 14:31 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21 14:31 [U-Boot] [PATCH 00/25] [2/3] Initial support Texas Instrument's AM654 Platform Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 01/25] firmware: Add basic support for TI System Control Interface (TI SCI) protocol Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-24 15:00     ` Lokesh Vutla
2018-08-21 14:31 ` Lokesh Vutla [this message]
2018-08-24 14:11   ` [U-Boot] [PATCH 02/25] firmware: ti_sci: Add support for board configuration Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 03/25] firmware: ti_sci: Add support for device control Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 04/25] firmware: ti_sci: Add support for clock control Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 05/25] firmware: ti_sci: Add support for reboot core service Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 06/25] firmware: ti_sci: Add support for processor control services Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 07/25] dm: firmware: Automatically bind child devices Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 08/25] dm: reset: Update uclass to allow querying reset status Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 09/25] reset: Extend reset control with an optional data field Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 10/25] reset: Introduce TI System Control Interface (TI SCI) reset driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 11/25] clk: Allow clock defaults to be set also during re-reloc state Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-24 14:42     ` Dr. Philipp Tomsich
2018-08-24 15:54       ` Andreas Dannenberg
2018-08-24 16:00         ` Dr. Philipp Tomsich
2018-08-24 16:28           ` Andreas Dannenberg
2018-08-27  3:26           ` Kever Yang
2018-08-27 16:06             ` Andreas Dannenberg
2018-08-28  9:12               ` Lokesh Vutla
2018-08-27  6:02       ` Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 12/25] clk: Extend clock control with an optional data field Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 13/25] clk: Introduce TI System Control Interface (TI SCI) clock driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 14/25] power domain: Add support for multiple powerdomains per device Lokesh Vutla
2018-08-22  9:21   ` Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 15/25] power domain: Introduce TI System Control Interface (TI SCI) power domain driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 16/25] sysreset: Add TI System Control Interface (TI SCI) sysreset driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 17/25] mailbox: Allow attaching private data for mbox_chan Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 18/25] mailbox: Introduce K3 Secure Proxy Driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 19/25] spl: Allow mailbox drivers to be used within SPL Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 20/25] remoteproc: Allow for individual remoteproc initialization Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 21/25] remoteproc: Introduce K3 system controller Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-24 15:02     ` Lokesh Vutla
2018-08-21 14:32 ` [U-Boot] [PATCH 22/25] remoteproc: Introduce K3 remoteproc driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 23/25] spl: Allow remoteproc drivers to be used within SPL Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 24/25] mmc: k3_arasan: Add sdhci driver support for K3 family SoCs Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 25/25] gpio: do not include <asm/arch/gpio.h> for ARCH_K3 Lokesh Vutla
2018-08-24 14:13   ` Tom Rini

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=20180821143203.29142-3-lokeshvutla@ti.com \
    --to=lokeshvutla@ti.com \
    --cc=u-boot@lists.denx.de \
    /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