blob: 8dd701b9f29ac458c11a005e587a983e0c620748 [file] [log] [blame]
Martin Roth5474eb12018-05-26 19:22:33 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
Elyes HAOUASa1e22b82019-03-18 22:49:36 +010014#include <arch/acpi.h>
Stefan Reinauerb15975b2011-10-21 12:57:59 -070015#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020016#include <device/pci_ops.h>
Stefan Reinauerb15975b2011-10-21 12:57:59 -070017#include <stdint.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <cpu/cpu.h>
Elyes HAOUASa1e22b82019-03-18 22:49:36 +010021
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020022#include "e7505.h"
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020023
24unsigned long acpi_fill_mcfg(unsigned long current)
25{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020026 /* Just a dummy */
27 return current;
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020028}
Stefan Reinauerb15975b2011-10-21 12:57:59 -070029
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030030static void mch_domain_read_resources(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070031{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030032 int idx;
33 unsigned long tomk, tolmk;
34 unsigned long remapbasek, remaplimitk;
35 const unsigned long basek_4G = 4 * (GiB / KiB);
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020036 struct device *mc_dev;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070037
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030038 pci_domain_read_resources(dev);
39
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030040 mc_dev = pcidev_on_root(0, 0);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030041 if (!mc_dev)
42 die("Could not find MCH device\n");
Stefan Reinauerb15975b2011-10-21 12:57:59 -070043
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030044 tolmk = pci_read_config16(mc_dev, TOLM) >> 11;
45 tolmk <<= 17;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070046
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030047 tomk = pci_read_config8(mc_dev, DRB_ROW_7);
48 tomk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070049
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030050 /* Remapped region with a 64 MiB granularity in register
51 definition. Limit is inclusive, so add one. */
52 remapbasek = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff;
53 remapbasek <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070054
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030055 remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff;
56 remaplimitk += 1;
57 remaplimitk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070058
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030059 /* Report the memory regions */
60 idx = 10;
61 ram_resource(dev, idx++, 0, 640);
62 ram_resource(dev, idx++, 768, tolmk - 768);
63
64 if (tomk > basek_4G)
65 ram_resource(dev, idx++, basek_4G, tomk - basek_4G);
66
67 if (remaplimitk > remapbasek)
68 ram_resource(dev, idx++, remapbasek, remaplimitk - remapbasek);
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030069}
70
71static void mch_domain_set_resources(struct device *dev)
72{
Stefan Reinauerb15975b2011-10-21 12:57:59 -070073 assign_resources(dev->link_list);
74}
75
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020076static struct pci_operations intel_pci_ops = {
Subrata Banik4a0f0712019-03-20 14:29:47 +053077 .set_subsystem = pci_dev_set_subsystem,
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020078};
79
Stefan Reinauerb15975b2011-10-21 12:57:59 -070080static struct device_operations pci_domain_ops = {
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030081 .read_resources = mch_domain_read_resources,
82 .set_resources = mch_domain_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020083 .scan_bus = pci_domain_scan_bus,
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020084 .ops_pci = &intel_pci_ops,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070085};
86
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020087static void cpu_bus_init(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070088{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020089 initialize_cpus(dev->link_list);
Stefan Reinauerb15975b2011-10-21 12:57:59 -070090}
91
Stefan Reinauerb15975b2011-10-21 12:57:59 -070092static struct device_operations cpu_bus_ops = {
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020093 .read_resources = DEVICE_NOOP,
94 .set_resources = DEVICE_NOOP,
95 .enable_resources = DEVICE_NOOP,
96 .init = cpu_bus_init,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070097};
98
99static void enable_dev(struct device *dev)
100{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +0200101 /* Set the operations if it is a special bus type */
102 if (dev->path.type == DEVICE_PATH_DOMAIN) {
103 dev->ops = &pci_domain_ops;
104 }
105 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
106 dev->ops = &cpu_bus_ops;
107 }
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700108}
109
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +0200110struct chip_operations northbridge_intel_e7505_ops = {
111 CHIP_NAME("Intel E7505 Northbridge")
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700112 .enable_dev = enable_dev,
113};