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_ops.h>
6 #include <device/pci_ids.h>
7 #include "i82801jx.h"
8 
9 static void pci_init(struct device *dev)
10 {
11  u16 reg16;
12 
13  /* This device has no interrupt */
15 
16  /* Master Latency Count must be set to 0x04! */
17  pci_update_config8(dev, D30F0_SMLT, 0x07, 0x04 << 3);
18 
19  /* Clear errors in status registers. FIXME: Do something? */
20  reg16 = pci_read_config16(dev, PCI_STATUS);
21  //reg16 |= 0xf900;
22  pci_write_config16(dev, PCI_STATUS, reg16);
23 
24  reg16 = pci_read_config16(dev, PCI_SEC_STATUS);
25  // reg16 |= 0xf900;
27 }
28 
29 static struct device_operations device_ops = {
31  .set_resources = pci_dev_set_resources,
32  .enable_resources = pci_bus_enable_resources,
33  .init = pci_init,
34  .scan_bus = pci_scan_bridge,
35  .reset_bus = pci_bus_reset,
36  .ops_pci = &pci_dev_ops_pci,
37 };
38 
39 static const unsigned short pci_device_ids[] = {
40  0x244e,
41  0
42 };
43 
44 static const struct pci_driver ich10_pci __pci_driver = {
45  .ops = &device_ops,
46  .vendor = PCI_VID_INTEL,
47  .devices = pci_device_ids,
48 };
#define D30F0_SMLT
Definition: i82801ix.h:80
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 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:29
static void pci_init(struct device *dev)
Definition: pci.c:9
static const unsigned short pci_device_ids[]
Definition: pci.c:39
static const struct pci_driver ich10_pci __pci_driver
Definition: pci.c:44
#define PCI_SEC_STATUS
Definition: pci_def.h:113
#define PCI_STATUS
Definition: pci_def.h:23
#define PCI_INTERRUPT_LINE
Definition: pci_def.h:94
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_bus_reset(struct bus *bus)
Definition: pci_device.c:777
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
uint16_t u16
Definition: stdint.h:48
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107