Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / include / asm / emif.h
index 7986e6e7949094d23995977f87f78c29435cf466..35424345bf02b0953dce03c6b55bed3d3931d081 100644 (file)
 #ifndef _EMIF_H_
 #define _EMIF_H_
 #include <asm/types.h>
-#include <common.h>
 #include <asm/io.h>
 
 /* Base address */
+#ifndef EMIF1_BASE
 #define EMIF1_BASE                             0x4c000000
+#endif
 #define EMIF2_BASE                             0x4d000000
 
 #define EMIF_4D                                        0x4
 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK  (0xFF << 4)
 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12
 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK    (0xFFFFF << 12)
+#define EMIF_DDR_PHY_CTRL_1_WRLVL_MASK_SHIFT           25
+#define EMIF_DDR_PHY_CTRL_1_WRLVL_MASK_MASK            (1 << 25)
+#define EMIF_DDR_PHY_CTRL_1_RDLVLGATE_MASK_SHIFT       26
+#define EMIF_DDR_PHY_CTRL_1_RDLVLGATE_MASK_MASK                (1 << 26)
+#define EMIF_DDR_PHY_CTRL_1_RDLVL_MASK_SHIFT           27
+#define EMIF_DDR_PHY_CTRL_1_RDLVL_MASK_MASK            (1 << 27)
 
 /* DDR_PHY_CTRL_2 */
 #define EMIF_REG_DDR_PHY_CTRL_2_SHIFT          0
 
 /* Memory Adapter */
 #define MA_BASE                                0x482AF040
+#define MA_PRIORITY                    0x482A2000
+#define MA_HIMEM_INTERLEAVE_UN_SHIFT   8
+#define MA_HIMEM_INTERLEAVE_UN_MASK    (1 << 8)
 
 /* DMM_LISA_MAP */
 #define EMIF_SYS_ADDR_SHIFT            24
 
 #define EMIF_EXT_PHY_CTRL_TIMING_REG   0x5
 
+/* EMIF ECC CTRL reg */
+#define EMIF_ECC_CTRL_REG_ECC_EN_SHIFT                 31
+#define EMIF_ECC_CTRL_REG_ECC_EN_MASK                  (1 << 31)
+#define EMIF_ECC_CTRL_REG_ECC_ADDR_RGN_PROT_SHIFT      30
+#define EMIF_ECC_CTRL_REG_ECC_ADDR_RGN_PROT_MASK       (1 << 30)
+#define EMIF_ECC_CTRL_REG_ECC_VERIFY_DIS_SHIFT         29
+#define EMIF_ECC_CTRL_REG_ECC_VERIFY_DIS_MASK          (1 << 29)
+#define EMIF_ECC_REG_RMW_EN_SHIFT                      28
+#define EMIF_ECC_REG_RMW_EN_MASK                       (1 << 28)
+#define EMIF_ECC_REG_ECC_ADDR_RGN_2_EN_SHIFT           1
+#define EMIF_ECC_REG_ECC_ADDR_RGN_2_EN_MASK            (1 << 1)
+#define EMIF_ECC_REG_ECC_ADDR_RGN_1_EN_SHIFT           0
+#define EMIF_ECC_REG_ECC_ADDR_RGN_1_EN_MASK            (1 << 0)
+
+/* EMIF ECC ADDRESS RANGE */
+#define EMIF_ECC_REG_ECC_END_ADDR_SHIFT                        16
+#define EMIF_ECC_REG_ECC_END_ADDR_MASK                 (0xffff << 16)
+#define EMIF_ECC_REG_ECC_START_ADDR_SHIFT              0
+#define EMIF_ECC_REG_ECC_START_ADDR_MASK               (0xffff << 0)
+
+/* EMIF_SYSTEM_OCP_INTERRUPT_RAW_STATUS */
+#define EMIF_INT_ONEBIT_ECC_ERR_SYS_SHIFT              5
+#define EMIF_INT_ONEBIT_ECC_ERR_SYS_MASK               (1 << 5)
+#define EMIF_INT_TWOBIT_ECC_ERR_SYS_SHIFT              4
+#define EMIF_INT_TWOBIT_ECC_ERR_SYS_MASK               (1 << 4)
+#define EMIF_INT_WR_ECC_ERR_SYS_SHIFT                  3
+#define EMIF_INT_WR_ECC_ERR_SYS_MASK                   (1 << 3)
+
 /* Reg mapping structure */
 struct emif_reg_struct {
        u32 emif_mod_id_rev;
@@ -655,12 +693,27 @@ struct emif_reg_struct {
        u32 emif_prio_class_serv_map;
        u32 emif_connect_id_serv_1_map;
        u32 emif_connect_id_serv_2_map;
-       u32 padding8[5];
+       u32 padding8;
+       u32 emif_ecc_ctrl_reg;
+       u32 emif_ecc_address_range_1;
+       u32 emif_ecc_address_range_2;
+       u32 padding8_1;
        u32 emif_rd_wr_exec_thresh;
        u32 emif_cos_config;
+#if defined(CONFIG_DRA7XX) || defined(CONFIG_ARCH_KEYSTONE)
+       u32 padding9[2];
+       u32 emif_1b_ecc_err_cnt;
+       u32 emif_1b_ecc_err_thrush;
+       u32 emif_1b_ecc_err_dist_1;
+       u32 emif_1b_ecc_err_addr_log;
+       u32 emif_2b_ecc_err_addr_log;
+       u32 emif_ddr_phy_status[28];
+       u32 padding10[19];
+#else
        u32 padding9[6];
        u32 emif_ddr_phy_status[28];
        u32 padding10[20];
+#endif
        u32 emif_ddr_ext_phy_ctrl_1;
        u32 emif_ddr_ext_phy_ctrl_1_shdw;
        u32 emif_ddr_ext_phy_ctrl_2;
@@ -905,8 +958,8 @@ struct dmm_lisa_map_regs {
 
 /* Maximum delay before Low Power Modes */
 #define REG_CS_TIM             0x0
-#define REG_SR_TIM             0x0
-#define REG_PD_TIM             0x0
+#define REG_SR_TIM             0xF
+#define REG_PD_TIM             0xF
 
 
 /* EMIF_PWR_MGMT_CTRL register */
@@ -914,7 +967,7 @@ struct dmm_lisa_map_regs {
        ((REG_CS_TIM << EMIF_REG_CS_TIM_SHIFT) & EMIF_REG_CS_TIM_MASK)|\
        ((REG_SR_TIM << EMIF_REG_SR_TIM_SHIFT) & EMIF_REG_SR_TIM_MASK)|\
        ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
-       ((LP_MODE_DISABLE << EMIF_REG_LP_MODE_SHIFT)\
+       ((LP_MODE_SELF_REFRESH << EMIF_REG_LP_MODE_SHIFT)\
                        & EMIF_REG_LP_MODE_MASK) |\
        ((DPD_DISABLE << EMIF_REG_DPD_EN_SHIFT)\
                        & EMIF_REG_DPD_EN_MASK))\
@@ -1162,6 +1215,7 @@ struct emif_regs {
        u32 sdram_tim1;
        u32 sdram_tim2;
        u32 sdram_tim3;
+       u32 ocp_config;
        u32 read_idle_ctrl;
        u32 zq_config;
        u32 temp_alert_config;
@@ -1180,6 +1234,9 @@ struct emif_regs {
        u32 emif_connect_id_serv_1_map;
        u32 emif_connect_id_serv_2_map;
        u32 emif_cos_config;
+       u32 emif_ecc_ctrl_reg;
+       u32 emif_ecc_address_range_1;
+       u32 emif_ecc_address_range_2;
 };
 
 struct lpddr2_mr_regs {