irqchip/irq-bcm7038-l1 updates
Subsystems (5)
cover irqchip/irq-bcm7038-l1 updates
Hi Marc, Jason, Thomas,
This patch series contains some updates from our internal tree to support power management and allow configuring specific instances of the brcm,bcm7038-l1-intc to leave some interrupts untouched and how the firmware might have configured them.
Florian Fainelli (5):
dt-bindings: Document brcm,irq-can-wake for brcm,bcm7038-l1-intc.txt irqchip/irq-bcm7038-l1: Enable parent IRQ if necessary
dt-bindings: Document brcm,int-fwd-mask property for bcm7038-l1-intc irqchip/irq-bcm7038-l1: Support brcm,int-fwd-mask
fixup! irqchip/irq-bcm7038-l1: Add PM support
Justin Chen (1):
irqchip/irq-bcm7038-l1: Add PM support
.../brcm,bcm7038-l1-intc.txt | 9 ++ drivers/irqchip/irq-bcm7038-l1.c | 117 +++++++++++++++++- 2 files changed, 124 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/6 irqchip/irq-bcm7038-l1: Add PM support
From: Justin Chen <[email protected]>
The current l1 controller does not mask any interrupts when dropping into suspend. This mean we can receive unexpected wake up sources. Modified MIPS l1 controller to mask the all non-wake interrupts before dropping into suspend.
--- drivers/irqchip/irq-bcm7038-l1.c | 98 ++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
drivers/irqchip/irq-bcm7038-l1.c +98 -0
@@ -27,6 +27,7 @@#include <linux/types.h> #include <linux/irqchip.h> #include <linux/irqchip/chained_irq.h> +#include <linux/syscore_ops.h> #define IRQS_PER_WORD 32#define REG_BYTES_PER_IRQ_WORD (sizeof(u32) * 4)
@@ -39,6 +40,10 @@ struct bcm7038_l1_chip {unsigned int n_words;struct irq_domain *domain;struct bcm7038_l1_cpu *cpus[NR_CPUS ]; +#ifdef CONFIG_PM_SLEEP +struct list_head list; +u32 wake_mask[MAX_WORDS ]; +#endif u8 affinity[MAX_WORDS *IRQS_PER_WORD ]; };
@@ -47,6 +52,17 @@ struct bcm7038_l1_cpu {u32 mask_cache[0 ]; }; +/* +* We keep a list of bcm7038_l1_chip used for suspend/resume. This hack is +* used because the struct chip_type suspend/resume hooks are not called +* unless chip_type is hooked onto a generic_chip. Since this driver does +* not use generic_chip, we need to manually hook our resume/suspend to +* syscore_ops. +*/ +#ifdef CONFIG_PM_SLEEP +static LIST_HEAD (bcm7038_l1_intcs_list); +#endif +/* * STATUS/MASK_STATUS/MASK_SET/MASK_CLEAR are packed one right after another: *
@@ -287,6 +303,77 @@ static int __init bcm7038_l1_init_one(struct device_node *dn,return 0 ; } +#ifdef CONFIG_PM_SLEEP +static int bcm7038_l1_suspend (void ) +{ +struct bcm7038_l1_chip *intc; +unsigned long flags; +int boot_cpu, word; + +/* Wakeup interrupt should only come from the boot cpu */ + boot_cpu =cpu_logical_map (smp_processor_id ()); + +list_for_each_entry (intc, &bcm7038_l1_intcs_list, list) { +raw_spin_lock_irqsave (&intc->lock, flags); +for (word =0 ; word < intc->n_words; word++) { +l1_writel (~intc->wake_mask[word], + intc->cpus[boot_cpu]->map_base + +reg_mask_set (intc, word)); +l1_writel (intc->wake_mask[word], + intc->cpus[boot_cpu]->map_base + +reg_mask_clr (intc, word)); + } +raw_spin_unlock_irqrestore (&intc->lock, flags); + } + +return 0 ; +} + +static void bcm7038_l1_resume (void ) +{ +struct bcm7038_l1_chip *intc; +unsigned long flags; +int boot_cpu, word; + + boot_cpu =cpu_logical_map (smp_processor_id ()); + +list_for_each_entry (intc, &bcm7038_l1_intcs_list, list) { +raw_spin_lock_irqsave (&intc->lock, flags); +for (word =0 ; word < intc->n_words; word++) { +l1_writel (intc->cpus[boot_cpu]->mask_cache[word], + intc->cpus[boot_cpu]->map_base + +reg_mask_set (intc, word)); +l1_writel (~intc->cpus[boot_cpu]->mask_cache[word], + intc->cpus[boot_cpu]->map_base + +reg_mask_clr (intc, word)); + } +raw_spin_unlock_irqrestore (&intc->lock, flags); + } +} + +static struct syscore_ops bcm7038_l1_syscore_ops = { + .suspend = bcm7038_l1_suspend, + .resume = bcm7038_l1_resume, +}; + +static int bcm7038_l1_set_wake (struct irq_data *d,unsigned int on) +{ +struct bcm7038_l1_chip *intc =irq_data_get_irq_chip_data (d); +unsigned long flags; +u32 word = d->hwirq /IRQS_PER_WORD ; +u32 mask =BIT (d->hwirq %IRQS_PER_WORD ); + +raw_spin_lock_irqsave (&intc->lock, flags); +if (on) + intc->wake_mask[word] |= mask; +else + intc->wake_mask[word] &= ~mask; +raw_spin_unlock_irqrestore (&intc->lock, flags); + +return 0 ; +} +#endif +static struct irq_chip bcm7038_l1_irq_chip = { .name ="bcm7038-l1" , .irq_mask = bcm7038_l1_mask,
@@ -295,6 +382,9 @@ static struct irq_chip bcm7038_l1_irq_chip = {#ifdef CONFIG_SMP .irq_cpu_offline = bcm7038_l1_cpu_offline,#endif +#if CONFIG_PM_SLEEP + .irq_set_wake = bcm7038_l1_set_wake, +#endif }; static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,
@@ -340,6 +430,14 @@ int __init bcm7038_l1_of_init(struct device_node *dn, goto out_unmap; } +#ifdef CONFIG_PM_SLEEP +/* Add bcm7038_l1_chip into a list */ +INIT_LIST_HEAD (&intc->list); +list_add_tail (&intc->list, &bcm7038_l1_intcs_list); + +register_syscore_ops (&bcm7038_l1_syscore_ops); +#endif +pr_info ("registered BCM7038 L1 intc (%pOF, IRQs: %d)\n" , dn,IRQS_PER_WORD * intc->n_words);
Signature · 1 line
2.17.1
PATCH 2/6 dt-bindings: Document brcm,irq-can-wake for brcm,bcm7038-l1-intc.txt
In reply to Florian FainelliThe BCM7038 L1 interrupt controller can be used as a wake-up interrupt controller on MIPS and ARM-based systems, document the brcm,irq-can-wake which has been "standardized" across Broadcom interrupt controllers.
--- .../bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt +5 -0
@@ -31,6 +31,11 @@ Required properties: - interrupts: specifies the interrupt line(s) in the interrupt-parent controller node; valid values depend on the type of parent interrupt controller +Optional properties: + +- brcm,irq-can-wake: If present, this means the L1 controller can be used as a + wakeup source for system suspend/resume. + If multiple reg ranges and interrupt-parent entries are present on an SMP system, the driver will allow IRQ SMP affinity to be set up through the /proc/irq/ interface. In the simplest possible configuration, only one
Signature · 1 line
2.17.1
PATCH 3/6 irqchip/irq-bcm7038-l1: Enable parent IRQ if necessary
In reply to Florian FainelliIf the 'brcm,irq-can-wake' property is specified, make sure we also enable the corresponding parent interrupt we are attached to.
--- drivers/irqchip/irq-bcm7038-l1.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/irqchip/irq-bcm7038-l1.c +4 -0
@@ -297,6 +297,10 @@ static int __init bcm7038_l1_init_one(struct device_node *dn,pr_err ("failed to map parent interrupt %d\n" , parent_irq);return -EINVAL ; } + +if (of_property_read_bool (dn,"brcm,irq-can-wake" )) +enable_irq_wake (parent_irq); +irq_set_chained_handler_and_data (parent_irq, bcm7038_l1_irq_handle, intc);
Signature · 1 line
2.17.1
PATCH 4/6 dt-bindings: Document brcm,int-fwd-mask property for bcm7038-l1-intc
In reply to Florian FainelliIndicate that the brcm,int-fwd-mask property is optional and can be optionaly set on platforms which require to leave specific interrupts untouched from Linux and retain the firmware configuration.
--- .../bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt +4 -0
@@ -36,6 +36,10 @@ Optional properties: - brcm,irq-can-wake: If present, this means the L1 controller can be used as a wakeup source for system suspend/resume. +- brcm,int-fwd-mask: if present, a bit mask to indicate which interrupts + have already been configured by the firmware and should be left untouched. + This should have one 32-bit word per status/set/clear/mask group. + If multiple reg ranges and interrupt-parent entries are present on an SMP system, the driver will allow IRQ SMP affinity to be set up through the /proc/irq/ interface. In the simplest possible configuration, only one
Signature · 1 line
2.17.1
PATCH 5/6 irqchip/irq-bcm7038-l1: Support brcm,int-fwd-mask
In reply to Florian FainelliOn some specific chips like 7211 we need to leave some interrupts untouched/forwarded to the VPU which is another agent in the system making use of that interrupt controller hardware (goes to both ARM GIC and VPU L1 interrupt controller). Make that possible by using the existing brcm,int-fwd-mask property.
--- drivers/irqchip/irq-bcm7038-l1.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/irqchip/irq-bcm7038-l1.c +13 -2
@@ -44,6 +44,7 @@ struct bcm7038_l1_chip {struct list_head list;u32 wake_mask[MAX_WORDS ];#endif +u32 irq_fwd_mask[MAX_WORDS ];u8 affinity[MAX_WORDS *IRQS_PER_WORD ]; };
@@ -265,6 +266,7 @@ static int __init bcm7038_l1_init_one(struct device_node *dn,resource_size_t sz;struct bcm7038_l1_cpu *cpu;unsigned int i, n_words, parent_irq; +int ret;if (of_address_to_resource (dn, idx, &res))return -EINVAL ;
@@ -278,6 +280,14 @@ static int __init bcm7038_l1_init_one(struct device_node *dn,else if (intc->n_words != n_words)return -EINVAL ; + ret =of_property_read_u32_array (dn ,"brcm,int-fwd-mask" , + intc->irq_fwd_mask, n_words); +if (ret !=0 && ret != -EINVAL ) { +/* property exists but has the wrong number of words */ +pr_err ("invalid brcm,int-fwd-mask property\n" ); +return -EINVAL ; + } + cpu = intc->cpus[idx] =kzalloc (sizeof (*cpu) + n_words *sizeof (u32),GFP_KERNEL );if (!cpu)
@@ -288,8 +298,9 @@ static int __init bcm7038_l1_init_one(struct device_node *dn,return -ENOMEM ;for (i =0 ; i < n_words; i++) { -l1_writel (0xffffffff , cpu->map_base +reg_mask_set (intc, i)); - cpu->mask_cache[i] =0xffffffff ; +l1_writel (0xffffffff & ~intc->irq_fwd_mask[i], + cpu->map_base +reg_mask_set (intc, i)); + cpu->mask_cache[i] =0xffffffff & ~intc->irq_fwd_mask[i]; } parent_irq =irq_of_parse_and_map (dn, idx);
Signature · 1 line
2.17.1
PATCH 6/6 fixup! irqchip/irq-bcm7038-l1: Add PM support
In reply to Florian Fainelli--- drivers/irqchip/irq-bcm7038-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm7038-l1.c +1 -1
@@ -397,7 +397,7 @@ static struct irq_chip bcm7038_l1_irq_chip = {#ifdef CONFIG_SMP .irq_cpu_offline = bcm7038_l1_cpu_offline,#endif -#if CONFIG_PM_SLEEP +#ifdef CONFIG_PM_SLEEP .irq_set_wake = bcm7038_l1_set_wake,#endif };
Signature · 1 line
2.17.1
Re: [PATCH 6/6] fixup! irqchip/irq-bcm7038-l1: Add PM support
Quoted 10 lines · Florian Fainelli
--- drivers/irqchip/irq-bcm7038-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/irqchip/irq-bcm7038-l1.c +0
-0
drivers/irqchip/irq-bcm7038-l1.c static struct irq_chip bcm7038_l1_irq_chip = { · line 403
Quoted 8 lines
drivers/irqchip/irq-bcm7038-l1.c +1
-1@@ -397,7 +397,7 @@ static struct irq_chip bcm7038_l1_irq_chip = {#ifdef CONFIG_SMP .irq_cpu_offline = bcm7038_l1_cpu_offline,#endif -#if CONFIG_PM_SLEEP +#ifdef CONFIG_PM_SLEEP .irq_set_wake = bcm7038_l1_set_wake,#endif };
This should have been part of patch #1, I will resubmit this series, sorry about that.
Signature · 1 line
Florian