/* Setup SLP signal assertion, SLP_S4=4s, SLP_S3=50ms */ REG_PCI_RMW16(GEN_PMCON_3, ~((3 << 4)|(1 << 10)), (1 << 3)|(1 << 11)|(1 << 12)), /* Prepare sleep mode */ REG_IO_RMW32(ACPI_BASE_ADDRESS + PM1_CNT, ~SLP_TYP, SCI_EN), /* Setup NMI on errors, disable SERR */ REG_IO_RMW8(0x61, ~0xf0, (1 << 2)), /* Disable NMI sources */ REG_IO_OR8(0x70, (1 << 7)), /* Indicate DRAM init done for MRC */ REG_PCI_OR8(GEN_PMCON_2, (1 << 7)), /* Enable BIOS updates outside of SMM */ REG_PCI_RMW8(0xdc, ~(1 << 5), 0), /* Clear status bits to prevent unexpected wake */ REG_MMIO_OR32(RCBA_BASE_ADDRESS + 0x3310, 0x0000002f), REG_MMIO_RMW32(RCBA_BASE_ADDRESS + 0x3f02, ~0x0000000f, 0), /* Enable PCIe Releaxed Order */ REG_MMIO_OR32(RCBA_BASE_ADDRESS + 0x2314, (1 << 31) | (1 << 7)), REG_MMIO_OR32(RCBA_BASE_ADDRESS + 0x1114, (1 << 15) | (1 << 14)), /* Setup SERIRQ, enable continuous mode */ REG_PCI_OR8(SERIRQ_CNTL, (1 << 7) | (1 << 6)), #if !CONFIG_SERIRQ_CONTINUOUS_MODE REG_PCI_RMW8(SERIRQ_CNTL, ~(1 << 6), 0), #endif REG_SCRIPT_END }; /* Magic register settings for power management */ static const struct reg_script pch_pm_init_script[] = { REG_PCI_WRITE8(0xa9, 0x46), REG_MMIO_RMW32(RCBA_BASE_ADDRESS + 0x232c, ~1, 0),
REG_PCI_WRITE32(GPIO_BASE, GPIO_BASE_ADDRESS | 1), REG_PCI_WRITE8(GPIO_CNTL, GPIO_EN), /* Set COM1/COM2 decode range */ REG_PCI_WRITE16(LPC_IO_DEC, 0x0010), /* Enable legacy decode ranges */ REG_PCI_WRITE16(LPC_EN, CNF1_LPC_EN | CNF2_LPC_EN | GAMEL_LPC_EN | COMA_LPC_EN | KBC_LPC_EN | MC_LPC_EN), /* Enable IOAPIC */ REG_MMIO_WRITE16(RCBA_BASE_ADDRESS + OIC, 0x0100), /* Read back for posted write */ REG_MMIO_READ16(RCBA_BASE_ADDRESS + OIC), /* Set HPET address and enable it */ REG_MMIO_RMW32(RCBA_BASE_ADDRESS + HPTC, ~3, (1 << 7)), /* Read back for posted write */ REG_MMIO_READ32(RCBA_BASE_ADDRESS + HPTC), /* Enable HPET to start counter */ REG_MMIO_OR32(HPET_BASE_ADDRESS + 0x10, (1 << 0)), /* Disable reset */ REG_MMIO_OR32(RCBA_BASE_ADDRESS + GCS, (1 << 5)), /* TCO timer halt */ REG_IO_OR16(ACPI_BASE_ADDRESS + TCO1_CNT, TCO_TMR_HLT), /* Enable upper 128 bytes of CMOS */ REG_MMIO_OR32(RCBA_BASE_ADDRESS + RC, (1 << 2)), /* Disable unused device (always) */ REG_MMIO_OR32(RCBA_BASE_ADDRESS + FD, PCH_DISABLE_ALWAYS),
REG_PCI_OR16(0x7a, 0x14de), /* Enable SB local clock gating * D29:F0:7C[14,3,2]=111b (14 set in clock gating step) */ REG_PCI_OR32(0x7c, 0x0000000c), REG_PCI_OR32(0x8c, 0x00000001), /* Enable dynamic clock gating 0x4001=0xCE */ REG_IOSF_RMW(IOSF_PORT_USBPHY, 0x4001, 0xFFFFFF00, 0xCE), /* Magic RCBA register set sequence */ /* RCBA + 0x200=0x1 */ REG_MMIO_WRITE32(RCBA_BASE_ADDRESS + 0x200, 0x00000001), /* RCBA + 0x204=0x2 */ REG_MMIO_WRITE32(RCBA_BASE_ADDRESS + 0x204, 0x00000002), /* RCBA + 0x208=0x0 */ REG_MMIO_WRITE32(RCBA_BASE_ADDRESS + 0x208, 0x00000000), /* RCBA + 0x240[4,3,2,1,0]=00000b */ REG_MMIO_RMW32(RCBA_BASE_ADDRESS + 0x240, ~0x0000001f, 0), /* RCBA + 0x318[9,8,6,5,4,3,2,1,0]=000000111b */ REG_MMIO_RMW32(RCBA_BASE_ADDRESS + 0x318, ~0x00000378, 0x00000007), /* RCBA + 0x31c[3,2,1,0]=0011b */ REG_MMIO_RMW32(RCBA_BASE_ADDRESS + 0x31c, ~0x0000000c, 0x00000003), REG_SCRIPT_END }; static const struct reg_script ehci_clock_gating_script[] = { /* Enable SB local clock gating */ REG_PCI_OR32(0x7c, 0x00004000), /* RCBA + 0x284=0xbe (step B0+) */ REG_MMIO_WRITE32(RCBA_BASE_ADDRESS + 0x284, 0x000000be), REG_SCRIPT_END };
#include <arch/early_variables.h> #include <delay.h> #include <device/pci_def.h> #include <reg_script.h> #include <stdint.h> #include <uart8250.h> #include <soc/iobp.h> #include <soc/serialio.h> const struct reg_script uart_init[] = { /* Set MMIO BAR */ REG_PCI_WRITE32(PCI_BASE_ADDRESS_0, CONFIG_TTYS0_BASE), /* Enable Memory access and Bus Master */ REG_PCI_OR32(PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER), /* Initialize LTR */ REG_MMIO_RMW32(CONFIG_TTYS0_BASE + SIO_REG_PPR_GEN, ~SIO_REG_PPR_GEN_LTR_MODE_MASK, 0), REG_MMIO_RMW32(CONFIG_TTYS0_BASE + SIO_REG_PPR_RST, ~(SIO_REG_PPR_RST_ASSERT), 0), /* Take UART out of reset */ REG_MMIO_OR32(CONFIG_TTYS0_BASE + SIO_REG_PPR_RST, SIO_REG_PPR_RST_ASSERT), /* Set M and N divisor inputs and enable clock */ REG_MMIO_WRITE32(CONFIG_TTYS0_BASE + SIO_REG_PPR_CLOCK, SIO_REG_PPR_CLOCK_EN | SIO_REG_PPR_CLOCK_UPDATE | (SIO_REG_PPR_CLOCK_N_DIV << 16) | (SIO_REG_PPR_CLOCK_M_DIV << 1)), REG_SCRIPT_END }; void pch_uart_init(void) {