Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ddr_defs.h |
| 3 | * |
| 4 | * ddr specific header |
| 5 | * |
| 6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _DDR_DEFS_H |
| 20 | #define _DDR_DEFS_H |
| 21 | |
| 22 | #include <asm/arch/hardware.h> |
Tom Rini | b668ae4 | 2012-07-24 14:55:38 -0700 | [diff] [blame] | 23 | #include <asm/emif.h> |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 24 | |
| 25 | /* AM335X EMIF Register values */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 26 | #define VTP_CTRL_READY (0x1 << 5) |
| 27 | #define VTP_CTRL_ENABLE (0x1 << 6) |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 28 | #define VTP_CTRL_START_EN (0x1) |
Tom Rini | f4914f9 | 2012-07-24 13:05:10 -0700 | [diff] [blame] | 29 | #define PHY_DLL_LOCK_DIFF 0x0 |
Tom Rini | de3c570 | 2012-07-24 14:03:24 -0700 | [diff] [blame] | 30 | #define DDR_CKE_CTRL_NORMAL 0x1 |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 31 | |
Peter Korsgaard | eb6cf7b | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 32 | /* Micron MT47H128M16RT-25E */ |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 33 | #define MT47H128M16RT25E_EMIF_READ_LATENCY 0x100005 |
| 34 | #define MT47H128M16RT25E_EMIF_TIM1 0x0666B3C9 |
| 35 | #define MT47H128M16RT25E_EMIF_TIM2 0x243631CA |
| 36 | #define MT47H128M16RT25E_EMIF_TIM3 0x0000033F |
| 37 | #define MT47H128M16RT25E_EMIF_SDCFG 0x41805332 |
| 38 | #define MT47H128M16RT25E_EMIF_SDREF 0x0000081a |
| 39 | #define MT47H128M16RT25E_DLL_LOCK_DIFF 0x0 |
| 40 | #define MT47H128M16RT25E_RATIO 0x80 |
| 41 | #define MT47H128M16RT25E_INVERT_CLKOUT 0x00 |
| 42 | #define MT47H128M16RT25E_RD_DQS 0x12 |
| 43 | #define MT47H128M16RT25E_WR_DQS 0x00 |
| 44 | #define MT47H128M16RT25E_PHY_WRLVL 0x00 |
| 45 | #define MT47H128M16RT25E_PHY_GATELVL 0x00 |
| 46 | #define MT47H128M16RT25E_PHY_WR_DATA 0x40 |
| 47 | #define MT47H128M16RT25E_PHY_FIFO_WE 0x80 |
| 48 | #define MT47H128M16RT25E_PHY_RANK0_DELAY 0x1 |
| 49 | #define MT47H128M16RT25E_IOCTRL_VALUE 0x18B |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 50 | |
Tom Rini | 323315a | 2012-07-30 14:49:50 -0700 | [diff] [blame] | 51 | /* Micron MT41J128M16JT-125 */ |
Peter Korsgaard | 3adb827 | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 52 | #define MT41J128MJT125_EMIF_READ_LATENCY 0x06 |
| 53 | #define MT41J128MJT125_EMIF_TIM1 0x0888A39B |
| 54 | #define MT41J128MJT125_EMIF_TIM2 0x26337FDA |
| 55 | #define MT41J128MJT125_EMIF_TIM3 0x501F830F |
| 56 | #define MT41J128MJT125_EMIF_SDCFG 0x61C04AB2 |
| 57 | #define MT41J128MJT125_EMIF_SDREF 0x0000093B |
| 58 | #define MT41J128MJT125_ZQ_CFG 0x50074BE4 |
| 59 | #define MT41J128MJT125_DLL_LOCK_DIFF 0x1 |
| 60 | #define MT41J128MJT125_RATIO 0x40 |
| 61 | #define MT41J128MJT125_INVERT_CLKOUT 0x1 |
| 62 | #define MT41J128MJT125_RD_DQS 0x3B |
| 63 | #define MT41J128MJT125_WR_DQS 0x85 |
| 64 | #define MT41J128MJT125_PHY_WR_DATA 0xC1 |
| 65 | #define MT41J128MJT125_PHY_FIFO_WE 0x100 |
| 66 | #define MT41J128MJT125_IOCTRL_VALUE 0x18B |
Tom Rini | 323315a | 2012-07-30 14:49:50 -0700 | [diff] [blame] | 67 | |
Lars Poeschel | 67b4a79 | 2013-01-11 00:53:31 +0000 | [diff] [blame^] | 68 | /* Micron MT41J256M8HX-15E */ |
| 69 | #define MT41J256M8HX15E_EMIF_READ_LATENCY 0x06 |
| 70 | #define MT41J256M8HX15E_EMIF_TIM1 0x0888A39B |
| 71 | #define MT41J256M8HX15E_EMIF_TIM2 0x26337FDA |
| 72 | #define MT41J256M8HX15E_EMIF_TIM3 0x501F830F |
| 73 | #define MT41J256M8HX15E_EMIF_SDCFG 0x61C04B32 |
| 74 | #define MT41J256M8HX15E_EMIF_SDREF 0x0000093B |
| 75 | #define MT41J256M8HX15E_ZQ_CFG 0x50074BE4 |
| 76 | #define MT41J256M8HX15E_DLL_LOCK_DIFF 0x1 |
| 77 | #define MT41J256M8HX15E_RATIO 0x40 |
| 78 | #define MT41J256M8HX15E_INVERT_CLKOUT 0x1 |
| 79 | #define MT41J256M8HX15E_RD_DQS 0x3B |
| 80 | #define MT41J256M8HX15E_WR_DQS 0x85 |
| 81 | #define MT41J256M8HX15E_PHY_WR_DATA 0xC1 |
| 82 | #define MT41J256M8HX15E_PHY_FIFO_WE 0x100 |
| 83 | #define MT41J256M8HX15E_IOCTRL_VALUE 0x18B |
| 84 | |
| 85 | |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 86 | /** |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 87 | * Configure SDRAM |
| 88 | */ |
Tom Rini | b668ae4 | 2012-07-24 14:55:38 -0700 | [diff] [blame] | 89 | void config_sdram(const struct emif_regs *regs); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Set SDRAM timings |
| 93 | */ |
Tom Rini | b668ae4 | 2012-07-24 14:55:38 -0700 | [diff] [blame] | 94 | void set_sdram_timings(const struct emif_regs *regs); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Configure DDR PHY |
| 98 | */ |
Tom Rini | b668ae4 | 2012-07-24 14:55:38 -0700 | [diff] [blame] | 99 | void config_ddr_phy(const struct emif_regs *regs); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * This structure represents the DDR registers on AM33XX devices. |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 103 | * We make use of DDR_PHY_BASE_ADDR2 to address the DATA1 registers that |
| 104 | * correspond to DATA1 registers defined here. |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 105 | */ |
| 106 | struct ddr_regs { |
| 107 | unsigned int resv0[7]; |
| 108 | unsigned int cm0csratio; /* offset 0x01C */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 109 | unsigned int resv1[2]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 110 | unsigned int cm0dldiff; /* offset 0x028 */ |
| 111 | unsigned int cm0iclkout; /* offset 0x02C */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 112 | unsigned int resv2[8]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 113 | unsigned int cm1csratio; /* offset 0x050 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 114 | unsigned int resv3[2]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 115 | unsigned int cm1dldiff; /* offset 0x05C */ |
| 116 | unsigned int cm1iclkout; /* offset 0x060 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 117 | unsigned int resv4[8]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 118 | unsigned int cm2csratio; /* offset 0x084 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 119 | unsigned int resv5[2]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 120 | unsigned int cm2dldiff; /* offset 0x090 */ |
| 121 | unsigned int cm2iclkout; /* offset 0x094 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 122 | unsigned int resv6[12]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 123 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 124 | unsigned int resv7[4]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 125 | unsigned int dt0wdsratio0; /* offset 0x0DC */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 126 | unsigned int resv8[4]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 127 | unsigned int dt0wiratio0; /* offset 0x0F0 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 128 | unsigned int resv9; |
| 129 | unsigned int dt0wimode0; /* offset 0x0F8 */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 130 | unsigned int dt0giratio0; /* offset 0x0FC */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 131 | unsigned int resv10; |
| 132 | unsigned int dt0gimode0; /* offset 0x104 */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 133 | unsigned int dt0fwsratio0; /* offset 0x108 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 134 | unsigned int resv11[4]; |
| 135 | unsigned int dt0dqoffset; /* offset 0x11C */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 136 | unsigned int dt0wrsratio0; /* offset 0x120 */ |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 137 | unsigned int resv12[4]; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 138 | unsigned int dt0rdelays0; /* offset 0x134 */ |
| 139 | unsigned int dt0dldiff0; /* offset 0x138 */ |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | /** |
| 143 | * Encapsulates DDR CMD control registers. |
| 144 | */ |
| 145 | struct cmd_control { |
| 146 | unsigned long cmd0csratio; |
| 147 | unsigned long cmd0csforce; |
| 148 | unsigned long cmd0csdelay; |
| 149 | unsigned long cmd0dldiff; |
| 150 | unsigned long cmd0iclkout; |
| 151 | unsigned long cmd1csratio; |
| 152 | unsigned long cmd1csforce; |
| 153 | unsigned long cmd1csdelay; |
| 154 | unsigned long cmd1dldiff; |
| 155 | unsigned long cmd1iclkout; |
| 156 | unsigned long cmd2csratio; |
| 157 | unsigned long cmd2csforce; |
| 158 | unsigned long cmd2csdelay; |
| 159 | unsigned long cmd2dldiff; |
| 160 | unsigned long cmd2iclkout; |
| 161 | }; |
| 162 | |
| 163 | /** |
| 164 | * Encapsulates DDR DATA registers. |
| 165 | */ |
| 166 | struct ddr_data { |
| 167 | unsigned long datardsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 168 | unsigned long datawdsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 169 | unsigned long datawiratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 170 | unsigned long datagiratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 171 | unsigned long datafwsratio0; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 172 | unsigned long datawrsratio0; |
Tom Rini | 3e44458 | 2012-07-30 11:49:47 -0700 | [diff] [blame] | 173 | unsigned long datauserank0delay; |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 174 | unsigned long datadldiff0; |
| 175 | }; |
| 176 | |
| 177 | /** |
| 178 | * Configure DDR CMD control registers |
| 179 | */ |
Tom Rini | 6f868cf | 2012-07-24 14:54:41 -0700 | [diff] [blame] | 180 | void config_cmd_ctrl(const struct cmd_control *cmd); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 181 | |
| 182 | /** |
| 183 | * Configure DDR DATA registers |
| 184 | */ |
Tom Rini | 6f868cf | 2012-07-24 14:54:41 -0700 | [diff] [blame] | 185 | void config_ddr_data(int data_macrono, const struct ddr_data *data); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * This structure represents the DDR io control on AM33XX devices. |
| 189 | */ |
| 190 | struct ddr_cmdtctrl { |
| 191 | unsigned int resv1[1]; |
| 192 | unsigned int cm0ioctl; |
| 193 | unsigned int cm1ioctl; |
| 194 | unsigned int cm2ioctl; |
| 195 | unsigned int resv2[12]; |
| 196 | unsigned int dt0ioctl; |
| 197 | unsigned int dt1ioctl; |
| 198 | }; |
| 199 | |
| 200 | /** |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 201 | * Configure DDR io control registers |
| 202 | */ |
Tom Rini | b239b3b | 2012-07-24 16:31:26 -0700 | [diff] [blame] | 203 | void config_io_ctrl(unsigned long val); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 204 | |
| 205 | struct ddr_ctrl { |
| 206 | unsigned int ddrioctrl; |
| 207 | unsigned int resv1[325]; |
| 208 | unsigned int ddrckectrl; |
| 209 | }; |
| 210 | |
Peter Korsgaard | eb6cf7b | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 211 | void config_ddr(unsigned int pll, unsigned int ioctrl, |
| 212 | const struct ddr_data *data, const struct cmd_control *ctrl, |
| 213 | const struct emif_regs *regs); |
Chandan Nath | 98b036e | 2011-10-14 02:58:24 +0000 | [diff] [blame] | 214 | |
| 215 | #endif /* _DDR_DEFS_H */ |