coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/acpimmio.h>
5 #include <console/console.h>
6 #include <device/device.h>
8 #include <device/mmio.h>
9 #include <device/pci_ops.h>
10 #include <device/pci_def.h>
12 #include <vendorcode/amd/cimx/sb800/OEM.h> /* SMBUS0_BASE_ADDRESS */
15 
16 static const u8 mainboard_intr_data[] = {
17  [0x00] = 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* INTA# - INTH# */
18  [0x08] = 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, /* Misc-nil, 0, 1, 2, INT from Serial irq */
19  [0x10] = 0x09, 0x1F, 0x1F, 0x10, 0x1F, 0x12, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20  0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21  0x12, 0x11, 0x12, 0x11, 0x12, 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22  0x11, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23  0x10, 0x11, 0x12, 0x13
24 };
25 
26 static void init(struct device *dev)
27 {
28  volatile u8 *spi_base; /* base addr of Hudson's SPI host controller */
29 
30  /* Init Hudson GPIOs. */
31  printk(BIOS_DEBUG, "Init FCH GPIOs @ 0x%08x\n", ACPI_MMIO_BASE+GPIO_BASE);
32  /* GPIO50: FCH_ARST#_GATE resets stuck PCIe devices */
33  iomux_write8(50, 2);
34  /* output set to 1 as it's never needed */
35  iomux_write8(50, 0xc0);
36  /* GPIO197: BIOS_DEFAULTS# = input (int. PU) */
37  iomux_write8(197, 2);
38  /* input, disable int. pull-up */
39  gpio_100_write8(197, 0x28);
40  /* GPIO58-56: REV_ID2-0 */
41  iomux_write8(56, 1);
42  /* inputs, disable int. pull-ups */
43  gpio_100_write8(56, 0x28);
44  iomux_write8(57, 1);
45  gpio_100_write8(57, 0x28);
46  iomux_write8(58, 1);
47  gpio_100_write8(58, 0x28);
48  /* GPIO187,188,166,GPO160: GPO0-3 on COM Express connector */
49  iomux_write8(187, 2);
50  /* outputs, disable PUs, default to 0 */
51  gpio_100_write8(187, 0x08);
52  iomux_write8(188, 2);
53  gpio_100_write8(188, 0x08);
54  iomux_write8(166, 2);
55  gpio_100_write8(166, 0x08);
56  /*
57  * needed to make GPO160 work (Hudson Register Reference
58  * section 2.3.6.1)
59  */
60  pm_write8(0xdc, pm_read8(0xdc) & (~0x80));
61  pm_write8(0xe6, (pm_read8(0xe6) & (~0x02)) | 1);
62  iomux_write8(160, 1);
63  gpio_100_write8(160, 0x08);
64  /* GPIO189-192: GPI0-3 on COM Express connector */
65  iomux_write8(189, 1);
66  /* default to inputs with int. PU */
67  iomux_write8(190, 1);
68  iomux_write8(191, 1);
69  iomux_write8(192, 1);
70 
71  /* just in case anyone cares */
72  if (!fch_gpio_state(197))
73  printk(BIOS_INFO, "BIOS_DEFAULTS jumper is present.\n");
74  printk(BIOS_INFO, "Board revision ID: %u\n",
75  fch_gpio_state(58)<<2 | fch_gpio_state(57)<<1 | fch_gpio_state(56));
76 
77  /* Lower SPI speed from default 66 to 22 MHz for SST 25VF032B */
79  0xA0) & 0xFFFFFFE0);
80  /* NormSpeed in SPI_Cntrl1 register */
81  spi_base[0x0D] = (spi_base[0x0D] & ~0x30) | 0x20;
82 
83  /*
84  * Notify the SMC we're alive and kicking, or after a while it will
85  * effect a power cycle and switch to the alternate BIOS chip.
86  * Should be done as late as possible.
87  * Failure here does not matter if watchdog was already disabled,
88  * by configuration or previous boot, so ignore return value.
89  */
91 
92 }
93 
94 /* PIRQ Setup */
95 static void pirq_setup(void)
96 {
98 }
99 
100 /**********************************************
101  * Enable the dedicated functions of the board.
102  **********************************************/
103 static void mainboard_enable(struct device *dev)
104 {
105  /* Initialize the PIRQ data structures for consumption */
106  pirq_setup();
107 
108  dev->ops->init = init;
109 
110  /* enable GPP CLK0 thru CLK1 */
111  /* disable GPP CLK2 thru SLT_GFX_CLK */
112  misc_write8(0, 0xff);
113  misc_write8(1, 0);
114  misc_write8(2, 0);
115  misc_write8(3, 0);
116  misc_write8(4, 0);
117 
118  /*
119  * Initialize ASF registers to an arbitrary address because someone
120  * long ago set things up this way inside the SPD read code. The
121  * SPD read code has been made generic and moved out of the board
122  * directory, so the ASF init is being done here.
123  */
124  pm_write8(0x29, 0x80);
125  pm_write8(0x28, 0x61);
126 }
127 
130 };
struct chip_operations mainboard_ops
Definition: mainboard.c:19
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
static void misc_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:271
static void gpio_100_write8(uint8_t reg, uint8_t value)
static void iomux_write8(uint8_t reg, uint8_t value)
#define printk(level,...)
Definition: stdlib.h:16
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
static uintptr_t spi_base
Definition: fch_spi_util.c:12
static u8 fch_gpio_state(unsigned int gpio_nr)
Definition: gpio_oem.h:20
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static const u8 mainboard_intr_data[]
Definition: mainboard.c:16
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:103
static void pirq_setup(void)
Definition: mainboard.c:95
static void init(struct device *dev)
Definition: mainboard.c:26
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
int sema_send_alive(void)
Definition: sema.c:49
const u8 * intr_data_ptr
Definition: amd_pci_util.c:13
#define GPIO_BASE
Definition: lpc.h:21
unsigned long uintptr_t
Definition: stdint.h:21
uint8_t u8
Definition: stdint.h:45
void(* enable_dev)(struct device *dev)
Definition: device.h:24
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
struct device_operations * ops
Definition: device.h:143