coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_setup.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _HUDSON_EARLY_SETUP_C_
4 #define _HUDSON_EARLY_SETUP_C_
5 
6 #include <stdint.h>
7 #include <amdblocks/acpimmio.h>
8 #include <device/pci_ops.h>
9 
10 #include "hudson.h"
11 
13 {
14  u8 byte;
15  pci_devfn_t dev;
16 
17  /* P2P Bridge */
18  dev = PCI_DEV(0, 0x14, 4);
19 
20  /* Chip Control: Enable subtractive decoding */
21  byte = pci_read_config8(dev, 0x40);
22  byte |= 1 << 5;
23  pci_write_config8(dev, 0x40, byte);
24 
25  /* Misc Control: Enable subtractive decoding if 0x40 bit 5 is set */
26  byte = pci_read_config8(dev, 0x4B);
27  byte |= 1 << 7;
28  pci_write_config8(dev, 0x4B, byte);
29 
30  /* The same IO Base and IO Limit here is meaningful because we set the
31  * bridge to be subtractive. During early setup stage, we have to make
32  * sure that data can go through port 0x80.
33  */
34  /* IO Base: 0xf000 */
35  byte = pci_read_config8(dev, 0x1C);
36  byte |= 0xF << 4;
37  pci_write_config8(dev, 0x1C, byte);
38 
39  /* IO Limit: 0xf000 */
40  byte = pci_read_config8(dev, 0x1D);
41  byte |= 0xF << 4;
42  pci_write_config8(dev, 0x1D, byte);
43 
44  /* PCI Command: Enable IO response */
45  byte = pci_read_config8(dev, 0x04);
46  byte |= 1 << 0;
47  pci_write_config8(dev, 0x04, byte);
48 
49  /* LPC controller */
50  dev = PCI_DEV(0, 0x14, 3);
51 
52  byte = pci_read_config8(dev, 0x4A);
53  byte &= ~(1 << 5); /* disable lpc port 80 */
54  pci_write_config8(dev, 0x4A, byte);
55 }
56 
58 {
59  u8 byte;
60 
61  /* Enable port 80 LPC decode in pci function 3 configuration space. */
62  const pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
63  byte = pci_read_config8(dev, 0x4a);
64  byte |= 1 << 5; /* enable port 80 */
65  pci_write_config8(dev, 0x4a, byte);
66 }
67 
69 {
70  u32 tmp;
71 
72  /* Enable LPC controller */
73  pm_write8(0xec, pm_read8(0xec) | 0x01);
74 
75  const pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
76  /* Serial port enumeration on Hudson:
77  * PORT0 - 0x3f8
78  * PORT1 - 0x2f8
79  * PORT5 - 0x2e8
80  * PORT7 - 0x3e8
81  */
84 
86 }
87 
88 #endif /* _HUDSON_EARLY_SETUP_C_ */
static uint8_t pm_read8(uint8_t reg)
Definition: acpimmio.h:166
static void pm_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:181
void hudson_pci_port80(void)
Definition: early_setup.c:12
void hudson_lpc_decode(void)
Definition: early_setup.c:68
void hudson_lpc_port80(void)
Definition: early_setup.c:57
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
#define LPC_IO_PORT_DECODE_ENABLE
Definition: lpc.h:16
#define DECODE_ENABLE_SERIAL_PORT7
Definition: lpc.h:30
#define DECODE_ENABLE_SERIAL_PORT1
Definition: lpc.h:24
#define DECODE_ENABLE_SERIAL_PORT5
Definition: lpc.h:28
#define DECODE_ENABLE_SERIAL_PORT0
Definition: lpc.h:23
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45