| .. | .. |
|---|
| 14 | 14 | * GNU General Public License for more details. |
|---|
| 15 | 15 | */ |
|---|
| 16 | 16 | |
|---|
| 17 | | -#include <generated/ti-emif-asm-offsets.h> |
|---|
| 18 | 17 | #include <linux/linkage.h> |
|---|
| 19 | 18 | #include <asm/assembler.h> |
|---|
| 20 | 19 | #include <asm/memory.h> |
|---|
| 21 | 20 | |
|---|
| 22 | 21 | #include "emif.h" |
|---|
| 22 | +#include "ti-emif-asm-offsets.h" |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | #define EMIF_POWER_MGMT_WAIT_SELF_REFRESH_8192_CYCLES 0x00a0 |
|---|
| 25 | 25 | #define EMIF_POWER_MGMT_SR_TIMER_MASK 0x00f0 |
|---|
| .. | .. |
|---|
| 27 | 27 | #define EMIF_POWER_MGMT_SELF_REFRESH_MODE_MASK 0x0700 |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | #define EMIF_SDCFG_TYPE_DDR2 0x2 << SDRAM_TYPE_SHIFT |
|---|
| 30 | +#define EMIF_SDCFG_TYPE_DDR3 0x3 << SDRAM_TYPE_SHIFT |
|---|
| 30 | 31 | #define EMIF_STATUS_READY 0x4 |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | #define AM43XX_EMIF_PHY_CTRL_REG_COUNT 0x120 |
|---|
| .. | .. |
|---|
| 245 | 246 | ENDPROC(ti_emif_restore_context) |
|---|
| 246 | 247 | |
|---|
| 247 | 248 | /* |
|---|
| 249 | + * void ti_emif_run_hw_leveling(void) |
|---|
| 250 | + * |
|---|
| 251 | + * Used during resume to run hardware leveling again and restore the |
|---|
| 252 | + * configuration of the EMIF PHY, only for DDR3. |
|---|
| 253 | + */ |
|---|
| 254 | +ENTRY(ti_emif_run_hw_leveling) |
|---|
| 255 | + adr r4, ti_emif_pm_sram_data |
|---|
| 256 | + ldr r0, [r4, #EMIF_PM_BASE_ADDR_PHYS_OFFSET] |
|---|
| 257 | + |
|---|
| 258 | + ldr r3, [r0, #EMIF_READ_WRITE_LEVELING_CONTROL] |
|---|
| 259 | + orr r3, r3, #RDWRLVLFULL_START |
|---|
| 260 | + ldr r2, [r0, #EMIF_SDRAM_CONFIG] |
|---|
| 261 | + and r2, r2, #SDRAM_TYPE_MASK |
|---|
| 262 | + cmp r2, #EMIF_SDCFG_TYPE_DDR3 |
|---|
| 263 | + bne skip_hwlvl |
|---|
| 264 | + |
|---|
| 265 | + str r3, [r0, #EMIF_READ_WRITE_LEVELING_CONTROL] |
|---|
| 266 | + |
|---|
| 267 | + /* |
|---|
| 268 | + * If EMIF registers are touched during initial stage of HW |
|---|
| 269 | + * leveling sequence there will be an L3 NOC timeout error issued |
|---|
| 270 | + * as the EMIF will not respond, which is not fatal, but it is |
|---|
| 271 | + * avoidable. This small wait loop is enough time for this condition |
|---|
| 272 | + * to clear, even at worst case of CPU running at max speed of 1Ghz. |
|---|
| 273 | + */ |
|---|
| 274 | + mov r2, #0x2000 |
|---|
| 275 | +1: |
|---|
| 276 | + subs r2, r2, #0x1 |
|---|
| 277 | + bne 1b |
|---|
| 278 | + |
|---|
| 279 | + /* Bit clears when operation is complete */ |
|---|
| 280 | +2: ldr r1, [r0, #EMIF_READ_WRITE_LEVELING_CONTROL] |
|---|
| 281 | + tst r1, #RDWRLVLFULL_START |
|---|
| 282 | + bne 2b |
|---|
| 283 | + |
|---|
| 284 | +skip_hwlvl: |
|---|
| 285 | + mov pc, lr |
|---|
| 286 | +ENDPROC(ti_emif_run_hw_leveling) |
|---|
| 287 | + |
|---|
| 288 | +/* |
|---|
| 248 | 289 | * void ti_emif_enter_sr(void) |
|---|
| 249 | 290 | * |
|---|
| 250 | 291 | * Programs the EMIF to tell the SDRAM to enter into self-refresh |
|---|