ram: stm32mp1_ddr: fix self refresh disable during DQS training
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 6 Mar 2020 10:14:09 +0000 (11:14 +0100)
committerPatrick Delaunay <patrick.delaunay@st.com>
Tue, 24 Mar 2020 13:23:18 +0000 (14:23 +0100)
DDRCTRL_PWRCTL.SELFREF_EN needs to be reset before DQS training step, not
to enter in self refresh mode during the execution of this phase.
Depending on settings, it can be set after the DQS training.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
drivers/ram/stm32mp1/stm32mp1_ddr.c
drivers/ram/stm32mp1/stm32mp1_ddr_regs.h

index a87914f..b9300dd 100644 (file)
@@ -639,7 +639,8 @@ void stm32mp1_refresh_disable(struct stm32mp1_ddrctl *ctl)
        start_sw_done(ctl);
        /* quasi-dynamic register update*/
        setbits_le32(&ctl->rfshctl3, DDRCTRL_RFSHCTL3_DIS_AUTO_REFRESH);
-       clrbits_le32(&ctl->pwrctl, DDRCTRL_PWRCTL_POWERDOWN_EN);
+       clrbits_le32(&ctl->pwrctl, DDRCTRL_PWRCTL_POWERDOWN_EN |
+                                  DDRCTRL_PWRCTL_SELFREF_EN);
        clrbits_le32(&ctl->dfimisc, DDRCTRL_DFIMISC_DFI_INIT_COMPLETE_EN);
        wait_sw_done_ack(ctl);
 }
@@ -652,6 +653,8 @@ void stm32mp1_refresh_restore(struct stm32mp1_ddrctl *ctl,
                clrbits_le32(&ctl->rfshctl3, DDRCTRL_RFSHCTL3_DIS_AUTO_REFRESH);
        if (pwrctl & DDRCTRL_PWRCTL_POWERDOWN_EN)
                setbits_le32(&ctl->pwrctl, DDRCTRL_PWRCTL_POWERDOWN_EN);
+       if ((pwrctl & DDRCTRL_PWRCTL_SELFREF_EN))
+               setbits_le32(&ctl->pwrctl, DDRCTRL_PWRCTL_SELFREF_EN);
        setbits_le32(&ctl->dfimisc, DDRCTRL_DFIMISC_DFI_INIT_COMPLETE_EN);
        wait_sw_done_ack(ctl);
 }
index 9d33186..afd93c5 100644 (file)
@@ -260,6 +260,7 @@ struct stm32mp1_ddrphy {
 
 #define DDRCTRL_MRSTAT_MR_WR_BUSY              BIT(0)
 
+#define DDRCTRL_PWRCTL_SELFREF_EN              BIT(0)
 #define DDRCTRL_PWRCTL_POWERDOWN_EN            BIT(1)
 #define DDRCTRL_PWRCTL_SELFREF_SW              BIT(5)