| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <delay.h> |
| 5 |
#include <northbridge/intel/haswell/haswell.h> |
| 6 |
#include <southbridge/intel/lynxpoint/pch.h> |
| 7 |
#include <types.h> |
| 8 |
#include <timer.h> |
| 9 |
|
| 10 |
#include "raminit_native.h" |
| 11 |
|
| 12 |
static void assert_reset(const bool do_reset) |
| 13 |
{ |
| 14 |
if (is_hsw_ult()) { |
| 15 |
uint32_t pm_cfg2 = RCBA32(PM_CFG2); |
| 16 |
if (do_reset) |
| 17 |
pm_cfg2 &= ~PM_CFG2_DRAM_RESET_CTL; |
| 18 |
else |
| 19 |
pm_cfg2 |= PM_CFG2_DRAM_RESET_CTL; |
| 20 |
RCBA32(PM_CFG2) = pm_cfg2; |
| 21 |
} else { |
| 22 |
union mc_init_state_g_reg mc_init_state_g = { |
| 23 |
.raw = mchbar_read32(MC_INIT_STATE_G), |
| 24 |
}; |
| 25 |
mc_init_state_g.ddr_not_reset = !do_reset; |
| 26 |
mchbar_write32(MC_INIT_STATE_G, mc_init_state_g.raw); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
static void jedec_reset(struct sysinfo *ctrl) |
| 37 |
{ |
| 38 |
if (is_hsw_ult()) |
| 39 |
assert_reset(false); |
| 40 |
|
| 41 |
union mc_init_state_g_reg mc_init_state_g = { |
| 42 |
.ddr_not_reset = 1, |
| 43 |
.safe_self_refresh = 1, |
| 44 |
}; |
| 45 |
mchbar_write32(MC_INIT_STATE_G, mc_init_state_g.raw); |
| 46 |
|
| 47 |
union reut_misc_cke_ctrl_reg reut_misc_cke_ctrl = { |
| 48 |
.cke_override = 0xf, |
| 49 |
.cke_on = 0, |
| 50 |
}; |
| 51 |
mchbar_write32(REUT_MISC_CKE_CTRL, reut_misc_cke_ctrl.raw); |
| 52 |
|
| 53 |
assert_reset(true); |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
udelay(200); |
| 58 |
|
| 59 |
assert_reset(false); |
| 60 |
|
| 61 |
udelay(500); |
| 62 |
|
| 63 |
mc_init_state_g.dclk_enable = 1; |
| 64 |
mchbar_write32(MC_INIT_STATE_G, mc_init_state_g.raw); |
| 65 |
|
| 66 |
|
| 67 |
tick_delay(1); |
| 68 |
|
| 69 |
for (uint8_t channel = 0; channel < NUM_CHANNELS; channel++) { |
| 70 |
reut_misc_cke_ctrl.cke_on = ctrl->rankmap[channel]; |
| 71 |
mchbar_write32(REUT_ch_MISC_CKE_CTRL(channel), reut_misc_cke_ctrl.raw); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
tick_delay(1); |
| 79 |
} |
| 80 |
|
| 81 |
enum raminit_status do_jedec_init(struct sysinfo *ctrl) |
| 82 |
{ |
| 83 |
|
| 84 |
if (ctrl->bootmode == BOOTMODE_S3) |
| 85 |
return RAMINIT_STATUS_SUCCESS; |
| 86 |
|
| 87 |
enum raminit_status status = io_reset(); |
| 88 |
if (status) |
| 89 |
return status; |
| 90 |
|
| 91 |
status = wait_for_first_rcomp(); |
| 92 |
if (status) |
| 93 |
return status; |
| 94 |
|
| 95 |
|
| 96 |
const union reut_misc_odt_ctrl_reg reut_misc_odt_ctrl = { |
| 97 |
.odt_override = 0xf, |
| 98 |
.odt_on = 0, |
| 99 |
}; |
| 100 |
mchbar_write32(REUT_MISC_ODT_CTRL, reut_misc_odt_ctrl.raw); |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
if (ctrl->lpddr) |
| 110 |
die("%s: LPDDR-specific JEDEC init not implemented\n", __func__); |
| 111 |
|
| 112 |
jedec_reset(ctrl); |
| 113 |
status = ddr3_jedec_init(ctrl); |
| 114 |
if (!status) |
| 115 |
ctrl->restore_mrs = true; |
| 116 |
|
| 117 |
|
| 118 |
mchbar_write32(REUT_MISC_ODT_CTRL, 0); |
| 119 |
return status; |
| 120 |
} |