@@ -721,3 +721,32 @@ void __iomem *of_iomap(struct device_node *np, int index)
return ioremap(res.start, resource_size(&res));
}
EXPORT_SYMBOL(of_iomap);
+
+/*
+ * of_io_request_and_map - Requests a resource and maps the memory mapped IO
+ * for a given device_node
+ * @device: the device whose io range will be mapped
+ * @index: index of the io range
+ * @name: name of the resource
+ *
+ * Returns a pointer to the requested and mapped memory
+ */
+void __iomem *of_io_request_and_map(struct device_node *np, int index,
+ char *name)
+{
+ struct resource res;
+ void __iomem *mem;
+
+ if (of_address_to_resource(np, index, &res))
+ return NULL;
+
+ if (!request_mem_region(res.start, resource_size(&res), name))
+ return NULL;
+
+ mem = ioremap(res.start, resource_size(&res));
+ if (!mem)
+ release_mem_region(res.start, resource_size(&res));
+
+ return mem;
+}
+EXPORT_SYMBOL(of_io_request_and_map);
@@ -96,6 +96,8 @@ static inline struct of_pci_range *of_pci_range_parser_one(
extern int of_address_to_resource(struct device_node *dev, int index,
struct resource *r);
void __iomem *of_iomap(struct device_node *node, int index);
+void __iomem *of_io_request_and_map(struct device_node *device,
+ int index, char *name);
#else
static inline int of_address_to_resource(struct device_node *dev, int index,
struct resource *r)
@@ -107,6 +109,12 @@ static inline void __iomem *of_iomap(struct device_node *device, int index)
{
return NULL;
}
+
+static inline void __iomem *of_io_request_and_map(struct device_node *device,
+ int index, char *name)
+{
+ return NULL;
+}
#endif
#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)