sunxi: H6: dram: remove usage of struct sunxi_ccm_reg
authorAndre Przywara <andre.przywara@arm.com>
Sat, 25 Jan 2025 17:56:14 +0000 (17:56 +0000)
committerTom Rini <trini@konsulko.com>
Mon, 28 Apr 2025 18:45:44 +0000 (12:45 -0600)
The Allwinner H6 DRAM initialisation code uses a complex C struct,
modelling the clock device's register frame. For this SoC, the struct
contains 127 registers, but the DRAM code only uses four of them.

Since we want to get rid of this struct, drop the usage of the struct in
the H6 DRAM code, by using #define'd register names and their offset, and
then adding those names to the base pointer.

This removes one more user of the clock register struct.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
arch/arm/mach-sunxi/dram_sun50i_h6.c

index fbb8651..66a30d8 100644 (file)
@@ -156,34 +156,34 @@ static void mctl_set_master_priority(void)
 
 static void mctl_sys_init(u32 clk_rate)
 {
-       struct sunxi_ccm_reg * const ccm =
-                       (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+       void * const ccm = (void *)SUNXI_CCM_BASE;
        struct sunxi_mctl_com_reg * const mctl_com =
                        (struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
        struct sunxi_mctl_ctl_reg * const mctl_ctl =
                        (struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
 
        /* Put all DRAM-related blocks to reset state */
-       clrbits_le32(&ccm->mbus_cfg, MBUS_ENABLE | MBUS_RESET);
-       clrbits_le32(&ccm->dram_gate_reset, BIT(0));
+       clrbits_le32(ccm + CCU_H6_MBUS_CFG, MBUS_ENABLE | MBUS_RESET);
+       clrbits_le32(ccm + CCU_H6_DRAM_GATE_RESET, BIT(0));
        udelay(5);
-       writel(0, &ccm->dram_gate_reset);
-       clrbits_le32(&ccm->pll5_cfg, CCM_PLL5_CTRL_EN);
-       clrbits_le32(&ccm->dram_clk_cfg, DRAM_MOD_RESET);
+       writel(0, ccm + CCU_H6_DRAM_GATE_RESET);
+       clrbits_le32(ccm + CCU_H6_PLL5_CFG, CCM_PLL5_CTRL_EN);
+       clrbits_le32(ccm + CCU_H6_DRAM_CLK_CFG, DRAM_MOD_RESET);
 
        udelay(5);
 
        /* Set PLL5 rate to doubled DRAM clock rate */
        writel(CCM_PLL5_CTRL_EN | CCM_PLL5_LOCK_EN |
-              CCM_PLL5_CTRL_N(clk_rate * 2 / 24), &ccm->pll5_cfg);
-       mctl_await_completion(&ccm->pll5_cfg, CCM_PLL5_LOCK, CCM_PLL5_LOCK);
+              CCM_PLL5_CTRL_N(clk_rate * 2 / 24), ccm + CCU_H6_PLL5_CFG);
+       mctl_await_completion(ccm + CCU_H6_PLL5_CFG,
+                             CCM_PLL5_LOCK, CCM_PLL5_LOCK);
 
        /* Configure DRAM mod clock */
-       writel(DRAM_CLK_SRC_PLL5, &ccm->dram_clk_cfg);
-       setbits_le32(&ccm->dram_clk_cfg, DRAM_CLK_UPDATE);
-       writel(BIT(RESET_SHIFT), &ccm->dram_gate_reset);
+       writel(DRAM_CLK_SRC_PLL5, ccm + CCU_H6_DRAM_CLK_CFG);
+       setbits_le32(ccm + CCU_H6_DRAM_CLK_CFG, DRAM_CLK_UPDATE);
+       writel(BIT(RESET_SHIFT), ccm + CCU_H6_DRAM_GATE_RESET);
        udelay(5);
-       setbits_le32(&ccm->dram_gate_reset, BIT(0));
+       setbits_le32(ccm + CCU_H6_DRAM_GATE_RESET, BIT(0));
 
        /* Disable all channels */
        writel(0, &mctl_com->maer0);
@@ -191,9 +191,9 @@ static void mctl_sys_init(u32 clk_rate)
        writel(0, &mctl_com->maer2);
 
        /* Configure MBUS and enable DRAM mod reset */
-       setbits_le32(&ccm->mbus_cfg, MBUS_RESET);
-       setbits_le32(&ccm->mbus_cfg, MBUS_ENABLE);
-       setbits_le32(&ccm->dram_clk_cfg, DRAM_MOD_RESET);
+       setbits_le32(ccm + CCU_H6_MBUS_CFG, MBUS_RESET);
+       setbits_le32(ccm + CCU_H6_MBUS_CFG, MBUS_ENABLE);
+       setbits_le32(ccm + CCU_H6_DRAM_CLK_CFG, DRAM_MOD_RESET);
        udelay(5);
 
        /* Unknown hack from the BSP, which enables access of mctl_ctl regs */