Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 31308
b: refs/heads/master
c: 8f96cd1
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller authored and David S. Miller committed Jun 29, 2006
1 parent d37cc4f commit d849c02
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2b1e59787198e75fb2ffb3bb4fb247da1c55ac12
refs/heads/master: 8f96cd1a69d4c43e3473406a1fdf15cd9f1de5e5
69 changes: 62 additions & 7 deletions trunk/arch/sparc/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ static int of_device_resume(struct device * dev)
return error;
}

static int node_match(struct device *dev, void *data)
{
struct of_device *op = to_of_device(dev);
struct device_node *dp = data;

return (op->node == dp);
}

struct of_device *of_find_device_by_node(struct device_node *dp)
{
struct device *dev = bus_find_device(&of_bus_type, NULL,
dp, node_match);

if (dev)
return to_of_device(dev);

return NULL;
}
EXPORT_SYMBOL(of_find_device_by_node);

#ifdef CONFIG_PCI
struct bus_type ebus_bus_type = {
.name = "ebus",
Expand Down Expand Up @@ -503,8 +523,8 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
struct device *parent)
{
struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL);
unsigned int *irq;
int len;
struct linux_prom_irqs *intr;
int len, i;

if (!op)
return NULL;
Expand All @@ -517,11 +537,46 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
if (op->portid == -1)
op->portid = of_getintprop_default(dp, "portid", -1);

irq = of_get_property(dp, "interrupts", &len);
if (irq)
op->irq = *irq;
else
op->irq = 0xffffffff;
intr = of_get_property(dp, "intr", &len);
if (intr) {
op->num_irqs = len / sizeof(struct linux_prom_irqs);
for (i = 0; i < op->num_irqs; i++)
op->irqs[i] = intr[i].pri;
} else {
unsigned int *irq = of_get_property(dp, "interrupts", &len);

if (irq) {
op->num_irqs = len / sizeof(unsigned int);
for (i = 0; i < op->num_irqs; i++)
op->irqs[i] = irq[i];
} else {
op->num_irqs = 0;
}
}
if (sparc_cpu_model == sun4d) {
static int pil_to_sbus[] = {
0, 0, 1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 0,
};
struct device_node *busp = dp->parent;
struct linux_prom_registers *regs;
int board = of_getintprop_default(busp, "board#", 0);
int slot;

regs = of_get_property(dp, "reg", NULL);
slot = regs->which_io;

for (i = 0; i < op->num_irqs; i++) {
int this_irq = op->irqs[i];
int sbusl = pil_to_sbus[this_irq];

if (sbusl)
this_irq = (((board + 1) << 5) +
(sbusl << 2) +
slot);

op->irqs[i] = this_irq;
}
}

build_device_resources(op, parent);

Expand Down
5 changes: 4 additions & 1 deletion trunk/include/asm-sparc/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ struct of_device
struct device_node *node;
struct device dev;
struct resource resource[PROMREG_MAX];
unsigned int irq;
unsigned int irqs[PROMINTR_MAX];
int num_irqs;

void *sysdata;

Expand All @@ -34,6 +35,8 @@ struct of_device
extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
extern void of_iounmap(void __iomem *base, unsigned long size);

extern struct of_device *of_find_device_by_node(struct device_node *);

extern const struct of_device_id *of_match_device(
const struct of_device_id *matches, const struct of_device *dev);

Expand Down

0 comments on commit d849c02

Please sign in to comment.