blob: eb5153c1339bc9d8d87c785889b014d42fcf4041 [file] [log] [blame]
Angel Ponsb6636b02020-04-05 13:21:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Shelley Chene3110b82018-12-10 12:59:01 -08002
Aamir Bohra4b85d462018-12-16 13:10:58 +05303#include <baseboard/variants.h>
Furquan Shaikh74184642019-03-11 20:22:59 -07004#include <ec/google/chromeec/ec.h>
Philip Chen0d4200f2019-04-29 10:18:24 -07005#include <gpio.h>
Furquan Shaikh74184642019-03-11 20:22:59 -07006#include <memory_info.h>
Aamir Bohra4b85d462018-12-16 13:10:58 +05307#include <soc/cnl_memcfg_init.h>
Shelley Chene3110b82018-12-10 12:59:01 -08008#include <soc/romstage.h>
Aamir Bohrad3c55442019-06-16 19:38:45 +05309#include <variant/gpio.h>
Philip Chen0d4200f2019-04-29 10:18:24 -070010
11/*
12 * GPIO_MEM_CH_SEL is set to 1 for single channel skus
13 * and 0 for dual channel skus.
14 */
15#define GPIO_MEM_CH_SEL GPP_F2
16
Furquan Shaikh463fca42019-07-11 22:38:42 -070017int __weak variant_memory_sku(void)
Philip Chen0d4200f2019-04-29 10:18:24 -070018{
19 const gpio_t spd_gpios[] = {
20 GPIO_MEM_CONFIG_0,
21 GPIO_MEM_CONFIG_1,
22 GPIO_MEM_CONFIG_2,
23 GPIO_MEM_CONFIG_3,
24 };
25
26 return gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios));
27}
28
Shelley Chene3110b82018-12-10 12:59:01 -080029void mainboard_memory_init_params(FSPM_UPD *memupd)
30{
Shelley Chen2ee720c2019-02-11 13:06:10 -080031 struct cnl_mb_cfg memcfg;
Philip Chen0d4200f2019-04-29 10:18:24 -070032 int mem_sku;
33 int is_single_ch_mem;
Aamir Bohra4b85d462018-12-16 13:10:58 +053034
Shelley Chen2ee720c2019-02-11 13:06:10 -080035 variant_memory_params(&memcfg);
Furquan Shaikh463fca42019-07-11 22:38:42 -070036 mem_sku = variant_memory_sku();
Philip Chen0d4200f2019-04-29 10:18:24 -070037 /*
38 * GPP_F2 is the MEM_CH_SEL gpio, which is set to 1 for single
39 * channel skus and 0 for dual channel skus.
40 */
41 is_single_ch_mem = gpio_get(GPIO_MEM_CH_SEL);
42
43 /*
44 * spd[0]-spd[3] map to CH0D0, CH0D1, CH1D0, CH1D1 respectively.
45 * Dual-DIMM memory is not used in hatch family, so we only
46 * fill in spd_info for CH0D0 and CH1D0 here.
47 */
48 memcfg.spd[0].read_type = READ_SPD_CBFS;
49 memcfg.spd[0].spd_spec.spd_index = mem_sku;
50 if (!is_single_ch_mem) {
51 memcfg.spd[2].read_type = READ_SPD_CBFS;
52 memcfg.spd[2].spd_spec.spd_index = mem_sku;
53 }
54
55 cannonlake_memcfg_init(&memupd->FspmConfig, &memcfg);
Shelley Chene3110b82018-12-10 12:59:01 -080056}