162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * ioport.h Definitions of routines for detecting, reserving and 462306a36Sopenharmony_ci * allocating system resources. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Authors: Linus Torvalds 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _LINUX_IOPORT_H 1062306a36Sopenharmony_ci#define _LINUX_IOPORT_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1362306a36Sopenharmony_ci#include <linux/bits.h> 1462306a36Sopenharmony_ci#include <linux/compiler.h> 1562306a36Sopenharmony_ci#include <linux/minmax.h> 1662306a36Sopenharmony_ci#include <linux/types.h> 1762306a36Sopenharmony_ci/* 1862306a36Sopenharmony_ci * Resources are tree-like, allowing 1962306a36Sopenharmony_ci * nesting etc.. 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_cistruct resource { 2262306a36Sopenharmony_ci resource_size_t start; 2362306a36Sopenharmony_ci resource_size_t end; 2462306a36Sopenharmony_ci const char *name; 2562306a36Sopenharmony_ci unsigned long flags; 2662306a36Sopenharmony_ci unsigned long desc; 2762306a36Sopenharmony_ci struct resource *parent, *sibling, *child; 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/* 3162306a36Sopenharmony_ci * IO resources have these defined flags. 3262306a36Sopenharmony_ci * 3362306a36Sopenharmony_ci * PCI devices expose these flags to userspace in the "resource" sysfs file, 3462306a36Sopenharmony_ci * so don't move them. 3562306a36Sopenharmony_ci */ 3662306a36Sopenharmony_ci#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */ 3962306a36Sopenharmony_ci#define IORESOURCE_IO 0x00000100 /* PCI/ISA I/O ports */ 4062306a36Sopenharmony_ci#define IORESOURCE_MEM 0x00000200 4162306a36Sopenharmony_ci#define IORESOURCE_REG 0x00000300 /* Register offsets */ 4262306a36Sopenharmony_ci#define IORESOURCE_IRQ 0x00000400 4362306a36Sopenharmony_ci#define IORESOURCE_DMA 0x00000800 4462306a36Sopenharmony_ci#define IORESOURCE_BUS 0x00001000 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define IORESOURCE_PREFETCH 0x00002000 /* No side effects */ 4762306a36Sopenharmony_ci#define IORESOURCE_READONLY 0x00004000 4862306a36Sopenharmony_ci#define IORESOURCE_CACHEABLE 0x00008000 4962306a36Sopenharmony_ci#define IORESOURCE_RANGELENGTH 0x00010000 5062306a36Sopenharmony_ci#define IORESOURCE_SHADOWABLE 0x00020000 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define IORESOURCE_SIZEALIGN 0x00040000 /* size indicates alignment */ 5362306a36Sopenharmony_ci#define IORESOURCE_STARTALIGN 0x00080000 /* start field is alignment */ 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#define IORESOURCE_MEM_64 0x00100000 5662306a36Sopenharmony_ci#define IORESOURCE_WINDOW 0x00200000 /* forwarded by bridge */ 5762306a36Sopenharmony_ci#define IORESOURCE_MUXED 0x00400000 /* Resource is software muxed */ 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define IORESOURCE_EXT_TYPE_BITS 0x01000000 /* Resource extended types */ 6062306a36Sopenharmony_ci#define IORESOURCE_SYSRAM 0x01000000 /* System RAM (modifier) */ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* IORESOURCE_SYSRAM specific bits. */ 6362306a36Sopenharmony_ci#define IORESOURCE_SYSRAM_DRIVER_MANAGED 0x02000000 /* Always detected via a driver. */ 6462306a36Sopenharmony_ci#define IORESOURCE_SYSRAM_MERGEABLE 0x04000000 /* Resource can be merged. */ 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define IORESOURCE_EXCLUSIVE 0x08000000 /* Userland may not map this resource */ 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define IORESOURCE_DISABLED 0x10000000 6962306a36Sopenharmony_ci#define IORESOURCE_UNSET 0x20000000 /* No address assigned yet */ 7062306a36Sopenharmony_ci#define IORESOURCE_AUTO 0x40000000 7162306a36Sopenharmony_ci#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* I/O resource extended types */ 7462306a36Sopenharmony_ci#define IORESOURCE_SYSTEM_RAM (IORESOURCE_MEM|IORESOURCE_SYSRAM) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* PnP IRQ specific bits (IORESOURCE_BITS) */ 7762306a36Sopenharmony_ci#define IORESOURCE_IRQ_HIGHEDGE (1<<0) 7862306a36Sopenharmony_ci#define IORESOURCE_IRQ_LOWEDGE (1<<1) 7962306a36Sopenharmony_ci#define IORESOURCE_IRQ_HIGHLEVEL (1<<2) 8062306a36Sopenharmony_ci#define IORESOURCE_IRQ_LOWLEVEL (1<<3) 8162306a36Sopenharmony_ci#define IORESOURCE_IRQ_SHAREABLE (1<<4) 8262306a36Sopenharmony_ci#define IORESOURCE_IRQ_OPTIONAL (1<<5) 8362306a36Sopenharmony_ci#define IORESOURCE_IRQ_WAKECAPABLE (1<<6) 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci/* PnP DMA specific bits (IORESOURCE_BITS) */ 8662306a36Sopenharmony_ci#define IORESOURCE_DMA_TYPE_MASK (3<<0) 8762306a36Sopenharmony_ci#define IORESOURCE_DMA_8BIT (0<<0) 8862306a36Sopenharmony_ci#define IORESOURCE_DMA_8AND16BIT (1<<0) 8962306a36Sopenharmony_ci#define IORESOURCE_DMA_16BIT (2<<0) 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define IORESOURCE_DMA_MASTER (1<<2) 9262306a36Sopenharmony_ci#define IORESOURCE_DMA_BYTE (1<<3) 9362306a36Sopenharmony_ci#define IORESOURCE_DMA_WORD (1<<4) 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define IORESOURCE_DMA_SPEED_MASK (3<<6) 9662306a36Sopenharmony_ci#define IORESOURCE_DMA_COMPATIBLE (0<<6) 9762306a36Sopenharmony_ci#define IORESOURCE_DMA_TYPEA (1<<6) 9862306a36Sopenharmony_ci#define IORESOURCE_DMA_TYPEB (2<<6) 9962306a36Sopenharmony_ci#define IORESOURCE_DMA_TYPEF (3<<6) 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/* PnP memory I/O specific bits (IORESOURCE_BITS) */ 10262306a36Sopenharmony_ci#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ 10362306a36Sopenharmony_ci#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ 10462306a36Sopenharmony_ci#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ 10562306a36Sopenharmony_ci#define IORESOURCE_MEM_TYPE_MASK (3<<3) 10662306a36Sopenharmony_ci#define IORESOURCE_MEM_8BIT (0<<3) 10762306a36Sopenharmony_ci#define IORESOURCE_MEM_16BIT (1<<3) 10862306a36Sopenharmony_ci#define IORESOURCE_MEM_8AND16BIT (2<<3) 10962306a36Sopenharmony_ci#define IORESOURCE_MEM_32BIT (3<<3) 11062306a36Sopenharmony_ci#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ 11162306a36Sopenharmony_ci#define IORESOURCE_MEM_EXPANSIONROM (1<<6) 11262306a36Sopenharmony_ci#define IORESOURCE_MEM_NONPOSTED (1<<7) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* PnP I/O specific bits (IORESOURCE_BITS) */ 11562306a36Sopenharmony_ci#define IORESOURCE_IO_16BIT_ADDR (1<<0) 11662306a36Sopenharmony_ci#define IORESOURCE_IO_FIXED (1<<1) 11762306a36Sopenharmony_ci#define IORESOURCE_IO_SPARSE (1<<2) 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci/* PCI ROM control bits (IORESOURCE_BITS) */ 12062306a36Sopenharmony_ci#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ 12162306a36Sopenharmony_ci#define IORESOURCE_ROM_SHADOW (1<<1) /* Use RAM image, not ROM BAR */ 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci/* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */ 12462306a36Sopenharmony_ci#define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */ 12562306a36Sopenharmony_ci#define IORESOURCE_PCI_EA_BEI (1<<5) /* BAR Equivalent Indicator */ 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci/* 12862306a36Sopenharmony_ci * I/O Resource Descriptors 12962306a36Sopenharmony_ci * 13062306a36Sopenharmony_ci * Descriptors are used by walk_iomem_res_desc() and region_intersects() 13162306a36Sopenharmony_ci * for searching a specific resource range in the iomem table. Assign 13262306a36Sopenharmony_ci * a new descriptor when a resource range supports the search interfaces. 13362306a36Sopenharmony_ci * Otherwise, resource.desc must be set to IORES_DESC_NONE (0). 13462306a36Sopenharmony_ci */ 13562306a36Sopenharmony_cienum { 13662306a36Sopenharmony_ci IORES_DESC_NONE = 0, 13762306a36Sopenharmony_ci IORES_DESC_CRASH_KERNEL = 1, 13862306a36Sopenharmony_ci IORES_DESC_ACPI_TABLES = 2, 13962306a36Sopenharmony_ci IORES_DESC_ACPI_NV_STORAGE = 3, 14062306a36Sopenharmony_ci IORES_DESC_PERSISTENT_MEMORY = 4, 14162306a36Sopenharmony_ci IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, 14262306a36Sopenharmony_ci IORES_DESC_DEVICE_PRIVATE_MEMORY = 6, 14362306a36Sopenharmony_ci IORES_DESC_RESERVED = 7, 14462306a36Sopenharmony_ci IORES_DESC_SOFT_RESERVED = 8, 14562306a36Sopenharmony_ci IORES_DESC_CXL = 9, 14662306a36Sopenharmony_ci}; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/* 14962306a36Sopenharmony_ci * Flags controlling ioremap() behavior. 15062306a36Sopenharmony_ci */ 15162306a36Sopenharmony_cienum { 15262306a36Sopenharmony_ci IORES_MAP_SYSTEM_RAM = BIT(0), 15362306a36Sopenharmony_ci IORES_MAP_ENCRYPTED = BIT(1), 15462306a36Sopenharmony_ci}; 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci/* helpers to define resources */ 15762306a36Sopenharmony_ci#define DEFINE_RES_NAMED(_start, _size, _name, _flags) \ 15862306a36Sopenharmony_ci(struct resource) { \ 15962306a36Sopenharmony_ci .start = (_start), \ 16062306a36Sopenharmony_ci .end = (_start) + (_size) - 1, \ 16162306a36Sopenharmony_ci .name = (_name), \ 16262306a36Sopenharmony_ci .flags = (_flags), \ 16362306a36Sopenharmony_ci .desc = IORES_DESC_NONE, \ 16462306a36Sopenharmony_ci } 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci#define DEFINE_RES_IO_NAMED(_start, _size, _name) \ 16762306a36Sopenharmony_ci DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_IO) 16862306a36Sopenharmony_ci#define DEFINE_RES_IO(_start, _size) \ 16962306a36Sopenharmony_ci DEFINE_RES_IO_NAMED((_start), (_size), NULL) 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#define DEFINE_RES_MEM_NAMED(_start, _size, _name) \ 17262306a36Sopenharmony_ci DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_MEM) 17362306a36Sopenharmony_ci#define DEFINE_RES_MEM(_start, _size) \ 17462306a36Sopenharmony_ci DEFINE_RES_MEM_NAMED((_start), (_size), NULL) 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci#define DEFINE_RES_REG_NAMED(_start, _size, _name) \ 17762306a36Sopenharmony_ci DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_REG) 17862306a36Sopenharmony_ci#define DEFINE_RES_REG(_start, _size) \ 17962306a36Sopenharmony_ci DEFINE_RES_REG_NAMED((_start), (_size), NULL) 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci#define DEFINE_RES_IRQ_NAMED(_irq, _name) \ 18262306a36Sopenharmony_ci DEFINE_RES_NAMED((_irq), 1, (_name), IORESOURCE_IRQ) 18362306a36Sopenharmony_ci#define DEFINE_RES_IRQ(_irq) \ 18462306a36Sopenharmony_ci DEFINE_RES_IRQ_NAMED((_irq), NULL) 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci#define DEFINE_RES_DMA_NAMED(_dma, _name) \ 18762306a36Sopenharmony_ci DEFINE_RES_NAMED((_dma), 1, (_name), IORESOURCE_DMA) 18862306a36Sopenharmony_ci#define DEFINE_RES_DMA(_dma) \ 18962306a36Sopenharmony_ci DEFINE_RES_DMA_NAMED((_dma), NULL) 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci/* PC/ISA/whatever - the normal PC address spaces: IO and memory */ 19262306a36Sopenharmony_ciextern struct resource ioport_resource; 19362306a36Sopenharmony_ciextern struct resource iomem_resource; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ciextern struct resource *request_resource_conflict(struct resource *root, struct resource *new); 19662306a36Sopenharmony_ciextern int request_resource(struct resource *root, struct resource *new); 19762306a36Sopenharmony_ciextern int release_resource(struct resource *new); 19862306a36Sopenharmony_civoid release_child_resources(struct resource *new); 19962306a36Sopenharmony_ciextern void reserve_region_with_split(struct resource *root, 20062306a36Sopenharmony_ci resource_size_t start, resource_size_t end, 20162306a36Sopenharmony_ci const char *name); 20262306a36Sopenharmony_ciextern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new); 20362306a36Sopenharmony_ciextern int insert_resource(struct resource *parent, struct resource *new); 20462306a36Sopenharmony_ciextern void insert_resource_expand_to_fit(struct resource *root, struct resource *new); 20562306a36Sopenharmony_ciextern int remove_resource(struct resource *old); 20662306a36Sopenharmony_ciextern void arch_remove_reservations(struct resource *avail); 20762306a36Sopenharmony_ciextern int allocate_resource(struct resource *root, struct resource *new, 20862306a36Sopenharmony_ci resource_size_t size, resource_size_t min, 20962306a36Sopenharmony_ci resource_size_t max, resource_size_t align, 21062306a36Sopenharmony_ci resource_size_t (*alignf)(void *, 21162306a36Sopenharmony_ci const struct resource *, 21262306a36Sopenharmony_ci resource_size_t, 21362306a36Sopenharmony_ci resource_size_t), 21462306a36Sopenharmony_ci void *alignf_data); 21562306a36Sopenharmony_cistruct resource *lookup_resource(struct resource *root, resource_size_t start); 21662306a36Sopenharmony_ciint adjust_resource(struct resource *res, resource_size_t start, 21762306a36Sopenharmony_ci resource_size_t size); 21862306a36Sopenharmony_ciresource_size_t resource_alignment(struct resource *res); 21962306a36Sopenharmony_cistatic inline resource_size_t resource_size(const struct resource *res) 22062306a36Sopenharmony_ci{ 22162306a36Sopenharmony_ci return res->end - res->start + 1; 22262306a36Sopenharmony_ci} 22362306a36Sopenharmony_cistatic inline unsigned long resource_type(const struct resource *res) 22462306a36Sopenharmony_ci{ 22562306a36Sopenharmony_ci return res->flags & IORESOURCE_TYPE_BITS; 22662306a36Sopenharmony_ci} 22762306a36Sopenharmony_cistatic inline unsigned long resource_ext_type(const struct resource *res) 22862306a36Sopenharmony_ci{ 22962306a36Sopenharmony_ci return res->flags & IORESOURCE_EXT_TYPE_BITS; 23062306a36Sopenharmony_ci} 23162306a36Sopenharmony_ci/* True iff r1 completely contains r2 */ 23262306a36Sopenharmony_cistatic inline bool resource_contains(struct resource *r1, struct resource *r2) 23362306a36Sopenharmony_ci{ 23462306a36Sopenharmony_ci if (resource_type(r1) != resource_type(r2)) 23562306a36Sopenharmony_ci return false; 23662306a36Sopenharmony_ci if (r1->flags & IORESOURCE_UNSET || r2->flags & IORESOURCE_UNSET) 23762306a36Sopenharmony_ci return false; 23862306a36Sopenharmony_ci return r1->start <= r2->start && r1->end >= r2->end; 23962306a36Sopenharmony_ci} 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci/* True if any part of r1 overlaps r2 */ 24262306a36Sopenharmony_cistatic inline bool resource_overlaps(struct resource *r1, struct resource *r2) 24362306a36Sopenharmony_ci{ 24462306a36Sopenharmony_ci return r1->start <= r2->end && r1->end >= r2->start; 24562306a36Sopenharmony_ci} 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_cistatic inline bool 24862306a36Sopenharmony_ciresource_intersection(struct resource *r1, struct resource *r2, struct resource *r) 24962306a36Sopenharmony_ci{ 25062306a36Sopenharmony_ci if (!resource_overlaps(r1, r2)) 25162306a36Sopenharmony_ci return false; 25262306a36Sopenharmony_ci r->start = max(r1->start, r2->start); 25362306a36Sopenharmony_ci r->end = min(r1->end, r2->end); 25462306a36Sopenharmony_ci return true; 25562306a36Sopenharmony_ci} 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_cistatic inline bool 25862306a36Sopenharmony_ciresource_union(struct resource *r1, struct resource *r2, struct resource *r) 25962306a36Sopenharmony_ci{ 26062306a36Sopenharmony_ci if (!resource_overlaps(r1, r2)) 26162306a36Sopenharmony_ci return false; 26262306a36Sopenharmony_ci r->start = min(r1->start, r2->start); 26362306a36Sopenharmony_ci r->end = max(r1->end, r2->end); 26462306a36Sopenharmony_ci return true; 26562306a36Sopenharmony_ci} 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci/* Convenience shorthand with allocation */ 26862306a36Sopenharmony_ci#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name), 0) 26962306a36Sopenharmony_ci#define request_muxed_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name), IORESOURCE_MUXED) 27062306a36Sopenharmony_ci#define __request_mem_region(start,n,name, excl) __request_region(&iomem_resource, (start), (n), (name), excl) 27162306a36Sopenharmony_ci#define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name), 0) 27262306a36Sopenharmony_ci#define request_mem_region_muxed(start, n, name) \ 27362306a36Sopenharmony_ci __request_region(&iomem_resource, (start), (n), (name), IORESOURCE_MUXED) 27462306a36Sopenharmony_ci#define request_mem_region_exclusive(start,n,name) \ 27562306a36Sopenharmony_ci __request_region(&iomem_resource, (start), (n), (name), IORESOURCE_EXCLUSIVE) 27662306a36Sopenharmony_ci#define rename_region(region, newname) do { (region)->name = (newname); } while (0) 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_ciextern struct resource * __request_region(struct resource *, 27962306a36Sopenharmony_ci resource_size_t start, 28062306a36Sopenharmony_ci resource_size_t n, 28162306a36Sopenharmony_ci const char *name, int flags); 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ci/* Compatibility cruft */ 28462306a36Sopenharmony_ci#define release_region(start,n) __release_region(&ioport_resource, (start), (n)) 28562306a36Sopenharmony_ci#define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ciextern void __release_region(struct resource *, resource_size_t, 28862306a36Sopenharmony_ci resource_size_t); 28962306a36Sopenharmony_ci#ifdef CONFIG_MEMORY_HOTREMOVE 29062306a36Sopenharmony_ciextern void release_mem_region_adjustable(resource_size_t, resource_size_t); 29162306a36Sopenharmony_ci#endif 29262306a36Sopenharmony_ci#ifdef CONFIG_MEMORY_HOTPLUG 29362306a36Sopenharmony_ciextern void merge_system_ram_resource(struct resource *res); 29462306a36Sopenharmony_ci#endif 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci/* Wrappers for managed devices */ 29762306a36Sopenharmony_cistruct device; 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ciextern int devm_request_resource(struct device *dev, struct resource *root, 30062306a36Sopenharmony_ci struct resource *new); 30162306a36Sopenharmony_ciextern void devm_release_resource(struct device *dev, struct resource *new); 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci#define devm_request_region(dev,start,n,name) \ 30462306a36Sopenharmony_ci __devm_request_region(dev, &ioport_resource, (start), (n), (name)) 30562306a36Sopenharmony_ci#define devm_request_mem_region(dev,start,n,name) \ 30662306a36Sopenharmony_ci __devm_request_region(dev, &iomem_resource, (start), (n), (name)) 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ciextern struct resource * __devm_request_region(struct device *dev, 30962306a36Sopenharmony_ci struct resource *parent, resource_size_t start, 31062306a36Sopenharmony_ci resource_size_t n, const char *name); 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci#define devm_release_region(dev, start, n) \ 31362306a36Sopenharmony_ci __devm_release_region(dev, &ioport_resource, (start), (n)) 31462306a36Sopenharmony_ci#define devm_release_mem_region(dev, start, n) \ 31562306a36Sopenharmony_ci __devm_release_region(dev, &iomem_resource, (start), (n)) 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ciextern void __devm_release_region(struct device *dev, struct resource *parent, 31862306a36Sopenharmony_ci resource_size_t start, resource_size_t n); 31962306a36Sopenharmony_ciextern int iomem_map_sanity_check(resource_size_t addr, unsigned long size); 32062306a36Sopenharmony_ciextern bool iomem_is_exclusive(u64 addr); 32162306a36Sopenharmony_ciextern bool resource_is_exclusive(struct resource *resource, u64 addr, 32262306a36Sopenharmony_ci resource_size_t size); 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ciextern int 32562306a36Sopenharmony_ciwalk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, 32662306a36Sopenharmony_ci void *arg, int (*func)(unsigned long, unsigned long, void *)); 32762306a36Sopenharmony_ciextern int 32862306a36Sopenharmony_ciwalk_mem_res(u64 start, u64 end, void *arg, 32962306a36Sopenharmony_ci int (*func)(struct resource *, void *)); 33062306a36Sopenharmony_ciextern int 33162306a36Sopenharmony_ciwalk_system_ram_res(u64 start, u64 end, void *arg, 33262306a36Sopenharmony_ci int (*func)(struct resource *, void *)); 33362306a36Sopenharmony_ciextern int 33462306a36Sopenharmony_ciwalk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, 33562306a36Sopenharmony_ci void *arg, int (*func)(struct resource *, void *)); 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_cistruct resource *devm_request_free_mem_region(struct device *dev, 33862306a36Sopenharmony_ci struct resource *base, unsigned long size); 33962306a36Sopenharmony_cistruct resource *request_free_mem_region(struct resource *base, 34062306a36Sopenharmony_ci unsigned long size, const char *name); 34162306a36Sopenharmony_cistruct resource *alloc_free_mem_region(struct resource *base, 34262306a36Sopenharmony_ci unsigned long size, unsigned long align, const char *name); 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_cistatic inline void irqresource_disabled(struct resource *res, u32 irq) 34562306a36Sopenharmony_ci{ 34662306a36Sopenharmony_ci res->start = irq; 34762306a36Sopenharmony_ci res->end = irq; 34862306a36Sopenharmony_ci res->flags |= IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET; 34962306a36Sopenharmony_ci} 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ciextern struct address_space *iomem_get_mapping(void); 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 35462306a36Sopenharmony_ci#endif /* _LINUX_IOPORT_H */ 355