coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootblock.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootblock_common.h>
4 #include <device/pci_def.h>
5 #include <device/pci_ops.h>
6 #include <intelblocks/pcr.h>
7 #include <soc/pci_devs.h>
8 #include <soc/pcr_ids.h>
11 #include <tp_pch_gpio.h>
12 
13 /* these are defined in intelblocks/lpc_lib.h but we can't use them yet */
14 #define PCR_DMI_LPCIOD 0x2770
15 #define PCR_DMI_LPCIOE 0x2774
16 #define ASPEED_CONFIG_INDEX 0x2E
17 #define ASPEED_CONFIG_DATA 0x2F
18 
19 static void enable_espi_lpc_io_windows(void)
20 {
21  /*
22  * Set up decoding windows on PCH over PCR. The CPUs use two of AST2500 SIO ports,
23  * one is connected to debug header (SUART1) and another is used as SOL (SUART2).
24  * For that end it is wired into BMC virtual port.
25  */
26 
27  /* Open IO windows: 0x3f8 for com1 and 02e8 for com2 */
28  pcr_or32(PID_DMI, PCR_DMI_LPCIOD, (0 << 0) | (1 << 4));
29  /* LPC I/O enable: com1 and com2 */
30  pcr_or32(PID_DMI, PCR_DMI_LPCIOE, (1 << 0) | (1 << 1));
31 
32  /* Enable com1 (0x3f8), com2 (02f8) and superio (0x2e) */
34  (1 << 28) | (1 << 16) | (1 << 17) | (0 << 0) | (1 << 4));
35 }
36 
38 {
39  switch (com) {
40  case 0:
41  return AST2400_SUART1;
42  case 1:
43  return AST2400_SUART2;
44  case 2:
45  return AST2400_SUART3;
46  case 4:
47  return AST2400_SUART4;
48  default:
49  return AST2400_SUART1;
50  }
51 }
52 
54 {
55  /* pre-configure Lewisburg PCH GPIO pads */
57 
58  /* Open IO windows */
60 
61  /* Configure appropriate physical port of SuperIO chip off BMC */
62  const pnp_devfn_t serial_dev = PNP_DEV(ASPEED_CONFIG_INDEX,
63  com_to_ast_sio(CONFIG_UART_FOR_CONSOLE));
64  aspeed_enable_serial(serial_dev, CONFIG_TTYS0_BASE);
65 
66  /* Port 80h direct to GPIO for LED display */
69 
70  /* Enable UART function pin */
71  aspeed_enable_uart_pin(serial_dev);
72 }
#define PID_DMI
Definition: pcr_ids.h:23
void aspeed_enable_uart_pin(pnp_devfn_t dev)
Definition: early_config.c:508
@ GPIOH
Definition: aspeed.h:421
void aspeed_enable_port80_direct_gpio(pnp_devfn_t dev, gpio_group_sel g)
Definition: early_config.c:105
void aspeed_enable_serial(pnp_devfn_t dev, uint16_t iobase)
Definition: early_serial.c:45
#define AST2400_SUART3
Definition: ast2400.h:11
#define AST2400_SUART1
Definition: ast2400.h:6
#define AST2400_SUART4
Definition: ast2400.h:12
#define AST2400_SUART2
Definition: ast2400.h:7
#define AST2400_GPIO
Definition: ast2400.h:10
#define ARRAY_SIZE(a)
Definition: helpers.h:12
void pcr_or32(uint8_t pid, uint16_t offset, uint32_t ordata)
Definition: pcr.c:184
__weak void bootblock_mainboard_early_init(void)
Definition: bootblock.c:16
static const struct pad_config gpio_table[]
Definition: bootblock.c:11
static void enable_espi_lpc_io_windows(void)
Definition: bootblock.c:19
#define PCR_DMI_LPCIOD
Definition: bootblock.c:14
#define PCR_DMI_LPCIOE
Definition: bootblock.c:15
static uint8_t com_to_ast_sio(uint8_t com)
Definition: bootblock.c:37
#define ASPEED_CONFIG_INDEX
Definition: bootblock.c:16
static __always_inline void pci_s_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value)
Definition: pci_io_cfg.h:110
#define PNP_DEV(PORT, FUNC)
Definition: pnp_type.h:10
u32 pnp_devfn_t
Definition: pnp_type.h:8
void gpio_configure_pads(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
program a particular set of GPIO
Definition: gpio.c:307
#define PCH_DEV_LPC
Definition: pci_devs.h:224
unsigned char uint8_t
Definition: stdint.h:8