All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay
@ 2022-01-14 12:25 Michal Simek
  2022-01-14 12:25 ` [PATCH 1/4] xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU fragments Michal Simek
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michal Simek @ 2022-01-14 12:25 UTC (permalink / raw)
  To: u-boot, git; +Cc: Adrian Fiergolski

Hi,

this small series is extending firmware interface for sending
pmufw configuration overlay with asking for access to certain
device. This infrastructure can be used via command or via power domain
driver.

Thanks,
Michal


Michal Simek (4):
  xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU
    fragments
  firmware: zynqmp: Move loading message to debug
  firmware: zynqmp: Do not report error if node is already configured
  arm64: zynqmp: Add command for disabling loading other overlays

 board/xilinx/zynqmp/cmds.c         | 16 ++++++++
 drivers/firmware/firmware-zynqmp.c | 60 +++++++++++++++++++++++++++++-
 include/zynqmp_firmware.h          |  2 +
 3 files changed, 77 insertions(+), 1 deletion(-)

-- 
2.34.1


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

* [PATCH 1/4] xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU fragments
  2022-01-14 12:25 [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
@ 2022-01-14 12:25 ` Michal Simek
  2022-01-14 12:25 ` [PATCH 2/4] firmware: zynqmp: Move loading message to debug Michal Simek
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2022-01-14 12:25 UTC (permalink / raw)
  To: u-boot, git; +Cc: Adrian Fiergolski

Introduce zynqmp_pmufw_node() for loading PMU configuration fragment for
enabling IPs. Firmware driver has small overlay where NODE id is added and
config fragment is sent to PMUFW. There is a need to build PMUFW with
fragment support.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/firmware/firmware-zynqmp.c | 32 ++++++++++++++++++++++++++++++
 include/zynqmp_firmware.h          |  1 +
 2 files changed, 33 insertions(+)

diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index 342dbc13dfdf..10240ddccd3b 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -27,6 +27,38 @@ struct zynqmp_power {
 	struct mbox_chan rx_chan;
 } zynqmp_power;
 
+#define NODE_ID_LOCATION	5
+
+static unsigned int xpm_configobject[] = {
+	/**********************************************************************/
+	/* HEADER */
+	2,	/* Number of remaining words in the header */
+	1,	/* Number of sections included in config object */
+	PM_CONFIG_OBJECT_TYPE_OVERLAY,	/* Type of Config object as overlay */
+	/**********************************************************************/
+	/* SLAVE SECTION */
+
+	PM_CONFIG_SLAVE_SECTION_ID,	/* Section ID */
+	1,				/* Number of slaves */
+
+	0, /* Node ID which will be changed below */
+	PM_SLAVE_FLAG_IS_SHAREABLE,
+	PM_CONFIG_IPI_PSU_CORTEXA53_0_MASK |
+	PM_CONFIG_IPI_PSU_CORTEXR5_0_MASK |
+	PM_CONFIG_IPI_PSU_CORTEXR5_1_MASK, /* IPI Mask */
+};
+
+int zynqmp_pmufw_node(u32 id)
+{
+	/* Record power domain id */
+	xpm_configobject[NODE_ID_LOCATION] = id;
+
+	zynqmp_pmufw_load_config_object(xpm_configobject,
+					sizeof(xpm_configobject));
+
+	return 0;
+}
+
 static int ipi_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen)
 {
 	struct zynqmp_ipi_msg msg;
diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h
index 19c004e91993..76c161806a0d 100644
--- a/include/zynqmp_firmware.h
+++ b/include/zynqmp_firmware.h
@@ -367,6 +367,7 @@ enum pm_ioctl_id {
 #define PAYLOAD_ARG_CNT	5U
 
 unsigned int zynqmp_firmware_version(void);
+int zynqmp_pmufw_node(u32 id);
 void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size);
 int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
 		      u32 arg3, u32 *ret_payload);
-- 
2.34.1


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

* [PATCH 2/4] firmware: zynqmp: Move loading message to debug
  2022-01-14 12:25 [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
  2022-01-14 12:25 ` [PATCH 1/4] xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU fragments Michal Simek
@ 2022-01-14 12:25 ` Michal Simek
  2022-01-14 12:25 ` [PATCH 3/4] firmware: zynqmp: Do not report error if node is already configured Michal Simek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2022-01-14 12:25 UTC (permalink / raw)
  To: u-boot, git; +Cc: Adrian Fiergolski

Power domain driver is using this function for every IP which is PD listed.
This can end up with a lot of messages which end up in boot log. That's why
show it only in EL3 as was used in past.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/firmware/firmware-zynqmp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index 10240ddccd3b..d6dd5a394ee9 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -131,7 +131,8 @@ void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
 	int err;
 	u32 ret_payload[PAYLOAD_ARG_CNT];
 
-	printf("Loading new PMUFW cfg obj (%ld bytes)\n", size);
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		printf("Loading new PMUFW cfg obj (%ld bytes)\n", size);
 
 	flush_dcache_range((ulong)cfg_obj, (ulong)(cfg_obj + size));
 
-- 
2.34.1


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

* [PATCH 3/4] firmware: zynqmp: Do not report error if node is already configured
  2022-01-14 12:25 [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
  2022-01-14 12:25 ` [PATCH 1/4] xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU fragments Michal Simek
  2022-01-14 12:25 ` [PATCH 2/4] firmware: zynqmp: Move loading message to debug Michal Simek
@ 2022-01-14 12:25 ` Michal Simek
  2022-01-14 12:25 ` [PATCH 4/4] arm64: zynqmp: Add command for disabling loading other overlays Michal Simek
  2022-01-19 10:38 ` [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2022-01-14 12:25 UTC (permalink / raw)
  To: u-boot, git; +Cc: Adrian Fiergolski

Power domain driver sends PM fragment to PMUFW. It is sent for every node
which is listed in DT. But some nodes could be already enabled but driver
is not capable to find it out. That's why it blinly sents request for every
listed IP. When PMUFW response by XST_PM_ALREADY_CONFIGURED error code
there is no need to show any error message because node is already enabled.
That's why cover this case with message when DEBUG is enabled.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/firmware/firmware-zynqmp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index d6dd5a394ee9..a80e73307982 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -21,6 +21,7 @@
 #define PMUFW_PAYLOAD_ARG_CNT	8
 
 #define XST_PM_NO_ACCESS	2002L
+#define XST_PM_ALREADY_CONFIGURED	2009L
 
 struct zynqmp_power {
 	struct mbox_chan tx_chan;
@@ -143,6 +144,11 @@ void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
 		return;
 	}
 
+	if (err == XST_PM_ALREADY_CONFIGURED) {
+		debug("PMUFW Node is already configured\n");
+		return;
+	}
+
 	if (err)
 		printf("Cannot load PMUFW configuration object (%d)\n", err);
 
-- 
2.34.1


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

* [PATCH 4/4] arm64: zynqmp: Add command for disabling loading other overlays
  2022-01-14 12:25 [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
                   ` (2 preceding siblings ...)
  2022-01-14 12:25 ` [PATCH 3/4] firmware: zynqmp: Do not report error if node is already configured Michal Simek
@ 2022-01-14 12:25 ` Michal Simek
  2022-01-19 10:38 ` [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2022-01-14 12:25 UTC (permalink / raw)
  To: u-boot, git; +Cc: Adrian Fiergolski

Add command "zynqmp pmufw node close" to disable permission to load
additional pmufw config overlays. This command will make sure that any
other sw will ask for changing permission.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 board/xilinx/zynqmp/cmds.c         | 16 ++++++++++++++++
 drivers/firmware/firmware-zynqmp.c | 19 +++++++++++++++++++
 include/zynqmp_firmware.h          |  1 +
 3 files changed, 36 insertions(+)

diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index 5a277c712f60..2ab9596248c0 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -209,6 +209,19 @@ static int do_zynqmp_pmufw(struct cmd_tbl *cmdtp, int flag, int argc,
 	if (argc != cmdtp->maxargs)
 		return CMD_RET_USAGE;
 
+	if (!strncmp(argv[2], "node", 4)) {
+		u32 id;
+
+		if (!strncmp(argv[3], "close", 5))
+			return zynqmp_pmufw_config_close();
+
+		id = dectoul(argv[3], NULL);
+
+		printf("Enable permission for node ID %d\n", id);
+
+		return zynqmp_pmufw_node(id);
+	}
+
 	addr = hextoul(argv[2], NULL);
 	size = hextoul(argv[3], NULL);
 
@@ -416,6 +429,9 @@ static char zynqmp_help_text[] =
 	"		       lock(0)/split(1)\n"
 #endif
 	"zynqmp pmufw address size - load PMU FW configuration object\n"
+	"zynqmp pmufw node <id> - load PMU FW configuration object\n"
+	"zynqmp pmufw node close - disable config object loading\n"
+	"	node: keyword, id: NODE_ID in decimal format\n"
 	"zynqmp rsa srcaddr srclen mod exp rsaop -\n"
 	"	Performs RSA encryption and RSA decryption on blob of data\n"
 	"	at srcaddr and puts it back in srcaddr using modulus and\n"
diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index a80e73307982..2ba0b3a7c5c6 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -49,6 +49,25 @@ static unsigned int xpm_configobject[] = {
 	PM_CONFIG_IPI_PSU_CORTEXR5_1_MASK, /* IPI Mask */
 };
 
+static unsigned int xpm_configobject_close[] = {
+	/**********************************************************************/
+	/* HEADER */
+	2,	/* Number of remaining words in the header */
+	1,	/* Number of sections included in config object */
+	PM_CONFIG_OBJECT_TYPE_OVERLAY,	/* Type of Config object as overlay */
+	/**********************************************************************/
+	/* SET CONFIG SECTION */
+	PM_CONFIG_SET_CONFIG_SECTION_ID,
+	0U,	/* Loading permission to Overlay config object */
+};
+
+int zynqmp_pmufw_config_close(void)
+{
+	zynqmp_pmufw_load_config_object(xpm_configobject_close,
+					sizeof(xpm_configobject_close));
+	return 0;
+}
+
 int zynqmp_pmufw_node(u32 id)
 {
 	/* Record power domain id */
diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h
index 76c161806a0d..50bf4ef39535 100644
--- a/include/zynqmp_firmware.h
+++ b/include/zynqmp_firmware.h
@@ -368,6 +368,7 @@ enum pm_ioctl_id {
 
 unsigned int zynqmp_firmware_version(void);
 int zynqmp_pmufw_node(u32 id);
+int zynqmp_pmufw_config_close(void);
 void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size);
 int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
 		      u32 arg3, u32 *ret_payload);
-- 
2.34.1


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

* Re: [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay
  2022-01-14 12:25 [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
                   ` (3 preceding siblings ...)
  2022-01-14 12:25 ` [PATCH 4/4] arm64: zynqmp: Add command for disabling loading other overlays Michal Simek
@ 2022-01-19 10:38 ` Michal Simek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2022-01-19 10:38 UTC (permalink / raw)
  To: U-Boot, git; +Cc: Adrian Fiergolski

pá 14. 1. 2022 v 13:25 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> Hi,
>
> this small series is extending firmware interface for sending
> pmufw configuration overlay with asking for access to certain
> device. This infrastructure can be used via command or via power domain
> driver.
>
> Thanks,
> Michal
>
>
> Michal Simek (4):
>   xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU
>     fragments
>   firmware: zynqmp: Move loading message to debug
>   firmware: zynqmp: Do not report error if node is already configured
>   arm64: zynqmp: Add command for disabling loading other overlays
>
>  board/xilinx/zynqmp/cmds.c         | 16 ++++++++
>  drivers/firmware/firmware-zynqmp.c | 60 +++++++++++++++++++++++++++++-
>  include/zynqmp_firmware.h          |  2 +
>  3 files changed, 77 insertions(+), 1 deletion(-)
>
> --
> 2.34.1
>

Applied.
M

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs

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

end of thread, other threads:[~2022-01-19 10:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 12:25 [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek
2022-01-14 12:25 ` [PATCH 1/4] xilinx: firmware: Introduce zynqmp_pmufw_node() for loading PMU fragments Michal Simek
2022-01-14 12:25 ` [PATCH 2/4] firmware: zynqmp: Move loading message to debug Michal Simek
2022-01-14 12:25 ` [PATCH 3/4] firmware: zynqmp: Do not report error if node is already configured Michal Simek
2022-01-14 12:25 ` [PATCH 4/4] arm64: zynqmp: Add command for disabling loading other overlays Michal Simek
2022-01-19 10:38 ` [PATCH 0/4] zynqmp: Add support for sending pmufw config object overlay Michal Simek

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.