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 <arch/io.h>
4 #include <bootstate.h>
5 #include <cf9_reset.h>
6 #include <device/pci_def.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
9 #include <gpio.h>
10 #include <hwilib.h>
11 #include <intelblocks/lpc_lib.h>
12 #include <intelblocks/pcr.h>
13 #include <soc/pcr_ids.h>
14 #include <baseboard/variants.h>
15 #include <types.h>
16 
17 #define TX_DWORD3 0xa8c
18 
20 {
21  struct device *dev = NULL;
22 
23  /* PIR6 register mapping for PCIe root ports
24  * INTA#->PIRQD#, INTB#->PIRQA#, INTC#->PIRQB#, INTD#-> PIRQC#
25  */
26  pcr_write16(PID_ITSS, 0x314c, 0x2103);
27 
28  /* Enable CLKRUN_EN for power gating LPC */
30 
31  /*
32  * Enable LPC PCE (Power Control Enable) by setting IOSF-SB port 0xD2
33  * offset 0x341D bit3 and bit0.
34  * Enable LPC CCE (Clock Control Enable) by setting IOSF-SB port 0xD2
35  * offset 0x341C bit [3:0].
36  */
38 
39  /* Set Master Enable for on-board PCI device if allowed. */
40  dev = dev_find_device(PCI_VID_SIEMENS, 0x403e, 0);
41  if (dev) {
42  if (CONFIG(PCI_ALLOW_BUS_MASTER_ANY_DEVICE))
44 
45  /* Disable clock outputs 0-3 (CLKOUT) for upstream
46  * XIO2001 PCIe to PCI Bridge.
47  */
48  struct device *parent = dev->bus->dev;
49  if (parent && parent->device == PCI_DID_TI_XIO2001)
50  pci_write_config8(parent, 0xd8, 0x0F);
51  }
52 
53  /* Disable clock outputs 2-5 (CLKOUT) for another XIO2001 PCIe to PCI
54  * Bridge on this mainboard.
55  */
56  dev = dev_find_device(PCI_VID_SIEMENS, 0x403f, 0);
57  if (dev) {
58  struct device *parent = dev->bus->dev;
59  if (parent && parent->device == PCI_DID_TI_XIO2001)
60  pci_write_config8(parent, 0xd8, 0x3c);
61  }
62 
63  /* Set Full Reset Bit in Reset Control Register (I/O port CF9h).
64  * When Bit 3 is set to 1 and then the reset button is pressed the PCH
65  * will drive SLP_S3 active (low). SLP_S3 is then used on the mainboard
66  * to generate the right reset timing.
67  */
69 }
70 
71 static void finalize_boot(void *unused)
72 {
73  /* Set coreboot ready LED. */
75 }
76 
#define PID_LPC
Definition: pcr_ids.h:21
@ BS_PAYLOAD_BOOT
Definition: bootstate.h:89
@ BS_ON_ENTRY
Definition: bootstate.h:95
#define RST_CNT
Definition: cf9_reset.h:7
#define FULL_RST
Definition: cf9_reset.h:8
void pcr_write16(uint8_t pid, uint16_t offset, uint16_t indata)
Definition: pcr.c:134
void pcr_or32(uint8_t pid, uint16_t offset, uint32_t ordata)
Definition: pcr.c:184
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT, sch5545_ec_hwm_init, NULL)
@ PID_ITSS
Definition: pcr.h:16
void outb(u8 val, u16 port)
struct device * dev_find_device(u16 vendor, u16 device, struct device *from)
Find a device of a given vendor and type.
Definition: device_util.c:42
@ CONFIG
Definition: dsi_common.h:201
#define CNV_RGI_DT
Definition: gpio_apl.h:138
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
void gpio_output(gpio_t gpio, int value)
Definition: gpio.c:194
#define PCR_LPC_PCE_EN
Definition: lpc_lib.h:31
void lpc_enable_pci_clk_cntl(void)
Definition: lpc_lib.c:292
#define PCR_LPC_CCE_EN
Definition: lpc_lib.h:30
#define PCR_LPC_PRC
Definition: lpc_lib.h:29
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_VID_SIEMENS
Definition: pci_ids.h:1491
#define PCI_DID_TI_XIO2001
Definition: pci_ids.h:868
void __weak variant_mainboard_final(void)
Definition: mainboard.c:245
static void finalize_boot(void *unused)
Definition: mainboard.c:71
#define NULL
Definition: stddef.h:19
DEVTREE_CONST struct device * dev
Definition: device.h:78
Definition: device.h:107
DEVTREE_CONST struct bus * bus
Definition: device.h:108
unsigned int device
Definition: device.h:117