Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Uri Mashiach | dd587fa | 2017-09-24 09:00:23 +0300 | [diff] [blame] | 2 | /* |
| 3 | * DDR controller registers of the i.MX7 architecture |
| 4 | * |
| 5 | * (C) Copyright 2017 CompuLab, Ltd. http://www.compulab.com |
| 6 | * |
| 7 | * Author: Uri Mashiach <uri.mashiach@compulab.co.il> |
Uri Mashiach | dd587fa | 2017-09-24 09:00:23 +0300 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __ASM_ARCH_MX7_DDR_H__ |
| 11 | #define __ASM_ARCH_MX7_DDR_H__ |
| 12 | |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame^] | 13 | #ifndef __ASSEMBLY__ |
| 14 | #include <linux/bitops.h> |
| 15 | #endif |
| 16 | |
Uri Mashiach | dd587fa | 2017-09-24 09:00:23 +0300 | [diff] [blame] | 17 | /* DDRC Registers (DDRC_IPS_BASE_ADDR) */ |
| 18 | struct ddrc { |
| 19 | u32 mstr; /* 0x0000 */ |
| 20 | u32 reserved1[0x18]; |
| 21 | u32 rfshtmg; /* 0x0064 */ |
| 22 | u32 reserved2[0x1a]; |
| 23 | u32 init0; /* 0x00d0 */ |
| 24 | u32 init1; /* 0x00d4 */ |
| 25 | u32 reserved3; |
| 26 | u32 init3; /* 0x00dc */ |
| 27 | u32 init4; /* 0x00e0 */ |
| 28 | u32 init5; /* 0x00e4 */ |
| 29 | u32 reserved4[0x03]; |
| 30 | u32 rankctl; /* 0x00f4 */ |
| 31 | u32 reserved5[0x02]; |
| 32 | u32 dramtmg0; /* 0x0100 */ |
| 33 | u32 dramtmg1; /* 0x0104 */ |
| 34 | u32 dramtmg2; /* 0x0108 */ |
| 35 | u32 dramtmg3; /* 0x010c */ |
| 36 | u32 dramtmg4; /* 0x0110 */ |
| 37 | u32 dramtmg5; /* 0x0114 */ |
| 38 | u32 reserved6[0x02]; |
| 39 | u32 dramtmg8; /* 0x0120 */ |
| 40 | u32 reserved7[0x17]; |
| 41 | u32 zqctl0; /* 0x0180 */ |
| 42 | u32 reserved8[0x03]; |
| 43 | u32 dfitmg0; /* 0x0190 */ |
| 44 | u32 dfitmg1; /* 0x0194 */ |
| 45 | u32 reserved9[0x02]; |
| 46 | u32 dfiupd0; /* 0x01a0 */ |
| 47 | u32 dfiupd1; /* 0x01a4 */ |
| 48 | u32 dfiupd2; /* 0x01a8 */ |
| 49 | u32 reserved10[0x15]; |
| 50 | u32 addrmap0; /* 0x0200 */ |
| 51 | u32 addrmap1; /* 0x0204 */ |
| 52 | u32 addrmap2; /* 0x0208 */ |
| 53 | u32 addrmap3; /* 0x020c */ |
| 54 | u32 addrmap4; /* 0x0210 */ |
| 55 | u32 addrmap5; /* 0x0214 */ |
| 56 | u32 addrmap6; /* 0x0218 */ |
| 57 | u32 reserved12[0x09]; |
| 58 | u32 odtcfg; /* 0x0240 */ |
| 59 | u32 odtmap; /* 0x0244 */ |
| 60 | }; |
| 61 | |
| 62 | /* DDRC_MSTR fields */ |
| 63 | #define MSTR_DATA_BUS_WIDTH_MASK 0x3 << 12 |
| 64 | #define MSTR_DATA_BUS_WIDTH_SHIFT 12 |
| 65 | #define MSTR_DATA_ACTIVE_RANKS_MASK 0xf << 24 |
| 66 | #define MSTR_DATA_ACTIVE_RANKS_SHIFT 24 |
| 67 | /* DDRC_ADDRMAP1 fields */ |
| 68 | #define ADDRMAP1_BANK_B0_MASK 0x1f << 0 |
| 69 | #define ADDRMAP1_BANK_B0_SHIFT 0 |
| 70 | #define ADDRMAP1_BANK_B1_MASK 0x1f << 8 |
| 71 | #define ADDRMAP1_BANK_B1_SHIFT 8 |
| 72 | #define ADDRMAP1_BANK_B2_MASK 0x1f << 16 |
| 73 | #define ADDRMAP1_BANK_B2_SHIFT 16 |
| 74 | /* DDRC_ADDRMAP2 fields */ |
| 75 | #define ADDRMAP2_COL_B2_MASK 0xF << 0 |
| 76 | #define ADDRMAP2_COL_B2_SHIFT 0 |
| 77 | #define ADDRMAP2_COL_B3_MASK 0xF << 8 |
| 78 | #define ADDRMAP2_COL_B3_SHIFT 8 |
| 79 | #define ADDRMAP2_COL_B4_MASK 0xF << 16 |
| 80 | #define ADDRMAP2_COL_B4_SHIFT 16 |
| 81 | #define ADDRMAP2_COL_B5_MASK 0xF << 24 |
| 82 | #define ADDRMAP2_COL_B5_SHIFT 24 |
| 83 | /* DDRC_ADDRMAP3 fields */ |
| 84 | #define ADDRMAP3_COL_B6_MASK 0xF << 0 |
| 85 | #define ADDRMAP3_COL_B6_SHIFT 0 |
| 86 | #define ADDRMAP3_COL_B7_MASK 0xF << 8 |
| 87 | #define ADDRMAP3_COL_B7_SHIFT 8 |
| 88 | #define ADDRMAP3_COL_B8_MASK 0xF << 16 |
| 89 | #define ADDRMAP3_COL_B8_SHIFT 16 |
| 90 | #define ADDRMAP3_COL_B9_MASK 0xF << 24 |
| 91 | #define ADDRMAP3_COL_B9_SHIFT 24 |
| 92 | /* DDRC_ADDRMAP4 fields */ |
| 93 | #define ADDRMAP4_COL_B10_MASK 0xF << 0 |
| 94 | #define ADDRMAP4_COL_B10_SHIFT 0 |
| 95 | #define ADDRMAP4_COL_B11_MASK 0xF << 8 |
| 96 | #define ADDRMAP4_COL_B11_SHIFT 8 |
| 97 | /* DDRC_ADDRMAP5 fields */ |
| 98 | #define ADDRMAP5_ROW_B0_MASK 0xF << 0 |
| 99 | #define ADDRMAP5_ROW_B0_SHIFT 0 |
| 100 | #define ADDRMAP5_ROW_B1_MASK 0xF << 8 |
| 101 | #define ADDRMAP5_ROW_B1_SHIFT 8 |
| 102 | #define ADDRMAP5_ROW_B2_10_MASK 0xF << 16 |
| 103 | #define ADDRMAP5_ROW_B2_10_SHIFT 16 |
| 104 | #define ADDRMAP5_ROW_B11_MASK 0xF << 24 |
| 105 | #define ADDRMAP5_ROW_B11_SHIFT 24 |
| 106 | /* DDRC_ADDRMAP6 fields */ |
| 107 | #define ADDRMAP6_ROW_B12_MASK 0xF << 0 |
| 108 | #define ADDRMAP6_ROW_B12_SHIFT 0 |
| 109 | #define ADDRMAP6_ROW_B13_MASK 0xF << 8 |
| 110 | #define ADDRMAP6_ROW_B13_SHIFT 8 |
| 111 | #define ADDRMAP6_ROW_B14_MASK 0xF << 16 |
| 112 | #define ADDRMAP6_ROW_B14_SHIFT 16 |
| 113 | #define ADDRMAP6_ROW_B15_MASK 0xF << 24 |
| 114 | #define ADDRMAP6_ROW_B15_SHIFT 24 |
| 115 | |
| 116 | /* DDRC_MP Registers */ |
| 117 | #define DDRC_MP_BASE_ADDR (DDRC_IPS_BASE_ADDR + 0x03fc) |
| 118 | struct ddrc_mp { |
| 119 | u32 reserved1[0x25]; |
| 120 | u32 pctrl_0; /* 0x0094 */ |
| 121 | }; |
| 122 | |
| 123 | /* DDR_PHY registers */ |
| 124 | struct ddr_phy { |
| 125 | u32 phy_con0; /* 0x0000 */ |
| 126 | u32 phy_con1; /* 0x0004 */ |
| 127 | u32 reserved1[0x02]; |
| 128 | u32 phy_con4; /* 0x0010 */ |
| 129 | u32 reserved2; |
| 130 | u32 offset_lp_con0; /* 0x0018 */ |
| 131 | u32 reserved3; |
| 132 | u32 offset_rd_con0; /* 0x0020 */ |
| 133 | u32 reserved4[0x03]; |
| 134 | u32 offset_wr_con0; /* 0x0030 */ |
| 135 | u32 reserved5[0x07]; |
| 136 | u32 cmd_sdll_con0; /* 0x0050 */ |
| 137 | u32 reserved6[0x12]; |
| 138 | u32 drvds_con0; /* 0x009c */ |
| 139 | u32 reserved7[0x04]; |
| 140 | u32 mdll_con0; /* 0x00b0 */ |
| 141 | u32 reserved8[0x03]; |
| 142 | u32 zq_con0; /* 0x00c0 */ |
| 143 | }; |
| 144 | |
| 145 | #define DDR_PHY_CMD_SDLL_CON0_CTRL_RESYNC_MASK BIT(24) |
| 146 | |
| 147 | #define MX7_CAL_VAL_MAX 5 |
| 148 | /* Calibration parameters */ |
| 149 | struct mx7_calibration { |
| 150 | int num_val; /* Number of calibration values */ |
| 151 | u32 values[MX7_CAL_VAL_MAX]; /* calibration values */ |
| 152 | }; |
| 153 | |
| 154 | void mx7_dram_cfg(struct ddrc *ddrc_regs_val, struct ddrc_mp *ddrc_mp_val, |
| 155 | struct ddr_phy *ddr_phy_regs_val, |
| 156 | struct mx7_calibration *calib_param); |
| 157 | |
| 158 | #endif /*__ASM_ARCH_MX7_DDR_H__ */ |