blob: 03230a53ae6fdf71f0fd07dd4d3ba688d0f62bf8 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Martin Roth5474eb12018-05-26 19:22:33 -06003
Elyes HAOUASa1e22b82019-03-18 22:49:36 +01004#include <arch/acpi.h>
Stefan Reinauerb15975b2011-10-21 12:57:59 -07005#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Stefan Reinauerb15975b2011-10-21 12:57:59 -07007#include <stdint.h>
8#include <device/device.h>
9#include <device/pci.h>
10#include <cpu/cpu.h>
Elyes HAOUASa1e22b82019-03-18 22:49:36 +010011
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020012#include "e7505.h"
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020013
14unsigned long acpi_fill_mcfg(unsigned long current)
15{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020016 /* Just a dummy */
17 return current;
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020018}
Stefan Reinauerb15975b2011-10-21 12:57:59 -070019
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030020static void mch_domain_read_resources(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070021{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030022 int idx;
23 unsigned long tomk, tolmk;
24 unsigned long remapbasek, remaplimitk;
25 const unsigned long basek_4G = 4 * (GiB / KiB);
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020026 struct device *mc_dev;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070027
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030028 pci_domain_read_resources(dev);
29
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030030 mc_dev = pcidev_on_root(0, 0);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030031 if (!mc_dev)
32 die("Could not find MCH device\n");
Stefan Reinauerb15975b2011-10-21 12:57:59 -070033
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030034 tolmk = pci_read_config16(mc_dev, TOLM) >> 11;
35 tolmk <<= 17;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070036
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030037 tomk = pci_read_config8(mc_dev, DRB_ROW_7);
38 tomk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070039
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030040 /* Remapped region with a 64 MiB granularity in register
41 definition. Limit is inclusive, so add one. */
42 remapbasek = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff;
43 remapbasek <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070044
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030045 remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff;
46 remaplimitk += 1;
47 remaplimitk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070048
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030049 /* Report the memory regions */
50 idx = 10;
51 ram_resource(dev, idx++, 0, 640);
52 ram_resource(dev, idx++, 768, tolmk - 768);
53
54 if (tomk > basek_4G)
55 ram_resource(dev, idx++, basek_4G, tomk - basek_4G);
56
57 if (remaplimitk > remapbasek)
58 ram_resource(dev, idx++, remapbasek, remaplimitk - remapbasek);
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030059}
60
61static void mch_domain_set_resources(struct device *dev)
62{
Stefan Reinauerb15975b2011-10-21 12:57:59 -070063 assign_resources(dev->link_list);
64}
65
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020066static struct pci_operations intel_pci_ops = {
Subrata Banik4a0f0712019-03-20 14:29:47 +053067 .set_subsystem = pci_dev_set_subsystem,
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020068};
69
Stefan Reinauerb15975b2011-10-21 12:57:59 -070070static struct device_operations pci_domain_ops = {
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030071 .read_resources = mch_domain_read_resources,
72 .set_resources = mch_domain_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020073 .scan_bus = pci_domain_scan_bus,
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020074 .ops_pci = &intel_pci_ops,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070075};
76
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020077static void cpu_bus_init(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070078{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020079 initialize_cpus(dev->link_list);
Stefan Reinauerb15975b2011-10-21 12:57:59 -070080}
81
Stefan Reinauerb15975b2011-10-21 12:57:59 -070082static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020083 .read_resources = noop_read_resources,
84 .set_resources = noop_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020085 .init = cpu_bus_init,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070086};
87
88static void enable_dev(struct device *dev)
89{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020090 /* Set the operations if it is a special bus type */
91 if (dev->path.type == DEVICE_PATH_DOMAIN) {
92 dev->ops = &pci_domain_ops;
93 }
94 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
95 dev->ops = &cpu_bus_ops;
96 }
Stefan Reinauerb15975b2011-10-21 12:57:59 -070097}
98
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020099struct chip_operations northbridge_intel_e7505_ops = {
100 CHIP_NAME("Intel E7505 Northbridge")
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700101 .enable_dev = enable_dev,
102};