From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-08-31 09:29:42
These patches add support to configure on-chip SRAM via device-tree
node and to obtain the resulting genalloc pool from a phandle pointing
at the node.
This allows drivers to allocate SRAM with the genalloc API without
hard-coding the genalloc pool address.
The on-chip SRAM on i.MX53 and i.MX6q is registered via device tree and
changed to use the simple generic SRAM driver:
ocram: ocram@00900000 {
compatible = "fsl,imx-ocram", "sram";
reg = <0x00900000 0x3f000>;
};
A driver that needs to allocate SRAM buffers, like the video processing
unit on i.MX53, can retrieve the genalloc pool from a phandle in the
device tree using of_get_named_gen_pool(node, "iram", 0) from patch 5:
vpu@63ff4000 {
/* ... */
iram = <&ocram>;
};
Changes since v1:
- Added a generic SRAM driver in drivers/misc that does nothing but
request/ioremap its given memory region and serve it via the genalloc
API.
- Renamed the i.MX device tree nodes from "iram" to "ocram".
regards
Philipp
---
arch/arm/boot/dts/imx53.dtsi | 5 ++
arch/arm/boot/dts/imx6q.dtsi | 5 ++
arch/arm/plat-mxc/Kconfig | 4 --
arch/arm/plat-mxc/Makefile | 1 -
arch/arm/plat-mxc/include/mach/iram.h | 41 -------------
arch/arm/plat-mxc/iram_alloc.c | 73 -----------------------
drivers/misc/Kconfig | 8 +++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++
include/linux/genalloc.h | 14 +++++
lib/genalloc.c | 77 ++++++++++++++++++++++++
11 files changed, 215 insertions(+), 119 deletions(-)
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-08-31 09:27:17
This driver requests and remaps a memory region as configured in the
device tree. It serves memory from this region via the genalloc API.
Other drivers can retrieve the genalloc pool from a phandle pointing
to this drivers' device node in the device tree.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/misc/Kconfig | 8 ++++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 drivers/misc/sram.c
@@ -1,35 +0,0 @@-/*- * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.- *- * This program is free software; you can redistribute it and/or- * modify it under the terms of the GNU General Public License- * as published by the Free Software Foundation; either version 2- * of the License, or (at your option) any later version.- *- * 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.- *- * You should have received a copy of the GNU General Public License- * along with this program; if not, write to the Free Software- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,- * MA 02110-1301, USA.- */-#include <linux/errno.h>--#ifdef CONFIG_IRAM_ALLOC--void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr);-void iram_free(unsigned long dma_addr, unsigned int size);--#else--static inline void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)-{- return NULL;-}--static inline void iram_free(unsigned long base, unsigned long size) {}--#endif
@@ -1,116 +0,0 @@-/*- * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.- *- * This program is free software; you can redistribute it and/or- * modify it under the terms of the GNU General Public License- * as published by the Free Software Foundation; either version 2- * of the License, or (at your option) any later version.- *- * 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.- *- * You should have received a copy of the GNU General Public License- * along with this program; if not, write to the Free Software- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,- * MA 02110-1301, USA.- */--#include <linux/kernel.h>-#include <linux/io.h>-#include <linux/module.h>-#include <linux/spinlock.h>-#include <linux/genalloc.h>-#include <linux/of.h>-#include <linux/platform_device.h>-#include <mach/iram.h>--static struct gen_pool *iram_pool;--void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)-{- unsigned long virt;-- if (!iram_pool)- return NULL;-- virt = gen_pool_alloc(iram_pool, size);- pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);- if (!virt)- return NULL;-- *dma_addr = gen_pool_virt_to_phys(iram_pool, virt);- return (void __iomem *)virt;-}-EXPORT_SYMBOL(iram_alloc);--void iram_free(unsigned long addr, unsigned int size)-{- if (!iram_pool)- return;-- gen_pool_free(iram_pool, addr, size);-}-EXPORT_SYMBOL(iram_free);--static int __devinit iram_probe(struct platform_device *pdev)-{- void __iomem *virt_base;- struct resource *res;- unsigned long size;- int ret;-- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);- if (!res)- return -EINVAL;-- if (iram_pool)- return -EBUSY;-- size = resource_size(res);-- virt_base = devm_ioremap(&pdev->dev, res->start, size);- if (!virt_base)- return -ENOMEM;-- iram_pool = gen_pool_create(PAGE_SHIFT, -1);- if (!iram_pool)- return -ENOMEM;-- ret = gen_pool_add_virt(iram_pool, (unsigned long)virt_base,- res->start, size, -1);- if (ret < 0) {- gen_pool_destroy(iram_pool);- iram_pool = NULL;- return ret;- }-- pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, virt_base);- return 0;-}--static int __devexit iram_remove(struct platform_device *pdev)-{- gen_pool_destroy(iram_pool);- iram_pool = NULL;- return 0;-}--#ifdef CONFIG_OF-static struct of_device_id iram_dt_ids[] = {- { .compatible = "fsl,imx-iram" },- { /* sentinel */ }-};-#endif--static struct platform_driver iram_driver = {- .driver = {- .name = "imx-iram",- .of_match_table = of_match_ptr(iram_dt_ids),- },- .probe = iram_probe,- .remove = __devexit_p(iram_remove),-};--module_platform_driver(iram_driver);
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-08-31 09:28:58
This patch keeps all created pools in a global list and adds two
functions that allow to retrieve the gen_pool pointer from a known
physical address and from a device tree node.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
include/linux/genalloc.h | 14 +++++++++
lib/genalloc.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
@@ -33,6 +33,7 @@*Generalpurposespecialmemorypooldescriptor.*/structgen_pool{+structlist_headnext_pool;/* pool in global list */spinlock_tlock;structlist_headchunks;/* list of chunks in this pool */intmin_alloc_order;/* minimum allocation order */
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-08-31 09:29:20
This improves the symmetry of iram_alloc and iram_free in that
iram_free has to be called with the virtual address now.
Also, gen_pool_virt_to_phys is now functional.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
arch/arm/plat-mxc/iram_alloc.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-08-31 09:29:40
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
- Renamed "iram" to "ocram" as it appears in the processor
reference manuals.
---
arch/arm/boot/dts/imx53.dtsi | 5 +++++
1 file changed, 5 insertions(+)
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-08-31 09:29:41
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1:
- Renamed "iram" to "ocram" as it appears in the processor
reference manuals.
---
arch/arm/boot/dts/imx6q.dtsi | 5 +++++
1 file changed, 5 insertions(+)
From: Jan Lübbe <jlu@pengutronix.de> Date: 2012-08-31 09:37:35
On Fri, 2012-08-31 at 11:27 +0200, Philipp Zabel wrote:
This driver requests and remaps a memory region as configured in the
device tree. It serves memory from this region via the genalloc API.
Other drivers can retrieve the genalloc pool from a phandle pointing
to this drivers' device node in the device tree.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/misc/Kconfig | 8 ++++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 drivers/misc/sram.c
We now have drivers/memory, which seems to be a good place for this.
Regards,
Jan
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On Fri, Aug 31, 2012 at 2:37 AM, Jan Lübbe [off-list ref] wrote:
On Fri, 2012-08-31 at 11:27 +0200, Philipp Zabel wrote:
quoted
This driver requests and remaps a memory region as configured in the
device tree. It serves memory from this region via the genalloc API.
Other drivers can retrieve the genalloc pool from a phandle pointing
to this drivers' device node in the device tree.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/misc/Kconfig | 8 ++++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105
+++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 drivers/misc/sram.c
We now have drivers/memory, which seems to be a good place for this.
drivers/memory is created for Memory controller device drivers. SRAM is
just pool of memory and should belong to some other place.
Regards
Santosh
I do not understand the point of introducing those imx patches, 1 ~ 4
and 7, 8. They are all unnecessary churns to me. IMO, 4 patches are
enough.
* genalloc: add a global pool list, allow to find pools by phys address
* misc: Generic on-chip SRAM allocation driver
* ARM i.MX: remove IRAM_ALLOC facility
* ARM: dts: add sram for imx53 and imx6q
Regards,
Shawn
On Fri, Aug 31, 2012 at 11:26:55AM +0200, Philipp Zabel wrote:
These patches add support to configure on-chip SRAM via device-tree
node and to obtain the resulting genalloc pool from a phandle pointing
at the node.
This allows drivers to allocate SRAM with the genalloc API without
hard-coding the genalloc pool address.
The on-chip SRAM on i.MX53 and i.MX6q is registered via device tree and
changed to use the simple generic SRAM driver:
ocram: ocram@00900000 {
compatible = "fsl,imx-ocram", "sram";
reg = <0x00900000 0x3f000>;
};
A driver that needs to allocate SRAM buffers, like the video processing
unit on i.MX53, can retrieve the genalloc pool from a phandle in the
device tree using of_get_named_gen_pool(node, "iram", 0) from patch 5:
vpu@63ff4000 {
/* ... */
iram = <&ocram>;
};
Changes since v1:
- Added a generic SRAM driver in drivers/misc that does nothing but
request/ioremap its given memory region and serve it via the genalloc
API.
- Renamed the i.MX device tree nodes from "iram" to "ocram".
regards
Philipp
---
arch/arm/boot/dts/imx53.dtsi | 5 ++
arch/arm/boot/dts/imx6q.dtsi | 5 ++
arch/arm/plat-mxc/Kconfig | 4 --
arch/arm/plat-mxc/Makefile | 1 -
arch/arm/plat-mxc/include/mach/iram.h | 41 -------------
arch/arm/plat-mxc/iram_alloc.c | 73 -----------------------
drivers/misc/Kconfig | 8 +++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++
include/linux/genalloc.h | 14 +++++
lib/genalloc.c | 77 ++++++++++++++++++++++++
11 files changed, 215 insertions(+), 119 deletions(-)
On Fri, Aug 31, 2012 at 11:27:00AM +0200, Philipp Zabel wrote:
quoted hunk
This patch keeps all created pools in a global list and adds two
functions that allow to retrieve the gen_pool pointer from a known
physical address and from a device tree node.
Signed-off-by: Philipp Zabel <redacted>
---
include/linux/genalloc.h | 14 +++++++++
lib/genalloc.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
@@ -33,6 +33,7 @@*Generalpurposespecialmemorypooldescriptor.*/structgen_pool{+structlist_headnext_pool;/* pool in global list */spinlock_tlock;structlist_headchunks;/* list of chunks in this pool */intmin_alloc_order;/* minimum allocation order */
On Fri, Aug 31, 2012 at 11:27:01AM +0200, Philipp Zabel wrote:
quoted hunk
This driver requests and remaps a memory region as configured in the
device tree. It serves memory from this region via the genalloc API.
Other drivers can retrieve the genalloc pool from a phandle pointing
to this drivers' device node in the device tree.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/misc/Kconfig | 8 ++++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 drivers/misc/sram.c
+ select GENERIC_ALLOCATOR
+ help
+ This driver allows to declare a memory region to be managed
+ by the genalloc API. It is supposed to be used for small
+ on-chip SRAM areas found on many ARM SoCs.
+
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2012-09-03 15:42:49
Hi Shawn,
Am Montag, den 03.09.2012, 09:53 +0800 schrieb Shawn Guo:
I do not understand the point of introducing those imx patches, 1 ~ 4
and 7, 8. They are all unnecessary churns to me. IMO, 4 patches are
enough.
* genalloc: add a global pool list, allow to find pools by phys address
* misc: Generic on-chip SRAM allocation driver
* ARM i.MX: remove IRAM_ALLOC facility
* ARM: dts: add sram for imx53 and imx6q
Regards,
Shawn
Thanks, I thought that first making the iram_alloc API work would
decouple this a bit from the coda vpu patches that depend on sram
support on imx53/6q. I'll work in your comments and reduce the patch
count as you propose.
regards
Philipp