40 changes: 40 additions & 0 deletions src/mainboard/pcengines/apu2/mainboard.c
Expand Up @@ -137,6 +137,46 @@ static void mainboard_enable(device_t dev)

static void mainboard_final(void *chip_info) {

/* ECC was not working because all memory was marked
* as excluded from ECC checking and error reporting.
* Normally one contiguous range is excluded to cover
* framebuffer region in systems with internal GPUs.
* AGESA set bit 0, EccExclEn, in register D18F5x240 as 1.
* Range was incorrectly enabled to cover all memory
* for cases without UMA (no integrated graphics).
*
* In order to clear EccExclEn DRAM scrubber needs to be
* disabled temporarily by setting D18F3x88[DisDramScrub]
*/
u32 val;
device_t D18F3 = dev_find_device(0x1022, 0x1583, NULL);
device_t D18F5 = dev_find_device(0x1022, 0x1585, NULL);

/* Disable DRAM ECC scrubbing */
val = pci_read_config32(D18F3, 0x88);
val |= (1 << 27);
pci_write_config32(D18F3, 0x88, val);

/* Clear reserved bits in register D18F3xB8
*
* D18F3xB8 NB Array Address has reserved bits [27:10]
* Multiple experiments showed that ECC injection
* doesn't work when these bits are set.
*/
val = pci_read_config32(D18F3, 0xB8);
val &= 0xF000003F;
pci_write_config32(D18F3, 0xB8, val);

/* Disable ECC exclusion range */
val = pci_read_config32(D18F5, 0x240);
val &= ~1;
pci_write_config32(D18F5, 0x240, val);

/* Re-enable DRAM ECC scrubbing */
val = pci_read_config32(D18F3, 0x88);
val &= ~(1 << 27);
pci_write_config32(D18F3, 0x88, val);

printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER "final\n");

/* Disabling LPCCLK0 which is unused according to the schematic doesn't work. The system is stuck if we do this
Expand Down
Binary file modified src/mainboard/pcengines/apu2/variants/apu2/bootorder
Binary file not shown.
3 changes: 0 additions & 3 deletions util/genbuild_h/genbuild_h.sh
Expand Up @@ -73,7 +73,4 @@ printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x$(our_date "$DATE" +%w)\n"
printf "#define COREBOOT_DMI_DATE \"$(our_date "$DATE" +%m/%d/%Y)\"\n"
printf "\n"
printf "#define COREBOOT_COMPILE_TIME \"$(our_date "$DATE" +%T)\"\n"
printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n"
printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null || hostname 2>/dev/null)\"\n"
printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n"
printf "#endif\n"