coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
northbridge.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 <stdint.h>
6 #include <device/device.h>
7 #include <device/pci.h>
8 #include <device/pci_ids.h>
9 #include <cpu/cpu.h>
10 #include "i440bx.h"
11 
12 static void northbridge_init(struct device *dev)
13 {
14  printk(BIOS_SPEW, "Northbridge Init\n");
15 }
16 
19  .set_resources = pci_dev_set_resources,
20  .enable_resources = pci_dev_enable_resources,
21  .init = northbridge_init,
22 };
23 
24 static const struct pci_driver northbridge_driver __pci_driver = {
25  .ops = &northbridge_operations,
26  .vendor = PCI_VID_INTEL,
27  .device = 0x7190,
28 };
29 
30 static void i440bx_domain_read_resources(struct device *dev)
31 {
32  struct device *mc_dev;
33  uint32_t pci_tolm;
34 
36 
37  pci_tolm = find_pci_tolm(dev->link_list);
38  mc_dev = dev->link_list->children;
39  if (mc_dev) {
40  unsigned long tomk, tolmk;
41  int idx;
42 
43  /* Figure out which areas are/should be occupied by RAM. The
44  * value of the highest DRB denotes the end of the physical
45  * memory (in units of 8MB).
46  */
47  tomk = ((unsigned long)pci_read_config8(mc_dev, DRB7));
48 
49  /* Convert to KB. */
50  tomk *= (8 * 1024);
51 
52  printk(BIOS_DEBUG, "Setting RAM size to %ld MB\n", tomk / 1024);
53 
54  /* Compute the top of low memory. */
55  tolmk = pci_tolm / 1024;
56 
57  if (tolmk >= tomk) {
58  /* The PCI hole does not overlap the memory. */
59  tolmk = tomk;
60  }
61 
62  /* Report the memory regions. */
63  idx = 10;
64  ram_resource(dev, idx++, 0, 640);
65  ram_resource(dev, idx++, 768, tolmk - 768);
66  }
67 }
68 
69 static struct device_operations pci_domain_ops = {
71  .set_resources = pci_domain_set_resources,
72  .scan_bus = pci_domain_scan_bus,
73 };
74 
75 static void cpu_bus_init(struct device *dev)
76 {
78 }
79 
80 static struct device_operations cpu_bus_ops = {
82  .set_resources = noop_set_resources,
83  .init = cpu_bus_init,
84 };
85 
86 static void enable_dev(struct device *dev)
87 {
88  /* Set the operations if it is a special bus type */
89  if (dev->path.type == DEVICE_PATH_DOMAIN) {
90  dev->ops = &pci_domain_ops;
91  }
92  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
93  dev->ops = &cpu_bus_ops;
94  }
95 }
96 
98  CHIP_NAME("Intel 82443BX (440BX) Northbridge")
99  .enable_dev = enable_dev,
100 };
#define printk(level,...)
Definition: stdlib.h:16
u32 find_pci_tolm(struct bus *bus)
Definition: device_util.c:890
#define DRB7
Definition: i440bx.h:40
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define ram_resource(dev, idx, basek, sizek)
Definition: device.h:321
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
void initialize_cpus(struct bus *cpu_bus)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
Definition: loglevel.h:142
static void cpu_bus_init(struct device *dev)
Definition: northbridge.c:75
static struct device_operations cpu_bus_ops
Definition: northbridge.c:80
static const struct pci_driver northbridge_driver __pci_driver
Definition: northbridge.c:24
struct chip_operations northbridge_intel_i440bx_ops
Definition: northbridge.c:97
static struct device_operations pci_domain_ops
Definition: northbridge.c:69
static void enable_dev(struct device *dev)
Definition: northbridge.c:86
static struct device_operations northbridge_operations
Definition: northbridge.c:17
static void i440bx_domain_read_resources(struct device *dev)
Definition: northbridge.c:30
static void northbridge_init(struct device *dev)
Definition: northbridge.c:12
@ DEVICE_PATH_CPU_CLUSTER
Definition: path.h:14
@ DEVICE_PATH_DOMAIN
Definition: path.h:13
void pci_domain_read_resources(struct device *dev)
Definition: pci_device.c:547
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_domain_set_resources(struct device *dev)
Definition: pci_device.c:564
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
void pci_domain_scan_bus(struct device *dev)
Scan a PCI domain.
Definition: pci_device.c:1610
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
unsigned int uint32_t
Definition: stdint.h:14
DEVTREE_CONST struct device * children
Definition: device.h:79
void(* read_resources)(struct device *dev)
Definition: device.h:39
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
DEVTREE_CONST struct bus * link_list
Definition: device.h:139