Martin Roth | 5474eb1 | 2018-05-26 19:22:33 -0600 | [diff] [blame] | 1 | /* |
| 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 Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 14 | #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älkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 22 | #include "e7505.h" |
Vladimir Serbinenko | c7310d9 | 2014-09-01 09:45:05 +0200 | [diff] [blame] | 23 | #include <arch/acpi.h> |
| 24 | |
| 25 | unsigned long acpi_fill_mcfg(unsigned long current) |
| 26 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 27 | /* Just a dummy */ |
| 28 | return current; |
Vladimir Serbinenko | c7310d9 | 2014-09-01 09:45:05 +0200 | [diff] [blame] | 29 | } |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 30 | |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 31 | static void mch_domain_read_resources(struct device *dev) |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 32 | { |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 33 | int idx; |
| 34 | unsigned long tomk, tolmk; |
| 35 | unsigned long remapbasek, remaplimitk; |
| 36 | const unsigned long basek_4G = 4 * (GiB / KiB); |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 37 | struct device *mc_dev; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 38 | |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 39 | pci_domain_read_resources(dev); |
| 40 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 41 | mc_dev = pcidev_on_root(0, 0); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 42 | if (!mc_dev) |
| 43 | die("Could not find MCH device\n"); |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 44 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 45 | tolmk = pci_read_config16(mc_dev, TOLM) >> 11; |
| 46 | tolmk <<= 17; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 47 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 48 | tomk = pci_read_config8(mc_dev, DRB_ROW_7); |
| 49 | tomk <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 50 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 51 | /* 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 Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 55 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 56 | remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff; |
| 57 | remaplimitk += 1; |
| 58 | remaplimitk <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 59 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 60 | /* 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älkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | static void mch_domain_set_resources(struct device *dev) |
| 73 | { |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 74 | assign_resources(dev->link_list); |
| 75 | } |
| 76 | |
Elyes HAOUAS | b60920d | 2018-09-20 17:38:38 +0200 | [diff] [blame] | 77 | static void intel_set_subsystem(struct device *dev, unsigned int vendor, |
| 78 | unsigned int device) |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 79 | { |
| 80 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 81 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 82 | } |
| 83 | |
| 84 | static struct pci_operations intel_pci_ops = { |
| 85 | .set_subsystem = intel_set_subsystem, |
| 86 | }; |
| 87 | |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 88 | static struct device_operations pci_domain_ops = { |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 89 | .read_resources = mch_domain_read_resources, |
| 90 | .set_resources = mch_domain_set_resources, |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 91 | .enable_resources = NULL, |
| 92 | .init = NULL, |
| 93 | .scan_bus = pci_domain_scan_bus, |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 94 | .ops_pci = &intel_pci_ops, |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 97 | static void cpu_bus_init(struct device *dev) |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 98 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 99 | initialize_cpus(dev->link_list); |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 102 | static struct device_operations cpu_bus_ops = { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 103 | .read_resources = DEVICE_NOOP, |
| 104 | .set_resources = DEVICE_NOOP, |
| 105 | .enable_resources = DEVICE_NOOP, |
| 106 | .init = cpu_bus_init, |
| 107 | .scan_bus = 0, |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | static void enable_dev(struct device *dev) |
| 111 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 112 | /* 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 Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 121 | struct chip_operations northbridge_intel_e7505_ops = { |
| 122 | CHIP_NAME("Intel E7505 Northbridge") |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 123 | .enable_dev = enable_dev, |
| 124 | }; |