From 94ebb327f5a2108494520bb27427a609443681ad Mon Sep 17 00:00:00 2001 From: Raghavendra Kakarla Date: Mon, 18 Mar 2019 23:12:41 +0530 Subject: [PATCH] drivers: coresight: Add interrupt service routine for apss tgu Add the interrupt service routine for apss tgu to handle tgu interrupt. Change-Id: Ic0128e41ed7a8e837ebab12a28c744af85109bda Signed-off-by: Raghavendra Kakarla --- drivers/hwtracing/coresight/Makefile | 2 +- drivers/hwtracing/coresight/apss_tgu.c | 58 +++++++++++++++++++++ drivers/hwtracing/coresight/apss_tgu.h | 17 ++++++ drivers/hwtracing/coresight/coresight-tgu.c | 9 ++++ include/trace/events/tgu.h | 40 ++++++++++++++ 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/apss_tgu.c create mode 100644 drivers/hwtracing/coresight/apss_tgu.h create mode 100644 include/trace/events/tgu.h diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 85b93c1a0cd3..d229fd25c568 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -30,4 +30,4 @@ obj-$(CONFIG_CORESIGHT_HWEVENT) += coresight-hwevent.o obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o obj-$(CONFIG_CORESIGHT_REMOTE_ETM) += coresight-remote-etm.o obj-$(CONFIG_CORESIGHT_CSR) += coresight-csr.o -obj-$(CONFIG_CORESIGHT_TGU) += coresight-tgu.o +obj-$(CONFIG_CORESIGHT_TGU) += coresight-tgu.o apss_tgu.o diff --git a/drivers/hwtracing/coresight/apss_tgu.c b/drivers/hwtracing/coresight/apss_tgu.c new file mode 100644 index 000000000000..0776cdd224e4 --- /dev/null +++ b/drivers/hwtracing/coresight/apss_tgu.c @@ -0,0 +1,58 @@ +/* Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#define CREATE_TRACE_POINTS +#include "trace/events/tgu.h" +#include "apss_tgu.h" + +static irqreturn_t tgu_irq_handler(int irq, void *data) +{ + trace_tgu_interrupt(irq); + return IRQ_HANDLED; +} + + +int register_interrupt_handler(struct device_node *node) +{ + int irq, ret, i, n; + + n = of_irq_count(node); + pr_debug("number of irqs == %d\n", n); + + for (i = 0; i < n; i++) { + irq = of_irq_get(node, i); + if (irq < 0) { + pr_err("Invalid IRQ for error fatal %u\n", irq); + return irq; + } + + ret = request_irq(irq, tgu_irq_handler, + IRQF_TRIGGER_RISING, "apps-tgu", NULL); + if (ret < 0) { + pr_err("Unable to register IRQ handler %d", irq); + continue; + } + + ret = irq_set_irq_wake(irq, true); + if (ret < 0) + pr_err("Unable to set as wakeup irq %d\n", irq); + + } + return 0; +} diff --git a/drivers/hwtracing/coresight/apss_tgu.h b/drivers/hwtracing/coresight/apss_tgu.h new file mode 100644 index 000000000000..a70bc5ddf983 --- /dev/null +++ b/drivers/hwtracing/coresight/apss_tgu.h @@ -0,0 +1,17 @@ +/* Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __QCOM_APSS_TGU_H__ +#define __QCOM_APSS_TGU_H__ + +int register_interrupt_handler(struct device_node *node); +#endif /* __QCOM_APSS_TGU_H__ */ diff --git a/drivers/hwtracing/coresight/coresight-tgu.c b/drivers/hwtracing/coresight/coresight-tgu.c index 607bc60f4b0e..8006e0faadc9 100644 --- a/drivers/hwtracing/coresight/coresight-tgu.c +++ b/drivers/hwtracing/coresight/coresight-tgu.c @@ -25,6 +25,7 @@ #include #include "coresight-priv.h" +#include "apss_tgu.h" #define tgu_writel(drvdata, val, off) __raw_writel((val), drvdata->base + off) #define tgu_readl(drvdata, off) __raw_readl(drvdata->base + off) @@ -415,6 +416,7 @@ static int tgu_probe(struct amba_device *adev, const struct amba_id *id) struct coresight_platform_data *pdata; struct tgu_drvdata *drvdata; struct coresight_desc *desc; + const char *name; pdata = of_get_coresight_platform_data(dev, adev->dev.of_node); if (IS_ERR(pdata)) @@ -504,6 +506,13 @@ static int tgu_probe(struct amba_device *adev, const struct amba_id *id) goto err; } + of_property_read_string(adev->dev.of_node, "coresight-name", &name); + if (!strcmp(name, "coresight-tgu-apss")) { + ret = register_interrupt_handler(adev->dev.of_node); + if (ret) + return ret; + } + pm_runtime_put(&adev->dev); dev_dbg(dev, "TGU initialized\n"); return 0; diff --git a/include/trace/events/tgu.h b/include/trace/events/tgu.h new file mode 100644 index 000000000000..1fd02aec88f4 --- /dev/null +++ b/include/trace/events/tgu.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM tgu + +#if !defined(_TRACE_TGU_) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TGU_H_ + +#include + +TRACE_EVENT(tgu_interrupt, + + TP_PROTO(uint32_t irqs), + + TP_ARGS(irqs), + + TP_STRUCT__entry( + __field(uint32_t, irqs) + ), + + TP_fast_assign( + __entry->irqs = irqs; + ), + + TP_printk("irq:%u ", __entry->irqs) +); + +#endif +#define TRACE_INCLUDE_FILE tgu +#include