aboutsummaryrefslogtreecommitdiff
path: root/arch/sparc/kernel/of_device_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/of_device_common.c')
-rw-r--r--arch/sparc/kernel/of_device_common.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c
index cb8eb799bb6..de0ee3971f0 100644
--- a/arch/sparc/kernel/of_device_common.c
+++ b/arch/sparc/kernel/of_device_common.c
@@ -1,59 +1,66 @@
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/of.h>
-#include <linux/init.h>
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/mod_devicetable.h>
-#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/irq.h>
-#include <linux/of_device.h>
#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
#include "of_device_common.h"
-static int node_match(struct device *dev, void *data)
+unsigned int irq_of_parse_and_map(struct device_node *node, int index)
{
- struct of_device *op = to_of_device(dev);
- struct device_node *dp = data;
+ struct platform_device *op = of_find_device_by_node(node);
- return (op->node == dp);
+ if (!op || index >= op->archdata.num_irqs)
+ return 0;
+
+ return op->archdata.irqs[index];
}
+EXPORT_SYMBOL(irq_of_parse_and_map);
-struct of_device *of_find_device_by_node(struct device_node *dp)
+int of_address_to_resource(struct device_node *node, int index,
+ struct resource *r)
{
- struct device *dev = bus_find_device(&of_platform_bus_type, NULL,
- dp, node_match);
+ struct platform_device *op = of_find_device_by_node(node);
- if (dev)
- return to_of_device(dev);
+ if (!op || index >= op->num_resources)
+ return -EINVAL;
- return NULL;
+ memcpy(r, &op->archdata.resource[index], sizeof(*r));
+ return 0;
}
-EXPORT_SYMBOL(of_find_device_by_node);
+EXPORT_SYMBOL_GPL(of_address_to_resource);
-unsigned int irq_of_parse_and_map(struct device_node *node, int index)
+void __iomem *of_iomap(struct device_node *node, int index)
{
- struct of_device *op = of_find_device_by_node(node);
+ struct platform_device *op = of_find_device_by_node(node);
+ struct resource *r;
- if (!op || index >= op->num_irqs)
- return 0;
+ if (!op || index >= op->num_resources)
+ return NULL;
- return op->irqs[index];
+ r = &op->archdata.resource[index];
+
+ return of_ioremap(r, 0, resource_size(r), (char *) r->name);
}
-EXPORT_SYMBOL(irq_of_parse_and_map);
+EXPORT_SYMBOL(of_iomap);
/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
- * BUS and propagate to all child of_device objects.
+ * BUS and propagate to all child platform_device objects.
*/
-void of_propagate_archdata(struct of_device *bus)
+void of_propagate_archdata(struct platform_device *bus)
{
struct dev_archdata *bus_sd = &bus->dev.archdata;
- struct device_node *bus_dp = bus->node;
+ struct device_node *bus_dp = bus->dev.of_node;
struct device_node *dp;
for (dp = bus_dp->child; dp; dp = dp->sibling) {
- struct of_device *op = of_find_device_by_node(dp);
+ struct platform_device *op = of_find_device_by_node(dp);
op->dev.archdata.iommu = bus_sd->iommu;
op->dev.archdata.stc = bus_sd->stc;
@@ -65,9 +72,6 @@ void of_propagate_archdata(struct of_device *bus)
}
}
-struct bus_type of_platform_bus_type;
-EXPORT_SYMBOL(of_platform_bus_type);
-
static void get_cells(struct device_node *dp, int *addrc, int *sizec)
{
if (addrc)