Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 2 | /* |
| 3 | * ddr_defs.h |
| 4 | * |
| 5 | * ddr specific header |
| 6 | * |
| 7 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef _DDR_DEFS_H |
| 11 | #define _DDR_DEFS_H |
| 12 | |
| 13 | #include <asm/arch/hardware.h> |
Tom Rini | b668ae4 | 2012-07-24 14:55:38 -0700 | [diff] [blame] | 14 | #include <asm/emif.h> |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 15 | |
| 16 | /* AM335X EMIF Register values */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 17 | #define VTP_CTRL_READY (0x1 << 5) |
| 18 | #define VTP_CTRL_ENABLE (0x1 << 6) |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 19 | #define VTP_CTRL_START_EN (0x1) |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 20 | #ifdef CONFIG_AM43XX |
| 21 | #define DDR_CKE_CTRL_NORMAL 0x3 |
| 22 | #else |
Tom Rini | de3c570 | 2012-07-24 14:03:24 -0700 | [diff] [blame] | 23 | #define DDR_CKE_CTRL_NORMAL 0x1 |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 24 | #endif |
Vaibhav Hiremath | c30d57b | 2013-03-14 21:11:16 +0000 | [diff] [blame] | 25 | #define PHY_EN_DYN_PWRDN (0x1 << 20) |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 26 | |
Peter Korsgaard | eb6cf7b | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 27 | /* Micron MT47H128M16RT-25E */ |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 28 | #define MT47H128M16RT25E_EMIF_READ_LATENCY 0x100005 |
| 29 | #define MT47H128M16RT25E_EMIF_TIM1 0x0666B3C9 |
| 30 | #define MT47H128M16RT25E_EMIF_TIM2 0x243631CA |
| 31 | #define MT47H128M16RT25E_EMIF_TIM3 0x0000033F |
| 32 | #define MT47H128M16RT25E_EMIF_SDCFG 0x41805332 |
| 33 | #define MT47H128M16RT25E_EMIF_SDREF 0x0000081a |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 34 | #define MT47H128M16RT25E_RATIO 0x80 |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 35 | #define MT47H128M16RT25E_RD_DQS 0x12 |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 36 | #define MT47H128M16RT25E_PHY_WR_DATA 0x40 |
| 37 | #define MT47H128M16RT25E_PHY_FIFO_WE 0x80 |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 38 | #define MT47H128M16RT25E_IOCTRL_VALUE 0x18B |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 39 | |
Tom Rini | 323315a | 2012-07-30 14:49:50 -0700 | [diff] [blame] | 40 | /* Micron MT41J128M16JT-125 */ |
Satyanarayana, Sandhya | c698a1a | 2013-12-19 10:00:29 +0530 | [diff] [blame] | 41 | #define MT41J128MJT125_EMIF_READ_LATENCY 0x100006 |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 42 | #define MT41J128MJT125_EMIF_TIM1 0x0888A39B |
| 43 | #define MT41J128MJT125_EMIF_TIM2 0x26337FDA |
| 44 | #define MT41J128MJT125_EMIF_TIM3 0x501F830F |
| 45 | #define MT41J128MJT125_EMIF_SDCFG 0x61C04AB2 |
| 46 | #define MT41J128MJT125_EMIF_SDREF 0x0000093B |
| 47 | #define MT41J128MJT125_ZQ_CFG 0x50074BE4 |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 48 | #define MT41J128MJT125_RATIO 0x40 |
| 49 | #define MT41J128MJT125_INVERT_CLKOUT 0x1 |
| 50 | #define MT41J128MJT125_RD_DQS 0x3B |
| 51 | #define MT41J128MJT125_WR_DQS 0x85 |
| 52 | #define MT41J128MJT125_PHY_WR_DATA 0xC1 |
| 53 | #define MT41J128MJT125_PHY_FIFO_WE 0x100 |
| 54 | #define MT41J128MJT125_IOCTRL_VALUE 0x18B |
Tom Rini | 323315a | 2012-07-30 14:49:50 -0700 | [diff] [blame] | 55 | |
Lokesh Vutla | 5837b90 | 2016-05-16 11:47:24 +0530 | [diff] [blame] | 56 | /* Micron MT41J128M16JT-125 at 400MHz*/ |
| 57 | #define MT41J128MJT125_EMIF_READ_LATENCY_400MHz 0x100007 |
| 58 | #define MT41J128MJT125_EMIF_TIM1_400MHz 0x0AAAD4DB |
| 59 | #define MT41J128MJT125_EMIF_TIM2_400MHz 0x26437FDA |
| 60 | #define MT41J128MJT125_EMIF_TIM3_400MHz 0x501F83FF |
| 61 | #define MT41J128MJT125_EMIF_SDCFG_400MHz 0x61C052B2 |
| 62 | #define MT41J128MJT125_EMIF_SDREF_400MHz 0x00000C30 |
| 63 | #define MT41J128MJT125_ZQ_CFG_400MHz 0x50074BE4 |
| 64 | #define MT41J128MJT125_RATIO_400MHz 0x80 |
| 65 | #define MT41J128MJT125_INVERT_CLKOUT_400MHz 0x0 |
| 66 | #define MT41J128MJT125_RD_DQS_400MHz 0x3A |
| 67 | #define MT41J128MJT125_WR_DQS_400MHz 0x3B |
| 68 | #define MT41J128MJT125_PHY_WR_DATA_400MHz 0x76 |
| 69 | #define MT41J128MJT125_PHY_FIFO_WE_400MHz 0x96 |
| 70 | |
Lothar Felten | 8c6324f | 2014-01-31 17:34:14 +0100 | [diff] [blame] | 71 | /* Micron MT41K128M16JT-187E */ |
| 72 | #define MT41K128MJT187E_EMIF_READ_LATENCY 0x06 |
| 73 | #define MT41K128MJT187E_EMIF_TIM1 0x0888B3DB |
| 74 | #define MT41K128MJT187E_EMIF_TIM2 0x36337FDA |
| 75 | #define MT41K128MJT187E_EMIF_TIM3 0x501F830F |
| 76 | #define MT41K128MJT187E_EMIF_SDCFG 0x61C04AB2 |
| 77 | #define MT41K128MJT187E_EMIF_SDREF 0x0000093B |
| 78 | #define MT41K128MJT187E_ZQ_CFG 0x50074BE4 |
| 79 | #define MT41K128MJT187E_RATIO 0x40 |
| 80 | #define MT41K128MJT187E_INVERT_CLKOUT 0x1 |
| 81 | #define MT41K128MJT187E_RD_DQS 0x3B |
| 82 | #define MT41K128MJT187E_WR_DQS 0x85 |
| 83 | #define MT41K128MJT187E_PHY_WR_DATA 0xC1 |
| 84 | #define MT41K128MJT187E_PHY_FIFO_WE 0x100 |
| 85 | #define MT41K128MJT187E_IOCTRL_VALUE 0x18B |
| 86 | |
Sjoerd Simons | c9c86c0 | 2019-02-25 15:32:58 +0000 | [diff] [blame] | 87 | /* Micron MT41K128M16JT-125 IT:K (256 MB) at 400MHz */ |
| 88 | #define MT41K128M16JT125K_EMIF_READ_LATENCY 0x07 |
| 89 | #define MT41K128M16JT125K_EMIF_TIM1 0x0AAAD4DB |
| 90 | #define MT41K128M16JT125K_EMIF_TIM2 0x2A437FDA |
| 91 | #define MT41K128M16JT125K_EMIF_TIM3 0x501F83FF |
| 92 | #define MT41K128M16JT125K_EMIF_SDCFG 0x61A052B2 |
| 93 | #define MT41K128M16JT125K_EMIF_SDREF 0x00000C30 |
| 94 | #define MT41K128M16JT125K_ZQ_CFG 0x50074BE4 |
| 95 | #define MT41K128M16JT125K_RATIO 0x80 |
| 96 | #define MT41K128M16JT125K_INVERT_CLKOUT 0x0 |
| 97 | #define MT41K128M16JT125K_RD_DQS 0x38 |
| 98 | #define MT41K128M16JT125K_WR_DQS 0x46 |
| 99 | #define MT41K128M16JT125K_PHY_WR_DATA 0x7D |
| 100 | #define MT41K128M16JT125K_PHY_FIFO_WE 0x9B |
| 101 | #define MT41K128M16JT125K_IOCTRL_VALUE 0x18B |
| 102 | |
Ilya Ledvich | 791ca18 | 2013-11-07 07:57:33 +0200 | [diff] [blame] | 103 | /* Micron MT41J64M16JT-125 */ |
| 104 | #define MT41J64MJT125_EMIF_SDCFG 0x61C04A32 |
| 105 | |
| 106 | /* Micron MT41J256M16JT-125 */ |
| 107 | #define MT41J256MJT125_EMIF_SDCFG 0x61C04B32 |
| 108 | |
Lars Poeschel | 67b4a79 | 2013-01-11 00:53:31 +0000 | [diff] [blame] | 109 | /* Micron MT41J256M8HX-15E */ |
Satyanarayana, Sandhya | c698a1a | 2013-12-19 10:00:29 +0530 | [diff] [blame] | 110 | #define MT41J256M8HX15E_EMIF_READ_LATENCY 0x100006 |
Lars Poeschel | 67b4a79 | 2013-01-11 00:53:31 +0000 | [diff] [blame] | 111 | #define MT41J256M8HX15E_EMIF_TIM1 0x0888A39B |
| 112 | #define MT41J256M8HX15E_EMIF_TIM2 0x26337FDA |
| 113 | #define MT41J256M8HX15E_EMIF_TIM3 0x501F830F |
| 114 | #define MT41J256M8HX15E_EMIF_SDCFG 0x61C04B32 |
| 115 | #define MT41J256M8HX15E_EMIF_SDREF 0x0000093B |
| 116 | #define MT41J256M8HX15E_ZQ_CFG 0x50074BE4 |
Lars Poeschel | 67b4a79 | 2013-01-11 00:53:31 +0000 | [diff] [blame] | 117 | #define MT41J256M8HX15E_RATIO 0x40 |
| 118 | #define MT41J256M8HX15E_INVERT_CLKOUT 0x1 |
| 119 | #define MT41J256M8HX15E_RD_DQS 0x3B |
| 120 | #define MT41J256M8HX15E_WR_DQS 0x85 |
| 121 | #define MT41J256M8HX15E_PHY_WR_DATA 0xC1 |
| 122 | #define MT41J256M8HX15E_PHY_FIFO_WE 0x100 |
| 123 | #define MT41J256M8HX15E_IOCTRL_VALUE 0x18B |
| 124 | |
Tom Rini | 385bc75 | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 125 | /* Micron MT41K256M16HA-125E */ |
Tom Rini | 8939ec3 | 2013-04-10 15:10:54 +0200 | [diff] [blame] | 126 | #define MT41K256M16HA125E_EMIF_READ_LATENCY 0x100007 |
| 127 | #define MT41K256M16HA125E_EMIF_TIM1 0x0AAAD4DB |
Tom Rini | 05acd82 | 2013-04-12 12:38:16 -0400 | [diff] [blame] | 128 | #define MT41K256M16HA125E_EMIF_TIM2 0x266B7FDA |
| 129 | #define MT41K256M16HA125E_EMIF_TIM3 0x501F867F |
| 130 | #define MT41K256M16HA125E_EMIF_SDCFG 0x61C05332 |
Tom Rini | 8939ec3 | 2013-04-10 15:10:54 +0200 | [diff] [blame] | 131 | #define MT41K256M16HA125E_EMIF_SDREF 0xC30 |
Tom Rini | 385bc75 | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 132 | #define MT41K256M16HA125E_ZQ_CFG 0x50074BE4 |
Tom Rini | 8939ec3 | 2013-04-10 15:10:54 +0200 | [diff] [blame] | 133 | #define MT41K256M16HA125E_RATIO 0x80 |
Tom Rini | 385bc75 | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 134 | #define MT41K256M16HA125E_INVERT_CLKOUT 0x0 |
Tom Rini | 05acd82 | 2013-04-12 12:38:16 -0400 | [diff] [blame] | 135 | #define MT41K256M16HA125E_RD_DQS 0x38 |
| 136 | #define MT41K256M16HA125E_WR_DQS 0x44 |
| 137 | #define MT41K256M16HA125E_PHY_WR_DATA 0x7D |
| 138 | #define MT41K256M16HA125E_PHY_FIFO_WE 0x94 |
Tom Rini | 385bc75 | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 139 | #define MT41K256M16HA125E_IOCTRL_VALUE 0x18B |
| 140 | |
Jeff Lance | 7c03a22 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 141 | /* Micron MT41J512M8RH-125 on EVM v1.5 */ |
Satyanarayana, Sandhya | c698a1a | 2013-12-19 10:00:29 +0530 | [diff] [blame] | 142 | #define MT41J512M8RH125_EMIF_READ_LATENCY 0x100006 |
Jeff Lance | 7c03a22 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 143 | #define MT41J512M8RH125_EMIF_TIM1 0x0888A39B |
| 144 | #define MT41J512M8RH125_EMIF_TIM2 0x26517FDA |
| 145 | #define MT41J512M8RH125_EMIF_TIM3 0x501F84EF |
| 146 | #define MT41J512M8RH125_EMIF_SDCFG 0x61C04BB2 |
| 147 | #define MT41J512M8RH125_EMIF_SDREF 0x0000093B |
| 148 | #define MT41J512M8RH125_ZQ_CFG 0x50074BE4 |
Jeff Lance | 7c03a22 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 149 | #define MT41J512M8RH125_RATIO 0x80 |
| 150 | #define MT41J512M8RH125_INVERT_CLKOUT 0x0 |
| 151 | #define MT41J512M8RH125_RD_DQS 0x3B |
| 152 | #define MT41J512M8RH125_WR_DQS 0x3C |
| 153 | #define MT41J512M8RH125_PHY_FIFO_WE 0xA5 |
| 154 | #define MT41J512M8RH125_PHY_WR_DATA 0x74 |
| 155 | #define MT41J512M8RH125_IOCTRL_VALUE 0x18B |
Lars Poeschel | 67b4a79 | 2013-01-11 00:53:31 +0000 | [diff] [blame] | 156 | |
Enric Balletbo i Serra | d8efff1 | 2013-04-04 22:27:57 +0000 | [diff] [blame] | 157 | /* Samsung K4B2G1646E-BIH9 */ |
Satyanarayana, Sandhya | c698a1a | 2013-12-19 10:00:29 +0530 | [diff] [blame] | 158 | #define K4B2G1646EBIH9_EMIF_READ_LATENCY 0x100007 |
Enric Balletbo i Serra | 177db36 | 2013-09-10 11:12:26 +0200 | [diff] [blame] | 159 | #define K4B2G1646EBIH9_EMIF_TIM1 0x0AAAE51B |
| 160 | #define K4B2G1646EBIH9_EMIF_TIM2 0x2A1D7FDA |
| 161 | #define K4B2G1646EBIH9_EMIF_TIM3 0x501F83FF |
| 162 | #define K4B2G1646EBIH9_EMIF_SDCFG 0x61C052B2 |
| 163 | #define K4B2G1646EBIH9_EMIF_SDREF 0x00000C30 |
Enric Balletbo i Serra | d8efff1 | 2013-04-04 22:27:57 +0000 | [diff] [blame] | 164 | #define K4B2G1646EBIH9_ZQ_CFG 0x50074BE4 |
Enric Balletbo i Serra | 177db36 | 2013-09-10 11:12:26 +0200 | [diff] [blame] | 165 | #define K4B2G1646EBIH9_RATIO 0x80 |
| 166 | #define K4B2G1646EBIH9_INVERT_CLKOUT 0x0 |
| 167 | #define K4B2G1646EBIH9_RD_DQS 0x35 |
| 168 | #define K4B2G1646EBIH9_WR_DQS 0x3A |
| 169 | #define K4B2G1646EBIH9_PHY_FIFO_WE 0x97 |
| 170 | #define K4B2G1646EBIH9_PHY_WR_DATA 0x76 |
Enric Balletbo i Serra | d8efff1 | 2013-04-04 22:27:57 +0000 | [diff] [blame] | 171 | #define K4B2G1646EBIH9_IOCTRL_VALUE 0x18B |
| 172 | |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 173 | #define LPDDR2_ADDRCTRL_IOCTRL_VALUE 0x294 |
| 174 | #define LPDDR2_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000 |
| 175 | #define LPDDR2_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000 |
| 176 | #define LPDDR2_DATA0_IOCTRL_VALUE 0x20000294 |
| 177 | #define LPDDR2_DATA1_IOCTRL_VALUE 0x20000294 |
| 178 | #define LPDDR2_DATA2_IOCTRL_VALUE 0x20000294 |
| 179 | #define LPDDR2_DATA3_IOCTRL_VALUE 0x20000294 |
| 180 | |
Lokesh Vutla | dd0037a | 2013-12-10 15:02:23 +0530 | [diff] [blame] | 181 | #define DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000 |
| 182 | #define DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000 |
| 183 | #define DDR3_ADDRCTRL_IOCTRL_VALUE 0x84 |
| 184 | #define DDR3_DATA0_IOCTRL_VALUE 0x84 |
| 185 | #define DDR3_DATA1_IOCTRL_VALUE 0x84 |
| 186 | #define DDR3_DATA2_IOCTRL_VALUE 0x84 |
| 187 | #define DDR3_DATA3_IOCTRL_VALUE 0x84 |
| 188 | |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 189 | /** |
Matt Porter | 4035510 | 2013-03-15 10:07:07 +0000 | [diff] [blame] | 190 | * Configure DMM |
| 191 | */ |
| 192 | void config_dmm(const struct dmm_lisa_map_regs *regs); |
| 193 | |
| 194 | /** |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 195 | * Configure SDRAM |
| 196 | */ |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 197 | void config_sdram(const struct emif_regs *regs, int nr); |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 198 | void config_sdram_emif4d5(const struct emif_regs *regs, int nr); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * Set SDRAM timings |
| 202 | */ |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 203 | void set_sdram_timings(const struct emif_regs *regs, int nr); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 204 | |
| 205 | /** |
| 206 | * Configure DDR PHY |
| 207 | */ |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 208 | void config_ddr_phy(const struct emif_regs *regs, int nr); |
| 209 | |
| 210 | struct ddr_cmd_regs { |
| 211 | unsigned int resv0[7]; |
| 212 | unsigned int cm0csratio; /* offset 0x01C */ |
Tom Rini | bcce2a0 | 2013-11-07 11:42:57 -0500 | [diff] [blame] | 213 | unsigned int resv1[3]; |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 214 | unsigned int cm0iclkout; /* offset 0x02C */ |
| 215 | unsigned int resv2[8]; |
| 216 | unsigned int cm1csratio; /* offset 0x050 */ |
Tom Rini | bcce2a0 | 2013-11-07 11:42:57 -0500 | [diff] [blame] | 217 | unsigned int resv3[3]; |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 218 | unsigned int cm1iclkout; /* offset 0x060 */ |
| 219 | unsigned int resv4[8]; |
| 220 | unsigned int cm2csratio; /* offset 0x084 */ |
Tom Rini | bcce2a0 | 2013-11-07 11:42:57 -0500 | [diff] [blame] | 221 | unsigned int resv5[3]; |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 222 | unsigned int cm2iclkout; /* offset 0x094 */ |
| 223 | unsigned int resv6[3]; |
| 224 | }; |
| 225 | |
| 226 | struct ddr_data_regs { |
| 227 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ |
| 228 | unsigned int resv1[4]; |
| 229 | unsigned int dt0wdsratio0; /* offset 0x0DC */ |
| 230 | unsigned int resv2[4]; |
| 231 | unsigned int dt0wiratio0; /* offset 0x0F0 */ |
| 232 | unsigned int resv3; |
| 233 | unsigned int dt0wimode0; /* offset 0x0F8 */ |
| 234 | unsigned int dt0giratio0; /* offset 0x0FC */ |
| 235 | unsigned int resv4; |
| 236 | unsigned int dt0gimode0; /* offset 0x104 */ |
| 237 | unsigned int dt0fwsratio0; /* offset 0x108 */ |
| 238 | unsigned int resv5[4]; |
| 239 | unsigned int dt0dqoffset; /* offset 0x11C */ |
| 240 | unsigned int dt0wrsratio0; /* offset 0x120 */ |
| 241 | unsigned int resv6[4]; |
| 242 | unsigned int dt0rdelays0; /* offset 0x134 */ |
| 243 | unsigned int dt0dldiff0; /* offset 0x138 */ |
| 244 | unsigned int resv7[12]; |
| 245 | }; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 246 | |
| 247 | /** |
| 248 | * This structure represents the DDR registers on AM33XX devices. |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 249 | * We make use of DDR_PHY_BASE_ADDR2 to address the DATA1 registers that |
| 250 | * correspond to DATA1 registers defined here. |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 251 | */ |
| 252 | struct ddr_regs { |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 253 | unsigned int resv0[3]; |
| 254 | unsigned int cm0config; /* offset 0x00C */ |
| 255 | unsigned int cm0configclk; /* offset 0x010 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 256 | unsigned int resv1[2]; |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 257 | unsigned int cm0csratio; /* offset 0x01C */ |
Tom Rini | bcce2a0 | 2013-11-07 11:42:57 -0500 | [diff] [blame] | 258 | unsigned int resv2[3]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 259 | unsigned int cm0iclkout; /* offset 0x02C */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 260 | unsigned int resv3[4]; |
| 261 | unsigned int cm1config; /* offset 0x040 */ |
| 262 | unsigned int cm1configclk; /* offset 0x044 */ |
| 263 | unsigned int resv4[2]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 264 | unsigned int cm1csratio; /* offset 0x050 */ |
Tom Rini | bcce2a0 | 2013-11-07 11:42:57 -0500 | [diff] [blame] | 265 | unsigned int resv5[3]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 266 | unsigned int cm1iclkout; /* offset 0x060 */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 267 | unsigned int resv6[4]; |
| 268 | unsigned int cm2config; /* offset 0x074 */ |
| 269 | unsigned int cm2configclk; /* offset 0x078 */ |
| 270 | unsigned int resv7[2]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 271 | unsigned int cm2csratio; /* offset 0x084 */ |
Tom Rini | bcce2a0 | 2013-11-07 11:42:57 -0500 | [diff] [blame] | 272 | unsigned int resv8[3]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 273 | unsigned int cm2iclkout; /* offset 0x094 */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 274 | unsigned int resv9[12]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 275 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 276 | unsigned int resv10[4]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 277 | unsigned int dt0wdsratio0; /* offset 0x0DC */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 278 | unsigned int resv11[4]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 279 | unsigned int dt0wiratio0; /* offset 0x0F0 */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 280 | unsigned int resv12; |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 281 | unsigned int dt0wimode0; /* offset 0x0F8 */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 282 | unsigned int dt0giratio0; /* offset 0x0FC */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 283 | unsigned int resv13; |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 284 | unsigned int dt0gimode0; /* offset 0x104 */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 285 | unsigned int dt0fwsratio0; /* offset 0x108 */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 286 | unsigned int resv14[4]; |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 287 | unsigned int dt0dqoffset; /* offset 0x11C */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 288 | unsigned int dt0wrsratio0; /* offset 0x120 */ |
TENART Antoine | 35c7e52 | 2013-07-02 12:05:59 +0200 | [diff] [blame] | 289 | unsigned int resv15[4]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 290 | unsigned int dt0rdelays0; /* offset 0x134 */ |
| 291 | unsigned int dt0dldiff0; /* offset 0x138 */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 292 | }; |
| 293 | |
| 294 | /** |
| 295 | * Encapsulates DDR CMD control registers. |
| 296 | */ |
| 297 | struct cmd_control { |
| 298 | unsigned long cmd0csratio; |
| 299 | unsigned long cmd0csforce; |
| 300 | unsigned long cmd0csdelay; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 301 | unsigned long cmd0iclkout; |
| 302 | unsigned long cmd1csratio; |
| 303 | unsigned long cmd1csforce; |
| 304 | unsigned long cmd1csdelay; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 305 | unsigned long cmd1iclkout; |
| 306 | unsigned long cmd2csratio; |
| 307 | unsigned long cmd2csforce; |
| 308 | unsigned long cmd2csdelay; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 309 | unsigned long cmd2iclkout; |
| 310 | }; |
| 311 | |
| 312 | /** |
| 313 | * Encapsulates DDR DATA registers. |
| 314 | */ |
| 315 | struct ddr_data { |
| 316 | unsigned long datardsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 317 | unsigned long datawdsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 318 | unsigned long datawiratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 319 | unsigned long datagiratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 320 | unsigned long datafwsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 321 | unsigned long datawrsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | /** |
| 325 | * Configure DDR CMD control registers |
| 326 | */ |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 327 | void config_cmd_ctrl(const struct cmd_control *cmd, int nr); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 328 | |
| 329 | /** |
| 330 | * Configure DDR DATA registers |
| 331 | */ |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 332 | void config_ddr_data(const struct ddr_data *data, int nr); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 333 | |
| 334 | /** |
| 335 | * This structure represents the DDR io control on AM33XX devices. |
| 336 | */ |
| 337 | struct ddr_cmdtctrl { |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 338 | unsigned int cm0ioctl; |
| 339 | unsigned int cm1ioctl; |
| 340 | unsigned int cm2ioctl; |
| 341 | unsigned int resv2[12]; |
| 342 | unsigned int dt0ioctl; |
| 343 | unsigned int dt1ioctl; |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 344 | unsigned int dt2ioctrl; |
| 345 | unsigned int dt3ioctrl; |
| 346 | unsigned int resv3[4]; |
| 347 | unsigned int emif_sdram_config_ext; |
| 348 | }; |
| 349 | |
| 350 | struct ctrl_ioregs { |
| 351 | unsigned int cm0ioctl; |
| 352 | unsigned int cm1ioctl; |
| 353 | unsigned int cm2ioctl; |
| 354 | unsigned int dt0ioctl; |
| 355 | unsigned int dt1ioctl; |
| 356 | unsigned int dt2ioctrl; |
| 357 | unsigned int dt3ioctrl; |
| 358 | unsigned int emif_sdram_config_ext; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 359 | }; |
| 360 | |
| 361 | /** |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 362 | * Configure DDR io control registers |
| 363 | */ |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 364 | void config_io_ctrl(const struct ctrl_ioregs *ioregs); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 365 | |
| 366 | struct ddr_ctrl { |
| 367 | unsigned int ddrioctrl; |
| 368 | unsigned int resv1[325]; |
| 369 | unsigned int ddrckectrl; |
| 370 | }; |
| 371 | |
Tom Rini | fbb2552 | 2017-05-16 14:46:35 -0400 | [diff] [blame] | 372 | #ifdef CONFIG_TI816X |
| 373 | void config_ddr(const struct ddr_data *data, const struct cmd_control *ctrl, |
| 374 | const struct emif_regs *regs, |
| 375 | const struct dmm_lisa_map_regs *lisa_regs, int nrs); |
| 376 | #else |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 377 | void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs, |
Peter Korsgaard | eb6cf7b | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 378 | const struct ddr_data *data, const struct cmd_control *ctrl, |
Matt Porter | 65991ec | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 379 | const struct emif_regs *regs, int nr); |
Tom Rini | fbb2552 | 2017-05-16 14:46:35 -0400 | [diff] [blame] | 380 | #endif |
Lokesh Vutla | a82d4e1 | 2013-12-10 15:02:22 +0530 | [diff] [blame] | 381 | void emif_get_ext_phy_ctrl_const_regs(const u32 **regs, u32 *size); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 382 | |
| 383 | #endif /* _DDR_DEFS_H */ |