* [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size
@ 2013-02-12 21:11 Jean-Christophe PLAGNIOL-VILLARD
2013-02-12 21:11 ` Jean-Christophe PLAGNIOL-VILLARD
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-12 21:11 UTC (permalink / raw)
To: barebox; +Cc: Rob Herring
the dtb is at 0x1000
if no dtb present use C code device
kepp in C the timer/gpio/uart
Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/highbank/env/bin/init_board | 7 +++++
arch/arm/boards/highbank/init.c | 44 ++++++++++++++++++++++++---
2 files changed, 47 insertions(+), 4 deletions(-)
create mode 100644 arch/arm/boards/highbank/env/bin/init_board
diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
new file mode 100644
index 0000000..610db15
--- /dev/null
+++ b/arch/arm/boards/highbank/env/bin/init_board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ -e /dev/dtb ]
+then
+ oftree -l /dev/dtb
+ oftree -p
+fi
diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
index 9fb7986..a01db5b 100644
--- a/arch/arm/boards/highbank/init.c
+++ b/arch/arm/boards/highbank/init.c
@@ -15,20 +15,56 @@
#include <sizes.h>
#include <io.h>
+struct fdt_header *fdt = NULL;
+
static int highbank_mem_init(void)
{
+ struct device_node *np;
+ u32 reg[2];
+ int ret;
+
+ /* load by the firmware at 0x1000 */
+ fdt = IOMEM(0x1000);
+
+ ret = of_unflatten_dtb(fdt);
+ if (ret) {
+ pr_warn("no dtb found at 0x1000 use default configuration\n");
+ fdt = NULL;
+ goto not_found;
+ }
+
+ np = of_find_node_by_path("/memory");
+ if (!np) {
+ pr_warn("no memory node use default configuration\n");
+ goto not_found;
+ }
+
+ ret = of_property_read_u32_array(np, "reg", reg, 2);
+ if (ret) {
+ pr_warn("memory node: no reg property use default configuration\n");
+ goto not_found;
+ }
+
+ pr_info("highbank: dtb probed mem_size = 0x%x\n", reg[1]);
+
+ highbank_add_ddram(reg[1]);
+
+not_found:
//highbank_add_ddram(4089 << 20);
highbank_add_ddram(SZ_1G);
-
return 0;
}
mem_initcall(highbank_mem_init);
static int highbank_devices_init(void)
{
- highbank_register_ahci();
- highbank_register_xgmac(0);
- highbank_register_xgmac(1);
+ if (!fdt) {
+ highbank_register_ahci();
+ highbank_register_xgmac(0);
+ highbank_register_xgmac(1);
+ } else {
+ devfs_add_partition("ram1", 0x1000, SZ_64K, DEVFS_PARTITION_FIXED, "dtb");
+ }
armlinux_set_bootparams((void *)(0x00000100));
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size
2013-02-12 21:11 [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-12 21:11 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 3:16 ` Rob Herring
2013-02-13 8:18 ` Sascha Hauer
2 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-12 21:11 UTC (permalink / raw)
To: barebox; +Cc: Rob Herring
Hi.
it's a rfc
Best Regards,
J.
On 22:11 Tue 12 Feb , Jean-Christophe PLAGNIOL-VILLARD wrote:
> the dtb is at 0x1000
>
> if no dtb present use C code device
>
> kepp in C the timer/gpio/uart
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> arch/arm/boards/highbank/env/bin/init_board | 7 +++++
> arch/arm/boards/highbank/init.c | 44 ++++++++++++++++++++++++---
> 2 files changed, 47 insertions(+), 4 deletions(-)
> create mode 100644 arch/arm/boards/highbank/env/bin/init_board
>
> diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
> new file mode 100644
> index 0000000..610db15
> --- /dev/null
> +++ b/arch/arm/boards/highbank/env/bin/init_board
> @@ -0,0 +1,7 @@
> +#!/bin/sh
> +
> +if [ -e /dev/dtb ]
> +then
> + oftree -l /dev/dtb
> + oftree -p
> +fi
> diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
> index 9fb7986..a01db5b 100644
> --- a/arch/arm/boards/highbank/init.c
> +++ b/arch/arm/boards/highbank/init.c
> @@ -15,20 +15,56 @@
> #include <sizes.h>
> #include <io.h>
>
> +struct fdt_header *fdt = NULL;
> +
> static int highbank_mem_init(void)
> {
> + struct device_node *np;
> + u32 reg[2];
> + int ret;
> +
> + /* load by the firmware at 0x1000 */
> + fdt = IOMEM(0x1000);
> +
> + ret = of_unflatten_dtb(fdt);
> + if (ret) {
> + pr_warn("no dtb found at 0x1000 use default configuration\n");
> + fdt = NULL;
> + goto not_found;
> + }
> +
> + np = of_find_node_by_path("/memory");
> + if (!np) {
> + pr_warn("no memory node use default configuration\n");
> + goto not_found;
> + }
> +
> + ret = of_property_read_u32_array(np, "reg", reg, 2);
> + if (ret) {
> + pr_warn("memory node: no reg property use default configuration\n");
> + goto not_found;
> + }
> +
> + pr_info("highbank: dtb probed mem_size = 0x%x\n", reg[1]);
> +
> + highbank_add_ddram(reg[1]);
> +
> +not_found:
> //highbank_add_ddram(4089 << 20);
> highbank_add_ddram(SZ_1G);
> -
> return 0;
> }
> mem_initcall(highbank_mem_init);
>
> static int highbank_devices_init(void)
> {
> - highbank_register_ahci();
> - highbank_register_xgmac(0);
> - highbank_register_xgmac(1);
> + if (!fdt) {
> + highbank_register_ahci();
> + highbank_register_xgmac(0);
> + highbank_register_xgmac(1);
> + } else {
> + devfs_add_partition("ram1", 0x1000, SZ_64K, DEVFS_PARTITION_FIXED, "dtb");
> + }
>
> armlinux_set_bootparams((void *)(0x00000100));
>
> --
> 1.7.10.4
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size
2013-02-12 21:11 [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size Jean-Christophe PLAGNIOL-VILLARD
2013-02-12 21:11 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-13 3:16 ` Rob Herring
2013-02-13 9:13 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 8:18 ` Sascha Hauer
2 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2013-02-13 3:16 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On 02/12/2013 03:11 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> the dtb is at 0x1000
>
> if no dtb present use C code device
>
> kepp in C the timer/gpio/uart
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> arch/arm/boards/highbank/env/bin/init_board | 7 +++++
> arch/arm/boards/highbank/init.c | 44 ++++++++++++++++++++++++---
> 2 files changed, 47 insertions(+), 4 deletions(-)
> create mode 100644 arch/arm/boards/highbank/env/bin/init_board
>
> diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
> new file mode 100644
> index 0000000..610db15
> --- /dev/null
> +++ b/arch/arm/boards/highbank/env/bin/init_board
> @@ -0,0 +1,7 @@
> +#!/bin/sh
> +
> +if [ -e /dev/dtb ]
> +then
> + oftree -l /dev/dtb
> + oftree -p
> +fi
> diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
> index 9fb7986..a01db5b 100644
> --- a/arch/arm/boards/highbank/init.c
> +++ b/arch/arm/boards/highbank/init.c
> @@ -15,20 +15,56 @@
> #include <sizes.h>
> #include <io.h>
>
> +struct fdt_header *fdt = NULL;
> +
> static int highbank_mem_init(void)
> {
> + struct device_node *np;
> + u32 reg[2];
> + int ret;
> +
> + /* load by the firmware at 0x1000 */
> + fdt = IOMEM(0x1000);
> +
> + ret = of_unflatten_dtb(fdt);
full blown DT seems a bit much. Can't you do what's needed with libfdt?
I guess if you've already pulled it all in, it doesn't matter.
> + if (ret) {
> + pr_warn("no dtb found at 0x1000 use default configuration\n");
> + fdt = NULL;
> + goto not_found;
> + }
> +
> + np = of_find_node_by_path("/memory");
> + if (!np) {
> + pr_warn("no memory node use default configuration\n");
> + goto not_found;
> + }
> +
> + ret = of_property_read_u32_array(np, "reg", reg, 2);
You assume the memory address and sizes are 1 word which soon will not
be true. See ecx-2000.dts. Note that I'm planning to merge the 2 memory
nodes to 1 node with 2 addresses and sizes in reg property.
> + if (ret) {
> + pr_warn("memory node: no reg property use default configuration\n");
> + goto not_found;
> + }
> +
> + pr_info("highbank: dtb probed mem_size = 0x%x\n", reg[1]);
> +
> + highbank_add_ddram(reg[1]);
> +
> +not_found:
> //highbank_add_ddram(4089 << 20);
> highbank_add_ddram(SZ_1G);
> -
> return 0;
> }
> mem_initcall(highbank_mem_init);
>
> static int highbank_devices_init(void)
> {
> - highbank_register_ahci();
> - highbank_register_xgmac(0);
> - highbank_register_xgmac(1);
> + if (!fdt) {
> + highbank_register_ahci();
> + highbank_register_xgmac(0);
> + highbank_register_xgmac(1);
> + } else {
> + devfs_add_partition("ram1", 0x1000, SZ_64K, DEVFS_PARTITION_FIXED, "dtb");
> + }
>
> armlinux_set_bootparams((void *)(0x00000100));
>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size
2013-02-12 21:11 [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size Jean-Christophe PLAGNIOL-VILLARD
2013-02-12 21:11 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 3:16 ` Rob Herring
@ 2013-02-13 8:18 ` Sascha Hauer
2013-02-13 9:53 ` Jean-Christophe PLAGNIOL-VILLARD
2 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2013-02-13 8:18 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox, Rob Herring
On Tue, Feb 12, 2013 at 10:11:00PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> the dtb is at 0x1000
>
> if no dtb present use C code device
>
> kepp in C the timer/gpio/uart
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> arch/arm/boards/highbank/env/bin/init_board | 7 +++++
> arch/arm/boards/highbank/init.c | 44 ++++++++++++++++++++++++---
> 2 files changed, 47 insertions(+), 4 deletions(-)
> create mode 100644 arch/arm/boards/highbank/env/bin/init_board
>
> diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
We already have:
| commit f59f5e86256f82daf4af3bf1922805592b780613
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date: Sat Oct 6 19:51:47 2012 +0200
|
| of: find and register memory during probe
|
| This automatically registers the memory nodes in the devicetree.
|
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
I suspect there is something missing since this commit checks for the
'device_type' property, but does not actually test if it matches
'memory'. So there might be some work necessary, but this code already
handles 64bit cells correctly, at least it tries to ;)
Sascha
--
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 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size
2013-02-13 3:16 ` Rob Herring
@ 2013-02-13 9:13 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-13 9:13 UTC (permalink / raw)
To: Rob Herring; +Cc: barebox
On 21:16 Tue 12 Feb , Rob Herring wrote:
> On 02/12/2013 03:11 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > the dtb is at 0x1000
> >
> > if no dtb present use C code device
> >
> > kepp in C the timer/gpio/uart
> >
> > Cc: Rob Herring <rob.herring@calxeda.com>
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > arch/arm/boards/highbank/env/bin/init_board | 7 +++++
> > arch/arm/boards/highbank/init.c | 44 ++++++++++++++++++++++++---
> > 2 files changed, 47 insertions(+), 4 deletions(-)
> > create mode 100644 arch/arm/boards/highbank/env/bin/init_board
> >
> > diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
> > new file mode 100644
> > index 0000000..610db15
> > --- /dev/null
> > +++ b/arch/arm/boards/highbank/env/bin/init_board
> > @@ -0,0 +1,7 @@
> > +#!/bin/sh
> > +
> > +if [ -e /dev/dtb ]
> > +then
> > + oftree -l /dev/dtb
> > + oftree -p
> > +fi
> > diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
> > index 9fb7986..a01db5b 100644
> > --- a/arch/arm/boards/highbank/init.c
> > +++ b/arch/arm/boards/highbank/init.c
> > @@ -15,20 +15,56 @@
> > #include <sizes.h>
> > #include <io.h>
> >
> > +struct fdt_header *fdt = NULL;
> > +
> > static int highbank_mem_init(void)
> > {
> > + struct device_node *np;
> > + u32 reg[2];
> > + int ret;
> > +
> > + /* load by the firmware at 0x1000 */
> > + fdt = IOMEM(0x1000);
> > +
> > + ret = of_unflatten_dtb(fdt);
>
> full blown DT seems a bit much. Can't you do what's needed with libfdt?
> I guess if you've already pulled it all in, it doesn't matter.
yes
>
> > + if (ret) {
> > + pr_warn("no dtb found at 0x1000 use default configuration\n");
> > + fdt = NULL;
> > + goto not_found;
> > + }
> > +
> > + np = of_find_node_by_path("/memory");
> > + if (!np) {
> > + pr_warn("no memory node use default configuration\n");
> > + goto not_found;
> > + }
> > +
> > + ret = of_property_read_u32_array(np, "reg", reg, 2);
>
> You assume the memory address and sizes are 1 word which soon will not
> be true. See ecx-2000.dts. Note that I'm planning to merge the 2 memory
> nodes to 1 node with 2 addresses and sizes in reg property.
I'll check
>
> > + if (ret) {
> > + pr_warn("memory node: no reg property use default configuration\n");
> > + goto not_found;
> > + }
> > +
> > + pr_info("highbank: dtb probed mem_size = 0x%x\n", reg[1]);
> > +
> > + highbank_add_ddram(reg[1]);
> > +
> > +not_found:
> > //highbank_add_ddram(4089 << 20);
> > highbank_add_ddram(SZ_1G);
> > -
> > return 0;
> > }
> > mem_initcall(highbank_mem_init);
> >
> > static int highbank_devices_init(void)
> > {
> > - highbank_register_ahci();
> > - highbank_register_xgmac(0);
> > - highbank_register_xgmac(1);
> > + if (!fdt) {
> > + highbank_register_ahci();
> > + highbank_register_xgmac(0);
> > + highbank_register_xgmac(1);
> > + } else {
> > + devfs_add_partition("ram1", 0x1000, SZ_64K, DEVFS_PARTITION_FIXED, "dtb");
> > + }
> >
> > armlinux_set_bootparams((void *)(0x00000100));
> >
> >
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size
2013-02-13 8:18 ` Sascha Hauer
@ 2013-02-13 9:53 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-13 9:53 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, Rob Herring
On 09:18 Wed 13 Feb , Sascha Hauer wrote:
> On Tue, Feb 12, 2013 at 10:11:00PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > the dtb is at 0x1000
> >
> > if no dtb present use C code device
> >
> > kepp in C the timer/gpio/uart
> >
> > Cc: Rob Herring <rob.herring@calxeda.com>
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > arch/arm/boards/highbank/env/bin/init_board | 7 +++++
> > arch/arm/boards/highbank/init.c | 44 ++++++++++++++++++++++++---
> > 2 files changed, 47 insertions(+), 4 deletions(-)
> > create mode 100644 arch/arm/boards/highbank/env/bin/init_board
> >
> > diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
>
> We already have:
>
> | commit f59f5e86256f82daf4af3bf1922805592b780613
> | Author: Sascha Hauer <s.hauer@pengutronix.de>
> | Date: Sat Oct 6 19:51:47 2012 +0200
> |
> | of: find and register memory during probe
> |
> | This automatically registers the memory nodes in the devicetree.
> |
> | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>
> I suspect there is something missing since this commit checks for the
> 'device_type' property, but does not actually test if it matches
> 'memory'. So there might be some work necessary, but this code already
> handles 64bit cells correctly, at least it tries to ;)
ok
>
> Sascha
>
> --
> 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 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-02-13 9:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-12 21:11 [PATCH 1/1] highbank: use the provided dtb by the firmware to probe barebox device and mem size Jean-Christophe PLAGNIOL-VILLARD
2013-02-12 21:11 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 3:16 ` Rob Herring
2013-02-13 9:13 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 8:18 ` Sascha Hauer
2013-02-13 9:53 ` Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox