Compare commits
1 Commits
upstream-8
...
upstream-5
Author | SHA1 | Date | |
---|---|---|---|
|
67a7ee7eb8 |
@@ -36,6 +36,18 @@
|
|||||||
#define DDR4_SPD_PART_OFF 329
|
#define DDR4_SPD_PART_OFF 329
|
||||||
#define DDR4_SPD_PART_LEN 20
|
#define DDR4_SPD_PART_LEN 20
|
||||||
#define DDR4_SPD_SN_OFF 325
|
#define DDR4_SPD_SN_OFF 325
|
||||||
|
#define MAX_SPD_PAGE_SIZE_SPD5 128
|
||||||
|
#define MAX_SPD_SIZE (SPD_PAGE_LEN * 4)
|
||||||
|
#define SPD_HUB_MEMREG(addr) ((u8)(0x80 | (addr)))
|
||||||
|
#define SPD5_MR11 0x0B
|
||||||
|
#define SPD5_MR0 0x00
|
||||||
|
#define SPD5_MEMREG_REG(addr) ((u8)((~0x80) & (addr)))
|
||||||
|
#define SPD5_MR0_SPD5_HUB_DEV 0x51
|
||||||
|
|
||||||
|
struct spd_offset_table {
|
||||||
|
u16 start; /* Offset 0 */
|
||||||
|
u16 end; /* Offset 2 */
|
||||||
|
};
|
||||||
|
|
||||||
struct spd_block {
|
struct spd_block {
|
||||||
u8 addr_map[CONFIG_DIMM_MAX]; /* 7 bit I2C addresses */
|
u8 addr_map[CONFIG_DIMM_MAX]; /* 7 bit I2C addresses */
|
||||||
|
@@ -209,7 +209,9 @@ enum cb_err spd_fill_from_cache(uint8_t *spd_cache, struct spd_block *blk)
|
|||||||
|
|
||||||
dram_type = *(spd_cache + SC_SPD_OFFSET(i) + SPD_DRAM_TYPE);
|
dram_type = *(spd_cache + SC_SPD_OFFSET(i) + SPD_DRAM_TYPE);
|
||||||
|
|
||||||
if (dram_type == SPD_DRAM_DDR4)
|
if (dram_type == SPD_DRAM_DDR5)
|
||||||
|
blk->len = CONFIG_DIMM_SPD_SIZE;
|
||||||
|
else if (dram_type == SPD_DRAM_DDR4)
|
||||||
blk->len = SPD_PAGE_LEN_DDR4;
|
blk->len = SPD_PAGE_LEN_DDR4;
|
||||||
else
|
else
|
||||||
blk->len = SPD_PAGE_LEN;
|
blk->len = SPD_PAGE_LEN;
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include <device/pci_ids.h>
|
#include <device/pci_ids.h>
|
||||||
#include <device/pci_ops.h>
|
#include <device/pci_ops.h>
|
||||||
#include <intelblocks/cse.h>
|
#include <intelblocks/cse.h>
|
||||||
#include <intelblocks/fast_spi.h>
|
|
||||||
#include <intelblocks/me.h>
|
#include <intelblocks/me.h>
|
||||||
#include <intelblocks/pmclib.h>
|
#include <intelblocks/pmclib.h>
|
||||||
#include <intelblocks/post_codes.h>
|
#include <intelblocks/post_codes.h>
|
||||||
@@ -1311,17 +1310,10 @@ static void cse_set_state(struct device *dev)
|
|||||||
|
|
||||||
size_t enable_reply_size;
|
size_t enable_reply_size;
|
||||||
|
|
||||||
int send;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
/* Function Start */
|
/* Function Start */
|
||||||
|
|
||||||
if (fast_spi_flash_descriptor_override()) {
|
int send;
|
||||||
printk(BIOS_WARNING, "HECI: not setting ME state because "
|
int result;
|
||||||
"flash descriptor override is enabled\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the CMOS value "me_state" exists, if it doesn't, then
|
* Check if the CMOS value "me_state" exists, if it doesn't, then
|
||||||
* don't do anything.
|
* don't do anything.
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
#include <bootstate.h>
|
#include <bootstate.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <intelblocks/cse.h>
|
#include <intelblocks/cse.h>
|
||||||
#include <intelblocks/fast_spi.h>
|
|
||||||
#include <intelblocks/pmc_ipc.h>
|
#include <intelblocks/pmc_ipc.h>
|
||||||
#include <security/vboot/vboot_common.h>
|
#include <security/vboot/vboot_common.h>
|
||||||
#include <soc/intel/common/reset.h>
|
#include <soc/intel/common/reset.h>
|
||||||
@@ -244,11 +243,6 @@ static void do_send_end_of_post(bool wait_for_completion)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fast_spi_flash_descriptor_override()) {
|
|
||||||
printk(BIOS_WARNING, "CSE: not sending EOP because flash descriptor override is enabled\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!eop_sent) {
|
if (!eop_sent) {
|
||||||
set_cse_device_state(PCH_DEVFN_CSE, DEV_ACTIVE);
|
set_cse_device_state(PCH_DEVFN_CSE, DEV_ACTIVE);
|
||||||
timestamp_add_now(TS_ME_END_OF_POST_START);
|
timestamp_add_now(TS_ME_END_OF_POST_START);
|
||||||
|
@@ -483,15 +483,6 @@ void fast_spi_clear_outstanding_status(void)
|
|||||||
write32(spibar + SPIBAR_HSFSTS_CTL, SPIBAR_HSFSTS_W1C_BITS);
|
write32(spibar + SPIBAR_HSFSTS_CTL, SPIBAR_HSFSTS_W1C_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if flash descriptor override is asserted */
|
|
||||||
bool fast_spi_flash_descriptor_override(void)
|
|
||||||
{
|
|
||||||
void *spibar = fast_spi_get_bar();
|
|
||||||
uint32_t hsfsts = read32(spibar + SPIBAR_HSFSTS_CTL);
|
|
||||||
printk(BIOS_DEBUG, "HSFSTS: 0x%X\n", hsfsts);
|
|
||||||
return !(hsfsts & SPIBAR_HSFSTS_FDOPSS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* As there is no official ACPI ID for this controller use the generic PNP ID for now. */
|
/* As there is no official ACPI ID for this controller use the generic PNP ID for now. */
|
||||||
static const char *fast_spi_acpi_hid(const struct device *dev)
|
static const char *fast_spi_acpi_hid(const struct device *dev)
|
||||||
|
@@ -111,7 +111,5 @@ void fast_spi_set_bde(void);
|
|||||||
* Set FAST_SPIBAR Vendor Component Lock bit.
|
* Set FAST_SPIBAR Vendor Component Lock bit.
|
||||||
*/
|
*/
|
||||||
void fast_spi_set_vcl(void);
|
void fast_spi_set_vcl(void);
|
||||||
/* Check if flash descriptor override is asserted */
|
|
||||||
bool fast_spi_flash_descriptor_override(void);
|
|
||||||
|
|
||||||
#endif /* SOC_INTEL_COMMON_BLOCK_FAST_SPI_H */
|
#endif /* SOC_INTEL_COMMON_BLOCK_FAST_SPI_H */
|
||||||
|
@@ -13,8 +13,11 @@ static void update_spd_len(struct spd_block *blk)
|
|||||||
if (blk->spd_array[i] != NULL)
|
if (blk->spd_array[i] != NULL)
|
||||||
j |= blk->spd_array[i][SPD_DRAM_TYPE];
|
j |= blk->spd_array[i][SPD_DRAM_TYPE];
|
||||||
|
|
||||||
|
/* If spd used is DDR5, then its length is 1024 byte. */
|
||||||
|
if (j == SPD_DRAM_DDR5)
|
||||||
|
blk->len = CONFIG_DIMM_SPD_SIZE;
|
||||||
/* If spd used is DDR4, then its length is 512 byte. */
|
/* If spd used is DDR4, then its length is 512 byte. */
|
||||||
if (j == SPD_DRAM_DDR4)
|
else if (j == SPD_DRAM_DDR4)
|
||||||
blk->len = SPD_PAGE_LEN_DDR4;
|
blk->len = SPD_PAGE_LEN_DDR4;
|
||||||
else
|
else
|
||||||
blk->len = SPD_PAGE_LEN;
|
blk->len = SPD_PAGE_LEN;
|
||||||
@@ -37,6 +40,61 @@ static void smbus_read_spd(u8 *spd, u8 addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void switch_page(u8 spd_addr, u8 new_page)
|
||||||
|
{
|
||||||
|
u32 offset;
|
||||||
|
/*
|
||||||
|
* By default,an SPD5 hub accepts 1 byte addressing pointing
|
||||||
|
* to the first 128 bytes of memory. MR11[2:0] selects the page
|
||||||
|
* pointer to address the entire 1024 bytes of non-volatile memory.
|
||||||
|
*/
|
||||||
|
offset = SPD5_MEMREG_REG(SPD5_MR11);
|
||||||
|
smbus_write_byte(spd_addr, offset, new_page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the SPD data over the SMBus, at the specified SPD address,
|
||||||
|
* starting at the specified starting offset and read the given amount of data.
|
||||||
|
*/
|
||||||
|
static void smbus_read_spd5(u8 *spd, u8 spd_addr, u16 size)
|
||||||
|
{
|
||||||
|
u8 page = ~0;
|
||||||
|
u32 max_page_size = MAX_SPD_PAGE_SIZE_SPD5;
|
||||||
|
|
||||||
|
if (size > MAX_SPD_SIZE) {
|
||||||
|
printk(BIOS_ERR, "Maximum SPD size reached\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
u8 next_page = (u8) (i / max_page_size);
|
||||||
|
if (next_page != page) {
|
||||||
|
switch_page(spd_addr, next_page);
|
||||||
|
page = next_page;
|
||||||
|
}
|
||||||
|
unsigned int byte_addr = SPD_HUB_MEMREG(i % max_page_size);
|
||||||
|
spd[i] = smbus_read_byte(spd_addr, byte_addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read SPD5 MR0 and check if SPD Byte 0 matches the SPD5 HUB MR0 identifier.*/
|
||||||
|
static int is_spd5_hub(u8 spd_addr)
|
||||||
|
{
|
||||||
|
u8 spd_hub_byte;
|
||||||
|
|
||||||
|
spd_hub_byte = smbus_read_byte(spd_addr, SPD5_MEMREG_REG(SPD5_MR0));
|
||||||
|
return spd_hub_byte == SPD5_MR0_SPD5_HUB_DEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset the SPD page back to page 0 on an SPD5 Hub device at the
|
||||||
|
* input SPD SMbus address.
|
||||||
|
*/
|
||||||
|
static void reset_page_spd5(u8 spd_addr)
|
||||||
|
{
|
||||||
|
/* Set SPD5 MR11[2:0] = 0 (Page 0) */
|
||||||
|
smbus_write_byte(spd_addr, SPD5_MEMREG_REG(SPD5_MR11), 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* return -1 if SMBus errors otherwise return 0 */
|
/* return -1 if SMBus errors otherwise return 0 */
|
||||||
static int get_spd(u8 *spd, u8 addr)
|
static int get_spd(u8 *spd, u8 addr)
|
||||||
{
|
{
|
||||||
@@ -52,22 +110,31 @@ static int get_spd(u8 *spd, u8 addr)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i2c_eeprom_read(addr, 0, SPD_PAGE_LEN, spd) < 0) {
|
if (is_spd5_hub(addr)) {
|
||||||
printk(BIOS_INFO, "do_i2c_eeprom_read failed, using fallback\n");
|
smbus_read_spd5(spd, addr, CONFIG_DIMM_SPD_SIZE);
|
||||||
smbus_read_spd(spd, addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if module is DDR4, DDR4 spd is 512 byte. */
|
/* Reset the page for the next loop iteration */
|
||||||
if (spd[SPD_DRAM_TYPE] == SPD_DRAM_DDR4 && CONFIG_DIMM_SPD_SIZE > SPD_PAGE_LEN) {
|
reset_page_spd5(addr);
|
||||||
/* Switch to page 1 */
|
} else {
|
||||||
smbus_write_byte(SPD_PAGE_1, 0, 0);
|
|
||||||
|
|
||||||
if (i2c_eeprom_read(addr, 0, SPD_PAGE_LEN, spd + SPD_PAGE_LEN) < 0) {
|
if (i2c_eeprom_read(addr, 0, SPD_PAGE_LEN, spd) < 0) {
|
||||||
printk(BIOS_INFO, "do_i2c_eeprom_read failed, using fallback\n");
|
printk(BIOS_INFO, "do_i2c_eeprom_read failed, using fallback\n");
|
||||||
smbus_read_spd(spd + SPD_PAGE_LEN, addr);
|
smbus_read_spd(spd, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if module is DDR4, DDR4 spd is 512 byte. */
|
||||||
|
if (spd[SPD_DRAM_TYPE] == SPD_DRAM_DDR4 &&
|
||||||
|
CONFIG_DIMM_SPD_SIZE > SPD_PAGE_LEN) {
|
||||||
|
/* Switch to page 1 */
|
||||||
|
smbus_write_byte(SPD_PAGE_1, 0, 0);
|
||||||
|
|
||||||
|
if (i2c_eeprom_read(addr, 0, SPD_PAGE_LEN, spd + SPD_PAGE_LEN) < 0) {
|
||||||
|
printk(BIOS_INFO, "do_i2c_eeprom_read failed, using fallback\n");
|
||||||
|
smbus_read_spd(spd + SPD_PAGE_LEN, addr);
|
||||||
|
}
|
||||||
|
/* Restore to page 0 */
|
||||||
|
smbus_write_byte(SPD_PAGE_0, 0, 0);
|
||||||
}
|
}
|
||||||
/* Restore to page 0 */
|
|
||||||
smbus_write_byte(SPD_PAGE_0, 0, 0);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user