| 1 |
|
| 2 |
|
| 3 |
#include <arch/bootblock.h> |
| 4 |
#include <arch/io.h> |
| 5 |
#include <device/pci_ops.h> |
| 6 |
#include <soc/iosf.h> |
| 7 |
#include <soc/iomap.h> |
| 8 |
#include <soc/gpio.h> |
| 9 |
#include <soc/lpc.h> |
| 10 |
#include <soc/spi.h> |
| 11 |
#include <soc/pm.h> |
| 12 |
|
| 13 |
static void program_base_addresses(void) |
| 14 |
{ |
| 15 |
uint32_t reg; |
| 16 |
const uint32_t lpc_dev = PCI_DEV(0, LPC_DEV, LPC_FUNC); |
| 17 |
|
| 18 |
|
| 19 |
reg = PMC_BASE_ADDRESS | 2; |
| 20 |
pci_write_config32(lpc_dev, PBASE, reg); |
| 21 |
reg = IO_BASE_ADDRESS | 2; |
| 22 |
pci_write_config32(lpc_dev, IOBASE, reg); |
| 23 |
reg = ILB_BASE_ADDRESS | 2; |
| 24 |
pci_write_config32(lpc_dev, IBASE, reg); |
| 25 |
reg = SPI_BASE_ADDRESS | 2; |
| 26 |
pci_write_config32(lpc_dev, SBASE, reg); |
| 27 |
reg = MPHY_BASE_ADDRESS | 2; |
| 28 |
pci_write_config32(lpc_dev, MPBASE, reg); |
| 29 |
reg = PUNIT_BASE_ADDRESS | 2; |
| 30 |
pci_write_config32(lpc_dev, PUBASE, reg); |
| 31 |
reg = RCBA_BASE_ADDRESS | 1; |
| 32 |
pci_write_config32(lpc_dev, RCBA, reg); |
| 33 |
|
| 34 |
|
| 35 |
reg = ACPI_BASE_ADDRESS | 2; |
| 36 |
pci_write_config32(lpc_dev, ABASE, reg); |
| 37 |
reg = GPIO_BASE_ADDRESS | 2; |
| 38 |
pci_write_config32(lpc_dev, GBASE, reg); |
| 39 |
} |
| 40 |
|
| 41 |
static void tco_disable(void) |
| 42 |
{ |
| 43 |
uint32_t reg; |
| 44 |
|
| 45 |
reg = inl(ACPI_BASE_ADDRESS + TCO1_CNT); |
| 46 |
reg |= TCO_TMR_HALT; |
| 47 |
outl(reg, ACPI_BASE_ADDRESS + TCO1_CNT); |
| 48 |
} |
| 49 |
|
| 50 |
static void spi_init(void) |
| 51 |
{ |
| 52 |
void *scs = (void *)(SPI_BASE_ADDRESS + SCS); |
| 53 |
void *bcr = (void *)(SPI_BASE_ADDRESS + BCR); |
| 54 |
uint32_t reg; |
| 55 |
|
| 56 |
|
| 57 |
write32(scs, read32(scs) & ~SMIWPEN); |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
reg = (read32(bcr) & ~SRC_MASK) | SRC_CACHE_PREFETCH | BCR_WPD; |
| 63 |
reg &= ~EISS; |
| 64 |
write32(bcr, reg); |
| 65 |
} |
| 66 |
|
| 67 |
static void byt_config_com1_and_enable(void) |
| 68 |
{ |
| 69 |
uint32_t reg; |
| 70 |
|
| 71 |
|
| 72 |
reg = 1; |
| 73 |
pci_write_config32(PCI_DEV(0, LPC_DEV, 0), UART_CONT, reg); |
| 74 |
|
| 75 |
|
| 76 |
score_select_func(UART_RXD_PAD, 1); |
| 77 |
score_select_func(UART_TXD_PAD, 1); |
| 78 |
} |
| 79 |
|
| 80 |
static void setup_mmconfig(void) |
| 81 |
{ |
| 82 |
uint32_t reg; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
reg = 0; |
| 90 |
|
| 91 |
pci_io_write_config32(IOSF_PCI_DEV, MCRX_REG, reg); |
| 92 |
reg = CONFIG_ECAM_MMCONF_BASE_ADDRESS | 1; |
| 93 |
pci_io_write_config32(IOSF_PCI_DEV, MDR_REG, reg); |
| 94 |
reg = IOSF_OPCODE(IOSF_OP_WRITE_BUNIT) | IOSF_PORT(IOSF_PORT_BUNIT) | |
| 95 |
IOSF_REG(BUNIT_MMCONF_REG) | IOSF_BYTE_EN; |
| 96 |
pci_io_write_config32(IOSF_PCI_DEV, MCR_REG, reg); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
void bootblock_early_northbridge_init(void) |
| 102 |
{ |
| 103 |
|
| 104 |
setup_mmconfig(); |
| 105 |
|
| 106 |
|
| 107 |
program_base_addresses(); |
| 108 |
tco_disable(); |
| 109 |
|
| 110 |
if (CONFIG(ENABLE_BUILTIN_COM1)) |
| 111 |
byt_config_com1_and_enable(); |
| 112 |
|
| 113 |
spi_init(); |
| 114 |
} |