Skip to contentSkip to conversation

arm: socfpga: Convert drivers from struct to defines

PATCH Superseded Ley Foon Tan 4 participants 25 messages Aug 20, 2019 – Aug 28, 2019

Subsystems (5)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover arm: socfpga: Convert drivers from struct to defines

Convert reset, system and clock manager drivers to use #define instead of struct.

No functional change.

Ley Foon Tan (3):
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/mach-socfpga/clock_manager.c         |  12 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c | 217 +++++++++--------
 arch/arm/mach-socfpga/clock_manager_gen5.c    | 221 +++++++++---------
 arch/arm/mach-socfpga/clock_manager_s10.c     | 171 +++++++-------
 .../mach-socfpga/include/mach/clock_manager.h |  15 ++
 .../include/mach/clock_manager_arria10.h      | 129 ++++------
 .../include/mach/clock_manager_gen5.h         | 108 ++++-----
 .../include/mach/clock_manager_s10.h          | 111 ++++-----
 .../mach-socfpga/include/mach/reset_manager.h |  12 +
 .../include/mach/reset_manager_arria10.h      |  41 +---
 .../include/mach/reset_manager_gen5.h         |  20 +-
 .../include/mach/reset_manager_s10.h          |  33 +--
 .../include/mach/system_manager.h             |  15 ++
 .../include/mach/system_manager_arria10.h     |  92 ++------
 .../include/mach/system_manager_gen5.h        | 121 ++--------
 .../include/mach/system_manager_s10.h         | 184 ++++++---------
 arch/arm/mach-socfpga/mailbox_s10.c           |   5 +-
 arch/arm/mach-socfpga/misc_arria10.c          |   7 +-
 arch/arm/mach-socfpga/misc_gen5.c             |  22 +-
 arch/arm/mach-socfpga/misc_s10.c              |   8 +-
 arch/arm/mach-socfpga/reset_manager_arria10.c |  73 +++---
 arch/arm/mach-socfpga/reset_manager_gen5.c    |  33 ++-
 arch/arm/mach-socfpga/reset_manager_s10.c     |  52 ++---
 arch/arm/mach-socfpga/scan_manager.c          |   6 +-
 arch/arm/mach-socfpga/spl_a10.c               |   5 +-
 arch/arm/mach-socfpga/spl_gen5.c              |  15 +-
 arch/arm/mach-socfpga/spl_s10.c               |   9 +-
 arch/arm/mach-socfpga/system_manager_gen5.c   |  33 ++-
 arch/arm/mach-socfpga/system_manager_s10.c    |  32 +--
 arch/arm/mach-socfpga/wrap_pll_config_s10.c   |  11 +-
 drivers/ddr/altera/sdram_gen5.c               |   9 +-
 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                  |  15 +-
 drivers/sysreset/sysreset_socfpga.c           |   6 +-
 36 files changed, 754 insertions(+), 1106 deletions(-)
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +12 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
+#define RSTMGR_READL(reg)			\
+	readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)		\
+	writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)		\
+	clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)		\
+	setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
 void reset_cpu(ulong addr);
 
 void socfpga_per_reset(u32 reset, int set);
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +7 -34

47 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/reset_manager_gen5.h +7 -13
index f4dcb14623..1b308a2b0e 100644
@@ -11,19 +11,13 @@
 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_STATUS		0
+#define RSTMGR_CTRL		4
+#define RSTMGR_MPUMODRST	0x10
+#define RSTMGR_PERMODRST	0x14
+#define RSTMGR_PER2MODRST	0x18
+#define RSTMGR_BRGMODRST	0x1c
+#define RSTMGR_MISCMODRST	0x20
 
 /*
  * SocFPGA Cyclone V/Arria V reset IDs, bank mapping is as follows:
arch/arm/mach-socfpga/include/mach/reset_manager_s10.h +5 -28
index 452147b017..64519c1d92 100644
@@ -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;
-};
+#define RSTMGR_STATUS		0
+#define RSTMGR_MPUMODRST	0x20
+#define RSTMGR_PER0MODRST	0x24
+#define RSTMGR_PER1MODRST	0x28
+#define RSTMGR_BRGMODRST	0x2c
 
 #define RSTMGR_MPUMODRST_CORE0		0
 #define RSTMGR_PER0MODRST_OCP_MASK	0x0020bf00
arch/arm/mach-socfpga/misc_gen5.c +2 -4
index 31681b799d..353c0e7acc 100644
@@ -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,12 @@ 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);
+		RSTMGR_WRITEL(iswgrp_handoff[0], RSTMGR_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);
+		RSTMGR_WRITEL(0, RSTMGR_BRGMODRST);
 		writel(1, &nic301_regs->remap);
 	}
 }
arch/arm/mach-socfpga/reset_manager_arria10.c +22 -27

117 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager_gen5.c +12 -14
index 9a32f5abfe..1d85ac8bd4 100644
@@ -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_MPUMODRST;
 		break;
 	case 1:
-		reg = &reset_manager_base->per_mod_reset;
+		reg = RSTMGR_PERMODRST;
 		break;
 	case 2:
-		reg = &reset_manager_base->per2_mod_reset;
+		reg = RSTMGR_PER2MODRST;
 		break;
 	case 3:
-		reg = &reset_manager_base->brg_mod_reset;
+		reg = RSTMGR_BRGMODRST;
 		break;
 	case 4:
-		reg = &reset_manager_base->misc_mod_reset;
+		reg = RSTMGR_MISCMODRST;
 		break;
 
 	default:
@@ -43,9 +41,9 @@ void socfpga_per_reset(u32 reset, int set)
 	}
 
 	if (set)
-		setbits_le32(reg, 1 << RSTMGR_RESET(reset));
+		RSTMGR_SETBITS(reg, 1 << RSTMGR_RESET(reset));
 	else
-		clrbits_le32(reg, 1 << RSTMGR_RESET(reset));
+		RSTMGR_CLRBITS(reg, 1 << RSTMGR_RESET(reset));
 }
 
 /*
@@ -57,8 +55,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);
+	RSTMGR_WRITEL(~l4wd0, RSTMGR_PERMODRST);
+	RSTMGR_WRITEL(0xffffffff, RSTMGR_PER2MODRST);
 }
 
 #define L3REGS_REMAP_LWHPS2FPGA_MASK	0x10
@@ -95,7 +93,7 @@ void socfpga_bridges_reset(int enable)
 
 	if (enable) {
 		/* brdmodrst */
-		writel(0x7, &reset_manager_base->brg_mod_reset);
+		RSTMGR_WRITEL(0x7, RSTMGR_BRGMODRST);
 		writel(L3REGS_REMAP_OCRAM_MASK, SOCFPGA_L3REGS_ADDRESS);
 	} else {
 		socfpga_bridges_set_handoff_regs(false, false, false);
@@ -109,7 +107,7 @@ void socfpga_bridges_reset(int enable)
 		}
 
 		/* brdmodrst */
-		writel(0, &reset_manager_base->brg_mod_reset);
+		RSTMGR_WRITEL(0, RSTMGR_BRGMODRST);
 
 		/* Remap the bridges into memory map */
 		writel(l3mask, SOCFPGA_L3REGS_ADDRESS);
arch/arm/mach-socfpga/reset_manager_s10.c +16 -19
index 499a84aff5..78a531f747 100644
@@ -12,31 +12,29 @@
 
 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_MPUMODRST;
 	else if (RSTMGR_BANK(reset) == 1)
-		reg = &reset_manager_base->per0modrst;
+		reg = RSTMGR_PER0MODRST;
 	else if (RSTMGR_BANK(reset) == 2)
-		reg = &reset_manager_base->per1modrst;
+		reg = RSTMGR_PER1MODRST;
 	else if (RSTMGR_BANK(reset) == 3)
-		reg = &reset_manager_base->brgmodrst;
+		reg = RSTMGR_BRGMODRST;
 	else	/* Invalid reset register, do nothing */
 		return;
 
 	if (set)
-		setbits_le32(reg, 1 << RSTMGR_RESET(reset));
+		RSTMGR_SETBITS(reg, 1 << RSTMGR_RESET(reset));
 	else
-		clrbits_le32(reg, 1 << RSTMGR_RESET(reset));
+		RSTMGR_CLRBITS(reg, 1 << RSTMGR_RESET(reset));
 }
 
 /*
@@ -49,10 +47,10 @@ void socfpga_per_reset_all(void)
 	const u32 l4wd0 = 1 << RSTMGR_RESET(SOCFPGA_RESET(L4WD0));
 
 	/* 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);
+	RSTMGR_WRITEL(~(l4wd0 | RSTMGR_PER0MODRST_OCP_MASK),
+		      RSTMGR_PER0MODRST);
+	RSTMGR_WRITEL(~l4wd0, RSTMGR_PER0MODRST);
+	RSTMGR_WRITEL(0xffffffff, RSTMGR_PER1MODRST);
 }
 
 void socfpga_bridges_reset(int enable)
@@ -62,7 +60,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);
+		RSTMGR_CLRBITS(RSTMGR_BRGMODRST, ~0);
 
 		/* Poll until all idleack to 0 */
 		while (readl(&system_manager_base->noc_idleack))
@@ -85,9 +83,9 @@ void socfpga_bridges_reset(int enable)
 			;
 
 		/* Reset all bridges (except NOR DDR scheduler & F2S) */
-		setbits_le32(&reset_manager_base->brgmodrst,
-			     ~(RSTMGR_BRGMODRST_DDRSCH_MASK |
-			     RSTMGR_BRGMODRST_FPGA2SOC_MASK));
+		RSTMGR_SETBITS(RSTMGR_BRGMODRST,
+			       ~(RSTMGR_BRGMODRST_DDRSCH_MASK |
+			       RSTMGR_BRGMODRST_FPGA2SOC_MASK));
 
 		/* Disable NOC timeout */
 		writel(0, &system_manager_base->noc_timeout);
@@ -99,6 +97,5 @@ void socfpga_bridges_reset(int enable)
  */
 int cpu_has_been_warmreset(void)
 {
-	return readl(&reset_manager_base->status) &
-		RSTMGR_L4WD_MPU_WARMRESET_MASK;
+	return RSTMGR_READL(RSTMGR_STATUS) & RSTMGR_L4WD_MPU_WARMRESET_MASK;
 }
drivers/sysreset/sysreset_socfpga.c +3 -3
index d6c26a5b23..3390b7bdc2 100644
@@ -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
#2 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 27 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
+#define RSTMGR_READL(reg)			\
+	readl(SOCFPGA_RSTMGR_ADDRESS + (reg))

arch/arm/mach-socfpga/include/mach/reset_manager.h line 20

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +10 -0
+
+#define RSTMGR_WRITEL(data, reg)		\
+	writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)		\
+	clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)		\
+	setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

Quoted 42 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
 void reset_cpu(ulong addr);
 
 void socfpga_per_reset(u32 reset, int set);
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +0 -31
index 6623ebee65..8b72f41498 100644
@@ -14,40 +14,13 @@ int socfpga_reset_deassert_bridges_handoff(void);
 void socfpga_reset_deassert_osc1wd0(void);
 int socfpga_bridges_reset(void);
 
-struct socfpga_reset_manager {
-	u32	stat;
-	u32	ramstat;
-	u32	miscstat;
-	u32	ctrl;
-	u32	hdsken;
-	u32	hdskreq;
-	u32	hdskack;
-	u32	counts;
-	u32	mpumodrst;
-	u32	per0modrst;
-	u32	per1modrst;
-	u32	brgmodrst;
-	u32	sysmodrst;
-	u32	coldmodrst;
-	u32	nrstmodrst;
-	u32	dbgmodrst;
-	u32	mpuwarmmask;
-	u32	per0warmmask;
-	u32	per1warmmask;
-	u32	brgwarmmask;
-	u32	syswarmmask;
-	u32	nrstwarmmask;
-	u32	l3warmmask;
-	u32	tststa;
-	u32	tstscratch;
-	u32	hdsktimeout;
-	u32	hmcintr;
-	u32	hmcintren;
-	u32	hmcintrens;
-	u32	hmcintrenr;

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h int socfpga_reset_deassert_bridges_handoff(void); · line 23

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +7 -3
-	u32	hmcgpout;
-	u32	hmcgpin;
-};
+#define RSTMGR_STATUS		0
+#define RSTMGR_CTRL		0xc
+#define RSTMGR_MPUMODRST	0x20
+#define RSTMGR_PER0MODRST	0x24
+#define RSTMGR_PER1MODRST	0x28
+#define RSTMGR_BRGMODRST	0x2c
+#define RSTMGR_SYSMODRST	0x30

It would be much better to have some SOCFPGA_ prefix here, to clearly identify those macros. Also, you are missing quite a few registers.

[...]

#3 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Marek Vasut <[email protected]> schrieb am Di., 20. Aug. 2019, 11:50:

Quoted 92 lines · Ley Foon Tan
Quoted 17 lines

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/mach-socfpga/include/mach/reset_manager.h

Quoted 9 lines

index 6ad037e325..c460e89d22 100644

arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))

arch/arm/mach-socfpga/include/mach/reset_manager.h line 20

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +10 -0
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

Review

Quoted 4 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
 void reset_cpu(ulong addr);
 
 void socfpga_per_reset(u32 reset, int set);
(quoted diff) +0 -0

b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h

Quoted 43 lines

index 6623ebee65..8b72f41498 100644

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +2 -34
@@ -14,40 +14,13 @@ int socfpga_reset_deassert_bridges_handoff(void);
 void socfpga_reset_deassert_osc1wd0(void);
 int socfpga_bridges_reset(void);
 
-struct socfpga_reset_manager {
-     u32     stat;
-     u32     ramstat;
-     u32     miscstat;
-     u32     ctrl;
-     u32     hdsken;
-     u32     hdskreq;
-     u32     hdskack;
-     u32     counts;
-     u32     mpumodrst;
-     u32     per0modrst;
-     u32     per1modrst;
-     u32     brgmodrst;
-     u32     sysmodrst;
-     u32     coldmodrst;
-     u32     nrstmodrst;
-     u32     dbgmodrst;
-     u32     mpuwarmmask;
-     u32     per0warmmask;
-     u32     per1warmmask;
-     u32     brgwarmmask;
-     u32     syswarmmask;
-     u32     nrstwarmmask;
-     u32     l3warmmask;
-     u32     tststa;
-     u32     tstscratch;
-     u32     hdsktimeout;
-     u32     hmcintr;
-     u32     hmcintren;
-     u32     hmcintrens;
-     u32     hmcintrenr;
-     u32     hmcgpout;
-     u32     hmcgpin;
-};
+#define RSTMGR_STATUS                0
+#define RSTMGR_CTRL          0xc
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h int socfpga_reset_deassert_bridges_handoff(void); · line 23

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +5 -0
+#define RSTMGR_MPUMODRST     0x20
+#define RSTMGR_PER0MODRST    0x24
+#define RSTMGR_PER1MODRST    0x28
+#define RSTMGR_BRGMODRST     0x2c
+#define RSTMGR_SYSMODRST     0x30

It would be much better to have some SOCFPGA_ prefix here, to clearly identify those macros. Also, you are missing quite a few registers.

I agree on the prefix, but I thought leaving away unused registers was one of the positive sides of this change?

That also allows using the same defines for S10 and Agilex even if some registers are different. That's how we came to this patchset, if I remember correctly.

Regards,
Simon

#4 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 110 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Di., 20. Aug. 2019, 11:50:

    On 8/20/19 4:35 AM, Ley Foon Tan wrote:
    > Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct
    > to defines.
    > No functional change.
    >
    > Signed-off-by: Ley Foon Tan <[email protected]
    <mailto:[email protected]>>
    > ---
    >  .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
    >  .../include/mach/reset_manager_arria10.h      | 41 +++-------------
    >  .../include/mach/reset_manager_gen5.h         | 20 +++-----
    >  .../include/mach/reset_manager_s10.h          | 33 ++-----------
    >  arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
    >  arch/arm/mach-socfpga/reset_manager_arria10.c | 49
    +++++++++----------
    >  arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
    >  arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
    >  drivers/sysreset/sysreset_socfpga.c           |  6 +--
    >  9 files changed, 86 insertions(+), 142 deletions(-)
    >
    > diff --git a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    > index 6ad037e325..c460e89d22 100644
    > --- a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    > @@ -6,6 +6,18 @@
    >  #ifndef _RESET_MANAGER_H_
    >  #define _RESET_MANAGER_H_
    > 
    > +#define RSTMGR_READL(reg)                    \
    > +     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
    > +
    > +#define RSTMGR_WRITEL(data, reg)             \
    > +     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
    > +
    > +#define RSTMGR_CLRBITS(reg, mask)            \
    > +     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    > +
    > +#define RSTMGR_SETBITS(reg, mask)            \
    > +     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    > +

    No, don't introduce such macros. Use readl()/writel()/... in the driver.
    The address should come from DT. Besides, there is no type checking in
    such macros.

    >  void reset_cpu(ulong addr);
    > 
    >  void socfpga_per_reset(u32 reset, int set);
    > diff --git
    a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    > index 6623ebee65..8b72f41498 100644
    > --- a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    > @@ -14,40 +14,13 @@ int socfpga_reset_deassert_bridges_handoff(void);
    >  void socfpga_reset_deassert_osc1wd0(void);
    >  int socfpga_bridges_reset(void);
    > 
    > -struct socfpga_reset_manager {
    > -     u32     stat;
    > -     u32     ramstat;
    > -     u32     miscstat;
    > -     u32     ctrl;
    > -     u32     hdsken;
    > -     u32     hdskreq;
    > -     u32     hdskack;
    > -     u32     counts;
    > -     u32     mpumodrst;
    > -     u32     per0modrst;
    > -     u32     per1modrst;
    > -     u32     brgmodrst;
    > -     u32     sysmodrst;
    > -     u32     coldmodrst;
    > -     u32     nrstmodrst;
    > -     u32     dbgmodrst;
    > -     u32     mpuwarmmask;
    > -     u32     per0warmmask;
    > -     u32     per1warmmask;
    > -     u32     brgwarmmask;
    > -     u32     syswarmmask;
    > -     u32     nrstwarmmask;
    > -     u32     l3warmmask;
    > -     u32     tststa;
    > -     u32     tstscratch;
    > -     u32     hdsktimeout;
    > -     u32     hmcintr;
    > -     u32     hmcintren;
    > -     u32     hmcintrens;
    > -     u32     hmcintrenr;
    > -     u32     hmcgpout;
    > -     u32     hmcgpin;
    > -};
    > +#define RSTMGR_STATUS                0
    > +#define RSTMGR_CTRL          0xc
    > +#define RSTMGR_MPUMODRST     0x20
    > +#define RSTMGR_PER0MODRST    0x24
    > +#define RSTMGR_PER1MODRST    0x28
    > +#define RSTMGR_BRGMODRST     0x2c
    > +#define RSTMGR_SYSMODRST     0x30

    It would be much better to have some SOCFPGA_ prefix here, to clearly
    identify those macros. Also, you are missing quite a few registers.
Quoted 6 lines

I agree on the prefix, but I thought leaving away unused registers was one of the positive sides of this change?

That also allows using the same defines for S10 and Agilex even if some registers are different. That's how we came to this patchset, if I remember correctly.

What happens if you want to use that register then ? I guess you can add it to the list, although it feels a bit strange. But maybe that's OK. The different registers should then probably have some SOCFPGA_<SOC>_ prefix or something.

#5 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Marek Vasut <[email protected]> schrieb am Di., 20. Aug. 2019, 12:15:

Quoted 118 lines · Simon Goldschmidt
Quoted 5 lines

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Di., 20. Aug. 2019, 11:50:

Quoted 10 lines
    On 8/20/19 4:35 AM, Ley Foon Tan wrote:
    > Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct
    > to defines.
    > No functional change.
    >
    > Signed-off-by: Ley Foon Tan <[email protected]
    <mailto:[email protected]>>
    > ---
    >  .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
    >  .../include/mach/reset_manager_arria10.h      | 41

+++-------------

Quoted 25 lines
Quoted 4 lines
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49
    +++++++++----------
    >  arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
    >  arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
    >  drivers/sysreset/sysreset_socfpga.c           |  6 +--
    >  9 files changed, 86 insertions(+), 142 deletions(-)
    >
    > diff --git a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    > index 6ad037e325..c460e89d22 100644
    > --- a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    > @@ -6,6 +6,18 @@
    >  #ifndef _RESET_MANAGER_H_
    >  #define _RESET_MANAGER_H_
    >
    > +#define RSTMGR_READL(reg)                    \
    > +     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
    > +
    > +#define RSTMGR_WRITEL(data, reg)             \
    > +     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
    > +
Quoted 8 lines
    > +#define RSTMGR_CLRBITS(reg, mask)            \
    > +     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    > +
    > +#define RSTMGR_SETBITS(reg, mask)            \
    > +     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    > +

    No, don't introduce such macros. Use readl()/writel()/... in the

driver.

Quoted 1 line

The address should come from DT. Besides, there is no type checking

in

Quoted 4 lines
    such macros.

    >  void reset_cpu(ulong addr);
    >
Quoted 8 lines
    >  void socfpga_per_reset(u32 reset, int set);
    > diff --git
    a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    > index 6623ebee65..8b72f41498 100644
    > --- a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    > @@ -14,40 +14,13 @@ int

socfpga_reset_deassert_bridges_handoff(void);

Quoted 52 lines
Quoted 34 lines

void socfpga_reset_deassert_osc1wd0(void);
int socfpga_bridges_reset(void);

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +0 -31
-struct socfpga_reset_manager {
-     u32     stat;
-     u32     ramstat;
-     u32     miscstat;
-     u32     ctrl;
-     u32     hdsken;
-     u32     hdskreq;
-     u32     hdskack;
-     u32     counts;
-     u32     mpumodrst;
-     u32     per0modrst;
-     u32     per1modrst;
-     u32     brgmodrst;
-     u32     sysmodrst;
-     u32     coldmodrst;
-     u32     nrstmodrst;
-     u32     dbgmodrst;
-     u32     mpuwarmmask;
-     u32     per0warmmask;
-     u32     per1warmmask;
-     u32     brgwarmmask;
-     u32     syswarmmask;
-     u32     nrstwarmmask;
-     u32     l3warmmask;
-     u32     tststa;
-     u32     tstscratch;
-     u32     hdsktimeout;
-     u32     hmcintr;
-     u32     hmcintren;
-     u32     hmcintrens;
-     u32     hmcintrenr;

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h int socfpga_reset_deassert_bridges_handoff(void); · line 23

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +7 -3
-     u32     hmcgpout;
-     u32     hmcgpin;
-};
+#define RSTMGR_STATUS                0
+#define RSTMGR_CTRL          0xc
+#define RSTMGR_MPUMODRST     0x20
+#define RSTMGR_PER0MODRST    0x24
+#define RSTMGR_PER1MODRST    0x28
+#define RSTMGR_BRGMODRST     0x2c
+#define RSTMGR_SYSMODRST     0x30

It would be much better to have some SOCFPGA_ prefix here, to clearly identify those macros. Also, you are missing quite a few registers.

I agree on the prefix, but I thought leaving away unused registers was one of the positive sides of this change?

Quoted 7 lines
Quoted 3 lines

That also allows using the same defines for S10 and Agilex even if some registers are different. That's how we came to this patchset, if I remember correctly.

What happens if you want to use that register then ? I guess you can add it to the list, although it feels a bit strange. But maybe that's OK.

Yes, it's a bit strange, but on the other hand, we have some big structs where we only use some registers, and I think that makes it hard to read.

The different registers should

then probably have some SOCFPGA_<SOC>_

Quoted 2 lines

prefix or something.

#6 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 139 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Di., 20. Aug. 2019, 12:15:

    On 8/20/19 11:55 AM, Simon Goldschmidt wrote:
    >
    >
    > Marek Vasut <marex at denx.de <mailto:[email protected]>
    <mailto:marex at denx.de <mailto:[email protected]>>> schrieb am Di., 20.
    > Aug. 2019, 11:50:
    >
    >     On 8/20/19 4:35 AM, Ley Foon Tan wrote:
    >     > Convert reset manager for Gen5, Arria 10 and Stratix 10 from
    struct
    >     > to defines.
    >     > No functional change.
    >     >
    >     > Signed-off-by: Ley Foon Tan <[email protected]
    <mailto:[email protected]>
    >     <mailto:ley.foon.tan at intel.com <mailto:[email protected]>>>
    >     > ---
    >     >  .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
    >     >  .../include/mach/reset_manager_arria10.h      | 41
    +++-------------
    >     >  .../include/mach/reset_manager_gen5.h         | 20 +++-----
    >     >  .../include/mach/reset_manager_s10.h          | 33
    ++-----------
    >     >  arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
    >     >  arch/arm/mach-socfpga/reset_manager_arria10.c | 49
    >     +++++++++----------
    >     >  arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
    >     >  arch/arm/mach-socfpga/reset_manager_s10.c     | 35
    ++++++-------
    >     >  drivers/sysreset/sysreset_socfpga.c           |  6 +--
    >     >  9 files changed, 86 insertions(+), 142 deletions(-)
    >     >
    >     > diff --git a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     > index 6ad037e325..c460e89d22 100644
    >     > --- a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     > @@ -6,6 +6,18 @@
    >     >  #ifndef _RESET_MANAGER_H_
    >     >  #define _RESET_MANAGER_H_
    >     > 
    >     > +#define RSTMGR_READL(reg)                    \
    >     > +     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
    >     > +
    >     > +#define RSTMGR_WRITEL(data, reg)             \
    >     > +     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
    >     > +
    >     > +#define RSTMGR_CLRBITS(reg, mask)            \
    >     > +     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    >     > +
    >     > +#define RSTMGR_SETBITS(reg, mask)            \
    >     > +     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    >     > +
    >
    >     No, don't introduce such macros. Use readl()/writel()/... in
    the driver.
    >     The address should come from DT. Besides, there is no type
    checking in
    >     such macros.
    >
    >     >  void reset_cpu(ulong addr);
    >     > 
    >     >  void socfpga_per_reset(u32 reset, int set);
    >     > diff --git
    >     a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     > index 6623ebee65..8b72f41498 100644
    >     > --- a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     > @@ -14,40 +14,13 @@ int
    socfpga_reset_deassert_bridges_handoff(void);
    >     >  void socfpga_reset_deassert_osc1wd0(void);
    >     >  int socfpga_bridges_reset(void);
    >     > 
    >     > -struct socfpga_reset_manager {
    >     > -     u32     stat;
    >     > -     u32     ramstat;
    >     > -     u32     miscstat;
    >     > -     u32     ctrl;
    >     > -     u32     hdsken;
    >     > -     u32     hdskreq;
    >     > -     u32     hdskack;
    >     > -     u32     counts;
    >     > -     u32     mpumodrst;
    >     > -     u32     per0modrst;
    >     > -     u32     per1modrst;
    >     > -     u32     brgmodrst;
    >     > -     u32     sysmodrst;
    >     > -     u32     coldmodrst;
    >     > -     u32     nrstmodrst;
    >     > -     u32     dbgmodrst;
    >     > -     u32     mpuwarmmask;
    >     > -     u32     per0warmmask;
    >     > -     u32     per1warmmask;
    >     > -     u32     brgwarmmask;
    >     > -     u32     syswarmmask;
    >     > -     u32     nrstwarmmask;
    >     > -     u32     l3warmmask;
    >     > -     u32     tststa;
    >     > -     u32     tstscratch;
    >     > -     u32     hdsktimeout;
    >     > -     u32     hmcintr;
    >     > -     u32     hmcintren;
    >     > -     u32     hmcintrens;
    >     > -     u32     hmcintrenr;
    >     > -     u32     hmcgpout;
    >     > -     u32     hmcgpin;
    >     > -};
    >     > +#define RSTMGR_STATUS                0
    >     > +#define RSTMGR_CTRL          0xc
    >     > +#define RSTMGR_MPUMODRST     0x20
    >     > +#define RSTMGR_PER0MODRST    0x24
    >     > +#define RSTMGR_PER1MODRST    0x28
    >     > +#define RSTMGR_BRGMODRST     0x2c
    >     > +#define RSTMGR_SYSMODRST     0x30
    >
    >     It would be much better to have some SOCFPGA_ prefix here, to
    clearly
    >     identify those macros. Also, you are missing quite a few
    registers.
    >
    >
    > I agree on the prefix, but I thought leaving away unused registers was
    > one of the positive sides of this change?
    >
    > That also allows using the same defines for S10 and Agilex even if
    some
    > registers are different. That's how we came to this patchset, if I
    > remember correctly.

    What happens if you want to use that register then ? I guess you can add
    it to the list, although it feels a bit strange. But maybe that's OK.
Quoted 2 lines

Yes, it's a bit strange, but on the other hand, we have some big structs where we only use some registers, and I think that makes it hard to read.

But at least you can git grep for the registers. Then again, I am not gonna push for complete register lists here, since I know how horrible the e.g. DDR ones are.

#7 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 141 lines · Marek Vasut
Quoted 139 lines · Simon Goldschmidt

Marek Vasut <marex at denx.de <mailto:[email protected]>> schrieb am Di., 20. Aug. 2019, 12:15:

    On 8/20/19 11:55 AM, Simon Goldschmidt wrote:
    >
    >
    > Marek Vasut <marex at denx.de <mailto:[email protected]>
    <mailto:marex at denx.de <mailto:[email protected]>>> schrieb am Di., 20.
    > Aug. 2019, 11:50:
    >
    >     On 8/20/19 4:35 AM, Ley Foon Tan wrote:
    >     > Convert reset manager for Gen5, Arria 10 and Stratix 10 from
    struct
    >     > to defines.
    >     > No functional change.
    >     >
    >     > Signed-off-by: Ley Foon Tan <[email protected]
    <mailto:[email protected]>
    >     <mailto:ley.foon.tan at intel.com <mailto:[email protected]>>>
    >     > ---
    >     >  .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
    >     >  .../include/mach/reset_manager_arria10.h      | 41
    +++-------------
    >     >  .../include/mach/reset_manager_gen5.h         | 20 +++-----
    >     >  .../include/mach/reset_manager_s10.h          | 33
    ++-----------
    >     >  arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
    >     >  arch/arm/mach-socfpga/reset_manager_arria10.c | 49
    >     +++++++++----------
    >     >  arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
    >     >  arch/arm/mach-socfpga/reset_manager_s10.c     | 35
    ++++++-------
    >     >  drivers/sysreset/sysreset_socfpga.c           |  6 +--
    >     >  9 files changed, 86 insertions(+), 142 deletions(-)
    >     >
    >     > diff --git a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     > index 6ad037e325..c460e89d22 100644
    >     > --- a/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager.h
    >     > @@ -6,6 +6,18 @@
    >     >  #ifndef _RESET_MANAGER_H_
    >     >  #define _RESET_MANAGER_H_
    >     >
    >     > +#define RSTMGR_READL(reg)                    \
    >     > +     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
    >     > +
    >     > +#define RSTMGR_WRITEL(data, reg)             \
    >     > +     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
    >     > +
    >     > +#define RSTMGR_CLRBITS(reg, mask)            \
    >     > +     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    >     > +
    >     > +#define RSTMGR_SETBITS(reg, mask)            \
    >     > +     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
    >     > +
    >
    >     No, don't introduce such macros. Use readl()/writel()/... in
    the driver.
    >     The address should come from DT. Besides, there is no type
    checking in
    >     such macros.
    >
    >     >  void reset_cpu(ulong addr);
    >     >
    >     >  void socfpga_per_reset(u32 reset, int set);
    >     > diff --git
    >     a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     > index 6623ebee65..8b72f41498 100644
    >     > --- a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     > +++ b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
    >     > @@ -14,40 +14,13 @@ int
    socfpga_reset_deassert_bridges_handoff(void);
    >     >  void socfpga_reset_deassert_osc1wd0(void);
    >     >  int socfpga_bridges_reset(void);
    >     >
    >     > -struct socfpga_reset_manager {
    >     > -     u32     stat;
    >     > -     u32     ramstat;
    >     > -     u32     miscstat;
    >     > -     u32     ctrl;
    >     > -     u32     hdsken;
    >     > -     u32     hdskreq;
    >     > -     u32     hdskack;
    >     > -     u32     counts;
    >     > -     u32     mpumodrst;
    >     > -     u32     per0modrst;
    >     > -     u32     per1modrst;
    >     > -     u32     brgmodrst;
    >     > -     u32     sysmodrst;
    >     > -     u32     coldmodrst;
    >     > -     u32     nrstmodrst;
    >     > -     u32     dbgmodrst;
    >     > -     u32     mpuwarmmask;
    >     > -     u32     per0warmmask;
    >     > -     u32     per1warmmask;
    >     > -     u32     brgwarmmask;
    >     > -     u32     syswarmmask;
    >     > -     u32     nrstwarmmask;
    >     > -     u32     l3warmmask;
    >     > -     u32     tststa;
    >     > -     u32     tstscratch;
    >     > -     u32     hdsktimeout;
    >     > -     u32     hmcintr;
    >     > -     u32     hmcintren;
    >     > -     u32     hmcintrens;
    >     > -     u32     hmcintrenr;
    >     > -     u32     hmcgpout;
    >     > -     u32     hmcgpin;
    >     > -};
    >     > +#define RSTMGR_STATUS                0
    >     > +#define RSTMGR_CTRL          0xc
    >     > +#define RSTMGR_MPUMODRST     0x20
    >     > +#define RSTMGR_PER0MODRST    0x24
    >     > +#define RSTMGR_PER1MODRST    0x28
    >     > +#define RSTMGR_BRGMODRST     0x2c
    >     > +#define RSTMGR_SYSMODRST     0x30
    >
    >     It would be much better to have some SOCFPGA_ prefix here, to
    clearly
    >     identify those macros. Also, you are missing quite a few
    registers.
    >
    >
    > I agree on the prefix, but I thought leaving away unused registers was
    > one of the positive sides of this change?
    >
    > That also allows using the same defines for S10 and Agilex even if
    some
    > registers are different. That's how we came to this patchset, if I
    > remember correctly.

    What happens if you want to use that register then ? I guess you can add
    it to the list, although it feels a bit strange. But maybe that's OK.
Quoted 6 lines
Quoted 2 lines

Yes, it's a bit strange, but on the other hand, we have some big structs where we only use some registers, and I think that makes it hard to read.

But at least you can git grep for the registers. Then again, I am not gonna push for complete register lists here, since I know how horrible the e.g. DDR ones are.

Yes, prefer not to add all. We can add it later if needs that new register.

Regards
Ley Foon

#8 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

In reply to Marek Vasut
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 16 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 20

Quoted 12 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +12 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

These macros call to writel() and readl() underlying, it just add base address to it.
So, it should have type checking as call writel()/readl() directly? If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Quoted 48 lines
Quoted 48 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
 void reset_cpu(ulong addr);
 
 void socfpga_per_reset(u32 reset, int set);
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +2 -34
index 6623ebee65..8b72f41498 100644
@@ -14,40 +14,13 @@ int socfpga_reset_deassert_bridges_handoff(void);
 void socfpga_reset_deassert_osc1wd0(void);
 int socfpga_bridges_reset(void);
 
-struct socfpga_reset_manager {
-     u32     stat;
-     u32     ramstat;
-     u32     miscstat;
-     u32     ctrl;
-     u32     hdsken;
-     u32     hdskreq;
-     u32     hdskack;
-     u32     counts;
-     u32     mpumodrst;
-     u32     per0modrst;
-     u32     per1modrst;
-     u32     brgmodrst;
-     u32     sysmodrst;
-     u32     coldmodrst;
-     u32     nrstmodrst;
-     u32     dbgmodrst;
-     u32     mpuwarmmask;
-     u32     per0warmmask;
-     u32     per1warmmask;
-     u32     brgwarmmask;
-     u32     syswarmmask;
-     u32     nrstwarmmask;
-     u32     l3warmmask;
-     u32     tststa;
-     u32     tstscratch;
-     u32     hdsktimeout;
-     u32     hmcintr;
-     u32     hmcintren;
-     u32     hmcintrens;
-     u32     hmcintrenr;
-     u32     hmcgpout;
-     u32     hmcgpin;
-};
+#define RSTMGR_STATUS                0
+#define RSTMGR_CTRL          0xc
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h int socfpga_reset_deassert_bridges_handoff(void); · line 23

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +5 -0
+#define RSTMGR_MPUMODRST     0x20
+#define RSTMGR_PER0MODRST    0x24
+#define RSTMGR_PER1MODRST    0x28
+#define RSTMGR_BRGMODRST     0x2c
+#define RSTMGR_SYSMODRST     0x30

It would be much better to have some SOCFPGA_ prefix here, to clearly identify those macros. Also, you are missing quite a few registers.

There are few registers same across all devices and use in their common functions. These common registers need to have same macro names.

For those different registers, they will be something like these (macro names will be longer):
SOCFPGA_A10_RSTMGR_MPUMODRST SOCFPGA_G5_RSTMGR_MPUMODRST SOCFPGA_S10_RSTMGR_MPUMODRST SOCFPGA_AGILEX_RSTMGR_MPUMODRST

Regards
Ley Foon

#9 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 45 lines · Ley Foon Tan
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 16 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 20

Quoted 12 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +12 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

Quoted 7 lines

These macros call to writel() and readl() underlying, it just add base address to it.
So, it should have type checking as call writel()/readl() directly? If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Hi Marek

Do you have further comment for these?

Regards
Ley Foon

Quoted 69 lines
Quoted 48 lines
Quoted 48 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
 void reset_cpu(ulong addr);
 
 void socfpga_per_reset(u32 reset, int set);
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +2 -34
index 6623ebee65..8b72f41498 100644
@@ -14,40 +14,13 @@ int socfpga_reset_deassert_bridges_handoff(void);
 void socfpga_reset_deassert_osc1wd0(void);
 int socfpga_bridges_reset(void);
 
-struct socfpga_reset_manager {
-     u32     stat;
-     u32     ramstat;
-     u32     miscstat;
-     u32     ctrl;
-     u32     hdsken;
-     u32     hdskreq;
-     u32     hdskack;
-     u32     counts;
-     u32     mpumodrst;
-     u32     per0modrst;
-     u32     per1modrst;
-     u32     brgmodrst;
-     u32     sysmodrst;
-     u32     coldmodrst;
-     u32     nrstmodrst;
-     u32     dbgmodrst;
-     u32     mpuwarmmask;
-     u32     per0warmmask;
-     u32     per1warmmask;
-     u32     brgwarmmask;
-     u32     syswarmmask;
-     u32     nrstwarmmask;
-     u32     l3warmmask;
-     u32     tststa;
-     u32     tstscratch;
-     u32     hdsktimeout;
-     u32     hmcintr;
-     u32     hmcintren;
-     u32     hmcintrens;
-     u32     hmcintrenr;
-     u32     hmcgpout;
-     u32     hmcgpin;
-};
+#define RSTMGR_STATUS                0
+#define RSTMGR_CTRL          0xc
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h int socfpga_reset_deassert_bridges_handoff(void); · line 23

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +5 -0
+#define RSTMGR_MPUMODRST     0x20
+#define RSTMGR_PER0MODRST    0x24
+#define RSTMGR_PER1MODRST    0x28
+#define RSTMGR_BRGMODRST     0x2c
+#define RSTMGR_SYSMODRST     0x30

It would be much better to have some SOCFPGA_ prefix here, to clearly identify those macros. Also, you are missing quite a few registers.

There are few registers same across all devices and use in their common functions. These common registers need to have same macro names.

For those different registers, they will be something like these (macro names will be longer):
SOCFPGA_A10_RSTMGR_MPUMODRST SOCFPGA_G5_RSTMGR_MPUMODRST SOCFPGA_S10_RSTMGR_MPUMODRST SOCFPGA_AGILEX_RSTMGR_MPUMODRST

Regards
Ley Foon

#10 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Ley Foon Tan
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 19

Quoted 11 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +11 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)

btw. mask is missing parenthesis, but see below.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 20

Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
+

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

These macros call to writel() and readl() underlying, it just add base address to it.

Right, it just makes the code hardware to read and understand.

Quoted 1 line
Quoted 1 line

So, it should have type checking as call writel()/readl() directly?

The functions in the macro get typechecked. But unlike function arguments, macro arguments are not checked.

Quoted 4 lines
Quoted 4 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

#11 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 48 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Ley Foon Tan
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 19

Quoted 11 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +11 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)

btw. mask is missing parenthesis, but see below.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
+
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

These macros call to writel() and readl() underlying, it just add base address to it.

Right, it just makes the code hardware to read and understand.

Okay, will change it.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

So, it should have type checking as call writel()/readl() directly?

The functions in the macro get typechecked. But unlike function arguments, macro arguments are not checked.

Noted.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

There is plan to convert clock drivers to DM. But, not in this patchset.

Regards
Ley Foon

#12 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 49 lines · Ley Foon Tan
Quoted 48 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Ley Foon Tan
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 19

Quoted 11 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +11 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)

btw. mask is missing parenthesis, but see below.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
+
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

These macros call to writel() and readl() underlying, it just add base address to it.

Right, it just makes the code hardware to read and understand.

Okay, will change it.

It should be easy to do:

$ sed "s at RSTMGR_SETBITS(\([^,]\+\),
\([^)]\+\))@setbits_le32(SOCFPGA_RSTMGR_ADDRESS + \1, \1)@"
$ git add -u ; git commit -sm part1
$ checkpatch -f --fix --fix-inplace <file>
$ git diff # review the fixes
$ git add -u ; git commit --amend #
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

So, it should have type checking as call writel()/readl() directly?

The functions in the macro get typechecked. But unlike function arguments, macro arguments are not checked.

Noted.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

Quoted 1 line

There is plan to convert clock drivers to DM. But, not in this patchset.

Isn't Simon working on that already ?

#13 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 83 lines · Marek Vasut
Quoted 49 lines · Ley Foon Tan
Quoted 48 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Ley Foon Tan
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 19

Quoted 11 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +11 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)

btw. mask is missing parenthesis, but see below.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
+
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

These macros call to writel() and readl() underlying, it just add base address to it.

Right, it just makes the code hardware to read and understand.

Okay, will change it.

It should be easy to do:

$ sed "s at RSTMGR_SETBITS(\([^,]\+\),
\([^)]\+\))@setbits_le32(SOCFPGA_RSTMGR_ADDRESS + \1, \1)@"
$ git add -u ; git commit -sm part1
$ checkpatch -f --fix --fix-inplace <file>
$ git diff # review the fixes
$ git add -u ; git commit --amend #
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

So, it should have type checking as call writel()/readl() directly?

The functions in the macro get typechecked. But unlike function arguments, macro arguments are not checked.

Noted.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

Quoted 7 lines

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

Quoted 1 line

There is plan to convert clock drivers to DM. But, not in this patchset.

Isn't Simon working on that already ?

Our plan is convert S10 clock driver, Simon is working on this?

Regards
Ley Foon

#14 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

On 8/26/19 9:28 AM, Ley Foon Tan wrote:
[...]

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

Quoted 8 lines
Quoted 7 lines

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

Quoted 1 line

There is plan to convert clock drivers to DM. But, not in this patchset.

Isn't Simon working on that already ?

Our plan is convert S10 clock driver, Simon is working on this?

I think he was working on Gen5 clock driver.

#15 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Marek Vasut <[email protected]> schrieb am Mo., 26. Aug. 2019, 10:50:

Quoted 16 lines · Ley Foon Tan

[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

If want to use address from DT, we need get address every time need

to

Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

There is plan to convert clock drivers to DM. But, not in this

patchset.

Quoted 3 lines
Quoted 2 lines

Isn't Simon working on that already ?

Our plan is convert S10 clock driver, Simon is working on this?

I think he was working on Gen5 clock driver.

Right. I have been working on a gen5 click driver only. It's more or less ready to submit, but I'm still facing memory problems because now more uclasses and drivers are active, also the SPL deb got quite big...

Regards,
Simon

Quoted 1 line
#16 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

In reply to Marek Vasut
Quoted 79 lines · Marek Vasut
Quoted 49 lines · Ley Foon Tan
Quoted 48 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Ley Foon Tan
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Convert reset manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 .../mach-socfpga/include/mach/reset_manager.h | 12 +++++
 .../include/mach/reset_manager_arria10.h      | 41 +++-------------
 .../include/mach/reset_manager_gen5.h         | 20 +++-----
 .../include/mach/reset_manager_s10.h          | 33 ++-----------
 arch/arm/mach-socfpga/misc_gen5.c             |  6 +--
 arch/arm/mach-socfpga/reset_manager_arria10.c | 49 +++++++++----------
 arch/arm/mach-socfpga/reset_manager_gen5.c    | 26 +++++-----
 arch/arm/mach-socfpga/reset_manager_s10.c     | 35 ++++++-------
 drivers/sysreset/sysreset_socfpga.c           |  6 +--
 9 files changed, 86 insertions(+), 142 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 6ad037e325..c460e89d22 100644
@@ -6,6 +6,18 @@
 #ifndef _RESET_MANAGER_H_
 #define _RESET_MANAGER_H_
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h line 19

Quoted 11 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +11 -0
+#define RSTMGR_READL(reg)                    \
+     readl(SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_WRITEL(data, reg)             \
+     writel(data, SOCFPGA_RSTMGR_ADDRESS + (reg))
+
+#define RSTMGR_CLRBITS(reg, mask)            \
+     clrbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)
+
+#define RSTMGR_SETBITS(reg, mask)            \
+     setbits_le32(SOCFPGA_RSTMGR_ADDRESS + (reg), mask)

btw. mask is missing parenthesis, but see below.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
+
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

No, don't introduce such macros. Use readl()/writel()/... in the driver. The address should come from DT. Besides, there is no type checking in such macros.

These macros call to writel() and readl() underlying, it just add base address to it.

Right, it just makes the code hardware to read and understand.

Okay, will change it.

It should be easy to do:

$ sed "s at RSTMGR_SETBITS(\([^,]\+\),
\([^)]\+\))@setbits_le32(SOCFPGA_RSTMGR_ADDRESS + \1, \1)@"
$ git add -u ; git commit -sm part1
$ checkpatch -f --fix --fix-inplace <file>
$ git diff # review the fixes
$ git add -u ; git commit --amend #
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

So, it should have type checking as call writel()/readl() directly?

The functions in the macro get typechecked. But unlike function arguments, macro arguments are not checked.

Noted.

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

I am working on this now and found there are 2 challenges if we get base address from DT.
1. We can only get the address from DT after gd->fdt_blob is initialized in spl_early_init(). So, spl_early_init() need move to beginning of board_init_f().
Tested this on Agilex, look okay. But, pending test on other device
families, like Gen5 or A10. Not sure any side effect with this change.
2. Secure (for PSCI) and non-secure functions share same functions, these functions can't use global data (for base address). Secure functions have its own secure data region.
#2 is more difficult to overcome. Do you have strong opinion to get base address from DT? Otherwise, can we use constant define for these base addresses?

Thanks.

Regards
Ley Foon

#17 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

On 8/28/19 10:13 AM, Ley Foon Tan wrote:
[...]

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

Quoted 8 lines
Quoted 3 lines

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

I am working on this now and found there are 2 challenges if we get base address from DT.
1. We can only get the address from DT after gd->fdt_blob is initialized in spl_early_init(). So, spl_early_init() need move to beginning of board_init_f().

This should be reasonably easy to solve I guess ?

Quoted 5 lines

Tested this on Agilex, look okay. But, pending test on other device
families, like Gen5 or A10. Not sure any side effect with this change.
2. Secure (for PSCI) and non-secure functions share same functions, these functions can't use global data (for base address). Secure functions have its own secure data region.

There was a discussion about this before, instead of hacking up this part constantly, maybe we should create a separate build of U-Boot (like SPL/TPL) and use that for the "secure" mode. But that's for another patchset and another discussion.

Quoted 3 lines

#2 is more difficult to overcome. Do you have strong opinion to get base address from DT? Otherwise, can we use constant define for these base addresses?

See above, the secure part might need further work.

#18 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Marek Vasut <[email protected]> schrieb am Mi., 28. Aug. 2019, 14:44:

Quoted 16 lines · Ley Foon Tan

[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

If want to use address from DT, we need get address every time need

to

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

Quoted 8 lines
Quoted 5 lines

I am working on this now and found there are 2 challenges if we get base address from DT.
1. We can only get the address from DT after gd->fdt_blob is initialized in spl_early_init(). So, spl_early_init() need move to beginning of board_init_f().

This should be reasonably easy to solve I guess ?

I did that for gen5 already in my pending patchset. It was kind of easy, although problems like coding bugs or lack of heap are hard to debug as the debug Hart doesn't work that early (no ponmux setup etc.)

Quoted 17 lines
Quoted 5 lines

Tested this on Agilex, look okay. But, pending test on other device
families, like Gen5 or A10. Not sure any side effect with this change.
2. Secure (for PSCI) and non-secure functions share same functions, these functions can't use global data (for base address). Secure functions have its own secure data region.

There was a discussion about this before, instead of hacking up this part constantly, maybe we should create a separate build of U-Boot (like SPL/TPL) and use that for the "secure" mode. But that's for another patchset and another discussion.

Quoted 3 lines

#2 is more difficult to overcome. Do you have strong opinion to get base address from DT? Otherwise, can we use constant define for these base addresses?

See above, the secure part might need further work.

#19 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

In reply to Marek Vasut
Quoted 16 lines · Marek Vasut

On 8/28/19 10:13 AM, Ley Foon Tan wrote:
[...]

Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

If want to use address from DT, we need get address every time need to use the address.
For non-DM, it is easier to use constant address. Let me know if you still prefer to use address from DT.

Surely you can cache the address or even better, convert to DM/DT ?

Will try to cache the address for now. But, we need get address from DT twice, one in SPL, one in Uboot. They not sharing global data.

I don't think there's much we can do about that, unless we can somehow share parsed live DT from SPL to U-Boot, but that's for another discussion/patchset/etc.

Quoted 7 lines
Quoted 5 lines

I am working on this now and found there are 2 challenges if we get base address from DT.
1. We can only get the address from DT after gd->fdt_blob is initialized in spl_early_init(). So, spl_early_init() need move to beginning of board_init_f().

This should be reasonably easy to solve I guess ?

Yes, this shouldn't be tough, just need testing. Make sure it doesn't break anything.

Quoted 11 lines
Quoted 6 lines

Tested this on Agilex, look okay. But, pending test on other device
families, like Gen5 or A10. Not sure any side effect with this change.
2. Secure (for PSCI) and non-secure functions share same functions, these functions can't use global data (for base address). Secure functions have its own secure data region.

There was a discussion about this before, instead of hacking up this part constantly, maybe we should create a separate build of U-Boot (like SPL/TPL) and use that for the "secure" mode. But that's for another patchset and another discussion.

Yes, we have discussion here internally regarding this secure firmware. We plan change the boot flow to include ATF. But, our downstream git still need to maintain this "secure" region for some period (so customer can migrate to new boot flow).
If change to DT address, we need patch our downstream git for these secure functions. :)
Anyway, I will try change for upstream. I'm trying to find where is the proper place to get DT address in Uboot. SPL is more straight forward, get the DT address in board_init_f.

Thanks.

Regards
Ley Foon

Quoted 6 lines
Quoted 4 lines

#2 is more difficult to overcome. Do you have strong opinion to get base address from DT? Otherwise, can we use constant define for these base addresses?

See above, the secure part might need further work.

#20 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

On 8/28/19 3:28 PM, Ley Foon Tan wrote:

[...]

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

Tested this on Agilex, look okay. But, pending test on other device
families, like Gen5 or A10. Not sure any side effect with this change.
2. Secure (for PSCI) and non-secure functions share same functions, these functions can't use global data (for base address). Secure functions have its own secure data region.

There was a discussion about this before, instead of hacking up this part constantly, maybe we should create a separate build of U-Boot (like SPL/TPL) and use that for the "secure" mode. But that's for another patchset and another discussion.

Quoted 9 lines

Yes, we have discussion here internally regarding this secure firmware. We plan change the boot flow to include ATF. But, our downstream git still need to maintain this "secure" region for some period (so customer can migrate to new boot flow).
If change to DT address, we need patch our downstream git for these secure functions. :)
Anyway, I will try change for upstream. I'm trying to find where is the proper place to get DT address in Uboot. SPL is more straight forward, get the DT address in board_init_f.

I have to admit, I have many things to say about ATF and none of them are positive. So it's real sad this is starting to move onto S10 too.

Anyway, one of the fdt_ functions should allow you to fish out the address from DT.

#21 lore raw

PATCH 1/3 arm: socfpga: Convert reset manager from struct to defines

Quoted 25 lines · Marek Vasut

On 8/28/19 3:28 PM, Ley Foon Tan wrote:

[...]

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

Tested this on Agilex, look okay. But, pending test on other device
families, like Gen5 or A10. Not sure any side effect with this change.
2. Secure (for PSCI) and non-secure functions share same functions, these functions can't use global data (for base address). Secure functions have its own secure data region.

There was a discussion about this before, instead of hacking up this part constantly, maybe we should create a separate build of U-Boot (like SPL/TPL) and use that for the "secure" mode. But that's for another patchset and another discussion.

Quoted 9 lines

Yes, we have discussion here internally regarding this secure firmware. We plan change the boot flow to include ATF. But, our downstream git still need to maintain this "secure" region for some period (so customer can migrate to new boot flow).
If change to DT address, we need patch our downstream git for these secure functions. :)
Anyway, I will try change for upstream. I'm trying to find where is the proper place to get DT address in Uboot. SPL is more straight forward, get the DT address in board_init_f.

Quoted 5 lines

I have to admit, I have many things to say about ATF and none of them are positive. So it's real sad this is starting to move onto S10 too.

Anyway, one of the fdt_ functions should allow you to fish out the address from DT.

Yes, we can use fdt_ functions. I got this part working.

Thanks.

Regards
Ley Foon

#22 lore raw

PATCH 2/3 arm: socfpga: Convert system manager from struct to defines

In reply to Ley Foon Tan

Convert system manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 arch/arm/mach-socfpga/clock_manager_s10.c     |   4 +-
 .../include/mach/system_manager.h             |  15 ++
 .../include/mach/system_manager_arria10.h     |  92 +++------
 .../include/mach/system_manager_gen5.h        | 121 ++----------
 .../include/mach/system_manager_s10.h         | 184 +++++++-----------
 arch/arm/mach-socfpga/mailbox_s10.c           |   5 +-
 arch/arm/mach-socfpga/misc_arria10.c          |   7 +-
 arch/arm/mach-socfpga/misc_gen5.c             |  16 +-
 arch/arm/mach-socfpga/misc_s10.c              |   8 +-
 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     |  17 +-
 arch/arm/mach-socfpga/scan_manager.c          |   6 +-
 arch/arm/mach-socfpga/spl_a10.c               |   5 +-
 arch/arm/mach-socfpga/spl_gen5.c              |  15 +-
 arch/arm/mach-socfpga/spl_s10.c               |   9 +-
 arch/arm/mach-socfpga/system_manager_gen5.c   |  33 ++--
 arch/arm/mach-socfpga/system_manager_s10.c    |  32 +--
 arch/arm/mach-socfpga/wrap_pll_config_s10.c   |  11 +-
 drivers/ddr/altera/sdram_gen5.c               |   9 +-
 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 +-
 24 files changed, 217 insertions(+), 426 deletions(-)
arch/arm/mach-socfpga/clock_manager_s10.c +1 -3
index 3ba2a00c02..d8835788cc 100644
@@ -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 SYSMGR_READL(SYSMGR_BOOT_SCRATCH_COLD0);
 }
 
 unsigned int cm_get_spi_controller_clk_hz(void)
arch/arm/mach-socfpga/include/mach/system_manager.h +15 -0
index 7e76df74b7..f2f6bc8aec 100644
@@ -6,6 +6,21 @@
 #ifndef _SYSTEM_MANAGER_H_
 #define _SYSTEM_MANAGER_H_
 
+#define SYSMGR_READL(reg)			\
+	readl(SOCFPGA_SYSMGR_ADDRESS + (reg))
+
+#define SYSMGR_WRITEL(data, reg)		\
+	writel(data, SOCFPGA_SYSMGR_ADDRESS + (reg))
+
+#define SYSMGR_CLRBITS(reg, mask)		\
+	clrbits_le32(SOCFPGA_SYSMGR_ADDRESS + (reg), mask)
+
+#define SYSMGR_SETBITS(reg, mask)		\
+	setbits_le32(SOCFPGA_SYSMGR_ADDRESS + (reg), mask)
+
+#define SYSMGR_CLRSETBITS(reg, clear, set)	\
+	clrsetbits_le32(SOCFPGA_SYSMGR_ADDRESS + (reg), clear, set)
+
 #if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
 #include <asm/arch/system_manager_s10.h>
 #else
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h +25 -67

98 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/system_manager_gen5.h +21 -100

127 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/system_manager_s10.h +65 -119

190 lines not on this page · raw message

arch/arm/mach-socfpga/mailbox_s10.c +1 -4
index 4498ab55df..83ebe33d32 100644
@@ -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,7 @@ 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);
+	SYSMGR_WRITEL(resp_buf[0], SYSMGR_BOOT_SCRATCH_COLD0);
 
 	return 0;
 
arch/arm/mach-socfpga/misc_arria10.c +2 -5
index 2e2a40b65d..e4380145a9 100644
@@ -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);
+	SYSMGR_WRITEL(0x0007FFFF, SYSMGR_ECC_INTMASK_SET);
 }
 
 void socfpga_sdram_remap_zero(void)
@@ -106,7 +103,7 @@ int arch_early_init_r(void)
 int print_cpuinfo(void)
 {
 	const u32 bsel =
-		SYSMGR_GET_BOOTINFO_BSEL(readl(&sysmgr_regs->bootinfo));
+		SYSMGR_GET_BOOTINFO_BSEL(SYSMGR_READL(SYSMGR_BOOTINFO));
 
 	puts("CPU:   Altera SoCFPGA Arria 10\n");
 
arch/arm/mach-socfpga/misc_gen5.c +7 -9
index 353c0e7acc..df9579b84c 100644
@@ -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 =
@@ -119,7 +117,7 @@ static int socfpga_fpga_id(const bool print_id)
 int print_cpuinfo(void)
 {
 	const u32 bsel =
-		SYSMGR_GET_BOOTINFO_BSEL(readl(&sysmgr_regs->bootinfo));
+		SYSMGR_GET_BOOTINFO_BSEL(SYSMGR_READL(SYSMGR_BOOTINFO));
 
 	puts("CPU:   Altera SoCFPGA Platform\n");
 	socfpga_fpga_id(1);
@@ -132,7 +130,7 @@ 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 = SYSMGR_READL(SYSMGR_BOOTINFO) & 0x7;
 	const int fpga_id = socfpga_fpga_id(0);
 	env_set("bootmode", bsel_str[bsel].mode);
 	if (fpga_id >= 0)
@@ -190,10 +188,10 @@ 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);
+	SYSMGR_WRITEL(0xae9efebc, SYSMGR_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] = SYSMGR_READL(SYSMGR_ISWGRP_HANDOFF_OFFSET(i));
 
 	socfpga_bridges_reset(1);
 
@@ -219,15 +217,15 @@ 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]);
+				SYSMGR_READL(SYSMGR_ISWGRP_HANDOFF_OFFSET(i));
 		}
 
-		writel(iswgrp_handoff[2], &sysmgr_regs->fpgaintfgrp_module);
+		SYSMGR_WRITEL(iswgrp_handoff[2], SYSMGR_FPGAINFGRP_MODULE);
 		writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst);
 		RSTMGR_WRITEL(iswgrp_handoff[0], RSTMGR_BRGMODRST);
 		writel(iswgrp_handoff[1], &nic301_regs->remap);
 	} else {
-		writel(0, &sysmgr_regs->fpgaintfgrp_module);
+		SYSMGR_WRITEL(0, SYSMGR_FPGAINFGRP_MODULE);
 		writel(0, &sdr_ctrl->fpgaport_rst);
 		RSTMGR_WRITEL(0, RSTMGR_BRGMODRST);
 		writel(1, &nic301_regs->remap);
arch/arm/mach-socfpga/misc_s10.c +2 -6
index 0a5fab11c0..33cf955f0a 100644
@@ -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,8 @@ 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);
+	SYSMGR_CLRSETBITS((unsigned long)(SYSMGR_EMAC0 + gmac_index),
+			  SYSMGR_EMACGRP_CTRL_PHYSEL_MASK, modereg);
 
 	return 0;
 }
arch/arm/mach-socfpga/reset_manager_arria10.c +12 -12
index 100df81d11..7c1edb60a9 100644
@@ -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;
@@ -96,14 +93,15 @@ int socfpga_reset_deassert_bridges_handoff(void)
 	}
 
 	/* clear idle request to all bridges */
-	setbits_le32(&sysmgr_regs->noc_idlereq_clr, mask_noc);
+	SYSMGR_SETBITS(SYSMGR_NOC_IDLEREQ_CLR, mask_noc);
 
 	/* Release bridges from reset state per handoff value */
 	RSTMGR_CLRBITS(RSTMGR_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_ADDRESS +
+				 SYSMGR_NOC_IDLEACK),
+				 mask_noc, false, 1000, false);
 }
 
 /* Release L4 OSC1 Watchdog Timer 0 from reset through reset manager */
@@ -183,19 +181,20 @@ int socfpga_bridges_reset(void)
 	/* Disable all the bridges (hps2fpga, lwhps2fpga, fpga2hps,
 	   fpga2sdram) */
 	/* set idle request to all bridges */
-	writel(ALT_SYSMGR_NOC_H2F_SET_MSK |
+	SYSMGR_WRITEL(ALT_SYSMGR_NOC_H2F_SET_MSK |
 		ALT_SYSMGR_NOC_LWH2F_SET_MSK |
 		ALT_SYSMGR_NOC_F2H_SET_MSK |
 		ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
 		ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
 		ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
-		&sysmgr_regs->noc_idlereq_set);
+		SYSMGR_NOC_IDLEREQ_SET);
 
 	/* Enable the NOC timeout */
-	writel(ALT_SYSMGR_NOC_TMO_EN_SET_MSK, &sysmgr_regs->noc_timeout);
+	SYSMGR_WRITEL(ALT_SYSMGR_NOC_TMO_EN_SET_MSK, SYSMGR_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_ADDRESS +
+				SYSMGR_NOC_IDLEACK),
 				ALT_SYSMGR_NOC_H2F_SET_MSK |
 				ALT_SYSMGR_NOC_LWH2F_SET_MSK |
 				ALT_SYSMGR_NOC_F2H_SET_MSK |
@@ -207,7 +206,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_ADDRESS +
+				SYSMGR_NOC_IDLESTATUS),
 				ALT_SYSMGR_NOC_H2F_SET_MSK |
 				ALT_SYSMGR_NOC_LWH2F_SET_MSK |
 				ALT_SYSMGR_NOC_F2H_SET_MSK |
@@ -228,7 +228,7 @@ int socfpga_bridges_reset(void)
 			ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK));
 
 	/* Disable NOC timeout */
-	writel(0, &sysmgr_regs->noc_timeout);
+	SYSMGR_WRITEL(0, SYSMGR_NOC_TIMEOUT);
 
 	return 0;
 }
arch/arm/mach-socfpga/reset_manager_gen5.c +2 -5
index 1d85ac8bd4..d8bba9372d 100644
@@ -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)
 {
@@ -81,8 +78,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]);
+	SYSMGR_WRITEL(brgmask, SYSMGR_ISWGRP_HANDOFF_OFFSET(0));
+	SYSMGR_WRITEL(l3rmask, SYSMGR_ISWGRP_HANDOFF_OFFSET(1));
 }
 
 void socfpga_bridges_reset(int enable)
arch/arm/mach-socfpga/reset_manager_s10.c +7 -10
index 78a531f747..229417ddea 100644
@@ -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)
 {
@@ -57,28 +54,28 @@ void socfpga_bridges_reset(int enable)
 {
 	if (enable) {
 		/* clear idle request to all bridges */
-		setbits_le32(&system_manager_base->noc_idlereq_clr, ~0);
+		SYSMGR_SETBITS(SYSMGR_NOC_IDLEREQ_CLR, ~0);
 
 		/* Release all bridges from reset state */
 		RSTMGR_CLRBITS(RSTMGR_BRGMODRST, ~0);
 
 		/* Poll until all idleack to 0 */
-		while (readl(&system_manager_base->noc_idleack))
+		while (SYSMGR_READL(SYSMGR_NOC_IDLEACK))
 			;
 	} else {
 		/* set idle request to all bridges */
-		writel(~0, &system_manager_base->noc_idlereq_set);
+		SYSMGR_WRITEL(~0, SYSMGR_NOC_IDLEREQ_SET);
 
 		/* Enable the NOC timeout */
-		writel(1, &system_manager_base->noc_timeout);
+		SYSMGR_WRITEL(1, SYSMGR_NOC_TIMEOUT);
 
 		/* Poll until all idleack to 1 */
-		while ((readl(&system_manager_base->noc_idleack) ^
+		while ((SYSMGR_READL(SYSMGR_NOC_IDLEACK) ^
 			(SYSMGR_NOC_H2F_MSK | SYSMGR_NOC_LWH2F_MSK)))
 			;
 
 		/* Poll until all idlestatus to 1 */
-		while ((readl(&system_manager_base->noc_idlestatus) ^
+		while ((SYSMGR_READL(SYSMGR_NOC_IDLESTATUS) ^
 			(SYSMGR_NOC_H2F_MSK | SYSMGR_NOC_LWH2F_MSK)))
 			;
 
@@ -88,7 +85,7 @@ void socfpga_bridges_reset(int enable)
 			       RSTMGR_BRGMODRST_FPGA2SOC_MASK));
 
 		/* Disable NOC timeout */
-		writel(0, &system_manager_base->noc_timeout);
+		SYSMGR_WRITEL(0, SYSMGR_NOC_TIMEOUT);
 	}
 }
 
arch/arm/mach-socfpga/scan_manager.c +2 -4
index 52175af48b..7858347706 100644
@@ -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);
+	SYSMGR_WRITEL(0x1, SYSMGR_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);
+	SYSMGR_WRITEL(0, SYSMGR_SCANMGRGRP_CTRL);
 
 	return id;
 }
arch/arm/mach-socfpga/spl_a10.c +1 -4
index b820cb0673..8c5132a923 100644
@@ -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 = SYSMGR_READL(SYSMGR_BOOTINFO);
 
 	switch (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	case 0x1:	/* FPGA (HPS2FPGA Bridge) */
arch/arm/mach-socfpga/spl_gen5.c +6 -9
index 47e63709ad..1e5658200f 100644
@@ -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 = SYSMGR_READL(SYSMGR_BOOTINFO);
 
 	switch (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	case 0x1:	/* FPGA (HPS2FPGA Bridge) */
@@ -71,13 +68,13 @@ void board_init_f(ulong dummy)
 	 * First C code to run. Clear fake OCRAM ECC first as SBE
 	 * and DBE might triggered during power on
 	 */
-	reg = readl(&sysmgr_regs->eccgrp_ocram);
+	reg = SYSMGR_READL(SYSMGR_ECCGRP_OCRAM);
 	if (reg & SYSMGR_ECC_OCRAM_SERR)
-		writel(SYSMGR_ECC_OCRAM_SERR | SYSMGR_ECC_OCRAM_EN,
-		       &sysmgr_regs->eccgrp_ocram);
+		SYSMGR_WRITEL(SYSMGR_ECC_OCRAM_SERR | SYSMGR_ECC_OCRAM_EN,
+			      SYSMGR_ECCGRP_OCRAM);
 	if (reg & SYSMGR_ECC_OCRAM_DERR)
-		writel(SYSMGR_ECC_OCRAM_DERR  | SYSMGR_ECC_OCRAM_EN,
-		       &sysmgr_regs->eccgrp_ocram);
+		SYSMGR_WRITEL(SYSMGR_ECC_OCRAM_DERR  | SYSMGR_ECC_OCRAM_EN,
+			      SYSMGR_ECCGRP_OCRAM);
 
 	socfpga_sdram_remap_zero();
 	socfpga_pl310_clear();
arch/arm/mach-socfpga/spl_s10.c +3 -6
index ec65e1ce64..8669ce0999 100644
@@ -21,9 +21,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 */
@@ -122,7 +119,7 @@ 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);
+	SYSMGR_WRITEL(SYSMGR_WDDBG_PAUSE_ALL_CPU, SYSMGR_WDDBG);
 
 	/* Enable watchdog before initializing the HW */
 	socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
@@ -155,8 +152,8 @@ 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);
+	SYSMGR_WRITEL(SYSMGR_DMA_IRQ_NS | SYSMGR_DMA_MGR_NS, SYSMGR_DMA);
+	SYSMGR_WRITEL(SYSMGR_DMAPERIPH_ALL_NS, SYSMGR_DMA_PERIPH);
 
 	spl_disable_firewall_l4_per();
 
arch/arm/mach-socfpga/system_manager_gen5.c +15 -18
index 9d04aea2a8..442dfb9ead 100644
@@ -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,30 @@ static void populate_sysmgr_fpgaintf_module(void)
 	u32 handoff_val = 0;
 
 	/* ISWGRP_HANDOFF_FPGAINTF */
-	writel(0, &sysmgr_regs->iswgrp_handoff[2]);
+	SYSMGR_WRITEL(0, SYSMGR_ISWGRP_HANDOFF_OFFSET(2));
 
 	/* Enable the signal for those HPS peripherals that use FPGA. */
-	if (readl(&sysmgr_regs->nandusefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_NAND_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_NAND;
-	if (readl(&sysmgr_regs->rgmii1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_RGMII1_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC1;
-	if (readl(&sysmgr_regs->sdmmcusefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_SDMMC_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SDMMC;
-	if (readl(&sysmgr_regs->rgmii0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_RGMII0_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC0;
-	if (readl(&sysmgr_regs->spim0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_SPIM0_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SPIM0;
-	if (readl(&sysmgr_regs->spim1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_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);
+	SYSMGR_SETBITS(SYSMGR_ISWGRP_HANDOFF_OFFSET(2), handoff_val);
 
-	handoff_val = readl(&sysmgr_regs->iswgrp_handoff[2]);
+	handoff_val = SYSMGR_READL(SYSMGR_ISWGRP_HANDOFF_OFFSET(2));
 	if (fpgamgr_test_fpga_ready()) {
 		/* Enable the required signals only */
-		writel(handoff_val, &sysmgr_regs->fpgaintfgrp_module);
+		SYSMGR_WRITEL(handoff_val, SYSMGR_FPGAINFGRP_MODULE);
 	}
 }
 
@@ -53,7 +50,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_ADDRESS + SYSMGR_EMACIO;
 	const u8 *sys_mgr_init_table;
 	unsigned int len;
 	int i;
@@ -74,9 +71,9 @@ void sysmgr_pinmux_init(void)
 void sysmgr_config_warmrstcfgio(int enable)
 {
 	if (enable)
-		setbits_le32(&sysmgr_regs->romcodegrp_ctrl,
-			     SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
+		SYSMGR_SETBITS(SYSMGR_ROMCODEGRP_CTRL,
+			       SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
 	else
-		clrbits_le32(&sysmgr_regs->romcodegrp_ctrl,
-			     SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
+		SYSMGR_CLRBITS(SYSMGR_ROMCODEGRP_CTRL,
+			       SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
 }
arch/arm/mach-socfpga/system_manager_s10.c +16 -16
index 122828c9ce..255b95fe30 100644
@@ -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,24 @@ 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 (SYSMGR_READL(SYSMGR_NAND_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_NAND;
-	if (readl(&sysmgr_regs->sdmmcusefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_SDMMC_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SDMMC;
-	if (readl(&sysmgr_regs->spim0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_SPIM0_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SPIM0;
-	if (readl(&sysmgr_regs->spim1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_SPIM1_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SPIM1;
-	writel(handoff_val, &sysmgr_regs->fpgaintf_en_2);
+	SYSMGR_WRITEL(handoff_val, SYSMGR_FPGAINTF_EN2);
 
 	handoff_val = 0;
-	if (readl(&sysmgr_regs->rgmii0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_EMAC0_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC0;
-	if (readl(&sysmgr_regs->rgmii1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_EMAC1_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC1;
-	if (readl(&sysmgr_regs->rgmii2usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+	if (SYSMGR_READL(SYSMGR_EMAC2_USEFPGA) == SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC2;
-	writel(handoff_val, &sysmgr_regs->fpgaintf_en_3);
+	SYSMGR_WRITEL(handoff_val, SYSMGR_FPGAINTF_EN3);
 }
 
 /*
@@ -64,14 +61,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_ADDRESS + SYSMGR_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_ADDRESS + SYSMGR_IOCTRL0);
 	}
 
 	/* setup the fpga use */
@@ -79,13 +78,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_ADDRESS + SYSMGR_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_ADDRESS + SYSMGR_IODELAY0);
 	}
 }
arch/arm/mach-socfpga/wrap_pll_config_s10.c +4 -7
index 7cafc7dcfc..65952396e9 100644
@@ -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);
+	SYSMGR_WRITEL(clock, SYSMGR_BOOT_SCRATCH_COLD1);
 #endif
-	return readl(&sysmgr_regs->boot_scratch_cold1);
+	return SYSMGR_READL(SYSMGR_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);
+	SYSMGR_WRITEL(clock, SYSMGR_BOOT_SCRATCH_COLD2);
 #endif
-	return readl(&sysmgr_regs->boot_scratch_cold2);
+	return SYSMGR_READL(SYSMGR_BOOT_SCRATCH_COLD2);
 }
drivers/ddr/altera/sdram_gen5.c +3 -6
index fcd89b619d..a9ec29167d 100644
@@ -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,12 @@ 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]);
+	SYSMGR_WRITEL(rows, 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]);
+	SYSMGR_WRITEL(cfg->fpgaport_rst, SYSMGR_ISWGRP_HANDOFF_OFFSET(3));
 
 	/* only enable if the FPGA is programmed */
 	if (fpgamgr_test_fpga_ready()) {
@@ -516,7 +513,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 = SYSMGR_READL(SYSMGR_ISWGRP_HANDOFF_OFFSET(4));
 	if (row == 0)
 		row = rowbits;
 	/*
drivers/ddr/altera/sdram_s10.c +2 -4
index 56cbbac9fe..80fcac655e 100644
@@ -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_ADDRESS +
+				 SYSMGR_HMC_CLK),
 				 SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false);
 }
 
drivers/fpga/socfpga_arria10.c +2 -5
index 5fb9d6a191..8964fd29c9 100644
@@ -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);
+	SYSMGR_WRITEL(0, SYSMGR_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);
+	SYSMGR_WRITEL(0, SYSMGR_FPGAINTF_EN_GLOBAL);
 
 	/* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
 	socfpga_bridges_reset();
drivers/fpga/socfpga_gen5.c +1 -3
index 6d16e0b37f..ff3ededbfa 100644
@@ -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);
+	SYSMGR_WRITEL(0, SYSMGR_FPGAINFGRP_MODULE);
 
 	/* Disable all signals from FPGA to HPS SDRAM */
 #define SDR_CTRLGRP_FPGAPORTRST_ADDRESS	0x5080
drivers/mmc/socfpga_dw_mmc.c +2 -4
index 739c1629a2..1a7436e2f6 100644
@@ -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);
+	SYSMGR_WRITEL(sdmmc_mask, SYSMGR_SDMMC);
 
 	debug("%s: SYSMGR_SDMMCGRP_CTRL_REG = 0x%x\n", __func__,
-		readl(&system_manager_base->sdmmcgrp_ctrl));
+		SYSMGR_READL(SYSMGR_SDMMC));
 
 	/* Enable SDMMC clock */
 	setbits_le32(&clock_manager_base->per_pll.en,
Signature · 1 line
2.19.0
#23 lore raw

PATCH 3/3 arm: socfpga: Convert clock manager from struct to defines

In reply to Ley Foon Tan

Convert clock manager for Gen5, Arria 10 and Stratix 10 from struct to defines.
No functional change.

---
 arch/arm/mach-socfpga/clock_manager.c         |  12 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c | 217 +++++++++--------
 arch/arm/mach-socfpga/clock_manager_gen5.c    | 221 +++++++++---------
 arch/arm/mach-socfpga/clock_manager_s10.c     | 167 +++++++------
 .../mach-socfpga/include/mach/clock_manager.h |  15 ++
 .../include/mach/clock_manager_arria10.h      | 129 ++++------
 .../include/mach/clock_manager_gen5.h         | 108 ++++-----
 .../include/mach/clock_manager_s10.h          | 111 ++++-----
 drivers/mmc/socfpga_dw_mmc.c                  |   9 +-
 9 files changed, 451 insertions(+), 538 deletions(-)
arch/arm/mach-socfpga/clock_manager.c +5 -7
index 9f3c643df8..59779e2175 100644
@@ -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 = CLKMGR_READL(CLKMGR_INTER) & mask;
 #else
-		inter_val = readl(&clock_manager_base->stat) & mask;
+		inter_val = CLKMGR_READL(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_ADDRESS +
+				 CLKMGR_STAT), CLKMGR_STAT_BUSY, false, 20000,
+				 false);
 }
 
 int set_cpu_clk_info(void)
arch/arm/mach-socfpga/clock_manager_arria10.c +105 -112

394 lines not on this page · raw message

arch/arm/mach-socfpga/clock_manager_gen5.c +110 -111

490 lines not on this page · raw message

arch/arm/mach-socfpga/clock_manager_s10.c +81 -86

320 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +15 -0
index dd80e3a767..73ec7dca65 100644
@@ -6,6 +6,21 @@
 #ifndef _CLOCK_MANAGER_H_
 #define _CLOCK_MANAGER_H_
 
+#define CLKMGR_READL(reg)			\
+	readl(SOCFPGA_CLKMGR_ADDRESS + (reg))
+
+#define CLKMGR_WRITEL(data, reg)		\
+	writel(data, SOCFPGA_CLKMGR_ADDRESS + (reg))
+
+#define CLKMGR_CLRBITS(reg, clear)		\
+	clrbits_le32(SOCFPGA_CLKMGR_ADDRESS + (reg), clear)
+
+#define CLKMGR_SETBITS(reg, set)		\
+	setbits_le32(SOCFPGA_CLKMGR_ADDRESS + (reg), set)
+
+#define	CLKMGR_CLRSETBITS(reg, clear, set)	\
+	clrsetbits_le32(SOCFPGA_CLKMGR_ADDRESS + (reg), clear, set)
+
 #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 +47 -82

141 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h +43 -65

114 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +43 -68

118 lines not on this page · raw message

drivers/mmc/socfpga_dw_mmc.c +2 -7
index 1a7436e2f6..8c4a17afa2 100644
@@ -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,7 @@ 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);
+	CLKMGR_CLRBITS(CLKMGR_PERPLL_EN, CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK);
 
 	debug("%s: drvsel %d smplsel %d\n", __func__,
 	      priv->drvsel, priv->smplsel);
@@ -65,8 +61,7 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host)
 		SYSMGR_READL(SYSMGR_SDMMC));
 
 	/* Enable SDMMC clock */
-	setbits_le32(&clock_manager_base->per_pll.en,
-		CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK);
+	CLKMGR_SETBITS(CLKMGR_PERPLL_EN, CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK);
 }
 
 static int socfpga_dwmmc_get_clk_rate(struct udevice *dev)
Signature · 1 line
2.19.0
#24 lore raw

cover arm: socfpga: Convert drivers from struct to defines

In reply to Ley Foon Tan

Ley,

Ley Foon Tan <[email protected]> schrieb am Di., 20. Aug. 2019, 04:35:

Quoted 5 lines

Convert reset, system and clock manager drivers to use #define instead of struct.

No functional change.

It's still holiday season here, it might probably take until September until I find the time to review this.

Regards,
Simon

Quoted 47 lines

Ley Foon Tan (3):
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/mach-socfpga/clock_manager.c         |  12 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c | 217 +++++++++--------
 arch/arm/mach-socfpga/clock_manager_gen5.c    | 221 +++++++++---------
 arch/arm/mach-socfpga/clock_manager_s10.c     | 171 +++++++-------
 .../mach-socfpga/include/mach/clock_manager.h |  15 ++
 .../include/mach/clock_manager_arria10.h      | 129 ++++------
 .../include/mach/clock_manager_gen5.h         | 108 ++++-----
 .../include/mach/clock_manager_s10.h          | 111 ++++-----
 .../mach-socfpga/include/mach/reset_manager.h |  12 +
 .../include/mach/reset_manager_arria10.h      |  41 +---
 .../include/mach/reset_manager_gen5.h         |  20 +-
 .../include/mach/reset_manager_s10.h          |  33 +--
 .../include/mach/system_manager.h             |  15 ++
 .../include/mach/system_manager_arria10.h     |  92 ++------
 .../include/mach/system_manager_gen5.h        | 121 ++--------
 .../include/mach/system_manager_s10.h         | 184 ++++++---------
 arch/arm/mach-socfpga/mailbox_s10.c           |   5 +-
 arch/arm/mach-socfpga/misc_arria10.c          |   7 +-
 arch/arm/mach-socfpga/misc_gen5.c             |  22 +-
 arch/arm/mach-socfpga/misc_s10.c              |   8 +-
 arch/arm/mach-socfpga/reset_manager_arria10.c |  73 +++---
 arch/arm/mach-socfpga/reset_manager_gen5.c    |  33 ++-
 arch/arm/mach-socfpga/reset_manager_s10.c     |  52 ++---
 arch/arm/mach-socfpga/scan_manager.c          |   6 +-
 arch/arm/mach-socfpga/spl_a10.c               |   5 +-
 arch/arm/mach-socfpga/spl_gen5.c              |  15 +-
 arch/arm/mach-socfpga/spl_s10.c               |   9 +-
 arch/arm/mach-socfpga/system_manager_gen5.c   |  33 ++-
 arch/arm/mach-socfpga/system_manager_s10.c    |  32 +--
 arch/arm/mach-socfpga/wrap_pll_config_s10.c   |  11 +-
 drivers/ddr/altera/sdram_gen5.c               |   9 +-
 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                  |  15 +-
 drivers/sysreset/sysreset_socfpga.c           |   6 +-
 36 files changed, 754 insertions(+), 1106 deletions(-)

--
2.19.0