Commit 947f5b10 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Rafael J. Wysocki

clk: at91: implement suspend/resume for the PMC irqchip

The irq line used by the PMC block is shared with several peripherals
including the init timer which is registering its handler with
IRQF_NO_SUSPEND.

Implement the appropriate suspend/resume callback for the PMC irqchip,
and inform irq core that PMC irq handler can be safely called while
the system is suspended by setting IRQF_COND_SUSPEND.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent dd1f1f39
...@@ -89,12 +89,29 @@ static int pmc_irq_set_type(struct irq_data *d, unsigned type) ...@@ -89,12 +89,29 @@ static int pmc_irq_set_type(struct irq_data *d, unsigned type)
return 0; return 0;
} }
static void pmc_irq_suspend(struct irq_data *d)
{
struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
pmc->imr = pmc_read(pmc, AT91_PMC_IMR);
pmc_write(pmc, AT91_PMC_IDR, pmc->imr);
}
static void pmc_irq_resume(struct irq_data *d)
{
struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
pmc_write(pmc, AT91_PMC_IER, pmc->imr);
}
static struct irq_chip pmc_irq = { static struct irq_chip pmc_irq = {
.name = "PMC", .name = "PMC",
.irq_disable = pmc_irq_mask, .irq_disable = pmc_irq_mask,
.irq_mask = pmc_irq_mask, .irq_mask = pmc_irq_mask,
.irq_unmask = pmc_irq_unmask, .irq_unmask = pmc_irq_unmask,
.irq_set_type = pmc_irq_set_type, .irq_set_type = pmc_irq_set_type,
.irq_suspend = pmc_irq_suspend,
.irq_resume = pmc_irq_resume,
}; };
static struct lock_class_key pmc_lock_class; static struct lock_class_key pmc_lock_class;
...@@ -224,7 +241,8 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np, ...@@ -224,7 +241,8 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
goto out_free_pmc; goto out_free_pmc;
pmc_write(pmc, AT91_PMC_IDR, 0xffffffff); pmc_write(pmc, AT91_PMC_IDR, 0xffffffff);
if (request_irq(pmc->virq, pmc_irq_handler, IRQF_SHARED, "pmc", pmc)) if (request_irq(pmc->virq, pmc_irq_handler,
IRQF_SHARED | IRQF_COND_SUSPEND, "pmc", pmc))
goto out_remove_irqdomain; goto out_remove_irqdomain;
return pmc; return pmc;
......
...@@ -33,6 +33,7 @@ struct at91_pmc { ...@@ -33,6 +33,7 @@ struct at91_pmc {
spinlock_t lock; spinlock_t lock;
const struct at91_pmc_caps *caps; const struct at91_pmc_caps *caps;
struct irq_domain *irqdomain; struct irq_domain *irqdomain;
u32 imr;
}; };
static inline void pmc_lock(struct at91_pmc *pmc) static inline void pmc_lock(struct at91_pmc *pmc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment