blob: 33e101830986e59a008aca78edfe5645991504a7 [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
Kyösti Mälkki0a18d642021-06-28 21:43:31 +03003#include <assert.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
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030012static void mch_domain_read_resources(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070013{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030014 int idx;
Kyösti Mälkki0a18d642021-06-28 21:43:31 +030015 unsigned long tolmk;
16 uint64_t tom, remapbase, remaplimit;
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020017 struct device *mc_dev;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070018
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030019 pci_domain_read_resources(dev);
20
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030021 mc_dev = pcidev_on_root(0, 0);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030022 if (!mc_dev)
23 die("Could not find MCH device\n");
Stefan Reinauerb15975b2011-10-21 12:57:59 -070024
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030025 tolmk = pci_read_config16(mc_dev, TOLM) >> 11;
26 tolmk <<= 17;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070027
Kyösti Mälkki0a18d642021-06-28 21:43:31 +030028 tom = pci_read_config8(mc_dev, DRB_ROW_7);
29 tom <<= 26;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070030
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030031 /* Remapped region with a 64 MiB granularity in register
32 definition. Limit is inclusive, so add one. */
Kyösti Mälkki0a18d642021-06-28 21:43:31 +030033 remapbase = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff;
34 remapbase <<= 26;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070035
Kyösti Mälkki0a18d642021-06-28 21:43:31 +030036 remaplimit = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff;
37 remaplimit += 1;
38 remaplimit <<= 26;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070039
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030040 /* Report the memory regions */
41 idx = 10;
Kyösti Mälkki27d62992022-05-24 20:25:58 +030042 ram_resource_kb(dev, idx++, 0, tolmk);
43 mmio_resource_kb(dev, idx++, 0xa0000 / KiB, (0xc0000 - 0xa0000) / KiB);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030044
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030045
Kyösti Mälkki0a18d642021-06-28 21:43:31 +030046 ASSERT(tom == remapbase);
47 upper_ram_end(dev, idx++, remaplimit);
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030048}
49
50static void mch_domain_set_resources(struct device *dev)
51{
Stefan Reinauerb15975b2011-10-21 12:57:59 -070052 assign_resources(dev->link_list);
53}
54
55static struct device_operations pci_domain_ops = {
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030056 .read_resources = mch_domain_read_resources,
57 .set_resources = mch_domain_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020058 .scan_bus = pci_domain_scan_bus,
Angel Pons1fc0edd2020-05-31 00:03:28 +020059 .ops_pci = &pci_dev_ops_pci,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070060};
61
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020062static void cpu_bus_init(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070063{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020064 initialize_cpus(dev->link_list);
Stefan Reinauerb15975b2011-10-21 12:57:59 -070065}
66
Stefan Reinauerb15975b2011-10-21 12:57:59 -070067static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020068 .read_resources = noop_read_resources,
69 .set_resources = noop_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020070 .init = cpu_bus_init,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070071};
72
73static void enable_dev(struct device *dev)
74{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020075 /* Set the operations if it is a special bus type */
76 if (dev->path.type == DEVICE_PATH_DOMAIN) {
77 dev->ops = &pci_domain_ops;
78 }
79 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
80 dev->ops = &cpu_bus_ops;
81 }
Stefan Reinauerb15975b2011-10-21 12:57:59 -070082}
83
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020084struct chip_operations northbridge_intel_e7505_ops = {
85 CHIP_NAME("Intel E7505 Northbridge")
Stefan Reinauerb15975b2011-10-21 12:57:59 -070086 .enable_dev = enable_dev,
87};