From ee2f573c4206ff3c4dbff2296c8d383d045c80a2 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:33:48 +0900 Subject: pinctrl: exynos: Set pin function to EINT in irq_set_type of GPIO EINTa Pins used as GPIO interrupts need to be configured as EINTs. This patch adds the required configuration code to exynos_gpio_irq_set_type, to set the pin as EINT when its interrupt trigger is configured. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park Acked-by: Linus Walleij Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-exynos.c | 12 ++++++++++++ drivers/pinctrl/pinctrl-exynos.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c index 447818d9851b..c2fa85f18764 100644 --- a/drivers/pinctrl/pinctrl-exynos.c +++ b/drivers/pinctrl/pinctrl-exynos.c @@ -76,9 +76,11 @@ static int exynos_gpio_irq_set_type(struct irq_data *irqd, unsigned int type) struct samsung_pinctrl_drv_data *d = irqd->domain->host_data; struct samsung_pin_ctrl *ctrl = d->ctrl; struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd); + struct samsung_pin_bank *bank = edata->bank; unsigned int shift = EXYNOS_EINT_CON_LEN * edata->pin; unsigned int con, trig_type; unsigned long reg_con = ctrl->geint_con + edata->eint_offset; + unsigned int mask; switch (type) { case IRQ_TYPE_EDGE_RISING: @@ -110,6 +112,16 @@ static int exynos_gpio_irq_set_type(struct irq_data *irqd, unsigned int type) con &= ~(EXYNOS_EINT_CON_MASK << shift); con |= trig_type << shift; writel(con, d->virt_base + reg_con); + + reg_con = bank->pctl_offset; + shift = edata->pin * bank->func_width; + mask = (1 << bank->func_width) - 1; + + con = readl(d->virt_base + reg_con); + con &= ~(mask << shift); + con |= EXYNOS_EINT_FUNC << shift; + writel(con, d->virt_base + reg_con); + return 0; } diff --git a/drivers/pinctrl/pinctrl-exynos.h b/drivers/pinctrl/pinctrl-exynos.h index 5f27ba974a3a..31d0a06174e4 100644 --- a/drivers/pinctrl/pinctrl-exynos.h +++ b/drivers/pinctrl/pinctrl-exynos.h @@ -144,6 +144,7 @@ enum exynos4210_gpio_xc_start { #define EXYNOS_WKUP_EMASK_OFFSET 0xF00 #define EXYNOS_WKUP_EPEND_OFFSET 0xF40 #define EXYNOS_SVC_OFFSET 0xB08 +#define EXYNOS_EINT_FUNC 0xF /* helpers to access interrupt service register */ #define EXYNOS_SVC_GROUP_SHIFT 3 -- cgit v1.2.3 From 3da23f27a0f6a5e44a01813a1c0a662011e5c221 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:33:52 +0900 Subject: pinctrl: exynos: Fix typos in gpio/wkup _irq_mask To mask GPIO/wakeup IRQ, the corresponding bit in mask register has to be set. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park Acked-by: Linus Walleij Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-exynos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c index c2fa85f18764..46cd637f4804 100644 --- a/drivers/pinctrl/pinctrl-exynos.c +++ b/drivers/pinctrl/pinctrl-exynos.c @@ -58,7 +58,7 @@ static void exynos_gpio_irq_mask(struct irq_data *irqd) unsigned long mask; mask = readl(d->virt_base + reg_mask); - mask |= ~(1 << edata->pin); + mask |= 1 << edata->pin; writel(mask, d->virt_base + reg_mask); } @@ -290,7 +290,7 @@ static void exynos_wkup_irq_mask(struct irq_data *irqd) unsigned long mask; mask = readl(d->virt_base + reg_mask); - mask &= ~(1 << pin); + mask |= 1 << pin; writel(mask, d->virt_base + reg_mask); } -- cgit v1.2.3 From de59049bd651c1f6b05869a4292f4c8017bdeff9 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:33:55 +0900 Subject: pinctrl: exynos: Handle only unmasked wakeup interrupts A bit in EINTxx_PEND register is set regardless of interrupt mask, which causes spurious interrupts. To avoid them, the read value of pending register must be masked with current interrupt mask manually. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park Acked-by: Linus Walleij Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-exynos.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c index 46cd637f4804..56489714cd70 100644 --- a/drivers/pinctrl/pinctrl-exynos.c +++ b/drivers/pinctrl/pinctrl-exynos.c @@ -395,12 +395,15 @@ static void exynos_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc) struct exynos_weint_data *eintd = irq_get_handler_data(irq); struct samsung_pinctrl_drv_data *d = eintd->domain->host_data; unsigned long pend; + unsigned long mask; chained_irq_enter(chip, desc); pend = readl(d->virt_base + d->ctrl->weint_pend + 0x8); - exynos_irq_demux_eint(16, pend, eintd->domain); + mask = readl(d->virt_base + d->ctrl->weint_mask + 0x8); + exynos_irq_demux_eint(16, pend & ~mask, eintd->domain); pend = readl(d->virt_base + d->ctrl->weint_pend + 0xC); - exynos_irq_demux_eint(24, pend, eintd->domain); + mask = readl(d->virt_base + d->ctrl->weint_mask + 0xC); + exynos_irq_demux_eint(24, pend & ~mask, eintd->domain); chained_irq_exit(chip, desc); } -- cgit v1.2.3 From 9759e2ebc4bc78c630ad952a288a53d131f1cb53 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:33:58 +0900 Subject: pinctrl: exynos: Mark exynos_irq_demux_eint as inline The exynos_irq_demux_eint utility function is used in chained IRQ handler for EINT16-31 to handle multiplexed interrupts. Inlining it should improve the performance a bit. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park Acked-by: Linus Walleij Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-exynos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c index 56489714cd70..49ef5a2f79ae 100644 --- a/drivers/pinctrl/pinctrl-exynos.c +++ b/drivers/pinctrl/pinctrl-exynos.c @@ -376,7 +376,7 @@ static void exynos_irq_eint0_15(unsigned int irq, struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void exynos_irq_demux_eint(int irq_base, unsigned long pend, +static inline void exynos_irq_demux_eint(int irq_base, unsigned long pend, struct irq_domain *domain) { unsigned int irq; -- cgit v1.2.3 From c3ad056b26fe5d5be71b96371b0b2d00b2276ad3 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:34:01 +0900 Subject: pinctrl: exynos: Correct the detection of wakeup-eint node Current way of finding the wakeup-eint node scans the whole device tree not only children of the pinctrl node, so it might detect a wakeup-eint node of another pinctrl device. This patch limits the scope of looking for nodes only to subnodes of the pinctrl node. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park Acked-by: Linus Walleij Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-exynos.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c index 49ef5a2f79ae..0d01d19edc91 100644 --- a/drivers/pinctrl/pinctrl-exynos.c +++ b/drivers/pinctrl/pinctrl-exynos.c @@ -431,15 +431,19 @@ static const struct irq_domain_ops exynos_wkup_irqd_ops = { static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) { struct device *dev = d->dev; - struct device_node *wkup_np; + struct device_node *wkup_np = NULL; + struct device_node *np; struct exynos_weint_data *weint_data; int idx, irq; - wkup_np = of_find_matching_node(dev->of_node, exynos_wkup_irq_ids); - if (!wkup_np) { - dev_err(dev, "wakeup controller node not found\n"); - return -ENODEV; + for_each_child_of_node(dev->of_node, np) { + if (of_match_node(exynos_wkup_irq_ids, np)) { + wkup_np = np; + break; + } } + if (!wkup_np) + return -ENODEV; d->wkup_irqd = irq_domain_add_linear(wkup_np, d->ctrl->nr_wint, &exynos_wkup_irqd_ops, d); -- cgit v1.2.3 From 2f0253ffed8ed1a7e0a733e8e86a7604eb80027a Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:34:04 +0900 Subject: pinctrl: samsung: Uninline samsung_pinctrl_get_soc_data Although the function is used only a single time, it is not performance critical and it is pretty heavy, so let the compiler decide whether to inline it instead. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park Acked-by: Linus Walleij Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-samsung.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c index 8a24223d5334..dd108a94acf9 100644 --- a/drivers/pinctrl/pinctrl-samsung.c +++ b/drivers/pinctrl/pinctrl-samsung.c @@ -776,7 +776,7 @@ static int __init samsung_gpiolib_unregister(struct platform_device *pdev, static const struct of_device_id samsung_pinctrl_dt_match[]; /* retrieve the soc specific data */ -static inline struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( +static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( struct platform_device *pdev) { int id; -- cgit v1.2.3 From d3c977927bd6320f1e9d4098989d6001bdcefc09 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Fri, 21 Sep 2012 07:34:07 +0900 Subject: pinctrl: exynos: Fix wakeup IRQ domain registration check Because of a typo, incorrect field of a structure was being checked. This patch fixes the check to use correct field. Signed-off-by: Tomasz Figa Signed-off-by: Kukjin Kim --- drivers/pinctrl/pinctrl-exynos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c index 0d01d19edc91..21362f48d370 100644 --- a/drivers/pinctrl/pinctrl-exynos.c +++ b/drivers/pinctrl/pinctrl-exynos.c @@ -447,7 +447,7 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) d->wkup_irqd = irq_domain_add_linear(wkup_np, d->ctrl->nr_wint, &exynos_wkup_irqd_ops, d); - if (!d->gpio_irqd) { + if (!d->wkup_irqd) { dev_err(dev, "wakeup irq domain allocation failed\n"); return -ENXIO; } -- cgit v1.2.3