Skip to content

Commit

Permalink
[POWERPC] Add an optional device_node pointer to the irq_host
Browse files Browse the repository at this point in the history
The majority of irq_host implementations (3 out of 4) are associated
with a device_node, and need to stash it somewhere. Rather than having
it somewhere different for each host, add an optional device_node pointer
to the irq_host structure.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Michael Ellerman authored and Paul Mackerras committed Sep 13, 2007
1 parent 0ae0b54 commit 52964f8
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 109 deletions.
10 changes: 6 additions & 4 deletions arch/powerpc/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,11 @@ irq_hw_number_t virq_to_hw(unsigned int virq)
}
EXPORT_SYMBOL_GPL(virq_to_hw);

__init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
unsigned int revmap_arg,
struct irq_host_ops *ops,
irq_hw_number_t inval_irq)
__init_refok struct irq_host *irq_alloc_host(struct device_node *of_node,
unsigned int revmap_type,
unsigned int revmap_arg,
struct irq_host_ops *ops,
irq_hw_number_t inval_irq)
{
struct irq_host *host;
unsigned int size = sizeof(struct irq_host);
Expand All @@ -446,6 +447,7 @@ __init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
host->revmap_type = revmap_type;
host->inval_irq = inval_irq;
host->ops = ops;
host->of_node = of_node;

spin_lock_irqsave(&irq_big_lock, flags);

Expand Down
5 changes: 2 additions & 3 deletions arch/powerpc/platforms/52xx/mpc52xx_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static struct irq_chip mpc52xx_sdma_irqchip = {
static int mpc52xx_irqhost_match(struct irq_host *h, struct device_node *node)
{
pr_debug("%s: node=%p\n", __func__, node);
return mpc52xx_irqhost->host_data == node;
return h->of_node == node;
}

static int mpc52xx_irqhost_xlate(struct irq_host *h, struct device_node *ct,
Expand Down Expand Up @@ -419,14 +419,13 @@ void __init mpc52xx_init_irq(void)
* hw irq information provided by the ofw to linux virq
*/

mpc52xx_irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR,
mpc52xx_irqhost = irq_alloc_host(picnode, IRQ_HOST_MAP_LINEAR,
MPC52xx_IRQ_HIGHTESTHWIRQ,
&mpc52xx_irqhost_ops, -1);

if (!mpc52xx_irqhost)
panic(__FILE__ ": Cannot allocate the IRQ host\n");

mpc52xx_irqhost->host_data = picnode;
printk(KERN_INFO "MPC52xx PIC is up and running!\n");
}

Expand Down
7 changes: 2 additions & 5 deletions arch/powerpc/platforms/82xx/mpc82xx_ads.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ static struct {

static unsigned long pci_int_base;
static struct irq_host *pci_pic_host;
static struct device_node *pci_pic_node;
#endif

static void __init mpc82xx_ads_pic_init(void)
Expand Down Expand Up @@ -401,7 +400,7 @@ m82xx_pci_irq_demux(unsigned int irq, struct irq_desc *desc)

static int pci_pic_host_match(struct irq_host *h, struct device_node *node)
{
return node == pci_pic_node;
return h->of_node == node;
}

static int pci_pic_host_map(struct irq_host *h, unsigned int virq,
Expand Down Expand Up @@ -478,7 +477,6 @@ void m82xx_pci_init_irq(void)
iounmap(immap);
return;
}
pci_pic_node = of_node_get(np);
/* PCI interrupt controller registers: status and mask */
regs = of_get_property(np, "reg", &size);
if ((!regs) || (size <= 2)) {
Expand All @@ -490,7 +488,6 @@ void m82xx_pci_init_irq(void)
ioremap(regs[0], sizeof(*pci_regs.pci_int_stat_reg));
pci_regs.pci_int_mask_reg =
ioremap(regs[1], sizeof(*pci_regs.pci_int_mask_reg));
of_node_put(np);
/* configure chip select for PCI interrupt controller */
immap->im_memctl.memc_br3 = regs[0] | 0x00001801;
immap->im_memctl.memc_or3 = 0xffff8010;
Expand All @@ -501,7 +498,7 @@ void m82xx_pci_init_irq(void)
*pci_regs.pci_int_mask_reg |= 0xfff00000;
iounmap(immap);
pci_pic_host =
irq_alloc_host(IRQ_HOST_MAP_LINEAR, irq_max - irq_min + 1,
irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, irq_max - irq_min + 1,
&pci_pic_host_ops, irq_max + 1);
return;
}
Expand Down
14 changes: 5 additions & 9 deletions arch/powerpc/platforms/cell/axon_msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@


struct axon_msic {
struct device_node *dn;
struct irq_host *irq_host;
__le32 *fifo;
dcr_host_t dcr_host;
Expand Down Expand Up @@ -297,9 +296,7 @@ static int msic_host_map(struct irq_host *h, unsigned int virq,

static int msic_host_match(struct irq_host *host, struct device_node *dn)
{
struct axon_msic *msic = host->host_data;

return msic->dn == dn;
return host->of_node == dn;
}

static struct irq_host_ops msic_host_ops = {
Expand All @@ -314,7 +311,8 @@ static int axon_msi_notify_reboot(struct notifier_block *nb,
u32 tmp;

list_for_each_entry(msic, &axon_msic_list, list) {
pr_debug("axon_msi: disabling %s\n", msic->dn->full_name);
pr_debug("axon_msi: disabling %s\n",
msic->irq_host->of_node->full_name);
tmp = msic_dcr_read(msic, MSIC_CTRL_REG);
tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE;
msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
Expand Down Expand Up @@ -370,8 +368,8 @@ static int axon_msi_setup_one(struct device_node *dn)

msic->fifo = page_address(page);

msic->irq_host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, NR_IRQS,
&msic_host_ops, 0);
msic->irq_host = irq_alloc_host(of_node_get(dn), IRQ_HOST_MAP_NOMAP,
NR_IRQS, &msic_host_ops, 0);
if (!msic->irq_host) {
printk(KERN_ERR "axon_msi: couldn't allocate irq_host for %s\n",
dn->full_name);
Expand All @@ -387,8 +385,6 @@ static int axon_msi_setup_one(struct device_node *dn)
goto out_free_host;
}

msic->dn = of_node_get(dn);

set_irq_data(virq, msic);
set_irq_chained_handler(virq, axon_msi_cascade);
pr_debug("axon_msi: irq 0x%x setup for axon_msi\n", virq);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static int __init setup_iic(void)
void __init iic_init_IRQ(void)
{
/* Setup an irq host data structure */
iic_host = irq_alloc_host(IRQ_HOST_MAP_LINEAR, IIC_SOURCE_COUNT,
iic_host = irq_alloc_host(NULL, IRQ_HOST_MAP_LINEAR, IIC_SOURCE_COUNT,
&iic_host_ops, IIC_IRQ_INVALID);
BUG_ON(iic_host == NULL);
irq_set_default_host(iic_host);
Expand Down
18 changes: 7 additions & 11 deletions arch/powerpc/platforms/cell/spider-pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ enum {

struct spider_pic {
struct irq_host *host;
struct device_node *of_node;
void __iomem *regs;
unsigned int node_id;
};
Expand Down Expand Up @@ -178,8 +177,7 @@ static struct irq_chip spider_pic = {

static int spider_host_match(struct irq_host *h, struct device_node *node)
{
struct spider_pic *pic = h->host_data;
return node == pic->of_node;
return h->of_node == node;
}

static int spider_host_map(struct irq_host *h, unsigned int virq,
Expand Down Expand Up @@ -247,18 +245,18 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
* tree in case the device-tree is ever fixed
*/
struct of_irq oirq;
if (of_irq_map_one(pic->of_node, 0, &oirq) == 0) {
if (of_irq_map_one(pic->host->of_node, 0, &oirq) == 0) {
virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
oirq.size);
return virq;
}

/* Now do the horrible hacks */
tmp = of_get_property(pic->of_node, "#interrupt-cells", NULL);
tmp = of_get_property(pic->host->of_node, "#interrupt-cells", NULL);
if (tmp == NULL)
return NO_IRQ;
intsize = *tmp;
imap = of_get_property(pic->of_node, "interrupt-map", &imaplen);
imap = of_get_property(pic->host->of_node, "interrupt-map", &imaplen);
if (imap == NULL || imaplen < (intsize + 1))
return NO_IRQ;
iic = of_find_node_by_phandle(imap[intsize]);
Expand Down Expand Up @@ -308,15 +306,13 @@ static void __init spider_init_one(struct device_node *of_node, int chip,
panic("spider_pic: can't map registers !");

/* Allocate a host */
pic->host = irq_alloc_host(IRQ_HOST_MAP_LINEAR, SPIDER_SRC_COUNT,
&spider_host_ops, SPIDER_IRQ_INVALID);
pic->host = irq_alloc_host(of_node_get(of_node), IRQ_HOST_MAP_LINEAR,
SPIDER_SRC_COUNT, &spider_host_ops,
SPIDER_IRQ_INVALID);
if (pic->host == NULL)
panic("spider_pic: can't allocate irq host !");
pic->host->host_data = pic;

/* Fill out other bits */
pic->of_node = of_node_get(of_node);

/* Go through all sources and disable them */
for (i = 0; i < SPIDER_SRC_COUNT; i++) {
void __iomem *cfg = pic->regs + TIR_CFGA + 8 * i;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/celleb/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void __init beatic_init_IRQ(void)
ppc_md.get_irq = beatic_get_irq;

/* Allocate an irq host */
beatic_host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, 0,
beatic_host = irq_alloc_host(NULL, IRQ_HOST_MAP_NOMAP, 0,
&beatic_pic_host_ops,
0);
BUG_ON(beatic_host == NULL);
Expand Down
3 changes: 2 additions & 1 deletion arch/powerpc/platforms/iseries/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ void __init iSeries_init_IRQ(void)
/* Create irq host. No need for a revmap since HV will give us
* back our virtual irq number
*/
host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, 0, &iseries_irq_host_ops, 0);
host = irq_alloc_host(NULL, IRQ_HOST_MAP_NOMAP, 0,
&iseries_irq_host_ops, 0);
BUG_ON(host == NULL);
irq_set_default_host(host);

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powermac/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static void __init pmac_pic_probe_oldstyle(void)
/*
* Allocate an irq host
*/
pmac_pic_host = irq_alloc_host(IRQ_HOST_MAP_LINEAR, max_irqs,
pmac_pic_host = irq_alloc_host(master, IRQ_HOST_MAP_LINEAR, max_irqs,
&pmac_pic_host_ops,
max_irqs);
BUG_ON(pmac_pic_host == NULL);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/ps3/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ void __init ps3_init_IRQ(void)
unsigned cpu;
struct irq_host *host;

host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, 0, &ps3_host_ops,
host = irq_alloc_host(NULL, IRQ_HOST_MAP_NOMAP, 0, &ps3_host_ops,
PS3_INVALID_OUTLET);
irq_set_default_host(host);
irq_set_virq_count(PS3_PLUG_MAX + 1);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/xics.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ static void __init xics_init_host(void)
ops = &xics_host_lpar_ops;
else
ops = &xics_host_direct_ops;
xics_host = irq_alloc_host(IRQ_HOST_MAP_TREE, 0, ops,
xics_host = irq_alloc_host(NULL, IRQ_HOST_MAP_TREE, 0, ops,
XICS_IRQ_SPURIOUS);
BUG_ON(xics_host == NULL);
irq_set_default_host(xics_host);
Expand Down
8 changes: 3 additions & 5 deletions arch/powerpc/sysdev/commproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static uint host_end; /* end + 1 */
cpm8xx_t *cpmp; /* Pointer to comm processor space */
cpic8xx_t *cpic_reg;

static struct device_node *cpm_pic_node;
static struct irq_host *cpm_pic_host;

static void cpm_mask_irq(unsigned int irq)
Expand Down Expand Up @@ -97,7 +96,7 @@ int cpm_get_irq(void)

static int cpm_pic_host_match(struct irq_host *h, struct device_node *node)
{
return cpm_pic_node == node;
return h->of_node == node;
}

static int cpm_pic_host_map(struct irq_host *h, unsigned int virq,
Expand Down Expand Up @@ -165,9 +164,8 @@ unsigned int cpm_pic_init(void)

out_be32(&cpic_reg->cpic_cimr, 0);

cpm_pic_node = of_node_get(np);

cpm_pic_host = irq_alloc_host(IRQ_HOST_MAP_LINEAR, 64, &cpm_pic_host_ops, 64);
cpm_pic_host = irq_alloc_host(of_node_get(np), IRQ_HOST_MAP_LINEAR,
64, &cpm_pic_host_ops, 64);
if (cpm_pic_host == NULL) {
printk(KERN_ERR "CPM2 PIC: failed to allocate irq host!\n");
sirq = NO_IRQ;
Expand Down
7 changes: 3 additions & 4 deletions arch/powerpc/sysdev/cpm2_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

static intctl_cpm2_t *cpm2_intctl;

static struct device_node *cpm2_pic_node;
static struct irq_host *cpm2_pic_host;
#define NR_MASK_WORDS ((NR_IRQS + 31) / 32)
static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
Expand Down Expand Up @@ -208,7 +207,7 @@ unsigned int cpm2_get_irq(void)

static int cpm2_pic_host_match(struct irq_host *h, struct device_node *node)
{
return cpm2_pic_node == node;
return h->of_node == node;
}

static int cpm2_pic_host_map(struct irq_host *h, unsigned int virq,
Expand Down Expand Up @@ -273,8 +272,8 @@ void cpm2_pic_init(struct device_node *node)
out_be32(&cpm2_intctl->ic_scprrl, 0x05309770);

/* create a legacy host */
cpm2_pic_node = of_node_get(node);
cpm2_pic_host = irq_alloc_host(IRQ_HOST_MAP_LINEAR, 64, &cpm2_pic_host_ops, 64);
cpm2_pic_host = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
64, &cpm2_pic_host_ops, 64);
if (cpm2_pic_host == NULL) {
printk(KERN_ERR "CPM2 PIC: failed to allocate irq host!\n");
return;
Expand Down
8 changes: 3 additions & 5 deletions arch/powerpc/sysdev/i8259.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ static unsigned char cached_8259[2] = { 0xff, 0xff };

static DEFINE_SPINLOCK(i8259_lock);

static struct device_node *i8259_node;
static struct irq_host *i8259_host;

/*
Expand Down Expand Up @@ -165,7 +164,7 @@ static struct resource pic_edgectrl_iores = {

static int i8259_host_match(struct irq_host *h, struct device_node *node)
{
return i8259_node == NULL || i8259_node == node;
return h->of_node == NULL || h->of_node == node;
}

static int i8259_host_map(struct irq_host *h, unsigned int virq,
Expand Down Expand Up @@ -276,9 +275,8 @@ void i8259_init(struct device_node *node, unsigned long intack_addr)
spin_unlock_irqrestore(&i8259_lock, flags);

/* create a legacy host */
if (node)
i8259_node = of_node_get(node);
i8259_host = irq_alloc_host(IRQ_HOST_MAP_LEGACY, 0, &i8259_host_ops, 0);
i8259_host = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LEGACY,
0, &i8259_host_ops, 0);
if (i8259_host == NULL) {
printk(KERN_ERR "i8259: failed to allocate irq host !\n");
return;
Expand Down
7 changes: 2 additions & 5 deletions arch/powerpc/sysdev/ipic.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,8 @@ static struct irq_chip ipic_irq_chip = {

static int ipic_host_match(struct irq_host *h, struct device_node *node)
{
struct ipic *ipic = h->host_data;

/* Exact match, unless ipic node is NULL */
return ipic->of_node == NULL || ipic->of_node == node;
return h->of_node == NULL || h->of_node == node;
}

static int ipic_host_map(struct irq_host *h, unsigned int virq,
Expand Down Expand Up @@ -568,9 +566,8 @@ struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
return NULL;

memset(ipic, 0, sizeof(struct ipic));
ipic->of_node = of_node_get(node);

ipic->irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR,
ipic->irqhost = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
NR_IPIC_INTS,
&ipic_host_ops, 0);
if (ipic->irqhost == NULL) {
Expand Down
3 changes: 0 additions & 3 deletions arch/powerpc/sysdev/ipic.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ struct ipic {

/* The "linux" controller struct */
struct irq_chip hc_irq;

/* The device node of the interrupt controller */
struct device_node *of_node;
};

struct ipic_info {
Expand Down
Loading

0 comments on commit 52964f8

Please sign in to comment.