arm64: zynqmp: Clean communication with PMUFW
Subsystems (5)
v2 cover arm64: zynqmp: Clean communication with PMUFW
Hi,
This patch series using ZynqMP firmware driver to provide a interface to communicate with the PMU Firmware. As part of the series a mailbox driver is also implemented to handle communication through ipi interface.
There are two new wiring:
1. Reading PMUFW version via firmware driver
- mailbox driver in case of SPL
- SMC in case of full U-Boot
2. Using the same patch for loading PMUFW configuration object
The whole series is based on several patches I have sent already that's why I am providing a branch which also contains this series.
https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze/tree/next
Thanks,
Michal
Changes in v2:
- Check error separately - Reported by Luca
- Align ret handling
- Also handle error from mbox_recv/mbox_send
- Move pm_api_id higher - Reported by Luca
- Fix macros for header protection
- pass rex_maxlen to ipi_req - reported by Luca
Ibai Erkiaga (10):
mailbox: check ops prior calling
mailbox: allow subnode for mbox regs
mailbox: zynqmp: ipi mailbox driver
firmware: zynqmp: Add zynqmp-power support
arm64: zynqmp: add firmware and mailbox node to DT
firmware: zynqmp: get fw version with mailbox driver
firmware: zynqmp: create firmware header
arm64: zynqmp: use firmware driver to get version
arm64: zynqmp: remove old fw version function
arm64: zynqmp: probe firmware driver
Michal Simek (3):
arm64: zynqmp: Cleanup PM SMC macro composition
firmware: zynqmp: Separate function for sending message via mailbox
arm64: zynqmp: Use mailbox driver for PMUFW config loading
MAINTAINERS | 2 + arch/arm/Kconfig | 3 + arch/arm/dts/zynqmp.dtsi | 44 +++++- arch/arm/mach-zynqmp/Makefile | 4 - arch/arm/mach-zynqmp/cpu.c | 24 +-- arch/arm/mach-zynqmp/include/mach/sys_proto.h | 24 +-- arch/arm/mach-zynqmp/pmu_ipc.c | 112 -------------- board/xilinx/zynqmp/cmds.c | 1 + board/xilinx/zynqmp/zynqmp.c | 19 +-- drivers/firmware/Kconfig | 2 + drivers/firmware/firmware-zynqmp.c | 142 ++++++++++++++++++ drivers/fpga/zynqmppl.c | 5 +- drivers/mailbox/Kconfig | 6 + drivers/mailbox/Makefile | 1 + drivers/mailbox/mailbox-uclass.c | 19 ++- drivers/mailbox/zynqmp-ipi.c | 134 +++++++++++++++++ include/zynqmp_firmware.h | 37 +++++ 17 files changed, 399 insertions(+), 180 deletions(-) delete mode 100644 arch/arm/mach-zynqmp/pmu_ipc.c create mode 100644 drivers/mailbox/zynqmp-ipi.c create mode 100644 include/zynqmp_firmware.h
Signature · 1 line
2.17.1
PATCH v2 1/13 mailbox: check ops prior calling
From: Ibai Erkiaga <[email protected]>
Check if request and free operations are present prior calling to the functions.
---
Changes in v2: None
drivers/mailbox/mailbox-uclass.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mailbox/mailbox-uclass.c +6 -2
@@ -63,7 +63,8 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan)return ret; } - ret = ops->request (chan); +if (ops->request) + ret = ops->request (chan);if (ret) {debug ("ops->request() failed: %d\n" , ret);return ret;
@@ -94,7 +95,10 @@ int mbox_free(struct mbox_chan *chan)debug ("%s(chan=%p)\n" , __func__, chan); -return ops->free (chan); +if (ops->free) +return ops->free (chan); + +return 0 ; }int mbox_send (struct mbox_chan *chan,const void *data)
Signature · 1 line
2.17.1
PATCH v2 2/13 mailbox: allow subnode for mbox regs
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
The following patch allows the mailbox node in DT to host subnodes with mailbox definitions. If the client phandle to the mailbox is not the mailbox driver node, just checks parents as well.
---
Changes in v2: None
drivers/mailbox/mailbox-uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mailbox/mailbox-uclass.c +10 -1
@@ -49,7 +49,16 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan)if (ret) {debug ("%s: uclass_get_device_by_of_offset failed: %d\n" , __func__, ret); -return ret; + +/* Test with parent node */ + ret =uclass_get_device_by_ofnode (UCLASS_MAILBOX , +ofnode_get_parent (args.node), + &dev_mbox); +if (ret) { +debug ("%s: mbox node from parent failed: %d\n" , + __func__, ret); +return ret; + }; } ops =mbox_dev_ops (dev_mbox);
Signature · 1 line
2.17.1
PATCH v2 3/13 mailbox: zynqmp: ipi mailbox driver
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
ZynqMP mailbox driver implementing IPI communication with PMU. This would allow U-Boot SPL to communicate with PMUFW to request privileged operations.
---
Changes in v2: None
MAINTAINERS | 1 + arch/arm/mach-zynqmp/include/mach/sys_proto.h | 5 + drivers/mailbox/Kconfig | 6 + drivers/mailbox/Makefile | 1 + drivers/mailbox/zynqmp-ipi.c | 134 ++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 drivers/mailbox/zynqmp-ipi.c
MAINTAINERS +1 -0
@@ -448,6 +448,7 @@ F: drivers/gpio/zynq_gpio.c F: drivers/i2c/i2c-cdns.c F: drivers/i2c/muxes/pca954x.c F: drivers/i2c/zynq_i2c.c +F: drivers/mailbox/zynqmp-ipi.c F: drivers/mmc/zynq_sdhci.c F: drivers/mtd/nand/raw/zynq_nand.c F: drivers/net/phy/xilinx_phy.c
arch/arm/mach-zynqmp/include/mach/sys_proto.h +5 -0
@@ -54,6 +54,11 @@ enum { TCM_SPLIT, }; +struct zynqmp_ipi_msg { +size_t len; +u32 *buf; +}; +int zynq_board_read_rom_ethaddr (unsigned char *ethaddr);unsigned int zynqmp_get_silicon_version (void );
drivers/mailbox/Kconfig +6 -0
@@ -41,4 +41,10 @@ config K3_SEC_PROXY Select this driver if your platform has support for this hardware block. +config ZYNQMP_IPI + bool "Xilinx ZynqMP IPI controller support" + depends on DM_MAILBOX && ARCH_ZYNQMP + help + This enables support for the Xilinx ZynqMP Inter Processor Interrupt + communication controller. endmenu
drivers/mailbox/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_SANDBOX_MBOX) += sandbox-mbox-test.o obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o obj-$(CONFIG_TEGRA_HSP) += tegra-hsp.o obj-$(CONFIG_K3_SEC_PROXY) += k3-sec-proxy.o +obj-$(CONFIG_ZYNQMP_IPI) += zynqmp-ipi.o
drivers/mailbox/zynqmp-ipi.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 4/13 firmware: zynqmp: Add zynqmp-power support
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
zynqmp-power driver for ZynqMP to handle the communication with the PMU firmware. Firmware driver just probes subnodes and power driver handles communication with PMU using the IPI mailbox driver.
---
Changes in v2:
- Check error separately - Reported by Luca
drivers/firmware/Kconfig | 2 ++ drivers/firmware/firmware-zynqmp.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
drivers/firmware/Kconfig +2 -0
@@ -30,6 +30,8 @@ config TI_SCI_PROTOCOL config ZYNQMP_FIRMWARE bool "ZynqMP Firmware interface" select FIRMWARE + select ZYNQMP_IPI + select DM_MAILBOX help Firmware interface driver is used by different drivers to communicate with the firmware for
drivers/firmware/firmware-zynqmp.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/13 arm64: zynqmp: add firmware and mailbox node to DT
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
The following patch adds a mailbox node and firmware node to following the mainline DT.
---
Changes in v2: None
arch/arm/dts/zynqmp.dtsi | 44 +++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-)
arch/arm/dts/zynqmp.dtsi +39 -5
@@ -96,6 +96,29 @@ }; }; + zynqmp_ipi { + u-boot,dm-pre-reloc; + compatible = "xlnx,zynqmp-ipi-mailbox"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + xlnx,ipi-id = <0>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + ipi_mailbox_pmu1: mailbox at ff990400 { + u-boot,dm-pre-reloc; + reg = <0x0 0xff9905c0 0x0 0x20>, + <0x0 0xff9905e0 0x0 0x20>, + <0x0 0xff990e80 0x0 0x20>, + <0x0 0xff990ea0 0x0 0x20>; + reg-names = "local_request_region" , "local_response_region", + "remote_request_region", "remote_response_region"; + #mbox-cells = <1>; + xlnx,ipi-id = <4>; + }; + }; + dcc: dcc { compatible = "arm,dcc"; status = "disabled";
@@ -116,11 +139,22 @@ method = "smc"; }; - pmufw: firmware { - compatible = "xlnx,zynqmp-pm"; - method = "smc"; - interrupt-parent = <&gic>; - interrupts = <0 35 4>; + firmware { + zynqmp-firmware { + compatible = "xlnx,zynqmp-firmware"; + method = "smc"; + #power-domain-cells = <0x1>; + u-boot,dm-pre-reloc; + + zynqmp_power: zynqmp-power { + u-boot,dm-pre-reloc; + compatible = "xlnx,zynqmp-power"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + mboxes = <&ipi_mailbox_pmu1 0>, <&ipi_mailbox_pmu1 1>; + mbox-names = "tx", "rx"; + }; + }; }; timer {
Signature · 1 line
2.17.1
PATCH v2 6/13 arm64: zynqmp: Cleanup PM SMC macro composition
In reply to Michal SimekCleanup PM ID handling by using enum values.
---
Changes in v2: None
arch/arm/mach-zynqmp/include/mach/sys_proto.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/include/mach/sys_proto.h +11 -2
@@ -10,7 +10,8 @@#define PAYLOAD_ARG_CNT 5#define ZYNQMP_CSU_SILICON_VER_MASK 0xF -#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD 0xC200002D +#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ + (PM_SIP_SVC + PM_SECURE_IMAGE)#define KEY_PTR_LEN 32#define ZYNQMP_FPGA_BIT_AUTH_DDR 1
@@ -21,7 +22,8 @@#define ZYNQMP_FPGA_AUTH_DDR 1 -#define ZYNQMP_SIP_SVC_GET_API_VERSION 0xC2000001 +#define ZYNQMP_SIP_SVC_GET_API_VERSION \ + (PM_SIP_SVC + PM_GET_API_VERSION)#define ZYNQMP_PM_VERSION_MAJOR 1#define ZYNQMP_PM_VERSION_MINOR 0
@@ -36,6 +38,13 @@#define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) +#define PM_SIP_SVC 0xc2000000 + +enum pm_api_id { +PM_GET_API_VERSION =1 , +PM_SECURE_IMAGE =45 , +}; +enum {IDCODE ,VERSION ,
Signature · 1 line
2.17.1
PATCH v2 7/13 firmware: zynqmp: get fw version with mailbox driver
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
Implements the function to get PMU Firmware version using the mailbox driver or smc call based on if running SPL or not. Additionally gets version as part of the ZynqMP Firmware driver probing
---
Changes in v2:
- Align ret handling
- Also handle error from mbox_recv/mbox_send
drivers/firmware/firmware-zynqmp.c | 76 +++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/firmware/firmware-zynqmp.c +74 -2
@@ -10,11 +10,76 @@#include <mailbox.h> #include <asm/arch/sys_proto.h> +#define PMUFW_PAYLOAD_ARG_CNT 8 +struct zynqmp_power {struct mbox_chan tx_chan;struct mbox_chan rx_chan; } zynqmp_power; +static int ipi_req (const u32 *req,size_t req_len,u32 *res,size_t res_maxlen) +{ +struct zynqmp_ipi_msg msg; +int ret; + +if (req_len >PMUFW_PAYLOAD_ARG_CNT || + res_maxlen >PMUFW_PAYLOAD_ARG_CNT ) +return -EINVAL ; + +if (!(zynqmp_power.tx_chan.dev) || !(&zynqmp_power.rx_chan.dev)) +return -EINVAL ; + + msg.buf = (u32 *)req; + msg.len = req_len; + ret =mbox_send (&zynqmp_power.tx_chan, &msg); +if (ret) { +debug ("%s: Sending message failed\n" , __func__); +return ret; + } + + msg.buf = res; + msg.len = res_maxlen; + ret =mbox_recv (&zynqmp_power.rx_chan, &msg,100 ); +if (ret) +debug ("%s: Receiving message failed\n" , __func__); + +return ret; +} + +unsigned int zynqmp_firmware_version (void ) +{ +int ret; +u32 ret_payload[PAYLOAD_ARG_CNT ]; +static u32 pm_api_version =ZYNQMP_PM_VERSION_INVALID ; + +/* +* Get PMU version only once and later +* just return stored values instead of +* asking PMUFW again. +**/ +if (pm_api_version ==ZYNQMP_PM_VERSION_INVALID ) { +if (IS_ENABLED (CONFIG_SPL_BUILD )) { +const u32 request[] = {PM_GET_API_VERSION }; + + ret =ipi_req (request,ARRAY_SIZE (request), + ret_payload,2 ); + }else { + ret =invoke_smc (ZYNQMP_SIP_SVC_GET_API_VERSION ,0 ,0 , +0 ,0 , ret_payload); + }; + +if (ret) +panic ("PMUFW is not found - Please load it!\n" ); + + pm_api_version = ret_payload[1 ]; +if (pm_api_version <ZYNQMP_PM_VERSION ) +panic ("PMUFW version error. Expected: v%d.%d\n" , +ZYNQMP_PM_VERSION_MAJOR ,ZYNQMP_PM_VERSION_MINOR ); + } + +return pm_api_version; +}; +static int zynqmp_power_probe (struct udevice *dev) {int ret =0 ;
@@ -28,10 +93,17 @@ static int zynqmp_power_probe(struct udevice *dev) } ret =mbox_get_by_name (dev,"rx" , &zynqmp_power.rx_chan); -if (ret) +if (ret) {debug ("%s, cannot rx mailbox\n" , __func__); +return ret; + } -return ret; + ret =zynqmp_firmware_version (); +printf ("PMUFW:\tv%d.%d\n" , + ret >>ZYNQMP_PM_VERSION_MAJOR_SHIFT , + ret &ZYNQMP_PM_VERSION_MINOR_MASK ); + +return 0 ; };static const struct udevice_id zynqmp_power_ids[] = {
Signature · 1 line
2.17.1
PATCH v2 8/13 firmware: zynqmp: create firmware header
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
New firmware header to place firmware specific macro and function declarations. The patch also moves the macros defining PM operations as well as some helper macros.
---
Changes in v2:
- Move pm_api_id higher - Reported by Luca
- Fix macros for header protection
MAINTAINERS | 1 + arch/arm/mach-zynqmp/cpu.c | 1 + arch/arm/mach-zynqmp/include/mach/sys_proto.h | 25 ------------ board/xilinx/zynqmp/cmds.c | 1 + board/xilinx/zynqmp/zynqmp.c | 1 + drivers/firmware/firmware-zynqmp.c | 1 + drivers/fpga/zynqmppl.c | 1 + include/zynqmp_firmware.h | 38 +++++++++++++++++++ 8 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 include/zynqmp_firmware.h
MAINTAINERS +1 -0
@@ -460,6 +460,7 @@ F: drivers/timer/cadence-ttc.c F: drivers/usb/host/ehci-zynq.c F: drivers/watchdog/cdns_wdt.c F: include/zynqmppl.h +F: include/zynqmp_firmware.h F: tools/zynqmp* N: ultra96 N: zynqmp
arch/arm/mach-zynqmp/cpu.c +1 -0
@@ -9,6 +9,7 @@#include <asm/arch/sys_proto.h> #include <asm/armv8/mmu.h> #include <asm/io.h> +#include <zynqmp_firmware.h> #define ZYNQ_SILICON_VER_MASK 0xF000#define ZYNQ_SILICON_VER_SHIFT 12
arch/arm/mach-zynqmp/include/mach/sys_proto.h +0 -25
@@ -10,8 +10,6 @@#define PAYLOAD_ARG_CNT 5#define ZYNQMP_CSU_SILICON_VER_MASK 0xF -#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ - (PM_SIP_SVC + PM_SECURE_IMAGE)#define KEY_PTR_LEN 32#define ZYNQMP_FPGA_BIT_AUTH_DDR 1
@@ -22,29 +20,6 @@#define ZYNQMP_FPGA_AUTH_DDR 1 -#define ZYNQMP_SIP_SVC_GET_API_VERSION \ - (PM_SIP_SVC + PM_GET_API_VERSION) - -#define ZYNQMP_PM_VERSION_MAJOR 1 -#define ZYNQMP_PM_VERSION_MINOR 0 -#define ZYNQMP_PM_VERSION_MAJOR_SHIFT 16 -#define ZYNQMP_PM_VERSION_MINOR_MASK 0xFFFF - -#define ZYNQMP_PM_VERSION \ - ((ZYNQMP_PM_VERSION_MAJOR << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | \ - ZYNQMP_PM_VERSION_MINOR) - -#define ZYNQMP_PM_VERSION_INVALID ~0 - -#define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) - -#define PM_SIP_SVC 0xc2000000 - -enum pm_api_id { -PM_GET_API_VERSION =1 , -PM_SECURE_IMAGE =45 , -}; -enum {IDCODE ,VERSION ,
board/xilinx/zynqmp/cmds.c +1 -0
@@ -7,6 +7,7 @@#include <common.h> #include <env.h> #include <malloc.h> +#include <zynqmp_firmware.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> #include <asm/io.h>
board/xilinx/zynqmp/zynqmp.c +1 -0
@@ -21,6 +21,7 @@#include <usb.h> #include <dwc3-uboot.h> #include <zynqmppl.h> +#include <zynqmp_firmware.h> #include <g_dnl.h> #include <linux/sizes.h>
drivers/firmware/firmware-zynqmp.c +1 -0
@@ -8,6 +8,7 @@#include <common.h> #include <dm.h> #include <mailbox.h> +#include <zynqmp_firmware.h> #include <asm/arch/sys_proto.h> #define PMUFW_PAYLOAD_ARG_CNT 8
drivers/fpga/zynqmppl.c +1 -0
@@ -8,6 +8,7 @@#include <console.h> #include <common.h> #include <zynqmppl.h> +#include <zynqmp_firmware.h> #include <linux/sizes.h> #include <asm/arch/sys_proto.h> #include <memalign.h>
include/zynqmp_firmware.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Xilinx Zynq MPSoC Firmware driver +* +* Copyright (C) 2018-2019 Xilinx, Inc. +*/ + +#ifndef _ZYNQMP_FIRMWARE_H_ +#define _ZYNQMP_FIRMWARE_H_ + +enum pm_api_id { +PM_GET_API_VERSION =1 , +PM_SET_CONFIGURATION , +PM_SECURE_IMAGE =45 , +}; + +#define PM_SIP_SVC 0xc2000000 +#define ZYNQMP_SIP_SVC_GET_API_VERSION \ + (PM_SIP_SVC + PM_GET_API_VERSION) +#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ + (PM_SIP_SVC + PM_SECURE_IMAGE) + +#define ZYNQMP_PM_VERSION_MAJOR 1 +#define ZYNQMP_PM_VERSION_MINOR 0 +#define ZYNQMP_PM_VERSION_MAJOR_SHIFT 16 +#define ZYNQMP_PM_VERSION_MINOR_MASK 0xFFFF + +#define ZYNQMP_PM_VERSION \ + ((ZYNQMP_PM_VERSION_MAJOR << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | \ + ZYNQMP_PM_VERSION_MINOR) + +#define ZYNQMP_PM_VERSION_INVALID ~0 + +#define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) + +unsigned int zynqmp_firmware_version (void ); + +#endif /* _ZYNQMP_FIRMWARE_H_ */
Signature · 1 line
2.17.1
PATCH v2 9/13 arm64: zynqmp: use firmware driver to get version
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
Use the new function from firmware version to get the firmware version.
---
Changes in v2: None
board/xilinx/zynqmp/zynqmp.c | 2 +- drivers/fpga/zynqmppl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
board/xilinx/zynqmp/zynqmp.c +1 -1
@@ -321,7 +321,7 @@ int board_early_init_f(void)#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_CLK_ZYNQMP )u32 pm_api_version; - pm_api_version =zynqmp_pmufw_version (); + pm_api_version =zynqmp_firmware_version ();printf ("PMUFW:\tv%d.%d\n" , pm_api_version >>ZYNQMP_PM_VERSION_MAJOR_SHIFT , pm_api_version &ZYNQMP_PM_VERSION_MINOR_MASK );
drivers/fpga/zynqmppl.c +2 -2
@@ -152,7 +152,7 @@ static ulong zynqmp_align_dma_buffer(u32 *buf, u32 len, u32 swap) buf = new_buf; }else if ((swap !=SWAP_DONE ) && - (zynqmp_pmufw_version () <=PMUFW_V1_0 )) { + (zynqmp_firmware_version () <=PMUFW_V1_0 )) {/* For bitstream which are aligned */ new_buf = buf;
@@ -205,7 +205,7 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize,u32 ret_payload[PAYLOAD_ARG_CNT ];bool xilfpga_old = false; -if (zynqmp_pmufw_version () <=PMUFW_V1_0 ) { +if (zynqmp_firmware_version () <=PMUFW_V1_0 ) {puts ("WARN: PMUFW v1.0 or less is detected\n" );puts ("WARN: Not all bitstream formats are supported\n" );puts ("WARN: Please upgrade PMUFW\n" );
Signature · 1 line
2.17.1
PATCH v2 10/13 arm64: zynqmp: remove old fw version function
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
Removes the old function to get the firmware version.
---
Changes in v2: None
arch/arm/mach-zynqmp/cpu.c | 23 ------------------- arch/arm/mach-zynqmp/include/mach/sys_proto.h | 1 - 2 files changed, 24 deletions(-)
arch/arm/mach-zynqmp/cpu.c +0 -23
@@ -180,29 +180,6 @@ int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2,return regs.regs[0 ]; } -unsigned int __maybe_unused zynqmp_pmufw_version (void ) -{ -int ret; -u32 ret_payload[PAYLOAD_ARG_CNT ]; -static u32 pm_api_version =ZYNQMP_PM_VERSION_INVALID ; - -/* -* Get PMU version only once and later -* just return stored values instead of -* asking PMUFW again. -*/ -if (pm_api_version ==ZYNQMP_PM_VERSION_INVALID ) { - ret =invoke_smc (ZYNQMP_SIP_SVC_GET_API_VERSION ,0 ,0 ,0 ,0 , - ret_payload); - pm_api_version = ret_payload[1 ]; - -if (ret) -panic ("PMUFW is not found - Please load it!\n" ); - } - -return pm_api_version; -} -static int zynqmp_mmio_rawwrite (const u32 address,const u32 mask,const u32 value)
arch/arm/mach-zynqmp/include/mach/sys_proto.h +0 -1
@@ -48,7 +48,6 @@ unsigned int zynqmp_get_silicon_version(void);void handoff_setup (void ); -unsigned int zynqmp_pmufw_version (void );int zynqmp_mmio_write (const u32 address,const u32 mask,const u32 value);int zynqmp_mmio_read (const u32 address,u32 *value); int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,
Signature · 1 line
2.17.1
PATCH v2 11/13 arm64: zynqmp: probe firmware driver
In reply to Michal SimekFrom: Ibai Erkiaga <[email protected]>
Probe ZynqMP firmware driver on the board initialization phase and ensure that firmware is in place to continue execution. The probing is done on board_init so it can be used for both SPL and U-Boot proper.
---
Changes in v2: None
arch/arm/Kconfig | 3 +++ board/xilinx/zynqmp/zynqmp.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-)
arch/arm/Kconfig +3 -0
@@ -1056,9 +1056,12 @@ config ARCH_ZYNQMP select DM_SPI if SPI select DM_SPI_FLASH if DM_SPI select DM_USB if USB + select FIRMWARE select OF_CONTROL select SPL_BOARD_INIT if SPL select SPL_CLK if SPL + select SPL_DM_MAILBOX if SPL + select SPL_FIRMWARE if SPL select SPL_SEPARATE_BSS if SPL select SUPPORT_SPL imply BOARD_LATE_INIT
board/xilinx/zynqmp/zynqmp.c +6 -12
@@ -318,18 +318,6 @@ static char *zynqmp_get_silicon_idcode_name(void)int board_early_init_f (void ) {int ret =0 ; -#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_CLK_ZYNQMP ) -u32 pm_api_version; - - pm_api_version =zynqmp_firmware_version (); -printf ("PMUFW:\tv%d.%d\n" , - pm_api_version >>ZYNQMP_PM_VERSION_MAJOR_SHIFT , - pm_api_version &ZYNQMP_PM_VERSION_MINOR_MASK ); - -if (pm_api_version <ZYNQMP_PM_VERSION ) -panic ("PMUFW version error. Expected: v%d.%d\n" , -ZYNQMP_PM_VERSION_MAJOR ,ZYNQMP_PM_VERSION_MINOR ); -#endif #if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED ) ret =psu_init ();
@@ -340,6 +328,12 @@ int board_early_init_f(void)int board_init (void ) { +struct udevice *dev; + +uclass_get_device_by_name (UCLASS_FIRMWARE ,"zynqmp-power" , &dev); +if (!dev) +panic ("PMU Firmware device not found - Enable it" ); +#if defined(CONFIG_SPL_BUILD )/* Check *at build time* if the filename is an non-empty string */ if (sizeof (CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE ) >1 )
Signature · 1 line
2.17.1
PATCH v2 12/13 firmware: zynqmp: Separate function for sending message via mailbox
In reply to Michal SimekU-Boot running in EL3 can't use SMC that's why there is a need to talk to PMUFW directly via mailbox. The same logic is applied to all functions which need to talk to PMUFW that's why move this logic to separate function to avoid code duplication.
Also SMC request ID can be composed from PM_SIP_SVC offset that's why ZYNQMP_SIP_SVC_GET_API_VERSION macro can be removed completely.
---
Changes in v2:
- pass rex_maxlen to ipi_req - reported by Luca
drivers/firmware/firmware-zynqmp.c | 19 ++++++++++--------- include/zynqmp_firmware.h | 2 -- 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/firmware/firmware-zynqmp.c +10 -9
@@ -47,6 +47,14 @@ static int ipi_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen)return ret; } +static int send_req (const u32 *req,size_t req_len,u32 *res,size_t res_maxlen) +{ +if (IS_ENABLED (CONFIG_SPL_BUILD )) +return ipi_req (req, req_len, res, res_maxlen); + +return invoke_smc (req[0 ] +PM_SIP_SVC ,0 ,0 ,0 ,0 , res); +} +unsigned int zynqmp_firmware_version (void ) {int ret;
@@ -59,16 +67,9 @@ unsigned int zynqmp_firmware_version(void)* asking PMUFW again. **/ if (pm_api_version ==ZYNQMP_PM_VERSION_INVALID ) { -if (IS_ENABLED (CONFIG_SPL_BUILD )) { -const u32 request[] = {PM_GET_API_VERSION }; - - ret =ipi_req (request,ARRAY_SIZE (request), - ret_payload,2 ); - }else { - ret =invoke_smc (ZYNQMP_SIP_SVC_GET_API_VERSION ,0 ,0 , -0 ,0 , ret_payload); - }; +const u32 request[] = {PM_GET_API_VERSION }; + ret =send_req (request,ARRAY_SIZE (request), ret_payload,2 );if (ret)panic ("PMUFW is not found - Please load it!\n" );
include/zynqmp_firmware.h +0 -2
@@ -15,8 +15,6 @@ enum pm_api_id { };#define PM_SIP_SVC 0xc2000000 -#define ZYNQMP_SIP_SVC_GET_API_VERSION \ - (PM_SIP_SVC + PM_GET_API_VERSION)#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ (PM_SIP_SVC + PM_SECURE_IMAGE)
Signature · 1 line
2.17.1
PATCH v2 13/13 arm64: zynqmp: Use mailbox driver for PMUFW config loading
In reply to Michal SimekWith new mailbox driver PMUFW configuration object can be loaded via the same interface and there is no need to have pmu_ipc.c completely.
---
Changes in v2: None
arch/arm/mach-zynqmp/Makefile | 4 - arch/arm/mach-zynqmp/include/mach/sys_proto.h | 2 - arch/arm/mach-zynqmp/pmu_ipc.c | 112 ------------------ drivers/firmware/firmware-zynqmp.c | 24 ++++ include/zynqmp_firmware.h | 1 + 5 files changed, 25 insertions(+), 118 deletions(-) delete mode 100644 arch/arm/mach-zynqmp/pmu_ipc.c
arch/arm/mach-zynqmp/Makefile +0 -4
@@ -8,7 +8,3 @@ obj-y += cpu.o obj-$(CONFIG_MP) += mp.o obj-$(CONFIG_SPL_BUILD) += spl.o handoff.o obj-$(CONFIG_ZYNQMP_PSU_INIT_ENABLED) += psu_spl_init.o - -ifneq ($(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE),"") -obj-$(CONFIG_SPL_BUILD) += pmu_ipc.o -endif
arch/arm/mach-zynqmp/include/mach/sys_proto.h +0 -2
@@ -60,6 +60,4 @@ int chip_id(unsigned char id);void tcm_init (u8 mode);#endif -void zynqmp_pmufw_load_config_object (const void *cfg_obj,size_t size); -#endif /* _ASM_ARCH_SYS_PROTO_H */
arch/arm/mach-zynqmp/pmu_ipc.c deleted +0 -112
112 lines not on this page · raw message
drivers/firmware/firmware-zynqmp.c +24 -0
@@ -82,6 +82,30 @@ unsigned int zynqmp_firmware_version(void)return pm_api_version; }; +/** +* Send a configuration object to the PMU firmware. +* +* @cfg_obj: Pointer to the configuration object +* @size: Size of @cfg_obj in bytes +*/ +void zynqmp_pmufw_load_config_object (const void *cfg_obj,size_t size) +{ +const u32 request[] = { +PM_SET_CONFIGURATION , + (u32)((u64 )cfg_obj) + }; +u32 response; +int err; + +printf ("Loading new PMUFW cfg obj (%ld bytes)\n" , size); + + err =send_req (request,ARRAY_SIZE (request), &response,1 ); +if (err) +panic ("Cannot load PMUFW configuration object (%d)\n" , err); +if (response !=0 ) +panic ("PMUFW returned 0x%08x status!\n" , response); +} +static int zynqmp_power_probe (struct udevice *dev) {int ret =0 ;
include/zynqmp_firmware.h +1 -0
@@ -32,5 +32,6 @@ enum pm_api_id {#define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0)unsigned int zynqmp_firmware_version (void ); +void zynqmp_pmufw_load_config_object (const void *cfg_obj,size_t size);#endif /* _ZYNQMP_FIRMWARE_H_ */
Signature · 1 line
2.17.1
v2 cover arm64: zynqmp: Clean communication with PMUFW
In reply to Michal Simekst 2. 10. 2019 v 15:39 odesÃlatel Michal Simek <[email protected]> napsal:
Quoted 28 lines
Hi,
This patch series using ZynqMP firmware driver to provide a interface to communicate with the PMU Firmware. As part of the series a mailbox driver is also implemented to handle communication through ipi interface.
There are two new wiring:
1. Reading PMUFW version via firmware driver
- mailbox driver in case of SPL
- SMC in case of full U-Boot
2. Using the same patch for loading PMUFW configuration objectThe whole series is based on several patches I have sent already that's why I am providing a branch which also contains this series.
https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze/tree/nextThanks,
MichalChanges in v2:
- Check error separately - Reported by Luca
- Align ret handling
- Also handle error from mbox_recv/mbox_send
- Movepm_api_idhigher - Reported by Luca
- Fix macros for header protection
- passrex_maxlentoipi_req- reported by Luca
Quoted 5 lines
Ibai Erkiaga (10):
mailbox: check ops prior calling
mailbox: allow subnode for mbox regs
mailbox: zynqmp: ipi mailbox driver
firmware: zynqmp: Add zynqmp-power support
Applied all. Only in this patch I have fixed dependencies to be selected via ARCH fragment.
Because IPI driver hasn't been adopted by Versal to be able to select IPI directly.
M
Signature · 5 lines
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
PATCH v2 3/13 mailbox: zynqmp: ipi mailbox driver
In reply to Michal SimekHi Ibai, Michal,
I had half-written a review of this patch and patch 4. Unfortunately I didn't finish them before they got applied. I'll send them now anyway, they are mostly nitpicking but you might consider them for a future improvement. Sorry for the inconvenience.
Quoted 8 lines · Michal Simek
From: Ibai Erkiaga <[email protected]>
ZynqMP mailbox driver implementing IPI communication with PMU. This would allow U-Boot SPL to communicate with PMUFW to request privileged operations.
Signed-off-by Ibai Erkiaga <[email protected]>Signed-off-by Michal Simek <[email protected]>
...
Quoted 29 lines
drivers/mailbox/zynqmp-ipi.c new file +29
-0+static int zynqmp_ipi_probe (struct udevice *dev) +{ +struct zynqmp_ipi *zynqmp =dev_get_priv (dev); +struct resource res; +ofnode node; + +debug ("%s(dev=%p)\n" , __func__, dev); + +/* Get subnode where the regs are defined */ +/* Note IPI mailbox node needs to be the first one in DT */ + node =ofnode_first_subnode (dev_ofnode (dev)); + +if (ofnode_read_resource_byname (node,"local_request_region" , &res)) { +dev_err (dev,"No reg property for local_request_region\n" ); +return -EINVAL ; + }; + zynqmp->local_req_regs =devm_ioremap (dev, res.start, + (res.start - res.end)); + +if (ofnode_read_resource_byname (node,"local_response_region" , &res)) { +dev_err (dev,"No reg property for local_response_region\n" ); +return -EINVAL ; + }; + zynqmp->local_res_regs =devm_ioremap (dev, res.start, + (res.start - res.end)); + +if (ofnode_read_resource_byname (node,"remote_request_region" , &res)) { +dev_err (dev,"No reg property for remote_request_region\n" ); +return -EINVAL ;
drivers/mailbox/zynqmp-ipi.c line 112
Quoted 10 lines
drivers/mailbox/zynqmp-ipi.c new file +10
-0+ }; + zynqmp->remote_req_regs =devm_ioremap (dev, res.start, + (res.start - res.end)); + +if (ofnode_read_resource_byname (node,"remote_response_region" , &res)) { +dev_err (dev,"No reg property for remote_response_region\n" ); +return -EINVAL ; + }; + zynqmp->remote_res_regs =devm_ioremap (dev, res.start, + (res.start - res.end));
remote_req_regs and remote_res_regs are not used, why adding them in DT?
Should there be a good reason to keep them, I think the above code could be reorganized to avoid code duplication (assuming binary size of a bootloader still matters nowadays).
Signature · 1 line
Luca
PATCH v2 4/13 firmware: zynqmp: Add zynqmp-power support
In reply to Michal SimekHi,
Quoted 22 lines · Michal Simek
From: Ibai Erkiaga <[email protected]>
zynqmp-power driver for ZynqMP to handle the communication with the PMU firmware. Firmware driver just probes subnodes and power driver handles communication with PMU using the IPI mailbox driver.
Signed-off-by Ibai Erkiaga <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Check error separately - Reported by Lucadrivers/firmware/Kconfig | 2 ++ drivers/firmware/firmware-zynqmp.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)drivers/firmware/Kconfig +0
-0
drivers/firmware/Kconfig config TI_SCI_PROTOCOL · line 34
Quoted 5 lines
drivers/firmware/Kconfig +2
-0@@ -30,6 +30,8 @@ config TI_SCI_PROTOCOL config ZYNQMP_FIRMWARE bool "ZynqMP Firmware interface" select FIRMWARE + select ZYNQMP_IPI + select DM_MAILBOX
Nitpick: ZYNQMP_IPI depends on DM_MAILBOX, so I'd list them in opposite order. Just for clarity.
Quoted 18 lines
drivers/firmware/Kconfig +0
-0help Firmware interface driver is used by different drivers to communicate with the firmware fordrivers/firmware/firmware-zynqmp.c +7
-0@@ -1,6 +1,50 @@// SPDX-License-Identifier: GPL-2.0 +/* +* Xilinx Zynq MPSoC Firmware driver +* +* Copyright (C) 2018-2019 Xilinx, Inc. +*/ +#include <common.h> #include <dm.h> +#include <mailbox.h>
drivers/firmware/firmware-zynqmp.c line 20
Quoted 10 lines
drivers/firmware/firmware-zynqmp.c +10
-0+#include <asm/arch/sys_proto.h> + +struct zynqmp_power { +struct mbox_chan tx_chan; +struct mbox_chan rx_chan; +} zynqmp_power; + +static int zynqmp_power_probe (struct udevice *dev) +{ +int ret =0 ;
No need to initialize.
drivers/firmware/firmware-zynqmp.c line 26
Quoted 6 lines
drivers/firmware/firmware-zynqmp.c +6
-0+ +debug ("%s, (dev=%p)\n" , __func__, dev); + + ret =mbox_get_by_name (dev,"tx" , &zynqmp_power.tx_chan); +if (ret) { +debug ("%s, cannot tx mailbox\n" , __func__);
"cannot tx" -> "cannot find tx"?
drivers/firmware/firmware-zynqmp.c line 32
Quoted 6 lines
drivers/firmware/firmware-zynqmp.c +6
-0+return ret; + } + + ret =mbox_get_by_name (dev,"rx" , &zynqmp_power.rx_chan); +if (ret) +debug ("%s, cannot rx mailbox\n" , __func__);
Ditto.
drivers/firmware/firmware-zynqmp.c line 34
Quoted 2 lines
drivers/firmware/firmware-zynqmp.c +2
-0+ +return ret;
return 0;
PS: I think some of the above are fixed in later patches, but some are still valid.
Signature · 1 line
Luca
PATCH v2 3/13 mailbox: zynqmp: ipi mailbox driver
In reply to Luca CeresoliQuoted 62 lines · Luca Ceresoli
Hi Ibai, Michal,
I had half-written a review of this patch and patch 4. Unfortunately I didn't finish them before they got applied. I'll send them now anyway, they are mostly nitpicking but you might consider them for a future improvement. Sorry for the inconvenience.
Quoted 8 lines · Michal Simek
From: Ibai Erkiaga <[email protected]>
ZynqMP mailbox driver implementing IPI communication with PMU. This would allow U-Boot SPL to communicate with PMUFW to request privileged operations.
Signed-off-by Ibai Erkiaga <[email protected]>Signed-off-by Michal Simek <[email protected]>...
Quoted 29 lines
drivers/mailbox/zynqmp-ipi.c new file +29
-0+static int zynqmp_ipi_probe (struct udevice *dev) +{ +struct zynqmp_ipi *zynqmp =dev_get_priv (dev); +struct resource res; +ofnode node; + +debug ("%s(dev=%p)\n" , __func__, dev); + +/* Get subnode where the regs are defined */ +/* Note IPI mailbox node needs to be the first one in DT */ + node =ofnode_first_subnode (dev_ofnode (dev)); + +if (ofnode_read_resource_byname (node,"local_request_region" , &res)) { +dev_err (dev,"No reg property for local_request_region\n" ); +return -EINVAL ; + }; + zynqmp->local_req_regs =devm_ioremap (dev, res.start, + (res.start - res.end)); + +if (ofnode_read_resource_byname (node,"local_response_region" , &res)) { +dev_err (dev,"No reg property for local_response_region\n" ); +return -EINVAL ; + }; + zynqmp->local_res_regs =devm_ioremap (dev, res.start, + (res.start - res.end)); + +if (ofnode_read_resource_byname (node,"remote_request_region" , &res)) { +dev_err (dev,"No reg property for remote_request_region\n" ); +return -EINVAL ;drivers/mailbox/zynqmp-ipi.c line 112
Quoted 10 lines
drivers/mailbox/zynqmp-ipi.c new file +10
-0+ }; + zynqmp->remote_req_regs =devm_ioremap (dev, res.start, + (res.start - res.end)); + +if (ofnode_read_resource_byname (node,"remote_response_region" , &res)) { +dev_err (dev,"No reg property for remote_response_region\n" ); +return -EINVAL ; + }; + zynqmp->remote_res_regs =devm_ioremap (dev, res.start, + (res.start - res.end));
remote_req_regsandremote_res_regsare not used, why adding them in DT?
Quoted 4 lines
Should there be a good reason to keep them, I think the above code could be reorganized to avoid code duplication (assuming binary size of a bootloader still matters nowadays).
Binding is taken from Linux kernel and these are required property there. I think it is used by Linux driver. It means checking required property is good thing to do.
Regarding if make sense to map them if they are not used. I think we can remove this code.
If make sense reorganized the code to make it smaller. Sure of course. Patches welcome.
Thanks,
Michal
PATCH v2 4/13 firmware: zynqmp: Add zynqmp-power support
In reply to Luca CeresoliQuoted 20 lines · Luca Ceresoli
Hi,
Quoted 17 lines · Michal Simek
From: Ibai Erkiaga <[email protected]>
zynqmp-power driver for ZynqMP to handle the communication with the PMU firmware. Firmware driver just probes subnodes and power driver handles communication with PMU using the IPI mailbox driver.
Signed-off-by Ibai Erkiaga <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Check error separately - Reported by Lucadrivers/firmware/Kconfig | 2 ++ drivers/firmware/firmware-zynqmp.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
Quoted 14 lines
drivers/firmware/Kconfig config TI_SCI_PROTOCOL · line 34
Quoted 10 lines
drivers/firmware/Kconfig +2
-0@@ -30,6 +30,8 @@ config TI_SCI_PROTOCOL config ZYNQMP_FIRMWARE bool "ZynqMP Firmware interface" select FIRMWARE + select ZYNQMP_IPI + select DM_MAILBOXNitpick:
ZYNQMP_IPIdepends onDM_MAILBOX, so I'd list them in opposite order. Just for clarity.
This has changed already.
Quoted 15 lines
Quoted 15 lines
drivers/firmware/Kconfig +0
-0help Firmware interface driver is used by different drivers to communicate with the firmware fordrivers/firmware/firmware-zynqmp.c +5
-0@@ -1,6 +1,50 @@// SPDX-License-Identifier: GPL-2.0 +/* +* Xilinx Zynq MPSoC Firmware driver +* +* Copyright (C) 2018-2019 Xilinx, Inc. +*/
Quoted 15 lines
drivers/firmware/firmware-zynqmp.c line 20
Quoted 13 lines
drivers/firmware/firmware-zynqmp.c +12
-0+#include <common.h> #include <dm.h> +#include <mailbox.h> +#include <asm/arch/sys_proto.h> + +struct zynqmp_power { +struct mbox_chan tx_chan; +struct mbox_chan rx_chan; +} zynqmp_power; + +static int zynqmp_power_probe (struct udevice *dev) +{ +int ret =0 ;No need to initialize.
Will fix.
Quoted 9 lines
drivers/firmware/firmware-zynqmp.c line 26
Quoted 7 lines
drivers/firmware/firmware-zynqmp.c +6
-0+ +debug ("%s, (dev=%p)\n" , __func__, dev); + + ret =mbox_get_by_name (dev,"tx" , &zynqmp_power.tx_chan); +if (ret) { +debug ("%s, cannot tx mailbox\n" , __func__);"cannot tx" -> "cannot find tx"?
ditto.
Quoted 9 lines
drivers/firmware/firmware-zynqmp.c line 32
Quoted 7 lines
drivers/firmware/firmware-zynqmp.c +6
-0+return ret; + } + + ret =mbox_get_by_name (dev,"rx" , &zynqmp_power.rx_chan); +if (ret) +debug ("%s, cannot rx mailbox\n" , __func__);Ditto.
ditto.
Quoted 5 lines
drivers/firmware/firmware-zynqmp.c line 34
Quoted 3 lines
drivers/firmware/firmware-zynqmp.c +2
-0+ +return ret;return 0;
return ret was correct here because if (ret) doesn't return error value and that code just print message in case of error.
Thanks,
Michal