it is to use ion_platform_heap like this in board configuration file.


It is only an example for test purpose do not merge it
It create 2 heaps (#1 and #2) where we can allocate/mmap/free buffers
from userland application

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 arch/arm/mach-ux500/board-mop500.c |   60 ++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index bdd7b80..b0242f5 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -50,6 +50,45 @@
 #include "board-mop500.h"
 #include "board-mop500-regulators.h"

+#ifdef CONFIG_ION
+#include <linux/ion.h>
+#include <linux/dma-contiguous.h>
+#endif
+
+#ifdef CONFIG_ION_CMA
+
+struct ion_platform_heap snowball_ion_heaps[] = {
+       [0] = {
+               .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
+               .id = 1,
+               .name = "ion-cma-heap-1",
+               .base = 0,
+               .size = (16 * SZ_1M),
+       },
+       [1] = {
+               .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
+               .id = 2,
+               .name = "ion-cma-heap-2",
+               .base = 0,
+               .size = (16 * SZ_1M),
+       },
+};
+
+static struct ion_platform_data snowball_ion_data = {
+       .heaps = snowball_ion_heaps,
+       .nr = ARRAY_SIZE(snowball_ion_heaps),
+};
+
+static struct platform_device snowball_ion_device = {
+       .name = "ion-cma",
+       .id = -1,
+       .dev = {
+               .platform_data = &snowball_ion_data,
+       },
+       .num_resources = 0,
+};
+#endif
+
 static struct gpio_led snowball_led_array[] = {
       {
               .name = "user_led",
@@ -598,8 +637,26 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
       &snowball_key_dev,
       &snowball_sbnet_dev,
       &ab8500_device,
+#ifdef CONFIG_ION_CMA
+       &snowball_ion_device,
+#endif
 };

+#ifdef CONFIG_ION_CMA
+static void __init mop500_reserve(void)
+{
+       int err;
+       struct ion_platform_data *data = snowball_ion_device.dev.platform_data;
+
+       err = dma_declare_contiguous(&snowball_ion_device.dev,
+                               data->heaps[0].size, data->heaps[0].base, 0);
+       if (err)
+               printk(KERN_ERR "ION CMA: can't declare dma contiguous\n");
+       else
+               printk(KERN_INFO "%s: reserve OK\n", __func__);
+}
+#endif
+
 static void __init mop500_init_machine(void)
 {
       int i2c0_devs;
@@ -713,4 +770,7 @@ MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
       /* we re-use nomadik timer here */
       .timer          = &ux500_timer,
       .init_machine   = snowball_init_machine,
+#ifdef CONFIG_ION_CMA
+       .reserve        = mop500_reserve,
+#endif
 MACHINE_END 

2012/3/13 Rebecca Schultz Zavin <rschultz@google.com>


On Tue, Mar 13, 2012 at 7:09 AM, <benjamin.gaignard@stericsson.com> wrote:
From: Benjamin Gaignard <benjamin.gaignard@linaro.org>

fix ion_platform_heap to make is use an usual way in board configuration file.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 include/linux/ion.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/ion.h b/include/linux/ion.h
index aed8349..1468cb3 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -83,7 +83,7 @@ struct ion_platform_heap {
 */
 struct ion_platform_data {
       int nr;
-       struct ion_platform_heap heaps[];
+       struct ion_platform_heap *heaps;
 };

 /**

Can you give me some context on why you need this change?  
 
--
1.7.0.4


_______________________________________________
Linaro-mm-sig mailing list
Linaro-mm-sig@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-mm-sig


_______________________________________________
Linaro-mm-sig mailing list
Linaro-mm-sig@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-mm-sig




--

Benjamin Gaignard 

Multimedia Working Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog