From 1323d08bdfdd76cf368de7b40ed876e336cdcb9a Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 30 Sep 2022 14:04:30 +0200 Subject: [PATCH 01/31] dm: fpga: Introduce new uclass For future DM based FPGA drivers and for now to have a meaningful logging class for old FPGA drivers. Suggested-by: Michal Simek Suggested-by: Simon Glass Signed-off-by: Alexander Dahl Reviewed-by: Simon Glass Link: https://lore.kernel.org/r/20220930120430.42307-2-post@lespocky.de Signed-off-by: Michal Simek --- MAINTAINERS | 1 + arch/sandbox/dts/test.dts | 4 ++++ drivers/fpga/Kconfig | 19 +++++++++++++++++++ drivers/fpga/Makefile | 3 +++ drivers/fpga/fpga-uclass.c | 11 +++++++++++ drivers/fpga/sandbox.c | 17 +++++++++++++++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/fpga.c | 20 ++++++++++++++++++++ 9 files changed, 77 insertions(+) create mode 100644 drivers/fpga/fpga-uclass.c create mode 100644 drivers/fpga/sandbox.c create mode 100644 test/dm/fpga.c diff --git a/MAINTAINERS b/MAINTAINERS index b4b185aacd..c4ed454e06 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -945,6 +945,7 @@ T: git https://source.denx.de/u-boot/custodians/u-boot-microblaze.git F: drivers/fpga/ F: cmd/fpga.c F: include/fpga.h +F: test/dm/fpga.c FLATTENED DEVICE TREE M: Simon Glass diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 4ee471238e..a7b49f315b 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -652,6 +652,10 @@ }; }; + fpga { + compatible = "sandbox,fpga"; + }; + pinctrl-gpio { compatible = "sandbox,pinctrl-gpio"; diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index e07a9cf80e..e2fd16e6d2 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -118,4 +118,23 @@ config SPL_FPGA_LOAD_SECURE Enables the fpga loads() functions that are used to load secure (authenticated or encrypted or both) bitstreams on to FPGA. +config DM_FPGA + bool "Enable Driver Model for FPGA drivers" + depends on DM + select FPGA + help + Enable driver model for Field-Programmable Gate Array (FPGA) devices. + The devices cover a wide range of applications and are configured at + runtime by loading a bitstream into the FPGA device. + Loading a bitstream from any kind of storage is the main task of the + FPGA drivers. + For now this uclass has no methods yet. + +config SANDBOX_FPGA + bool "Enable sandbox FPGA driver" + depends on SANDBOX && DM_FPGA + help + This is a driver model based FPGA driver for sandbox. + Currently it is a stub only, as there are no usable uclass methods yet. + endmenu diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 83243fb107..610c168fc3 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -4,6 +4,9 @@ # Wolfgang Denk, DENX Software Engineering, wd@denx.de. obj-y += fpga.o +obj-$(CONFIG_DM_FPGA) += fpga-uclass.o +obj-$(CONFIG_SANDBOX_FPGA) += sandbox.o + obj-$(CONFIG_FPGA_SPARTAN2) += spartan2.o obj-$(CONFIG_FPGA_SPARTAN3) += spartan3.o obj-$(CONFIG_FPGA_VERSALPL) += versalpl.o diff --git a/drivers/fpga/fpga-uclass.c b/drivers/fpga/fpga-uclass.c new file mode 100644 index 0000000000..4278ec28e5 --- /dev/null +++ b/drivers/fpga/fpga-uclass.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Alexander Dahl + */ + +#include + +UCLASS_DRIVER(fpga) = { + .name = "fpga", + .id = UCLASS_FPGA, +}; diff --git a/drivers/fpga/sandbox.c b/drivers/fpga/sandbox.c new file mode 100644 index 0000000000..f17a822179 --- /dev/null +++ b/drivers/fpga/sandbox.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Alexander Dahl + */ + +#include + +static const struct udevice_id sandbox_fpga_match[] = { + { .compatible = "sandbox,fpga" }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(sandbox_fpga) = { + .name = "sandbox_fpga", + .id = UCLASS_FPGA, + .of_match = sandbox_fpga_match, +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index a432e43871..c2b15881ba 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -56,6 +56,7 @@ enum uclass_id { UCLASS_ETH, /* Ethernet device */ UCLASS_ETH_PHY, /* Ethernet PHY device */ UCLASS_FIRMWARE, /* Firmware */ + UCLASS_FPGA, /* FPGA device */ UCLASS_FUZZING_ENGINE, /* Fuzzing engine */ UCLASS_FS_FIRMWARE_LOADER, /* Generic loader */ UCLASS_GPIO, /* Bank of general-purpose I/O pins */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 5178daa7cf..499e76980d 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -47,6 +47,7 @@ ifneq ($(CONFIG_EFI_PARTITION),) obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o endif obj-$(CONFIG_FIRMWARE) += firmware.o +obj-$(CONFIG_DM_FPGA) += fpga.o obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_SOUND) += i2s.o diff --git a/test/dm/fpga.c b/test/dm/fpga.c new file mode 100644 index 0000000000..8bb3535853 --- /dev/null +++ b/test/dm/fpga.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Alexander Dahl + */ + +#include +#include +#include +#include + +static int dm_test_fpga(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_FPGA, &dev)); + + return 0; +} + +DM_TEST(dm_test_fpga, UT_TESTF_SCAN_FDT); From 2fe55d1827ea215d6fed7f9485b3899c48fb163a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 27 Sep 2022 09:55:46 +0200 Subject: [PATCH 02/31] xilinx: zynq: Enable early eeprom decoding Xilinx Zynq evaluation boards have factory program content in eeprom. Enable reading and decoding eeprom content to get information about board name, revision and especially getting ethernet mac address. Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/db334bd3c0a377074a43b7ae479fade98efb545f.1664265344.git.michal.simek@amd.com --- board/xilinx/zynq/board.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index c96433be69..17ee541bd8 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -37,6 +37,9 @@ int board_init(void) if (IS_ENABLED(CONFIG_SPL_BUILD)) printf("Silicon version:\t%d\n", zynq_get_silicon_version()); + if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) + xilinx_read_eeprom(); + return 0; } From ce92321559dbc66434c9d07ec338a72c4dc159c3 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 27 Sep 2022 09:55:12 +0200 Subject: [PATCH 03/31] ARM: zynq: Point via nvmem0 alias to eeprom on zc702/zc706 EEPROM stores identification information about board like a board name, revision, serial number and ethernet MAC address. U-Boot is capable to read nvmemX aliases and read/display provided information when nvmem alias link is described. Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/c63bba87d0400b6bd0f5651fac21d525f12288f5.1664265311.git.michal.simek@amd.com --- arch/arm/dts/zynq-zc702.dts | 3 ++- arch/arm/dts/zynq-zc706.dts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/zynq-zc702.dts b/arch/arm/dts/zynq-zc702.dts index 1bd4f8c9f6..99ee87bb24 100644 --- a/arch/arm/dts/zynq-zc702.dts +++ b/arch/arm/dts/zynq-zc702.dts @@ -17,6 +17,7 @@ spi0 = &qspi; mmc0 = &sdhci0; usb0 = &usb0; + nvmem0 = &eeprom; }; memory@0 { @@ -142,7 +143,7 @@ #address-cells = <1>; #size-cells = <0>; reg = <2>; - eeprom@54 { + eeprom: eeprom@54 { compatible = "atmel,24c08"; reg = <0x54>; }; diff --git a/arch/arm/dts/zynq-zc706.dts b/arch/arm/dts/zynq-zc706.dts index cb919e4053..f0ad68d94f 100644 --- a/arch/arm/dts/zynq-zc706.dts +++ b/arch/arm/dts/zynq-zc706.dts @@ -16,6 +16,7 @@ serial0 = &uart1; spi0 = &qspi; mmc0 = &sdhci0; + nvmem0 = &eeprom; }; memory@0 { @@ -101,7 +102,7 @@ #address-cells = <1>; #size-cells = <0>; reg = <2>; - eeprom@54 { + eeprom: eeprom@54 { compatible = "atmel,24c08"; reg = <0x54>; }; From 52a504c5c004be30b62f19e4334e5ea4ecd61a0d Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 27 Sep 2022 13:50:26 +0200 Subject: [PATCH 04/31] ARM: zynq: Define rtc alias on zc702/zc706 Define rtc alias on zc702/zc706 boards. Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/47df614929d49af9f562c103defb92900de9d3e1.1664279424.git.michal.simek@amd.com --- arch/arm/dts/zynq-zc702.dts | 3 ++- arch/arm/dts/zynq-zc706.dts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/zynq-zc702.dts b/arch/arm/dts/zynq-zc702.dts index 99ee87bb24..f04129fd04 100644 --- a/arch/arm/dts/zynq-zc702.dts +++ b/arch/arm/dts/zynq-zc702.dts @@ -18,6 +18,7 @@ mmc0 = &sdhci0; usb0 = &usb0; nvmem0 = &eeprom; + rtc0 = &rtc; }; memory@0 { @@ -165,7 +166,7 @@ #address-cells = <1>; #size-cells = <0>; reg = <4>; - rtc@51 { + rtc: rtc@51 { compatible = "nxp,pcf8563"; reg = <0x51>; }; diff --git a/arch/arm/dts/zynq-zc706.dts b/arch/arm/dts/zynq-zc706.dts index f0ad68d94f..dd3ae83c82 100644 --- a/arch/arm/dts/zynq-zc706.dts +++ b/arch/arm/dts/zynq-zc706.dts @@ -17,6 +17,7 @@ spi0 = &qspi; mmc0 = &sdhci0; nvmem0 = &eeprom; + rtc0 = &rtc; }; memory@0 { @@ -124,7 +125,7 @@ #address-cells = <1>; #size-cells = <0>; reg = <4>; - rtc@51 { + rtc: rtc@51 { compatible = "nxp,pcf8563"; reg = <0x51>; }; From ef2896a4d218fe54b261ba63ea0ec3682b2eea29 Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Fri, 30 Sep 2022 09:37:26 +0200 Subject: [PATCH 05/31] firmware: zynqmp: Change loadable config object from APU_0 to OCM_BANK_0 To check dynamic loading of config object, currently APU_0 is used. Suggestion from pmwfw team is to load OCM_BANK_0 and check for XST_PM_NO_ACCESS error only to skip future config objects. Other errors should not be considered for skipping. Change from NODE_APU_0 to NODE_OCM_BANK_0 and check for XST_PM_NO_ACCESS to skip future config objects. Add ": " to printf statement when there is no permission to load config object, to align with PMUFW version print. Update kernel doc for return value for zynqmp_pmufw_load_config_object(). Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/2784018844ba4afced0e3edff76bdbfe532f517d.1664523444.git.michal.simek@amd.com --- drivers/firmware/firmware-zynqmp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index d8e0d79c57..dc8e3ad2b9 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -82,7 +82,7 @@ int zynqmp_pmufw_node(u32 id) ret = zynqmp_pmufw_load_config_object(xpm_configobject, sizeof(xpm_configobject)); - if (ret && id == NODE_APU_0) + if (ret == XST_PM_NO_ACCESS && id == NODE_OCM_BANK_0) skip_config = true; return 0; @@ -235,6 +235,8 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id) * * @cfg_obj: Pointer to the configuration object * @size: Size of @cfg_obj in bytes + * Return: 0 on success otherwise negative errno. If the config object + * is not loadable returns positive errno XST_PM_NO_ACCESS(2002) */ int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size) { @@ -249,7 +251,10 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size) err = xilinx_pm_request(PM_SET_CONFIGURATION, (u32)(u64)cfg_obj, 0, 0, 0, ret_payload); if (err == XST_PM_NO_ACCESS) { - printf("PMUFW no permission to change config object\n"); + if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0) { + printf("PMUFW: No permission to change config object\n"); + return err; + } return -EACCES; } @@ -294,7 +299,7 @@ static int zynqmp_power_probe(struct udevice *dev) ret & ZYNQMP_PM_VERSION_MINOR_MASK); if (IS_ENABLED(CONFIG_ARCH_ZYNQMP)) - zynqmp_pmufw_node(NODE_APU_0); + zynqmp_pmufw_node(NODE_OCM_BANK_0); return 0; }; From 078d8eb5bbb770bcf55c0f70b3da4df2c1362659 Mon Sep 17 00:00:00 2001 From: Samuel Obuch Date: Tue, 27 Sep 2022 13:21:01 +0200 Subject: [PATCH 06/31] net: emaclite: enable for more architectures Function ioremap_nocache seems to be defined only for MIPS and Microblaze architectures. Therefore, the function call in the emaclite driver causes this driver to be unusable with other architectures, for example RISC-V. Use ioremap function instead of ioremap_nocache, and include linux/io.h instead of asm/io.h, so that ioremap function is automatically created, if not defined by the architecture. We can switch to the ioremap function, as Microblaze's ioremap_nocache is just empty and in MIPS implementations of ioremap_nocache and ioremap are the same. Signed-off-by: Samuel Obuch Link: https://lore.kernel.org/r/20220927112103.155689-1-samuel.obuch@codasip.com Signed-off-by: Michal Simek --- drivers/net/xilinx_emaclite.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 6c9f1f7c27..29e8271c63 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -14,14 +14,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include -#include #include DECLARE_GLOBAL_DATA_PTR; @@ -615,8 +614,8 @@ static int emaclite_of_to_plat(struct udevice *dev) int offset = 0; pdata->iobase = dev_read_addr(dev); - emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase, - 0x10000); + emaclite->regs = (struct emaclite_regs *)ioremap(pdata->iobase, + 0x10000); emaclite->phyaddr = -1; From 3d1700296c7149f93e6fca6c733afc1c20a74e39 Mon Sep 17 00:00:00 2001 From: Samuel Obuch Date: Tue, 27 Sep 2022 13:21:02 +0200 Subject: [PATCH 07/31] net: emaclite: fix xemaclite_alignedread/write functions Use __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out. Signed-off-by: Samuel Obuch Reviewed-by: Ramon Fried Link: https://lore.kernel.org/r/20220927112103.155689-2-samuel.obuch@codasip.com Signed-off-by: Michal Simek --- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 29e8271c63..a4851ad36f 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -112,12 +112,12 @@ static void xemaclite_alignedread(u32 *srcptr, void *destptr, u32 bytecount) /* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr; while (bytecount > 3) { - *to32ptr++ = *from32ptr++; + *to32ptr++ = __raw_readl(from32ptr++); bytecount -= 4; } to8ptr = (u8 *) to32ptr; - alignbuffer = *from32ptr++; + alignbuffer = __raw_readl(from32ptr++); from8ptr = (u8 *) &alignbuffer; for (i = 0; i < bytecount; i++) @@ -135,8 +135,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) from32ptr = (u32 *) srcptr; while (bytecount > 3) { - - *to32ptr++ = *from32ptr++; + __raw_writel(*from32ptr++, to32ptr++); bytecount -= 4; } @@ -147,7 +146,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) for (i = 0; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; + __raw_writel(alignbuffer, to32ptr++); } static int wait_for_bit(const char *func, u32 *reg, const u32 mask, From f4cf004d273523494bb276c3317c0c8f17a48c59 Mon Sep 17 00:00:00 2001 From: Samuel Obuch Date: Tue, 27 Sep 2022 13:21:03 +0200 Subject: [PATCH 08/31] net: emaclite: fix handling for IP packets with specific lengths The maximum length is capped similarly to the emaclite_send function. Avoid integer underflow for values of ip->ip_len < 30, the minimum length of an IP packet is 21 bytes. Signed-off-by: Samuel Obuch Reviewed-by: Ramon Fried Link: https://lore.kernel.org/r/20220927112103.155689-3-samuel.obuch@codasip.com Signed-off-by: Michal Simek --- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index a4851ad36f..16ba915fba 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -517,6 +517,8 @@ try_again: length = ntohs(ip->ip_len); length += ETHER_HDR_SIZE + ETH_FCS_LEN; debug("IP Packet %x\n", length); + if (length > PKTSIZE) + length = PKTSIZE; break; default: debug("Other Packet\n"); @@ -525,7 +527,7 @@ try_again: } /* Read the rest of the packet which is longer then first read */ - if (length != first_read) + if (length > first_read) xemaclite_alignedread(addr + first_read, etherrxbuff + first_read, length - first_read); From e1a193b95177fb5325c07fa85810f640a8ed8687 Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Mon, 26 Sep 2022 12:22:42 +0530 Subject: [PATCH 09/31] xilinx: common: Fix static checker warnings Avoid signed extension for uuid and byte. Eliminate the below smatch warnings: board/xilinx/common/board.c:128 xilinx_eeprom_legacy_cleanup() warn: impossible condition '(byte == 255) => ((-128)-127 == 255)' board/xilinx/common/board.c:466 board_late_init_xilinx() warn: argument 3 to %02x specifier has type 'char' board/xilinx/common/board.c:466 board_late_init_xilinx() warn: argument 4 to %02x specifier has type 'char' Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20220926065242.4355-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- board/xilinx/common/board.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 391ce4dbd7..bbfe84b8d0 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -121,7 +121,7 @@ struct xilinx_legacy_format { static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size) { int i; - char byte; + unsigned char byte; for (i = 0; i < size; i++) { byte = eeprom[i]; @@ -460,8 +460,8 @@ int board_late_init_xilinx(void) desc->serial); if (desc->uuid[0]) { - char uuid[UUID_STR_LEN + 1]; - char *t = desc->uuid; + unsigned char uuid[UUID_STR_LEN + 1]; + unsigned char *t = desc->uuid; memset(uuid, 0, UUID_STR_LEN + 1); From 9a082d2548de523c37f035cee7e0c280bad62bee Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Thu, 29 Sep 2022 10:26:05 +0530 Subject: [PATCH 10/31] net: Fix static checker warnings Here are the smatch warning messages: drivers/net/xilinx_axi_emac.c:324 axiemac_phy_init() error: 'phydev' dereferencing possible ERR_PTR() drivers/net/zynq_gem.c:340 zynq_phy_init() error: 'priv->phydev' dereferencing possible ERR_PTR() Fix by adding error checking before dereferencing the pointer. Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20220929045605.23964-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- drivers/net/xilinx_axi_emac.c | 5 +++++ drivers/net/zynq_gem.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index d48e342ea0..5f5bc650be 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -317,6 +318,10 @@ static int axiemac_phy_init(struct udevice *dev) /* Interface - look at tsec */ phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface); + if (IS_ERR_OR_NULL(phydev)) { + dev_err(dev, "phy_connect() failed\n"); + return -ENODEV; + } phydev->supported &= supported; phydev->advertising = phydev->supported; diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 61a6c83e33..3f4357ec80 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -328,7 +328,7 @@ static int zynq_phy_init(struct udevice *dev) priv->phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface); - if (!priv->phydev) + if (IS_ERR_OR_NULL(priv->phydev)) return -ENODEV; if (priv->max_speed) { From cbdee4d5e88c8509a3491f8784be42841466cb6c Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Fri, 30 Sep 2022 03:25:46 -0600 Subject: [PATCH 11/31] mmc: zynq_sdhci: Change node_id prototype to u32 In Versal platform power domain node_id is bigger than u8, hence change prototype to u32 to accommodate. Change u8 to u32 in the function prototypes that use node_id and remove casting to u32 from xilinx_pm_request() call parameters. Signed-off-by: Ashok Reddy Soma Link: https://lore.kernel.org/r/20220930092548.18453-2-ashok.reddy.soma@amd.com Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 8f4071c8c2..3a4194452c 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -111,7 +111,7 @@ static const u8 mode2timing[] = { [MMC_HS_200] = MMC_TIMING_MMC_HS200, }; -static inline int arasan_zynqmp_set_in_tapdelay(u8 node_id, u32 itap_delay) +static inline int arasan_zynqmp_set_in_tapdelay(u32 node_id, u32 itap_delay) { int ret; @@ -155,7 +155,7 @@ static inline int arasan_zynqmp_set_in_tapdelay(u8 node_id, u32 itap_delay) if (ret) return ret; } else { - return xilinx_pm_request(PM_IOCTL, (u32)node_id, + return xilinx_pm_request(PM_IOCTL, node_id, IOCTL_SET_SD_TAPDELAY, PM_TAPDELAY_INPUT, itap_delay, NULL); } @@ -163,7 +163,7 @@ static inline int arasan_zynqmp_set_in_tapdelay(u8 node_id, u32 itap_delay) return 0; } -static inline int arasan_zynqmp_set_out_tapdelay(u8 node_id, u32 otap_delay) +static inline int arasan_zynqmp_set_out_tapdelay(u32 node_id, u32 otap_delay) { if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) { if (node_id == NODE_SD_0) @@ -174,13 +174,13 @@ static inline int arasan_zynqmp_set_out_tapdelay(u8 node_id, u32 otap_delay) return zynqmp_mmio_write(SD_OTAP_DLY, SD1_OTAPDLYSEL_MASK, (otap_delay << 16)); } else { - return xilinx_pm_request(PM_IOCTL, (u32)node_id, + return xilinx_pm_request(PM_IOCTL, node_id, IOCTL_SET_SD_TAPDELAY, PM_TAPDELAY_OUTPUT, otap_delay, NULL); } } -static inline int zynqmp_dll_reset(u8 node_id, u32 type) +static inline int zynqmp_dll_reset(u32 node_id, u32 type) { if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) { if (node_id == NODE_SD_0) @@ -192,12 +192,12 @@ static inline int zynqmp_dll_reset(u8 node_id, u32 type) type == PM_DLL_RESET_ASSERT ? SD1_DLL_RST : 0); } else { - return xilinx_pm_request(PM_IOCTL, (u32)node_id, + return xilinx_pm_request(PM_IOCTL, node_id, IOCTL_SD_DLL_RESET, type, 0, NULL); } } -static int arasan_zynqmp_dll_reset(struct sdhci_host *host, u8 node_id) +static int arasan_zynqmp_dll_reset(struct sdhci_host *host, u32 node_id) { struct mmc *mmc = (struct mmc *)host->mmc; struct udevice *dev = mmc->dev; From aba0e6510f8fb4166179cc6d486abd6bb6b7b7e8 Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Fri, 30 Sep 2022 03:25:47 -0600 Subject: [PATCH 12/31] mmc: zynq_sdhci: Read power-domains id from DT and use Firmware calls need node_id which is basically "power-domains" id. At present static values are used based on the "device_id" property of dt. Instead of this, read "power-domains" id from dt and use it. Add a element called node_id in priv structure and read it from dt. Replace static node_id with this priv->node_id across the driver. Since "device_id" is not used anywhere else simply remove it. Signed-off-by: Ashok Reddy Soma Link: https://lore.kernel.org/r/20220930092548.18453-3-ashok.reddy.soma@amd.com Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 3a4194452c..7dcf6ad842 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -61,7 +61,7 @@ struct arasan_sdhci_plat { struct arasan_sdhci_priv { struct sdhci_host *host; struct arasan_sdhci_clk_data clk_data; - u8 deviceid; + u32 node_id; u8 bank; u8 no_1p8; struct reset_ctl_bulk resets; @@ -250,7 +250,6 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) struct sdhci_host *host; struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev); char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT; - u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; dev_dbg(mmc->dev, "%s\n", __func__); @@ -262,7 +261,7 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) mdelay(1); - arasan_zynqmp_dll_reset(host, node_id); + arasan_zynqmp_dll_reset(host, priv->node_id); sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_INT_ENABLE); sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_SIGNAL_ENABLE); @@ -308,7 +307,7 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) } udelay(1); - arasan_zynqmp_dll_reset(host, node_id); + arasan_zynqmp_dll_reset(host, priv->node_id); /* Enable only interrupts served by the SD controller */ sdhci_writel(host, SDHCI_INT_DATA_MASK | SDHCI_INT_CMD_MASK, @@ -334,7 +333,6 @@ static int sdhci_zynqmp_sdcardclk_set_phase(struct sdhci_host *host, struct mmc *mmc = (struct mmc *)host->mmc; struct udevice *dev = mmc->dev; struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev); - u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; u8 tap_delay, tap_max = 0; int timing = mode2timing[mmc->selected_mode]; int ret; @@ -374,14 +372,14 @@ static int sdhci_zynqmp_sdcardclk_set_phase(struct sdhci_host *host, tap_delay &= SDHCI_ARASAN_OTAPDLY_SEL_MASK; /* Set the Clock Phase */ - ret = arasan_zynqmp_set_out_tapdelay(node_id, tap_delay); + ret = arasan_zynqmp_set_out_tapdelay(priv->node_id, tap_delay); if (ret) { dev_err(dev, "Error setting output Tap Delay\n"); return ret; } /* Release DLL Reset */ - ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_RELEASE); + ret = zynqmp_dll_reset(priv->node_id, PM_DLL_RESET_RELEASE); if (ret) { dev_err(dev, "dll_reset release failed with err: %d\n", ret); return ret; @@ -405,7 +403,6 @@ static int sdhci_zynqmp_sampleclk_set_phase(struct sdhci_host *host, struct mmc *mmc = (struct mmc *)host->mmc; struct udevice *dev = mmc->dev; struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev); - u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; u8 tap_delay, tap_max = 0; int timing = mode2timing[mmc->selected_mode]; int ret; @@ -419,7 +416,7 @@ static int sdhci_zynqmp_sampleclk_set_phase(struct sdhci_host *host, return 0; /* Assert DLL Reset */ - ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_ASSERT); + ret = zynqmp_dll_reset(priv->node_id, PM_DLL_RESET_ASSERT); if (ret) { dev_err(dev, "dll_reset assert failed with err: %d\n", ret); return ret; @@ -451,7 +448,7 @@ static int sdhci_zynqmp_sampleclk_set_phase(struct sdhci_host *host, /* Limit input tap_delay value to 8 bits */ tap_delay &= SDHCI_ARASAN_ITAPDLY_SEL_MASK; - ret = arasan_zynqmp_set_in_tapdelay(node_id, tap_delay); + ret = arasan_zynqmp_set_in_tapdelay(priv->node_id, tap_delay); if (ret) { dev_err(dev, "Error setting Input Tap Delay\n"); return ret; @@ -717,14 +714,14 @@ static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, struct udevice *dev) { int ret; - u32 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; struct clk clk; unsigned long clock, mhz; - ret = xilinx_pm_request(PM_REQUEST_NODE, node_id, ZYNQMP_PM_CAPABILITY_ACCESS, - ZYNQMP_PM_MAX_QOS, ZYNQMP_PM_REQUEST_ACK_NO, NULL); + ret = xilinx_pm_request(PM_REQUEST_NODE, priv->node_id, + ZYNQMP_PM_CAPABILITY_ACCESS, ZYNQMP_PM_MAX_QOS, + ZYNQMP_PM_REQUEST_ACK_NO, NULL); if (ret) { - dev_err(dev, "Request node failed for %d\n", node_id); + dev_err(dev, "Request node failed for %d\n", priv->node_id); return ret; } @@ -743,13 +740,13 @@ static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, return ret; } - ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_FIXED, 0); + ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_FIXED, 0); if (ret) { dev_err(dev, "SD_CONFIG_FIXED failed\n"); return ret; } - ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_EMMC_SEL, + ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_EMMC_SEL, dev_read_bool(dev, "non-removable")); if (ret) { dev_err(dev, "SD_CONFIG_EMMC_SEL failed\n"); @@ -779,13 +776,13 @@ static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, else mhz = 25; - ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_BASECLK, mhz); + ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_BASECLK, mhz); if (ret) { dev_err(dev, "SD_CONFIG_BASECLK failed\n"); return ret; } - ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_8BIT, + ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_8BIT, (dev_read_u32_default(dev, "bus-width", 1) == 8)); if (ret) { dev_err(dev, "SD_CONFIG_8BIT failed\n"); @@ -900,6 +897,7 @@ static int arasan_sdhci_probe(struct udevice *dev) static int arasan_sdhci_of_to_plat(struct udevice *dev) { struct arasan_sdhci_priv *priv = dev_get_priv(dev); + u32 pm_info[2]; priv->host = calloc(1, sizeof(struct sdhci_host)); if (!priv->host) @@ -916,10 +914,13 @@ static int arasan_sdhci_of_to_plat(struct udevice *dev) if (IS_ERR(priv->host->ioaddr)) return PTR_ERR(priv->host->ioaddr); - priv->deviceid = dev_read_u32_default(dev, "xlnx,device_id", -1); priv->bank = dev_read_u32_default(dev, "xlnx,mio-bank", 0); priv->no_1p8 = dev_read_bool(dev, "no-1-8-v"); + priv->node_id = 0; + if (!dev_read_u32_array(dev, "power-domains", pm_info, ARRAY_SIZE(pm_info))) + priv->node_id = pm_info[1]; + return 0; } From 5ccf97aeb003c0044ed8ae013cbb83754c2c3a15 Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Fri, 30 Sep 2022 03:25:48 -0600 Subject: [PATCH 13/31] arm64: dts: Remove unused property device_id Device tree property "xlnx,device_id" is not used anymore, remove it. Signed-off-by: Ashok Reddy Soma Link: https://lore.kernel.org/r/20220930092548.18453-4-ashok.reddy.soma@amd.com Signed-off-by: Michal Simek --- arch/arm/dts/versal-mini-emmc0.dts | 1 - arch/arm/dts/versal-mini-emmc1.dts | 1 - arch/arm/dts/zynqmp-mini-emmc0.dts | 1 - arch/arm/dts/zynqmp-mini-emmc1.dts | 1 - arch/arm/dts/zynqmp.dtsi | 2 -- 5 files changed, 6 deletions(-) diff --git a/arch/arm/dts/versal-mini-emmc0.dts b/arch/arm/dts/versal-mini-emmc0.dts index 7c81a82fb9..d098c2d01b 100644 --- a/arch/arm/dts/versal-mini-emmc0.dts +++ b/arch/arm/dts/versal-mini-emmc0.dts @@ -44,7 +44,6 @@ reg = <0x0 0xf1040000 0x0 0x10000>; clock-names = "clk_xin", "clk_ahb"; clocks = <&clk200 &clk200>; - xlnx,device_id = <0>; no-1-8-v; xlnx,mio-bank = <0>; }; diff --git a/arch/arm/dts/versal-mini-emmc1.dts b/arch/arm/dts/versal-mini-emmc1.dts index bf7569d4cc..9d4ac28359 100644 --- a/arch/arm/dts/versal-mini-emmc1.dts +++ b/arch/arm/dts/versal-mini-emmc1.dts @@ -44,7 +44,6 @@ reg = <0x0 0xf1050000 0x0 0x10000>; clock-names = "clk_xin", "clk_ahb"; clocks = <&clk200 &clk200>; - xlnx,device_id = <1>; no-1-8-v; xlnx,mio-bank = <0>; }; diff --git a/arch/arm/dts/zynqmp-mini-emmc0.dts b/arch/arm/dts/zynqmp-mini-emmc0.dts index 8467dd8e1c..1cc4ade5e8 100644 --- a/arch/arm/dts/zynqmp-mini-emmc0.dts +++ b/arch/arm/dts/zynqmp-mini-emmc0.dts @@ -56,7 +56,6 @@ reg = <0x0 0xff160000 0x0 0x1000>; clock-names = "clk_xin", "clk_ahb"; clocks = <&clk_xin &clk_xin>; - xlnx,device_id = <0>; }; }; }; diff --git a/arch/arm/dts/zynqmp-mini-emmc1.dts b/arch/arm/dts/zynqmp-mini-emmc1.dts index 2afcc7751b..96b5dc2932 100644 --- a/arch/arm/dts/zynqmp-mini-emmc1.dts +++ b/arch/arm/dts/zynqmp-mini-emmc1.dts @@ -56,7 +56,6 @@ reg = <0x0 0xff170000 0x0 0x1000>; clock-names = "clk_xin", "clk_ahb"; clocks = <&clk_xin &clk_xin>; - xlnx,device_id = <1>; }; }; }; diff --git a/arch/arm/dts/zynqmp.dtsi b/arch/arm/dts/zynqmp.dtsi index f4184f79a5..b210bc4b87 100644 --- a/arch/arm/dts/zynqmp.dtsi +++ b/arch/arm/dts/zynqmp.dtsi @@ -720,7 +720,6 @@ interrupts = <0 48 4>; reg = <0x0 0xff160000 0x0 0x1000>; clock-names = "clk_xin", "clk_ahb"; - xlnx,device_id = <0>; iommus = <&smmu 0x870>; #clock-cells = <1>; clock-output-names = "clk_out_sd0", "clk_in_sd0"; @@ -736,7 +735,6 @@ interrupts = <0 49 4>; reg = <0x0 0xff170000 0x0 0x1000>; clock-names = "clk_xin", "clk_ahb"; - xlnx,device_id = <1>; iommus = <&smmu 0x871>; #clock-cells = <1>; clock-output-names = "clk_out_sd1", "clk_in_sd1"; From c9e28930e3d091b9ca51946abd7d395a34792ad8 Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Tue, 4 Oct 2022 11:04:54 +0530 Subject: [PATCH 14/31] arm64: zynqmp: Fix compiler warnings in mp.c make W=1 generates the following warning in cpu_disable, cpu_status and cpu_release functions. arch/arm/mach-zynqmp/mp.c:166:16: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits] 166 | if (nr >= ZYNQMP_CORE_APU0 && nr <= ZYNQMP_CORE_APU3) { | ^~ Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20221004053454.25470-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- arch/arm/mach-zynqmp/mp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-zynqmp/mp.c b/arch/arm/mach-zynqmp/mp.c index 4f1ed44afb..949456d530 100644 --- a/arch/arm/mach-zynqmp/mp.c +++ b/arch/arm/mach-zynqmp/mp.c @@ -163,7 +163,7 @@ static int check_r5_mode(void) int cpu_disable(u32 nr) { - if (nr >= ZYNQMP_CORE_APU0 && nr <= ZYNQMP_CORE_APU3) { + if (nr <= ZYNQMP_CORE_APU3) { u32 val = readl(&crfapb_base->rst_fpd_apu); val |= 1 << nr; writel(val, &crfapb_base->rst_fpd_apu); @@ -176,7 +176,7 @@ int cpu_disable(u32 nr) int cpu_status(u32 nr) { - if (nr >= ZYNQMP_CORE_APU0 && nr <= ZYNQMP_CORE_APU3) { + if (nr <= ZYNQMP_CORE_APU3) { u32 addr_low = readl(((u8 *)&apu_base->rvbar_addr0_l) + nr * 8); u32 addr_high = readl(((u8 *)&apu_base->rvbar_addr0_h) + nr * 8); @@ -252,7 +252,7 @@ void initialize_tcm(bool mode) int cpu_release(u32 nr, int argc, char *const argv[]) { - if (nr >= ZYNQMP_CORE_APU0 && nr <= ZYNQMP_CORE_APU3) { + if (nr <= ZYNQMP_CORE_APU3) { u64 boot_addr = simple_strtoull(argv[0], NULL, 16); /* HIGH */ writel((u32)(boot_addr >> 32), From b451330df228975be814aaaebc3bf4ad5cbf1e23 Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Tue, 4 Oct 2022 11:07:30 +0530 Subject: [PATCH 15/31] spi: zynqmp_qspi: Mark zynqmp_qspi_set_tapdelay() as static Fix the following sparse and compile time warning triggered with W=1: drivers/spi/zynqmp_gqspi.c:286:6: warning: no previous prototype for 'zynqmp_qspi_set_tapdelay' [-Wmissing-prototypes] Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20221004053730.25602-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- drivers/spi/zynqmp_gqspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index d3cc8554b8..49facc46d3 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -294,7 +294,7 @@ static void zynqmp_qspi_chipselect(struct zynqmp_qspi_priv *priv, int is_on) zynqmp_qspi_fill_gen_fifo(priv, gqspi_fifo_reg); } -void zynqmp_qspi_set_tapdelay(struct udevice *bus, u32 baudrateval) +static void zynqmp_qspi_set_tapdelay(struct udevice *bus, u32 baudrateval) { struct zynqmp_qspi_plat *plat = dev_get_plat(bus); struct zynqmp_qspi_priv *priv = dev_get_priv(bus); From faf6a286f1329e398083a85e59c26fccc943c47d Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Tue, 4 Oct 2022 11:20:53 +0530 Subject: [PATCH 16/31] xilinx: common: Add print_cpuinfo() declaration cpu-info.c defines print_cpuinfo(), but neglected to include its declaration, causing the following sparse and compile time warnings: board/xilinx/common/cpu-info.c:10:5: warning: no previous prototype for 'print_cpuinfo' [-Wmissing-prototypes] Include init.h, which includes the missing declaration. Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20221004055053.26047-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- board/xilinx/common/cpu-info.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/xilinx/common/cpu-info.c b/board/xilinx/common/cpu-info.c index 4a863d00de..4eccc7abbe 100644 --- a/board/xilinx/common/cpu-info.c +++ b/board/xilinx/common/cpu-info.c @@ -5,6 +5,7 @@ */ #include +#include #include int print_cpuinfo(void) From 024cfd0ab5aacc809d24991902705f58c73da06e Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Tue, 4 Oct 2022 11:22:01 +0530 Subject: [PATCH 17/31] soc: xilinx: zynqmp: Mark soc_xilinx_zynqmp_get_machine() as static Fix the following sparse and compile time warning triggered with W=1: drivers/soc/soc_xilinx_zynqmp.c:288:5: warning: no previous prototype for 'soc_xilinx_zynqmp_get_machine' [-Wmissing-prototypes] Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20221004055201.26146-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- drivers/soc/soc_xilinx_zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/soc_xilinx_zynqmp.c b/drivers/soc/soc_xilinx_zynqmp.c index c10fc7d444..a51bcdb478 100644 --- a/drivers/soc/soc_xilinx_zynqmp.c +++ b/drivers/soc/soc_xilinx_zynqmp.c @@ -285,7 +285,7 @@ static int soc_xilinx_zynqmp_get_family(struct udevice *dev, char *buf, int size return snprintf(buf, size, "%s", priv->family); } -int soc_xilinx_zynqmp_get_machine(struct udevice *dev, char *buf, int size) +static int soc_xilinx_zynqmp_get_machine(struct udevice *dev, char *buf, int size) { struct soc_xilinx_zynqmp_priv *priv = dev_get_priv(dev); const char *machine = priv->machine; From f60be62d771c9a9d0b57576c0ef5fb832d8d40ba Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Tue, 4 Oct 2022 11:22:54 +0530 Subject: [PATCH 18/31] xilinx: zynqmp: change the type of multiboot variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In function ‘set_dfu_alt_info’ a comparison of a u8 value against 0 is done. Since it is always false, change the signature of this function to use an `int` instead, which match the type used in caller: `multi_boot()`. Fix the following warning triggered with W=1: board/xilinx/zynqmp/zynqmp.c:651:23: warning: comparison is always false due to limited range of data type [-Wtype-limits] 651 | if (multiboot < 0) Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20221004055254.26246-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 62537760df..8188e76dd8 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -607,7 +607,7 @@ enum env_location env_get_location(enum env_operation op, int prio) void set_dfu_alt_info(char *interface, char *devstr) { - u8 multiboot; + int multiboot; int bootseq = 0; ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); From 872a9b81ee32336668f81d8221dfce41508584e4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 8 Oct 2022 11:13:17 +0200 Subject: [PATCH 19/31] xilinx: common: fix board_late_init_xilinx() Compiling with GCC-12 leads to an error: +board/xilinx/common/board.c:479:37: error: the comparison will always evaluate as 'true' for the address of 'mac_addr' will never be NULL [-Werror=address] + 479 | if (!desc->mac_addr[i]) + | ^ Remove the redundant check. Fixes: a03b594738f8 ("xilinx: board: Add support for additional card detection") Signed-off-by: Heinrich Schuchardt Link: https://lore.kernel.org/r/20221008091317.52838-1-heinrich.schuchardt@canonical.com Signed-off-by: Michal Simek --- board/xilinx/common/board.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index bbfe84b8d0..99fdbac639 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -476,9 +476,6 @@ int board_late_init_xilinx(void) continue; for (i = 0; i < EEPROM_HDR_NO_OF_MAC_ADDR; i++) { - if (!desc->mac_addr[i]) - break; - if (is_valid_ethaddr((const u8 *)desc->mac_addr[i])) ret |= eth_env_set_enetaddr_by_index("eth", macid++, desc->mac_addr[i]); From 0b33770b54a57cc5dcfc91a497dc5f044a0b2e92 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 5 Oct 2022 11:39:27 +0200 Subject: [PATCH 20/31] xilinx: zynqmp: Load pmufw configuration before checking access Before this patch you could see in the log: U-Boot SPL 2022.10-rc5 (Sep 29 2022 - 15:29:27 +0200) PMUFW: v1.1 Loading new PMUFW cfg obj (32 bytes) PMUFW: No permission to change config object Loading new PMUFW cfg obj (2032 bytes) where it is visible that permission is check before sending PMUFW configuration (big size). When this patch is applied it is visible that order is correct. U-Boot SPL 2022.10-rc5 (Sep 29 2022 - 15:47:08 +0200) Loading new PMUFW cfg obj (2032 bytes) PMUFW: v1.1 Loading new PMUFW cfg obj (32 bytes) Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/a0bf4f46d670023da4f848790eece6fff22090c2.1664962765.git.michal.simek@amd.com --- board/xilinx/zynqmp/zynqmp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 8188e76dd8..5fe0873fe2 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -145,6 +145,14 @@ int board_init(void) char name[SOC_MAX_STR_SIZE]; int ret; #endif + +#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) + zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, + zynqmp_pm_cfg_obj_size); +#endif + #if defined(CONFIG_ZYNQMP_FIRMWARE) struct udevice *dev; @@ -154,10 +162,6 @@ int board_init(void) #endif #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) - zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, - zynqmp_pm_cfg_obj_size); printf("Silicon version:\t%d\n", zynqmp_get_silicon_version()); /* the CSU disables the JTAG interface when secure boot is enabled */ From 673f18955ee2db5c20c7d8e38763b530a372f283 Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Fri, 7 Oct 2022 16:25:35 +0530 Subject: [PATCH 21/31] clk: versal: Mark versal_clock_setup() as static Fix the following sparse and compile time warning triggered with W=1: drivers/clk/clk_versal.c:605:5: warning: no previous prototype for 'versal_clock_setup' [-Wmissing-prototypes] 605 | int versal_clock_setup(void) Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20221007105535.31902-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- drivers/clk/clk_versal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk_versal.c b/drivers/clk/clk_versal.c index b2f62061ce..76fde00491 100644 --- a/drivers/clk/clk_versal.c +++ b/drivers/clk/clk_versal.c @@ -602,7 +602,7 @@ static void versal_get_clock_info(void) } } -int versal_clock_setup(void) +static int versal_clock_setup(void) { int ret; From 312c4b11306a57b10ccab1c772c01ee402eb5027 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:19:54 +0200 Subject: [PATCH 22/31] fpga: Add missing Kconfig symbols for old FPGA drivers Those drivers could not be built anymore without those options present. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-2-ada@thorsis.com --- drivers/fpga/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index e2fd16e6d2..813d6a836d 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -27,6 +27,12 @@ config FPGA_STRATIX_V help Say Y here to enable the Altera Stratix V FPGA specific driver. +config FPGA_ACEX1K + bool "Enable Altera ACEX 1K driver" + depends on FPGA_ALTERA + help + Say Y here to enable the Altera ACEX 1K FPGA specific driver. + config FPGA_CYCLON2 bool "Enable Altera FPGA driver for Cyclone II" depends on FPGA_ALTERA @@ -71,6 +77,12 @@ config FPGA_VERSALPL Versal. The bitstream will only be generated as PDI for Versal platform. +config FPGA_SPARTAN2 + bool "Enable Spartan2 FPGA driver" + depends on FPGA_XILINX + help + Enable Spartan2 FPGA driver. + config FPGA_SPARTAN3 bool "Enable Spartan3 FPGA driver" depends on FPGA_XILINX From cf4d6b519d4aab6620cdecbaa7e457c74b4eb976 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:19:55 +0200 Subject: [PATCH 23/31] fpga: spartan2: Fix printf arguments warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That extra comma messes up format arguments. Warning appears if built with FPGA_DEBUG defined: CC drivers/fpga/spartan2.o /mnt/data/adahl/src/u-boot/drivers/fpga/spartan2.c: In function ‘spartan2_sp_load’: /mnt/data/adahl/src/u-boot/drivers/fpga/spartan2.c:112:11: warning: too many arguments for format [-Wformat-extra-args] PRINTF ("%s: Function Table:\n" ^~~~~~~~~~~~~~~~~~~~~~~ /mnt/data/adahl/src/u-boot/drivers/fpga/spartan2.c:12:37: note: in definition of macro ‘PRINTF’ #define PRINTF(fmt,args...) printf (fmt ,##args) ^~~ CC drivers/fpga/spartan3.o /mnt/data/adahl/src/u-boot/drivers/fpga/spartan3.c: In function ‘spartan3_sp_load’: /mnt/data/adahl/src/u-boot/drivers/fpga/spartan3.c:117:11: warning: too many arguments for format [-Wformat-extra-args] PRINTF ("%s: Function Table:\n" ^~~~~~~~~~~~~~~~~~~~~~~ /mnt/data/adahl/src/u-boot/drivers/fpga/spartan3.c:17:37: note: in definition of macro ‘PRINTF’ #define PRINTF(fmt,args...) printf (fmt ,##args) ^~~ Fixes: e221174377d7 ("Initial revision") Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-3-ada@thorsis.com --- drivers/fpga/spartan2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fpga/spartan2.c b/drivers/fpga/spartan2.c index 47692e3207..3817ad8bb7 100644 --- a/drivers/fpga/spartan2.c +++ b/drivers/fpga/spartan2.c @@ -122,7 +122,7 @@ static int spartan2_sp_load(xilinx_desc *desc, const void *buf, size_t bsize) "read data:\t0x%p\n" "write data:\t0x%p\n" "busy:\t0x%p\n" - "abort:\t0x%p\n", + "abort:\t0x%p\n" "post:\t0x%p\n\n", __FUNCTION__, &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, From 0ff33f464f078116be7afac420c5193f3867c14c Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:19:56 +0200 Subject: [PATCH 24/31] fpga: spartan3: Fix printf arguments warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The additional comma messes up the arguments. Warning appears if built with FPGA_DEBUG defined: CC drivers/fpga/spartan3.o /mnt/data/adahl/src/u-boot/drivers/fpga/spartan3.c: In function ‘spartan3_sp_load’: /mnt/data/adahl/src/u-boot/drivers/fpga/spartan3.c:118:11: warning: too many arguments for format [-Wformat-extra-args] PRINTF ("%s: Function Table:\n" ^~~~~~~~~~~~~~~~~~~~~~~ /mnt/data/adahl/src/u-boot/drivers/fpga/spartan3.c:18:37: note: in definition of macro ‘PRINTF’ #define PRINTF(fmt,args...) printf (fmt ,##args) ^~~ Fixes: 875c78934ee2 ("Add Xilinx Spartan3 family FPGA support Patch by Kurt Stremerch, 14 February 2005") Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-4-ada@thorsis.com --- drivers/fpga/spartan3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fpga/spartan3.c b/drivers/fpga/spartan3.c index 918f6db506..641216ad5c 100644 --- a/drivers/fpga/spartan3.c +++ b/drivers/fpga/spartan3.c @@ -127,7 +127,7 @@ static int spartan3_sp_load(xilinx_desc *desc, const void *buf, size_t bsize) "read data:\t0x%p\n" "write data:\t0x%p\n" "busy:\t0x%p\n" - "abort:\t0x%p\n", + "abort:\t0x%p\n" "post:\t0x%p\n\n", __FUNCTION__, &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, From 27fb2e25e5bac6960e757e47e3421c04ce4f094b Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:19:57 +0200 Subject: [PATCH 25/31] fpga: virtex2: Fix printf format string warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warning appears if built with FPGA_DEBUG defined: CC drivers/fpga/virtex2.o /mnt/data/adahl/src/u-boot/drivers/fpga/virtex2.c: In function ‘virtex2_ssm_load’: /mnt/data/adahl/src/u-boot/drivers/fpga/virtex2.c:333:11: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] PRINTF("%s:%d:done went active early, bytecount = %d\n", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __func__, __LINE__, bytecount); ~~~~~~~~~ /mnt/data/adahl/src/u-boot/drivers/fpga/virtex2.c:25:37: note: in definition of macro ‘PRINTF’ #define PRINTF(fmt, args...) printf(fmt, ##args) ^~~ /mnt/data/adahl/src/u-boot/drivers/fpga/virtex2.c: In function ‘virtex2_ss_load’: /mnt/data/adahl/src/u-boot/drivers/fpga/virtex2.c:468:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] PRINTF("%s:%d:done went active early, bytecount = %d\n", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __func__, __LINE__, bytecount); ~~~~~~~~~ /mnt/data/adahl/src/u-boot/drivers/fpga/virtex2.c:25:37: note: in definition of macro ‘PRINTF’ #define PRINTF(fmt, args...) printf(fmt, ##args) ^~~ Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-5-ada@thorsis.com --- drivers/fpga/virtex2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/virtex2.c b/drivers/fpga/virtex2.c index 51b8d31205..e769ceebc1 100644 --- a/drivers/fpga/virtex2.c +++ b/drivers/fpga/virtex2.c @@ -330,7 +330,7 @@ static int virtex2_ssm_load(xilinx_desc *desc, const void *buf, size_t bsize) #endif if ((*fn->done)(cookie) == FPGA_SUCCESS) { - PRINTF("%s:%d:done went active early, bytecount = %d\n", + PRINTF("%s:%d:done went active early, bytecount = %zu\n", __func__, __LINE__, bytecount); break; } @@ -465,7 +465,7 @@ static int virtex2_ss_load(xilinx_desc *desc, const void *buf, size_t bsize) #endif if ((*fn->done)(cookie) == FPGA_SUCCESS) { - PRINTF("%s:%d:done went active early, bytecount = %d\n", + PRINTF("%s:%d:done went active early, bytecount = %zu\n", __func__, __LINE__, bytecount); break; } From 6c62e8ffd99ff110bd6ae30e52b1e46777685198 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:19:58 +0200 Subject: [PATCH 26/31] fpga: altera: Use logging feature instead of FPGA_DEBUG Instead of using DEBUG or LOG_DEBUG the driver still had its own definition for debug output. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-6-ada@thorsis.com --- drivers/fpga/altera.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/fpga/altera.c b/drivers/fpga/altera.c index 10c0475d25..6a4f0cb9bc 100644 --- a/drivers/fpga/altera.c +++ b/drivers/fpga/altera.c @@ -7,6 +7,8 @@ * Rich Ireland, Enterasys Networks, rireland@enterasys.com. */ +#define LOG_CATEGORY UCLASS_FPGA + /* * Altera FPGA support */ @@ -16,9 +18,6 @@ #include #include -/* Define FPGA_DEBUG to 1 to get debug printf's */ -#define FPGA_DEBUG 0 - static const struct altera_fpga { enum altera_family family; const char *name; @@ -106,8 +105,7 @@ int altera_load(Altera_desc *desc, const void *buf, size_t bsize) if (!fpga) return FPGA_FAIL; - debug_cond(FPGA_DEBUG, "%s: Launching the %s Loader...\n", - __func__, fpga->name); + log_debug("Launching the %s Loader...\n", fpga->name); if (fpga->load) return fpga->load(desc, buf, bsize); return 0; @@ -120,8 +118,7 @@ int altera_dump(Altera_desc *desc, const void *buf, size_t bsize) if (!fpga) return FPGA_FAIL; - debug_cond(FPGA_DEBUG, "%s: Launching the %s Reader...\n", - __func__, fpga->name); + log_debug("Launching the %s Reader...\n", fpga->name); if (fpga->dump) return fpga->dump(desc, buf, bsize); return 0; From 29e58112edae2ec9b9ae2e6c0b80d759e437a13a Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:19:59 +0200 Subject: [PATCH 27/31] fpga: cyclon2: Use logging feature instead of FPGA_DEBUG Instead of using DEBUG or LOG_DEBUG the driver still had its own definition for debug output. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-7-ada@thorsis.com --- drivers/fpga/cyclon2.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/fpga/cyclon2.c b/drivers/fpga/cyclon2.c index 3b008facb8..f264ff8c0e 100644 --- a/drivers/fpga/cyclon2.c +++ b/drivers/fpga/cyclon2.c @@ -5,18 +5,14 @@ * Based on ACE1XK.c */ +#define LOG_CATEGORY UCLASS_FPGA + #include /* core U-Boot definitions */ +#include #include #include /* ACEX device family */ #include -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt, args...) printf(fmt, ##args) -#else -#define PRINTF(fmt, args...) -#endif - /* Note: The assumption is that we cannot possibly run fast enough to * overrun the device (the Slave Parallel mode can free run at 50MHz). * If there is a need to operate slower, define CONFIG_FPGA_DELAY in @@ -42,7 +38,7 @@ int CYC2_load(Altera_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case passive_serial: - PRINTF("%s: Launching Passive Serial Loader\n", __func__); + log_debug("Launching Passive Serial Loader\n"); ret_val = CYC2_ps_load(desc, buf, bsize); break; @@ -51,8 +47,7 @@ int CYC2_load(Altera_desc *desc, const void *buf, size_t bsize) * done in the write() callback. Use the existing PS load * function for FPP, too. */ - PRINTF("%s: Launching Fast Passive Parallel Loader\n", - __func__); + log_debug("Launching Fast Passive Parallel Loader\n"); ret_val = CYC2_ps_load(desc, buf, bsize); break; @@ -72,7 +67,7 @@ int CYC2_dump(Altera_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case passive_serial: - PRINTF("%s: Launching Passive Serial Dump\n", __func__); + log_debug("Launching Passive Serial Dump\n"); ret_val = CYC2_ps_dump(desc, buf, bsize); break; @@ -99,22 +94,21 @@ static int CYC2_ps_load(Altera_desc *desc, const void *buf, size_t bsize) Altera_CYC2_Passive_Serial_fns *fn = desc->iface_fns; int ret = 0; - PRINTF("%s: start with interface functions @ 0x%p\n", - __func__, fn); + log_debug("start with interface functions @ 0x%p\n", fn); if (fn) { int cookie = desc->cookie; /* make a local copy */ unsigned long ts; /* timestamp */ - PRINTF("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "config:\t0x%p\n" - "status:\t0x%p\n" - "write:\t0x%p\n" - "done:\t0x%p\n\n", - __func__, &fn, fn, fn->config, fn->status, - fn->write, fn->done); + log_debug("Function Table:\n" + "ptr:\t0x%p\n" + "struct: 0x%p\n" + "config:\t0x%p\n" + "status:\t0x%p\n" + "write:\t0x%p\n" + "done:\t0x%p\n\n", + &fn, fn, fn->config, fn->status, + fn->write, fn->done); #ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf("Loading FPGA Device %d...", cookie); #endif From 40923f56114d44206ff4b08cd4d52af3aaef6d4a Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:20:00 +0200 Subject: [PATCH 28/31] fpga: ACEX1K: Use logging feature instead of FPGA_DEBUG Instead of using DEBUG or LOG_DEBUG the driver still had its own definition for debug output. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-8-ada@thorsis.com --- drivers/fpga/ACEX1K.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/fpga/ACEX1K.c b/drivers/fpga/ACEX1K.c index aca8049c56..a1ff47035b 100644 --- a/drivers/fpga/ACEX1K.c +++ b/drivers/fpga/ACEX1K.c @@ -7,18 +7,14 @@ * Rich Ireland, Enterasys Networks, rireland@enterasys.com. */ +#define LOG_CATEGORY UCLASS_FPGA + #include /* core U-Boot definitions */ #include +#include #include /* ACEX device family */ #include -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - /* Note: The assumption is that we cannot possibly run fast enough to * overrun the device (the Slave Parallel mode can free run at 50MHz). * If there is a need to operate slower, define CONFIG_FPGA_DELAY in @@ -44,7 +40,7 @@ int ACEX1K_load(Altera_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case passive_serial: - PRINTF ("%s: Launching Passive Serial Loader\n", __FUNCTION__); + log_debug("Launching Passive Serial Loader\n"); ret_val = ACEX1K_ps_load (desc, buf, bsize); break; @@ -64,7 +60,7 @@ int ACEX1K_dump(Altera_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case passive_serial: - PRINTF ("%s: Launching Passive Serial Dump\n", __FUNCTION__); + log_debug("Launching Passive Serial Dump\n"); ret_val = ACEX1K_ps_dump (desc, buf, bsize); break; @@ -93,8 +89,7 @@ static int ACEX1K_ps_load(Altera_desc *desc, const void *buf, size_t bsize) Altera_ACEX1K_Passive_Serial_fns *fn = desc->iface_fns; int i; - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); + log_debug("start with interface functions @ 0x%p\n", fn); if (fn) { size_t bytecount = 0; @@ -102,16 +97,16 @@ static int ACEX1K_ps_load(Altera_desc *desc, const void *buf, size_t bsize) int cookie = desc->cookie; /* make a local copy */ unsigned long ts; /* timestamp */ - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "config:\t0x%p\n" - "status:\t0x%p\n" - "clk:\t0x%p\n" - "data:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->config, fn->status, - fn->clk, fn->data, fn->done); + log_debug("Function Table:\n" + "ptr:\t0x%p\n" + "struct: 0x%p\n" + "config:\t0x%p\n" + "status:\t0x%p\n" + "clk:\t0x%p\n" + "data:\t0x%p\n" + "done:\t0x%p\n\n", + &fn, fn, fn->config, fn->status, + fn->clk, fn->data, fn->done); #ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...", cookie); #endif From bc33b69604c10f93ad4624e4b49310a3ad61b062 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:20:01 +0200 Subject: [PATCH 29/31] fpga: spartan2: Use logging feature instead of FPGA_DEBUG Instead of using DEBUG or LOG_DEBUG the driver still had its own definition for debug output. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-9-ada@thorsis.com --- drivers/fpga/spartan2.c | 82 +++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/drivers/fpga/spartan2.c b/drivers/fpga/spartan2.c index 3817ad8bb7..f72dfdec94 100644 --- a/drivers/fpga/spartan2.c +++ b/drivers/fpga/spartan2.c @@ -4,15 +4,11 @@ * Rich Ireland, Enterasys Networks, rireland@enterasys.com. */ -#include /* core U-Boot definitions */ -#include /* Spartan-II device family */ +#define LOG_CATEGORY UCLASS_FPGA -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif +#include /* core U-Boot definitions */ +#include +#include /* Spartan-II device family */ #undef CONFIG_SYS_FPGA_CHECK_BUSY @@ -46,12 +42,12 @@ static int spartan2_load(xilinx_desc *desc, const void *buf, size_t bsize, switch (desc->iface) { case slave_serial: - PRINTF ("%s: Launching Slave Serial Load\n", __FUNCTION__); + log_debug("Launching Slave Serial Load\n"); ret_val = spartan2_ss_load(desc, buf, bsize); break; case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Load\n", __FUNCTION__); + log_debug("Launching Slave Parallel Load\n"); ret_val = spartan2_sp_load(desc, buf, bsize); break; @@ -69,12 +65,12 @@ static int spartan2_dump(xilinx_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case slave_serial: - PRINTF ("%s: Launching Slave Serial Dump\n", __FUNCTION__); + log_debug("Launching Slave Serial Dump\n"); ret_val = spartan2_ss_dump(desc, buf, bsize); break; case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Dump\n", __FUNCTION__); + log_debug("Launching Slave Parallel Dump\n"); ret_val = spartan2_sp_dump(desc, buf, bsize); break; @@ -100,8 +96,7 @@ static int spartan2_sp_load(xilinx_desc *desc, const void *buf, size_t bsize) int ret_val = FPGA_FAIL; /* assume the worst */ xilinx_spartan2_slave_parallel_fns *fn = desc->iface_fns; - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); + log_debug("start with interface functions @ 0x%p\n", fn); if (fn) { size_t bytecount = 0; @@ -109,24 +104,24 @@ static int spartan2_sp_load(xilinx_desc *desc, const void *buf, size_t bsize) int cookie = desc->cookie; /* make a local copy */ unsigned long ts; /* timestamp */ - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pre: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "err:\t0x%p\n" - "clk:\t0x%p\n" - "cs:\t0x%p\n" - "wr:\t0x%p\n" - "read data:\t0x%p\n" - "write data:\t0x%p\n" - "busy:\t0x%p\n" - "abort:\t0x%p\n" - "post:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, - fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, - fn->abort, fn->post); + log_debug("Function Table:\n" + "ptr:\t0x%p\n" + "struct: 0x%p\n" + "pre: 0x%p\n" + "pgm:\t0x%p\n" + "init:\t0x%p\n" + "err:\t0x%p\n" + "clk:\t0x%p\n" + "cs:\t0x%p\n" + "wr:\t0x%p\n" + "read data:\t0x%p\n" + "write data:\t0x%p\n" + "busy:\t0x%p\n" + "abort:\t0x%p\n" + "post:\t0x%p\n\n", + &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, + fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, + fn->abort, fn->post); /* * This code is designed to emulate the "Express Style" @@ -302,8 +297,7 @@ static int spartan2_ss_load(xilinx_desc *desc, const void *buf, size_t bsize) int i; unsigned char val; - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); + log_debug("start with interface functions @ 0x%p\n", fn); if (fn) { size_t bytecount = 0; @@ -311,16 +305,16 @@ static int spartan2_ss_load(xilinx_desc *desc, const void *buf, size_t bsize) int cookie = desc->cookie; /* make a local copy */ unsigned long ts; /* timestamp */ - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "clk:\t0x%p\n" - "wr:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pgm, fn->init, - fn->clk, fn->wr, fn->done); + log_debug("Function Table:\n" + "ptr:\t0x%p\n" + "struct: 0x%p\n" + "pgm:\t0x%p\n" + "init:\t0x%p\n" + "clk:\t0x%p\n" + "wr:\t0x%p\n" + "done:\t0x%p\n\n", + &fn, fn, fn->pgm, fn->init, + fn->clk, fn->wr, fn->done); #ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...\n", cookie); #endif From 1fda8471143bd9b9fe669286488320211ff19d3b Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:20:02 +0200 Subject: [PATCH 30/31] fpga: spartan3: Use logging feature instead of FPGA_DEBUG Instead of using DEBUG or LOG_DEBUG the driver still had its own definition for debug output. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-10-ada@thorsis.com --- drivers/fpga/spartan3.c | 82 +++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/drivers/fpga/spartan3.c b/drivers/fpga/spartan3.c index 641216ad5c..b7a063a95f 100644 --- a/drivers/fpga/spartan3.c +++ b/drivers/fpga/spartan3.c @@ -9,15 +9,11 @@ * on spartan2.c (Rich Ireland, rireland@enterasys.com). */ -#include /* core U-Boot definitions */ -#include /* Spartan-II device family */ +#define LOG_CATEGORY UCLASS_FPGA -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif +#include /* core U-Boot definitions */ +#include +#include /* Spartan-II device family */ #undef CONFIG_SYS_FPGA_CHECK_BUSY @@ -51,12 +47,12 @@ static int spartan3_load(xilinx_desc *desc, const void *buf, size_t bsize, switch (desc->iface) { case slave_serial: - PRINTF ("%s: Launching Slave Serial Load\n", __FUNCTION__); + log_debug("Launching Slave Serial Load\n"); ret_val = spartan3_ss_load(desc, buf, bsize); break; case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Load\n", __FUNCTION__); + log_debug("Launching Slave Parallel Load\n"); ret_val = spartan3_sp_load(desc, buf, bsize); break; @@ -74,12 +70,12 @@ static int spartan3_dump(xilinx_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case slave_serial: - PRINTF ("%s: Launching Slave Serial Dump\n", __FUNCTION__); + log_debug("Launching Slave Serial Dump\n"); ret_val = spartan3_ss_dump(desc, buf, bsize); break; case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Dump\n", __FUNCTION__); + log_debug("Launching Slave Parallel Dump\n"); ret_val = spartan3_sp_dump(desc, buf, bsize); break; @@ -105,8 +101,7 @@ static int spartan3_sp_load(xilinx_desc *desc, const void *buf, size_t bsize) int ret_val = FPGA_FAIL; /* assume the worst */ xilinx_spartan3_slave_parallel_fns *fn = desc->iface_fns; - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); + log_debug("start with interface functions @ 0x%p\n", fn); if (fn) { size_t bytecount = 0; @@ -114,24 +109,24 @@ static int spartan3_sp_load(xilinx_desc *desc, const void *buf, size_t bsize) int cookie = desc->cookie; /* make a local copy */ unsigned long ts; /* timestamp */ - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pre: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "err:\t0x%p\n" - "clk:\t0x%p\n" - "cs:\t0x%p\n" - "wr:\t0x%p\n" - "read data:\t0x%p\n" - "write data:\t0x%p\n" - "busy:\t0x%p\n" - "abort:\t0x%p\n" - "post:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, - fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, - fn->abort, fn->post); + log_debug("Function Table:\n" + "ptr:\t0x%p\n" + "struct: 0x%p\n" + "pre: 0x%p\n" + "pgm:\t0x%p\n" + "init:\t0x%p\n" + "err:\t0x%p\n" + "clk:\t0x%p\n" + "cs:\t0x%p\n" + "wr:\t0x%p\n" + "read data:\t0x%p\n" + "write data:\t0x%p\n" + "busy:\t0x%p\n" + "abort:\t0x%p\n" + "post:\t0x%p\n\n", + &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, + fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, + fn->abort, fn->post); /* * This code is designed to emulate the "Express Style" @@ -309,8 +304,7 @@ static int spartan3_ss_load(xilinx_desc *desc, const void *buf, size_t bsize) int i; unsigned char val; - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); + log_debug("start with interface functions @ 0x%p\n", fn); if (fn) { size_t bytecount = 0; @@ -318,16 +312,16 @@ static int spartan3_ss_load(xilinx_desc *desc, const void *buf, size_t bsize) int cookie = desc->cookie; /* make a local copy */ unsigned long ts; /* timestamp */ - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "clk:\t0x%p\n" - "wr:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pgm, fn->init, - fn->clk, fn->wr, fn->done); + log_debug("Function Table:\n" + "ptr:\t0x%p\n" + "struct: 0x%p\n" + "pgm:\t0x%p\n" + "init:\t0x%p\n" + "clk:\t0x%p\n" + "wr:\t0x%p\n" + "done:\t0x%p\n\n", + &fn, fn, fn->pgm, fn->init, + fn->clk, fn->wr, fn->done); #ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...\n", cookie); #endif From 63c46e028c14254f28332b3bd57fc3202e26b10a Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 7 Oct 2022 14:20:03 +0200 Subject: [PATCH 31/31] fpga: virtex2: Use logging feature instead of FPGA_DEBUG Instead of using DEBUG or LOG_DEBUG the driver still had its own definition for debug output. Signed-off-by: Alexander Dahl Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20221007122003.11239-11-ada@thorsis.com --- drivers/fpga/virtex2.c | 69 ++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/drivers/fpga/virtex2.c b/drivers/fpga/virtex2.c index e769ceebc1..0d536f0d04 100644 --- a/drivers/fpga/virtex2.c +++ b/drivers/fpga/virtex2.c @@ -12,21 +12,14 @@ * on spartan2.c (Rich Ireland, rireland@enterasys.com). */ +#define LOG_CATEGORY UCLASS_FPGA + #include #include +#include #include #include -#if 0 -#define FPGA_DEBUG -#endif - -#ifdef FPGA_DEBUG -#define PRINTF(fmt, args...) printf(fmt, ##args) -#else -#define PRINTF(fmt, args...) -#endif - /* * If the SelectMap interface can be overrun by the processor, define * CONFIG_SYS_FPGA_CHECK_BUSY and/or CONFIG_FPGA_DELAY in the board @@ -89,12 +82,12 @@ static int virtex2_load(xilinx_desc *desc, const void *buf, size_t bsize, switch (desc->iface) { case slave_serial: - PRINTF("%s: Launching Slave Serial Load\n", __func__); + log_debug("Launching Slave Serial Load\n"); ret_val = virtex2_ss_load(desc, buf, bsize); break; case slave_selectmap: - PRINTF("%s: Launching Slave Parallel Load\n", __func__); + log_debug("Launching Slave Parallel Load\n"); ret_val = virtex2_ssm_load(desc, buf, bsize); break; @@ -111,12 +104,12 @@ static int virtex2_dump(xilinx_desc *desc, const void *buf, size_t bsize) switch (desc->iface) { case slave_serial: - PRINTF("%s: Launching Slave Serial Dump\n", __func__); + log_debug("Launching Slave Serial Dump\n"); ret_val = virtex2_ss_dump(desc, buf, bsize); break; case slave_parallel: - PRINTF("%s: Launching Slave Parallel Dump\n", __func__); + log_debug("Launching Slave Parallel Dump\n"); ret_val = virtex2_ssm_dump(desc, buf, bsize); break; @@ -150,8 +143,7 @@ static int virtex2_slave_pre(xilinx_virtex2_slave_fns *fn, int cookie) { unsigned long ts; - PRINTF("%s:%d: Start with interface functions @ 0x%p\n", - __func__, __LINE__, fn); + log_debug("Start with interface functions @ 0x%p\n", fn); if (!fn) { printf("%s:%d: NULL Interface function table!\n", @@ -160,25 +152,24 @@ static int virtex2_slave_pre(xilinx_virtex2_slave_fns *fn, int cookie) } /* Gotta split this one up (so the stack won't blow??) */ - PRINTF("%s:%d: Function Table:\n" - " base 0x%p\n" - " struct 0x%p\n" - " pre 0x%p\n" - " prog 0x%p\n" - " init 0x%p\n" - " error 0x%p\n", - __func__, __LINE__, - &fn, fn, fn->pre, fn->pgm, fn->init, fn->err); - PRINTF(" clock 0x%p\n" - " cs 0x%p\n" - " write 0x%p\n" - " rdata 0x%p\n" - " wdata 0x%p\n" - " busy 0x%p\n" - " abort 0x%p\n" - " post 0x%p\n\n", - fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, - fn->busy, fn->abort, fn->post); + log_debug("Function Table:\n" + " base 0x%p\n" + " struct 0x%p\n" + " pre 0x%p\n" + " prog 0x%p\n" + " init 0x%p\n" + " error 0x%p\n", + &fn, fn, fn->pre, fn->pgm, fn->init, fn->err); + log_debug(" clock 0x%p\n" + " cs 0x%p\n" + " write 0x%p\n" + " rdata 0x%p\n" + " wdata 0x%p\n" + " busy 0x%p\n" + " abort 0x%p\n" + " post 0x%p\n\n", + fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, + fn->busy, fn->abort, fn->post); #ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf("Initializing FPGA Device %d...\n", cookie); @@ -330,8 +321,8 @@ static int virtex2_ssm_load(xilinx_desc *desc, const void *buf, size_t bsize) #endif if ((*fn->done)(cookie) == FPGA_SUCCESS) { - PRINTF("%s:%d:done went active early, bytecount = %zu\n", - __func__, __LINE__, bytecount); + log_debug("done went active early, bytecount = %zu\n", + bytecount); break; } @@ -465,8 +456,8 @@ static int virtex2_ss_load(xilinx_desc *desc, const void *buf, size_t bsize) #endif if ((*fn->done)(cookie) == FPGA_SUCCESS) { - PRINTF("%s:%d:done went active early, bytecount = %zu\n", - __func__, __LINE__, bytecount); + log_debug("done went active early, bytecount = %zu\n", + bytecount); break; }