aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/iram_alloc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-12 14:51:39 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-12 14:51:39 -0500
commitd01e4afdbb65e030fd6f1f96c30a558e2eb0f279 (patch)
tree02ef82b2740cf93a98199eded5ef765fa6e03052 /arch/arm/mach-imx/iram_alloc.c
parent8287361abca36504da813638310d2547469283eb (diff)
parent794b175fc0c0c4844dbb7b137a73bbfd01f6c608 (diff)
Merge tag 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC cleanups on various subarchitectures from Olof Johansson: "Cleanup patches for various ARM platforms and some of their associated drivers. There's also a branch in here that enables Freescale i.MX to be part of the multiplatform support -- the first "big" SoC that is moved over (more multiplatform work comes in a separate branch later during the merge window)." Conflicts fixed as per Olof, including a silent semantic one in arch/arm/mach-omap2/board-generic.c (omap_prcm_restart() was renamed to omap3xxx_restart(), and a new user of the old name was added). * tag 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (189 commits) ARM: omap: fix typo on timer cleanup ARM: EXYNOS: Remove unused regs-mem.h file ARM: EXYNOS: Remove unused non-dt support for dwmci controller ARM: Kirkwood: Use hw_pci.ops instead of hw_pci.scan ARM: OMAP3: cm-t3517: use GPTIMER for system clock ARM: OMAP2+: timer: remove CONFIG_OMAP_32K_TIMER ARM: SAMSUNG: use devm_ functions for ADC driver ARM: EXYNOS: no duplicate mask/unmask in eint0_15 ARM: S3C24XX: SPI clock channel setup is fixed for S3C2443 ARM: EXYNOS: Remove i2c0 resource information and setting of device names ARM: Kirkwood: checkpatch cleanups ARM: Kirkwood: Fix sparse warnings. ARM: Kirkwood: Remove unused includes ARM: kirkwood: cleanup lsxl board includes ARM: integrator: use BUG_ON where possible ARM: integrator: push down SC dependencies ARM: integrator: delete static UART1 mapping ARM: integrator: delete SC mapping on the CP ARM: integrator: remove static CP syscon mapping ARM: integrator: remove static AP syscon mapping ...
Diffstat (limited to 'arch/arm/mach-imx/iram_alloc.c')
-rw-r--r--arch/arm/mach-imx/iram_alloc.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/iram_alloc.c b/arch/arm/mach-imx/iram_alloc.c
new file mode 100644
index 000000000000..6c80424f678e
--- /dev/null
+++ b/arch/arm/mach-imx/iram_alloc.c
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20#include <linux/kernel.h>
21#include <linux/io.h>
22#include <linux/module.h>
23#include <linux/spinlock.h>
24#include <linux/genalloc.h>
25
26#include "iram.h"
27
28static unsigned long iram_phys_base;
29static void __iomem *iram_virt_base;
30static struct gen_pool *iram_pool;
31
32static inline void __iomem *iram_phys_to_virt(unsigned long p)
33{
34 return iram_virt_base + (p - iram_phys_base);
35}
36
37void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
38{
39 if (!iram_pool)
40 return NULL;
41
42 *dma_addr = gen_pool_alloc(iram_pool, size);
43 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
44 if (!*dma_addr)
45 return NULL;
46 return iram_phys_to_virt(*dma_addr);
47}
48EXPORT_SYMBOL(iram_alloc);
49
50void iram_free(unsigned long addr, unsigned int size)
51{
52 if (!iram_pool)
53 return;
54
55 gen_pool_free(iram_pool, addr, size);
56}
57EXPORT_SYMBOL(iram_free);
58
59int __init iram_init(unsigned long base, unsigned long size)
60{
61 iram_phys_base = base;
62
63 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
64 if (!iram_pool)
65 return -ENOMEM;
66
67 gen_pool_add(iram_pool, base, size, -1);
68 iram_virt_base = ioremap(iram_phys_base, size);
69 if (!iram_virt_base)
70 return -EIO;
71
72 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
73 return 0;
74}