Skip to content

Commit acc9bca

Browse files
committed
Merge pull request #12 from rzk/odroid-3.0.y
mali-400 r3p2 from rz2k ;) We now have r3p2 and r2p4 drivers on Kernel. r3p2 is for Linux and r2p4 is for Android. We should probably upgrade Android blobs as well.
2 parents ddf3fa8 + 9bc519c commit acc9bca

File tree

165 files changed

+32353
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+32353
-136
lines changed

drivers/gpu/drm/mali/Makefile

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
1313

1414
ccflags-y = -Iinclude/drm
15-
mali_drm-y := mali_drv.o
15+
mali_drm-y := mali_drv.o mali_mm.o
1616

1717
obj-$(CONFIG_DRM_MALI) += mali_drm.o
1818

drivers/gpu/drm/mali/mali_drm.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
3+
*
4+
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
5+
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6+
*
7+
* A copy of the licence is included with the program, and can also be obtained from Free Software
8+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9+
*/
10+
11+
#ifndef __MALI_DRM_H__
12+
#define __MALI_DRM_H__
13+
14+
#include <linux/vermagic.h>
15+
#include <linux/version.h>
16+
#include <linux/printk.h>
17+
#include <linux/platform_device.h>
18+
#include <linux/list.h>
19+
#include <linux/init.h>
20+
#include <drm/drmP.h>
21+
22+
/* Mali specific ioctls */
23+
#define NOT_USED_0_3
24+
#define DRM_MALI_FB_ALLOC 0x04
25+
#define DRM_MALI_FB_FREE 0x05
26+
#define NOT_USED_6_12
27+
#define DRM_MALI_MEM_INIT 0x13
28+
#define DRM_MALI_MEM_ALLOC 0x14
29+
#define DRM_MALI_MEM_FREE 0x15
30+
#define DRM_MALI_FB_INIT 0x16
31+
32+
#define DRM_IOCTL_MALI_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_FB_ALLOC, drm_mali_mem_t)
33+
#define DRM_IOCTL_MALI_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_FB_FREE, drm_mali_mem_t)
34+
#define DRM_IOCTL_MALI_MEM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_MEM_INIT, drm_mali_mem_t)
35+
#define DRM_IOCTL_MALI_MEM_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_MEM_ALLOC, drm_mali_mem_t)
36+
#define DRM_IOCTL_MALI_MEM_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_MEM_FREE, drm_mali_mem_t)
37+
#define DRM_IOCTL_MALI_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_FB_INIT, drm_mali_fb_t)
38+
39+
typedef struct
40+
{
41+
int context;
42+
unsigned int offset;
43+
unsigned int size;
44+
unsigned long free;
45+
} drm_mali_mem_t;
46+
47+
typedef struct {
48+
unsigned int offset, size;
49+
} drm_mali_fb_t;
50+
51+
#endif /* __MALI_DRM_H__ */

drivers/gpu/drm/mali/mali_drv.c

100755100644
Lines changed: 93 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,123 @@
1-
/**
2-
* Copyright (C) 2010 ARM Limited. All rights reserved.
3-
*
1+
/*
2+
* Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
3+
*
44
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
55
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6-
*
6+
*
77
* A copy of the licence is included with the program, and can also be obtained from Free Software
88
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
99
*/
1010

11-
/**
12-
* @file mali_drv.c
13-
* Implementation of the Linux device driver entrypoints for Mali DRM
14-
*/
15-
#include <linux/vermagic.h>
16-
#include <drm/drmP.h>
11+
12+
#include "mali_drm.h"
1713
#include "mali_drv.h"
1814

19-
static struct platform_device *dev0;
20-
static struct platform_device *dev1;
15+
static struct platform_device *pdev;
2116

22-
void mali_drm_preclose(struct drm_device *dev, struct drm_file *file_priv)
17+
static int mali_platform_drm_probe(struct platform_device *dev)
2318
{
19+
printk(KERN_INFO "DRM: mali_platform_drm_probe()\n");
20+
return mali_drm_init(dev);
2421
}
2522

26-
void mali_drm_lastclose(struct drm_device *dev)
23+
static int mali_platform_drm_remove(struct platform_device *dev)
2724
{
25+
printk(KERN_INFO "DRM: mali_platform_drm_remove()\n");
26+
mali_drm_exit(dev);
27+
return 0;
2828
}
2929

30-
static int mali_drm_suspend(struct drm_device *dev, pm_message_t state)
30+
static int mali_platform_drm_suspend(struct platform_device *dev, pm_message_t state)
3131
{
32+
printk(KERN_INFO "DRM: mali_platform_drm_suspend()\n");
3233
return 0;
3334
}
3435

35-
static int mali_drm_resume(struct drm_device *dev)
36+
static int mali_platform_drm_resume(struct platform_device *dev)
3637
{
38+
printk(KERN_INFO "DRM: mali_platform_drm_resume()\n");
3739
return 0;
3840
}
3941

40-
static int mali_drm_load(struct drm_device *dev, unsigned long chipset)
42+
static char mali_drm_device_name[] = "mali_drm";
43+
static struct platform_driver platform_drm_driver = {
44+
.probe = mali_platform_drm_probe,
45+
.remove = mali_platform_drm_remove,
46+
.suspend = mali_platform_drm_suspend,
47+
.resume = mali_platform_drm_resume,
48+
.driver = {
49+
.name = mali_drm_device_name,
50+
.owner = THIS_MODULE,
51+
}
52+
};
53+
54+
static int mali_driver_load(struct drm_device *dev, unsigned long flags)
4155
{
42-
return 0;
56+
int ret;
57+
//unsigned long base, size;
58+
drm_mali_private_t *dev_priv;
59+
printk(KERN_INFO "DRM: mali_driver_load()\n");
60+
61+
dev_priv = kmalloc(sizeof(drm_mali_private_t), GFP_KERNEL);
62+
if (dev_priv != NULL)
63+
memset((void *)dev_priv, 0, sizeof(drm_mali_private_t));
64+
65+
if (dev_priv == NULL)
66+
{
67+
printk(KERN_INFO "DRM: No memory!\n");
68+
return -ENOMEM;
69+
}
70+
71+
dev->dev_private = (void *)dev_priv;
72+
73+
if ( NULL == dev->platformdev )
74+
{
75+
dev->platformdev = platform_device_register_simple(mali_drm_device_name, 0, NULL, 0);
76+
pdev = dev->platformdev;
77+
}
78+
79+
#if 0
80+
base = drm_get_resource_start(dev, 1 );
81+
size = drm_get_resource_len(dev, 1 );
82+
#endif
83+
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
84+
//if ( ret ) drm_free(dev_priv, sizeof(dev_priv), DRM_MEM_DRIVER);
85+
if ( ret )
86+
kfree( dev_priv );
87+
88+
return ret;
4389
}
4490

45-
static int mali_drm_unload(struct drm_device *dev)
91+
static int mali_driver_unload( struct drm_device *dev )
4692
{
93+
drm_mali_private_t *dev_priv = dev->dev_private;
94+
95+
drm_sman_takedown(&dev_priv->sman);
96+
//drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
97+
kfree( dev_priv );
4798
return 0;
4899
}
49100

50-
static struct drm_driver driver =
51-
{
52-
.driver_features = DRIVER_BUS_PLATFORM,
53-
.load = mali_drm_load,
54-
.unload = mali_drm_unload,
55-
.context_dtor = NULL,
56-
.reclaim_buffers = NULL,
57-
.reclaim_buffers_idlelocked = NULL,
58-
.preclose = mali_drm_preclose,
59-
.lastclose = mali_drm_lastclose,
60-
.suspend = mali_drm_suspend,
61-
.resume = mali_drm_resume,
62-
.ioctls = NULL,
63-
.fops = {
64-
.owner = THIS_MODULE,
65-
.open = drm_open,
66-
.release = drm_release,
67-
.unlocked_ioctl = drm_ioctl,
68-
.mmap = drm_mmap,
69-
.poll = drm_poll,
70-
.fasync = drm_fasync,
71-
},
72-
.name = DRIVER_NAME,
73-
.desc = DRIVER_DESC,
74-
.date = DRIVER_DATE,
75-
.major = DRIVER_MAJOR,
76-
.minor = DRIVER_MINOR,
77-
.patchlevel = DRIVER_PATCHLEVEL,
78-
};
79-
80-
static struct drm_driver driver1 =
101+
static struct drm_driver driver =
81102
{
82103
.driver_features = DRIVER_BUS_PLATFORM,
83-
.load = mali_drm_load,
84-
.unload = mali_drm_unload,
104+
.load = mali_driver_load,
105+
.unload = mali_driver_unload,
85106
.context_dtor = NULL,
107+
.dma_quiescent = mali_idle,
86108
.reclaim_buffers = NULL,
87-
.reclaim_buffers_idlelocked = NULL,
88-
.preclose = mali_drm_preclose,
89-
.lastclose = mali_drm_lastclose,
90-
.suspend = mali_drm_suspend,
91-
.resume = mali_drm_resume,
92-
.ioctls = NULL,
109+
.reclaim_buffers_idlelocked = mali_reclaim_buffers_locked,
110+
.lastclose = mali_lastclose,
111+
.ioctls = mali_ioctls,
93112
.fops = {
94113
.owner = THIS_MODULE,
95114
.open = drm_open,
96115
.release = drm_release,
116+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
117+
.ioctl = drm_ioctl,
118+
#else
97119
.unlocked_ioctl = drm_ioctl,
120+
#endif
98121
.mmap = drm_mmap,
99122
.poll = drm_poll,
100123
.fasync = drm_fasync,
@@ -109,74 +132,27 @@ static struct drm_driver driver1 =
109132

110133
int mali_drm_init(struct platform_device *dev)
111134
{
112-
printk(KERN_INFO "Mali DRM initialize, driver name: %s, version %d.%d\n", DRIVER_NAME, DRIVER_MAJOR, DRIVER_MINOR);
113-
if (dev == dev0) {
114-
driver.num_ioctls = 0;
115-
driver.kdriver.platform_device = dev;
116-
return drm_platform_init(&driver, dev);
117-
} else if (dev == dev1) {
118-
driver1.num_ioctls = 0;
119-
driver1.kdriver.platform_device = dev;
120-
return drm_platform_init(&driver1, dev);
121-
}
122-
return 0;
135+
printk(KERN_INFO "mali_drm_init(), driver name: %s, version %d.%d\n", DRIVER_NAME, DRIVER_MAJOR, DRIVER_MINOR);
136+
driver.num_ioctls = mali_max_ioctl;
137+
driver.kdriver.platform_device = dev;
138+
return drm_platform_init(&driver, dev);
123139
}
124140

125141
void mali_drm_exit(struct platform_device *dev)
126142
{
127-
if (driver.kdriver.platform_device == dev) {
128-
drm_platform_exit(&driver, dev);
129-
} else if (driver1.kdriver.platform_device == dev) {
130-
drm_platform_exit(&driver1, dev);
131-
}
132-
}
133-
134-
static int __devinit mali_platform_drm_probe(struct platform_device *dev)
135-
{
136-
return mali_drm_init(dev);
143+
drm_platform_exit(&driver, dev);
137144
}
138145

139-
static int mali_platform_drm_remove(struct platform_device *dev)
140-
{
141-
mali_drm_exit(dev);
142-
143-
return 0;
144-
}
145-
146-
static int mali_platform_drm_suspend(struct platform_device *dev, pm_message_t state)
147-
{
148-
return 0;
149-
}
150-
151-
static int mali_platform_drm_resume(struct platform_device *dev)
152-
{
153-
return 0;
154-
}
155-
156-
157-
static struct platform_driver platform_drm_driver = {
158-
.probe = mali_platform_drm_probe,
159-
.remove = __devexit_p(mali_platform_drm_remove),
160-
.suspend = mali_platform_drm_suspend,
161-
.resume = mali_platform_drm_resume,
162-
.driver = {
163-
.owner = THIS_MODULE,
164-
.name = DRIVER_NAME,
165-
},
166-
};
167-
168146
static int __init mali_platform_drm_init(void)
169147
{
170-
dev0 = platform_device_register_simple("mali_drm", 0, NULL, 0);
171-
dev1 = platform_device_register_simple("mali_drm", 1, NULL, 0);
172-
return platform_driver_register( &platform_drm_driver );
148+
pdev = platform_device_register_simple(mali_drm_device_name, 0, NULL, 0);
149+
return platform_driver_register(&platform_drm_driver);
173150
}
174151

175152
static void __exit mali_platform_drm_exit(void)
176153
{
177-
platform_driver_unregister( &platform_drm_driver );
178-
platform_device_unregister(dev0);
179-
platform_device_unregister(dev1);
154+
platform_driver_unregister(&platform_drm_driver);
155+
platform_device_unregister(pdev);
180156
}
181157

182158
#ifdef MODULE
@@ -186,9 +162,7 @@ late_initcall(mali_platform_drm_init);
186162
#endif
187163
module_exit(mali_platform_drm_exit);
188164

189-
MODULE_DESCRIPTION(DRIVER_DESC);
190-
MODULE_VERSION(DRIVER_VERSION);
191-
MODULE_AUTHOR(DRIVER_AUTHOR);
192-
MODULE_LICENSE(DRIVER_LICENSE);
193-
MODULE_ALIAS(DRIVER_ALIAS);
194165
MODULE_INFO(vermagic, VERMAGIC_STRING);
166+
MODULE_AUTHOR("ARM Ltd.");
167+
MODULE_DESCRIPTION(DRIVER_DESC);
168+
MODULE_LICENSE("GPL and additional rights");

0 commit comments

Comments
 (0)