coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pch.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/pci_ops.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_def.h>
8 #include "iobp.h"
9 #include "pch.h"
10 
11 #ifdef __SIMPLE_DEVICE__
13 {
14  return PCI_DEV(0, 0x1f, 0);
15 }
16 #else
17 static struct device *pch_get_lpc_device(void)
18 {
19  return pcidev_on_root(0x1f, 0);
20 }
21 #endif
22 
24 {
25  static int pch_revision_id = -1;
26 
27  if (pch_revision_id < 0)
28  pch_revision_id = pci_read_config8(pch_get_lpc_device(),
30  return pch_revision_id;
31 }
32 
33 int pch_silicon_id(void)
34 {
35  static int pch_id = -1;
36 
37  if (pch_id < 0)
39 
40  return pch_id;
41 }
42 
44 {
46 
47  /* Check if this is a LPT-LP or WPT-LP device ID */
48  if ((did & 0xff00) == 0x9c00)
49  return PCH_TYPE_ULT;
50 
51  /* Non-LP laptop SKUs have an odd device ID (least significant bit is one) */
52  if (did & 1)
53  return PCH_TYPE_MOBILE;
54 
55  /* Desktop and Server SKUs have an even device ID */
56  return PCH_TYPE_DESKTOP;
57 }
58 
60 {
61  static u16 pmbase;
62 
63  if (!pmbase)
65  PMBASE) & 0xfffc;
66  return pmbase;
67 }
68 
70 {
71  static u16 gpiobase;
72 
73  if (!gpiobase)
75  GPIOBASE) & 0xfffc;
76  return gpiobase;
77 }
78 
79 #ifndef __SIMPLE_DEVICE__
80 
81 /* Put device in D3Hot Power State */
82 static void pch_enable_d3hot(struct device *dev)
83 {
85 }
86 
87 /* Set bit in function disable register to hide this device */
88 void pch_disable_devfn(struct device *dev)
89 {
90  switch (dev->path.pci.devfn) {
91  case PCI_DEVFN(19, 0): /* Audio DSP */
93  break;
94  case PCI_DEVFN(20, 0): /* XHCI */
96  break;
97  case PCI_DEVFN(21, 0): /* DMA */
98  pch_enable_d3hot(dev);
100  break;
101  case PCI_DEVFN(21, 1): /* I2C0 */
102  pch_enable_d3hot(dev);
104  break;
105  case PCI_DEVFN(21, 2): /* I2C1 */
106  pch_enable_d3hot(dev);
108  break;
109  case PCI_DEVFN(21, 3): /* SPI0 */
110  pch_enable_d3hot(dev);
112  break;
113  case PCI_DEVFN(21, 4): /* SPI1 */
114  pch_enable_d3hot(dev);
116  break;
117  case PCI_DEVFN(21, 5): /* UART0 */
118  pch_enable_d3hot(dev);
120  break;
121  case PCI_DEVFN(21, 6): /* UART1 */
122  pch_enable_d3hot(dev);
124  break;
125  case PCI_DEVFN(22, 0): /* MEI #1 */
127  break;
128  case PCI_DEVFN(22, 1): /* MEI #2 */
130  break;
131  case PCI_DEVFN(22, 2): /* IDE-R */
133  break;
134  case PCI_DEVFN(22, 3): /* KT */
136  break;
137  case PCI_DEVFN(23, 0): /* SDIO */
138  pch_enable_d3hot(dev);
140  break;
141  case PCI_DEVFN(25, 0): /* Gigabit Ethernet */
143  break;
144  case PCI_DEVFN(26, 0): /* EHCI #2 */
146  break;
147  case PCI_DEVFN(27, 0): /* HD Audio Controller */
149  break;
150  case PCI_DEVFN(28, 0): /* PCI Express Root Port 1 */
151  case PCI_DEVFN(28, 1): /* PCI Express Root Port 2 */
152  case PCI_DEVFN(28, 2): /* PCI Express Root Port 3 */
153  case PCI_DEVFN(28, 3): /* PCI Express Root Port 4 */
154  case PCI_DEVFN(28, 4): /* PCI Express Root Port 5 */
155  case PCI_DEVFN(28, 5): /* PCI Express Root Port 6 */
156  case PCI_DEVFN(28, 6): /* PCI Express Root Port 7 */
157  case PCI_DEVFN(28, 7): /* PCI Express Root Port 8 */
159  break;
160  case PCI_DEVFN(29, 0): /* EHCI #1 */
162  break;
163  case PCI_DEVFN(31, 0): /* LPC */
165  break;
166  case PCI_DEVFN(31, 2): /* SATA #1 */
168  break;
169  case PCI_DEVFN(31, 3): /* SMBUS */
171  break;
172  case PCI_DEVFN(31, 5): /* SATA #2 */
174  break;
175  case PCI_DEVFN(31, 6): /* Thermal Subsystem */
177  break;
178  }
179 }
180 
181 void pch_enable(struct device *dev)
182 {
183  /* PCH PCIe Root Ports are handled in PCIe driver. */
184  if (PCI_SLOT(dev->path.pci.devfn) == PCH_PCIE_DEV_SLOT)
185  return;
186 
187  if (!dev->enabled) {
188  printk(BIOS_DEBUG, "%s: Disabling device\n", dev_path(dev));
189 
190  /* Ensure memory, io, and bus master are all disabled */
193 
194  /* Disable this device if possible */
195  pch_disable_devfn(dev);
196  } else {
197  /* Enable SERR */
199  }
200 }
201 
203  CHIP_NAME("Intel Series 8 (Lynx Point) Southbridge")
204  .enable_dev = pch_enable,
205 };
206 
207 #endif /* __SIMPLE_DEVICE__ */
#define SIO_IOBP_FUNCDIS2
Definition: serialio.h:36
#define SIO_IOBP_FUNCDIS0
Definition: serialio.h:34
#define SIO_IOBP_FUNCDIS_DIS
Definition: serialio.h:42
#define SIO_IOBP_FUNCDIS3
Definition: serialio.h:37
#define SIO_IOBP_FUNCDIS4
Definition: serialio.h:38
#define SIO_IOBP_FUNCDIS6
Definition: serialio.h:40
#define SIO_IOBP_FUNCDIS5
Definition: serialio.h:39
#define SIO_IOBP_FUNCDIS1
Definition: serialio.h:35
#define SIO_IOBP_FUNCDIS7
Definition: serialio.h:41
#define printk(level,...)
Definition: stdlib.h:16
uint16_t did
Definition: tis.c:16
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
const char * dev_path(const struct device *dev)
Definition: device_util.c:149
#define CHIP_NAME(X)
Definition: device.h:32
static __always_inline void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
Definition: pci_ops.h:191
static __always_inline void pci_and_config16(const struct device *dev, u16 reg, u16 andmask)
Definition: pci_ops.h:147
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define PCI_COMMAND_SERR
Definition: pci_def.h:19
#define PCI_DEVFN(slot, func)
Definition: pci_def.h:548
#define PCI_COMMAND_IO
Definition: pci_def.h:11
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_FUNC(devfn)
Definition: pci_def.h:550
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_DEVICE_ID
Definition: pci_def.h:9
#define PCI_REVISION_ID
Definition: pci_def.h:41
#define PCI_SLOT(devfn)
Definition: pci_def.h:549
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
#define PMBASE
Definition: lpc.h:8
#define GPIOBASE
Definition: lpc.h:19
#define PCH_PCS_PS_D3HOT
Definition: pch.h:24
#define PCH_PCS
Definition: pch.h:23
#define PCH_DISABLE_HD_AUDIO
Definition: rcba.h:136
#define PCH_DISABLE_KT
Definition: rcba.h:146
#define PCH_DISABLE_MEI1
Definition: rcba.h:149
#define PCH_DISABLE_XHCI
Definition: rcba.h:143
#define PCH_DISABLE_SMBUS
Definition: rcba.h:135
#define PCH_DISABLE_ADSPD
Definition: rcba.h:133
#define PCH_DISABLE_EHCI1
Definition: rcba.h:139
#define PCH_DISABLE_SATA2
Definition: rcba.h:142
#define PCH_DISABLE_GBE
Definition: rcba.h:124
#define BUC
Definition: rcba.h:123
#define PCH_DISABLE_LPC
Definition: rcba.h:138
#define PCH_DISABLE_EHCI2
Definition: rcba.h:137
#define FD2
Definition: rcba.h:128
#define FD
Definition: rcba.h:125
#define PCH_DISABLE_IDER
Definition: rcba.h:147
#define PCH_DISABLE_SATA1
Definition: rcba.h:134
#define PCH_DISABLE_THERMAL
Definition: rcba.h:141
#define PCH_DISABLE_PCIE(x)
Definition: rcba.h:140
#define PCH_DISABLE_MEI2
Definition: rcba.h:148
void pch_disable_devfn(struct device *dev)
Definition: pch.c:77
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue)
Definition: pch.c:86
void pch_enable(struct device *dev)
Definition: pch.c:404
int pch_silicon_revision(void)
Definition: pch.c:14
#define PCH_PCIE_DEV_SLOT
Definition: pch.h:81
#define RCBA32_OR(x, or)
Definition: rcba.h:22
static u16 pmbase
Definition: smi.c:27
u16 get_pmbase(void)
Definition: pch.c:59
int pch_silicon_id(void)
Definition: pch.c:33
static struct device * pch_get_lpc_device(void)
Definition: pch.c:17
enum pch_platform_type get_pch_platform_type(void)
Definition: pch.c:43
u16 get_gpiobase(void)
Definition: pch.c:69
static void pch_enable_d3hot(struct device *dev)
Definition: pch.c:82
struct chip_operations southbridge_intel_lynxpoint_ops
Definition: pch.c:202
pch_platform_type
Definition: pch.h:110
@ PCH_TYPE_DESKTOP
Definition: pch.h:112
@ PCH_TYPE_ULT
Definition: pch.h:113
@ PCH_TYPE_MOBILE
Definition: pch.h:111
uint16_t u16
Definition: stdint.h:48
struct pci_path pci
Definition: path.h:116
Definition: device.h:107
struct device_path path
Definition: device.h:115
unsigned int enabled
Definition: device.h:122
unsigned int devfn
Definition: path.h:54