coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pci.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <device/pci_def.h>
6 #include <device/pci_ops.h>
7 #include <device/pci_ids.h>
8 #include "i82801gx.h"
9 
10 static void pci_init(struct device *dev)
11 {
12  u16 reg16;
13 
14  /* Enable Bus Master */
16 
17  /* This device has no interrupt */
18  pci_write_config8(dev, INTR, 0xff);
19 
20  /* Disable parity error response and SERR */
23 
24  /* Master Latency Count must be set to 0x04! */
25  pci_update_config8(dev, SMLT, 0x07, 0x04 << 3);
26 
27  /* Clear errors in status registers. FIXME: Do something? */
28  reg16 = pci_read_config16(dev, PSTS);
29  //reg16 |= 0xf900;
30  pci_write_config16(dev, PSTS, reg16);
31 
32  reg16 = pci_read_config16(dev, SECSTS);
33  // reg16 |= 0xf900;
34  pci_write_config16(dev, SECSTS, reg16);
35 }
36 
37 static struct device_operations device_ops = {
39  .set_resources = pci_dev_set_resources,
40  .enable_resources = pci_bus_enable_resources,
41  .init = pci_init,
42  .scan_bus = pci_scan_bridge,
43  .ops_pci = &pci_dev_ops_pci,
44 };
45 
46 /* Desktop */
47 /* 82801BA/CA/DB/EB/ER/FB/FR/FW/FRW/GB/GR/GDH/HB/IB/6300ESB/i3100 */
48 static const struct pci_driver i82801g_pci __pci_driver = {
49  .ops = &device_ops,
50  .vendor = PCI_VID_INTEL,
51  .device = 0x244e,
52 };
53 
54 /* Mobile / Ultra Mobile */
55 /* 82801BAM/CAM/DBL/DBM/FBM/GBM/GHM/GU/HBM/HEM */
56 static const struct pci_driver i82801gmu_pci __pci_driver = {
57  .ops = &device_ops,
58  .vendor = PCI_VID_INTEL,
59  .device = 0x2448,
60 };
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_update_config8(const struct device *dev, u16 reg, u8 mask, u8 or)
Definition: pci_ops.h:88
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
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
static struct device_operations device_ops
Definition: pci.c:37
static void pci_init(struct device *dev)
Definition: pci.c:10
static const struct pci_driver i82801g_pci __pci_driver
Definition: pci.c:48
#define PCI_BRIDGE_CTL_PARITY
Definition: pci_def.h:136
#define PCI_BRIDGE_CONTROL
Definition: pci_def.h:134
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_BRIDGE_CTL_SERR
Definition: pci_def.h:137
#define PCI_COMMAND
Definition: pci_def.h:10
void pci_bus_enable_resources(struct device *dev)
Definition: pci_device.c:758
void pci_bus_read_resources(struct device *dev)
Definition: pci_device.c:540
void pci_scan_bridge(struct device *dev)
Scan a PCI bridge and the buses behind the bridge.
Definition: pci_device.c:1598
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
#define SECSTS
Definition: pch.h:74
#define INTR
Definition: pch.h:75
#define PSTS
Definition: pch.h:72
#define SMLT
Definition: pch.h:73
uint16_t u16
Definition: stdint.h:48
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107