Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Joseph Smith | 0d7a996 | 2010-03-17 03:18:29 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org> |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <arch/io.h> |
| 19 | #include <stdint.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <device/pci_ids.h> |
Stefan Reinauer | fd611f9 | 2013-02-27 23:45:20 +0100 | [diff] [blame] | 23 | #include <cbmem.h> |
Stefan Reinauer | be7f798 | 2009-03-13 15:42:27 +0000 | [diff] [blame] | 24 | #include <cpu/cpu.h> |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 27 | #include "i82830.h" |
| 28 | |
| 29 | static void northbridge_init(device_t dev) |
| 30 | { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 31 | printk(BIOS_SPEW, "Northbridge init\n"); |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static struct device_operations northbridge_operations = { |
| 35 | .read_resources = pci_dev_read_resources, |
| 36 | .set_resources = pci_dev_set_resources, |
| 37 | .enable_resources = pci_dev_enable_resources, |
| 38 | .init = northbridge_init, |
| 39 | .enable = 0, |
| 40 | .ops_pci = 0, |
| 41 | }; |
| 42 | |
Stefan Reinauer | 6363050 | 2010-02-22 09:28:15 +0000 | [diff] [blame] | 43 | static const struct pci_driver northbridge_driver __pci_driver = { |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 44 | .ops = &northbridge_operations, |
| 45 | .vendor = PCI_VENDOR_ID_INTEL, |
| 46 | .device = 0x3575, |
| 47 | }; |
| 48 | |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 49 | static void pci_domain_set_resources(device_t dev) |
| 50 | { |
| 51 | device_t mc_dev; |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 52 | int igd_memory = 0; |
Kyösti Mälkki | f7bfc34 | 2013-10-18 11:02:46 +0300 | [diff] [blame] | 53 | uint64_t uma_memory_base = 0, uma_memory_size = 0; |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 54 | |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 55 | mc_dev = dev->link_list->children; |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 56 | if (!mc_dev) |
| 57 | return; |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 58 | |
Kyösti Mälkki | 6ff1d36 | 2012-07-27 08:42:20 +0300 | [diff] [blame] | 59 | unsigned long tomk, tomk_stolen; |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 60 | int idx; |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 61 | |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 62 | if (CONFIG_VIDEO_MB == 512) { |
| 63 | igd_memory = (CONFIG_VIDEO_MB); |
| 64 | printk(BIOS_DEBUG, "%dKB IGD UMA\n", igd_memory >> 10); |
| 65 | } else { |
| 66 | igd_memory = (CONFIG_VIDEO_MB * 1024); |
| 67 | printk(BIOS_DEBUG, "%dMB IGD UMA\n", igd_memory >> 10); |
| 68 | } |
Joseph Smith | 0d7a996 | 2010-03-17 03:18:29 +0000 | [diff] [blame] | 69 | |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 70 | /* Get the value of the highest DRB. This tells the end of |
| 71 | * the physical memory. The units are ticks of 32MB |
| 72 | * i.e. 1 means 32MB. |
| 73 | */ |
| 74 | tomk = ((unsigned long)pci_read_config8(mc_dev, DRB + 3)) << 15; |
Kyösti Mälkki | 6ff1d36 | 2012-07-27 08:42:20 +0300 | [diff] [blame] | 75 | tomk_stolen = tomk - igd_memory; |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 76 | |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 77 | /* For reserving UMA memory in the memory map */ |
Kyösti Mälkki | 6ff1d36 | 2012-07-27 08:42:20 +0300 | [diff] [blame] | 78 | uma_memory_base = tomk_stolen * 1024ULL; |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 79 | uma_memory_size = igd_memory * 1024ULL; |
Kyösti Mälkki | 6ff1d36 | 2012-07-27 08:42:20 +0300 | [diff] [blame] | 80 | printk(BIOS_DEBUG, "Available memory: %ldKB\n", tomk_stolen); |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 81 | |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 82 | /* Report the memory regions. */ |
| 83 | idx = 10; |
| 84 | ram_resource(dev, idx++, 0, 640); |
Kyösti Mälkki | 6ff1d36 | 2012-07-27 08:42:20 +0300 | [diff] [blame] | 85 | ram_resource(dev, idx++, 768, tomk - 768); |
| 86 | uma_resource(dev, idx++, uma_memory_base >> 10, uma_memory_size >> 10); |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 87 | |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 88 | assign_resources(dev->link_list); |
Stefan Reinauer | b5fb0c5 | 2009-04-30 13:58:42 +0000 | [diff] [blame] | 89 | |
Kyösti Mälkki | 42f4651 | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 90 | set_top_of_ram(tomk_stolen * 1024); |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 93 | static struct device_operations pci_domain_ops = { |
| 94 | .read_resources = pci_domain_read_resources, |
| 95 | .set_resources = pci_domain_set_resources, |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 96 | .enable_resources = NULL, |
| 97 | .init = NULL, |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 98 | .scan_bus = pci_domain_scan_bus, |
Kyösti Mälkki | 33e5df3 | 2013-07-03 10:51:34 +0300 | [diff] [blame] | 99 | .ops_pci_bus = pci_bus_default_ops, |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | static void cpu_bus_init(device_t dev) |
| 103 | { |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 104 | initialize_cpus(dev->link_list); |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 107 | static struct device_operations cpu_bus_ops = { |
Edward O'Callaghan | 9f74462 | 2014-10-31 08:12:34 +1100 | [diff] [blame] | 108 | .read_resources = DEVICE_NOOP, |
| 109 | .set_resources = DEVICE_NOOP, |
| 110 | .enable_resources = DEVICE_NOOP, |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 111 | .init = cpu_bus_init, |
| 112 | .scan_bus = 0, |
| 113 | }; |
| 114 | |
| 115 | static void enable_dev(struct device *dev) |
| 116 | { |
| 117 | struct device_path; |
| 118 | |
| 119 | /* Set the operations if it is a special bus type. */ |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 120 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 121 | dev->ops = &pci_domain_ops; |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 122 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
Joseph Smith | 6a1dc86 | 2008-03-09 13:24:46 +0000 | [diff] [blame] | 123 | dev->ops = &cpu_bus_ops; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | struct chip_operations northbridge_intel_i82830_ops = { |
| 128 | CHIP_NAME("Intel 82830 Northbridge") |
| 129 | .enable_dev = enable_dev, |
| 130 | }; |