From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tan, Ley Foon Date: Tue, 23 Mar 2021 10:03:53 +0000 Subject: [v1 5/5] arm: socfpga: Restructure Stratix10 and Agilex handoff code In-Reply-To: <20210315094329.30282-6-elly.siew.chin.lim@intel.com> References: <20210315094329.30282-1-elly.siew.chin.lim@intel.com> <20210315094329.30282-6-elly.siew.chin.lim@intel.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > -----Original Message----- > From: Lim, Elly Siew Chin > Sent: Monday, March 15, 2021 5:43 PM > To: u-boot at lists.denx.de > Cc: Marek Vasut ; Tan, Ley Foon > ; See, Chin Liang ; > Simon Goldschmidt ; Chee, Tien Fong > ; Westergreen, Dalon > ; Simon Glass ; Gan, > Yau Wai ; Lim, Elly Siew Chin > > Subject: [v1 5/5] arm: socfpga: Restructure Stratix10 and Agilex handoff code > > Restructure Stratix10 and Agilex handoff code to used by all SOC64 devices, > in preparation to support handoff for Diamond Mesa. > > Remove wrap_pinmux_config_s10.c. Add wrap_handoff_soc64.c which > contains the generic function to parse the handoff data. > > Update system_manager_soc64.c to use generic handoff function in > wrap_handoff_soc64.c. > > Signed-off-by: Siew Chin Lim > --- > arch/arm/mach-socfpga/Makefile | 4 +- > arch/arm/mach-socfpga/include/mach/handoff_soc64.h | 21 +++++++ > .../include/mach/system_manager_soc64.h | 4 -- > arch/arm/mach-socfpga/system_manager_soc64.c | 53 ++++++++++----- > - > arch/arm/mach-socfpga/wrap_handoff_soc64.c | 73 > ++++++++++++++++++++++ > > diff --git a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h > b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h > index 2561255712..f4c03688d6 100644 > --- a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h > +++ b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h > @@ -11,6 +11,7 @@ > * Offset for HW handoff from Quartus tools > */ > /* HPS handoff */ > +#define SOC64_HANDOFF_MAGIC_BOOT 0x424F4F54 > #define SOC64_HANDOFF_MAGIC_MUX 0x504D5558 > #define SOC64_HANDOFF_MAGIC_IOCTL 0x494F4354 > #define SOC64_HANDOFF_MAGIC_FPGA 0x46504741 > @@ -38,4 +39,24 @@ > #define SOC64_HANDOFF_CLOCK_FPGA (SOC64_HANDOFF_BASE + > 0x600) > #endif > > +#define SOC64_HANDOFF_MUX_LEN 96 > +#define SOC64_HANDOFF_IOCTL_LEN 96 > +#ifdef CONFIG_TARGET_SOCFPGA_STRATIX10 Can change to #if CONFIG_IS_ENABLED() > +#define SOC64_HANDOFF_FPGA_LEN 42 > +#else > +#define SOC64_HANDOFF_FPGA_LEN 40 > +#endif > +#define SOC64_HANDOFF_DELAY_LEN 96 > + > +#ifndef __ASSEMBLY__ > +#include > +enum endianness { > + little_endian, > + big_endian > +}; Uses capital letter for enum macros. > + > +int socfpga_get_handoff_size(void *handoff_address, enum endianness > +endian); int socfpga_handoff_read(void *handoff_address, void *table, > u32 table_len, > + enum endianness big_endian); > +#endif > #endif /* _HANDOFF_SOC64_H_ */ > diff --git a/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h > b/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h > index 4949cae97a..1eb8e7a904 100644 > --- a/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h > +++ b/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h > @@ -10,10 +10,6 @@ > void sysmgr_pinmux_init(void); > void populate_sysmgr_fpgaintf_module(void); > void populate_sysmgr_pinmux(void); > -void sysmgr_pinmux_table_sel(const u32 **table, unsigned int *table_len); > -void sysmgr_pinmux_table_ctrl(const u32 **table, unsigned int *table_len); > -void sysmgr_pinmux_table_fpga(const u32 **table, unsigned int > *table_len); -void sysmgr_pinmux_table_delay(const u32 **table, unsigned > int *table_len); > > #define SYSMGR_SOC64_WDDBG 0x08 > #define SYSMGR_SOC64_DMA 0x20 [...] > diff --git a/arch/arm/mach-socfpga/wrap_handoff_soc64.c > b/arch/arm/mach-socfpga/wrap_handoff_soc64.c > new file mode 100644 > index 0000000000..ba168676e9 > --- /dev/null > +++ b/arch/arm/mach-socfpga/wrap_handoff_soc64.c > @@ -0,0 +1,73 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2020 Intel Corporation > + * > + */ > + > +#include > +#include > +#include > +#include > +#include "log.h" Sort this. > + > +int socfpga_get_handoff_size(void *handoff_address, enum endianness > +endian) { > + u32 handoff_size; > + > + if (endian == little_endian) { > + handoff_size = (readl(handoff_address + > SOC64_HANDOFF_OFFSET_LENGTH) - > + SOC64_HANDOFF_OFFSET_DATA) / > + sizeof(u32); > + } else if (endian == big_endian) { > + handoff_size = swab32(readl(handoff_address + > + Can merge this, just need do additional swab32 if it is bit endian. [.....] > + > +int socfpga_handoff_read(void *handoff_address, void *table, u32 > table_len, > + enum endianness big_endian) > +{ > + u32 temp, i; > + u32 *table_x32 = table; > + > + debug("%s: handoff addr = 0x%p ", __func__, (u32 > *)handoff_address); > + > + if (big_endian) { > + if (swab32(readl(SOC64_HANDOFF_BASE)) == > SOC64_HANDOFF_MAGIC_BOOT) { > + debug("Handoff table address = 0x%p ", table_x32); > + debug("table length = 0x%x\n", table_len); > + debug("%s: handoff data =\n{\n", __func__); > + > + for (i = 0; i < table_len; i++) { > + temp = readl(handoff_address + > + SOC64_HANDOFF_OFFSET_DATA + > + (i * sizeof(u32))); > + *table_x32 = swab32(temp); > + > + if (!(i % 2)) > + debug(" No.%d Addr 0x%08x: ", i, > + *table_x32); > + else > + debug(" 0x%08x\n", *table_x32); > + > + table_x32++; > + } > + debug("\n}\n"); > + } else { > + debug("%s: Cannot find > SOC64_HANDOFF_MAGIC_BOOT ", __func__); > + debug("at addr 0x%p\n", (u32 *)handoff_address); > + return -EPERM; > + } > + } How about if it is little endian, why don't need to fill up table_x32? Regards Ley Foon