nb/haswell: Use newer function for resource declarations

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Change-Id: Ib649943e13b9b319297c4be68b7039b760ebd820
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76270
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Arthur Heymans 2023-07-05 09:22:39 +02:00 committed by Kyösti Mälkki
parent 99eee16a13
commit a5543aeae6
1 changed files with 24 additions and 45 deletions

View File

@ -96,7 +96,6 @@ static void mc_add_fixed_mmio_resources(struct device *dev)
for (i = 0; i < ARRAY_SIZE(mc_fixed_resources); i++) { for (i = 0; i < ARRAY_SIZE(mc_fixed_resources); i++) {
u32 base; u32 base;
u32 size; u32 size;
struct resource *resource;
unsigned int index; unsigned int index;
size = mc_fixed_resources[i].size; size = mc_fixed_resources[i].size;
@ -104,12 +103,7 @@ static void mc_add_fixed_mmio_resources(struct device *dev)
if (!mc_fixed_resources[i].get_resource(dev, index, &base, &size)) if (!mc_fixed_resources[i].get_resource(dev, index, &base, &size))
continue; continue;
resource = new_resource(dev, mc_fixed_resources[i].index); mmio_range(dev, mc_fixed_resources[i].index, base, size);
resource->base = base;
resource->size = size;
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_RESERVE | IORESOURCE_ASSIGNED;
printk(BIOS_DEBUG, "%s: Adding %s @ %x 0x%08lx-0x%08lx.\n", printk(BIOS_DEBUG, "%s: Adding %s @ %x 0x%08lx-0x%08lx.\n",
__func__, mc_fixed_resources[i].description, index, __func__, mc_fixed_resources[i].description, index,
(unsigned long)base, (unsigned long)(base + size - 1)); (unsigned long)base, (unsigned long)(base + size - 1));
@ -236,8 +230,7 @@ static void mc_report_map_entries(struct device *dev, uint64_t *values)
static void mc_add_dram_resources(struct device *dev, int *resource_cnt) static void mc_add_dram_resources(struct device *dev, int *resource_cnt)
{ {
unsigned long base_k, size_k, index; int index;
struct resource *resource;
uint64_t mc_values[NUM_MAP_ENTRIES]; uint64_t mc_values[NUM_MAP_ENTRIES];
/* Read in the MAP registers and report their values */ /* Read in the MAP registers and report their values */
@ -283,43 +276,29 @@ static void mc_add_dram_resources(struct device *dev, int *resource_cnt)
*/ */
index = *resource_cnt; index = *resource_cnt;
/* 0 - > 0xa0000 */ /*
base_k = 0; * 0 - > 0xa0000: RAM
size_k = (0xa0000 >> 10) - base_k;
ram_resource_kb(dev, index++, base_k, size_k);
/* 0xc0000 -> TSEG - DPR */
base_k = 0xc0000 >> 10;
size_k = (unsigned long)(mc_values[TSEG_REG] >> 10) - base_k;
size_k -= dpr.size * MiB / KiB;
ram_resource_kb(dev, index++, base_k, size_k);
/* TSEG - DPR -> BGSM */
resource = new_resource(dev, index++);
resource->base = mc_values[TSEG_REG] - dpr.size * MiB;
resource->size = mc_values[BGSM_REG] - (mc_values[TSEG_REG] - dpr.size * MiB);
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_RESERVE | IORESOURCE_ASSIGNED | IORESOURCE_CACHEABLE;
/* BGSM -> TOLUD. If the IGD is disabled, BGSM can equal TOLUD. */
if (mc_values[BGSM_REG] != mc_values[TOLUD_REG]) {
resource = new_resource(dev, index++);
resource->base = mc_values[BGSM_REG];
resource->size = mc_values[TOLUD_REG] - mc_values[BGSM_REG];
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_RESERVE | IORESOURCE_ASSIGNED;
}
/* 4GiB -> TOUUD */
upper_ram_end(dev, index++, mc_values[TOUUD_REG]);
/* Reserve everything between A segment and 1MB:
*
* 0xa0000 - 0xbffff: Legacy VGA * 0xa0000 - 0xbffff: Legacy VGA
* 0xc0000 - 0xfffff: RAM * 0xc0000 - 0xfffff: RAM
*/ */
mmio_resource_kb(dev, index++, (0xa0000 >> 10), (0xc0000 - 0xa0000) >> 10);
reserved_ram_resource_kb(dev, index++, (0xc0000 >> 10), (0x100000 - 0xc0000) >> 10); ram_range(dev, index++, 0, 0xa0000);
mmio_from_to(dev, index++, 0xa0000, 0xc0000);
reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB);
/* 1MiB -> TSEG - DPR */
ram_from_to(dev, index++, 1 * MiB, mc_values[TSEG_REG] - dpr.size * MiB);
/* TSEG - DPR -> BGSM */
reserved_ram_from_to(dev, index++, mc_values[TSEG_REG] - dpr.size * MiB,
mc_values[BGSM_REG]);
/* BGSM -> TOLUD. If the IGD is disabled, BGSM can equal TOLUD. */
if (mc_values[BGSM_REG] != mc_values[TOLUD_REG])
mmio_from_to(dev, index++, mc_values[BGSM_REG], mc_values[TOLUD_REG]);
/* 4GiB -> TOUUD */
upper_ram_end(dev, index++, mc_values[TOUUD_REG]);
*resource_cnt = index; *resource_cnt = index;
} }
@ -337,8 +316,8 @@ static void mc_read_resources(struct device *dev)
/* Add VT-d MMIO resources, if capable */ /* Add VT-d MMIO resources, if capable */
if (vtd_capable) { if (vtd_capable) {
mmio_resource_kb(dev, index++, GFXVT_BASE_ADDRESS / KiB, GFXVT_BASE_SIZE / KiB); mmio_range(dev, index++, GFXVT_BASE_ADDRESS, GFXVT_BASE_SIZE);
mmio_resource_kb(dev, index++, VTVC0_BASE_ADDRESS / KiB, VTVC0_BASE_SIZE / KiB); mmio_range(dev, index++, VTVC0_BASE_ADDRESS, VTVC0_BASE_SIZE);
} }
/* Calculate and add DRAM resources */ /* Calculate and add DRAM resources */