coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
i82801gx.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/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ops.h>
7 #include "i82801gx.h"
8 #include "sata.h"
9 
10 static void ich_hide_devfn(unsigned int devfn)
11 {
12  switch (devfn) {
13  case PCI_DEVFN(27, 0): /* HD Audio Controller */
15  break;
16  case PCI_DEVFN(28, 0): /* PCI Express Root Port 1 */
17  case PCI_DEVFN(28, 1): /* PCI Express Root Port 2 */
18  case PCI_DEVFN(28, 2): /* PCI Express Root Port 3 */
19  case PCI_DEVFN(28, 3): /* PCI Express Root Port 4 */
20  case PCI_DEVFN(28, 4): /* PCI Express Root Port 5 */
21  case PCI_DEVFN(28, 5): /* PCI Express Root Port 6 */
23  break;
24  case PCI_DEVFN(29, 0): /* UHCI #1 */
25  case PCI_DEVFN(29, 1): /* UHCI #2 */
26  case PCI_DEVFN(29, 2): /* UHCI #3 */
27  case PCI_DEVFN(29, 3): /* UHCI #4 */
29  break;
30  case PCI_DEVFN(29, 7): /* EHCI #1 */
32  break;
33  case PCI_DEVFN(30, 2): /* AC Audio */
35  break;
36  case PCI_DEVFN(30, 3): /* AC Modem */
38  break;
39  case PCI_DEVFN(31, 0): /* LPC */
41  break;
42  case PCI_DEVFN(31, 1): /* PATA #1 */
44  break;
45  case PCI_DEVFN(31, 2): /* SATA #1 */
47  break;
48  case PCI_DEVFN(31, 3): /* SMBUS */
50  break;
51  }
52 }
53 
54 void i82801gx_enable(struct device *dev)
55 {
56  u16 reg16;
57 
58  if (!dev->enabled) {
59  printk(BIOS_DEBUG, "%s: Disabling device\n", dev_path(dev));
60 
61  /* Ensure memory, io, and bus master are all disabled */
62  reg16 = pci_read_config16(dev, PCI_COMMAND);
64  pci_write_config16(dev, PCI_COMMAND, reg16);
65 
66  /* Hide this device if possible */
68  } else {
69  /* Enable SERR */
71 
72  if (dev->path.pci.devfn == PCI_DEVFN(31, 2)) {
73  printk(BIOS_DEBUG, "Set SATA mode early\n");
74  sata_enable(dev);
75  }
76  }
77 }
78 
79 static void i82801gx_init(void *chip_info)
80 {
81  /* Disable performance counter */
82  RCBA32_OR(FD, 1);
83 }
84 
86  CHIP_NAME("Intel ICH7/ICH7-M (82801Gx) Series Southbridge")
87  .enable_dev = i82801gx_enable,
88  .init = i82801gx_init,
89 };
#define printk(level,...)
Definition: stdlib.h:16
const char * dev_path(const struct device *dev)
Definition: device_util.c:149
static void ich_hide_devfn(unsigned int devfn)
Definition: i82801gx.c:10
struct chip_operations southbridge_intel_i82801gx_ops
Definition: i82801gx.c:85
void i82801gx_enable(struct device *dev)
Definition: i82801gx.c:54
static void i82801gx_init(void *chip_info)
Definition: i82801gx.c:79
#define ICH_DISABLE_UHCI(x)
Definition: i82801gx.h:246
#define FD_ACMOD
Definition: i82801gx.h:249
#define FD_HDAUD
Definition: i82801gx.h:251
#define FD_PATA
Definition: i82801gx.h:254
#define FD_EHCI
Definition: i82801gx.h:240
#define FD_LPCB
Definition: i82801gx.h:241
#define ICH_DISABLE_PCIE(x)
Definition: i82801gx.h:239
#define FD_SATA
Definition: i82801gx.h:253
#define FD_SMBUS
Definition: i82801gx.h:252
#define FD_ACAUD
Definition: i82801gx.h:250
#define CHIP_NAME(X)
Definition: device.h:32
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 void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
#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
static void sata_enable(struct device *dev)
Definition: sata.c:139
#define FD
Definition: rcba.h:125
#define RCBA32_OR(x, or)
Definition: rcba.h:22
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