forked from CyanogenMod/zte-kernel-msm7x27
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpu: ion: Add platform driver for msm ion
Add platform driver for msm specific ion devices Signed-off-by: Laura Abbott <[email protected]>
- Loading branch information
1 parent
edaf7c7
commit 6ddff29
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
obj-$(CONFIG_ION) += ion.o ion_heap.o ion_system_heap.o ion_carveout_heap.o | ||
obj-$(CONFIG_ION_TEGRA) += tegra/ | ||
obj-$(CONFIG_ION_MSM) += msm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj-y += msm_ion.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 and | ||
* only version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
#include <linux/err.h> | ||
#include <linux/ion.h> | ||
#include <linux/platform_device.h> | ||
#include <linux/slab.h> | ||
#include "../ion_priv.h" | ||
|
||
struct ion_device *idev; | ||
int num_heaps; | ||
struct ion_heap **heaps; | ||
|
||
struct ion_client *msm_ion_client_create(unsigned int heap_mask, | ||
const char *name) | ||
{ | ||
return ion_client_create(idev, heap_mask, name); | ||
} | ||
|
||
static int msm_ion_probe(struct platform_device *pdev) | ||
{ | ||
struct ion_platform_data *pdata = pdev->dev.platform_data; | ||
int err; | ||
int i; | ||
|
||
num_heaps = pdata->nr; | ||
|
||
heaps = kcalloc(pdata->nr, sizeof(struct ion_heap *), GFP_KERNEL); | ||
|
||
if (!heaps) { | ||
err = -ENOMEM; | ||
goto out; | ||
} | ||
|
||
idev = ion_device_create(NULL); | ||
if (IS_ERR_OR_NULL(idev)) { | ||
err = PTR_ERR(idev); | ||
goto freeheaps; | ||
} | ||
|
||
/* create the heaps as specified in the board file */ | ||
for (i = 0; i < num_heaps; i++) { | ||
struct ion_platform_heap *heap_data = &pdata->heaps[i]; | ||
|
||
heaps[i] = ion_heap_create(heap_data); | ||
if (IS_ERR_OR_NULL(heaps[i])) { | ||
err = PTR_ERR(heaps[i]); | ||
goto heapdestroy; | ||
} | ||
ion_device_add_heap(idev, heaps[i]); | ||
} | ||
platform_set_drvdata(pdev, idev); | ||
return 0; | ||
|
||
heapdestroy: | ||
for (i = 0; i < num_heaps; i++) { | ||
if (!IS_ERR_OR_NULL(heaps[i])) | ||
ion_heap_destroy(heaps[i]); | ||
} | ||
freeheaps: | ||
kfree(heaps); | ||
out: | ||
return err; | ||
} | ||
|
||
static int msm_ion_remove(struct platform_device *pdev) | ||
{ | ||
struct ion_device *idev = platform_get_drvdata(pdev); | ||
int i; | ||
|
||
for (i = 0; i < num_heaps; i++) | ||
ion_heap_destroy(heaps[i]); | ||
|
||
ion_device_destroy(idev); | ||
kfree(heaps); | ||
return 0; | ||
} | ||
|
||
static struct platform_driver msm_ion_driver = { | ||
.probe = msm_ion_probe, | ||
.remove = msm_ion_remove, | ||
.driver = { .name = "ion-msm" } | ||
}; | ||
|
||
static int __init msm_ion_init(void) | ||
{ | ||
return platform_driver_register(&msm_ion_driver); | ||
} | ||
|
||
static void __exit msm_ion_exit(void) | ||
{ | ||
platform_driver_unregister(&msm_ion_driver); | ||
} | ||
|
||
module_init(msm_ion_init); | ||
module_exit(msm_ion_exit); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters