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 <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_def.h>
7 #include <device/pci_ops.h>
8 #include <device/pci_ids.h>
9 #include "pch.h"
10 
11 static void pci_init(struct device *dev)
12 {
13  u16 reg16;
14 
15  printk(BIOS_DEBUG, "PCI init.\n");
16  /* Enable Bus Master */
18 
19  /* This device has no interrupt */
20  pci_write_config8(dev, INTR, 0xff);
21 
22  /* disable parity error response and SERR */
25 
26  /* Master Latency Count must be set to 0x04! */
27  pci_update_config8(dev, SMLT, 0x07, (0x04 << 3));
28 
29  /* Clear errors in status registers. FIXME: do we need to do something? */
30  reg16 = pci_read_config16(dev, PSTS);
31  //reg16 |= 0xf900;
32  pci_write_config16(dev, PSTS, reg16);
33 
34  reg16 = pci_read_config16(dev, SECSTS);
35  // reg16 |= 0xf900;
36  pci_write_config16(dev, SECSTS, reg16);
37 }
38 
39 static struct device_operations device_ops = {
41  .set_resources = pci_dev_set_resources,
42  .enable_resources = pci_bus_enable_resources,
43  .init = pci_init,
44  .scan_bus = pci_scan_bridge,
45  .ops_pci = &pci_dev_ops_pci,
46 };
47 
48 static const unsigned short pci_device_ids[] = {
49  0x2448, /* Mobile */
50  0x244e, /* Desktop */
51  0
52 };
53 
54 static const struct pci_driver pch_pci __pci_driver = {
55  .ops = &device_ops,
56  .vendor = PCI_VID_INTEL,
57  .devices = pci_device_ids,
58 };
#define printk(level,...)
Definition: stdlib.h:16
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:39
static void pci_init(struct device *dev)
Definition: pci.c:11
static const struct pci_driver pch_pci __pci_driver
Definition: pci.c:54
static const unsigned short pci_device_ids[]
Definition: pci.c:48
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#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