arm: socfpga: Convert drivers from struct to defines
Subsystems (5)
v5 cover arm: socfpga: Convert drivers from struct to defines
This is 5th version of patchset to convert reset, system and clock manager drivers to use #define instead of struct.
Patch 1 unchanged, patch 2,3,4 change macro value to 0x** format.
Tested on Cyclone 5, Arria 10 and Stratix 10 devices.
Changes in v5:
- Patch 2,3,4: Change macro value to 0x** format.
History:
v1: https://patchwork.ozlabs.org/cover/1149731/
v2: https://patchwork.ozlabs.org/cover/1160079/
v3: https://patchwork.ozlabs.org/cover/1174327/
v4: https://patchwork.ozlabs.org/cover/1174347/
Ley Foon Tan (4):
arm: dts: socfpga: Add u-boot,dm-pre-reloc for sysmgr and clkmgr nodes
arm: socfpga: Convert reset manager from struct to defines
arm: socfpga: Convert system manager from struct to defines
arm: socfpga: Convert clock manager from struct to defines
arch/arm/dts/socfpga-common-u-boot.dtsi | 8 + arch/arm/dts/socfpga.dtsi | 2 +- arch/arm/dts/socfpga_arria10.dtsi | 2 +- arch/arm/dts/socfpga_arria10_socdk.dtsi | 8 + arch/arm/dts/socfpga_stratix10.dtsi | 2 +- .../dts/socfpga_stratix10_socdk-u-boot.dtsi | 8 + arch/arm/mach-socfpga/clock_manager.c | 12 +- arch/arm/mach-socfpga/clock_manager_arria10.c | 156 +++++++------ arch/arm/mach-socfpga/clock_manager_gen5.c | 199 +++++++++-------- arch/arm/mach-socfpga/clock_manager_s10.c | 210 ++++++++++-------- .../mach-socfpga/include/mach/clock_manager.h | 2 + .../include/mach/clock_manager_arria10.h | 133 +++++------ .../include/mach/clock_manager_gen5.h | 112 ++++------ .../include/mach/clock_manager_s10.h | 115 ++++------ arch/arm/mach-socfpga/include/mach/misc.h | 1 + .../mach-socfpga/include/mach/reset_manager.h | 2 + .../include/mach/reset_manager_arria10.h | 43 +--- .../include/mach/reset_manager_gen5.h | 22 +- .../include/mach/reset_manager_s10.h | 33 +-- .../include/mach/system_manager.h | 2 + .../include/mach/system_manager_arria10.h | 94 +++----- .../include/mach/system_manager_gen5.h | 123 ++-------- .../include/mach/system_manager_s10.h | 184 ++++++--------- arch/arm/mach-socfpga/mailbox_s10.c | 6 +- arch/arm/mach-socfpga/misc.c | 42 ++++ arch/arm/mach-socfpga/misc_arria10.c | 9 +- arch/arm/mach-socfpga/misc_gen5.c | 29 +-- arch/arm/mach-socfpga/misc_s10.c | 9 +- arch/arm/mach-socfpga/reset_manager_arria10.c | 71 +++--- arch/arm/mach-socfpga/reset_manager_gen5.c | 35 ++- arch/arm/mach-socfpga/reset_manager_s10.c | 52 +++-- arch/arm/mach-socfpga/scan_manager.c | 6 +- arch/arm/mach-socfpga/spl_a10.c | 12 +- arch/arm/mach-socfpga/spl_gen5.c | 25 +-- arch/arm/mach-socfpga/spl_s10.c | 24 +- arch/arm/mach-socfpga/system_manager_gen5.c | 38 ++-- arch/arm/mach-socfpga/system_manager_s10.c | 39 ++-- arch/arm/mach-socfpga/wrap_pll_config_s10.c | 11 +- drivers/ddr/altera/sdram_gen5.c | 10 +- drivers/ddr/altera/sdram_s10.c | 6 +- drivers/fpga/socfpga_arria10.c | 7 +- drivers/fpga/socfpga_gen5.c | 4 +- drivers/mmc/socfpga_dw_mmc.c | 17 +- drivers/sysreset/sysreset_socfpga.c | 6 +- 44 files changed, 881 insertions(+), 1050 deletions(-)
Signature · 1 line
2.19.0
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Add u-boot,dm-pre-reloc for sysmgr and clkmgr nodes to use it in SPL. In preparation to get base address from DT.
---
v3:
- Fix missing '0' in clkmgr at ffd10000 node.
--- arch/arm/dts/socfpga-common-u-boot.dtsi | 8 ++++++++ arch/arm/dts/socfpga.dtsi | 2 +- arch/arm/dts/socfpga_arria10.dtsi | 2 +- arch/arm/dts/socfpga_arria10_socdk.dtsi | 8 ++++++++ arch/arm/dts/socfpga_stratix10.dtsi | 2 +- arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi | 8 ++++++++ 6 files changed, 27 insertions(+), 3 deletions(-)
arch/arm/dts/socfpga-common-u-boot.dtsi +8 -0
@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };
@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; }; + +&sysmgr { + u-boot,dm-pre-reloc; +};
arch/arm/dts/socfpga.dtsi +1 -1
@@ -114,7 +114,7 @@ status = "disabled"; }; - clkmgr at ffd04000 { + clkmgr: clkmgr at ffd04000 { compatible = "altr,clk-mgr"; reg = <0xffd04000 0x1000>;
arch/arm/dts/socfpga_arria10.dtsi +1 -1
@@ -96,7 +96,7 @@ fpga-mgr = <&fpga_mgr>; }; - clkmgr at ffd04000 { + clkmgr: clkmgr at ffd04000 { compatible = "altr,clk-mgr"; reg = <0xffd04000 0x1000>; u-boot,dm-pre-reloc;
arch/arm/dts/socfpga_arria10_socdk.dtsi +8 -0
@@ -180,3 +180,11 @@ &l4_sp_clk { u-boot,dm-pre-reloc; }; + +&clkmgr { + u-boot,dm-pre-reloc; +}; + +&sysmgr { + u-boot,dm-pre-reloc; +};
arch/arm/dts/socfpga_stratix10.dtsi +1 -1
@@ -82,7 +82,7 @@ ranges = <0 0 0 0xffffffff>; u-boot,dm-pre-reloc; - clkmgr at ffd1000 { + clkmgr: clkmgr at ffd10000 { compatible = "altr,clk-mgr"; reg = <0xffd10000 0x1000>; };
arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi +8 -0
@@ -11,6 +11,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &qspi { status = "okay"; u-boot,dm-pre-reloc;
@@ -23,3 +27,7 @@ spi-rx-bus-width = <4>; u-boot,dm-pre-reloc; }; + +&sysmgr { + u-boot,dm-pre-reloc; +};
Signature · 1 line
2.19.0
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]
Quoted 16 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };
arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 7 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; }; + +&sysmgr { + u-boot,dm-pre-reloc; +};
Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
[...]
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Quoted 22 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 19 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; };
Quoted 9 lines
arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 4 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0+ +&sysmgr { + u-boot,dm-pre-reloc; +};Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
But, we need to get clkmgr base address from DT even we don't have clock driver for it.
So, clkmgr needs enable in SPL.
Regards
Ley Foon
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Quoted 32 lines · Ley Foon Tan
Quoted 22 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 19 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; };Quoted 9 lines
arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 4 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0+ +&sysmgr { + u-boot,dm-pre-reloc; +};Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
Quoted 3 lines
But, we need to get clkmgr base address from DT even we don't have clock driver for it.
So, clkmgr needs enable in SPL.
Ah, I see, thanks for clarifying.
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Quoted 34 lines · Marek Vasut
Quoted 32 lines · Ley Foon Tan
Quoted 31 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 16 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 7 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; }; + +&sysmgr { + u-boot,dm-pre-reloc; +};Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
Quoted 3 lines
Quoted 3 lines
But, we need to get clkmgr base address from DT even we don't have clock driver for it.
So, clkmgr needs enable in SPL.
Plus gen5 will have get clock manager soon ;-)
Regards,
Simon
Quoted 2 lines
Ah, I see, thanks for clarifying.
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Quoted 35 lines · Simon Goldschmidt
Quoted 34 lines · Marek Vasut
Quoted 32 lines · Ley Foon Tan
Quoted 31 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 16 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 7 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; }; + +&sysmgr { + u-boot,dm-pre-reloc; +};Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
But, we need to get clkmgr base address from DT even we don't have clock driver for it.
So, clkmgr needs enable in SPL.Plus gen5 will have get clock manager soon ;-)
Keep in mind we're already in -rc1 , so that's for next release.
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Quoted 37 lines · Marek Vasut
Quoted 35 lines · Simon Goldschmidt
Quoted 34 lines · Marek Vasut
Quoted 32 lines · Ley Foon Tan
Quoted 31 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 16 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 7 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; }; + +&sysmgr { + u-boot,dm-pre-reloc; +};Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
But, we need to get clkmgr base address from DT even we don't have clock driver for it.
So, clkmgr needs enable in SPL.Plus gen5 will have get clock manager soon ;-)
Keep in mind we're already in -rc1 , so that's for next release.
Right, that's in the gen5 DM series for next. I just wanted to say it's ok to add this here because we'll need it anyway soon.
Regards,
Simon
PATCH v5 1/4 arm: dts: socfpga: Add u-boot, dm-pre-reloc for sysmgr and clkmgr nodes
Quoted 42 lines · Simon Goldschmidt
Quoted 41 lines · Marek Vasut
Quoted 39 lines · Simon Goldschmidt
Quoted 37 lines · Marek Vasut
Quoted 35 lines · Ley Foon Tan
Quoted 22 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 19 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0@@ -10,6 +10,10 @@ }; }; +&clkmgr { + u-boot,dm-pre-reloc; +}; + &rst { u-boot,dm-pre-reloc; };@@ -17,3 +21,7 @@ &sdr { u-boot,dm-pre-reloc; };Quoted 9 lines
arch/arm/dts/socfpga-common-u-boot.dtsi line 27
Quoted 4 lines
arch/arm/dts/socfpga-common-u-boot.dtsi +4
-0+ +&sysmgr { + u-boot,dm-pre-reloc; +};Gen5 doesn't have any clock driver, so does it really make sense to retain the clkmgr node in SPL now ? Seems like this only grows the SPL size with no benefit.
But, we need to get clkmgr base address from DT even we don't have clock driver for it.
So, clkmgr needs enable in SPL.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Plus gen5 will have get clock manager soon ;-)
Keep in mind we're already in -rc1 , so that's for next release.
Right, that's in the gen5 DM series for next. I just wanted to say it's ok to add this here because we'll need it anyway soon.
OK
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
In reply to Ley Foon TanConvert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Change to get reset manager base address from DT node instead of using #define.
---
v5:
- Change macro values with 0x** format.
v4:
- Update commit message about get base address from DT node.
v3:
- Remove "No functional change" in commit description.
v2:
- Get base address from DT
- Revert to use writel(), readl(), setbits_le32() and clrbits_le32().
- Add prefix to defines.
--- arch/arm/mach-socfpga/include/mach/misc.h | 1 + .../mach-socfpga/include/mach/reset_manager.h | 2 + .../include/mach/reset_manager_arria10.h | 43 ++++------------- .../include/mach/reset_manager_gen5.h | 22 ++++----- .../include/mach/reset_manager_s10.h | 33 ++----------- arch/arm/mach-socfpga/misc.c | 32 +++++++++++++ arch/arm/mach-socfpga/misc_gen5.c | 7 ++- arch/arm/mach-socfpga/reset_manager_arria10.c | 47 ++++++++++--------- arch/arm/mach-socfpga/reset_manager_gen5.c | 28 +++++------ arch/arm/mach-socfpga/reset_manager_s10.c | 34 +++++++------- arch/arm/mach-socfpga/spl_a10.c | 7 ++- arch/arm/mach-socfpga/spl_gen5.c | 14 +++--- arch/arm/mach-socfpga/spl_s10.c | 12 +++-- drivers/sysreset/sysreset_socfpga.c | 6 +-- 14 files changed, 138 insertions(+), 150 deletions(-)
arch/arm/mach-socfpga/include/mach/misc.h +1 -0
@@ -41,5 +41,6 @@ void socfpga_sdram_remap_zero(void);void do_bridge_reset (int enable,unsigned int mask);void socfpga_pl310_clear (void ); +void socfpga_get_manager_addr (void );#endif /* _MISC_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
@@ -6,6 +6,8 @@#ifndef _RESET_MANAGER_H_#define _RESET_MANAGER_H_ +extern phys_addr_t socfpga_rstmgr_base; +void reset_cpu (ulong addr);void socfpga_per_reset (u32 reset,int set);
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +9 -34
49 lines not on this page · raw message
arch/arm/mach-socfpga/include/mach/reset_manager_gen5.h +9 -13
@@ -11,19 +11,15 @@void socfpga_bridges_set_handoff_regs (bool h2f,bool lwh2f,bool f2h);void socfpga_bridges_reset (int enable); -struct socfpga_reset_manager { -u32 status; -u32 ctrl; -u32 counts; -u32 padding1; -u32 mpu_mod_reset; -u32 per_mod_reset; -u32 per2_mod_reset; -u32 brg_mod_reset; -u32 misc_mod_reset; -u32 padding2[12 ]; -u32 tstscratch; -}; +#define RSTMGR_GEN5_STATUS 0x00 +#define RSTMGR_GEN5_CTRL 0x04 +#define RSTMGR_GEN5_MPUMODRST 0x10 +#define RSTMGR_GEN5_PERMODRST 0x14 +#define RSTMGR_GEN5_PER2MODRST 0x18 +#define RSTMGR_GEN5_BRGMODRST 0x1c +#define RSTMGR_GEN5_MISCMODRST 0x20 + +#define RSTMGR_CTRL RSTMGR_GEN5_CTRL/* * SocFPGA Cyclone V/Arria V reset IDs, bank mapping is as follows:
arch/arm/mach-socfpga/include/mach/reset_manager_s10.h +5 -28
@@ -15,34 +15,11 @@ void socfpga_bridges_reset(int enable);void socfpga_per_reset (u32 reset,int set);void socfpga_per_reset_all (void ); -struct socfpga_reset_manager { -u32 status; -u32 mpu_rst_stat; -u32 misc_stat; -u32 padding1; -u32 hdsk_en; -u32 hdsk_req; -u32 hdsk_ack; -u32 hdsk_stall; -u32 mpumodrst; -u32 per0modrst; -u32 per1modrst; -u32 brgmodrst; -u32 padding2; -u32 cold_mod_reset; -u32 padding3; -u32 dbg_mod_reset; -u32 tap_mod_reset; -u32 padding4; -u32 padding5; -u32 brg_warm_mask; -u32 padding6[3 ]; -u32 tst_stat; -u32 padding7; -u32 hdsk_timeout; -u32 mpul2flushtimeout; -u32 dbghdsktimeout; -}; +i#define RSTMGR_S10_STATUS 0x00 +#define RSTMGR_S10_MPUMODRST 0x20 +#define RSTMGR_S10_PER0MODRST 0x24 +#define RSTMGR_S10_PER1MODRST 0x28 +#define RSTMGR_S10_BRGMODRST 0x2c#define RSTMGR_MPUMODRST_CORE0 0#define RSTMGR_PER0MODRST_OCP_MASK 0x0020bf00
arch/arm/mach-socfpga/misc.c +32 -0
@@ -22,6 +22,8 @@DECLARE_GLOBAL_DATA_PTR ; +phys_addr_t socfpga_rstmgr_base __section(".data"); +#ifdef CONFIG_SYS_L2_PL310 static const struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE ;
@@ -145,6 +147,8 @@ void socfpga_fpga_add(void *fpga_desc)int arch_cpu_init (void ) { +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* * In case the watchdog is enabled, make sure to (re-)configure it
@@ -202,3 +206,31 @@ U_BOOT_CMD(bridge, 3, 1, do_bridge, );#endif + +static phys_addr_t socfpga_get_base_addr (const char *compat) +{ +const void *blob = gd->fdt_blob; +struct fdt_resource r; +int node; +int ret; + + node =fdt_node_offset_by_compatible (blob,-1 , compat); +if (node <0 ) +return 0 ; + +if (!fdtdec_get_is_enabled (blob, node)) +return 0 ; + + ret =fdt_get_resource (blob, node,"reg" ,0 , &r); +if (ret) +return 0 ; + +return (phys_addr_t )r.start; +} + +void socfpga_get_manager_addr (void ) +{ + socfpga_rstmgr_base =socfpga_get_base_addr ("altr,rst-mgr" ); +if (!socfpga_rstmgr_base) +hang (); +}
arch/arm/mach-socfpga/misc_gen5.c +3 -4
@@ -206,8 +206,6 @@ int arch_early_init_r(void) }#ifndef CONFIG_SPL_BUILD -static struct socfpga_reset_manager *reset_manager_base = - (struct socfpga_reset_manager *)SOCFPGA_RSTMGR_ADDRESS ;static struct socfpga_sdr_ctrl *sdr_ctrl = (struct socfpga_sdr_ctrl *)SDR_CTRLGRP_ADDRESS ;
@@ -226,12 +224,13 @@ void do_bridge_reset(int enable, unsigned int mask)writel (iswgrp_handoff[2 ], &sysmgr_regs->fpgaintfgrp_module);writel (iswgrp_handoff[3 ], &sdr_ctrl->fpgaport_rst); -writel (iswgrp_handoff[0 ], &reset_manager_base->brg_mod_reset); +writel (iswgrp_handoff[0 ], + socfpga_rstmgr_base +RSTMGR_GEN5_BRGMODRST );writel (iswgrp_handoff[1 ], &nic301_regs->remap); }else {writel (0 , &sysmgr_regs->fpgaintfgrp_module);writel (0 , &sdr_ctrl->fpgaport_rst); -writel (0 , &reset_manager_base->brg_mod_reset); +writel (0 , socfpga_rstmgr_base +RSTMGR_GEN5_BRGMODRST );writel (1 , &nic301_regs->remap); } }
arch/arm/mach-socfpga/reset_manager_arria10.c +24 -23
117 lines not on this page · raw message
arch/arm/mach-socfpga/reset_manager_gen5.c +14 -14
@@ -10,32 +10,30 @@#include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> -static const struct socfpga_reset_manager *reset_manager_base = - (void *)SOCFPGA_RSTMGR_ADDRESS ;static const struct socfpga_system_manager *sysmgr_regs = (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;/* Assert or de-assert SoCFPGA reset manager reset. */ void socfpga_per_reset (u32 reset,int set) { -const u32 *reg; +unsigned long reg;u32 rstmgr_bank =RSTMGR_BANK (reset);switch (rstmgr_bank) {case 0 : - reg = &reset_manager_base->mpu_mod_reset; + reg =RSTMGR_GEN5_MPUMODRST ;break ;case 1 : - reg = &reset_manager_base->per_mod_reset; + reg =RSTMGR_GEN5_PERMODRST ;break ;case 2 : - reg = &reset_manager_base->per2_mod_reset; + reg =RSTMGR_GEN5_PER2MODRST ;break ;case 3 : - reg = &reset_manager_base->brg_mod_reset; + reg =RSTMGR_GEN5_BRGMODRST ;break ;case 4 : - reg = &reset_manager_base->misc_mod_reset; + reg =RSTMGR_GEN5_MISCMODRST ;break ;default :
@@ -43,9 +41,11 @@ void socfpga_per_reset(u32 reset, int set) }if (set) -setbits_le32 (reg,1 <<RSTMGR_RESET (reset)); +setbits_le32 (socfpga_rstmgr_base + reg, +1 <<RSTMGR_RESET (reset));else -clrbits_le32 (reg,1 <<RSTMGR_RESET (reset)); +clrbits_le32 (socfpga_rstmgr_base + reg, +1 <<RSTMGR_RESET (reset)); }/*
@@ -57,8 +57,8 @@ void socfpga_per_reset_all(void) {const u32 l4wd0 =1 <<RSTMGR_RESET (SOCFPGA_RESET (L4WD0 )); -writel (~l4wd0, &reset_manager_base->per_mod_reset); -writel (0xffffffff , &reset_manager_base->per2_mod_reset); +writel (~l4wd0, socfpga_rstmgr_base +RSTMGR_GEN5_PERMODRST ); +writel (0xffffffff , socfpga_rstmgr_base +RSTMGR_GEN5_PER2MODRST ); }#define L3REGS_REMAP_LWHPS2FPGA_MASK 0x10
@@ -95,7 +95,7 @@ void socfpga_bridges_reset(int enable)if (enable) {/* brdmodrst */ -writel (0x7 , &reset_manager_base->brg_mod_reset); +writel (0x7 , socfpga_rstmgr_base +RSTMGR_GEN5_BRGMODRST );writel (L3REGS_REMAP_OCRAM_MASK ,SOCFPGA_L3REGS_ADDRESS ); }else {socfpga_bridges_set_handoff_regs (false, false, false);
@@ -109,7 +109,7 @@ void socfpga_bridges_reset(int enable) }/* brdmodrst */ -writel (0 , &reset_manager_base->brg_mod_reset); +writel (0 , socfpga_rstmgr_base +RSTMGR_GEN5_BRGMODRST );/* Remap the bridges into memory map */ writel (l3mask,SOCFPGA_L3REGS_ADDRESS );
arch/arm/mach-socfpga/reset_manager_s10.c +17 -17
@@ -12,31 +12,31 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_reset_manager *reset_manager_base = - (void *)SOCFPGA_RSTMGR_ADDRESS ;static const struct socfpga_system_manager *system_manager_base = (void *)SOCFPGA_SYSMGR_ADDRESS ;/* Assert or de-assert SoCFPGA reset manager reset. */ void socfpga_per_reset (u32 reset,int set) { -const void *reg; +unsigned long reg;if (RSTMGR_BANK (reset) ==0 ) - reg = &reset_manager_base->mpumodrst; + reg =RSTMGR_S10_MPUMODRST ;else if (RSTMGR_BANK (reset) ==1 ) - reg = &reset_manager_base->per0modrst; + reg =RSTMGR_S10_PER0MODRST ;else if (RSTMGR_BANK (reset) ==2 ) - reg = &reset_manager_base->per1modrst; + reg =RSTMGR_S10_PER1MODRST ;else if (RSTMGR_BANK (reset) ==3 ) - reg = &reset_manager_base->brgmodrst; + reg =RSTMGR_S10_BRGMODRST ;else /* Invalid reset register, do nothing */ return ;if (set) -setbits_le32 (reg,1 <<RSTMGR_RESET (reset)); +setbits_le32 (socfpga_rstmgr_base + reg, +1 <<RSTMGR_RESET (reset));else -clrbits_le32 (reg,1 <<RSTMGR_RESET (reset)); +clrbits_le32 (socfpga_rstmgr_base + reg, +1 <<RSTMGR_RESET (reset)); }/*
@@ -50,9 +50,9 @@ void socfpga_per_reset_all(void)/* disable all except OCP and l4wd0. OCP disable later */ writel (~(l4wd0 |RSTMGR_PER0MODRST_OCP_MASK ), - &reset_manager_base->per0modrst); -writel (~l4wd0, &reset_manager_base->per0modrst); -writel (0xffffffff , &reset_manager_base->per1modrst); + socfpga_rstmgr_base +RSTMGR_S10_PER0MODRST ); +writel (~l4wd0, socfpga_rstmgr_base +RSTMGR_S10_PER0MODRST ); +writel (0xffffffff , socfpga_rstmgr_base +RSTMGR_S10_PER1MODRST ); }void socfpga_bridges_reset (int enable)
@@ -62,7 +62,7 @@ void socfpga_bridges_reset(int enable)setbits_le32 (&system_manager_base->noc_idlereq_clr, ~0 );/* Release all bridges from reset state */ -clrbits_le32 (&reset_manager_base->brgmodrst, ~0 ); +clrbits_le32 (socfpga_rstmgr_base +RSTMGR_S10_BRGMODRST , ~0 );/* Poll until all idleack to 0 */ while (readl (&system_manager_base->noc_idleack))
@@ -85,9 +85,9 @@ void socfpga_bridges_reset(int enable) ;/* Reset all bridges (except NOR DDR scheduler & F2S) */ -setbits_le32 (&reset_manager_base->brgmodrst, +setbits_le32 (socfpga_rstmgr_base +RSTMGR_S10_BRGMODRST , ~(RSTMGR_BRGMODRST_DDRSCH_MASK | -RSTMGR_BRGMODRST_FPGA2SOC_MASK )); +RSTMGR_BRGMODRST_FPGA2SOC_MASK ));/* Disable NOC timeout */ writel (0 , &system_manager_base->noc_timeout);
@@ -99,6 +99,6 @@ void socfpga_bridges_reset(int enable)*/ int cpu_has_been_warmreset (void ) { -return readl (&reset_manager_base->status) & -RSTMGR_L4WD_MPU_WARMRESET_MASK ; +return readl (socfpga_rstmgr_base +RSTMGR_S10_STATUS ) & +RSTMGR_L4WD_MPU_WARMRESET_MASK ; }
arch/arm/mach-socfpga/spl_a10.c +5 -2
@@ -106,6 +106,11 @@ void spl_board_init(void)void board_init_f (ulong dummy) { +if (spl_early_init ()) +hang (); + +socfpga_get_manager_addr (); +dcache_disable ();socfpga_init_security_policies ();
@@ -116,8 +121,6 @@ void board_init_f(ulong dummy)socfpga_per_reset_all ();socfpga_watchdog_disable (); -spl_early_init (); -/* Configure the clock based on handoff */ cm_basic_init (gd->fdt_blob);
arch/arm/mach-socfpga/spl_gen5.c +7 -7
@@ -67,8 +67,14 @@ void board_init_f(ulong dummy)int ret;struct udevice *dev; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +/* -* First C code to run. Clear fake OCRAM ECC first as SBE +* Clear fake OCRAM ECC first as SBE * and DBE might triggered during power on */ reg =readl (&sysmgr_regs->eccgrp_ocram);
@@ -128,12 +134,6 @@ void board_init_f(ulong dummy)debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - } - ret =uclass_get_device (UCLASS_RESET ,0 , &dev);if (ret)debug ("Reset init failed: %d\n" , ret);
arch/arm/mach-socfpga/spl_s10.c +7 -5
@@ -14,6 +14,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/firewall_s10.h> #include <asm/arch/mailbox_s10.h> +#include <asm/arch/misc.h> #include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> #include <watchdog.h>
@@ -120,6 +121,12 @@ void board_init_f(ulong dummy)const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , &sysmgr_regs->wddbg);
@@ -145,11 +152,6 @@ void board_init_f(ulong dummy)socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - }preloader_console_init ();cm_print_clock_quick_summary ();
drivers/sysreset/sysreset_socfpga.c +3 -3
@@ -12,7 +12,7 @@#include <asm/arch/reset_manager.h> struct socfpga_sysreset_data { -struct socfpga_reset_manager *rstmgr_base; +void __iomem *rstmgr_base; }; static int socfpga_sysreset_request(struct udevice *dev,
@@ -23,11 +23,11 @@ static int socfpga_sysreset_request(struct udevice *dev,switch (type) {case SYSRESET_WARM :writel (BIT (RSTMGR_CTRL_SWWARMRSTREQ_LSB ), - &data->rstmgr_base->ctrl); + data->rstmgr_base +RSTMGR_CTRL );break ;case SYSRESET_COLD :writel (BIT (RSTMGR_CTRL_SWCOLDRSTREQ_LSB ), - &data->rstmgr_base->ctrl); + data->rstmgr_base +RSTMGR_CTRL );break ;default :return -EPROTONOSUPPORT ;
Signature · 1 line
2.19.0
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
Quoted 5 lines · Ley Foon Tan
Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Change to get reset manager base address from DT node instead of using #define.
It seems the patch also moves spl_early_init() around ?
[...]
arch/arm/mach-socfpga/include/mach/reset_manager.h line 9
Quoted 9 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +1
-0@@ -6,6 +6,8 @@#ifndef _RESET_MANAGER_H_#define _RESET_MANAGER_H_ +extern phys_addr_t socfpga_rstmgr_base;
Would it make sense to implement a getter function which would return the reset manager base address , instead of using the extern ?
[...]
Quoted 27 lines
arch/arm/mach-socfpga/misc.c +5
-0@@ -22,6 +22,8 @@DECLARE_GLOBAL_DATA_PTR ; +phys_addr_t socfpga_rstmgr_base __section(".data"); +#ifdef CONFIG_SYS_L2_PL310 static const struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE ;@@ -145,6 +147,8 @@ void socfpga_fpga_add(void *fpga_desc)int arch_cpu_init (void ) { +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* * In case the watchdog is enabled, make sure to (re-)configure it @@ -202,3 +206,31 @@ U_BOOT_CMD(bridge, 3, 1, do_bridge, );#endif +
arch/arm/mach-socfpga/misc.c U_BOOT_CMD(bridge, 3, 1, do_bridge, · line 219
Quoted 10 lines
arch/arm/mach-socfpga/misc.c +10
-0+static phys_addr_t socfpga_get_base_addr (const char *compat) +{ +const void *blob = gd->fdt_blob; +struct fdt_resource r; +int node; +int ret; + + node =fdt_node_offset_by_compatible (blob,-1 , compat); +if (node <0 ) +return 0 ;
0 is a valid address, so you want to discern 0 from errors here. I think if you change the prototype of the function to e.g.
static int socfpga_get_rstmgr_base_addr(const char *compat, phys_addr_t *base) {} , it should work. Then you can return error values as well as the base address.
arch/arm/mach-socfpga/misc.c U_BOOT_CMD(bridge, 3, 1, do_bridge, · line 231
Quoted 11 lines
arch/arm/mach-socfpga/misc.c +11
-0+if (!fdtdec_get_is_enabled (blob, node)) +return 0 ; + + ret =fdt_get_resource (blob, node,"reg" ,0 , &r); +if (ret) +return 0 ; + +return (phys_addr_t )r.start; +} + +void socfpga_get_manager_addr (void )
You should rename this function, a lot of blocks on the Gen5 are called <something>-manager .
Quoted 5 lines
arch/arm/mach-socfpga/misc.c +5
-0+{ + socfpga_rstmgr_base =socfpga_get_base_addr ("altr,rst-mgr" ); +if (!socfpga_rstmgr_base) +hang (); +}
[...]
Quoted 85 lines
arch/arm/mach-socfpga/spl_a10.c +5
-2@@ -106,6 +106,11 @@ void spl_board_init(void)void board_init_f (ulong dummy) { +if (spl_early_init ()) +hang (); + +socfpga_get_manager_addr (); +dcache_disable ();socfpga_init_security_policies ();@@ -116,8 +121,6 @@ void board_init_f(ulong dummy)socfpga_per_reset_all ();socfpga_watchdog_disable (); -spl_early_init (); -/* Configure the clock based on handoff */ cm_basic_init (gd->fdt_blob);arch/arm/mach-socfpga/spl_gen5.c +7
-7@@ -67,8 +67,14 @@ void board_init_f(ulong dummy)int ret;struct udevice *dev; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +/* -* First C code to run. Clear fake OCRAM ECC first as SBE +* Clear fake OCRAM ECC first as SBE * and DBE might triggered during power on */ reg =readl (&sysmgr_regs->eccgrp_ocram);@@ -128,12 +134,6 @@ void board_init_f(ulong dummy)debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - } - ret =uclass_get_device (UCLASS_RESET ,0 , &dev);if (ret)debug ("Reset init failed: %d\n" , ret);arch/arm/mach-socfpga/spl_s10.c +7
-0@@ -14,6 +14,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/firewall_s10.h> #include <asm/arch/mailbox_s10.h> +#include <asm/arch/misc.h> #include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> #include <watchdog.h> @@ -120,6 +121,12 @@ void board_init_f(ulong dummy)const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , &sysmgr_regs->wddbg);@@ -145,11 +152,6 @@ void board_init_f(ulong dummy)socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 157
Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c +0
-5debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - }preloader_console_init ();cm_print_clock_quick_summary ();
Are these three hunks above really supposed to be in this patch ?
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
Quoted 9 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan
Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Change to get reset manager base address from DT node instead of using #define.
It seems the patch also moves
spl_early_init()around ?
Yes, because spl_early_init() initialize DT stuff, so it needs to be called before we get base address from DT.
Quoted 11 lines
[...]
Quoted 8 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0
-0@@ -6,6 +6,8 @@#ifndef _RESET_MANAGER_H_#define _RESET_MANAGER_H_
Quoted 4 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h line 9
Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1
-0+extern phys_addr_t socfpga_rstmgr_base;Would it make sense to implement a getter function which would return the reset manager base address , instead of using the extern ?
Okay, I can add a function for it.
Quoted 38 lines
[...]
Quoted 35 lines
arch/arm/mach-socfpga/misc.c +13
-0@@ -22,6 +22,8 @@DECLARE_GLOBAL_DATA_PTR ; +phys_addr_t socfpga_rstmgr_base __section(".data"); +#ifdef CONFIG_SYS_L2_PL310 static const struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE ;@@ -145,6 +147,8 @@ void socfpga_fpga_add(void *fpga_desc)int arch_cpu_init (void ) { +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* * In case the watchdog is enabled, make sure to (re-)configure it @@ -202,3 +206,31 @@ U_BOOT_CMD(bridge, 3, 1, do_bridge, );#endif + +static phys_addr_t socfpga_get_base_addr (const char *compat) +{ +const void *blob = gd->fdt_blob; +struct fdt_resource r; +int node; +int ret; + + node =fdt_node_offset_by_compatible (blob,-1 , compat);
Quoted 8 lines
arch/arm/mach-socfpga/misc.c U_BOOT_CMD(bridge, 3, 1, do_bridge, · line 219
Quoted 2 lines
arch/arm/mach-socfpga/misc.c +2
-0+if (node <0 ) +return 0 ;0 is a valid address, so you want to discern 0 from errors here. I think if you change the prototype of the function to e.g.
static intsocfpga_get_rstmgr_base_addr(const char *compat, phys_addr_t *base){} , it should work. Then you can return error values as well as the base address.
Okay, will change that.
Quoted 15 lines
arch/arm/mach-socfpga/misc.c U_BOOT_CMD(bridge, 3, 1, do_bridge, · line 231
Quoted 12 lines
arch/arm/mach-socfpga/misc.c +11
-0+if (!fdtdec_get_is_enabled (blob, node)) +return 0 ; + + ret =fdt_get_resource (blob, node,"reg" ,0 , &r); +if (ret) +return 0 ; + +return (phys_addr_t )r.start; +} + +void socfpga_get_manager_addr (void )You should rename this function, a lot of blocks on the Gen5 are called <something>-manager .
Okay, will change it something like socfpga_get_base_addr().
Quoted 101 lines
Quoted 6 lines
arch/arm/mach-socfpga/misc.c +5
-0+{ + socfpga_rstmgr_base =socfpga_get_base_addr ("altr,rst-mgr" ); +if (!socfpga_rstmgr_base) +hang (); +}[...]
Quoted 93 lines
arch/arm/mach-socfpga/spl_a10.c +5
-2@@ -106,6 +106,11 @@ void spl_board_init(void)void board_init_f (ulong dummy) { +if (spl_early_init ()) +hang (); + +socfpga_get_manager_addr (); +dcache_disable ();socfpga_init_security_policies ();@@ -116,8 +121,6 @@ void board_init_f(ulong dummy)socfpga_per_reset_all ();socfpga_watchdog_disable (); -spl_early_init (); -/* Configure the clock based on handoff */ cm_basic_init (gd->fdt_blob);arch/arm/mach-socfpga/spl_gen5.c +7
-7@@ -67,8 +67,14 @@ void board_init_f(ulong dummy)int ret;struct udevice *dev; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +/* -* First C code to run. Clear fake OCRAM ECC first as SBE +* Clear fake OCRAM ECC first as SBE * and DBE might triggered during power on */ reg =readl (&sysmgr_regs->eccgrp_ocram);@@ -128,12 +134,6 @@ void board_init_f(ulong dummy)debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - } - ret =uclass_get_device (UCLASS_RESET ,0 , &dev);if (ret)debug ("Reset init failed: %d\n" , ret);arch/arm/mach-socfpga/spl_s10.c +7
-5@@ -14,6 +14,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/firewall_s10.h> #include <asm/arch/mailbox_s10.h> +#include <asm/arch/misc.h> #include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> #include <watchdog.h> @@ -120,6 +121,12 @@ void board_init_f(ulong dummy)const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , &sysmgr_regs->wddbg);@@ -145,11 +152,6 @@ void board_init_f(ulong dummy)socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - }
Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 157
Quoted 2 lines
arch/arm/mach-socfpga/spl_s10.c +0
-0preloader_console_init ();cm_print_clock_quick_summary ();Are these three hunks above really supposed to be in this patch ?
Yes, as explained earlier, spl_early_init() need to be called before get base address from DT.
Regards
Ley Foon
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
Quoted 6 lines · Ley Foon Tan
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Ley Foon Tan
Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Change to get reset manager base address from DT node instead of using #define.
It seems the patch also moves
spl_early_init()around ?Yes, because
spl_early_init()initialize DT stuff, so it needs to be called before we get base address from DT.
That really should be documented in the commit message though.
[...]
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
+void
socfpga_get_manager_addr(void)You should rename this function, a lot of blocks on the Gen5 are called <something>-manager .
Okay, will change it something like
socfpga_get_base_addr().
If it's only used to retrieve the reset manager base, then it should say so in the function name.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-socfpga/misc.c +5
-0+{ + socfpga_rstmgr_base =socfpga_get_base_addr ("altr,rst-mgr" ); +if (!socfpga_rstmgr_base) +hang (); +}
[...]
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
arch/arm/mach-socfpga/spl_s10.c +7
-5@@ -14,6 +14,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/firewall_s10.h> #include <asm/arch/mailbox_s10.h> +#include <asm/arch/misc.h> #include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> #include <watchdog.h> @@ -120,6 +121,12 @@ void board_init_f(ulong dummy)const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , &sysmgr_regs->wddbg);@@ -145,11 +152,6 @@ void board_init_f(ulong dummy)socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - }
Quoted 6 lines
Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 157
Quoted 2 lines
arch/arm/mach-socfpga/spl_s10.c +0
-0preloader_console_init ();cm_print_clock_quick_summary ();Are these three hunks above really supposed to be in this patch ?
Yes, as explained earlier,
spl_early_init()need to be called before get base address from DT.
OK, please just add it into the commit message.
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
Quoted 8 lines · Marek Vasut
Quoted 6 lines · Ley Foon Tan
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Ley Foon Tan
Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Change to get reset manager base address from DT node instead of using #define.
It seems the patch also moves
spl_early_init()around ?Yes, because
spl_early_init()initialize DT stuff, so it needs to be called before we get base address from DT.That really should be documented in the commit message though.
Okay.
Quoted 11 lines
[...]
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
+void
socfpga_get_manager_addr(void)You should rename this function, a lot of blocks on the Gen5 are called <something>-manager .
Okay, will change it something like
socfpga_get_base_addr().If it's only used to retrieve the reset manager base, then it should say so in the function name.
socfpga_get_manager_addr() function will get base address for clkmgr, rstmgr and sysmgr, not only reset manger.
Quoted 44 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-socfpga/misc.c +5
-0+{ + socfpga_rstmgr_base =socfpga_get_base_addr ("altr,rst-mgr" ); +if (!socfpga_rstmgr_base) +hang (); +}[...]
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
arch/arm/mach-socfpga/spl_s10.c +7
-5@@ -14,6 +14,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/firewall_s10.h> #include <asm/arch/mailbox_s10.h> +#include <asm/arch/misc.h> #include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> #include <watchdog.h> @@ -120,6 +121,12 @@ void board_init_f(ulong dummy)const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; + ret =spl_early_init (); +if (ret) +hang (); + +socfpga_get_manager_addr (); +#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , &sysmgr_regs->wddbg);@@ -145,11 +152,6 @@ void board_init_f(ulong dummy)socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );debug_uart_init ();#endif - ret =spl_early_init (); -if (ret) { -debug ("spl_early_init() failed: %d\n" , ret); -hang (); - }
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 157
Quoted 2 lines
arch/arm/mach-socfpga/spl_s10.c +0
-0preloader_console_init ();cm_print_clock_quick_summary ();Are these three hunks above really supposed to be in this patch ?
Yes, as explained earlier,
spl_early_init()need to be called before get base address from DT.OK, please just add it into the commit message.
Okay.
Thanks.
Regards
Ley Foon
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
Quoted 23 lines · Ley Foon Tan
Quoted 8 lines · Marek Vasut
Quoted 6 lines · Ley Foon Tan
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Ley Foon Tan
Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Change to get reset manager base address from DT node instead of using #define.
It seems the patch also moves
spl_early_init()around ?Yes, because
spl_early_init()initialize DT stuff, so it needs to be called before we get base address from DT.That really should be documented in the commit message though.
Okay.
Quoted 5 lines
[...]
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+void
socfpga_get_manager_addr(void)
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
You should rename this function, a lot of blocks on the Gen5 are called <something>-manager .
Okay, will change it something like
socfpga_get_base_addr().If it's only used to retrieve the reset manager base, then it should say so in the function name.
socfpga_get_manager_addr()function will get base address for clkmgr, rstmgr and sysmgr, not only reset manger.
Aha, OK, then that's fine as is.
[...]
PATCH v5 2/4 arm: socfpga: Convert reset manager from struct to defines
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan
Quoted 8 lines · Marek Vasut
Quoted 6 lines · Ley Foon Tan
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Ley Foon Tan
Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Change to get reset manager base address from DT node instead of using #define.
It seems the patch also moves
spl_early_init()around ?Yes, because
spl_early_init()initialize DT stuff, so it needs to be called before we get base address from DT.That really should be documented in the commit message though.
Okay.
Quoted 7 lines
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+void
socfpga_get_manager_addr(void)You should rename this function, a lot of blocks on the Gen5 are called <something>-manager .
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Okay, will change it something like
socfpga_get_base_addr().If it's only used to retrieve the reset manager base, then it should say so in the function name.
socfpga_get_manager_addr()function will get base address for clkmgr, rstmgr and sysmgr, not only reset manger.Aha, OK, then that's fine as is.
Will keep the socfpga_get_managers_addr() function name.
Just noticed it already have socfpga_get_base_addr() function to get
base from DT (with targeted compatible string).
Regards
Ley Foon
PATCH v5 3/4 arm: socfpga: Convert system manager from struct to defines
In reply to Ley Foon TanConvert system manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Change to get system manager base address from DT node instead of using #define.
---
v5:
- Change macro value to 0x** format.
v4:
- Update commit message about get base address from DT node.
v3:
- Remove "No functional change" in commit description.
v2:
- Revert to use writel(), readl() and etc.
- Get base address from DT.
- Add prefix to defines.
--- arch/arm/mach-socfpga/clock_manager_s10.c | 4 +- .../include/mach/system_manager.h | 2 + .../include/mach/system_manager_arria10.h | 94 +++------ .../include/mach/system_manager_gen5.h | 123 +++--------- .../include/mach/system_manager_s10.h | 184 +++++++----------- arch/arm/mach-socfpga/mailbox_s10.c | 6 +- arch/arm/mach-socfpga/misc.c | 5 + arch/arm/mach-socfpga/misc_arria10.c | 9 +- arch/arm/mach-socfpga/misc_gen5.c | 22 ++- arch/arm/mach-socfpga/misc_s10.c | 9 +- arch/arm/mach-socfpga/reset_manager_arria10.c | 24 +-- arch/arm/mach-socfpga/reset_manager_gen5.c | 7 +- arch/arm/mach-socfpga/reset_manager_s10.c | 18 +- arch/arm/mach-socfpga/scan_manager.c | 6 +- arch/arm/mach-socfpga/spl_a10.c | 5 +- arch/arm/mach-socfpga/spl_gen5.c | 11 +- arch/arm/mach-socfpga/spl_s10.c | 12 +- arch/arm/mach-socfpga/system_manager_gen5.c | 38 ++-- arch/arm/mach-socfpga/system_manager_s10.c | 39 ++-- arch/arm/mach-socfpga/wrap_pll_config_s10.c | 11 +- drivers/ddr/altera/sdram_gen5.c | 10 +- drivers/ddr/altera/sdram_s10.c | 6 +- drivers/fpga/socfpga_arria10.c | 7 +- drivers/fpga/socfpga_gen5.c | 4 +- drivers/mmc/socfpga_dw_mmc.c | 6 +- 25 files changed, 240 insertions(+), 422 deletions(-)
arch/arm/mach-socfpga/clock_manager_s10.c +1 -3
@@ -14,8 +14,6 @@ DECLARE_GLOBAL_DATA_PTR;static const struct socfpga_clock_manager *clock_manager_base = (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS ; -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;/* * function to write the bypass register which requires a poll of the
@@ -351,7 +349,7 @@ unsigned int cm_get_l4_sp_clk_hz(void)unsigned int cm_get_qspi_controller_clk_hz (void ) { -return readl (&sysmgr_regs->boot_scratch_cold0); +return readl (socfpga_sysmgr_base +SYSMGR_S10_BOOT_SCRATCH_COLD0 ); }unsigned int cm_get_spi_controller_clk_hz (void )
arch/arm/mach-socfpga/include/mach/system_manager.h +2 -0
@@ -6,6 +6,8 @@#ifndef _SYSTEM_MANAGER_H_#define _SYSTEM_MANAGER_H_ +extern phys_addr_t socfpga_sysmgr_base; +#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10 )#include <asm/arch/system_manager_s10.h> #else
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h +27 -67
100 lines not on this page · raw message
arch/arm/mach-socfpga/include/mach/system_manager_gen5.h +23 -100
129 lines not on this page · raw message
arch/arm/mach-socfpga/include/mach/system_manager_s10.h +66 -118
191 lines not on this page · raw message
arch/arm/mach-socfpga/mailbox_s10.c +2 -4
@@ -287,9 +287,6 @@ int mbox_qspi_close(void)int mbox_qspi_open (void ) { -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -int ret;u32 resp_buf[1 ];u32 resp_buf_len;
@@ -318,7 +315,8 @@ int mbox_qspi_open(void)/* We are getting QSPI ref clock and set into sysmgr boot register */ printf ("QSPI: Reference clock at %d Hz\n" , resp_buf[0 ]); -writel (resp_buf[0 ], &sysmgr_regs->boot_scratch_cold0); +writel (resp_buf[0 ], + socfpga_sysmgr_base +SYSMGR_S10_BOOT_SCRATCH_COLD0 );return 0 ;
arch/arm/mach-socfpga/misc.c +5 -0
@@ -23,6 +23,7 @@DECLARE_GLOBAL_DATA_PTR ; phys_addr_t socfpga_rstmgr_base __section(".data"); +phys_addr_t socfpga_sysmgr_base __section(".data");#ifdef CONFIG_SYS_L2_PL310 static const struct pl310_regs *const pl310 =
@@ -233,4 +234,8 @@ void socfpga_get_manager_addr(void) socfpga_rstmgr_base =socfpga_get_base_addr ("altr,rst-mgr" );if (!socfpga_rstmgr_base)hang (); + + socfpga_sysmgr_base =socfpga_get_base_addr ("altr,sys-mgr" ); +if (!socfpga_sysmgr_base) +hang (); }
arch/arm/mach-socfpga/misc_arria10.c +3 -6
@@ -28,9 +28,6 @@#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q3_7 0x78#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q4_3 0x98 -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * FPGA programming support for SoC FPGA Arria 10 */
@@ -81,7 +78,7 @@ void socfpga_init_security_policies(void)writel (~0 ,SOCFPGA_NOC_FW_H2F_SCR_OFST );writel (~0 ,SOCFPGA_NOC_FW_H2F_SCR_OFST +4 ); -writel (0x0007FFFF , &sysmgr_regs->ecc_intmask_set); +writel (0x0007FFFF , socfpga_sysmgr_base +SYSMGR_A10_ECC_INTMASK_SET ); }void socfpga_sdram_remap_zero (void )
@@ -105,8 +102,8 @@ int arch_early_init_r(void)#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) { -const u32 bsel = -SYSMGR_GET_BOOTINFO_BSEL (readl (&sysmgr_regs->bootinfo)); +u32 bootinfo =readl (socfpga_sysmgr_base +SYSMGR_A10_BOOTINFO ); +const u32 bsel =SYSMGR_GET_BOOTINFO_BSEL (bootinfo);puts ("CPU: Altera SoCFPGA Arria 10\n" );
arch/arm/mach-socfpga/misc_gen5.c +12 -10
@@ -28,8 +28,6 @@ DECLARE_GLOBAL_DATA_PTR;static struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;static struct nic301_registers *nic301_regs = (struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS ; static struct scu_registers *scu_regs =
@@ -118,8 +116,8 @@ static int socfpga_fpga_id(const bool print_id)#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) { -const u32 bsel = -SYSMGR_GET_BOOTINFO_BSEL (readl (&sysmgr_regs->bootinfo)); +u32 bootinfo =readl (socfpga_sysmgr_base +SYSMGR_GEN5_BOOTINFO ); +const u32 bsel =SYSMGR_GET_BOOTINFO_BSEL (bootinfo);puts ("CPU: Altera SoCFPGA Platform\n" );socfpga_fpga_id (1 );
@@ -132,7 +130,8 @@ int print_cpuinfo(void)#ifdef CONFIG_ARCH_MISC_INIT int arch_misc_init (void ) { -const u32 bsel =readl (&sysmgr_regs->bootinfo) &0x7 ; +const u32 bsel =readl (socfpga_sysmgr_base + +SYSMGR_GEN5_BOOTINFO ) &0x7 ;const int fpga_id =socfpga_fpga_id (0 );env_set ("bootmode" , bsel_str[bsel].mode);if (fpga_id >=0 )
@@ -190,10 +189,11 @@ int arch_early_init_r(void)* to support that old code, we write it here instead of in the * reset_cpu() function just before resetting the CPU. */ -writel (0xae9efebc , &sysmgr_regs->romcodegrp_warmramgrp_enable); +writel (0xae9efebc , socfpga_sysmgr_base +SYSMGR_GEN5_WARMRAMGRP_EN );for (i =0 ; i <8 ; i++)/* Cache initial SW setting regs */ - iswgrp_handoff[i] =readl (&sysmgr_regs->iswgrp_handoff[i]); + iswgrp_handoff[i] =readl (socfpga_sysmgr_base + +SYSMGR_ISWGRP_HANDOFF_OFFSET (i));socfpga_bridges_reset (1 );
@@ -219,16 +219,18 @@ void do_bridge_reset(int enable, unsigned int mask) !(mask & BIT(2)));for (i =0 ; i <2 ; i++) {/* Reload SW setting cache */ iswgrp_handoff[i] = -readl (&sysmgr_regs->iswgrp_handoff[i]); +readl (socfpga_sysmgr_base + +SYSMGR_ISWGRP_HANDOFF_OFFSET (i)); } -writel (iswgrp_handoff[2 ], &sysmgr_regs->fpgaintfgrp_module); +writel (iswgrp_handoff[2 ], + socfpga_sysmgr_base +SYSMGR_GEN5_FPGAINFGRP_MODULE );writel (iswgrp_handoff[3 ], &sdr_ctrl->fpgaport_rst);writel (iswgrp_handoff[0 ], socfpga_rstmgr_base +RSTMGR_GEN5_BRGMODRST );writel (iswgrp_handoff[1 ], &nic301_regs->remap); }else { -writel (0 , &sysmgr_regs->fpgaintfgrp_module); +writel (0 , socfpga_sysmgr_base +SYSMGR_GEN5_FPGAINFGRP_MODULE );writel (0 , &sdr_ctrl->fpgaport_rst);writel (0 , socfpga_rstmgr_base +RSTMGR_GEN5_BRGMODRST );writel (1 , &nic301_regs->remap);
arch/arm/mach-socfpga/misc_s10.c +3 -6
@@ -23,9 +23,6 @@DECLARE_GLOBAL_DATA_PTR ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * FPGA programming support for SoC FPGA Stratix 10 */
@@ -68,9 +65,9 @@ static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode)else return -EINVAL ; -clrsetbits_le32 (&sysmgr_regs->emac0 + gmac_index, -SYSMGR_EMACGRP_CTRL_PHYSEL_MASK , - modereg); +clrsetbits_le32 ((unsigned long )(socfpga_sysmgr_base +SYSMGR_S10_EMAC0 + + gmac_index), +SYSMGR_EMACGRP_CTRL_PHYSEL_MASK , modereg);return 0 ; }
arch/arm/mach-socfpga/reset_manager_arria10.c +13 -11
@@ -15,9 +15,6 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -struct bridge_cfg {int compat_id;u32 mask_noc;
@@ -98,14 +95,16 @@ int socfpga_reset_deassert_bridges_handoff(void) }/* clear idle request to all bridges */ -setbits_le32 (&sysmgr_regs->noc_idlereq_clr, mask_noc); +setbits_le32 (socfpga_sysmgr_base +SYSMGR_A10_NOC_IDLEREQ_CLR , + mask_noc);/* Release bridges from reset state per handoff value */ clrbits_le32 (socfpga_rstmgr_base +RSTMGR_A10_BRGMODRST , mask_rstmgr);/* Poll until all idleack to 0, timeout at 1000ms */ -return wait_for_bit_le32 (&sysmgr_regs->noc_idleack, mask_noc, - false,1000 , false); +return wait_for_bit_le32 ((const void *)(socfpga_sysmgr_base + +SYSMGR_A10_NOC_IDLEACK ), + mask_noc, false,1000 , false); }/* Release L4 OSC1 Watchdog Timer 0 from reset through reset manager */
@@ -195,13 +194,15 @@ int socfpga_bridges_reset(void)ALT_SYSMGR_NOC_F2SDR0_SET_MSK |ALT_SYSMGR_NOC_F2SDR1_SET_MSK |ALT_SYSMGR_NOC_F2SDR2_SET_MSK , - &sysmgr_regs->noc_idlereq_set); + socfpga_sysmgr_base + SYSMGR_A10_NOC_IDLEREQ_SET);/* Enable the NOC timeout */ -writel (ALT_SYSMGR_NOC_TMO_EN_SET_MSK , &sysmgr_regs->noc_timeout); +writel (ALT_SYSMGR_NOC_TMO_EN_SET_MSK , + socfpga_sysmgr_base +SYSMGR_A10_NOC_TIMEOUT );/* Poll until all idleack to 1 */ - ret = wait_for_bit_le32(&sysmgr_regs->noc_idleack, + ret = wait_for_bit_le32((const void *)(socfpga_sysmgr_base + + SYSMGR_A10_NOC_IDLEACK), ALT_SYSMGR_NOC_H2F_SET_MSK | ALT_SYSMGR_NOC_LWH2F_SET_MSK | ALT_SYSMGR_NOC_F2H_SET_MSK |
@@ -213,7 +214,8 @@ int socfpga_bridges_reset(void)return ret;/* Poll until all idlestatus to 1 */ - ret = wait_for_bit_le32(&sysmgr_regs->noc_idlestatus, + ret = wait_for_bit_le32((const void *)(socfpga_sysmgr_base + + SYSMGR_A10_NOC_IDLESTATUS), ALT_SYSMGR_NOC_H2F_SET_MSK | ALT_SYSMGR_NOC_LWH2F_SET_MSK | ALT_SYSMGR_NOC_F2H_SET_MSK |
@@ -234,7 +236,7 @@ int socfpga_bridges_reset(void) ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK));/* Disable NOC timeout */ -writel (0 , &sysmgr_regs->noc_timeout); +writel (0 , socfpga_sysmgr_base +SYSMGR_A10_NOC_TIMEOUT );return 0 ; }
arch/arm/mach-socfpga/reset_manager_gen5.c +2 -5
@@ -10,9 +10,6 @@#include <asm/arch/reset_manager.h> #include <asm/arch/system_manager.h> -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* Assert or de-assert SoCFPGA reset manager reset. */ void socfpga_per_reset (u32 reset,int set) {
@@ -83,8 +80,8 @@ void socfpga_bridges_set_handoff_regs(bool h2f, bool lwh2f, bool f2h)if (f2h) brgmask |=BIT (2 ); -writel (brgmask, &sysmgr_regs->iswgrp_handoff[0 ]); -writel (l3rmask, &sysmgr_regs->iswgrp_handoff[1 ]); +writel (brgmask, socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (0 )); +writel (l3rmask, socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (1 )); }void socfpga_bridges_reset (int enable)
arch/arm/mach-socfpga/reset_manager_s10.c +8 -10
@@ -12,9 +12,6 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_system_manager *system_manager_base = - (void *)SOCFPGA_SYSMGR_ADDRESS ; -/* Assert or de-assert SoCFPGA reset manager reset. */ void socfpga_per_reset (u32 reset,int set) {
@@ -59,28 +56,29 @@ void socfpga_bridges_reset(int enable) {if (enable) {/* clear idle request to all bridges */ -setbits_le32 (&system_manager_base->noc_idlereq_clr, ~0 ); +setbits_le32 (socfpga_sysmgr_base +SYSMGR_S10_NOC_IDLEREQ_CLR , + ~0 );/* Release all bridges from reset state */ clrbits_le32 (socfpga_rstmgr_base +RSTMGR_S10_BRGMODRST , ~0 );/* Poll until all idleack to 0 */ -while (readl (&system_manager_base->noc_idleack)) +while (readl (socfpga_sysmgr_base +SYSMGR_S10_NOC_IDLEACK )) ; }else {/* set idle request to all bridges */ -writel (~0 , &system_manager_base->noc_idlereq_set); +writel (~0 , socfpga_sysmgr_base +SYSMGR_S10_NOC_IDLEREQ_SET );/* Enable the NOC timeout */ -writel (1 , &system_manager_base->noc_timeout); +writel (1 , socfpga_sysmgr_base +SYSMGR_S10_NOC_TIMEOUT );/* Poll until all idleack to 1 */ -while ((readl (&system_manager_base->noc_idleack) ^ +while ((readl (socfpga_sysmgr_base +SYSMGR_S10_NOC_IDLEACK ) ^ (SYSMGR_NOC_H2F_MSK |SYSMGR_NOC_LWH2F_MSK ))) ;/* Poll until all idlestatus to 1 */ -while ((readl (&system_manager_base->noc_idlestatus) ^ +while ((readl (socfpga_sysmgr_base +SYSMGR_S10_NOC_IDLESTATUS ) ^ (SYSMGR_NOC_H2F_MSK |SYSMGR_NOC_LWH2F_MSK ))) ;
@@ -90,7 +88,7 @@ void socfpga_bridges_reset(int enable) RSTMGR_BRGMODRST_FPGA2SOC_MASK));/* Disable NOC timeout */ -writel (0 , &system_manager_base->noc_timeout); +writel (0 , socfpga_sysmgr_base +SYSMGR_S10_NOC_TIMEOUT ); } }
arch/arm/mach-socfpga/scan_manager.c +2 -4
@@ -31,8 +31,6 @@ static const struct socfpga_scan_manager *scan_manager_base = (void *)(SOCFPGA_SCANMGR_ADDRESS );static const struct socfpga_freeze_controller *freeze_controller_base = (void *)(SOCFPGA_SYSMGR_ADDRESS +SYSMGR_FRZCTRL_ADDRESS ); -static struct socfpga_system_manager *sys_mgr_base = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;/** * scan_chain_engine_is_idle() - Check if the JTAG scan chain is idle
@@ -218,7 +216,7 @@ u32 scan_mgr_get_fpga_id(void)int ret;/* Enable HPS to talk to JTAG in the FPGA through the System Manager */ -writel (0x1 , &sys_mgr_base->scanmgrgrp_ctrl); +writel (0x1 , socfpga_sysmgr_base +SYSMGR_GEN5_SCANMGRGRP_CTRL );/* Enable port 7 */ writel (0x80 , &scan_manager_base->en);
@@ -253,7 +251,7 @@ u32 scan_mgr_get_fpga_id(void)/* Disable all port */ writel (0 , &scan_manager_base->en); -writel (0 , &sys_mgr_base->scanmgrgrp_ctrl); +writel (0 , socfpga_sysmgr_base +SYSMGR_GEN5_SCANMGRGRP_CTRL );return id; }
arch/arm/mach-socfpga/spl_a10.c +1 -4
@@ -31,12 +31,9 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -u32 spl_boot_device (void ) { -const u32 bsel =readl (&sysmgr_regs->bootinfo); +const u32 bsel =readl (socfpga_sysmgr_base +SYSMGR_A10_BOOTINFO );switch (SYSMGR_GET_BOOTINFO_BSEL (bsel)) {case 0x1 :/* FPGA (HPS2FPGA Bridge) */
arch/arm/mach-socfpga/spl_gen5.c +4 -7
@@ -24,12 +24,9 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -u32 spl_boot_device (void ) { -const u32 bsel =readl (&sysmgr_regs->bootinfo); +const u32 bsel =readl (socfpga_sysmgr_base +SYSMGR_GEN5_BOOTINFO );switch (SYSMGR_GET_BOOTINFO_BSEL (bsel)) {case 0x1 :/* FPGA (HPS2FPGA Bridge) */
@@ -77,13 +74,13 @@ void board_init_f(ulong dummy)* Clear fake OCRAM ECC first as SBE * and DBE might triggered during power on */ - reg =readl (&sysmgr_regs->eccgrp_ocram); + reg =readl (socfpga_sysmgr_base +SYSMGR_GEN5_ECCGRP_OCRAM );if (reg &SYSMGR_ECC_OCRAM_SERR )writel (SYSMGR_ECC_OCRAM_SERR |SYSMGR_ECC_OCRAM_EN , - &sysmgr_regs->eccgrp_ocram); + socfpga_sysmgr_base +SYSMGR_GEN5_ECCGRP_OCRAM );if (reg &SYSMGR_ECC_OCRAM_DERR )writel (SYSMGR_ECC_OCRAM_DERR |SYSMGR_ECC_OCRAM_EN , - &sysmgr_regs->eccgrp_ocram); + socfpga_sysmgr_base +SYSMGR_GEN5_ECCGRP_OCRAM );socfpga_sdram_remap_zero ();socfpga_pl310_clear ();
arch/arm/mach-socfpga/spl_s10.c +6 -6
@@ -22,9 +22,6 @@DECLARE_GLOBAL_DATA_PTR ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -u32 spl_boot_device (void ) {/* TODO: Get from SDM or handoff */
@@ -129,7 +126,8 @@ void board_init_f(ulong dummy)#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ -writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , &sysmgr_regs->wddbg); +writel (SYSMGR_WDDBG_PAUSE_ALL_CPU , + socfpga_sysmgr_base +SYSMGR_S10_WDDBG );/* Enable watchdog before initializing the HW */ socfpga_per_reset (SOCFPGA_RESET (L4WD0 ),1 );
@@ -157,8 +155,10 @@ void board_init_f(ulong dummy)cm_print_clock_quick_summary ();/* enable non-secure interface to DMA330 DMA and peripherals */ -writel (SYSMGR_DMA_IRQ_NS |SYSMGR_DMA_MGR_NS , &sysmgr_regs->dma); -writel (SYSMGR_DMAPERIPH_ALL_NS , &sysmgr_regs->dma_periph); +writel (SYSMGR_DMA_IRQ_NS |SYSMGR_DMA_MGR_NS , + socfpga_sysmgr_base +SYSMGR_S10_DMA ); +writel (SYSMGR_DMAPERIPH_ALL_NS , + socfpga_sysmgr_base +SYSMGR_S10_DMA_PERIPH );spl_disable_firewall_l4_per ();
arch/arm/mach-socfpga/system_manager_gen5.c +22 -16
@@ -8,9 +8,6 @@#include <asm/arch/system_manager.h> #include <asm/arch/fpga_manager.h> -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * Populate the value for SYSMGR.FPGAINTF.MODULE based on pinmux setting. * The value is not wrote to SYSMGR.FPGAINTF.MODULE but
@@ -21,30 +18,39 @@ static void populate_sysmgr_fpgaintf_module(void)u32 handoff_val =0 ;/* ISWGRP_HANDOFF_FPGAINTF */ -writel (0 , &sysmgr_regs->iswgrp_handoff[2 ]); +writel (0 , socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (2 ));/* Enable the signal for those HPS peripherals that use FPGA. */ -if (readl (&sysmgr_regs->nandusefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_GEN5_NAND_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_NAND ; -if (readl (&sysmgr_regs->rgmii1usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_GEN5_RGMII1_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_EMAC1 ; -if (readl (&sysmgr_regs->sdmmcusefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_GEN5_SDMMC_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_SDMMC ; -if (readl (&sysmgr_regs->rgmii0usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_GEN5_RGMII0_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_EMAC0 ; -if (readl (&sysmgr_regs->spim0usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_GEN5_SPIM0_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_SPIM0 ; -if (readl (&sysmgr_regs->spim1usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_GEN5_SPIM1_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_SPIM1 ;/* populate (not writing) the value for SYSMGR.FPGAINTF.MODULE based on pinmux setting */ -setbits_le32 (&sysmgr_regs->iswgrp_handoff[2 ], handoff_val); +setbits_le32 (socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (2 ), + handoff_val); - handoff_val =readl (&sysmgr_regs->iswgrp_handoff[2 ]); + handoff_val =readl (socfpga_sysmgr_base + +SYSMGR_ISWGRP_HANDOFF_OFFSET (2 ));if (fpgamgr_test_fpga_ready ()) {/* Enable the required signals only */ -writel (handoff_val, &sysmgr_regs->fpgaintfgrp_module); +writel (handoff_val, + socfpga_sysmgr_base +SYSMGR_GEN5_FPGAINFGRP_MODULE ); } }
@@ -53,7 +59,7 @@ static void populate_sysmgr_fpgaintf_module(void)*/ void sysmgr_pinmux_init (void ) { -u32 regs = (u32)&sysmgr_regs->emacio[0 ]; +u32 regs = (u32 )socfpga_sysmgr_base +SYSMGR_GEN5_EMACIO ;const u8 *sys_mgr_init_table;unsigned int len;int i;
@@ -74,9 +80,9 @@ void sysmgr_pinmux_init(void)void sysmgr_config_warmrstcfgio (int enable) {if (enable) -setbits_le32 (&sysmgr_regs->romcodegrp_ctrl, +setbits_le32 (socfpga_sysmgr_base +SYSMGR_GEN5_ROMCODEGRP_CTRL ,SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO );else -clrbits_le32 (&sysmgr_regs->romcodegrp_ctrl, +clrbits_le32 (socfpga_sysmgr_base +SYSMGR_GEN5_ROMCODEGRP_CTRL ,SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO ); }
arch/arm/mach-socfpga/system_manager_s10.c +23 -16
@@ -10,9 +10,6 @@DECLARE_GLOBAL_DATA_PTR ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * Configure all the pin muxes */
@@ -32,24 +29,31 @@ void populate_sysmgr_fpgaintf_module(void)u32 handoff_val =0 ;/* Enable the signal for those HPS peripherals that use FPGA. */ -if (readl (&sysmgr_regs->nandusefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_NAND_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_NAND ; -if (readl (&sysmgr_regs->sdmmcusefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_SDMMC_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_SDMMC ; -if (readl (&sysmgr_regs->spim0usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_SPIM0_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_SPIM0 ; -if (readl (&sysmgr_regs->spim1usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_SPIM1_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_SPIM1 ; -writel (handoff_val, &sysmgr_regs->fpgaintf_en_2); +writel (handoff_val, socfpga_sysmgr_base +SYSMGR_S10_FPGAINTF_EN2 ); handoff_val =0 ; -if (readl (&sysmgr_regs->rgmii0usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_EMAC0_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_EMAC0 ; -if (readl (&sysmgr_regs->rgmii1usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_EMAC1_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_EMAC1 ; -if (readl (&sysmgr_regs->rgmii2usefpga) ==SYSMGR_FPGAINTF_USEFPGA ) +if (readl (socfpga_sysmgr_base +SYSMGR_S10_EMAC2_USEFPGA ) == +SYSMGR_FPGAINTF_USEFPGA ) handoff_val |=SYSMGR_FPGAINTF_EMAC2 ; -writel (handoff_val, &sysmgr_regs->fpgaintf_en_3); +writel (handoff_val, socfpga_sysmgr_base +SYSMGR_S10_FPGAINTF_EN3 ); }/*
@@ -64,14 +68,16 @@ void populate_sysmgr_pinmux(void)sysmgr_pinmux_table_sel (&sys_mgr_table_u32, &len);for (i =0 ; i < len; i = i +2 ) {writel (sys_mgr_table_u32[i +1 ], - sys_mgr_table_u32[i] + (u8 *)&sysmgr_regs->pinsel0[0 ]); + sys_mgr_table_u32[i] + + (u8 *)socfpga_sysmgr_base +SYSMGR_S10_PINSEL0 ); }/* setup the pin ctrl */ sysmgr_pinmux_table_ctrl (&sys_mgr_table_u32, &len);for (i =0 ; i < len; i = i +2 ) {writel (sys_mgr_table_u32[i +1 ], - sys_mgr_table_u32[i] + (u8 *)&sysmgr_regs->ioctrl0[0 ]); + sys_mgr_table_u32[i] + + (u8 *)socfpga_sysmgr_base +SYSMGR_S10_IOCTRL0 ); }/* setup the fpga use */
@@ -79,13 +85,14 @@ void populate_sysmgr_pinmux(void)for (i =0 ; i < len; i = i +2 ) {writel (sys_mgr_table_u32[i +1 ], sys_mgr_table_u32[i] + - (u8 *)&sysmgr_regs->rgmii0usefpga); + (u8 *)socfpga_sysmgr_base +SYSMGR_S10_EMAC0_USEFPGA ); }/* setup the IO delay */ sysmgr_pinmux_table_delay (&sys_mgr_table_u32, &len);for (i =0 ; i < len; i = i +2 ) {writel (sys_mgr_table_u32[i +1 ], - sys_mgr_table_u32[i] + (u8 *)&sysmgr_regs->iodelay0[0 ]); + sys_mgr_table_u32[i] + + (u8 *)socfpga_sysmgr_base +SYSMGR_S10_IODELAY0 ); } }
arch/arm/mach-socfpga/wrap_pll_config_s10.c +4 -7
@@ -10,9 +10,6 @@#include <asm/arch/handoff_s10.h> #include <asm/arch/system_manager.h> -static const struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -const struct cm_config *const cm_get_default_config (void ) { struct cm_config *cm_handoff_cfg = (struct cm_config *)
@@ -38,9 +35,9 @@ const unsigned int cm_get_osc_clk_hz(void)#ifdef CONFIG_SPL_BUILD u32 clock =readl (S10_HANDOFF_CLOCK_OSC ); -writel (clock, &sysmgr_regs->boot_scratch_cold1); +writel (clock, socfpga_sysmgr_base +SYSMGR_S10_BOOT_SCRATCH_COLD1 );#endif -return readl (&sysmgr_regs->boot_scratch_cold1); +return readl (socfpga_sysmgr_base +SYSMGR_S10_BOOT_SCRATCH_COLD1 ); }const unsigned int cm_get_intosc_clk_hz (void )
@@ -53,7 +50,7 @@ const unsigned int cm_get_fpga_clk_hz(void)#ifdef CONFIG_SPL_BUILD u32 clock =readl (S10_HANDOFF_CLOCK_FPGA ); -writel (clock, &sysmgr_regs->boot_scratch_cold2); +writel (clock, socfpga_sysmgr_base +SYSMGR_S10_BOOT_SCRATCH_COLD2 );#endif -return readl (&sysmgr_regs->boot_scratch_cold2); +return readl (socfpga_sysmgr_base +SYSMGR_S10_BOOT_SCRATCH_COLD2 ); }
drivers/ddr/altera/sdram_gen5.c +4 -6
@@ -40,9 +40,6 @@ struct sdram_prot_rule {u32 hi_prot_id; }; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -static unsigned long sdram_calculate_size (struct socfpga_sdr_ctrl *sdr_ctrl);/**
@@ -455,12 +452,13 @@ int sdram_mmr_init_full(struct socfpga_sdr_ctrl *sdr_ctrl,SDR_CTRLGRP_DRAMADDRW_ROWBITS_LSB ;int ret; -writel (rows, &sysmgr_regs->iswgrp_handoff[4 ]); +writel (rows, socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (4 ));sdr_load_regs (sdr_ctrl, cfg);/* saving this value to SYSMGR.ISWGRP.HANDOFF.FPGA2SDR */ -writel (cfg->fpgaport_rst, &sysmgr_regs->iswgrp_handoff[3 ]); +writel (cfg->fpgaport_rst, + socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (3 ));/* only enable if the FPGA is programmed */ if (fpgamgr_test_fpga_ready ()) {
@@ -516,7 +514,7 @@ static unsigned long sdram_calculate_size(struct socfpga_sdr_ctrl *sdr_ctrl)* since the FB specifies we modify ROWBITs to work around SDRAM * controller issue. */ - row =readl (&sysmgr_regs->iswgrp_handoff[4 ]); + row =readl (socfpga_sysmgr_base +SYSMGR_ISWGRP_HANDOFF_OFFSET (4 ));if (row ==0 ) row = rowbits;/*
drivers/ddr/altera/sdram_s10.c +2 -4
@@ -32,9 +32,6 @@ struct altera_sdram_platdata {DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_system_manager *sysmgr_regs = - (void *)SOCFPGA_SYSMGR_ADDRESS ; -#define DDR_CONFIG (A ,B ,C ,R ) (((A) << 24) | ((B) << 16) | ((C) << 8) | (R))#define PGTABLE_OFF 0x4000
@@ -150,7 +147,8 @@ static int emif_reset(struct altera_sdram_platdata *plat)static int poll_hmc_clock_status (void ) { -return wait_for_bit_le32 (&sysmgr_regs->hmc_clk, +return wait_for_bit_le32 ((const void *)(socfpga_sysmgr_base + +SYSMGR_S10_HMC_CLK ),SYSMGR_HMC_CLK_STATUS_MSK , true,1000 , false); }
drivers/fpga/socfpga_arria10.c +2 -5
@@ -30,9 +30,6 @@ DECLARE_GLOBAL_DATA_PTR;static const struct socfpga_fpga_manager *fpga_manager_base = (void *)SOCFPGA_FPGAMGRREGS_ADDRESS ; -static const struct socfpga_system_manager *system_manager_base = - (void *)SOCFPGA_SYSMGR_ADDRESS ; -static void fpgamgr_set_cd_ratio (unsigned long ratio);static uint32_t fpgamgr_get_msel (void )
@@ -818,7 +815,7 @@ int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize, }/* Disable all signals from HPS peripheral controller to FPGA */ -writel (0 , &system_manager_base->fpgaintf_en_global); +writel (0 , socfpga_sysmgr_base +SYSMGR_A10_FPGAINTF_EN_GLOBAL );/* Disable all axi bridges (hps2fpga, lwhps2fpga & fpga2hps) */ socfpga_bridges_reset ();
@@ -910,7 +907,7 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)memset (&rbfinfo,0 ,sizeof (rbfinfo));/* Disable all signals from hps peripheral controller to fpga */ -writel (0 , &system_manager_base->fpgaintf_en_global); +writel (0 , socfpga_sysmgr_base +SYSMGR_A10_FPGAINTF_EN_GLOBAL );/* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */ socfpga_bridges_reset ();
drivers/fpga/socfpga_gen5.c +1 -3
@@ -15,8 +15,6 @@static struct socfpga_fpga_manager *fpgamgr_regs = (struct socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;/* Set CD ratio */ static void fpgamgr_set_cd_ratio (unsigned long ratio)
@@ -214,7 +212,7 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)/* Prior programming the FPGA, all bridges need to be shut off */ /* Disable all signals from hps peripheral controller to fpga */ -writel (0 , &sysmgr_regs->fpgaintfgrp_module); +writel (0 , socfpga_sysmgr_base +SYSMGR_GEN5_FPGAINFGRP_MODULE );/* Disable all signals from FPGA to HPS SDRAM */ #define SDR_CTRLGRP_FPGAPORTRST_ADDRESS 0x5080
drivers/mmc/socfpga_dw_mmc.c +2 -4
@@ -20,8 +20,6 @@ DECLARE_GLOBAL_DATA_PTR;static const struct socfpga_clock_manager *clock_manager_base = (void *)SOCFPGA_CLKMGR_ADDRESS ; -static const struct socfpga_system_manager *system_manager_base = - (void *)SOCFPGA_SYSMGR_ADDRESS ;struct socfpga_dwmci_plat {struct mmc_config cfg;
@@ -61,10 +59,10 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host)debug ("%s: drvsel %d smplsel %d\n" , __func__, priv->drvsel, priv->smplsel); -writel (sdmmc_mask, &system_manager_base->sdmmcgrp_ctrl); +writel (sdmmc_mask, socfpga_sysmgr_base +SYSMGR_SDMMC );debug ("%s: SYSMGR_SDMMCGRP_CTRL_REG = 0x%x\n" , __func__, -readl (&system_manager_base->sdmmcgrp_ctrl)); +readl (socfpga_sysmgr_base +SYSMGR_SDMMC ));/* Enable SDMMC clock */ setbits_le32(&clock_manager_base->per_pll.en,
Signature · 1 line
2.19.0
PATCH v5 3/4 arm: socfpga: Convert system manager from struct to defines
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]
Quoted 24 lines
arch/arm/mach-socfpga/misc_arria10.c +1
-4@@ -28,9 +28,6 @@#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q3_7 0x78#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q4_3 0x98 -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * FPGA programming support for SoC FPGA Arria 10 */ @@ -81,7 +78,7 @@ void socfpga_init_security_policies(void)writel (~0 ,SOCFPGA_NOC_FW_H2F_SCR_OFST );writel (~0 ,SOCFPGA_NOC_FW_H2F_SCR_OFST +4 ); -writel (0x0007FFFF , &sysmgr_regs->ecc_intmask_set); +writel (0x0007FFFF , socfpga_sysmgr_base +SYSMGR_A10_ECC_INTMASK_SET ); }void socfpga_sdram_remap_zero (void )
arch/arm/mach-socfpga/misc_arria10.c int arch_early_init_r(void) · line 105
Quoted 6 lines
arch/arm/mach-socfpga/misc_arria10.c +1
-2@@ -105,8 +102,8 @@ int arch_early_init_r(void)#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) { -const u32 bsel = -SYSMGR_GET_BOOTINFO_BSEL (readl (&sysmgr_regs->bootinfo)); +u32 bootinfo =readl (socfpga_sysmgr_base +SYSMGR_A10_BOOTINFO );
const u32
Quoted 18 lines
arch/arm/mach-socfpga/misc_arria10.c +1
-0+const u32 bsel =SYSMGR_GET_BOOTINFO_BSEL (bootinfo);puts ("CPU: Altera SoCFPGA Arria 10\n" );arch/arm/mach-socfpga/misc_gen5.c +0
-2@@ -28,8 +28,6 @@ DECLARE_GLOBAL_DATA_PTR;static struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;static struct nic301_registers *nic301_regs = (struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS ; static struct scu_registers *scu_regs =
arch/arm/mach-socfpga/misc_gen5.c static int socfpga_fpga_id(const bool print_id) · line 120
Quoted 7 lines
arch/arm/mach-socfpga/misc_gen5.c +2
-2@@ -118,8 +116,8 @@ static int socfpga_fpga_id(const bool print_id)#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) { -const u32 bsel = -SYSMGR_GET_BOOTINFO_BSEL (readl (&sysmgr_regs->bootinfo)); +u32 bootinfo =readl (socfpga_sysmgr_base +SYSMGR_GEN5_BOOTINFO ); +const u32 bsel =SYSMGR_GET_BOOTINFO_BSEL (bootinfo);
Same here , const u32 .
Quoted 2 lines
arch/arm/mach-socfpga/misc_gen5.c +0
-0puts ("CPU: Altera SoCFPGA Platform\n" );socfpga_fpga_id (1 );
[...]
Quoted 15 lines
arch/arm/mach-socfpga/misc_s10.c +0
-3@@ -23,9 +23,6 @@DECLARE_GLOBAL_DATA_PTR ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * FPGA programming support for SoC FPGA Stratix 10 */
arch/arm/mach-socfpga/misc_s10.c static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode) · line 68
Quoted 7 lines
arch/arm/mach-socfpga/misc_s10.c +1
-3@@ -68,9 +65,9 @@ static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode)else return -EINVAL ; -clrsetbits_le32 (&sysmgr_regs->emac0 + gmac_index, -SYSMGR_EMACGRP_CTRL_PHYSEL_MASK , - modereg); + clrsetbits_le32((unsigned long)(socfpga_sysmgr_base + SYSMGR_S10_EMAC0 +
Is the typecast needed at all ?
Also, the typecast should probably apply only on socfpga_sysmgr_base, not the entire expression.
Quoted 5 lines
arch/arm/mach-socfpga/misc_s10.c +2
-0+ gmac_index), + SYSMGR_EMACGRP_CTRL_PHYSEL_MASK, modereg);return 0 ; }
[...]
PATCH v5 3/4 arm: socfpga: Convert system manager from struct to defines
Quoted 25 lines · Marek Vasut
On 11/7/19 3:10 AM, Ley Foon Tan wrote:
[...]Quoted 22 lines
arch/arm/mach-socfpga/misc_arria10.c +1
-4@@ -28,9 +28,6 @@#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q3_7 0x78#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q4_3 0x98 -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * FPGA programming support for SoC FPGA Arria 10 */ @@ -81,7 +78,7 @@ void socfpga_init_security_policies(void)writel (~0 ,SOCFPGA_NOC_FW_H2F_SCR_OFST );writel (~0 ,SOCFPGA_NOC_FW_H2F_SCR_OFST +4 ); -writel (0x0007FFFF , &sysmgr_regs->ecc_intmask_set); +writel (0x0007FFFF , socfpga_sysmgr_base +SYSMGR_A10_ECC_INTMASK_SET ); }
Quoted 10 lines
arch/arm/mach-socfpga/misc_arria10.c int arch_early_init_r(void) · line 105
Quoted 8 lines
arch/arm/mach-socfpga/misc_arria10.c +1
-2void socfpga_sdram_remap_zero (void )@@ -105,8 +102,8 @@ int arch_early_init_r(void)#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) { -const u32 bsel = -SYSMGR_GET_BOOTINFO_BSEL (readl (&sysmgr_regs->bootinfo)); +u32 bootinfo =readl (socfpga_sysmgr_base +SYSMGR_A10_BOOTINFO );const u32
Okay.
Quoted 20 lines
Quoted 20 lines
arch/arm/mach-socfpga/misc_arria10.c +1
-0+const u32 bsel =SYSMGR_GET_BOOTINFO_BSEL (bootinfo);puts ("CPU: Altera SoCFPGA Arria 10\n" );arch/arm/mach-socfpga/misc_gen5.c +0
-2@@ -28,8 +28,6 @@ DECLARE_GLOBAL_DATA_PTR;static struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ;static struct nic301_registers *nic301_regs = (struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS ; static struct scu_registers *scu_regs =@@ -118,8 +116,8 @@ static int socfpga_fpga_id(const bool print_id)#if defined(CONFIG_DISPLAY_CPUINFO )
Quoted 8 lines
arch/arm/mach-socfpga/misc_gen5.c static int socfpga_fpga_id(const bool print_id) · line 120
Quoted 6 lines
arch/arm/mach-socfpga/misc_gen5.c +2
-2int print_cpuinfo (void ) { -const u32 bsel = -SYSMGR_GET_BOOTINFO_BSEL (readl (&sysmgr_regs->bootinfo)); +u32 bootinfo =readl (socfpga_sysmgr_base +SYSMGR_GEN5_BOOTINFO ); +const u32 bsel =SYSMGR_GET_BOOTINFO_BSEL (bootinfo);Same here , const u32 .
Okay.
Quoted 24 lines
Quoted 3 lines
arch/arm/mach-socfpga/misc_gen5.c +0
-0puts ("CPU: Altera SoCFPGA Platform\n" );socfpga_fpga_id (1 );[...]
Quoted 18 lines
arch/arm/mach-socfpga/misc_s10.c +0
-3@@ -23,9 +23,6 @@DECLARE_GLOBAL_DATA_PTR ; -static struct socfpga_system_manager *sysmgr_regs = - (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS ; -/* * FPGA programming support for SoC FPGA Stratix 10 */ @@ -68,9 +65,9 @@ static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode)else return -EINVAL ;
Quoted 8 lines
arch/arm/mach-socfpga/misc_s10.c static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode) · line 68
Quoted 4 lines
arch/arm/mach-socfpga/misc_s10.c +1
-3-clrsetbits_le32 (&sysmgr_regs->emac0 + gmac_index, -SYSMGR_EMACGRP_CTRL_PHYSEL_MASK , - modereg); + clrsetbits_le32((unsigned long)(socfpga_sysmgr_base + SYSMGR_S10_EMAC0 +Is the typecast needed at all ?
Also, the typecast should probably apply only onsocfpga_sysmgr_base, not the entire expression.
You are right, don't need typecase here. Will remove it.
Quoted 8 lines
Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c +2
-0+ gmac_index), + SYSMGR_EMACGRP_CTRL_PHYSEL_MASK, modereg);return 0 ; }[...]
Regards
Ley Foon
PATCH v5 4/4 arm: socfpga: Convert clock manager from struct to defines
In reply to Ley Foon TanConvert clock manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
Change to get clock manager base address from DT node instead of using #define.
---
v5:
- Change macro value to 0x** format.
v4:
- Update commit message about get base address from DT node.
v3:
- Remove "No functional change" in commit description.
v2:
- Revert to use writel(), readl() and etc.
- Get base address from DT.
- Add prefix to defines.
--- arch/arm/mach-socfpga/clock_manager.c | 12 +- arch/arm/mach-socfpga/clock_manager_arria10.c | 156 +++++++------ arch/arm/mach-socfpga/clock_manager_gen5.c | 199 +++++++++-------- arch/arm/mach-socfpga/clock_manager_s10.c | 206 ++++++++++-------- .../mach-socfpga/include/mach/clock_manager.h | 2 + .../include/mach/clock_manager_arria10.h | 133 +++++------ .../include/mach/clock_manager_gen5.h | 112 ++++------ .../include/mach/clock_manager_s10.h | 115 ++++------ arch/arm/mach-socfpga/misc.c | 5 + drivers/mmc/socfpga_dw_mmc.c | 11 +- 10 files changed, 476 insertions(+), 475 deletions(-)
arch/arm/mach-socfpga/clock_manager.c +5 -7
@@ -10,18 +10,15 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_clock_manager *clock_manager_base = - (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS ; -void cm_wait_for_lock (u32 mask) {u32 inter_val;u32 retry =0 ; do { #if defined(CONFIG_TARGET_SOCFPGA_GEN5) - inter_val = readl(&clock_manager_base->inter) & mask; + inter_val = readl(socfpga_clkmgr_base + CLKMGR_INTER) & mask; #else - inter_val = readl(&clock_manager_base->stat) & mask; + inter_val = readl(socfpga_clkmgr_base + CLKMGR_STAT) & mask; #endif /* Wait for stable lock */ if (inter_val == mask)
@@ -36,8 +33,9 @@ void cm_wait_for_lock(u32 mask)/* function to poll in the fsm busy bit */ int cm_wait_for_fsm (void ) { -return wait_for_bit_le32 (&clock_manager_base->stat, -CLKMGR_STAT_BUSY , false,20000 , false); +return wait_for_bit_le32 ((const void *)(socfpga_clkmgr_base + +CLKMGR_STAT ),CLKMGR_STAT_BUSY , false,20000 , + false); }int set_cpu_clk_info (void )
arch/arm/mach-socfpga/clock_manager_arria10.c +85 -71
352 lines not on this page · raw message
arch/arm/mach-socfpga/clock_manager_gen5.c +110 -89
483 lines not on this page · raw message
arch/arm/mach-socfpga/clock_manager_s10.c +120 -86
357 lines not on this page · raw message
arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
@@ -6,6 +6,8 @@#ifndef _CLOCK_MANAGER_H_#define _CLOCK_MANAGER_H_ +extern phys_addr_t socfpga_clkmgr_base; +#ifndef __ASSEMBLER__void cm_wait_for_lock (u32 mask);int cm_wait_for_fsm (void );
arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h +51 -82
145 lines not on this page · raw message
arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h +47 -65
118 lines not on this page · raw message
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +47 -68
122 lines not on this page · raw message
arch/arm/mach-socfpga/misc.c +5 -0
@@ -22,6 +22,7 @@DECLARE_GLOBAL_DATA_PTR ; +phys_addr_t socfpga_clkmgr_base __section(".data"); phys_addr_t socfpga_rstmgr_base __section(".data"); phys_addr_t socfpga_sysmgr_base __section(".data");
@@ -238,4 +239,8 @@ void socfpga_get_manager_addr(void) socfpga_sysmgr_base =socfpga_get_base_addr ("altr,sys-mgr" );if (!socfpga_sysmgr_base)hang (); + + socfpga_clkmgr_base =socfpga_get_base_addr ("altr,clk-mgr" ); +if (!socfpga_clkmgr_base) +hang (); }
drivers/mmc/socfpga_dw_mmc.c +4 -7
@@ -18,9 +18,6 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct socfpga_clock_manager *clock_manager_base = - (void *)SOCFPGA_CLKMGR_ADDRESS ; -struct socfpga_dwmci_plat {struct mmc_config cfg;struct mmc mmc;
@@ -54,8 +51,8 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host) ((priv->drvsel &0x7 ) <<SYSMGR_SDMMC_DRVSEL_SHIFT );/* Disable SDMMC clock. */ -clrbits_le32 (&clock_manager_base->per_pll.en, -CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK ); +clrbits_le32 (socfpga_clkmgr_base +CLKMGR_PERPLL_EN , +CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK );debug ("%s: drvsel %d smplsel %d\n" , __func__, priv->drvsel, priv->smplsel);
@@ -65,8 +62,8 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host) readl(socfpga_sysmgr_base + SYSMGR_SDMMC));/* Enable SDMMC clock */ -setbits_le32 (&clock_manager_base->per_pll.en, -CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK ); +setbits_le32 (socfpga_clkmgr_base +CLKMGR_PERPLL_EN , +CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK ); }static int socfpga_dwmmc_get_clk_rate (struct udevice *dev)
Signature · 1 line
2.19.0