Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 5474eb1 | 2018-05-26 19:22:33 -0600 | [diff] [blame] | 2 | |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 3 | #include <console/console.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
| 7 | #include <cpu/cpu.h> |
Elyes HAOUAS | a1e22b8 | 2019-03-18 22:49:36 +0100 | [diff] [blame] | 8 | |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 9 | #include "e7505.h" |
Vladimir Serbinenko | c7310d9 | 2014-09-01 09:45:05 +0200 | [diff] [blame] | 10 | |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 11 | static void mch_domain_read_resources(struct device *dev) |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 12 | { |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 13 | int idx; |
| 14 | unsigned long tomk, tolmk; |
| 15 | unsigned long remapbasek, remaplimitk; |
| 16 | const unsigned long basek_4G = 4 * (GiB / KiB); |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 17 | struct device *mc_dev; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 18 | |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 19 | pci_domain_read_resources(dev); |
| 20 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 21 | mc_dev = pcidev_on_root(0, 0); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 22 | if (!mc_dev) |
| 23 | die("Could not find MCH device\n"); |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 24 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 25 | tolmk = pci_read_config16(mc_dev, TOLM) >> 11; |
| 26 | tolmk <<= 17; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 27 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 28 | tomk = pci_read_config8(mc_dev, DRB_ROW_7); |
| 29 | tomk <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 30 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 31 | /* Remapped region with a 64 MiB granularity in register |
| 32 | definition. Limit is inclusive, so add one. */ |
| 33 | remapbasek = pci_read_config16(mc_dev, REMAPBASE) & 0x3ff; |
| 34 | remapbasek <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 35 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 36 | remaplimitk = pci_read_config16(mc_dev, REMAPLIMIT) & 0x3ff; |
| 37 | remaplimitk += 1; |
| 38 | remaplimitk <<= 16; |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 39 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 40 | /* Report the memory regions */ |
| 41 | idx = 10; |
Kyösti Mälkki | 27d6299 | 2022-05-24 20:25:58 +0300 | [diff] [blame] | 42 | ram_resource_kb(dev, idx++, 0, tolmk); |
| 43 | mmio_resource_kb(dev, idx++, 0xa0000 / KiB, (0xc0000 - 0xa0000) / KiB); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 44 | |
| 45 | if (tomk > basek_4G) |
Kyösti Mälkki | 27d6299 | 2022-05-24 20:25:58 +0300 | [diff] [blame] | 46 | ram_resource_kb(dev, idx++, basek_4G, tomk - basek_4G); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 47 | |
| 48 | if (remaplimitk > remapbasek) |
Kyösti Mälkki | 27d6299 | 2022-05-24 20:25:58 +0300 | [diff] [blame] | 49 | ram_resource_kb(dev, idx++, remapbasek, remaplimitk - remapbasek); |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static void mch_domain_set_resources(struct device *dev) |
| 53 | { |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 54 | assign_resources(dev->link_list); |
| 55 | } |
| 56 | |
| 57 | static struct device_operations pci_domain_ops = { |
Kyösti Mälkki | 9e69c87 | 2018-06-02 15:35:27 +0300 | [diff] [blame] | 58 | .read_resources = mch_domain_read_resources, |
| 59 | .set_resources = mch_domain_set_resources, |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 60 | .scan_bus = pci_domain_scan_bus, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 61 | .ops_pci = &pci_dev_ops_pci, |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
Elyes HAOUAS | 97e8b75 | 2018-05-09 17:39:47 +0200 | [diff] [blame] | 64 | static void cpu_bus_init(struct device *dev) |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 65 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 66 | initialize_cpus(dev->link_list); |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 69 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 70 | .read_resources = noop_read_resources, |
| 71 | .set_resources = noop_set_resources, |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 72 | .init = cpu_bus_init, |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | static void enable_dev(struct device *dev) |
| 76 | { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 77 | /* Set the operations if it is a special bus type */ |
| 78 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 79 | dev->ops = &pci_domain_ops; |
| 80 | } |
| 81 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 82 | dev->ops = &cpu_bus_ops; |
| 83 | } |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Kyösti Mälkki | 0a0d5e8 | 2011-10-31 14:18:33 +0200 | [diff] [blame] | 86 | struct chip_operations northbridge_intel_e7505_ops = { |
| 87 | CHIP_NAME("Intel E7505 Northbridge") |
Stefan Reinauer | b15975b | 2011-10-21 12:57:59 -0700 | [diff] [blame] | 88 | .enable_dev = enable_dev, |
| 89 | }; |