blob: e3a0a011662e9211b36f2de3da49baa337b8a43c [file] [log] [blame]
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2017 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include "harcuvar_boardid.h"
18#include "gpio.h"
19#include "spd/spd.h"
20#include <console/console.h>
21#include <fsp/api.h>
22#include <fsp/soc_binding.h>
23#include <string.h>
24
25#if IS_ENABLED(CONFIG_ENABLE_FSP_MEMORY_DOWN)
26
27/*
28 * Define platform specific Memory Down Configure structure.
29 *
30 * If CONFIG_ENABLE_FSP_MEMORY_DOWN is enabled, the MEMORY_DOWN_CONFIG
31 * structure should be customized to match the design.
32 *
33 * .SlotState indicates the memory down state of the specific channel/DIMM.
34 *
35 * SlotState options:
36 *
37 * STATE_MEMORY_DOWN: Memory down.
38 * STATE_MEMORY_SLOT: Physical memory slot.
39 *
40 * .SpdDataLen should always be MAX_SPD_BYTES/512.
41 *
42 * .SpdDataPtr is pointing to the SPD data structure when memory modules
43 * are memory down.
44 *
45 * SpdDataPtr options:
46 *
47 * Non-NULL: Pointing to SPD data structure.
48 * NULL: Physical memory slot, no SPD data used.
49 *
50 * DIMM Mapping of SlotState & SpdDataPtr:
51 *
52 * {{CH0DIMM0, CH0DIMM1}, {CH1DIMM0, CH1DIMM1}}
53 *
54 * Sample: Channel 0 is memory down and channel 1 is physical slot.
55 *
56 * const MEMORY_DOWN_CONFIG mMemoryDownConfig = {
57 * .SlotState = {
58 * {STATE_MEMORY_DOWN, STATE_MEMORY_DOWN},
59 * {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT}
60 * },
61 * .SpdDataLen = MAX_SPD_BYTES,
62 * .SpdDataPtr = {
63 * {(void *)CONFIG_SPD_LOC, (void *)CONFIG_SPD_LOC},
64 * {(void *)NULL, (void *)NULL}
65 * }
66 * }
67 */
68
69const MEMORY_DOWN_CONFIG mMemoryDownConfig = {
70 .SlotState = {
71 {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT},
72 {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT}
73 },
74 .SpdDataLen = MAX_SPD_BYTES,
75 .SpdDataPtr = {
76 {(void *)NULL, (void *)NULL},
77 {(void *)NULL, (void *)NULL}
78 }
79};
80
81#endif /* CONFIG_ENABLE_FSP_MEMORY_DOWN */
82
83void mainboard_config_gpios(void);
84void mainboard_memory_init_params(FSPM_UPD *mupd);
85
86/*
87* Configure GPIO depend on platform
88*/
89void mainboard_config_gpios(void)
90{
91 size_t num;
Julien Viard de Galbert7ebb6b02018-03-01 16:03:31 +010092 const struct dnv_pad_config *table;
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020093 uint8_t boardid = board_id();
94
95 /* Configure pads prior to SiliconInit() in case there's any
96 * dependencies during hardware initialization.
97 */
98 switch (boardid) {
99 case BoardIdHarcuvar:
100 table = harcuvar_gpio_table;
101 num = ARRAY_SIZE(harcuvar_gpio_table);
102 break;
103 default:
104 table = NULL;
105 num = 0;
106 break;
107 }
108
109 if ((!table) || (!num)) {
110 printk(BIOS_ERR, "ERROR: No valid GPIO table found!\n");
111 return;
112 }
113
114 printk(BIOS_INFO, "GPIO table: 0x%x, entry num: 0x%x!\n",
115 (uint32_t)table, (uint32_t)num);
Julien Viard de Galbert7ebb6b02018-03-01 16:03:31 +0100116 gpio_configure_dnv_pads(table, num);
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +0200117}
118
119void mainboard_memory_init_params(FSPM_UPD *mupd)
120{
121#if IS_ENABLED(CONFIG_ENABLE_FSP_MEMORY_DOWN)
122 uint8_t *spd_data_ptr = NULL;
123
124 /* Get SPD data pointer */
125 spd_data_ptr = mainboard_find_spd_data();
126
127 if (spd_data_ptr != NULL) {
128 printk(BIOS_DEBUG, "Memory Down function is enabled!\n");
129
130 /* Enable Memory Down function, set Memory
131 * Down Configure structure pointer.
132 */
133 mupd->FspmConfig.PcdMemoryDown = 1;
134 mupd->FspmConfig.PcdMemoryDownConfigPtr =
135 (uint32_t)&mMemoryDownConfig;
136 } else {
137 printk(BIOS_DEBUG, "Memory Down function is disabled!\n");
138
139 /* Disable Memory Down function */
140 mupd->FspmConfig.PcdMemoryDown = 0;
141 mupd->FspmConfig.PcdMemoryDownConfigPtr = 0;
142 }
143#endif /* CONFIG_ENABLE_FSP_MEMORY_DOWN */
144}