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" |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 23 | #include <cbmem.h> |
Vladimir Serbinenko | c7310d9 | 2014-09-01 09:45:05 +0200 | [diff] [blame] | 24 | #include <arch/acpi.h> |
| 25 | |
| 26 | unsigned long acpi_fill_mcfg(unsigned long current) |
| 27 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 28 | /* Just a dummy */ |
| 29 | return current; |
Vladimir Serbinenko | c7310d9 | 2014-09-01 09:45:05 +0200 | [diff] [blame] | 30 | } |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 31 | |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 32 | static void mch_domain_read_resources(struct device *dev) |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 33 | { |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 34 | int idx; |
| 35 | unsigned long tomk, tolmk; |
| 36 | unsigned long remapbasek, remaplimitk; |
| 37 | const unsigned long basek_4G = 4 * (GiB / KiB); |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 38 | struct device *mc_dev; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 39 | |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 40 | pci_domain_read_resources(dev); |
| 41 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 42 | mc_dev = dev_find_slot(0, PCI_DEVFN(0x0, 0)); |
| 43 | if (!mc_dev) |
| 44 | die("Could not find MCH device\n"); |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 45 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 46 | tolmk = pci_read_config16(mc_dev, TOLM) >> 11; |
| 47 | tolmk <<= 17; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 48 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 49 | tomk = pci_read_config8(mc_dev, DRB_ROW_7); |
| 50 | tomk <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 51 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 52 | /* Remapped region with a 64 MiB granularity in register |
| 53 | definition. Limit is inclusive, so add one. */ |
| 54 | remapbasek = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff; |
| 55 | remapbasek <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 56 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 57 | remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff; |
| 58 | remaplimitk += 1; |
| 59 | remaplimitk <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 60 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 61 | /* Report the memory regions */ |
| 62 | idx = 10; |
| 63 | ram_resource(dev, idx++, 0, 640); |
| 64 | ram_resource(dev, idx++, 768, tolmk - 768); |
| 65 | |
| 66 | if (tomk > basek_4G) |
| 67 | ram_resource(dev, idx++, basek_4G, tomk - basek_4G); |
| 68 | |
| 69 | if (remaplimitk > remapbasek) |
| 70 | ram_resource(dev, idx++, remapbasek, remaplimitk - remapbasek); |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static void mch_domain_set_resources(struct device *dev) |
| 74 | { |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 75 | assign_resources(dev->link_list); |
| 76 | } |
| 77 | |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 78 | static void intel_set_subsystem(struct device *dev, |
| 79 | unsigned vendor, unsigned device) |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 80 | { |
| 81 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 82 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 83 | } |
| 84 | |
| 85 | static struct pci_operations intel_pci_ops = { |
| 86 | .set_subsystem = intel_set_subsystem, |
| 87 | }; |
| 88 | |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 89 | static struct device_operations pci_domain_ops = { |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 90 | .read_resources = mch_domain_read_resources, |
| 91 | .set_resources = mch_domain_set_resources, |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 92 | .enable_resources = NULL, |
| 93 | .init = NULL, |
| 94 | .scan_bus = pci_domain_scan_bus, |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 95 | .ops_pci = &intel_pci_ops, |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 98 | static void cpu_bus_init(struct device *dev) |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 99 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 100 | initialize_cpus(dev->link_list); |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 103 | static struct device_operations cpu_bus_ops = { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 104 | .read_resources = DEVICE_NOOP, |
| 105 | .set_resources = DEVICE_NOOP, |
| 106 | .enable_resources = DEVICE_NOOP, |
| 107 | .init = cpu_bus_init, |
| 108 | .scan_bus = 0, |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | static void enable_dev(struct device *dev) |
| 112 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 113 | /* Set the operations if it is a special bus type */ |
| 114 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 115 | dev->ops = &pci_domain_ops; |
| 116 | } |
| 117 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 118 | dev->ops = &cpu_bus_ops; |
| 119 | } |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 122 | struct chip_operations northbridge_intel_e7505_ops = { |
| 123 | CHIP_NAME("Intel E7505 Northbridge") |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 124 | .enable_dev = enable_dev, |
| 125 | }; |