[PATCH 14/19] include: linux/device.h: implement dev_platform_ioremap_resource
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Jan 19 08:26:05 PST 2024
There are more than a thousand instances of devm_platform_ioremap_resource
across Linux drivers and porting it to barebox is cumbersome, because
unlike Linux we don't remap, so the MMIO region may be at address zero.
Now that dev_request_mem_region_err_null() prints a warning in that
case, let's just use it to implement dev_platform_ioremap_resource().
Platforms with relevant MMIO at address 0 are scarce anyway and when we
run on such a platform, we can always switch to use normal
dev_request_mem_resource().
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/device.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index 0bd61154ac30..d892a9cb0ef5 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -32,6 +32,18 @@
#define driver_register register_driver
#define driver_unregister unregister_driver
+
+static inline void __iomem *dev_platform_ioremap_resource(struct device *dev,
+ int resource)
+{
+ /*
+ * barebox maps everything outside the RAM banks suitably for MMIO,
+ * so we don't need to do anything besides requesting the regions
+ * and can leave the memory attributes unchanged.
+ */
+ return dev_request_mem_region_err_null(dev, resource);
+}
+
static inline void __iomem *devm_ioremap(struct device *dev,
resource_size_t start,
resource_size_t size)
--
2.39.2
More information about the barebox
mailing list