blob: fc771b3c3a533ad28300e8ef87b24b127daecf3a [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5474eb12018-05-26 19:22:33 -06002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi.h>
Stefan Reinauerb15975b2011-10-21 12:57:59 -07004#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02005#include <device/pci_ops.h>
Stefan Reinauerb15975b2011-10-21 12:57:59 -07006#include <device/device.h>
7#include <device/pci.h>
8#include <cpu/cpu.h>
Elyes HAOUASa1e22b82019-03-18 22:49:36 +01009
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020010#include "e7505.h"
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020011
12unsigned long acpi_fill_mcfg(unsigned long current)
13{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020014 /* Just a dummy */
15 return current;
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020016}
Stefan Reinauerb15975b2011-10-21 12:57:59 -070017
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030018static void mch_domain_read_resources(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070019{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030020 int idx;
21 unsigned long tomk, tolmk;
22 unsigned long remapbasek, remaplimitk;
23 const unsigned long basek_4G = 4 * (GiB / KiB);
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020024 struct device *mc_dev;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070025
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030026 pci_domain_read_resources(dev);
27
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030028 mc_dev = pcidev_on_root(0, 0);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030029 if (!mc_dev)
30 die("Could not find MCH device\n");
Stefan Reinauerb15975b2011-10-21 12:57:59 -070031
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030032 tolmk = pci_read_config16(mc_dev, TOLM) >> 11;
33 tolmk <<= 17;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070034
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030035 tomk = pci_read_config8(mc_dev, DRB_ROW_7);
36 tomk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070037
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030038 /* Remapped region with a 64 MiB granularity in register
39 definition. Limit is inclusive, so add one. */
40 remapbasek = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff;
41 remapbasek <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070042
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030043 remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff;
44 remaplimitk += 1;
45 remaplimitk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070046
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030047 /* Report the memory regions */
48 idx = 10;
49 ram_resource(dev, idx++, 0, 640);
50 ram_resource(dev, idx++, 768, tolmk - 768);
51
52 if (tomk > basek_4G)
53 ram_resource(dev, idx++, basek_4G, tomk - basek_4G);
54
55 if (remaplimitk > remapbasek)
56 ram_resource(dev, idx++, remapbasek, remaplimitk - remapbasek);
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030057}
58
59static void mch_domain_set_resources(struct device *dev)
60{
Stefan Reinauerb15975b2011-10-21 12:57:59 -070061 assign_resources(dev->link_list);
62}
63
64static struct device_operations pci_domain_ops = {
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030065 .read_resources = mch_domain_read_resources,
66 .set_resources = mch_domain_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020067 .scan_bus = pci_domain_scan_bus,
Angel Pons1fc0edd2020-05-31 00:03:28 +020068 .ops_pci = &pci_dev_ops_pci,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070069};
70
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020071static void cpu_bus_init(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070072{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020073 initialize_cpus(dev->link_list);
Stefan Reinauerb15975b2011-10-21 12:57:59 -070074}
75
Stefan Reinauerb15975b2011-10-21 12:57:59 -070076static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020077 .read_resources = noop_read_resources,
78 .set_resources = noop_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020079 .init = cpu_bus_init,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070080};
81
82static void enable_dev(struct device *dev)
83{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020084 /* Set the operations if it is a special bus type */
85 if (dev->path.type == DEVICE_PATH_DOMAIN) {
86 dev->ops = &pci_domain_ops;
87 }
88 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
89 dev->ops = &cpu_bus_ops;
90 }
Stefan Reinauerb15975b2011-10-21 12:57:59 -070091}
92
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020093struct chip_operations northbridge_intel_e7505_ops = {
94 CHIP_NAME("Intel E7505 Northbridge")
Stefan Reinauerb15975b2011-10-21 12:57:59 -070095 .enable_dev = enable_dev,
96};