From 9370bb92b2d16684ee45cf24e879c93c509162da Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Thu, 19 Dec 2024 01:47:39 +0000
Subject: [PATCH] add wifi6 8852be driver
---
kernel/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c | 72 +++++++++++++++++++----------------
1 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/kernel/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c b/kernel/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c
index 08df33d..534db25 100755
--- a/kernel/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c
+++ b/kernel/drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c
@@ -31,6 +31,7 @@
#include <linux/clk.h>
#include <linux/regulator/consumer.h>
#include <linux/mali/mali_utgard.h>
+#include <linux/pm_runtime.h>
#include <soc/rockchip/rockchip_opp_select.h>
#include "mali_kernel_common.h"
@@ -177,11 +178,7 @@
static int mali_open(struct inode *inode, struct file *filp);
static int mali_release(struct inode *inode, struct file *filp);
-#ifdef HAVE_UNLOCKED_IOCTL
static long mali_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
-#else
-static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
-#endif
static int mali_probe(struct platform_device *pdev);
static int mali_remove(struct platform_device *pdev);
@@ -275,11 +272,7 @@
.owner = THIS_MODULE,
.open = mali_open,
.release = mali_release,
-#ifdef HAVE_UNLOCKED_IOCTL
.unlocked_ioctl = mali_ioctl,
-#else
- .ioctl = mali_ioctl,
-#endif
.compat_ioctl = mali_ioctl,
.mmap = mali_mmap
};
@@ -521,6 +514,7 @@
int err;
#ifdef CONFIG_MALI_DEVFREQ
struct mali_device *mdev;
+ const char *name = "mali";
#endif
MALI_DEBUG_PRINT(2, ("mali_probe(): Called for platform device %s\n", pdev->name));
@@ -575,25 +569,38 @@
mdev->regulator = NULL;
/* Allow probe to continue without regulator */
}
+ if (mdev->regulator) {
+ mdev->opp_table = dev_pm_opp_set_regulators(mdev->dev, &name, 1);
+ if (IS_ERR(mdev->opp_table)) {
+ mdev->opp_table = NULL;
+ MALI_DEBUG_PRINT(2, ("Continuing without opp regulator\n"));
+ }
+ }
#endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
+
+ mdev->num_clks = devm_clk_bulk_get_all(mdev->dev, &mdev->clks);
+ if (mdev->num_clks < 1) {
+ MALI_DEBUG_PRINT(2, ("Continuing without Mali clock control\n"));
+ mdev->num_clks = 0;
+ mdev->clock = NULL;
+ } else {
+ /* Get "clk_mali" in the device tree for gpu dvfs */
+ mdev->clock = clk_get(mdev->dev, "clk_mali");
+ if (IS_ERR_OR_NULL(mdev->clock)) {
+ MALI_DEBUG_PRINT(2, ("Continuing without Mali dvfs clock\n"));
+ /* Allow probe to continue without clock. */
+ mdev->clock = NULL;
+ }
+ }
+ err = clk_bulk_prepare_enable(mdev->num_clks, mdev->clks);
+ if (err) {
+ MALI_PRINT_ERROR(("Failed to prepare clock (%d)\n", err));
+ goto clock_prepare_failed;
+ }
err = rk_platform_init_opp_table(mdev->dev);
if (err)
MALI_DEBUG_PRINT(3, ("Failed to init_opp_table\n"));
-
- /* Need to name the gpu clock "clk_mali" in the device tree */
- mdev->clock = clk_get(mdev->dev, "clk_mali");
- if (IS_ERR_OR_NULL(mdev->clock)) {
- MALI_DEBUG_PRINT(2, ("Continuing without Mali clock control\n"));
- mdev->clock = NULL;
- /* Allow probe to continue without clock. */
- } else {
- err = clk_prepare(mdev->clock);
- if (err) {
- MALI_PRINT_ERROR(("Failed to prepare clock (%d)\n", err));
- goto clock_prepare_failed;
- }
- }
/* initilize pm metrics related */
if (mali_pm_metrics_init(mdev) < 0) {
@@ -605,6 +612,7 @@
MALI_DEBUG_PRINT(2, ("mali devfreq init failed\n"));
goto devfreq_init_failed;
}
+ clk_bulk_disable(mdev->num_clks, mdev->clks);
#endif
@@ -640,8 +648,9 @@
devfreq_init_failed:
mali_pm_metrics_term(mdev);
pm_metrics_init_failed:
- clk_unprepare(mdev->clock);
+ clk_bulk_disable_unprepare(mdev->num_clks, mdev->clks);
clock_prepare_failed:
+ clk_bulk_put(mdev->num_clks, mdev->clks);
clk_put(mdev->clock);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_OF) \
&& defined(CONFIG_PM_OPP)
@@ -651,6 +660,7 @@
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) && defined(CONFIG_OF) \
&& defined(CONFIG_REGULATOR)
regulator_put(mdev->regulator);
+ dev_pm_opp_put_regulators(mdev->opp_table);
#endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
mali_device_free(mdev);
#endif
@@ -680,10 +690,12 @@
mali_pm_metrics_term(mdev);
if (mdev->clock) {
- clk_unprepare(mdev->clock);
clk_put(mdev->clock);
mdev->clock = NULL;
}
+ clk_bulk_unprepare(mdev->num_clks, mdev->clks);
+ clk_bulk_put(mdev->num_clks, mdev->clks);
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_OF) \
&& defined(CONFIG_PM_OPP)
dev_pm_opp_of_remove_table(mdev->dev);
@@ -692,6 +704,7 @@
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) && defined(CONFIG_OF) \
&& defined(CONFIG_REGULATOR)
regulator_put(mdev->regulator);
+ dev_pm_opp_put_regulators(mdev->opp_table);
#endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
mali_device_free(mdev);
#endif
@@ -733,6 +746,7 @@
return -ENODEV;
#endif
+ pm_runtime_force_suspend(dev);
#if defined(CONFIG_MALI_DEVFREQ) && \
(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
devfreq_suspend_device(mdev->devfreq);
@@ -777,6 +791,7 @@
(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
devfreq_resume_device(mdev->devfreq);
#endif
+ pm_runtime_force_resume(dev);
return 0;
}
@@ -917,19 +932,10 @@
}
}
-#ifdef HAVE_UNLOCKED_IOCTL
static long mali_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-#else
-static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
-#endif
{
int err;
struct mali_session_data *session_data;
-
-#ifndef HAVE_UNLOCKED_IOCTL
- /* inode not used */
- (void)inode;
-#endif
MALI_DEBUG_PRINT(7, ("Ioctl received 0x%08X 0x%08lX\n", cmd, arg));
--
Gitblit v1.6.2