Skip to content

Commit

Permalink
Merge pull request #12 from rzk/odroid-3.0.y
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mdrjr committed Jan 16, 2013
2 parents ddf3fa8 + 9bc519c commit acc9bca
Show file tree
Hide file tree
Showing 165 changed files with 32,353 additions and 136 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/mali/Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

ccflags-y = -Iinclude/drm
mali_drm-y := mali_drv.o
mali_drm-y := mali_drv.o mali_mm.o

obj-$(CONFIG_DRM_MALI) += mali_drm.o

Expand Down
51 changes: 51 additions & 0 deletions drivers/gpu/drm/mali/mali_drm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained from Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef __MALI_DRM_H__
#define __MALI_DRM_H__

#include <linux/vermagic.h>
#include <linux/version.h>
#include <linux/printk.h>
#include <linux/platform_device.h>
#include <linux/list.h>
#include <linux/init.h>
#include <drm/drmP.h>

/* Mali specific ioctls */
#define NOT_USED_0_3
#define DRM_MALI_FB_ALLOC 0x04
#define DRM_MALI_FB_FREE 0x05
#define NOT_USED_6_12
#define DRM_MALI_MEM_INIT 0x13
#define DRM_MALI_MEM_ALLOC 0x14
#define DRM_MALI_MEM_FREE 0x15
#define DRM_MALI_FB_INIT 0x16

#define DRM_IOCTL_MALI_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_FB_ALLOC, drm_mali_mem_t)
#define DRM_IOCTL_MALI_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_FB_FREE, drm_mali_mem_t)
#define DRM_IOCTL_MALI_MEM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_MEM_INIT, drm_mali_mem_t)
#define DRM_IOCTL_MALI_MEM_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_MEM_ALLOC, drm_mali_mem_t)
#define DRM_IOCTL_MALI_MEM_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_MEM_FREE, drm_mali_mem_t)
#define DRM_IOCTL_MALI_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_FB_INIT, drm_mali_fb_t)

typedef struct
{
int context;
unsigned int offset;
unsigned int size;
unsigned long free;
} drm_mali_mem_t;

typedef struct {
unsigned int offset, size;
} drm_mali_fb_t;

#endif /* __MALI_DRM_H__ */
212 changes: 93 additions & 119 deletions drivers/gpu/drm/mali/mali_drv.c
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,100 +1,123 @@
/**
* Copyright (C) 2010 ARM Limited. All rights reserved.
*
/*
* Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
*
*
* A copy of the licence is included with the program, and can also be obtained from Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/**
* @file mali_drv.c
* Implementation of the Linux device driver entrypoints for Mali DRM
*/
#include <linux/vermagic.h>
#include <drm/drmP.h>

#include "mali_drm.h"
#include "mali_drv.h"

static struct platform_device *dev0;
static struct platform_device *dev1;
static struct platform_device *pdev;

void mali_drm_preclose(struct drm_device *dev, struct drm_file *file_priv)
static int mali_platform_drm_probe(struct platform_device *dev)
{
printk(KERN_INFO "DRM: mali_platform_drm_probe()\n");
return mali_drm_init(dev);
}

void mali_drm_lastclose(struct drm_device *dev)
static int mali_platform_drm_remove(struct platform_device *dev)
{
printk(KERN_INFO "DRM: mali_platform_drm_remove()\n");
mali_drm_exit(dev);
return 0;
}

static int mali_drm_suspend(struct drm_device *dev, pm_message_t state)
static int mali_platform_drm_suspend(struct platform_device *dev, pm_message_t state)
{
printk(KERN_INFO "DRM: mali_platform_drm_suspend()\n");
return 0;
}

static int mali_drm_resume(struct drm_device *dev)
static int mali_platform_drm_resume(struct platform_device *dev)
{
printk(KERN_INFO "DRM: mali_platform_drm_resume()\n");
return 0;
}

static int mali_drm_load(struct drm_device *dev, unsigned long chipset)
static char mali_drm_device_name[] = "mali_drm";
static struct platform_driver platform_drm_driver = {
.probe = mali_platform_drm_probe,
.remove = mali_platform_drm_remove,
.suspend = mali_platform_drm_suspend,
.resume = mali_platform_drm_resume,
.driver = {
.name = mali_drm_device_name,
.owner = THIS_MODULE,
}
};

static int mali_driver_load(struct drm_device *dev, unsigned long flags)
{
return 0;
int ret;
//unsigned long base, size;
drm_mali_private_t *dev_priv;
printk(KERN_INFO "DRM: mali_driver_load()\n");

dev_priv = kmalloc(sizeof(drm_mali_private_t), GFP_KERNEL);
if (dev_priv != NULL)
memset((void *)dev_priv, 0, sizeof(drm_mali_private_t));

if (dev_priv == NULL)
{
printk(KERN_INFO "DRM: No memory!\n");
return -ENOMEM;
}

dev->dev_private = (void *)dev_priv;

if ( NULL == dev->platformdev )
{
dev->platformdev = platform_device_register_simple(mali_drm_device_name, 0, NULL, 0);
pdev = dev->platformdev;
}

#if 0
base = drm_get_resource_start(dev, 1 );
size = drm_get_resource_len(dev, 1 );
#endif
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
//if ( ret ) drm_free(dev_priv, sizeof(dev_priv), DRM_MEM_DRIVER);
if ( ret )
kfree( dev_priv );

return ret;
}

static int mali_drm_unload(struct drm_device *dev)
static int mali_driver_unload( struct drm_device *dev )
{
drm_mali_private_t *dev_priv = dev->dev_private;

drm_sman_takedown(&dev_priv->sman);
//drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
kfree( dev_priv );
return 0;
}

static struct drm_driver driver =
{
.driver_features = DRIVER_BUS_PLATFORM,
.load = mali_drm_load,
.unload = mali_drm_unload,
.context_dtor = NULL,
.reclaim_buffers = NULL,
.reclaim_buffers_idlelocked = NULL,
.preclose = mali_drm_preclose,
.lastclose = mali_drm_lastclose,
.suspend = mali_drm_suspend,
.resume = mali_drm_resume,
.ioctls = NULL,
.fops = {
.owner = THIS_MODULE,
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
.fasync = drm_fasync,
},
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
};

static struct drm_driver driver1 =
static struct drm_driver driver =
{
.driver_features = DRIVER_BUS_PLATFORM,
.load = mali_drm_load,
.unload = mali_drm_unload,
.load = mali_driver_load,
.unload = mali_driver_unload,
.context_dtor = NULL,
.dma_quiescent = mali_idle,
.reclaim_buffers = NULL,
.reclaim_buffers_idlelocked = NULL,
.preclose = mali_drm_preclose,
.lastclose = mali_drm_lastclose,
.suspend = mali_drm_suspend,
.resume = mali_drm_resume,
.ioctls = NULL,
.reclaim_buffers_idlelocked = mali_reclaim_buffers_locked,
.lastclose = mali_lastclose,
.ioctls = mali_ioctls,
.fops = {
.owner = THIS_MODULE,
.open = drm_open,
.release = drm_release,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
.ioctl = drm_ioctl,
#else
.unlocked_ioctl = drm_ioctl,
#endif
.mmap = drm_mmap,
.poll = drm_poll,
.fasync = drm_fasync,
Expand All @@ -109,74 +132,27 @@ static struct drm_driver driver1 =

int mali_drm_init(struct platform_device *dev)
{
printk(KERN_INFO "Mali DRM initialize, driver name: %s, version %d.%d\n", DRIVER_NAME, DRIVER_MAJOR, DRIVER_MINOR);
if (dev == dev0) {
driver.num_ioctls = 0;
driver.kdriver.platform_device = dev;
return drm_platform_init(&driver, dev);
} else if (dev == dev1) {
driver1.num_ioctls = 0;
driver1.kdriver.platform_device = dev;
return drm_platform_init(&driver1, dev);
}
return 0;
printk(KERN_INFO "mali_drm_init(), driver name: %s, version %d.%d\n", DRIVER_NAME, DRIVER_MAJOR, DRIVER_MINOR);
driver.num_ioctls = mali_max_ioctl;
driver.kdriver.platform_device = dev;
return drm_platform_init(&driver, dev);
}

void mali_drm_exit(struct platform_device *dev)
{
if (driver.kdriver.platform_device == dev) {
drm_platform_exit(&driver, dev);
} else if (driver1.kdriver.platform_device == dev) {
drm_platform_exit(&driver1, dev);
}
}

static int __devinit mali_platform_drm_probe(struct platform_device *dev)
{
return mali_drm_init(dev);
drm_platform_exit(&driver, dev);
}

static int mali_platform_drm_remove(struct platform_device *dev)
{
mali_drm_exit(dev);

return 0;
}

static int mali_platform_drm_suspend(struct platform_device *dev, pm_message_t state)
{
return 0;
}

static int mali_platform_drm_resume(struct platform_device *dev)
{
return 0;
}


static struct platform_driver platform_drm_driver = {
.probe = mali_platform_drm_probe,
.remove = __devexit_p(mali_platform_drm_remove),
.suspend = mali_platform_drm_suspend,
.resume = mali_platform_drm_resume,
.driver = {
.owner = THIS_MODULE,
.name = DRIVER_NAME,
},
};

static int __init mali_platform_drm_init(void)
{
dev0 = platform_device_register_simple("mali_drm", 0, NULL, 0);
dev1 = platform_device_register_simple("mali_drm", 1, NULL, 0);
return platform_driver_register( &platform_drm_driver );
pdev = platform_device_register_simple(mali_drm_device_name, 0, NULL, 0);
return platform_driver_register(&platform_drm_driver);
}

static void __exit mali_platform_drm_exit(void)
{
platform_driver_unregister( &platform_drm_driver );
platform_device_unregister(dev0);
platform_device_unregister(dev1);
platform_driver_unregister(&platform_drm_driver);
platform_device_unregister(pdev);
}

#ifdef MODULE
Expand All @@ -186,9 +162,7 @@ late_initcall(mali_platform_drm_init);
#endif
module_exit(mali_platform_drm_exit);

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_LICENSE(DRIVER_LICENSE);
MODULE_ALIAS(DRIVER_ALIAS);
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_AUTHOR("ARM Ltd.");
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL and additional rights");
Loading

0 comments on commit acc9bca

Please sign in to comment.