* [PATCH v3 0/4] Add device tree support for on-chip SRAM
@ 2012-09-03 16:02 Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Philipp Zabel @ 2012-09-03 16:02 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
Dong Aisheng, kernel, devicetree-discuss
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 v2, as per Shawn's suggestions:
- Moved struct device_node declaration out of #ifdef CONFIG_OF.
- Simplified of_get_named_gen_pool using of_parse_phandle and
of_address_to_resource.
- Return -EADDRNOTAVAIL if devm_request_and_ioremap fails.
- Squashed i.MX changes together.
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 | 9 +++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++
include/linux/genalloc.h | 14 +++++
lib/genalloc.c | 67 +++++++++++++++++++++
11 files changed, 206 insertions(+), 119 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/4] genalloc: add a global pool list, allow to find pools by phys address
2012-09-03 16:02 [PATCH v3 0/4] Add device tree support for on-chip SRAM Philipp Zabel
@ 2012-09-03 16:02 ` Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Philipp Zabel @ 2012-09-03 16:02 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
Dong Aisheng, kernel, devicetree-discuss
Cc: Philipp Zabel
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>
---
Changes since v2:
- Moved struct device_node declaration out of #ifdef CONFIG_OF.
- Simplified of_get_named_gen_pool using of_parse_phandle and
of_address_to_resource.
---
include/linux/genalloc.h | 14 ++++++++++
lib/genalloc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index 5e98eeb..d498c43 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -33,6 +33,7 @@
* General purpose special memory pool descriptor.
*/
struct gen_pool {
+ struct list_head next_pool; /* pool in global list */
spinlock_t lock;
struct list_head chunks; /* list of chunks in this pool */
int min_alloc_order; /* minimum allocation order */
@@ -78,4 +79,17 @@ extern void gen_pool_for_each_chunk(struct gen_pool *,
void (*)(struct gen_pool *, struct gen_pool_chunk *, void *), void *);
extern size_t gen_pool_avail(struct gen_pool *);
extern size_t gen_pool_size(struct gen_pool *);
+extern struct gen_pool *gen_pool_find_by_phys(phys_addr_t phys);
+
+struct device_node;
+#ifdef CONFIG_OF
+extern struct gen_pool *of_get_named_gen_pool(struct device_node *np,
+ const char *propname, int index);
+#else
+inline struct gen_pool *of_get_named_gen_pool(struct device_node *np,
+ const char *propname, int index)
+{
+ return NULL;
+}
+#endif
#endif /* __GENALLOC_H__ */
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 6bc04aa..90699ac 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -34,6 +34,11 @@
#include <linux/rculist.h>
#include <linux/interrupt.h>
#include <linux/genalloc.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+
+static LIST_HEAD(pools);
+static DEFINE_SPINLOCK(list_lock);
static int set_bits_ll(unsigned long *addr, unsigned long mask_to_set)
{
@@ -152,6 +157,9 @@ struct gen_pool *gen_pool_create(int min_alloc_order, int nid)
spin_lock_init(&pool->lock);
INIT_LIST_HEAD(&pool->chunks);
pool->min_alloc_order = min_alloc_order;
+ spin_lock(&list_lock);
+ list_add_rcu(&pool->next_pool, &pools);
+ spin_unlock(&list_lock);
}
return pool;
}
@@ -234,6 +242,9 @@ void gen_pool_destroy(struct gen_pool *pool)
int order = pool->min_alloc_order;
int bit, end_bit;
+ spin_lock(&list_lock);
+ list_del_rcu(&pool->next_pool);
+ spin_unlock(&list_lock);
list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
list_del(&chunk->next_chunk);
@@ -400,3 +411,59 @@ size_t gen_pool_size(struct gen_pool *pool)
return size;
}
EXPORT_SYMBOL_GPL(gen_pool_size);
+
+/**
+ * gen_pool_find_by_phys - find a pool by physical start address
+ * @phys: physical address as added with gen_pool_add_virt
+ *
+ * Returns the pool that contains the chunk starting at phys,
+ * or NULL if not found.
+ */
+struct gen_pool *gen_pool_find_by_phys(phys_addr_t phys)
+{
+ struct gen_pool *pool, *found = NULL;
+ struct gen_pool_chunk *chunk;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(pool, &pools, next_pool) {
+ list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
+ if (phys == chunk->phys_addr) {
+ found = pool;
+ break;
+ }
+ }
+ }
+ rcu_read_unlock();
+
+ return found;
+}
+EXPORT_SYMBOL_GPL(gen_pool_find_by_phys);
+
+#ifdef CONFIG_OF
+/**
+ * of_get_named_gen_pool - find a pool by phandle property
+ * @np: device node
+ * @propname: property name containing phandle(s)
+ * @index: index into the phandle array
+ *
+ * Returns the pool that contains the chunk starting at the physical
+ * address of the device tree node pointed at by the phandle property,
+ * or NULL if not found.
+ */
+struct gen_pool *of_get_named_gen_pool(struct device_node *np,
+ const char *propname, int index)
+{
+ struct device_node *np_pool;
+ struct resource res;
+ int ret;
+
+ np_pool = of_parse_phandle(np, propname, index);
+ if (!np_pool)
+ return NULL;
+ ret = of_address_to_resource(np_pool, 0, &res);
+ if (ret < 0)
+ return NULL;
+ return gen_pool_find_by_phys((phys_addr_t) res.start);
+}
+EXPORT_SYMBOL_GPL(of_get_named_gen_pool);
+#endif /* CONFIG_OF */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/4] misc: Generic on-chip SRAM allocation driver
2012-09-03 16:02 [PATCH v3 0/4] Add device tree support for on-chip SRAM Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
@ 2012-09-03 16:02 ` Philipp Zabel
2012-09-05 4:03 ` Shawn Guo
2012-09-03 16:02 ` [PATCH v3 3/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Philipp Zabel @ 2012-09-03 16:02 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
Dong Aisheng, kernel, devicetree-discuss
Cc: Philipp Zabel
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>
---
Changes since v2:
- Return -EADDRNOTAVAIL if devm_request_and_ioremap fails.
---
drivers/misc/Kconfig | 9 +++++
drivers/misc/Makefile | 1 +
drivers/misc/sram.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 115 insertions(+)
create mode 100644 drivers/misc/sram.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 98a442d..9a3395f 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -509,6 +509,15 @@ config USB_SWITCH_FSA9480
stereo and mono audio, video, microphone and UART data to use
a common connector port.
+config SRAM
+ bool "Generic on-chip SRAM driver"
+ depends on HAS_IOMEM
+ 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"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b88df7a..ccc759a 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -50,3 +50,4 @@ obj-y += carma/
obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/
obj-$(CONFIG_INTEL_MEI) += mei/
+obj-$(CONFIG_SRAM) += sram.o
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
new file mode 100644
index 0000000..d6e1230
--- /dev/null
+++ b/drivers/misc/sram.c
@@ -0,0 +1,105 @@
+/*
+ * Generic on-chip SRAM allocation driver
+ *
+ * Copyright (C) 2012 Philipp Zabel, Pengutronix
+ *
+ * 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/module.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/spinlock.h>
+#include <linux/genalloc.h>
+
+struct sram_dev {
+ struct gen_pool *pool;
+};
+
+static int __devinit sram_probe(struct platform_device *pdev)
+{
+ void __iomem *virt_base;
+ struct sram_dev *sram;
+ struct resource *res;
+ unsigned long size;
+ int ret;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
+
+ size = resource_size(res);
+
+ virt_base = devm_request_and_ioremap(&pdev->dev, res);
+ if (!virt_base)
+ return -EADDRNOTAVAIL;
+
+ sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
+ if (!sram)
+ return -ENOMEM;
+
+ sram->pool = gen_pool_create(PAGE_SHIFT, -1);
+ if (!sram->pool)
+ return -ENOMEM;
+
+ ret = gen_pool_add_virt(sram->pool, (unsigned long)virt_base,
+ res->start, size, -1);
+ if (ret < 0) {
+ gen_pool_destroy(sram->pool);
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, sram);
+
+ dev_dbg(&pdev->dev, "SRAM pool: %ld KiB @ 0x%p\n", size / 1024, virt_base);
+
+ return 0;
+}
+
+static int __devexit sram_remove(struct platform_device *pdev)
+{
+ struct sram_dev *sram = platform_get_drvdata(pdev);
+
+ if (gen_pool_avail(sram->pool) < gen_pool_size(sram->pool))
+ dev_dbg(&pdev->dev, "removed while SRAM allocated\n");
+
+ gen_pool_destroy(sram->pool);
+
+ return 0;
+}
+
+#ifdef CONFIG_OF
+static struct of_device_id sram_dt_ids[] = {
+ { .compatible = "sram" },
+ { /* sentinel */ }
+};
+#endif
+
+static struct platform_driver sram_driver = {
+ .driver = {
+ .name = "sram",
+ .of_match_table = of_match_ptr(sram_dt_ids),
+ },
+ .probe = sram_probe,
+ .remove = __devexit_p(sram_remove),
+};
+
+module_platform_driver(sram_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Philipp Zabel, Pengutronix");
+MODULE_DESCRIPTION("Generic SRAM allocator driver");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/4] ARM: dts: add sram for imx53 and imx6q
2012-09-03 16:02 [PATCH v3 0/4] Add device tree support for on-chip SRAM Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
@ 2012-09-03 16:02 ` Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 4/4] ARM i.MX: remove IRAM_ALLOC facility Philipp Zabel
2012-09-04 1:12 ` [PATCH v3 0/4] Add device tree support for on-chip SRAM Shawn Guo
4 siblings, 0 replies; 7+ messages in thread
From: Philipp Zabel @ 2012-09-03 16:02 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
Dong Aisheng, kernel, devicetree-discuss
Cc: Philipp Zabel
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
arch/arm/boot/dts/imx53.dtsi | 5 +++++
arch/arm/boot/dts/imx6q.dtsi | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index cd37165..2767a92 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -337,5 +337,10 @@
status = "disabled";
};
};
+
+ ocram: ocram@f8000000 {
+ compatible = "fsl,imx-ocram", "sram";
+ reg = <0xf8000000 0x20000>;
+ };
};
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fd57079..1e463c4 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -111,6 +111,11 @@
status = "disabled";
};
+ ocram: ocram@00900000 {
+ compatible = "fsl,imx-ocram", "sram";
+ reg = <0x00900000 0x3f000>;
+ };
+
timer@00a00600 {
compatible = "arm,cortex-a9-twd-timer";
reg = <0x00a00600 0x20>;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/4] ARM i.MX: remove IRAM_ALLOC facility
2012-09-03 16:02 [PATCH v3 0/4] Add device tree support for on-chip SRAM Philipp Zabel
` (2 preceding siblings ...)
2012-09-03 16:02 ` [PATCH v3 3/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
@ 2012-09-03 16:02 ` Philipp Zabel
2012-09-04 1:12 ` [PATCH v3 0/4] Add device tree support for on-chip SRAM Shawn Guo
4 siblings, 0 replies; 7+ messages in thread
From: Philipp Zabel @ 2012-09-03 16:02 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
Dong Aisheng, kernel, devicetree-discuss
Cc: Philipp Zabel
A generic on-chip SRAM allocator driver can be used instead.
Users of the iram_alloc/free API should convert to the genalloc API:
- virt = iram_alloc(SIZE, &phys);
+ gen_pool_alloc(iram_pool, SIZE);
+ phys = gen_pool_virt_to_phys(iram_pool, virt);
/* ... */
- iram_free(virt, SIZE);
+ gen_pool_free(iram_pool, virt, SIZE);
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
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 ---------------------------------
4 files changed, 119 deletions(-)
delete mode 100644 arch/arm/plat-mxc/include/mach/iram.h
delete mode 100644 arch/arm/plat-mxc/iram_alloc.c
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index baf9064..8e63f10 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -82,8 +82,4 @@ config IMX_HAVE_IOMUX_V1
config ARCH_MXC_IOMUX_V3
bool
-config IRAM_ALLOC
- bool
- select GENERIC_ALLOCATOR
-
endif
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index 6ac7200..bdf370f 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -10,7 +10,6 @@ obj-$(CONFIG_MXC_AVIC) += avic.o
obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o
obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
-obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o
obj-$(CONFIG_MXC_ULPI) += ulpi.o
obj-$(CONFIG_MXC_USE_EPIT) += epit.o
obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
diff --git a/arch/arm/plat-mxc/include/mach/iram.h b/arch/arm/plat-mxc/include/mach/iram.h
deleted file mode 100644
index 022690c..0000000
--- a/arch/arm/plat-mxc/include/mach/iram.h
+++ /dev/null
@@ -1,41 +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
-
-int __init iram_init(unsigned long base, unsigned long size);
-void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr);
-void iram_free(unsigned long dma_addr, unsigned int size);
-
-#else
-
-static inline int __init iram_init(unsigned long base, unsigned long size)
-{
- return -ENOMEM;
-}
-
-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
diff --git a/arch/arm/plat-mxc/iram_alloc.c b/arch/arm/plat-mxc/iram_alloc.c
deleted file mode 100644
index 074c386..0000000
--- a/arch/arm/plat-mxc/iram_alloc.c
+++ /dev/null
@@ -1,73 +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 <mach/iram.h>
-
-static unsigned long iram_phys_base;
-static void __iomem *iram_virt_base;
-static struct gen_pool *iram_pool;
-
-static inline void __iomem *iram_phys_to_virt(unsigned long p)
-{
- return iram_virt_base + (p - iram_phys_base);
-}
-
-void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
-{
- if (!iram_pool)
- return NULL;
-
- *dma_addr = gen_pool_alloc(iram_pool, size);
- pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
- if (!*dma_addr)
- return NULL;
- return iram_phys_to_virt(*dma_addr);
-}
-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);
-
-int __init iram_init(unsigned long base, unsigned long size)
-{
- iram_phys_base = base;
-
- iram_pool = gen_pool_create(PAGE_SHIFT, -1);
- if (!iram_pool)
- return -ENOMEM;
-
- gen_pool_add(iram_pool, base, size, -1);
- iram_virt_base = ioremap(iram_phys_base, size);
- if (!iram_virt_base)
- return -EIO;
-
- pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
- return 0;
-}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] Add device tree support for on-chip SRAM
2012-09-03 16:02 [PATCH v3 0/4] Add device tree support for on-chip SRAM Philipp Zabel
` (3 preceding siblings ...)
2012-09-03 16:02 ` [PATCH v3 4/4] ARM i.MX: remove IRAM_ALLOC facility Philipp Zabel
@ 2012-09-04 1:12 ` Shawn Guo
4 siblings, 0 replies; 7+ messages in thread
From: Shawn Guo @ 2012-09-04 1:12 UTC (permalink / raw)
To: Philipp Zabel
Cc: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Richard Zhao, Huang Shijie, Dong Aisheng, kernel,
devicetree-discuss
On Mon, Sep 03, 2012 at 06:02:04PM +0200, Philipp Zabel wrote:
> Changes since v2, as per Shawn's suggestions:
> - Moved struct device_node declaration out of #ifdef CONFIG_OF.
> - Simplified of_get_named_gen_pool using of_parse_phandle and
> of_address_to_resource.
> - Return -EADDRNOTAVAIL if devm_request_and_ioremap fails.
> - Squashed i.MX changes together.
>
For the series:
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
Though it will be very simple one, we may still need a binding doc for
that "sram" driver.
Regards,
Shawn
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/4] misc: Generic on-chip SRAM allocation driver
2012-09-03 16:02 ` [PATCH v3 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
@ 2012-09-05 4:03 ` Shawn Guo
0 siblings, 0 replies; 7+ messages in thread
From: Shawn Guo @ 2012-09-05 4:03 UTC (permalink / raw)
To: Philipp Zabel
Cc: linux-kernel, linux-arm-kernel, Grant Likely, Rob Herring,
Paul Gortmaker, Richard Zhao, Huang Shijie, Dong Aisheng, kernel,
devicetree-discuss
On Mon, Sep 03, 2012 at 06:02:06PM +0200, Philipp Zabel wrote:
> +static struct platform_driver sram_driver = {
> + .driver = {
> + .name = "sram",
> + .of_match_table = of_match_ptr(sram_dt_ids),
> + },
> + .probe = sram_probe,
> + .remove = __devexit_p(sram_remove),
> +};
> +
> +module_platform_driver(sram_driver);
I think we'd better make it a postcore_initcall time driver, so that
it can be ensured that when the client drivers call gen_pool_* API
the pool has been created by sram_driver.
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-09-05 4:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 16:02 [PATCH v3 0/4] Add device tree support for on-chip SRAM Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
2012-09-05 4:03 ` Shawn Guo
2012-09-03 16:02 ` [PATCH v3 3/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
2012-09-03 16:02 ` [PATCH v3 4/4] ARM i.MX: remove IRAM_ALLOC facility Philipp Zabel
2012-09-04 1:12 ` [PATCH v3 0/4] Add device tree support for on-chip SRAM Shawn Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).