summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorXinyu Chen <xinyu.chen@freescale.com>2012-04-26 10:19:39 +0800
committerXinyu Chen <xinyu.chen@freescale.com>2012-04-26 13:32:33 +0800
commit698e761daab207dcfd40dffdf43b82f0fded9d7d (patch)
tree81e2b46fb4c3fc9f477e38d4965f6aec556ee411 /drivers/gpu
parent2897d6961e17d1f2bed19c5101b4ecf0472637f7 (diff)
ENGR00180865-2 ion: Add imx ion allocator driver support
Enable ion in drivers Kconfig Add imx ion allocator device driver Add ION_IOC_PHYS ioctl for user to get phys addr of buffers Correct the remap pfn pgprot to writecombine Signed-off-by: Xinyu Chen <xinyu.chen@freescale.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/ion/Kconfig6
-rw-r--r--drivers/gpu/ion/Makefile1
-rw-r--r--drivers/gpu/ion/ion.c15
-rw-r--r--drivers/gpu/ion/ion_carveout_heap.c2
-rw-r--r--drivers/gpu/ion/mxc/Makefile1
-rw-r--r--drivers/gpu/ion/mxc/mxc_ion.c101
6 files changed, 125 insertions, 1 deletions
diff --git a/drivers/gpu/ion/Kconfig b/drivers/gpu/ion/Kconfig
index 5b48b4e85e73..13dcbaf3d2d6 100644
--- a/drivers/gpu/ion/Kconfig
+++ b/drivers/gpu/ion/Kconfig
@@ -4,6 +4,12 @@ menuconfig ION
help
Chose this option to enable the ION Memory Manager.
+config ION_MXC
+ tristate "Ion for MXC"
+ depends on ARCH_MXC && ION
+ help
+ Choose this option if you wish to use ion on an Freescale MXC.
+
config ION_TEGRA
tristate "Ion for Tegra"
depends on ARCH_TEGRA && ION
diff --git a/drivers/gpu/ion/Makefile b/drivers/gpu/ion/Makefile
index 73fe3fa10706..5e159032944f 100644
--- a/drivers/gpu/ion/Makefile
+++ b/drivers/gpu/ion/Makefile
@@ -1,2 +1,3 @@
obj-$(CONFIG_ION) += ion.o ion_heap.o ion_system_heap.o ion_carveout_heap.o
+obj-$(CONFIG_ION_MXC) += mxc/
obj-$(CONFIG_ION_TEGRA) += tegra/
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 37b23af0550b..47ba2155e39b 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1013,6 +1013,21 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return -EFAULT;
return dev->custom_ioctl(client, data.cmd, data.arg);
}
+ case ION_IOC_PHYS:
+ {
+ struct ion_handle_data data;
+ ion_phys_addr_t phys;
+ int len;
+ bool valid;
+
+ if (copy_from_user(&data, (void __user *)arg,
+ sizeof(struct ion_handle_data)))
+ return -EFAULT;
+ valid = ion_phys(client, data.handle, &phys, &len);
+ if (valid)
+ return 0;
+ return phys;
+ }
default:
return -ENOTTY;
}
diff --git a/drivers/gpu/ion/ion_carveout_heap.c b/drivers/gpu/ion/ion_carveout_heap.c
index 606adae13f48..6d0a938235f6 100644
--- a/drivers/gpu/ion/ion_carveout_heap.c
+++ b/drivers/gpu/ion/ion_carveout_heap.c
@@ -117,7 +117,7 @@ int ion_carveout_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer,
return remap_pfn_range(vma, vma->vm_start,
__phys_to_pfn(buffer->priv_phys) + vma->vm_pgoff,
buffer->size,
- pgprot_noncached(vma->vm_page_prot));
+ pgprot_writecombine(vma->vm_page_prot));
}
static struct ion_heap_ops carveout_heap_ops = {
diff --git a/drivers/gpu/ion/mxc/Makefile b/drivers/gpu/ion/mxc/Makefile
new file mode 100644
index 000000000000..85726164ed55
--- /dev/null
+++ b/drivers/gpu/ion/mxc/Makefile
@@ -0,0 +1 @@
+obj-y += mxc_ion.o
diff --git a/drivers/gpu/ion/mxc/mxc_ion.c b/drivers/gpu/ion/mxc/mxc_ion.c
new file mode 100644
index 000000000000..82a2d082637b
--- /dev/null
+++ b/drivers/gpu/ion/mxc/mxc_ion.c
@@ -0,0 +1,101 @@
+/*
+ * drivers/gpu/mxc/mxc_ion.c
+ *
+ * Copyright (C) 2011 Google, Inc.
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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;
+struct ion_mapper *mxc_user_mapper;
+int num_heaps;
+struct ion_heap **heaps;
+
+int mxc_ion_probe(struct platform_device *pdev)
+{
+ struct ion_platform_data *pdata = pdev->dev.platform_data;
+ int err;
+ int i;
+
+ num_heaps = pdata->nr;
+
+ heaps = kzalloc(sizeof(struct ion_heap *) * pdata->nr, GFP_KERNEL);
+
+ idev = ion_device_create(NULL);
+ if (IS_ERR_OR_NULL(idev)) {
+ kfree(heaps);
+ return PTR_ERR(idev);
+ }
+
+ /* 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 err;
+ }
+ ion_device_add_heap(idev, heaps[i]);
+ }
+ platform_set_drvdata(pdev, idev);
+ return 0;
+err:
+ for (i = 0; i < num_heaps; i++) {
+ if (heaps[i])
+ ion_heap_destroy(heaps[i]);
+ }
+ kfree(heaps);
+ return err;
+}
+
+int mxc_ion_remove(struct platform_device *pdev)
+{
+ struct ion_device *idev = platform_get_drvdata(pdev);
+ int i;
+
+ ion_device_destroy(idev);
+ for (i = 0; i < num_heaps; i++)
+ ion_heap_destroy(heaps[i]);
+ kfree(heaps);
+ return 0;
+}
+
+static struct platform_driver ion_driver = {
+ .probe = mxc_ion_probe,
+ .remove = mxc_ion_remove,
+ .driver = { .name = "ion-mxc" }
+};
+
+static int __init ion_init(void)
+{
+ return platform_driver_register(&ion_driver);
+}
+
+static void __exit ion_exit(void)
+{
+ platform_driver_unregister(&ion_driver);
+}
+
+module_init(ion_init);
+module_exit(ion_exit);
+
+MODULE_AUTHOR("Freescale Semiconductor, Inc.");
+MODULE_DESCRIPTION("MXC ion allocator driver");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("fb");