Skip to content

Commit

Permalink
powerpc: Consolidate mpic_alloc() OF address translation
Browse files Browse the repository at this point in the history
Instead of using the open-coded "reg" property lookup and address
translation in mpic_alloc(), directly call of_address_to_resource().
This includes various workarounds for special cases which the naive
of_address_translate() does not.

Afterwards it is possible to remove the copiously copy-pasted calls to
of_address_translate() from the 85xx/86xx/powermac platforms.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Kyle Moffett authored and Benjamin Herrenschmidt committed Dec 7, 2011
1 parent 582d3e0 commit 8bf4156
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 175 deletions.
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/corenet_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
void __init corenet_ds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;
unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
Expand All @@ -48,16 +47,10 @@ void __init corenet_ds_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

if (ppc_md.get_irq == mpic_get_coreint_irq)
flags |= MPIC_ENABLE_COREINT;

mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC ");
mpic = mpic_alloc(np, 0, flags, 0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);

mpic_init(mpic);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/ksi8560.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static void machine_restart(char *cmd)
static void __init ksi8560_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -68,13 +67,7 @@ static void __init ksi8560_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Could not map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/mpc8536_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
void __init mpc8536_ds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -46,13 +45,7 @@ void __init mpc8536_ds_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
0, 256, " OpenPIC ");
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/mpc85xx_ads.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
static void __init mpc85xx_ads_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;

np = of_find_node_by_type(np, "open-pic");
Expand All @@ -60,13 +59,7 @@ static void __init mpc85xx_ads_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Could not map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/mpc85xx_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
static void __init mpc85xx_cds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;

np = of_find_node_by_type(np, "open-pic");
Expand All @@ -198,13 +197,7 @@ static void __init mpc85xx_cds_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
11 changes: 2 additions & 9 deletions arch/powerpc/platforms/85xx/mpc85xx_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
void __init mpc85xx_ds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;
#ifdef CONFIG_PPC_I8259
struct device_node *cascade_node = NULL;
Expand All @@ -77,20 +76,14 @@ void __init mpc85xx_ds_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
MPIC_SINGLE_DEST_CPU,
0, 256, " OpenPIC ");
} else {
mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
MPIC_SINGLE_DEST_CPU,
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/mpc85xx_mds.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,20 +435,13 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
static void __init mpc85xx_mds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;

np = of_find_node_by_type(NULL, "open-pic");
if (!np)
return;

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
0, 256, " OpenPIC ");
Expand Down
11 changes: 2 additions & 9 deletions arch/powerpc/platforms/85xx/mpc85xx_rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
void __init mpc85xx_rdb_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;
unsigned long root = of_get_flat_dt_root();

Expand All @@ -55,20 +54,14 @@ void __init mpc85xx_rdb_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
MPIC_SINGLE_DEST_CPU,
0, 256, " OpenPIC ");
} else {
mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
MPIC_SINGLE_DEST_CPU,
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/p1010rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
void __init p1010_rdb_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -42,13 +41,7 @@ void __init p1010_rdb_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start, MPIC_PRIMARY | MPIC_WANTS_RESET |
mpic = mpic_alloc(np, 0, MPIC_PRIMARY | MPIC_WANTS_RESET |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
0, 256, " OpenPIC ");

Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/p1022_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ p1022ds_valid_monitor_port(enum fsl_diu_monitor_port port)
void __init p1022_ds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -251,13 +250,7 @@ void __init p1022_ds_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
pr_err("Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET |
MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
MPIC_SINGLE_DEST_CPU,
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/p1023_rds.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices);
static void __init mpc85xx_rds_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -103,13 +102,7 @@ static void __init mpc85xx_rds_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
0, 256, " OpenPIC ");
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/sbc8548.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static int sbc_rev;
static void __init sbc8548_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;

np = of_find_node_by_type(np, "open-pic");
Expand All @@ -65,13 +64,7 @@ static void __init sbc8548_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Failed to map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/sbc8560.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
static void __init sbc8560_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np = NULL;

np = of_find_node_by_type(np, "open-pic");
Expand All @@ -51,13 +50,7 @@ static void __init sbc8560_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Could not map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/socrates.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
static void __init socrates_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -56,13 +55,7 @@ static void __init socrates_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Could not map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/stx_gp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
static void __init stx_gp3_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -58,13 +57,7 @@ static void __init stx_gp3_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Could not map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
9 changes: 1 addition & 8 deletions arch/powerpc/platforms/85xx/tqm85xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
static void __init tqm85xx_pic_init(void)
{
struct mpic *mpic;
struct resource r;
struct device_node *np;

np = of_find_node_by_type(NULL, "open-pic");
Expand All @@ -56,13 +55,7 @@ static void __init tqm85xx_pic_init(void)
return;
}

if (of_address_to_resource(np, 0, &r)) {
printk(KERN_ERR "Could not map mpic register space\n");
of_node_put(np);
return;
}

mpic = mpic_alloc(np, r.start,
mpic = mpic_alloc(np, 0,
MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
Expand Down
Loading

0 comments on commit 8bf4156

Please sign in to comment.