From 6c708d8a467e7027cd841896b8f5cbc8555fb254 Mon Sep 17 00:00:00 2001 From: Shuo Liu Date: Mon, 29 Apr 2024 18:16:30 +0800 Subject: soc/intel/xeon_sp: Add domain resource window creation utils It might be benefical to have utils for domain resource window creation so that the correct IORESOURCE flags used could be guaranteed. TEST=Build and boot on intel/archercity CRB TEST=Build on intel/avenuecity CRB Change-Id: I1e90512a48ab002a1c1d5031585ddadaac63673e Signed-off-by: Shuo Liu Reviewed-on: https://review.coreboot.org/c/coreboot/+/82103 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/include/device/device.h | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'src/include') diff --git a/src/include/device/device.h b/src/include/device/device.h index 48e539f8dc..367635a952 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -263,7 +263,7 @@ void mmconf_resource(struct device *dev, unsigned long index); /* These are temporary resource constructors to get us through the migration away from open-coding all the IORESOURCE_FLAGS. */ -const struct resource *fixed_resource_range_idx(struct device *dev, unsigned long index, +const struct resource *resource_range_idx(struct device *dev, unsigned long index, uint64_t base, uint64_t size, unsigned long flags); @@ -272,7 +272,8 @@ const struct resource *fixed_mem_range_flags(struct device *dev, unsigned long i uint64_t base, uint64_t size, unsigned long flags) { - return fixed_resource_range_idx(dev, index, base, size, IORESOURCE_MEM | flags); + return resource_range_idx(dev, index, base, size, + IORESOURCE_FIXED | IORESOURCE_MEM | flags); } static inline @@ -284,6 +285,24 @@ const struct resource *fixed_mem_from_to_flags(struct device *dev, unsigned long return fixed_mem_range_flags(dev, index, base, end - base, flags); } +static inline +const struct resource *domain_mem_window_range(struct device *dev, unsigned long index, + uint64_t base, uint64_t size) +{ + return resource_range_idx(dev, index, base, size, + IORESOURCE_MEM | IORESOURCE_BRIDGE); +} + +static inline +const struct resource *domain_mem_window_from_to(struct device *dev, unsigned long index, + uint64_t base, uint64_t end) +{ + if (end <= base) + return NULL; + return domain_mem_window_range(dev, index, base, end - base); +} + + static inline const struct resource *ram_range(struct device *dev, unsigned long index, uint64_t base, uint64_t size) @@ -344,7 +363,8 @@ static inline const struct resource *fixed_io_range_flags(struct device *dev, unsigned long index, uint16_t base, uint16_t size, unsigned long flags) { - return fixed_resource_range_idx(dev, index, base, size, IORESOURCE_IO | flags); + return resource_range_idx(dev, index, base, size, + IORESOURCE_FIXED | IORESOURCE_IO | flags); } static inline @@ -363,6 +383,23 @@ const struct resource *fixed_io_range_reserved(struct device *dev, unsigned long return fixed_io_range_flags(dev, index, base, size, IORESOURCE_RESERVE); } +static inline +const struct resource *domain_io_window_range(struct device *dev, unsigned long index, + uint16_t base, uint16_t size) +{ + return resource_range_idx(dev, index, base, size, + IORESOURCE_IO | IORESOURCE_BRIDGE); +} + +static inline +const struct resource *domain_io_window_from_to(struct device *dev, unsigned long index, + uint16_t base, uint16_t end) +{ + if (end <= base) + return NULL; + return domain_io_window_range(dev, index, base, end - base); +} + /* Compatibility code */ static inline void fixed_mem_resource_kb(struct device *dev, unsigned long index, -- cgit v1.2.3