summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Brown <david.brown@arm.com>2015-02-09 10:03:10 +0000
committerRyan Harkin <ryan.harkin@linaro.org>2015-02-10 06:46:12 +0000
commit6f186e3250782c50651be81987b95d75e0e6d8c7 (patch)
treef32752ebc33ea72abc4f9cea824ca01832e2f580
parent42e38f97e50d13ef18c109a912dae93f0cfb5982 (diff)
juno: ion: Initial ION driver for Juno
Previously ION support on Juno was limited to the dummy ION driver available in the Kernel. This, however, makes it difficult to add any additional heaps which are specific to the Juno platform. To address this we create a Juno-specific ION implementation. The implementation currently has a hacked-up, hardcoded additional DMA heap that provides access to the DDR RAM present in the virtex 7 FPGA daughterboard so this heap should only be used by the FPGA is present. Signed-off-by: David Brown <david.brown@arm.com>
-rw-r--r--drivers/staging/android/ion/Kconfig5
-rw-r--r--drivers/staging/android/ion/Makefile1
-rw-r--r--drivers/staging/android/ion/juno/Makefile2
-rw-r--r--drivers/staging/android/ion/juno/juno_ion_dev.c80
-rw-r--r--drivers/staging/android/ion/juno/juno_ion_driver.c98
5 files changed, 186 insertions, 0 deletions
diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index 0f8fec1f84e..00fb3bd0b8c 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -33,3 +33,8 @@ config ION_TEGRA
help
Choose this option if you wish to use ion on an nVidia Tegra.
+config ION_JUNO
+ bool "Ion for Juno board"
+ depends on ION
+ help
+ ION support for arm juno reference board.
diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile
index b56fd2bf2b4..0c47324a0a8 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -7,4 +7,5 @@ endif
obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o
obj-$(CONFIG_ION_TEGRA) += tegra/
+obj-$(CONFIG_ION_JUNO) += juno/
diff --git a/drivers/staging/android/ion/juno/Makefile b/drivers/staging/android/ion/juno/Makefile
new file mode 100644
index 00000000000..a5a7e42740c
--- /dev/null
+++ b/drivers/staging/android/ion/juno/Makefile
@@ -0,0 +1,2 @@
+obj-y += juno_ion_driver.o
+obj-y += juno_ion_dev.o
diff --git a/drivers/staging/android/ion/juno/juno_ion_dev.c b/drivers/staging/android/ion/juno/juno_ion_dev.c
new file mode 100644
index 00000000000..cee6be3ce3f
--- /dev/null
+++ b/drivers/staging/android/ion/juno/juno_ion_dev.c
@@ -0,0 +1,80 @@
+/*
+ * drivers/gpu/ion/juno/juno_ion_dev.c
+ *
+ * Copyright (C) 2014 ARM, 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/platform_device.h>
+#include <linux/dma-mapping.h>
+#include "../ion.h"
+
+u64 juno_dmamask = DMA_BIT_MASK(64);
+
+struct platform_device juno_device_ion = {
+ .name = "ion-juno",
+ .id = -1,
+};
+
+struct ion_platform_heap juno_heaps[] = {
+ {
+ .id = ION_HEAP_TYPE_SYSTEM,
+ .type = ION_HEAP_TYPE_SYSTEM,
+ .name = "system",
+ },
+ {
+ .id = ION_HEAP_TYPE_SYSTEM_CONTIG,
+ .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
+ .name = "system contig",
+ },
+ {
+ .id = ION_HEAP_TYPE_DMA,
+ .type = ION_HEAP_TYPE_DMA,
+ .name = "ion_dma_heap-3",
+ .priv = &juno_device_ion.dev,
+ }
+};
+
+struct ion_platform_data juno_ion_pdata = {
+ .nr = 3,
+ .heaps = juno_heaps,
+};
+
+static int __init juno_ion_dev_init(void)
+{
+ int ret;
+
+ ret = dma_declare_coherent_memory(&juno_device_ion.dev,
+ 0x60000000, 0x60000000, 0x08000000,
+ DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
+ if (ret < 0)
+ {
+ pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret);
+ return ret;
+ }
+
+ juno_device_ion.dev.platform_data = &juno_ion_pdata;
+ juno_device_ion.dev.coherent_dma_mask = juno_dmamask;
+ juno_device_ion.dev.dma_mask = &juno_dmamask;
+
+ return platform_device_register(&juno_device_ion);
+}
+
+static void __exit juno_ion_dev_exit(void)
+{
+ platform_device_unregister(&juno_device_ion);
+}
+
+module_init(juno_ion_dev_init);
+module_exit(juno_ion_dev_exit);
+
diff --git a/drivers/staging/android/ion/juno/juno_ion_driver.c b/drivers/staging/android/ion/juno/juno_ion_driver.c
new file mode 100644
index 00000000000..eee5fc1f25b
--- /dev/null
+++ b/drivers/staging/android/ion/juno/juno_ion_driver.c
@@ -0,0 +1,98 @@
+/*
+ * drivers/gpu/ion/juno/juno_ion_driver.c
+ *
+ * Copyright (C) 2014 ARM, 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.
+ *
+ * Some parts based on drivers/staging/android/ion/tegra/tegra_ion.c
+ * which is:
+ * Copyright (C) 2011 Google, Inc.
+ */
+
+#include <linux/err.h>
+#include "../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;
+
+int juno_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 juno_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 juno_ion_driver = {
+ .probe = juno_ion_probe,
+ .remove = juno_ion_remove,
+ .driver = { .name = "ion-juno" }
+};
+
+static int __init juno_ion_init(void)
+{
+ return platform_driver_register(&juno_ion_driver);
+}
+
+static void __exit juno_ion_exit(void)
+{
+ platform_driver_unregister(&juno_ion_driver);
+}
+
+module_init(juno_ion_init);
+module_exit(juno_ion_exit);
+