diff options
author | Shelley Chen <shchen@chromium.org> | 2018-03-05 11:15:37 -0800 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2018-03-07 20:03:53 +0000 |
commit | 9d2e597908d4467bd325a0b581f978e5639c8b68 (patch) | |
tree | 384ea66cec5e8a7d1c2b66c75bcc691c68ff7ef8 /src/mainboard/google/poppy/variants/nami/memory.c | |
parent | ee62c4937d38880beaf629a40777a8c86639bf03 (diff) |
mb/google/poppy/variants/nami: Add memory detection logic
Alkali will use LPDDR3, so need to have Nami support both
DDR4 and LPDDR3. We do this with the PCH_MEM_CONFIG4 GPIO.
BUG=b:73514687
BRANCH=None
TEST=None
Change-Id: Ife6740ce0e8fe109ded7b954134171ba91895628
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://review.coreboot.org/25000
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/mainboard/google/poppy/variants/nami/memory.c')
-rw-r--r-- | src/mainboard/google/poppy/variants/nami/memory.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/mainboard/google/poppy/variants/nami/memory.c b/src/mainboard/google/poppy/variants/nami/memory.c index dec7626b73..6aa0e7610f 100644 --- a/src/mainboard/google/poppy/variants/nami/memory.c +++ b/src/mainboard/google/poppy/variants/nami/memory.c @@ -14,14 +14,32 @@ */ #include <baseboard/variants.h> +#include <gpio.h> +#include <variant/gpio.h> #include <string.h> /* Rcomp resistor */ static const u16 rcomp_resistor_ddp[] = { 121, 81, 100 }; static const u16 rcomp_resistor_sdp[] = { 200, 81, 100 }; +static const u16 rcomp_resistor_lpddr3[] = { 200, 81, 162 }; /* Rcomp target */ static const u16 rcomp_target[] = { 100, 40, 20, 20, 26 }; +static const u16 rcomp_target_lpddr3[] = { 100, 40, 40, 23, 40 }; + +/* DQ byte map */ +static const u8 dq_map_lpddr3[][12] = { + { 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0, + 0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 }, + { 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0, + 0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 } +}; + +/* DQS CPU<>DRAM map */ +static const u8 dqs_map_lpddr3[][8] = { + { 1, 0, 3, 2, 6, 5, 4, 7 }, + { 0, 3, 2, 1, 6, 4, 7, 5 }, +}; /* Memory ids are 1-indexed, so subtract 1 to use 0-indexed values in bitmap. */ #define MEM_ID(x) (1 << ((x) - 1)) @@ -29,10 +47,24 @@ static const u16 rcomp_target[] = { 100, 40, 20, 20, 26 }; /* Bitmap to indicate which memory ids are using DDP. */ static const uint16_t ddp_bitmap = MEM_ID(4); -void variant_memory_params(struct memory_params *p) +static void fill_lpddr3_memory_params(struct memory_params *p) +{ + p->type = MEMORY_LPDDR3; + p->use_sec_spd = 1; + p->dq_map = dq_map_lpddr3; + p->dq_map_size = sizeof(dq_map_lpddr3); + p->dqs_map = dqs_map_lpddr3; + p->dqs_map_size = sizeof(dqs_map_lpddr3); + p->rcomp_resistor = rcomp_resistor_lpddr3; + p->rcomp_resistor_size = sizeof(rcomp_resistor_lpddr3); + p->rcomp_target = rcomp_target_lpddr3; + p->rcomp_target_size = sizeof(rcomp_target_lpddr3); +} + +static void fill_ddr4_memory_params(struct memory_params *p) { - memset(p, 0, sizeof(*p)); p->type = MEMORY_DDR4; + p->use_sec_spd = 0; /* Rcomp resistor values are different for SDP and DDP. */ if (ddp_bitmap & MEM_ID(variant_memory_sku())) { @@ -46,3 +78,15 @@ void variant_memory_params(struct memory_params *p) p->rcomp_target = rcomp_target; p->rcomp_target_size = sizeof(rcomp_target); } + +void variant_memory_params(struct memory_params *p) +{ + memset(p, 0, sizeof(*p)); + gpio_input(GPIO_MEM_CONFIG_4); + if (gpio_get(GPIO_MEM_CONFIG_4)) + /* set to LPDDR3 */ + fill_lpddr3_memory_params(p); + else + /* default to DDR4 */ + fill_ddr4_memory_params(p); +} |