blob: 317f0874f8ad6388fdc483688e0a89592a3fe17f [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
Stefan Reinauerb15975b2011-10-21 12:57:59 -070014#include <console/console.h>
15#include <arch/io.h>
16#include <stdint.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <cpu/cpu.h>
20#include <stdlib.h>
21#include <string.h>
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020022#include "e7505.h"
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020023#include <arch/acpi.h>
24
25unsigned long acpi_fill_mcfg(unsigned long current)
26{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020027 /* Just a dummy */
28 return current;
Vladimir Serbinenkoc7310d92014-09-01 09:45:05 +020029}
Stefan Reinauerb15975b2011-10-21 12:57:59 -070030
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030031static void mch_domain_read_resources(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070032{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030033 int idx;
34 unsigned long tomk, tolmk;
35 unsigned long remapbasek, remaplimitk;
36 const unsigned long basek_4G = 4 * (GiB / KiB);
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020037 struct device *mc_dev;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070038
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030039 pci_domain_read_resources(dev);
40
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030041 mc_dev = pcidev_on_root(0, 0);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030042 if (!mc_dev)
43 die("Could not find MCH device\n");
Stefan Reinauerb15975b2011-10-21 12:57:59 -070044
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030045 tolmk = pci_read_config16(mc_dev, TOLM) >> 11;
46 tolmk <<= 17;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070047
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030048 tomk = pci_read_config8(mc_dev, DRB_ROW_7);
49 tomk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070050
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030051 /* Remapped region with a 64 MiB granularity in register
52 definition. Limit is inclusive, so add one. */
53 remapbasek = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff;
54 remapbasek <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070055
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030056 remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff;
57 remaplimitk += 1;
58 remaplimitk <<= 16;
Stefan Reinauerb15975b2011-10-21 12:57:59 -070059
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030060 /* Report the memory regions */
61 idx = 10;
62 ram_resource(dev, idx++, 0, 640);
63 ram_resource(dev, idx++, 768, tolmk - 768);
64
65 if (tomk > basek_4G)
66 ram_resource(dev, idx++, basek_4G, tomk - basek_4G);
67
68 if (remaplimitk > remapbasek)
69 ram_resource(dev, idx++, remapbasek, remaplimitk - remapbasek);
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030070}
71
72static void mch_domain_set_resources(struct device *dev)
73{
Stefan Reinauerb15975b2011-10-21 12:57:59 -070074 assign_resources(dev->link_list);
75}
76
Elyes HAOUASb60920d2018-09-20 17:38:38 +020077static void intel_set_subsystem(struct device *dev, unsigned int vendor,
78 unsigned int device)
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020079{
80 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
81 ((device & 0xffff) << 16) | (vendor & 0xffff));
82}
83
84static struct pci_operations intel_pci_ops = {
85 .set_subsystem = intel_set_subsystem,
86};
87
Stefan Reinauerb15975b2011-10-21 12:57:59 -070088static struct device_operations pci_domain_ops = {
Kyösti Mälkki9e69c872018-06-02 15:35:27 +030089 .read_resources = mch_domain_read_resources,
90 .set_resources = mch_domain_set_resources,
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020091 .enable_resources = NULL,
92 .init = NULL,
93 .scan_bus = pci_domain_scan_bus,
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +020094 .ops_pci = &intel_pci_ops,
Stefan Reinauerb15975b2011-10-21 12:57:59 -070095};
96
Elyes HAOUAS97e8b752018-05-09 17:39:47 +020097static void cpu_bus_init(struct device *dev)
Stefan Reinauerb15975b2011-10-21 12:57:59 -070098{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020099 initialize_cpus(dev->link_list);
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700100}
101
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700102static struct device_operations cpu_bus_ops = {
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +0200103 .read_resources = DEVICE_NOOP,
104 .set_resources = DEVICE_NOOP,
105 .enable_resources = DEVICE_NOOP,
106 .init = cpu_bus_init,
107 .scan_bus = 0,
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700108};
109
110static void enable_dev(struct device *dev)
111{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +0200112 /* Set the operations if it is a special bus type */
113 if (dev->path.type == DEVICE_PATH_DOMAIN) {
114 dev->ops = &pci_domain_ops;
115 }
116 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
117 dev->ops = &cpu_bus_ops;
118 }
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700119}
120
Kyösti Mälkki0a0d5e82011-10-31 14:18:33 +0200121struct chip_operations northbridge_intel_e7505_ops = {
122 CHIP_NAME("Intel E7505 Northbridge")
Stefan Reinauerb15975b2011-10-21 12:57:59 -0700123 .enable_dev = enable_dev,
124};