summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2022-06-13 18:06:36 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2022-06-13 18:06:36 +0800
commitfbe83d4594ab7b97089f2f97ce204b1c9643a5e5 (patch)
treed9d990e2bbd54bd65cf909b5dab9dadd9e05b223
parent7fa64adc3b5dfe6d84e7e4885bc4a505ebf7088b (diff)
downloadhikey-modules-fbe83d4594ab7b97089f2f97ce204b1c9643a5e5.tar.gz
mali_kbase_core_linux.c: switched to platform_get_irq_byname
After the followig commit[1]: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core") Otherwise the mali ko file will be failed to installed, with errors like the following: 01-01 00:18:05.711 197 197 E mali e82c0000.mali: No IRQ resource at index 0 01-01 00:18:05.732 197 197 E mali e82c0000.mali: IRQ search failed 01-01 00:18:05.746 197 197 W mali : probe of e82c0000.mali failed with error -2 01-01 00:20:12.840 2860 2864 E mali : Failed creating base context during opening of kernel driver. 01-01 00:20:12.840 2860 2864 E mali : Kernel module may not have been loaded And that causes the Android build failed to boot This change refered to this commit[2] with the use of irq_get_trigger_type. [1]: https://lore.kernel.org/all/20220316200633.28974-1-prabhakar.mahadev-lad.rj@bp.renesas.com/ [2]: https://www.spinics.net/lists/linux-renesas-soc/msg62775.html Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org> Change-Id: Ic5eb6a54b899890ca027a6e0efc4538f15736768
-rw-r--r--midgard/mali_kbase_core_linux.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/midgard/mali_kbase_core_linux.c b/midgard/mali_kbase_core_linux.c
index f003655..f5d4044 100644
--- a/midgard/mali_kbase_core_linux.c
+++ b/midgard/mali_kbase_core_linux.c
@@ -60,6 +60,7 @@
#include <linux/errno.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/miscdevice.h>
#include <linux/list.h>
@@ -182,6 +183,14 @@ static struct kbase_device *to_kbase_device(struct device *dev)
{
return dev_get_drvdata(dev);
}
+/*
+ * Number of IRQ resources supported by the MALI
+ */
+#define MALI_IRQS_NUM 3
+
+static const char * const irq_names[MALI_IRQS_NUM] = {
+ "JOB", "MMU", "GPU",
+};
static int assign_irqs(struct platform_device *pdev)
{
@@ -192,33 +201,50 @@ static int assign_irqs(struct platform_device *pdev)
return -ENODEV;
/* 3 IRQ resources */
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < MALI_IRQS_NUM; i++) {
+ int irqtag, irqflags;
+ const char *irq_name;
+ int irq_start;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0))
+ int irq;
+ irq = platform_get_irq_byname(pdev, irq_names[i]);
+ if (irq <= 0) {
+ dev_err(kbdev->dev, "No IRQ defined as %s\n", irq_names[i]);
+ return -ENOENT;
+ }
+ irq_start = irq;
+ irq_name = irq_names[i];
+ irqflags = irq_get_trigger_type(irq);
+#else
struct resource *irq_res;
- int irqtag;
-
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
if (!irq_res) {
dev_err(kbdev->dev, "No IRQ resource at index %d\n", i);
return -ENOENT;
}
+ irq_start = irq_res->start;
+ irq_name = irq_res->name;
+ irqflags = irq_res->flags & IRQF_TRIGGER_MASK;
+#endif
#ifdef CONFIG_OF
- if (!strncmp(irq_res->name, "JOB", 4)) {
+ if (!strncmp(irq_name, "JOB", 4)) {
irqtag = JOB_IRQ_TAG;
- } else if (!strncmp(irq_res->name, "MMU", 4)) {
+ } else if (!strncmp(irq_name, "MMU", 4)) {
irqtag = MMU_IRQ_TAG;
- } else if (!strncmp(irq_res->name, "GPU", 4)) {
+ } else if (!strncmp(irq_name, "GPU", 4)) {
irqtag = GPU_IRQ_TAG;
} else {
dev_err(&pdev->dev, "Invalid irq res name: '%s'\n",
- irq_res->name);
+ irq_name);
return -EINVAL;
}
#else
irqtag = i;
#endif /* CONFIG_OF */
- kbdev->irqs[irqtag].irq = irq_res->start;
- kbdev->irqs[irqtag].flags = irq_res->flags & IRQF_TRIGGER_MASK;
+ kbdev->irqs[irqtag].irq = irq_start;
+ kbdev->irqs[irqtag].flags = irqflags;
}
return 0;