summaryrefslogtreecommitdiff
path: root/arch/sparc64/kernel/isa.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-06-23 06:12:03 +0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 10:15:28 +0400
commit690c8fd31f1e35985d0f35772fde514da59ec9d1 (patch)
tree8a5a0036b3780a9eb315ea2201a2562570de1ebe /arch/sparc64/kernel/isa.c
parentde8d28b16f5614aeb12bb69c8f9a38578b8d3ada (diff)
downloadlinux-690c8fd31f1e35985d0f35772fde514da59ec9d1.tar.xz
[SPARC64]: Use in-kernel PROM tree for EBUS and ISA.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/isa.c')
-rw-r--r--arch/sparc64/kernel/isa.c144
1 files changed, 57 insertions, 87 deletions
diff --git a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c
index ae02c3820eab..8c8c5a491ad6 100644
--- a/arch/sparc64/kernel/isa.c
+++ b/arch/sparc64/kernel/isa.c
@@ -15,23 +15,19 @@ static void __init fatal_err(const char *reason)
static void __init report_dev(struct sparc_isa_device *isa_dev, int child)
{
if (child)
- printk(" (%s)", isa_dev->prom_name);
+ printk(" (%s)", isa_dev->prom_node->name);
else
- printk(" [%s", isa_dev->prom_name);
+ printk(" [%s", isa_dev->prom_node->name);
}
-static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev,
- struct linux_prom_registers *pregs,
- int pregs_size)
+static struct linux_prom_registers * __init
+isa_dev_get_resource(struct sparc_isa_device *isa_dev)
{
+ struct linux_prom_registers *pregs;
unsigned long base, len;
int prop_len;
- prop_len = prom_getproperty(isa_dev->prom_node, "reg",
- (char *) pregs, pregs_size);
-
- if (prop_len <= 0)
- return;
+ pregs = of_get_property(isa_dev->prom_node, "reg", &prop_len);
/* Only the first one is interesting. */
len = pregs[0].reg_size;
@@ -42,10 +38,12 @@ static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev,
isa_dev->resource.start = base;
isa_dev->resource.end = (base + len - 1UL);
isa_dev->resource.flags = IORESOURCE_IO;
- isa_dev->resource.name = isa_dev->prom_name;
+ isa_dev->resource.name = isa_dev->prom_node->name;
request_resource(&isa_dev->bus->parent->io_space,
&isa_dev->resource);
+
+ return pregs;
}
/* I can't believe they didn't put a real INO in the isa device
@@ -98,8 +96,8 @@ static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev,
{
int irq_prop;
- irq_prop = prom_getintdefault(isa_dev->prom_node,
- "interrupts", -1);
+ irq_prop = of_getintprop_default(isa_dev->prom_node,
+ "interrupts", -1);
if (irq_prop <= 0) {
goto no_irq;
} else {
@@ -141,16 +139,15 @@ no_irq:
static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)
{
- int node = prom_getchild(parent_isa_dev->prom_node);
+ struct device_node *dp = parent_isa_dev->prom_node->child;
- if (node == 0)
+ if (!dp)
return;
printk(" ->");
- while (node != 0) {
- struct linux_prom_registers regs[PROMREG_MAX];
+ while (dp) {
+ struct linux_prom_registers *regs;
struct sparc_isa_device *isa_dev;
- int prop_len;
isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL);
if (!isa_dev) {
@@ -165,40 +162,24 @@ static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)
parent_isa_dev->child = isa_dev;
isa_dev->bus = parent_isa_dev->bus;
- isa_dev->prom_node = node;
- prop_len = prom_getproperty(node, "name",
- (char *) isa_dev->prom_name,
- sizeof(isa_dev->prom_name));
- if (prop_len <= 0) {
- fatal_err("cannot get child isa_dev OBP node name");
- prom_halt();
- }
-
- prop_len = prom_getproperty(node, "compatible",
- (char *) isa_dev->compatible,
- sizeof(isa_dev->compatible));
+ isa_dev->prom_node = dp;
- /* Not having this is OK. */
- if (prop_len <= 0)
- isa_dev->compatible[0] = '\0';
-
- isa_dev_get_resource(isa_dev, regs, sizeof(regs));
+ regs = isa_dev_get_resource(isa_dev);
isa_dev_get_irq(isa_dev, regs);
report_dev(isa_dev, 1);
- node = prom_getsibling(node);
+ dp = dp->sibling;
}
}
static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
{
- int node = prom_getchild(isa_br->prom_node);
+ struct device_node *dp = isa_br->prom_node->child;
- while (node != 0) {
- struct linux_prom_registers regs[PROMREG_MAX];
+ while (dp) {
+ struct linux_prom_registers *regs;
struct sparc_isa_device *isa_dev;
- int prop_len;
isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL);
if (!isa_dev) {
@@ -222,24 +203,9 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
}
isa_dev->bus = isa_br;
- isa_dev->prom_node = node;
- prop_len = prom_getproperty(node, "name",
- (char *) isa_dev->prom_name,
- sizeof(isa_dev->prom_name));
- if (prop_len <= 0) {
- fatal_err("cannot get isa_dev OBP node name");
- prom_halt();
- }
-
- prop_len = prom_getproperty(node, "compatible",
- (char *) isa_dev->compatible,
- sizeof(isa_dev->compatible));
-
- /* Not having this is OK. */
- if (prop_len <= 0)
- isa_dev->compatible[0] = '\0';
+ isa_dev->prom_node = dp;
- isa_dev_get_resource(isa_dev, regs, sizeof(regs));
+ regs = isa_dev_get_resource(isa_dev);
isa_dev_get_irq(isa_dev, regs);
report_dev(isa_dev, 0);
@@ -248,10 +214,40 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
printk("]");
- node = prom_getsibling(node);
+ dp = dp->sibling;
}
}
+static void __init get_bridge_props(struct sparc_isa_bridge *isa_br)
+{
+ struct device_node *dp = isa_br->prom_node;
+ void *pval;
+ int len;
+
+ pval = of_get_property(dp, "ranges", &len);
+ if (pval) {
+ memcpy(isa_br->isa_ranges, pval, len);
+ isa_br->num_isa_ranges =
+ len / sizeof(struct linux_prom_isa_ranges);
+ } else {
+ isa_br->num_isa_ranges = 0;
+ }
+
+ pval = of_get_property(dp, "interrupt-map", &len);
+ if (pval) {
+ memcpy(isa_br->isa_intmap, pval, len);
+ isa_br->num_isa_intmap =
+ (len / sizeof(struct linux_prom_isa_intmap));
+ } else {
+ isa_br->num_isa_intmap = 0;
+ }
+
+ pval = of_get_property(dp, "interrupt-map-mask", &len);
+ if (pval)
+ memcpy(&isa_br->isa_intmask, pval,
+ sizeof(isa_br->isa_intmask));
+}
+
void __init isa_init(void)
{
struct pci_dev *pdev;
@@ -266,7 +262,6 @@ void __init isa_init(void)
struct pcidev_cookie *pdev_cookie;
struct pci_pbm_info *pbm;
struct sparc_isa_bridge *isa_br;
- int prop_len;
pdev_cookie = pdev->sysdata;
if (!pdev_cookie) {
@@ -291,34 +286,9 @@ void __init isa_init(void)
isa_br->parent = pbm;
isa_br->self = pdev;
isa_br->index = index++;
- isa_br->prom_node = pdev_cookie->prom_node->node;
- strncpy(isa_br->prom_name, pdev_cookie->prom_node->name,
- sizeof(isa_br->prom_name));
-
- prop_len = prom_getproperty(isa_br->prom_node,
- "ranges",
- (char *) isa_br->isa_ranges,
- sizeof(isa_br->isa_ranges));
- if (prop_len <= 0)
- isa_br->num_isa_ranges = 0;
- else
- isa_br->num_isa_ranges =
- (prop_len / sizeof(struct linux_prom_isa_ranges));
-
- prop_len = prom_getproperty(isa_br->prom_node,
- "interrupt-map",
- (char *) isa_br->isa_intmap,
- sizeof(isa_br->isa_intmap));
- if (prop_len <= 0)
- isa_br->num_isa_intmap = 0;
- else
- isa_br->num_isa_intmap =
- (prop_len / sizeof(struct linux_prom_isa_intmap));
-
- prop_len = prom_getproperty(isa_br->prom_node,
- "interrupt-map-mask",
- (char *) &(isa_br->isa_intmask),
- sizeof(isa_br->isa_intmask));
+ isa_br->prom_node = pdev_cookie->prom_node;
+
+ get_bridge_props(isa_br);
printk("isa%d:", isa_br->index);