hardware-init-review/listings/src_mainboard_asus_kgpe-d16...

37 lines
983 B
C
Raw Normal View History

2024-08-22 19:18:34 +02:00
#include <device/pci_ops.h>
#include <pc80/mc146818rtc.h>
void bootblock_mainboard_init(void)
{
uint8_t recovery_enabled;
unsigned char addr;
unsigned char byte;
bootblock_northbridge_init();
bootblock_southbridge_init();
/* Recovery jumper is connected to SP5100 GPIO61, and clears the GPIO when placed in the Recovery position */
byte = pci_io_read_config8(PCI_DEV(0, 0x14, 0), 0x56);
byte |= 0x1 << 4; /* Set GPIO61 to input mode */
pci_io_write_config8(PCI_DEV(0, 0x14, 0), 0x56, byte);
recovery_enabled = (!(pci_io_read_config8(PCI_DEV(0, 0x14, 0), 0x57) & 0x1));
if (recovery_enabled) {
#if CONFIG(USE_OPTION_TABLE)
/* Clear NVRAM checksum */
for (addr = LB_CKS_RANGE_START; addr <= LB_CKS_RANGE_END; addr++) {
cmos_write(0x0, addr);
}
/* Set fallback boot */
byte = cmos_read(RTC_BOOT_BYTE);
byte &= 0xfc;
cmos_write(byte, RTC_BOOT_BYTE);
#else
/* FIXME
* Figure out how to recover if the option table is not available
*/
#endif
}
}