diff options
Diffstat (limited to 'drivers/clk/at91/pmc.c')
-rw-r--r-- | drivers/clk/at91/pmc.c | 144 |
1 files changed, 3 insertions, 141 deletions
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 295b17b9c689..f17a2a1f1e85 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -13,12 +13,6 @@ #include <linux/clk/at91_pmc.h> #include <linux/of.h> #include <linux/of_address.h> -#include <linux/io.h> -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/irqchip/chained_irq.h> -#include <linux/irqdomain.h> -#include <linux/of_irq.h> #include <linux/mfd/syscon.h> #include <linux/regmap.h> @@ -67,118 +61,6 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname, } EXPORT_SYMBOL_GPL(of_at91_get_clk_range); -static void pmc_irq_mask(struct irq_data *d) -{ - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); - - regmap_write(pmc->regmap, AT91_PMC_IDR, 1 << d->hwirq); -} - -static void pmc_irq_unmask(struct irq_data *d) -{ - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); - - regmap_write(pmc->regmap, AT91_PMC_IER, 1 << d->hwirq); -} - -static int pmc_irq_set_type(struct irq_data *d, unsigned type) -{ - if (type != IRQ_TYPE_LEVEL_HIGH) { - pr_warn("PMC: type not supported (support only IRQ_TYPE_LEVEL_HIGH type)\n"); - return -EINVAL; - } - - return 0; -} - -static void pmc_irq_suspend(struct irq_data *d) -{ - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); - - regmap_read(pmc->regmap, AT91_PMC_IMR, &pmc->imr); - regmap_write(pmc->regmap, 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); - - regmap_write(pmc->regmap, AT91_PMC_IER, pmc->imr); -} - -static struct irq_chip pmc_irq = { - .name = "PMC", - .irq_disable = pmc_irq_mask, - .irq_mask = pmc_irq_mask, - .irq_unmask = pmc_irq_unmask, - .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 int pmc_irq_map(struct irq_domain *h, unsigned int virq, - irq_hw_number_t hw) -{ - struct at91_pmc *pmc = h->host_data; - - irq_set_lockdep_class(virq, &pmc_lock_class); - - irq_set_chip_and_handler(virq, &pmc_irq, - handle_level_irq); - irq_set_chip_data(virq, pmc); - - return 0; -} - -static int pmc_irq_domain_xlate(struct irq_domain *d, - struct device_node *ctrlr, - const u32 *intspec, unsigned int intsize, - irq_hw_number_t *out_hwirq, - unsigned int *out_type) -{ - struct at91_pmc *pmc = d->host_data; - const struct at91_pmc_caps *caps = pmc->caps; - - if (WARN_ON(intsize < 1)) - return -EINVAL; - - *out_hwirq = intspec[0]; - - if (!(caps->available_irqs & (1 << *out_hwirq))) - return -EINVAL; - - *out_type = IRQ_TYPE_LEVEL_HIGH; - - return 0; -} - -static const struct irq_domain_ops pmc_irq_ops = { - .map = pmc_irq_map, - .xlate = pmc_irq_domain_xlate, -}; - -static irqreturn_t pmc_irq_handler(int irq, void *data) -{ - struct at91_pmc *pmc = (struct at91_pmc *)data; - unsigned int tmpsr, imr; - unsigned long sr; - int n; - - regmap_read(pmc->regmap, AT91_PMC_SR, &tmpsr); - regmap_read(pmc->regmap, AT91_PMC_IMR, &imr); - - sr = tmpsr & imr; - if (!sr) - return IRQ_NONE; - - for_each_set_bit(n, &sr, BITS_PER_LONG) - generic_handle_irq(irq_find_mapping(pmc->irqdomain, n)); - - return IRQ_HANDLED; -} - static const struct at91_pmc_caps at91rm9200_caps = { .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB | AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY | @@ -230,12 +112,12 @@ static const struct at91_pmc_caps sama5d3_caps = { static struct at91_pmc *__init at91_pmc_init(struct device_node *np, struct regmap *regmap, - void __iomem *regbase, int virq, + void __iomem *regbase, const struct at91_pmc_caps *caps) { struct at91_pmc *pmc; - if (!regbase || !virq || !caps) + if (!regbase || !caps) return NULL; at91_pmc_base = regbase; @@ -245,26 +127,11 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np, return NULL; pmc->regmap = regmap; - pmc->virq = virq; pmc->caps = caps; - pmc->irqdomain = irq_domain_add_linear(np, 32, &pmc_irq_ops, pmc); - if (!pmc->irqdomain) - goto out_free_pmc; - regmap_write(pmc->regmap, AT91_PMC_IDR, 0xffffffff); - if (request_irq(pmc->virq, pmc_irq_handler, - IRQF_SHARED | IRQF_COND_SUSPEND, "pmc", pmc)) - goto out_remove_irqdomain; return pmc; - -out_remove_irqdomain: - irq_domain_remove(pmc->irqdomain); -out_free_pmc: - kfree(pmc); - - return NULL; } static void __init of_at91_pmc_setup(struct device_node *np, @@ -273,17 +140,12 @@ static void __init of_at91_pmc_setup(struct device_node *np, struct at91_pmc *pmc; void __iomem *regbase = of_iomap(np, 0); struct regmap *regmap; - int virq; regmap = syscon_node_to_regmap(np); if (IS_ERR(regmap)) panic("Could not retrieve syscon regmap"); - virq = irq_of_parse_and_map(np, 0); - if (!virq) - return; - - pmc = at91_pmc_init(np, regmap, regbase, virq, caps); + pmc = at91_pmc_init(np, regmap, regbase, caps); if (!pmc) return; } |