summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-kernel/linux/linux-ti-staging-4.1/0001-DT-gpu-add-binding-for-TI-SGX-driver.patch52
-rw-r--r--recipes-kernel/linux/linux-ti-staging-4.1/0002-ARM-dts-DRA7xx-add-device-tree-entry-for-SGX.patch37
-rw-r--r--recipes-kernel/linux/linux-ti-staging-4.1/0003-arm-dra7xx-Add-gpu-hwmod-data.patch85
-rw-r--r--recipes-kernel/linux/linux-ti-staging-4.1/0004-drm-omap-Add-omapdrm-plugin-API.patch585
-rw-r--r--recipes-kernel/linux/linux-ti-staging-4.1/sgx.cfg1
-rw-r--r--recipes-kernel/linux/linux-ti-staging_4.1.bb25
6 files changed, 14 insertions, 771 deletions
diff --git a/recipes-kernel/linux/linux-ti-staging-4.1/0001-DT-gpu-add-binding-for-TI-SGX-driver.patch b/recipes-kernel/linux/linux-ti-staging-4.1/0001-DT-gpu-add-binding-for-TI-SGX-driver.patch
deleted file mode 100644
index 00628a6c..00000000
--- a/recipes-kernel/linux/linux-ti-staging-4.1/0001-DT-gpu-add-binding-for-TI-SGX-driver.patch
+++ /dev/null
@@ -1,52 +0,0 @@
1From 4b375ae644830ea38d8bfc1c78da6d83628527ea Mon Sep 17 00:00:00 2001
2From: Anand Balagopalakrishnan <anandb@ti.com>
3Date: Wed, 26 Aug 2015 09:34:49 +0000
4Subject: [PATCH 1/8] DT: gpu: add binding for TI SGX driver
5
6This patch adds the devicetree binding for TI SGX device driver.
7
8Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
9---
10 Documentation/devicetree/bindings/gpu/ti-sgx.txt | 30 ++++++++++++++++++++++++
11 1 file changed, 30 insertions(+)
12 create mode 100644 Documentation/devicetree/bindings/gpu/ti-sgx.txt
13
14diff --git a/Documentation/devicetree/bindings/gpu/ti-sgx.txt b/Documentation/devicetree/bindings/gpu/ti-sgx.txt
15new file mode 100644
16index 0000000..6b7886a
17--- /dev/null
18+++ b/Documentation/devicetree/bindings/gpu/ti-sgx.txt
19@@ -0,0 +1,30 @@
20+TI SGX 3D Graphics Accelerator
21+
22+Required properties:
23+ - compatible : value should take the following format:
24+ "ti,<soc>-<gpuversion>", "img,<gpuversion>"
25+
26+ accepted values:
27+ (a) "ti,dra7-sgx544", "img,sgx544" for TI DRA7xx / AM57x
28+ (b) "ti,am4-sgx530", "img,sgx530" for TI AM43x
29+ (c) "ti,am3-sgx530", "img,sgx530" for TI AM33x
30+ - reg: base address and length of the SGX registers
31+ - interrupts : SGX interrupt number
32+
33+Optional properties:
34+ - ti,hwmods: Name of the hwmod associated with the SGX
35+ - clocks : from SoC clock binding
36+ - clock-names : names of clocks listed in clocks property in the same order
37+ - reg-names : names of registers listed in reg property in same order
38+
39+Example:
40+ sgx@0x56000000 {
41+ compatible = "ti,dra7-sgx544", "img,sgx544";
42+ reg = <0x5600fe00 0x200>;
43+ reg-names = "gpu_wrapper";
44+ interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
45+ ti,hwmods = "gpu";
46+ clocks = <&l3_iclk_div>, <&gpu_core_gclk_mux>,
47+ <&gpu_hyd_gclk_mux>;
48+ clock-names = "gpu_iclk", "gpu_fclk1", "gpu_fclk2";
49+ };
50--
512.2.0
52
diff --git a/recipes-kernel/linux/linux-ti-staging-4.1/0002-ARM-dts-DRA7xx-add-device-tree-entry-for-SGX.patch b/recipes-kernel/linux/linux-ti-staging-4.1/0002-ARM-dts-DRA7xx-add-device-tree-entry-for-SGX.patch
deleted file mode 100644
index ca84e279..00000000
--- a/recipes-kernel/linux/linux-ti-staging-4.1/0002-ARM-dts-DRA7xx-add-device-tree-entry-for-SGX.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From f3a4651fef3c51a0ec30f321352dc26273eb56d4 Mon Sep 17 00:00:00 2001
2From: Anand Balagopalakrishnan <anandb@ti.com>
3Date: Wed, 26 Aug 2015 09:34:50 +0000
4Subject: [PATCH 2/8] ARM: dts: DRA7xx: add device tree entry for SGX
5
6Addition of SGX to DRA7xx DTS to enable graphics support.
7
8Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
9---
10 arch/arm/boot/dts/dra7.dtsi | 11 +++++++++++
11 1 file changed, 11 insertions(+)
12
13diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
14index ce10ce3..c117ed0 100644
15--- a/arch/arm/boot/dts/dra7.dtsi
16+++ b/arch/arm/boot/dts/dra7.dtsi
17@@ -889,6 +889,17 @@
18 status = "disabled";
19 };
20
21+ sgx: sgx@0x56000000 {
22+ compatible = "ti,dra7-sgx544", "img,sgx544";
23+ reg = <0x5600fe00 0x200>;
24+ reg-names = "gpu_wrapper";
25+ interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
26+ ti,hwmods = "gpu";
27+ clocks = <&l3_iclk_div>, <&gpu_core_gclk_mux>,
28+ <&gpu_hyd_gclk_mux>;
29+ clock-names = "gpu_iclk", "gpu_fclk1", "gpu_fclk2";
30+ };
31+
32 i2c1: i2c@48070000 {
33 compatible = "ti,omap4-i2c";
34 reg = <0x48070000 0x100>;
35--
362.2.0
37
diff --git a/recipes-kernel/linux/linux-ti-staging-4.1/0003-arm-dra7xx-Add-gpu-hwmod-data.patch b/recipes-kernel/linux/linux-ti-staging-4.1/0003-arm-dra7xx-Add-gpu-hwmod-data.patch
deleted file mode 100644
index 7c74b243..00000000
--- a/recipes-kernel/linux/linux-ti-staging-4.1/0003-arm-dra7xx-Add-gpu-hwmod-data.patch
+++ /dev/null
@@ -1,85 +0,0 @@
1From 7d96508055ba60029f6fc7a3f8603f2f2630a667 Mon Sep 17 00:00:00 2001
2From: Hemant Hariyani <hemanthariyani@ti.com>
3Date: Wed, 26 Aug 2015 09:34:51 +0000
4Subject: [PATCH 3/8] arm:dra7xx: Add gpu hwmod data
5
6GPU hwmod data for DRA7xx
7
8Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
9Signed-off-by: Gowtham Tammana <g-tammana@ti.com>
10Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
11---
12 arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 43 +++++++++++++++++++++++++++++++
13 1 file changed, 43 insertions(+)
14
15diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
16index 0641f03..03982b7 100644
17--- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
18+++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
19@@ -1318,6 +1318,40 @@ static struct omap_hwmod dra7xx_gpmc_hwmod = {
20 };
21
22 /*
23+ * 'gpu' class
24+ * 3d graphics accelerator
25+ */
26+
27+static struct omap_hwmod_class_sysconfig dra7xx_gpu_sysc = {
28+ .rev_offs = 0x0000,
29+ .sysc_offs = 0x0010,
30+ .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE),
31+ .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
32+ SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
33+ MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
34+ .sysc_fields = &omap_hwmod_sysc_type2,
35+};
36+
37+static struct omap_hwmod_class dra7xx_gpu_hwmod_class = {
38+ .name = "gpu",
39+ .sysc = &dra7xx_gpu_sysc,
40+};
41+
42+static struct omap_hwmod dra7xx_gpu_hwmod = {
43+ .name = "gpu",
44+ .class = &dra7xx_gpu_hwmod_class,
45+ .clkdm_name = "gpu_clkdm",
46+ .main_clk = "gpu_core_gclk_mux",
47+ .prcm = {
48+ .omap4 = {
49+ .clkctrl_offs = DRA7XX_CM_GPU_GPU_CLKCTRL_OFFSET,
50+ .context_offs = DRA7XX_RM_GPU_GPU_CONTEXT_OFFSET,
51+ .modulemode = MODULEMODE_SWCTRL,
52+ },
53+ },
54+};
55+
56+/*
57 * 'hdq1w' class
58 *
59 */
60@@ -3686,6 +3720,14 @@ static struct omap_hwmod_ocp_if dra7xx_l3_main_1__gpmc = {
61 .user = OCP_USER_MPU | OCP_USER_SDMA,
62 };
63
64+/* l3_main_1 -> gpu */
65+static struct omap_hwmod_ocp_if dra7xx_l3_main_1__gpu = {
66+ .master = &dra7xx_l3_main_1_hwmod,
67+ .slave = &dra7xx_gpu_hwmod,
68+ .clk = "l3_iclk_div",
69+ .user = OCP_USER_MPU | OCP_USER_SDMA,
70+};
71+
72 static struct omap_hwmod_addr_space dra7xx_hdq1w_addrs[] = {
73 {
74 .pa_start = 0x480b2000,
75@@ -4461,6 +4503,7 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] __initdata = {
76 &dra7xx_l4_per1__gpio7,
77 &dra7xx_l4_per1__gpio8,
78 &dra7xx_l3_main_1__gpmc,
79+ &dra7xx_l3_main_1__gpu,
80 &dra7xx_l4_per1__hdq1w,
81 &dra7xx_l4_per1__i2c1,
82 &dra7xx_l4_per1__i2c2,
83--
842.2.0
85
diff --git a/recipes-kernel/linux/linux-ti-staging-4.1/0004-drm-omap-Add-omapdrm-plugin-API.patch b/recipes-kernel/linux/linux-ti-staging-4.1/0004-drm-omap-Add-omapdrm-plugin-API.patch
deleted file mode 100644
index e09325ab..00000000
--- a/recipes-kernel/linux/linux-ti-staging-4.1/0004-drm-omap-Add-omapdrm-plugin-API.patch
+++ /dev/null
@@ -1,585 +0,0 @@
1From 931f19bb07833a342e1d87785e989f4609825927 Mon Sep 17 00:00:00 2001
2From: Rob Clark <rob@ti.com>
3Date: Wed, 26 Aug 2015 09:34:52 +0000
4Subject: [PATCH 4/8] drm/omap: Add omapdrm plugin API
5
6This patch enables SGX driver to be added as a plugin to omapdrm.
7
8Main changes involved:
9
101. SGX specific GEM VM operations
11 SGX requires contiguous memory for both texture memory as well as
12 framebuffers. Memory allocation of FB is done through GEM and is
13 guaranteed to be contiguous.
14
15 Texture memory can be non-contiguous if:
16 a. user space allocates memory
17 b. memory is allocated by other cores
18 c. memory comes from CMA
19
20 We want to wrap such memory regions as GEM objects so that the graphics
21 pipeline remains consistent.
22
232. Support for ioctls from plugin driver
24 SGX driver registers as a plugin to the omapdrm driver. During
25 registration, SGX specific ioctls are added to omapdrm. This allows
26 user space to control specific SGX feature sets using the DRM FD.
27
283. Make GEM operations public
29 SGX driver needs to work directly on GEM objects for DSS
30 synchronization, getting Tiler address, etc.
31
32Signed-off-by: Rob Clark <rob@ti.com>
33Signed-off-by: Subhajit Paul <subhajit_paul@ti.com>
34Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
35Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
36---
37 drivers/gpu/drm/omapdrm/omap_drv.c | 125 +++++++++++++++++++++++++++++++++++--
38 drivers/gpu/drm/omapdrm/omap_drv.h | 60 ++++++++++++++++--
39 drivers/gpu/drm/omapdrm/omap_gem.c | 90 ++++++++++++++++++++++++++
40 include/uapi/drm/omap_drm.h | 10 +--
41 4 files changed, 270 insertions(+), 15 deletions(-)
42
43diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
44index ea537a5..00876c7 100644
45--- a/drivers/gpu/drm/omapdrm/omap_drv.c
46+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
47@@ -34,11 +34,20 @@
48 #define DRIVER_MINOR 0
49 #define DRIVER_PATCHLEVEL 0
50
51+struct drm_device *drm_device;
52+
53 static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS;
54
55 MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs");
56 module_param(num_crtc, int, 0600);
57
58+static struct omap_drm_plugin *sgx_plugin;
59+
60+/* keep track of whether we are already loaded.. we may need to call
61+ * plugin's load() if they register after we are already loaded
62+ */
63+static bool loaded;
64+
65 /*
66 * mode config funcs
67 */
68@@ -615,6 +624,19 @@ static int ioctl_set_param(struct drm_device *dev, void *data,
69 return 0;
70 }
71
72+static int ioctl_get_base(struct drm_device *dev, void *data,
73+ struct drm_file *file_priv)
74+{
75+ struct drm_omap_get_base *args = data;
76+
77+ if (!sgx_plugin)
78+ return -ENODEV;
79+
80+ args->ioctl_base = sgx_plugin->ioctl_base;
81+
82+ return 0;
83+}
84+
85 static int ioctl_gem_new(struct drm_device *dev, void *data,
86 struct drm_file *file_priv)
87 {
88@@ -693,9 +715,10 @@ static int ioctl_gem_info(struct drm_device *dev, void *data,
89 return ret;
90 }
91
92-static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
93+static struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
94 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_UNLOCKED|DRM_AUTH),
95 DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
96+ DRM_IOCTL_DEF_DRV(OMAP_GET_BASE, ioctl_get_base, DRM_UNLOCKED|DRM_AUTH),
97 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH),
98 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
99 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
100@@ -725,6 +748,8 @@ static int dev_load(struct drm_device *dev, unsigned long flags)
101
102 DBG("load: dev=%p", dev);
103
104+ drm_device = dev;
105+
106 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
107 if (!priv)
108 return -ENOMEM;
109@@ -770,6 +795,11 @@ static int dev_load(struct drm_device *dev, unsigned long flags)
110
111 drm_kms_helper_poll_init(dev);
112
113+ loaded = true;
114+
115+ if (sgx_plugin)
116+ sgx_plugin->load(dev, flags);
117+
118 return 0;
119 }
120
121@@ -779,6 +809,9 @@ static int dev_unload(struct drm_device *dev)
122
123 DBG("unload: dev=%p", dev);
124
125+ if (sgx_plugin)
126+ sgx_plugin->unload(dev);
127+
128 drm_kms_helper_poll_fini(dev);
129
130 if (priv->fbdev)
131@@ -797,15 +830,18 @@ static int dev_unload(struct drm_device *dev)
132
133 dev_set_drvdata(dev->dev, NULL);
134
135+ loaded = false;
136+
137 return 0;
138 }
139
140 static int dev_open(struct drm_device *dev, struct drm_file *file)
141 {
142- file->driver_priv = NULL;
143-
144 DBG("open: dev=%p, file=%p", dev, file);
145
146+ if (sgx_plugin)
147+ sgx_plugin->open(dev, file);
148+
149 return 0;
150 }
151
152@@ -862,6 +898,9 @@ static void dev_preclose(struct drm_device *dev, struct drm_file *file)
153
154 DBG("preclose: dev=%p", dev);
155
156+ if (sgx_plugin)
157+ sgx_plugin->release(dev, file);
158+
159 /*
160 * Unlink all pending CRTC events to make sure they won't be queued up
161 * by a pending asynchronous commit.
162@@ -874,6 +913,8 @@ static void dev_preclose(struct drm_device *dev, struct drm_file *file)
163 }
164 }
165 spin_unlock_irqrestore(&dev->event_lock, flags);
166+
167+ kfree(file->driver_priv);
168 }
169
170 static void dev_postclose(struct drm_device *dev, struct drm_file *file)
171@@ -883,8 +924,8 @@ static void dev_postclose(struct drm_device *dev, struct drm_file *file)
172
173 static const struct vm_operations_struct omap_gem_vm_ops = {
174 .fault = omap_gem_fault,
175- .open = drm_gem_vm_open,
176- .close = drm_gem_vm_close,
177+ .open = omap_gem_vm_open,
178+ .close = omap_gem_vm_close,
179 };
180
181 static const struct file_operations omapdriver_fops = {
182@@ -934,6 +975,80 @@ static struct drm_driver omap_drm_driver = {
183 .patchlevel = DRIVER_PATCHLEVEL,
184 };
185
186+int omap_drm_register_plugin(struct omap_drm_plugin *plugin)
187+{
188+ struct drm_device *dev = drm_device;
189+ int i;
190+
191+ DBG("register plugin: %p (%s)", plugin, plugin->name);
192+
193+ if (sgx_plugin)
194+ return -EBUSY;
195+
196+ for (i = 0; i < plugin->num_ioctls; i++) {
197+ int nr = i + DRM_OMAP_NUM_IOCTLS;
198+
199+ /* check for out of bounds ioctl or already registered ioctl */
200+ if (nr > ARRAY_SIZE(ioctls) || ioctls[nr].func) {
201+ dev_err(dev->dev, "invalid ioctl: %d (nr=%d)\n", i, nr);
202+ return -EINVAL;
203+ }
204+ }
205+
206+ plugin->ioctl_base = DRM_OMAP_NUM_IOCTLS;
207+
208+ /* register the plugin's ioctl's */
209+ for (i = 0; i < plugin->num_ioctls; i++) {
210+ int nr = i + DRM_OMAP_NUM_IOCTLS;
211+
212+ DBG("register ioctl: %d %08x", nr, plugin->ioctls[i].cmd);
213+
214+ ioctls[nr] = plugin->ioctls[i];
215+ }
216+
217+ omap_drm_driver.num_ioctls = DRM_OMAP_NUM_IOCTLS + plugin->num_ioctls;
218+
219+ sgx_plugin = plugin;
220+
221+ if (loaded)
222+ plugin->load(dev, 0);
223+
224+ return 0;
225+}
226+EXPORT_SYMBOL(omap_drm_register_plugin);
227+
228+int omap_drm_unregister_plugin(struct omap_drm_plugin *plugin)
229+{
230+ int i;
231+
232+ for (i = 0; i < plugin->num_ioctls; i++) {
233+ const struct drm_ioctl_desc empty = { 0 };
234+ int nr = i + DRM_OMAP_NUM_IOCTLS;
235+
236+ ioctls[nr] = empty;
237+ }
238+
239+ omap_drm_driver.num_ioctls = DRM_OMAP_NUM_IOCTLS;
240+
241+ sgx_plugin = NULL;
242+
243+ return 0;
244+}
245+EXPORT_SYMBOL(omap_drm_unregister_plugin);
246+
247+void *omap_drm_file_priv(struct drm_file *file)
248+{
249+ return file->driver_priv;
250+}
251+EXPORT_SYMBOL(omap_drm_file_priv);
252+
253+void omap_drm_file_set_priv(struct drm_file *file, void *priv)
254+{
255+ file->driver_priv = priv;
256+}
257+EXPORT_SYMBOL(omap_drm_file_set_priv);
258+
259+
260 static int pdev_probe(struct platform_device *device)
261 {
262 int r;
263diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
264index 1f13c96..502d7b9 100644
265--- a/drivers/gpu/drm/omapdrm/omap_drv.h
266+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
267@@ -36,12 +36,6 @@
268
269 #define MODULE_NAME "omapdrm"
270
271-/* max # of mapper-id's that can be assigned.. todo, come up with a better
272- * (but still inexpensive) way to store/access per-buffer mapper private
273- * data..
274- */
275-#define MAX_MAPPERS 2
276-
277 /* parameters which describe (unrotated) coordinates of scanout within a fb: */
278 struct omap_drm_window {
279 uint32_t rotation;
280@@ -276,4 +270,58 @@ fail:
281 return -ENOENT;
282 }
283
284+/****** PLUGIN API specific ******/
285+
286+/* interface that plug-in drivers (for now just PVR) can implement */
287+struct omap_drm_plugin {
288+ const char *name;
289+
290+ /* drm functions */
291+ int (*load)(struct drm_device *dev, unsigned long flags);
292+ int (*unload)(struct drm_device *dev);
293+ int (*open)(struct drm_device *dev, struct drm_file *file);
294+ int (*release)(struct drm_device *dev, struct drm_file *file);
295+
296+ struct drm_ioctl_desc *ioctls;
297+ int num_ioctls;
298+ int ioctl_base;
299+};
300+
301+int omap_drm_register_plugin(struct omap_drm_plugin *plugin);
302+int omap_drm_unregister_plugin(struct omap_drm_plugin *plugin);
303+
304+void *omap_drm_file_priv(struct drm_file *file);
305+void omap_drm_file_set_priv(struct drm_file *file, void *priv);
306+
307+void *omap_gem_priv(struct drm_gem_object *obj);
308+void omap_gem_set_priv(struct drm_gem_object *obj, void *priv);
309+void omap_gem_vm_open(struct vm_area_struct *vma);
310+void omap_gem_vm_close(struct vm_area_struct *vma);
311+
312+/* for external plugin buffers wrapped as GEM object (via. omap_gem_new_ext())
313+ * a vm_ops struct can be provided to get callback notification of various
314+ * events..
315+ */
316+struct omap_gem_vm_ops {
317+ void (*open)(struct vm_area_struct *area);
318+ void (*close)(struct vm_area_struct *area);
319+ /*maybe: int (*fault)(struct vm_area_struct *vma,
320+ struct vm_fault *vmf)*/
321+
322+ /* note: mmap isn't expected to do anything. it is just to allow buffer
323+ * allocate to update it's own internal state
324+ */
325+ void (*mmap)(struct file *, struct vm_area_struct *);
326+};
327+
328+struct drm_gem_object *omap_gem_new_ext(struct drm_device *dev,
329+ union omap_gem_size gsize, uint32_t flags,
330+ dma_addr_t paddr, struct page **pages,
331+ struct omap_gem_vm_ops *ops);
332+
333+void omap_gem_op_update(void);
334+int omap_gem_set_sync_object(struct drm_gem_object *obj, void *syncobj);
335+/*********************************/
336+
337+
338 #endif /* __OMAP_DRV_H__ */
339diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
340index f9ddbf5..8634fc6 100644
341--- a/drivers/gpu/drm/omapdrm/omap_gem.c
342+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
343@@ -117,6 +117,14 @@ struct omap_gem_object {
344 uint32_t read_pending;
345 uint32_t read_complete;
346 } *sync;
347+
348+ struct omap_gem_vm_ops *ops;
349+
350+ /**
351+ * per-mapper private data..
352+ */
353+ void *priv;
354+
355 };
356
357 static int get_pages(struct drm_gem_object *obj, struct page ***pages);
358@@ -300,6 +308,7 @@ uint32_t omap_gem_flags(struct drm_gem_object *obj)
359 {
360 return to_omap_bo(obj)->flags;
361 }
362+EXPORT_SYMBOL(omap_gem_flags);
363
364 /** get mmap offset */
365 static uint64_t mmap_offset(struct drm_gem_object *obj)
366@@ -329,6 +338,7 @@ uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj)
367 mutex_unlock(&obj->dev->struct_mutex);
368 return offset;
369 }
370+EXPORT_SYMBOL(omap_gem_mmap_offset);
371
372 /** get mmap size */
373 size_t omap_gem_mmap_size(struct drm_gem_object *obj)
374@@ -361,6 +371,7 @@ int omap_gem_tiled_size(struct drm_gem_object *obj, uint16_t *w, uint16_t *h)
375 }
376 return -EINVAL;
377 }
378+EXPORT_SYMBOL(omap_gem_tiled_size);
379
380 /* Normal handling for the case of faulting in non-tiled buffers */
381 static int fault_1d(struct drm_gem_object *obj,
382@@ -593,6 +604,9 @@ int omap_gem_mmap_obj(struct drm_gem_object *obj,
383 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
384 }
385
386+ if (omap_obj->ops && omap_obj->ops->mmap)
387+ omap_obj->ops->mmap(obj->filp, vma);
388+
389 return 0;
390 }
391
392@@ -804,6 +818,7 @@ fail:
393
394 return ret;
395 }
396+EXPORT_SYMBOL(omap_gem_get_paddr);
397
398 /* Release physical address, when DMA is no longer being performed.. this
399 * could potentially unpin and unmap buffers from TILER
400@@ -834,6 +849,7 @@ void omap_gem_put_paddr(struct drm_gem_object *obj)
401
402 mutex_unlock(&obj->dev->struct_mutex);
403 }
404+EXPORT_SYMBOL(omap_gem_put_paddr);
405
406 /* Get rotated scanout address (only valid if already pinned), at the
407 * specified orientation and x,y offset from top-left corner of buffer
408@@ -864,6 +880,7 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient)
409 ret = tiler_stride(gem2fmt(omap_obj->flags), orient);
410 return ret;
411 }
412+EXPORT_SYMBOL(omap_gem_tiled_stride);
413
414 /* acquire pages when needed (for example, for DMA where physically
415 * contiguous buffer is not required
416@@ -913,6 +930,7 @@ int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
417 mutex_unlock(&obj->dev->struct_mutex);
418 return ret;
419 }
420+EXPORT_SYMBOL(omap_gem_get_pages);
421
422 /* release pages when DMA no longer being performed */
423 int omap_gem_put_pages(struct drm_gem_object *obj)
424@@ -923,6 +941,7 @@ int omap_gem_put_pages(struct drm_gem_object *obj)
425 */
426 return 0;
427 }
428+EXPORT_SYMBOL(omap_gem_put_pages);
429
430 /* Get kernel virtual address for CPU access.. this more or less only
431 * exists for omap_fbdev. This should be called with struct_mutex
432@@ -1118,17 +1137,20 @@ void omap_gem_op_update(void)
433 sync_op_update();
434 spin_unlock(&sync_lock);
435 }
436+EXPORT_SYMBOL(omap_gem_op_update);
437
438 /* mark the start of read and/or write operation */
439 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op)
440 {
441 return sync_op(obj, op, true);
442 }
443+EXPORT_SYMBOL(omap_gem_op_start);
444
445 int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op)
446 {
447 return sync_op(obj, op, false);
448 }
449+EXPORT_SYMBOL(omap_gem_op_finish);
450
451 static DECLARE_WAIT_QUEUE_HEAD(sync_event);
452
453@@ -1181,6 +1203,7 @@ int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op)
454 }
455 return ret;
456 }
457+EXPORT_SYMBOL(omap_gem_op_sync);
458
459 /* call fxn(arg), either synchronously or asynchronously if the op
460 * is currently blocked.. fxn() can be called from any context
461@@ -1227,6 +1250,7 @@ int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
462
463 return 0;
464 }
465+EXPORT_SYMBOL(omap_gem_op_async);
466
467 /* special API so PVR can update the buffer to use a sync-object allocated
468 * from it's sync-obj heap. Only used for a newly allocated (from PVR's
469@@ -1264,6 +1288,7 @@ unlock:
470 spin_unlock(&sync_lock);
471 return ret;
472 }
473+EXPORT_SYMBOL(omap_gem_set_sync_object);
474
475 /* don't call directly.. called from GEM core when it is time to actually
476 * free the object..
477@@ -1485,3 +1510,68 @@ void omap_gem_deinit(struct drm_device *dev)
478 */
479 kfree(usergart);
480 }
481+
482+/****** PLUGIN API specific ******/
483+
484+/* This constructor is mainly to give plugins a way to wrap their
485+ * own allocations
486+ */
487+struct drm_gem_object *omap_gem_new_ext(struct drm_device *dev,
488+ union omap_gem_size gsize, uint32_t flags,
489+ dma_addr_t paddr, struct page **pages,
490+ struct omap_gem_vm_ops *ops)
491+{
492+ struct drm_gem_object *obj;
493+
494+ BUG_ON((flags & OMAP_BO_TILED) && !pages);
495+
496+ if (paddr)
497+ flags |= OMAP_BO_DMA;
498+
499+ obj = omap_gem_new(dev, gsize, flags | OMAP_BO_EXT_MEM);
500+ if (obj) {
501+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
502+
503+ omap_obj->paddr = paddr;
504+ omap_obj->pages = pages;
505+ omap_obj->ops = ops;
506+ }
507+ return obj;
508+}
509+EXPORT_SYMBOL(omap_gem_new_ext);
510+
511+void omap_gem_vm_open(struct vm_area_struct *vma)
512+{
513+ struct drm_gem_object *obj = vma->vm_private_data;
514+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
515+
516+ if (omap_obj->ops && omap_obj->ops->open)
517+ omap_obj->ops->open(vma);
518+ else
519+ drm_gem_vm_open(vma);
520+
521+}
522+
523+void omap_gem_vm_close(struct vm_area_struct *vma)
524+{
525+ struct drm_gem_object *obj = vma->vm_private_data;
526+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
527+
528+ if (omap_obj->ops && omap_obj->ops->close)
529+ omap_obj->ops->close(vma);
530+ else
531+ drm_gem_vm_close(vma);
532+
533+}
534+
535+void *omap_gem_priv(struct drm_gem_object *obj)
536+{
537+ return to_omap_bo(obj)->priv;
538+}
539+EXPORT_SYMBOL(omap_gem_priv);
540+
541+void omap_gem_set_priv(struct drm_gem_object *obj, void *priv)
542+{
543+ to_omap_bo(obj)->priv = priv;
544+}
545+EXPORT_SYMBOL(omap_gem_set_priv);
546diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h
547index 1d0b117..5292b93 100644
548--- a/include/uapi/drm/omap_drm.h
549+++ b/include/uapi/drm/omap_drm.h
550@@ -33,6 +33,12 @@ struct drm_omap_param {
551 uint64_t value; /* in (set_param), out (get_param) */
552 };
553
554+struct drm_omap_get_base {
555+ char plugin_name[64]; /* in */
556+ uint32_t ioctl_base; /* out */
557+ uint32_t __pad;
558+};
559+
560 #define OMAP_BO_SCANOUT 0x00000001 /* scanout capable (phys contiguous) */
561 #define OMAP_BO_CACHE_MASK 0x00000006 /* cache type mask, see cache modes */
562 #define OMAP_BO_TILED_MASK 0x00000f00 /* tiled mapping mask, see tiled modes */
563@@ -101,9 +107,7 @@ struct drm_omap_gem_info {
564
565 #define DRM_OMAP_GET_PARAM 0x00
566 #define DRM_OMAP_SET_PARAM 0x01
567-/* placeholder for plugin-api
568 #define DRM_OMAP_GET_BASE 0x02
569-*/
570 #define DRM_OMAP_GEM_NEW 0x03
571 #define DRM_OMAP_GEM_CPU_PREP 0x04
572 #define DRM_OMAP_GEM_CPU_FINI 0x05
573@@ -112,9 +116,7 @@ struct drm_omap_gem_info {
574
575 #define DRM_IOCTL_OMAP_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GET_PARAM, struct drm_omap_param)
576 #define DRM_IOCTL_OMAP_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_OMAP_SET_PARAM, struct drm_omap_param)
577-/* placeholder for plugin-api
578 #define DRM_IOCTL_OMAP_GET_BASE DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GET_BASE, struct drm_omap_get_base)
579-*/
580 #define DRM_IOCTL_OMAP_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GEM_NEW, struct drm_omap_gem_new)
581 #define DRM_IOCTL_OMAP_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_OMAP_GEM_CPU_PREP, struct drm_omap_gem_cpu_prep)
582 #define DRM_IOCTL_OMAP_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_OMAP_GEM_CPU_FINI, struct drm_omap_gem_cpu_fini)
583--
5842.2.0
585
diff --git a/recipes-kernel/linux/linux-ti-staging-4.1/sgx.cfg b/recipes-kernel/linux/linux-ti-staging-4.1/sgx.cfg
new file mode 100644
index 00000000..37e19a3d
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti-staging-4.1/sgx.cfg
@@ -0,0 +1 @@
CONFIG_DRM_OMAP_SGX_PLUGIN=y
diff --git a/recipes-kernel/linux/linux-ti-staging_4.1.bb b/recipes-kernel/linux/linux-ti-staging_4.1.bb
index 36f0323c..4ecab8ef 100644
--- a/recipes-kernel/linux/linux-ti-staging_4.1.bb
+++ b/recipes-kernel/linux/linux-ti-staging_4.1.bb
@@ -50,18 +50,19 @@ S = "${WORKDIR}/git"
50 50
51BRANCH = "ti-lsk-linux-4.1.y" 51BRANCH = "ti-lsk-linux-4.1.y"
52 52
53SRCREV = "babcc95b3b74f099c63cae31abf403edf6154c0b" 53SRCREV = "1d476946dc0c881868ffd78cd2be30740ce0dea1"
54PV = "4.1.6+git${SRCPV}" 54PV = "4.1.6+git${SRCPV}"
55 55
56# Append to the MACHINE_KERNEL_PR so that a new SRCREV will cause a rebuild 56# Append to the MACHINE_KERNEL_PR so that a new SRCREV will cause a rebuild
57MACHINE_KERNEL_PR_append = "f" 57MACHINE_KERNEL_PR_append = "g"
58PR = "${MACHINE_KERNEL_PR}" 58PR = "${MACHINE_KERNEL_PR}"
59 59
60KERNEL_CONFIG_DIR = "${S}/ti_config_fragments" 60KERNEL_CONFIG_DIR = "${S}/ti_config_fragments"
61 61
62# SoC specific config fragments are not enabled yet 62# SoC specific config fragments are not enabled yet
63#KERNEL_CONFIG_FRAGMENTS_append_ti33x = " ${KERNEL_CONFIG_DIR}/am33xx_only.cfg" 63KERNEL_CONFIG_FRAGMENTS_append_ti33x = " ${KERNEL_CONFIG_DIR}/am33xx_only.cfg"
64#KERNEL_CONFIG_FRAGMENTS_append_ti43x = " ${KERNEL_CONFIG_DIR}/am43xx_only.cfg" 64KERNEL_CONFIG_FRAGMENTS_append_ti43x = " ${KERNEL_CONFIG_DIR}/am43xx_only.cfg"
65KERNEL_CONFIG_FRAGMENTS_append_dra7xx = " ${KERNEL_CONFIG_DIR}/dra7_only.cfg"
65 66
66MULTI_CONFIG_BASE_SUFFIX = "" 67MULTI_CONFIG_BASE_SUFFIX = ""
67 68
@@ -70,15 +71,15 @@ KERNEL_GIT_PROTOCOL = "git"
70SRC_URI += "${KERNEL_GIT_URI};protocol=${KERNEL_GIT_PROTOCOL};branch=${BRANCH} \ 71SRC_URI += "${KERNEL_GIT_URI};protocol=${KERNEL_GIT_PROTOCOL};branch=${BRANCH} \
71 file://defconfig" 72 file://defconfig"
72 73
73GFX_PATCHES = "file://0001-DT-gpu-add-binding-for-TI-SGX-driver.patch \ 74GFX_PATCHES = "file://0005-arm-Export-cache-flush-management-symbols-when-MULTI.patch \
74 file://0002-ARM-dts-DRA7xx-add-device-tree-entry-for-SGX.patch \
75 file://0003-arm-dra7xx-Add-gpu-hwmod-data.patch \
76 file://0004-drm-omap-Add-omapdrm-plugin-API.patch \
77 file://0005-arm-Export-cache-flush-management-symbols-when-MULTI.patch \
78 file://0006-ARM-dts-am33xx-add-DT-node-for-gpu.patch \ 75 file://0006-ARM-dts-am33xx-add-DT-node-for-gpu.patch \
79 file://0007-ARM-dts-am437x-add-DT-node-for-gpu.patch \ 76 file://0007-ARM-dts-am437x-add-DT-node-for-gpu.patch \
80 file://0008-ARM-OMAP2-Use-pdata-quirks-for-sgx-deassert_hardrese.patch" 77 file://0008-ARM-OMAP2-Use-pdata-quirks-for-sgx-deassert_hardrese.patch"
81 78
82SRC_URI_append_omap-a15 = " ${GFX_PATCHES}" 79SRC_URI_append_omap-a15 = " ${GFX_PATCHES} file://sgx.cfg"
83SRC_URI_append_ti33x = " ${GFX_PATCHES}" 80SRC_URI_append_ti33x = " ${GFX_PATCHES} file://sgx.cfg"
84SRC_URI_append_ti43x = " ${GFX_PATCHES}" 81SRC_URI_append_ti43x = " ${GFX_PATCHES} file://sgx.cfg"
82
83KERNEL_CONFIG_FRAGMENTS_append_omap-a15 = " ${WORKDIR}/sgx.cfg"
84KERNEL_CONFIG_FRAGMENTS_append_ti33x = " ${WORKDIR}/sgx.cfg"
85KERNEL_CONFIG_FRAGMENTS_append_ti43x = " ${WORKDIR}/sgx.cfg"