ipq806x: correct wrong node in r7800 dts
[openwrt/openwrt.git] / target / linux / ipq806x / patches-5.4 / 0073-pinctrl-qom-use-scm_call-to-route-GPIO-irq-to-Apps.patch
1 From 2034addc7e193dc81d7ca60d8884832751b76758 Mon Sep 17 00:00:00 2001
2 From: Ajay Kishore <akisho@codeaurora.org>
3 Date: Tue, 24 Jan 2017 14:14:16 +0530
4 Subject: pinctrl: qcom: use scm_call to route GPIO irq to Apps
5
6 For IPQ806x targets, TZ protects the registers that are used to
7 configure the routing of interrupts to a target processor.
8 To resolve this, this patch uses scm call to route GPIO interrupts
9 to application processor. Also the scm call interface is changed.
10
11 Change-Id: Ib6c06829d04bc8c20483c36e63da92e26cdef9ce
12 Signed-off-by: Ajay Kishore <akisho@codeaurora.org>
13 ---
14
15 --- a/drivers/pinctrl/qcom/pinctrl-msm.c
16 +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
17 @@ -30,7 +30,8 @@
18 #include <linux/reboot.h>
19 #include <linux/pm.h>
20 #include <linux/log2.h>
21 -
22 +#include <linux/qcom_scm.h>
23 +#include <linux/io.h>
24 #include "../core.h"
25 #include "../pinconf.h"
26 #include "pinctrl-msm.h"
27 @@ -628,6 +629,9 @@ static void msm_gpio_irq_mask(struct irq
28 const struct msm_pingroup *g;
29 unsigned long flags;
30 u32 val;
31 + u32 addr;
32 + int ret;
33 + const __be32 *reg;
34
35 g = &pctrl->soc->groups[d->hwirq];
36
37 @@ -732,11 +736,30 @@ static int msm_gpio_irq_set_type(struct
38 else
39 clear_bit(d->hwirq, pctrl->dual_edge_irqs);
40
41 + int ret = of_device_is_compatible(pctrl->dev->of_node,
42 + "qcom,ipq8064-pinctrl");
43 /* Route interrupts to application cpu */
44 - val = readl(pctrl->regs + g->intr_target_reg);
45 - val &= ~(7 << g->intr_target_bit);
46 - val |= g->intr_target_kpss_val << g->intr_target_bit;
47 - writel(val, pctrl->regs + g->intr_target_reg);
48 + if (!ret) {
49 + val = readl(pctrl->regs + g->intr_target_reg);
50 + val &= ~(7 << g->intr_target_bit);
51 + val |= g->intr_target_kpss_val << g->intr_target_bit;
52 + writel(val, pctrl->regs + g->intr_target_reg);
53 + } else {
54 + const __be32 *reg = of_get_property(pctrl->dev->of_node, "reg", NULL);
55 + if (reg) {
56 + u32 addr = be32_to_cpup(reg) + g->intr_target_reg;
57 + qcom_scm_io_readl(addr, &val);
58 + __iormb();
59 +
60 + val &= ~(7 << g->intr_target_bit);
61 + val |= g->intr_target_kpss_val << g->intr_target_bit;
62 +
63 + __iowmb();
64 + ret = qcom_scm_io_writel(addr, val);
65 + if (ret)
66 + pr_err("\n Routing interrupts to Apps proc failed");
67 + }
68 + }
69
70 /* Update configuration for gpio.
71 * RAW_STATUS_EN is left on for all gpio irqs. Due to the