diff options
Diffstat (limited to 'meta-xilinx-mali400/recipes-graphics/mali/kernel-module-mali/0011-linux-mali_kernel_linux.c-Enable-disable-clock-for-r.patch')
-rw-r--r-- | meta-xilinx-mali400/recipes-graphics/mali/kernel-module-mali/0011-linux-mali_kernel_linux.c-Enable-disable-clock-for-r.patch | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/meta-xilinx-mali400/recipes-graphics/mali/kernel-module-mali/0011-linux-mali_kernel_linux.c-Enable-disable-clock-for-r.patch b/meta-xilinx-mali400/recipes-graphics/mali/kernel-module-mali/0011-linux-mali_kernel_linux.c-Enable-disable-clock-for-r.patch new file mode 100644 index 00000000..38ab4042 --- /dev/null +++ b/meta-xilinx-mali400/recipes-graphics/mali/kernel-module-mali/0011-linux-mali_kernel_linux.c-Enable-disable-clock-for-r.patch | |||
@@ -0,0 +1,153 @@ | |||
1 | From aeff13ad9e9ef73172a9325f669aefd3c0403dbb Mon Sep 17 00:00:00 2001 | ||
2 | From: Madhurkiran Harikrishnan <madhurki@xilinx.com> | ||
3 | Date: Wed, 21 Feb 2018 16:52:15 -0800 | ||
4 | Subject: [PATCH] linux/mali_kernel_linux.c: Enable/disable clock for runtime | ||
5 | resume/suspend | ||
6 | |||
7 | Enable/Disable the clock for GP,PP0 and PP1 during runtime | ||
8 | resume/suspend. | ||
9 | |||
10 | Signed-off-by: Madhurkiran Harikrishnan <madhurki@xilinx.com> | ||
11 | Reviewed-by: Hyun Kwon <hyunk@xilinx.com> | ||
12 | Upstream Status: Inappropriate [Xilinx specific] | ||
13 | --- | ||
14 | .../src/devicedrv/mali/linux/mali_kernel_linux.c | 65 ++++++++++++++++++---- | ||
15 | 1 file changed, 54 insertions(+), 11 deletions(-) | ||
16 | |||
17 | diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c | ||
18 | index f15fb56..e61f33b 100644 | ||
19 | --- linux/mali_kernel_linux.c | ||
20 | +++ b/linux/mali_kernel_linux.c | ||
21 | @@ -51,6 +51,7 @@ | ||
22 | struct clk *clk_gpu; | ||
23 | struct clk *clk_gpu_pp0; | ||
24 | struct clk *clk_gpu_pp1; | ||
25 | +mali_bool clk_enabled; | ||
26 | #endif | ||
27 | |||
28 | #if defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_MALI_DVFS) | ||
29 | @@ -281,6 +282,46 @@ struct file_operations mali_fops = { | ||
30 | .mmap = mali_mmap | ||
31 | }; | ||
32 | |||
33 | +static int mali_enable_clk(void) | ||
34 | +{ | ||
35 | +#if defined(CONFIG_ARCH_ZYNQMP) | ||
36 | + int err = 0; | ||
37 | + | ||
38 | + if (clk_enabled) | ||
39 | + return 0; | ||
40 | + | ||
41 | + clk_enabled = MALI_TRUE; | ||
42 | + err = clk_prepare_enable(clk_gpu); | ||
43 | + if (err) { | ||
44 | + MALI_PRINT_ERROR(("Could not enable clock for GP\n\r")); | ||
45 | + return err; | ||
46 | + } | ||
47 | + err = clk_prepare_enable(clk_gpu_pp0); | ||
48 | + if (err) { | ||
49 | + MALI_PRINT_ERROR(("Could not enable clock for PP0\n\r")); | ||
50 | + return err; | ||
51 | + } | ||
52 | + err = clk_prepare_enable(clk_gpu_pp1); | ||
53 | + if (err) { | ||
54 | + MALI_PRINT_ERROR(("Could not enable clock for PP1\n\r")); | ||
55 | + return err; | ||
56 | + } | ||
57 | +#endif | ||
58 | + return 0; | ||
59 | +} | ||
60 | + | ||
61 | +static void mali_disable_clk(void) | ||
62 | +{ | ||
63 | +#if defined(CONFIG_ARCH_ZYNQMP) | ||
64 | + if (clk_enabled) { | ||
65 | + clk_enabled = MALI_FALSE; | ||
66 | + clk_disable_unprepare(clk_gpu); | ||
67 | + clk_disable_unprepare(clk_gpu_pp0); | ||
68 | + clk_disable_unprepare(clk_gpu_pp1); | ||
69 | + } | ||
70 | +#endif | ||
71 | +} | ||
72 | + | ||
73 | #if MALI_ENABLE_CPU_CYCLES | ||
74 | void mali_init_cpu_time_counters(int reset, int enable_divide_by_64) | ||
75 | { | ||
76 | @@ -593,18 +634,19 @@ static int mali_probe(struct platform_device *pdev) | ||
77 | clk_gpu = devm_clk_get(&pdev->dev, "gpu"); | ||
78 | if (IS_ERR(clk_gpu)) | ||
79 | return PTR_ERR(clk_gpu); | ||
80 | - clk_prepare_enable(clk_gpu); | ||
81 | |||
82 | clk_gpu_pp0 = devm_clk_get(&pdev->dev, "gpu_pp0"); | ||
83 | if (IS_ERR(clk_gpu_pp0)) | ||
84 | return PTR_ERR(clk_gpu_pp0); | ||
85 | - clk_prepare_enable(clk_gpu_pp0); | ||
86 | |||
87 | clk_gpu_pp1 = devm_clk_get(&pdev->dev, "gpu_pp1"); | ||
88 | if (IS_ERR(clk_gpu_pp1)) | ||
89 | return PTR_ERR(clk_gpu_pp1); | ||
90 | - clk_prepare_enable(clk_gpu_pp1); | ||
91 | #endif | ||
92 | + | ||
93 | + err = mali_enable_clk(); | ||
94 | + if (err) | ||
95 | + return err; | ||
96 | if (_MALI_OSK_ERR_OK == _mali_osk_wq_init()) { | ||
97 | /* Initialize the Mali GPU HW specified by pdev */ | ||
98 | if (_MALI_OSK_ERR_OK == mali_initialize_subsystems()) { | ||
99 | @@ -632,11 +674,6 @@ static int mali_probe(struct platform_device *pdev) | ||
100 | _mali_osk_wq_term(); | ||
101 | } | ||
102 | |||
103 | -#if defined(CONFIG_ARCH_ZYNQMP) | ||
104 | - clk_disable_unprepare(clk_gpu); | ||
105 | - clk_disable_unprepare(clk_gpu_pp0); | ||
106 | - clk_disable_unprepare(clk_gpu_pp1); | ||
107 | -#endif | ||
108 | |||
109 | #ifdef CONFIG_MALI_DEVFREQ | ||
110 | mali_devfreq_term(mdev); | ||
111 | @@ -644,6 +681,7 @@ devfreq_init_failed: | ||
112 | mali_pm_metrics_term(mdev); | ||
113 | pm_metrics_init_failed: | ||
114 | clk_disable_unprepare(mdev->clock); | ||
115 | + mali_disable_clk(); | ||
116 | clock_prepare_failed: | ||
117 | clk_put(mdev->clock); | ||
118 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_OF) \ | ||
119 | @@ -706,9 +744,7 @@ static int mali_remove(struct platform_device *pdev) | ||
120 | |||
121 | #if defined(CONFIG_ARCH_ZYNQMP) | ||
122 | /* Remove clock */ | ||
123 | - clk_disable_unprepare(clk_gpu); | ||
124 | - clk_disable_unprepare(clk_gpu_pp0); | ||
125 | - clk_disable_unprepare(clk_gpu_pp1); | ||
126 | + mali_disable_clk(); | ||
127 | #endif | ||
128 | |||
129 | return 0; | ||
130 | @@ -816,6 +852,8 @@ static int mali_driver_runtime_suspend(struct device *dev) | ||
131 | devfreq_suspend_device(mdev->devfreq); | ||
132 | #endif | ||
133 | |||
134 | + mali_disable_clk(); | ||
135 | + | ||
136 | return 0; | ||
137 | } else { | ||
138 | return -EBUSY; | ||
139 | @@ -824,6 +862,11 @@ static int mali_driver_runtime_suspend(struct device *dev) | ||
140 | |||
141 | static int mali_driver_runtime_resume(struct device *dev) | ||
142 | { | ||
143 | + int err ; | ||
144 | + | ||
145 | + err = mali_enable_clk(); | ||
146 | + if (err) | ||
147 | + return err; | ||
148 | #ifdef CONFIG_MALI_DEVFREQ | ||
149 | struct mali_device *mdev = dev_get_drvdata(dev); | ||
150 | if (!mdev) | ||
151 | -- | ||
152 | 2.7.4 | ||
153 | |||