]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
sh: Add memory chunks to SH-Mobile UIO devices
authorMagnus Damm <damm@igel.co.jp>
Wed, 16 Jul 2008 10:02:54 +0000 (19:02 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 28 Jul 2008 09:10:35 +0000 (18:10 +0900)
This patch adds physically contiguous memory chunks to the UIO devices.
The same strategy can be used in the future for the CEU as well.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/mm/consistent.c
include/asm-sh/device.h

index bcc4255acd8485a727e560f479e2d5e57cbb73f1..79ce34e19a2e99ef9e77061a0172164148ce79ac 100644 (file)
@@ -66,6 +66,9 @@ static struct resource vpu_resources[] = {
                .end    = 0xfe9022eb,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device vpu_device = {
@@ -91,6 +94,9 @@ static struct resource veu_resources[] = {
                .end    = 0xfe9200b7,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device veu_device = {
@@ -132,6 +138,8 @@ static struct platform_device *sh7343_devices[] __initdata = {
 
 static int __init sh7343_devices_setup(void)
 {
+       platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20);
+       platform_resource_setup_memory(&veu_device, "veu", 2 << 20);
        return platform_add_devices(sh7343_devices,
                                    ARRAY_SIZE(sh7343_devices));
 }
index 2a0fbc3ed9c20b92a7607af47960a9324d5976b5..7ee01757f3fe8b936ed8ae09218fe79f69f09757 100644 (file)
@@ -48,6 +48,9 @@ static struct resource vpu_resources[] = {
                .end    = 0xfe902807,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device vpu_device = {
@@ -73,6 +76,9 @@ static struct resource veu0_resources[] = {
                .end    = 0xfe9200b7,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device veu0_device = {
@@ -98,6 +104,9 @@ static struct resource veu1_resources[] = {
                .end    = 0xfe9240b7,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device veu1_device = {
@@ -139,6 +148,9 @@ static struct platform_device *sh7366_devices[] __initdata = {
 
 static int __init sh7366_devices_setup(void)
 {
+       platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20);
+       platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20);
+       platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
        return platform_add_devices(sh7366_devices,
                                    ARRAY_SIZE(sh7366_devices));
 }
index 39854d9413cfddec2bb380d47c7a7c89fb1602ae..6015f842edad624c0d0051f4e4b1b4c1abc7bf7d 100644 (file)
@@ -73,6 +73,9 @@ static struct resource vpu_resources[] = {
                .end    = 0xfe9022eb,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device vpu_device = {
@@ -98,6 +101,9 @@ static struct resource veu_resources[] = {
                .end    = 0xfe9200b7,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device veu_device = {
@@ -152,6 +158,8 @@ static struct platform_device *sh7722_devices[] __initdata = {
 
 static int __init sh7722_devices_setup(void)
 {
+       platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20);
+       platform_resource_setup_memory(&veu_device, "veu", 2 << 20);
        return platform_add_devices(sh7722_devices,
                                    ARRAY_SIZE(sh7722_devices));
 }
index 1f3137ad0136a4e4ed527d412c75128523166108..cb5e6f822e64797af395b51374756f4050e41c98 100644 (file)
@@ -28,6 +28,9 @@ static struct resource vpu_resources[] = {
                .end    = 0xfe902807,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device vpu_device = {
@@ -53,6 +56,9 @@ static struct resource veu0_resources[] = {
                .end    = 0xfe92027b,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device veu0_device = {
@@ -78,6 +84,9 @@ static struct resource veu1_resources[] = {
                .end    = 0xfe92427b,
                .flags  = IORESOURCE_MEM,
        },
+       [1] = {
+               /* place holder for contiguous memory */
+       },
 };
 
 static struct platform_device veu1_device = {
@@ -221,6 +230,9 @@ static struct platform_device *sh7723_devices[] __initdata = {
 
 static int __init sh7723_devices_setup(void)
 {
+       platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20);
+       platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20);
+       platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
        return platform_add_devices(sh7723_devices,
                                    ARRAY_SIZE(sh7723_devices));
 }
index d3c33fc5b1c2d252bc739717c8d5dd50dd096482..8277982d0938d06aa390e6cdaa7af3d4d9d4e5bb 100644 (file)
@@ -10,6 +10,7 @@
  * for more details.
  */
 #include <linux/mm.h>
+#include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <asm/cacheflush.h>
 #include <asm/addrspace.h>
@@ -185,3 +186,32 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
        }
 }
 EXPORT_SYMBOL(dma_cache_sync);
+
+int platform_resource_setup_memory(struct platform_device *pdev,
+                                  char *name, unsigned long memsize)
+{
+       struct resource *r;
+       dma_addr_t dma_handle;
+       void *buf;
+
+       r = pdev->resource + pdev->num_resources - 1;
+       if (r->flags) {
+               pr_warning("%s: unable to find empty space for resource\n",
+                       name);
+               return -EINVAL;
+       }
+
+       buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL);
+       if (!buf) {
+               pr_warning("%s: unable to allocate memory\n", name);
+               return -ENOMEM;
+       }
+
+       memset(buf, 0, memsize);
+
+       r->flags = IORESOURCE_MEM;
+       r->start = dma_handle;
+       r->end = r->start + memsize - 1;
+       r->name = name;
+       return 0;
+}
index d8f9872b0e2dc3587a9e658adc957f093b7906fb..efd511d0803ad4002fcb73f8a04af39aa51eede3 100644 (file)
@@ -5,3 +5,8 @@
  */
 #include <asm-generic/device.h>
 
+struct platform_device;
+/* allocate contiguous memory chunk and fill in struct resource */
+int platform_resource_setup_memory(struct platform_device *pdev,
+                                  char *name, unsigned long memsize);
+