Skip to content

Commit

Permalink
sparc/of: Move of_device fields into struct pdev_archdata
Browse files Browse the repository at this point in the history
This patch moves SPARC architecture specific data members out of
struct of_device and into the pdev_archdata structure.  The reason
for this change is to unify the struct of_device definition amongst
all the architectures.  It also remvoes the .sysdata, .slot, .portid
and .clock_freq properties because they aren't actually used by
anything.

A subsequent patch will replace struct of_device entirely with struct
platform_device and the of_platform support code will share common
routines with the platform bus (but the bus instances themselves can
remain separate).

This patch also adds 'struct resources *resource' and num_resources
to match the fields defined in struct platform_device.  After this
change, 'struct platform_device' can be used as a drop-in replacement
for 'struct of_platform'.

This change is in preparation for merging the of_platform_bus_type
with the platform_bus_type.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
  • Loading branch information
glikely committed Jun 28, 2010
1 parent 2b07be2 commit 1636f8a
Show file tree
Hide file tree
Showing 33 changed files with 100 additions and 108 deletions.
5 changes: 5 additions & 0 deletions arch/sparc/include/asm/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef _ASM_SPARC_DEVICE_H
#define _ASM_SPARC_DEVICE_H

#include <asm/openprom.h>

struct device_node;
struct of_device;

Expand All @@ -18,6 +20,9 @@ struct dev_archdata {
};

struct pdev_archdata {
struct resource resource[PROMREG_MAX];
unsigned int irqs[PROMINTR_MAX];
int num_irqs;
};

#endif /* _ASM_SPARC_DEVICE_H */
4 changes: 2 additions & 2 deletions arch/sparc/include/asm/floppy_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static unsigned long __init sun_floppy_init(void)
}
if (op) {
floppy_op = op;
FLOPPY_IRQ = op->irqs[0];
FLOPPY_IRQ = op->archdata.irqs[0];
} else {
struct device_node *ebus_dp;
void __iomem *auxio_reg;
Expand All @@ -593,7 +593,7 @@ static unsigned long __init sun_floppy_init(void)
if (state_prop && !strncmp(state_prop, "disabled", 8))
return 0;

FLOPPY_IRQ = op->irqs[0];
FLOPPY_IRQ = op->archdata.irqs[0];

/* Make sure the high density bit is set, some systems
* (most notably Ultra5/Ultra10) come up with it clear.
Expand Down
11 changes: 3 additions & 8 deletions arch/sparc/include/asm/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@
struct of_device
{
struct device dev;
struct resource resource[PROMREG_MAX];
unsigned int irqs[PROMINTR_MAX];
int num_irqs;
u32 num_resources;
struct resource *resource;

void *sysdata;

int slot;
int portid;
int clock_freq;
struct pdev_archdata archdata;
};

extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/include/asm/parport.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id
parent = op->dev.of_node->parent;
if (!strcmp(parent->name, "dma")) {
p = parport_pc_probe_port(base, base + 0x400,
op->irqs[0], PARPORT_DMA_NOFIFO,
op->archdata.irqs[0], PARPORT_DMA_NOFIFO,
op->dev.parent->parent, 0);
if (!p)
return -ENOMEM;
Expand Down Expand Up @@ -166,7 +166,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id
0, PTR_LPT_REG_DIR);

p = parport_pc_probe_port(base, base + 0x400,
op->irqs[0],
op->archdata.irqs[0],
slot,
op->dev.parent,
0);
Expand Down
28 changes: 12 additions & 16 deletions arch/sparc/kernel/of_device_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ static void __init build_device_resources(struct of_device *op,
/* Conver to num-entries. */
num_reg /= na + ns;

op->resource = op->archdata.resource;
op->num_resources = num_reg;
for (index = 0; index < num_reg; index++) {
struct resource *r = &op->resource[index];
u32 addr[OF_MAX_ADDR_CELLS];
Expand Down Expand Up @@ -349,27 +351,21 @@ static struct of_device * __init scan_one_device(struct device_node *dp,

op->dev.of_node = dp;

op->clock_freq = of_getintprop_default(dp, "clock-frequency",
(25*1000*1000));
op->portid = of_getintprop_default(dp, "upa-portid", -1);
if (op->portid == -1)
op->portid = of_getintprop_default(dp, "portid", -1);

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;
op->archdata.num_irqs = len / sizeof(struct linux_prom_irqs);
for (i = 0; i < op->archdata.num_irqs; i++)
op->archdata.irqs[i] = intr[i].pri;
} else {
const 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];
op->archdata.num_irqs = len / sizeof(unsigned int);
for (i = 0; i < op->archdata.num_irqs; i++)
op->archdata.irqs[i] = irq[i];
} else {
op->num_irqs = 0;
op->archdata.num_irqs = 0;
}
}
if (sparc_cpu_model == sun4d) {
Expand Down Expand Up @@ -411,16 +407,16 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
goto build_resources;
}

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

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

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

Expand Down
24 changes: 10 additions & 14 deletions arch/sparc/kernel/of_device_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ static void __init build_device_resources(struct of_device *op,
num_reg = PROMREG_MAX;
}

op->resource = op->archdata.resource;
op->num_resources = num_reg;
for (index = 0; index < num_reg; index++) {
struct resource *r = &op->resource[index];
u32 addr[OF_MAX_ADDR_CELLS];
Expand Down Expand Up @@ -644,31 +646,25 @@ static struct of_device * __init scan_one_device(struct device_node *dp,

op->dev.of_node = dp;

op->clock_freq = of_getintprop_default(dp, "clock-frequency",
(25*1000*1000));
op->portid = of_getintprop_default(dp, "upa-portid", -1);
if (op->portid == -1)
op->portid = of_getintprop_default(dp, "portid", -1);

irq = of_get_property(dp, "interrupts", &len);
if (irq) {
op->num_irqs = len / 4;
op->archdata.num_irqs = len / 4;

/* Prevent overrunning the op->irqs[] array. */
if (op->num_irqs > PROMINTR_MAX) {
if (op->archdata.num_irqs > PROMINTR_MAX) {
printk(KERN_WARNING "%s: Too many irqs (%d), "
"limiting to %d.\n",
dp->full_name, op->num_irqs, PROMINTR_MAX);
op->num_irqs = PROMINTR_MAX;
dp->full_name, op->archdata.num_irqs, PROMINTR_MAX);
op->archdata.num_irqs = PROMINTR_MAX;
}
memcpy(op->irqs, irq, op->num_irqs * 4);
memcpy(op->archdata.irqs, irq, op->archdata.num_irqs * 4);
} else {
op->num_irqs = 0;
op->archdata.num_irqs = 0;
}

build_device_resources(op, parent);
for (i = 0; i < op->num_irqs; i++)
op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]);
for (i = 0; i < op->archdata.num_irqs; i++)
op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]);

op->dev.parent = parent;
op->dev.bus = &of_platform_bus_type;
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/kernel/of_device_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ unsigned int irq_of_parse_and_map(struct device_node *node, int index)
{
struct of_device *op = of_find_device_by_node(node);

if (!op || index >= op->num_irqs)
if (!op || index >= op->archdata.num_irqs)
return 0;

return op->irqs[index];
return op->archdata.irqs[index];
}
EXPORT_SYMBOL(irq_of_parse_and_map);

Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/kernel/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
dev->rom_base_reg = PCI_ROM_ADDRESS;

dev->irq = sd->op->irqs[0];
dev->irq = sd->op->archdata.irqs[0];
if (dev->irq == 0xffffffff)
dev->irq = PCI_IRQ_NONE;
}
Expand Down
8 changes: 4 additions & 4 deletions arch/sparc/kernel/pci_psycho.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,23 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
* 5: POWER MANAGEMENT
*/

if (op->num_irqs < 6)
if (op->archdata.num_irqs < 6)
return;

/* We really mean to ignore the return result here. Two
* PCI controller share the same interrupt numbers and
* drive the same front-end hardware.
*/
err = request_irq(op->irqs[1], psycho_ue_intr, IRQF_SHARED,
err = request_irq(op->archdata.irqs[1], psycho_ue_intr, IRQF_SHARED,
"PSYCHO_UE", pbm);
err = request_irq(op->irqs[2], psycho_ce_intr, IRQF_SHARED,
err = request_irq(op->archdata.irqs[2], psycho_ce_intr, IRQF_SHARED,
"PSYCHO_CE", pbm);

/* This one, however, ought not to fail. We can just warn
* about it since the system can still operate properly even
* if this fails.
*/
err = request_irq(op->irqs[0], psycho_pcierr_intr, IRQF_SHARED,
err = request_irq(op->archdata.irqs[0], psycho_pcierr_intr, IRQF_SHARED,
"PSYCHO_PCIERR", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register PCIERR, "
Expand Down
8 changes: 4 additions & 4 deletions arch/sparc/kernel/pci_sabre.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
* 2: CE ERR
* 3: POWER FAIL
*/
if (op->num_irqs < 4)
if (op->archdata.num_irqs < 4)
return;

/* We clear the error bits in the appropriate AFSR before
Expand All @@ -341,7 +341,7 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE),
base + SABRE_UE_AFSR);

err = request_irq(op->irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm);
err = request_irq(op->archdata.irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm);
if (err)
printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n",
pbm->name, err);
Expand All @@ -351,11 +351,11 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
base + SABRE_CE_AFSR);


err = request_irq(op->irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm);
err = request_irq(op->archdata.irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm);
if (err)
printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n",
pbm->name, err);
err = request_irq(op->irqs[0], psycho_pcierr_intr, 0,
err = request_irq(op->archdata.irqs[0], psycho_pcierr_intr, 0,
"SABRE_PCIERR", pbm);
if (err)
printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n",
Expand Down
20 changes: 10 additions & 10 deletions arch/sparc/kernel/pci_schizo.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,33 +857,33 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
*/

if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) {
err = request_irq(op->irqs[1], schizo_ue_intr, 0,
err = request_irq(op->archdata.irqs[1], schizo_ue_intr, 0,
"TOMATILLO_UE", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register UE, "
"err=%d\n", pbm->name, err);
}
if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) {
err = request_irq(op->irqs[2], schizo_ce_intr, 0,
err = request_irq(op->archdata.irqs[2], schizo_ce_intr, 0,
"TOMATILLO_CE", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register CE, "
"err=%d\n", pbm->name, err);
}
err = 0;
if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) {
err = request_irq(op->irqs[0], schizo_pcierr_intr, 0,
err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
"TOMATILLO_PCIERR", pbm);
} else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) {
err = request_irq(op->irqs[0], schizo_pcierr_intr, 0,
err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
"TOMATILLO_PCIERR", pbm);
}
if (err)
printk(KERN_WARNING "%s: Could not register PCIERR, "
"err=%d\n", pbm->name, err);

if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) {
err = request_irq(op->irqs[3], schizo_safarierr_intr, 0,
err = request_irq(op->archdata.irqs[3], schizo_safarierr_intr, 0,
"TOMATILLO_SERR", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register SERR, "
Expand Down Expand Up @@ -952,33 +952,33 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
*/

if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) {
err = request_irq(op->irqs[1], schizo_ue_intr, 0,
err = request_irq(op->archdata.irqs[1], schizo_ue_intr, 0,
"SCHIZO_UE", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register UE, "
"err=%d\n", pbm->name, err);
}
if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) {
err = request_irq(op->irqs[2], schizo_ce_intr, 0,
err = request_irq(op->archdata.irqs[2], schizo_ce_intr, 0,
"SCHIZO_CE", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register CE, "
"err=%d\n", pbm->name, err);
}
err = 0;
if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) {
err = request_irq(op->irqs[0], schizo_pcierr_intr, 0,
err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
"SCHIZO_PCIERR", pbm);
} else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) {
err = request_irq(op->irqs[0], schizo_pcierr_intr, 0,
err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
"SCHIZO_PCIERR", pbm);
}
if (err)
printk(KERN_WARNING "%s: Could not register PCIERR, "
"err=%d\n", pbm->name, err);

if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) {
err = request_irq(op->irqs[3], schizo_safarierr_intr, 0,
err = request_irq(op->archdata.irqs[3], schizo_safarierr_intr, 0,
"SCHIZO_SERR", pbm);
if (err)
printk(KERN_WARNING "%s: Could not register SERR, "
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/kernel/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int __devinit has_button_interrupt(unsigned int irq, struct device_node *
static int __devinit power_probe(struct of_device *op, const struct of_device_id *match)
{
struct resource *res = &op->resource[0];
unsigned int irq= op->irqs[0];
unsigned int irq = op->archdata.irqs[0];

power_reg = of_ioremap(res, 0, 0x4, "power");

Expand Down
2 changes: 1 addition & 1 deletion drivers/atm/fore200e.c
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,7 @@ static int __devinit fore200e_sba_probe(struct of_device *op,

fore200e->bus = bus;
fore200e->bus_dev = op;
fore200e->irq = op->irqs[0];
fore200e->irq = op->archdata.irqs[0];
fore200e->phys_base = op->resource[0].start;

sprintf(fore200e->name, "%s-%d", bus->model_name, index);
Expand Down
8 changes: 4 additions & 4 deletions drivers/input/serio/i8042-sparcio.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_dev
if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
!strcmp(dp->name, OBP_PS2KBD_NAME2)) {
struct of_device *kbd = of_find_device_by_node(dp);
unsigned int irq = kbd->irqs[0];
unsigned int irq = kbd->archdata.irqs[0];
if (irq == 0xffffffff)
irq = op->irqs[0];
irq = op->archdata.irqs[0];
i8042_kbd_irq = irq;
kbd_iobase = of_ioremap(&kbd->resource[0],
0, 8, "kbd");
kbd_res = &kbd->resource[0];
} else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
!strcmp(dp->name, OBP_PS2MS_NAME2)) {
struct of_device *ms = of_find_device_by_node(dp);
unsigned int irq = ms->irqs[0];
unsigned int irq = ms->archdata.irqs[0];
if (irq == 0xffffffff)
irq = op->irqs[0];
irq = op->archdata.irqs[0];
i8042_aux_irq = irq;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/myri_sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic

mp->dev = dev;
dev->watchdog_timeo = 5*HZ;
dev->irq = op->irqs[0];
dev->irq = op->archdata.irqs[0];
dev->netdev_ops = &myri_ops;

/* Register interrupt handler now. */
Expand Down
Loading

0 comments on commit 1636f8a

Please sign in to comment.