coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <stdint.h>
4 #include <amdblocks/acpimmio.h>
5 #include <amdblocks/gpio.h>
6 #include <amdblocks/gpio_defs.h>
7 #include <device/pci_def.h>
8 #include <device/pci_ops.h>
9 #include <gpio.h>
11 
12 #include "gpio_ftns.h"
13 
14 static void early_lpc_init(void);
15 
16 void board_BeforeAgesa(struct sysinfo *cb)
17 {
18  u32 val;
19 
21 
22  /* Disable SVI2 controller to wait for command completion */
23  val = pci_read_config32(PCI_DEV(0, 0x18, 5), 0x12C);
24  if (!(val & (1 << 30))) {
25  val |= (1 << 30);
26  pci_write_config32(PCI_DEV(0, 0x18, 5), 0x12C, val);
27  }
28 
29  /* Release GPIO32/33 for other uses. */
30  pm_write8(0xea, 1);
31 }
32 
33 const struct soc_amd_gpio gpio_common[] = {
37  PAD_GPO(GPIO_57, LOW),
38  PAD_GPO(GPIO_58, LOW),
39  PAD_GPO(GPIO_59, LOW),
40  PAD_GPO(GPIO_51, HIGH),
41  PAD_GPO(GPIO_55, HIGH),
42  PAD_GPO(GPIO_64, HIGH),
43  PAD_GPO(GPIO_68, HIGH),
44 };
45 
46 const struct soc_amd_gpio gpio_apu2[] = {
48 };
49 
50 const struct soc_amd_gpio gpio_apu34[] = {
52  PAD_GPO(GPIO_33, LOW),
53 };
54 
55 const struct soc_amd_gpio gpio_apu5[] = {
57  PAD_GPO(GPIO_32, HIGH),
58  PAD_GPO(GPIO_33, HIGH),
59 };
60 
61 static void early_lpc_init(void)
62 {
64 
65  if (CONFIG(BOARD_PCENGINES_APU2))
67 
68  if (CONFIG(BOARD_PCENGINES_APU3) || CONFIG(BOARD_PCENGINES_APU4))
70 
71  if (CONFIG(BOARD_PCENGINES_APU5))
73 }
static void pm_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:181
#define GPIO_51
Definition: gpio_ftns.h:19
#define GPIO_49
Definition: gpio_ftns.h:17
#define GPIO_57
Definition: gpio_ftns.h:21
#define GPIO_50
Definition: gpio_ftns.h:18
#define GPIO_64
Definition: gpio_ftns.h:24
#define GPIO_71
Definition: gpio_ftns.h:27
#define GPIO_22
Definition: gpio_ftns.h:14
#define GPIO_58
Definition: gpio_ftns.h:22
#define GPIO_59
Definition: gpio_ftns.h:23
#define GPIO_32
Definition: gpio_ftns.h:15
#define GPIO_68
Definition: gpio_ftns.h:26
#define GPIO_55
Definition: gpio_ftns.h:20
#define GPIO_33
Definition: gpio_ftns.h:16
#define ARRAY_SIZE(a)
Definition: helpers.h:12
void __weak board_BeforeAgesa(struct sysinfo *cb)
Definition: romstage.c:19
@ CONFIG
Definition: dsi_common.h:201
#define PULL_NONE
Definition: buildOpts.c:72
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static void early_lpc_init(void)
Definition: romstage.c:61
const struct soc_amd_gpio gpio_common[]
Definition: romstage.c:33
const struct soc_amd_gpio gpio_apu5[]
Definition: romstage.c:55
const struct soc_amd_gpio gpio_apu2[]
Definition: romstage.c:46
const struct soc_amd_gpio gpio_apu34[]
Definition: romstage.c:50
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
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 PAD_GPO(pin, direction)
Definition: gpio_defs.h:220
#define PAD_GPI(pin, pull)
Definition: gpio_defs.h:216
uint32_t u32
Definition: stdint.h:51
u8 val
Definition: sys.c:300