summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/hal/os/linux/kernel/platform/ti/gc_hal_kernel_platform_j6.c')
-rwxr-xr-xsrc/hal/os/linux/kernel/platform/ti/gc_hal_kernel_platform_j6.c253
1 files changed, 253 insertions, 0 deletions
diff --git a/src/hal/os/linux/kernel/platform/ti/gc_hal_kernel_platform_j6.c b/src/hal/os/linux/kernel/platform/ti/gc_hal_kernel_platform_j6.c
new file mode 100755
index 0000000..e760bb6
--- /dev/null
+++ b/src/hal/os/linux/kernel/platform/ti/gc_hal_kernel_platform_j6.c
@@ -0,0 +1,253 @@
1/****************************************************************************
2*
3* The MIT License (MIT)
4*
5* Copyright (c) 2014 Vivante Corporation
6*
7* Permission is hereby granted, free of charge, to any person obtaining a
8* copy of this software and associated documentation files (the "Software"),
9* to deal in the Software without restriction, including without limitation
10* the rights to use, copy, modify, merge, publish, distribute, sublicense,
11* and/or sell copies of the Software, and to permit persons to whom the
12* Software is furnished to do so, subject to the following conditions:
13*
14* The above copyright notice and this permission notice shall be included in
15* all copies or substantial portions of the Software.
16*
17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23* DEALINGS IN THE SOFTWARE.
24*
25*****************************************************************************
26*
27* The GPL License (GPL)
28*
29* Copyright (C) 2014 Vivante Corporation
30*
31* This program is free software; you can redistribute it and/or
32* modify it under the terms of the GNU General Public License
33* as published by the Free Software Foundation; either version 2
34* of the License, or (at your option) any later version.
35*
36* This program is distributed in the hope that it will be useful,
37* but WITHOUT ANY WARRANTY; without even the implied warranty of
38* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39* GNU General Public License for more details.
40*
41* You should have received a copy of the GNU General Public License
42* along with this program; if not, write to the Free Software Foundation,
43* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
44*
45*****************************************************************************
46*
47* Note: This software is released under dual MIT and GPL licenses. A
48* recipient may use this file under the terms of either the MIT license or
49* GPL License. If you wish to use only one license not the other, you can
50* indicate your decision by deleting one of the above license notices in your
51* version of this file.
52*
53*****************************************************************************/
54
55
56#include "gc_hal_kernel_linux.h"
57#include "gc_hal_kernel_platform.h"
58
59#include <linux/pm_runtime.h>
60#include <linux/delay.h>
61#include <linux/io.h>
62#include <linux/of.h>
63#include <linux/of_device.h>
64
65/*
66 * GC320 platform data struct, using the definition as in
67 * `linux/platform_data/omap_gcx.h` in k3.8
68 *
69 * TODO: revisit this and tune it as per latest requirements
70 */
71struct omap_gcx_platform_data {
72 bool is_hw_present;
73 void *regbase;
74 /*bool (*was_context_lost)(struct device *dev);*/
75 int (*get_context_loss_count)(struct device *dev);
76 /* device scale */
77 int (*scale_dev)(struct device *dev, unsigned long freq);
78 /* bandwidth */
79 int (*set_bw)(struct device *dev, unsigned long v);
80};
81
82static int gcxxx_get_context_loss_count(struct device *dev)
83{
84 /*
85 omap_pm_get_context_loss_count not supported:
86 returning with default 1
87 */
88 return 1;
89}
90static int gcxxx_scale_dev(struct device *dev, unsigned long val)
91{
92 /*omap_device_scale(dev, val) is not supported, returning with no-op
93 * for now. */
94 return 0;
95}
96
97static int gcxxx_set_l3_bw(struct device *dev, unsigned long val)
98{
99 return 0; /*omap_pm_set_min_bus_tput(dev, OCP_INITIATOR_AGENT, val);*/
100}
101static struct omap_gcx_platform_data omap_gcxxx = {
102 .get_context_loss_count = gcxxx_get_context_loss_count,
103 .scale_dev = gcxxx_scale_dev,
104 .set_bw = gcxxx_set_l3_bw,
105};
106
107
108
109static const struct of_device_id bb2d_of_match[] = {
110 {
111 .compatible = "ti,dra7-bb2d",
112 .data = &omap_gcxxx,
113 },
114 {},
115};
116
117
118static gctBOOL
119_NeedAddDevice(
120 IN gckPLATFORM Platform
121 )
122{
123 /*
124 * platform_device is registered through DTS framework, we dont need to
125 * register explicitly, return false here.
126 */
127 return gcvFALSE;
128}
129
130/* override J6 specific fields of `platform_driver` */
131static gceSTATUS
132_AdjustDriver(
133 IN gckPLATFORM Platform
134 )
135{
136 struct platform_driver * driver = Platform->driver;
137
138 /* return DTS match entry */
139 driver->driver.of_match_table = bb2d_of_match;
140
141 return gcvSTATUS_TRUE;
142}
143
144/* prepare clock and power operations */
145static gceSTATUS
146_GetPower(
147 IN gckPLATFORM Platform
148 )
149{
150 struct platform_device *pdev;
151 pdev = Platform->device;
152
153 pm_runtime_enable(&pdev->dev);
154 pm_runtime_get_sync(&pdev->dev);
155
156 return gcvSTATUS_TRUE;
157}
158
159/* finish clock and power operations */
160static gceSTATUS
161_PutPower(
162 IN gckPLATFORM Platform
163 )
164{
165 struct platform_device *pdev;
166 pdev = Platform->device;
167
168 pm_runtime_put_sync(&pdev->dev);
169 pm_runtime_disable(&pdev->dev);
170
171 return gcvSTATUS_TRUE;
172}
173
174/*
175 * AdjustParam - override default/passed in module arguments.
176 *
177 * Here we modify/update IRQ and register address entries by querying through
178 * DTS framework.
179 */
180static gceSTATUS
181_AdjustParam(
182 IN gckPLATFORM Platform,
183 OUT gcsMODULE_PARAMETERS *Args
184 )
185{
186 struct resource *res_ptr = NULL;
187
188 struct omap_gcx_platform_data *plat;
189 struct of_device_id *match;
190 struct platform_device *pdev;
191 int dev_irq;
192
193 if (Args->registerMemMapped)
194 return gcvSTATUS_TRUE;
195
196 pdev = Platform->device;
197
198 match = (struct of_device_id *)of_match_device(of_match_ptr(bb2d_of_match), &pdev->dev);
199
200 if (match) {
201 plat = (struct omap_gcx_platform_data *) match->data;
202 plat->is_hw_present = (of_machine_is_compatible("ti, omap54xx") || of_machine_is_compatible("ti,dra7"));
203 } else {
204 /* platform_device registration */
205 plat = (struct omap_gcx_platform_data *)dev_get_platdata(&pdev->dev);
206 }
207
208 if ( !plat->is_hw_present )
209 return gcvSTATUS_FALSE;
210
211 res_ptr = platform_get_resource(pdev, IORESOURCE_MEM, 0);
212 if (!res_ptr) {
213 return gcvSTATUS_FALSE;
214 }
215 /* map the address space */
216 Args->registerMemAddress = (gctPOINTER)devm_ioremap_resource(&pdev->dev, res_ptr);
217 Args->registerMemMapped = gcvTRUE;
218
219 /*
220 * IRQ line is acquired through commandline argument with unified driver.
221 * With k3.14, the MPU IRQ line in J6 is configured dynamically at runtime
222 * per dtb configuration and has to be queried through `platform_get_irq()`
223 * API.
224 */
225 dev_irq = platform_get_irq(pdev, 0);
226 if (dev_irq < 0) {
227 /* TODO: use Vivante debug prints */
228 printk(KERN_ERR "%s: platform_get_irq failed (%d)\n",
229 __FUNCTION__, -dev_irq);
230 return -EINVAL;
231 }
232 printk(KERN_INFO "GC320 IRQ: %d\n", dev_irq);
233 Args->irqLine = dev_irq;
234
235 return gcvSTATUS_TRUE;
236}
237
238gcsPLATFORM_OPERATIONS platformOperations =
239{
240 .adjustParam = _AdjustParam,
241 .adjustDriver = _AdjustDriver,
242 .needAddDevice = _NeedAddDevice,
243 .getPower = _GetPower,
244 .putPower = _PutPower,
245};
246
247void
248gckPLATFORM_QueryOperations(
249 IN gcsPLATFORM_OPERATIONS ** Operations
250 )
251{
252 *Operations = &platformOperations;
253}