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 <soc/pch.h>
9 #include <soc/pci_devs.h>
10 #include <soc/rcba.h>
11 #include <soc/serialio.h>
12 #include <soc/spi.h>
14 
16 {
18 }
19 
21 {
23 }
24 
25 /* Return 1 if PCH type is WildcatPoint */
26 int pch_is_wpt(void)
27 {
28  return ((pch_type() & 0xfff0) == 0x9cc0) ? 1 : 0;
29 }
30 
31 /* Return 1 if PCH type is WildcatPoint ULX */
32 int pch_is_wpt_ulx(void)
33 {
34  u16 lpcid = pch_type();
35 
36  switch (lpcid) {
39  case PCH_WPT_BDW_Y_BASE:
40  return 1;
41  }
42 
43  return 0;
44 }
45 
47 {
48  u32 fdoc;
49 
50  fdoc = SPIBAR32(SPIBAR_FDOC);
51  fdoc &= ~0x00007ffc;
52  SPIBAR32(SPIBAR_FDOC) = fdoc;
53 
54  fdoc |= 0x00004000;
55  fdoc |= id * 4;
56  SPIBAR32(SPIBAR_FDOC) = fdoc;
57 
58  return SPIBAR32(SPIBAR_FDOD);
59 }
60 
61 #ifndef __SIMPLE_DEVICE__
62 
63 /* Put device in D3Hot Power State */
64 static void pch_enable_d3hot(struct device *dev)
65 {
67 }
68 
69 /* RCBA function disable and posting read to flush the transaction */
70 static void rcba_function_disable(u32 reg, u32 bit)
71 {
72  RCBA32_OR(reg, bit);
73  RCBA32(reg);
74 }
75 
76 /* Set bit in Function Disable register to hide this device */
77 void pch_disable_devfn(struct device *dev)
78 {
79  switch (dev->path.pci.devfn) {
80  case PCH_DEVFN_ADSP: /* Audio DSP */
82  break;
83  case PCH_DEVFN_XHCI: /* XHCI */
85  break;
86  case PCH_DEVFN_SDMA: /* DMA */
87  pch_enable_d3hot(dev);
89  break;
90  case PCH_DEVFN_I2C0: /* I2C0 */
91  pch_enable_d3hot(dev);
93  break;
94  case PCH_DEVFN_I2C1: /* I2C1 */
95  pch_enable_d3hot(dev);
97  break;
98  case PCH_DEVFN_SPI0: /* SPI0 */
99  pch_enable_d3hot(dev);
101  break;
102  case PCH_DEVFN_SPI1: /* SPI1 */
103  pch_enable_d3hot(dev);
105  break;
106  case PCH_DEVFN_UART0: /* UART0 */
107  pch_enable_d3hot(dev);
109  break;
110  case PCH_DEVFN_UART1: /* UART1 */
111  pch_enable_d3hot(dev);
113  break;
114  case PCH_DEVFN_ME: /* MEI #1 */
116  break;
117  case PCH_DEVFN_ME_2: /* MEI #2 */
119  break;
120  case PCH_DEVFN_ME_IDER: /* IDE-R */
122  break;
123  case PCH_DEVFN_ME_KT: /* KT */
125  break;
126  case PCH_DEVFN_SDIO: /* SDIO */
127  pch_enable_d3hot(dev);
129  break;
130  case PCH_DEVFN_GBE: /* Gigabit Ethernet */
132  break;
133  case PCH_DEVFN_HDA: /* HD Audio Controller */
135  break;
136  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 0): /* PCI Express Root Port 1 */
137  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 1): /* PCI Express Root Port 2 */
138  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 2): /* PCI Express Root Port 3 */
139  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 3): /* PCI Express Root Port 4 */
140  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 4): /* PCI Express Root Port 5 */
141  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 5): /* PCI Express Root Port 6 */
142  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 6): /* PCI Express Root Port 7 */
143  case PCI_DEVFN(PCH_DEV_SLOT_PCIE, 7): /* PCI Express Root Port 8 */
146  break;
147  case PCH_DEVFN_EHCI: /* EHCI #1 */
149  break;
150  case PCH_DEVFN_LPC: /* LPC */
152  break;
153  case PCH_DEVFN_SATA: /* SATA #1 */
155  break;
156  case PCH_DEVFN_SMBUS: /* SMBUS */
158  break;
159  case PCH_DEVFN_SATA2: /* SATA #2 */
161  break;
162  case PCH_DEVFN_THERMAL: /* Thermal Subsystem */
164  break;
165  }
166 }
167 
168 static void broadwell_pch_enable_dev(struct device *dev)
169 {
170  if (dev->path.type != DEVICE_PATH_PCI)
171  return;
172 
173  if (dev->ops && dev->ops->enable)
174  return;
175 
176  /* These devices need special enable/disable handling */
177  switch (PCI_SLOT(dev->path.pci.devfn)) {
178  case PCH_DEV_SLOT_PCIE:
179  case PCH_DEV_SLOT_EHCI:
180  case PCH_DEV_SLOT_HDA:
181  return;
182  }
183 
184  if (!dev->enabled) {
185  printk(BIOS_DEBUG, "%s: Disabling device\n", dev_path(dev));
186 
187  /* Ensure memory, io, and bus master are all disabled */
190 
191  /* Disable this device if possible */
192  pch_disable_devfn(dev);
193  } else {
194  /* Enable SERR */
196  }
197 }
198 
200  CHIP_NAME("Intel Broadwell PCH")
201  .enable_dev = &broadwell_pch_enable_dev,
202 };
203 
204 #endif
#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
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
@ DEVICE_PATH_PCI
Definition: path.h:9
#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 PCH_DEV_LPC
Definition: pci_devs.h:224
#define PCH_DEVFN_I2C0
Definition: pci_devs.h:134
#define PCH_DEVFN_UART0
Definition: pci_devs.h:204
#define PCH_DEVFN_SATA
Definition: pci_devs.h:158
#define PCH_DEVFN_UART1
Definition: pci_devs.h:205
#define PCH_DEVFN_GBE
Definition: pci_devs.h:221
#define PCH_DEV_SLOT_PCIE
Definition: pci_devs.h:175
#define PCH_DEVFN_XHCI
Definition: pci_devs.h:124
#define PCH_DEVFN_HDA
Definition: pci_devs.h:218
#define PCH_DEVFN_SMBUS
Definition: pci_devs.h:219
#define PCH_DEVFN_I2C1
Definition: pci_devs.h:135
#define PCH_DEVFN_LPC
Definition: pci_devs.h:156
#define PCH_DEVFN_SPI0
Definition: pci_devs.h:131
#define PCH_DEV_SLOT_HDA
Definition: pci_devs.h:59
#define PCH_DEVFN_SPI1
Definition: pci_devs.h:132
#define PCH_DEVFN_SDIO
Definition: pci_devs.h:152
u16 lpcid
#define PCH_WPT_BDW_Y_SAMPLE
Definition: pch.h:17
#define PCH_PCS_PS_D3HOT
Definition: pch.h:24
#define PCH_PCS
Definition: pch.h:23
#define PCH_WPT_BDW_Y_BASE
Definition: pch.h:19
#define PCH_WPT_BDW_Y_PREMIUM
Definition: pch.h:18
#define PCH_DEVFN_THERMAL
Definition: pci_devs.h:77
#define PCH_DEV_SLOT_EHCI
Definition: pci_devs.h:68
#define PCH_DEVFN_SATA2
Definition: pci_devs.h:76
#define PCH_DEVFN_ME_IDER
Definition: pci_devs.h:53
#define PCH_DEVFN_ME
Definition: pci_devs.h:51
#define PCH_DEVFN_EHCI
Definition: pci_devs.h:69
#define PCH_DEVFN_ADSP
Definition: pci_devs.h:33
#define PCH_DEVFN_ME_KT
Definition: pci_devs.h:54
#define PCH_DEVFN_SDMA
Definition: pci_devs.h:42
#define PCH_DEVFN_ME_2
Definition: pci_devs.h:52
#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 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
#define SPIBAR_FDOC
Definition: spi.h:17
#define SPIBAR32(x)
Definition: spi.h:13
#define SPIBAR_FDOD
Definition: spi.h:18
u8 pch_revision(void)
Definition: pch.c:15
static void broadwell_pch_enable_dev(struct device *dev)
Definition: pch.c:168
static void rcba_function_disable(u32 reg, u32 bit)
Definition: pch.c:70
int pch_is_wpt(void)
Definition: pch.c:26
void pch_disable_devfn(struct device *dev)
Definition: pch.c:77
int pch_is_wpt_ulx(void)
Definition: pch.c:32
u16 pch_type(void)
Definition: pch.c:20
static void pch_enable_d3hot(struct device *dev)
Definition: pch.c:64
u32 pch_read_soft_strap(int id)
Definition: pch.c:46
struct chip_operations soc_intel_broadwell_pch_ops
Definition: pch.c:199
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue)
Definition: pch.c:86
#define RCBA32_OR(x, or)
Definition: rcba.h:22
#define RCBA32(x)
Definition: rcba.h:14
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
void(* enable)(struct device *dev)
Definition: device.h:45
struct pci_path pci
Definition: path.h:116
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143
unsigned int enabled
Definition: device.h:122
unsigned int devfn
Definition: path.h:54