Skip to content

Commit 13bec8d

Browse files
Ajay Kishorelinusw
authored andcommitted
pinctrl: qcom: use scm_call to route GPIO irq to Apps
For IPQ806x targets, TZ protects the registers that are used to configure the routing of interrupts to a target processor. To resolve this, this patch uses scm call to route GPIO interrupts to application processor. Also the scm call interface is changed. Signed-off-by: Ajay Kishore <[email protected]> Signed-off-by: Ansuel Smith <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 1592c4b commit 13bec8d

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <linux/reboot.h>
2323
#include <linux/pm.h>
2424
#include <linux/log2.h>
25+
#include <linux/qcom_scm.h>
26+
#include <linux/io.h>
2527

2628
#include <linux/soc/qcom/irq.h>
2729

@@ -60,6 +62,8 @@ struct msm_pinctrl {
6062
struct irq_chip irq_chip;
6163
int irq;
6264

65+
bool intr_target_use_scm;
66+
6367
raw_spinlock_t lock;
6468

6569
DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO);
@@ -68,6 +72,7 @@ struct msm_pinctrl {
6872

6973
const struct msm_pinctrl_soc_data *soc;
7074
void __iomem *regs[MAX_NR_TILES];
75+
u32 phys_base[MAX_NR_TILES];
7176
};
7277

7378
#define MSM_ACCESSOR(name) \
@@ -882,11 +887,31 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
882887
else
883888
clear_bit(d->hwirq, pctrl->dual_edge_irqs);
884889

885-
/* Route interrupts to application cpu */
886-
val = msm_readl_intr_target(pctrl, g);
887-
val &= ~(7 << g->intr_target_bit);
888-
val |= g->intr_target_kpss_val << g->intr_target_bit;
889-
msm_writel_intr_target(val, pctrl, g);
890+
/* Route interrupts to application cpu.
891+
* With intr_target_use_scm interrupts are routed to
892+
* application cpu using scm calls.
893+
*/
894+
if (pctrl->intr_target_use_scm) {
895+
u32 addr = pctrl->phys_base[0] + g->intr_target_reg;
896+
int ret;
897+
898+
qcom_scm_io_readl(addr, &val);
899+
900+
val &= ~(7 << g->intr_target_bit);
901+
val |= g->intr_target_kpss_val << g->intr_target_bit;
902+
903+
ret = qcom_scm_io_writel(addr, val);
904+
if (ret)
905+
dev_err(pctrl->dev,
906+
"Failed routing %lu interrupt to Apps proc",
907+
d->hwirq);
908+
}
909+
} else {
910+
val = msm_readl_intr_target(pctrl, g);
911+
val &= ~(7 << g->intr_target_bit);
912+
val |= g->intr_target_kpss_val << g->intr_target_bit;
913+
msm_writel_intr_target(val, pctrl, g);
914+
}
890915

891916
/* Update configuration for gpio.
892917
* RAW_STATUS_EN is left on for all gpio irqs. Due to the
@@ -1241,6 +1266,9 @@ int msm_pinctrl_probe(struct platform_device *pdev,
12411266
pctrl->dev = &pdev->dev;
12421267
pctrl->soc = soc_data;
12431268
pctrl->chip = msm_gpio_template;
1269+
pctrl->intr_target_use_scm = of_device_is_compatible(
1270+
pctrl->dev->of_node,
1271+
"qcom,ipq8064-pinctrl");
12441272

12451273
raw_spin_lock_init(&pctrl->lock);
12461274

@@ -1253,9 +1281,12 @@ int msm_pinctrl_probe(struct platform_device *pdev,
12531281
return PTR_ERR(pctrl->regs[i]);
12541282
}
12551283
} else {
1256-
pctrl->regs[0] = devm_platform_ioremap_resource(pdev, 0);
1284+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1285+
pctrl->regs[0] = devm_ioremap_resource(&pdev->dev, res);
12571286
if (IS_ERR(pctrl->regs[0]))
12581287
return PTR_ERR(pctrl->regs[0]);
1288+
1289+
pctrl->phys_base[0] = res->start;
12591290
}
12601291

12611292
msm_pinctrl_setup_pm_reset(pctrl);

0 commit comments

Comments
 (0)