[U-Boot] [PATCH 1/2] arm64: zynqmp: Prepare psu_init rework
Michal Simek
monstr at monstr.eu
Mon Jan 15 12:25:44 UTC 2018
Hi,
2018-01-10 16:38 GMT+01:00 Michal Simek <michal.simek at xilinx.com>:
> Move generic functions to common location spl.c. Function declarations
> are added to private header.
> These changes are done in connection to the fact that still files from
> HDF can be copied over and compilation should pass.
>
> Signed-off-by: Michal Simek <michal.simek at xilinx.com>
> ---
>
> Depends on previous psu_init patches
>
> ---
> arch/arm/cpu/armv8/zynqmp/spl.c | 55
> +++++++++++++++++++++++++
> arch/arm/include/asm/arch-zynqmp/psu_init_gpl.h | 25 +++++++++++
> arch/arm/include/asm/arch-zynqmp/sys_proto.h | 2 -
> board/xilinx/zynqmp/zynqmp.c | 1 +
> 4 files changed, 81 insertions(+), 2 deletions(-)
> create mode 100644 arch/arm/include/asm/arch-zynqmp/psu_init_gpl.h
>
> diff --git a/arch/arm/cpu/armv8/zynqmp/spl.c b/arch/arm/cpu/armv8/zynqmp/
> spl.c
> index 41ca74a2be2b..da983458a982 100644
> --- a/arch/arm/cpu/armv8/zynqmp/spl.c
> +++ b/arch/arm/cpu/armv8/zynqmp/spl.c
> @@ -14,6 +14,7 @@
> #include <asm/spl.h>
> #include <asm/arch/hardware.h>
> #include <asm/arch/sys_proto.h>
> +#include <asm/arch/psu_init_gpl.h>
>
> void board_init_f(ulong dummy)
> {
> @@ -156,3 +157,57 @@ int board_fit_config_name_match(const char *name)
> return 0;
> }
> #endif
> +
> +#define PSU_MASK_POLL_TIME 1100000
> +
> +int __maybe_unused mask_pollonvalue(unsigned long add, u32 mask, u32
> value)
> +{
> + int i = 0;
> +
> + while ((__raw_readl(add) & mask) != value) {
> + if (i == PSU_MASK_POLL_TIME)
> + return 0;
> + i++;
> + }
> + return 1;
> +}
> +
> +__weak int mask_poll(u32 add, u32 mask)
> +{
> + int i = 0;
> + unsigned long addr = add;
> +
> + while (!(__raw_readl(addr) & mask)) {
> + if (i == PSU_MASK_POLL_TIME)
> + return 0;
> + i++;
> + }
> + return 1;
> +}
> +
> +__weak void mask_delay(u32 delay)
> +{
> + udelay(delay);
> +}
> +
> +__weak void psu_mask_write(unsigned long offset, unsigned long mask,
> + unsigned long val)
> +{
> + unsigned long regval = 0;
> +
> + regval = readl(offset);
> + regval &= ~(mask);
> + regval |= (val & mask);
> + writel(regval, offset);
> +}
> +
> +__weak void prog_reg(unsigned long addr, unsigned long mask,
> + unsigned long shift, unsigned long value)
> +{
> + int rdata = 0;
> +
> + rdata = readl(addr);
> + rdata = rdata & (~mask);
> + rdata = rdata | (value << shift);
> + writel(rdata, addr);
> +}
> diff --git a/arch/arm/include/asm/arch-zynqmp/psu_init_gpl.h
> b/arch/arm/include/asm/arch-zynqmp/psu_init_gpl.h
> new file mode 100644
> index 000000000000..29ea8ee1aa19
> --- /dev/null
> +++ b/arch/arm/include/asm/arch-zynqmp/psu_init_gpl.h
> @@ -0,0 +1,25 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#ifndef _PSU_INIT_GPL_H_ /* prevent circular inclusions */
> +#define _PSU_INIT_GPL_H_
> +
> +#include <asm/io.h>
> +#include <common.h>
> +
> +int mask_pollonvalue(unsigned long add, u32 mask, u32 value);
> +
> +int mask_poll(u32 add, u32 mask);
> +
> +void mask_delay(u32 delay);
> +
> +void psu_mask_write(unsigned long offset, unsigned long mask,
> + unsigned long val);
> +
> +void prog_reg(unsigned long addr, unsigned long mask,
> + unsigned long shift, unsigned long value);
> +
> +int psu_init(void);
> +
> +#endif /* _PSU_INIT_GPL_H_ */
> diff --git a/arch/arm/include/asm/arch-zynqmp/sys_proto.h
> b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
> index 4dfabba80a5c..084d55a2b01f 100644
> --- a/arch/arm/include/asm/arch-zynqmp/sys_proto.h
> +++ b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
> @@ -33,8 +33,6 @@ enum {
> int zynq_board_read_rom_ethaddr(unsigned char *ethaddr);
> unsigned int zynqmp_get_silicon_version(void);
>
> -int psu_init(void);
> -
> void handoff_setup(void);
>
> void zynqmp_pmufw_version(void);
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index db557e880674..824f4ae50fe5 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -13,6 +13,7 @@
> #include <asm/arch/clk.h>
> #include <asm/arch/hardware.h>
> #include <asm/arch/sys_proto.h>
> +#include <asm/arch/psu_init_gpl.h>
> #include <asm/io.h>
> #include <usb.h>
> #include <dwc3-uboot.h>
> --
> 1.9.1
>
>
Will send v2 of this patch. Psu init functions should be moved to separate
files as is done for zynq.
M
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
More information about the U-Boot
mailing list