| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <arch_helpers.h> |
| 9 |
#include <common/debug.h> |
| 10 |
#include <drivers/mentor/mi2cv.h> |
| 11 |
#include <lib/mmio.h> |
| 12 |
|
| 13 |
#include <mv_ddr_if.h> |
| 14 |
#include <mvebu_def.h> |
| 15 |
#include <plat_marvell.h> |
| 16 |
|
| 17 |
#define MVEBU_AP_MPP_CTRL0_7_REG MVEBU_AP_MPP_REGS(0) |
| 18 |
#define MVEBU_AP_MPP_CTRL4_OFFS 16 |
| 19 |
#define MVEBU_AP_MPP_CTRL5_OFFS 20 |
| 20 |
#define MVEBU_AP_MPP_CTRL4_I2C0_SDA_ENA 0x3 |
| 21 |
#define MVEBU_AP_MPP_CTRL5_I2C0_SCK_ENA 0x3 |
| 22 |
|
| 23 |
#define MVEBU_CP_MPP_CTRL37_OFFS 20 |
| 24 |
#define MVEBU_CP_MPP_CTRL38_OFFS 24 |
| 25 |
#define MVEBU_CP_MPP_CTRL37_I2C0_SCK_ENA 0x2 |
| 26 |
#define MVEBU_CP_MPP_CTRL38_I2C0_SDA_ENA 0x2 |
| 27 |
|
| 28 |
#define MVEBU_MPP_CTRL_MASK 0xf |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
static struct mv_ddr_topology_map board_topology_map = { |
| 35 |
|
| 36 |
DEBUG_LEVEL_ERROR, |
| 37 |
0x1, |
| 38 |
|
| 39 |
{ { { {0x1, 0x0, 0, 0}, |
| 40 |
{0x1, 0x0, 0, 0}, |
| 41 |
{0x1, 0x0, 0, 0}, |
| 42 |
{0x1, 0x0, 0, 0}, |
| 43 |
{0x1, 0x0, 0, 0}, |
| 44 |
{0x1, 0x0, 0, 0}, |
| 45 |
{0x1, 0x0, 0, 0}, |
| 46 |
{0x1, 0x0, 0, 0}, |
| 47 |
{0x1, 0x0, 0, 0} }, |
| 48 |
|
| 49 |
SPEED_BIN_DDR_2400T, |
| 50 |
MV_DDR_DEV_WIDTH_8BIT, |
| 51 |
MV_DDR_DIE_CAP_8GBIT, |
| 52 |
MV_DDR_FREQ_SAR, |
| 53 |
0, 0, |
| 54 |
MV_DDR_TEMP_LOW} }, |
| 55 |
MV_DDR_64BIT_BUS_MASK, |
| 56 |
MV_DDR_CFG_SPD, |
| 57 |
NOT_COMBINED, |
| 58 |
{ {0} }, |
| 59 |
{0}, |
| 60 |
{ |
| 61 |
{ |
| 62 |
MV_DDR_RTT_NOM_PARK_RZQ_DISABLE, |
| 63 |
{ |
| 64 |
MV_DDR_RTT_NOM_PARK_RZQ_DIV4, |
| 65 |
MV_DDR_RTT_NOM_PARK_RZQ_DIV1 |
| 66 |
}, |
| 67 |
{ |
| 68 |
MV_DDR_RTT_WR_DYN_ODT_OFF, |
| 69 |
MV_DDR_RTT_WR_RZQ_DIV2 |
| 70 |
}, |
| 71 |
MV_DDR_DIC_RZQ_DIV7 |
| 72 |
}, |
| 73 |
{ |
| 74 |
MV_DDR_OHM_30, |
| 75 |
MV_DDR_OHM_30, |
| 76 |
MV_DDR_OHM_30, |
| 77 |
MV_DDR_OHM_30, |
| 78 |
{ |
| 79 |
MV_DDR_OHM_60, |
| 80 |
MV_DDR_OHM_120 |
| 81 |
}, |
| 82 |
{ |
| 83 |
MV_DDR_OHM_60, |
| 84 |
MV_DDR_OHM_120 |
| 85 |
}, |
| 86 |
}, |
| 87 |
{ |
| 88 |
MV_DDR_ODT_CFG_NORMAL, |
| 89 |
MV_DDR_ODT_CFG_ALWAYS_ON, |
| 90 |
MV_DDR_ODT_CFG_NORMAL, |
| 91 |
}, |
| 92 |
} |
| 93 |
}; |
| 94 |
|
| 95 |
struct mv_ddr_topology_map *mv_ddr_topology_map_get(void) |
| 96 |
{ |
| 97 |
|
| 98 |
return &board_topology_map; |
| 99 |
} |
| 100 |
|
| 101 |
static void mpp_config(void) |
| 102 |
{ |
| 103 |
uint32_t val; |
| 104 |
uintptr_t reg; |
| 105 |
|
| 106 |
|
| 107 |
reg = MVEBU_AP_MPP_CTRL0_7_REG; |
| 108 |
|
| 109 |
val = mmio_read_32(reg); |
| 110 |
val &= ~((MVEBU_MPP_CTRL_MASK << MVEBU_AP_MPP_CTRL4_OFFS) | |
| 111 |
(MVEBU_MPP_CTRL_MASK << MVEBU_AP_MPP_CTRL5_OFFS)); |
| 112 |
val |= ((MVEBU_AP_MPP_CTRL4_I2C0_SDA_ENA << MVEBU_AP_MPP_CTRL4_OFFS) | |
| 113 |
(MVEBU_AP_MPP_CTRL5_I2C0_SCK_ENA << MVEBU_AP_MPP_CTRL5_OFFS)); |
| 114 |
|
| 115 |
mmio_write_32(reg, val); |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
void plat_marvell_dram_update_topology(void) |
| 124 |
{ |
| 125 |
struct mv_ddr_topology_map *tm = mv_ddr_topology_map_get(); |
| 126 |
|
| 127 |
INFO("Gathering DRAM information\n"); |
| 128 |
|
| 129 |
if (tm->cfg_src == MV_DDR_CFG_SPD) { |
| 130 |
|
| 131 |
mpp_config(); |
| 132 |
|
| 133 |
i2c_init((void *)MVEBU_AP_I2C_BASE); |
| 134 |
|
| 135 |
i2c_write(I2C_SPD_P0_ADDR, 0x0, 1, tm->spd_data.all_bytes, 0); |
| 136 |
|
| 137 |
i2c_read(I2C_SPD_ADDR, 0x0, 1, tm->spd_data.all_bytes, |
| 138 |
sizeof(tm->spd_data.all_bytes)); |
| 139 |
} |
| 140 |
} |