21 #include <linux/module.h>
22 #include <linux/device.h>
28 #include <linux/slab.h>
37 static const struct of_device_id exynos_wkup_irq_ids[] = {
38 { .compatible =
"samsung,exynos4210-wakeup-eint", },
41 static void exynos_gpio_irq_unmask(
struct irq_data *irqd)
49 mask &= ~(1 << edata->
pin);
53 static void exynos_gpio_irq_mask(
struct irq_data *irqd)
61 mask |= 1 << edata->
pin;
65 static void exynos_gpio_irq_ack(
struct irq_data *irqd)
74 static int exynos_gpio_irq_set_type(
struct irq_data *irqd,
unsigned int type)
81 unsigned int con, trig_type;
102 pr_err(
"unsupported external interrupt type\n");
113 con |= trig_type << shift;
121 con &= ~(mask << shift);
131 static struct irq_chip exynos_gpio_irq_chip = {
132 .name =
"exynos_gpio_irq_chip",
133 .irq_unmask = exynos_gpio_irq_unmask,
134 .irq_mask = exynos_gpio_irq_mask,
135 .irq_ack = exynos_gpio_irq_ack,
136 .irq_set_type = exynos_gpio_irq_set_type,
148 unsigned int nr_banks = d->
ctrl->nr_banks,
idx;
151 if (hw >= d->
ctrl->nr_gint) {
152 dev_err(d->
dev,
"unsupported ext-gpio interrupt\n");
156 for (
idx = 0;
idx < nr_banks;
idx++, bank++) {
159 if ((hw >= irq_base) && (hw < (irq_base + bank->
nr_pins)))
165 if (
idx == nr_banks) {
166 dev_err(d->
dev,
"pin bank not found for ext-gpio interrupt\n");
172 dev_err(d->
dev,
"no memory for eint-gpio data\n");
177 eint_data->
pin = hw - irq_base;
182 static int exynos_gpio_irq_map(
struct irq_domain *
h,
unsigned int virq,
188 eint_data = exynos_get_eint_data(hw, d);
194 irq_set_chip_and_handler(virq, &exynos_gpio_irq_chip,
200 static void exynos_gpio_irq_unmap(
struct irq_domain *h,
unsigned int virq)
205 eint_data = irq_get_handler_data(virq);
213 .map = exynos_gpio_irq_map,
214 .unmap = exynos_gpio_irq_unmap,
250 dev_err(dev,
"irq number not available\n");
254 ret = devm_request_irq(dev, d->
irq, exynos_eint_gpio_irq,
255 0, dev_name(dev), d);
257 dev_err(dev,
"irq request failed\n");
262 &exynos_gpio_irqd_ops, d);
264 dev_err(dev,
"gpio irq domain allocation failed\n");
271 static void exynos_wkup_irq_unmask(
struct irq_data *irqd)
276 unsigned long reg_mask = d->
ctrl->weint_mask + (bank << 2);
284 static void exynos_wkup_irq_mask(
struct irq_data *irqd)
289 unsigned long reg_mask = d->
ctrl->weint_mask + (bank << 2);
297 static void exynos_wkup_irq_ack(
struct irq_data *irqd)
302 unsigned long pend = d->
ctrl->weint_pend + (bank << 2);
307 static int exynos_wkup_irq_set_type(
struct irq_data *irqd,
unsigned int type)
312 unsigned long reg_con = d->
ctrl->weint_con + (bank << 2);
314 unsigned long con, trig_type;
333 pr_err(
"unsupported external interrupt type\n");
344 con |= trig_type << shift;
352 static struct irq_chip exynos_wkup_irq_chip = {
353 .name =
"exynos_wkup_irq_chip",
354 .irq_unmask = exynos_wkup_irq_unmask,
355 .irq_mask = exynos_wkup_irq_mask,
356 .irq_ack = exynos_wkup_irq_ack,
357 .irq_set_type = exynos_wkup_irq_set_type,
361 static void exynos_irq_eint0_15(
unsigned int irq,
struct irq_desc *
desc)
367 chained_irq_enter(chip, desc);
376 chained_irq_exit(chip, desc);
379 static inline void exynos_irq_demux_eint(
int irq_base,
unsigned long pend,
392 static void exynos_irq_demux_eint16_31(
unsigned int irq,
struct irq_desc *desc)
394 struct irq_chip *chip = irq_get_chip(irq);
400 chained_irq_enter(chip, desc);
403 exynos_irq_demux_eint(16, pend & ~mask, eintd->
domain);
406 exynos_irq_demux_eint(24, pend & ~mask, eintd->
domain);
407 chained_irq_exit(chip, desc);
410 static int exynos_wkup_irq_map(
struct irq_domain *h,
unsigned int virq,
423 .map = exynos_wkup_irq_map,
449 &exynos_wkup_irqd_ops, d);
451 dev_err(dev,
"wakeup irq domain allocation failed\n");
457 dev_err(dev,
"could not allocate memory for weint_data\n");
464 irq_set_chained_handler(irq, exynos_irq_demux_eint16_31);
467 dev_err(dev,
"irq number for EINT16-32 not found\n");
470 for (idx = 0; idx < 16; idx++) {
477 irq_set_chained_handler(irq, exynos_irq_eint0_15);
479 dev_err(dev,
"irq number for eint-%x not found\n", idx);
541 .pin_banks = exynos4210_pin_banks0,
542 .nr_banks =
ARRAY_SIZE(exynos4210_pin_banks0),
550 .eint_gpio_init = exynos_eint_gpio_init,
551 .label =
"exynos4210-gpio-ctrl0",
554 .pin_banks = exynos4210_pin_banks1,
555 .nr_banks =
ARRAY_SIZE(exynos4210_pin_banks1),
567 .eint_gpio_init = exynos_eint_gpio_init,
568 .eint_wkup_init = exynos_eint_wkup_init,
569 .label =
"exynos4210-gpio-ctrl1",
572 .pin_banks = exynos4210_pin_banks2,
573 .nr_banks =
ARRAY_SIZE(exynos4210_pin_banks2),
577 .label =
"exynos4210-gpio-ctrl2",