From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH v2 1/4] of: separate out "generic" memory bank adding
Date: Sun, 12 May 2013 23:54:03 +0400 [thread overview]
Message-ID: <1368388446-31669-2-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1368388446-31669-1-git-send-email-antonynpavlov@gmail.com>
This patch separates out the "generic" memory
segment registration function (of_add_memory_bank())
from of_add_memory().
The MIPS architecture has different view on memory
resources than the ARM and PPC architectures
so the "generic" of_add_memory_bank() is
unusable for the MIPS architecture.
We can add MIPS-specific of_add_memory_bank()
into arch/mips code.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/of/Kconfig | 5 +++++
drivers/of/Makefile | 1 +
drivers/of/base.c | 8 +-------
drivers/of/mem_generic.c | 15 +++++++++++++++
include/of.h | 2 ++
5 files changed, 24 insertions(+), 7 deletions(-)
create mode 100644 drivers/of/mem_generic.c
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 56762e4..ffe063e 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -1,6 +1,11 @@
config OFTREE
bool
+config OFTREE_MEM_GENERIC
+ depends on OFTREE
+ depends on PPC || ARM
+ def_bool y
+
config DTC
bool
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index d16a946..c81bbec 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,4 +1,5 @@
obj-y += base.o fdt.o
+obj-$(CONFIG_OFTREE_MEM_GENERIC) += mem_generic.o
obj-$(CONFIG_GPIOLIB) += gpio.o
obj-y += partition.o
obj-y += of_net.o
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8383549..1158132 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -873,7 +873,6 @@ int of_add_memory(struct device_node *node, bool dump)
int na, nc;
const __be32 *reg, *endp;
int len, r = 0, ret;
- static char str[6];
const char *device_type;
ret = of_property_read_string(node, "device_type", &device_type);
@@ -900,12 +899,7 @@ int of_add_memory(struct device_node *node, bool dump)
if (size == 0)
continue;
- sprintf(str, "ram%d", r);
-
- barebox_add_memory_bank(str, base, size);
-
- if (dump)
- pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+ of_add_memory_bank(node, dump, r, base, size);
r++;
}
diff --git a/drivers/of/mem_generic.c b/drivers/of/mem_generic.c
new file mode 100644
index 0000000..9094243
--- /dev/null
+++ b/drivers/of/mem_generic.c
@@ -0,0 +1,15 @@
+#include <common.h>
+#include <of.h>
+#include <memory.h>
+
+void of_add_memory_bank(struct device_node *node, bool dump, int r,
+ u64 base, u64 size)
+{
+ static char str[6];
+
+ sprintf(str, "ram%d", r);
+ barebox_add_memory_bank(str, base, size);
+
+ if (dump)
+ pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+}
diff --git a/include/of.h b/include/of.h
index 4dcf37e..e0fc768 100644
--- a/include/of.h
+++ b/include/of.h
@@ -180,6 +180,8 @@ int of_device_is_stdout_path(struct device_d *dev);
const char *of_get_model(void);
void *of_flatten_dtb(struct device_node *node);
int of_add_memory(struct device_node *node, bool dump);
+void of_add_memory_bank(struct device_node *node, bool dump, int r,
+ u64 base, u64 size);
#else
static inline int of_parse_partitions(struct cdev *cdev,
struct device_node *node)
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-05-12 19:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
2013-05-12 19:54 ` Antony Pavlov [this message]
2013-05-12 19:54 ` [PATCH v2 2/4] " Antony Pavlov
2013-05-12 19:54 ` [PATCH v2 3/4] MIPS: qemu-malta: add " Antony Pavlov
2013-05-12 19:54 ` [PATCH v2 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov
2013-05-14 5:14 ` [PATCH v2 0/4] MIPS: add initial device tree support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1368388446-31669-2-git-send-email-antonynpavlov@gmail.com \
--to=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox