* [PATCH] bus: mvebu: fix ranges fixup
@ 2014-08-02 5:12 Ezequiel Garcia
2014-08-02 8:44 ` Sebastian Hesselbarth
2014-08-04 18:49 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ezequiel Garcia @ 2014-08-02 5:12 UTC (permalink / raw)
To: barebox
The current fixup code is slightly wrong, and only works when the
root address cell number is one.
However, Armada XP has a root address cell number of two. In this case
we are currently applying the fixup on the child high base address,
while it should be applied on the child low base address.
Fix it and add some detailed explanation to avoid having to figure this
out each time.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
Without this patch, the Plathome Openblocks AX3-4 board wouldn't
boot on -next. It should affect every Armada XP board that require this
fixup.
drivers/bus/mvebu-mbus.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index b1e407a..b7f7836 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -788,6 +788,21 @@ static int mvebu_mbus_of_fixup(struct device_node *root, void *context)
ranges = xzalloc(lenp);
of_property_read_u32_array(np, "ranges", ranges, lenp/4);
+ /*
+ * Iterate through each ranges tuple and fixup the custom
+ * window ranges low base address. Because Armada XP supports
+ * LPAE, it has 2 cells for the parent address:
+ * <windowid child_base high_base low_base size>
+ *
+ * whereas for Armada 370, there's just one:
+ * <windowid child_base base size>
+ *
+ * For instance, the following tuple:
+ * <MBUS_ID(0xf0, 0x01) child_base {0} base 0x100000>
+ *
+ * would be fixed-up like:
+ * <MBUS_ID(0xf0, 0x01) child_base {0} remap 0x100000>
+ */
for (n = 0; n < lenp/4; n += size) {
struct mbus_range *r;
u32 mbusid = ranges[n];
@@ -797,7 +812,7 @@ static int mvebu_mbus_of_fixup(struct device_node *root, void *context)
list_for_each_entry(r, &mbus_ranges, list) {
if (r->mbusid == mbusid)
- ranges[n + na] = r->remap;
+ ranges[n + na + pa - 1] = r->remap;
}
}
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bus: mvebu: fix ranges fixup
2014-08-02 5:12 [PATCH] bus: mvebu: fix ranges fixup Ezequiel Garcia
@ 2014-08-02 8:44 ` Sebastian Hesselbarth
2014-08-04 18:49 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Hesselbarth @ 2014-08-02 8:44 UTC (permalink / raw)
To: Ezequiel Garcia, barebox
On 08/02/2014 07:12 AM, Ezequiel Garcia wrote:
> The current fixup code is slightly wrong, and only works when the
> root address cell number is one.
>
> However, Armada XP has a root address cell number of two. In this case
> we are currently applying the fixup on the child high base address,
> while it should be applied on the child low base address.
>
> Fix it and add some detailed explanation to avoid having to figure this
> out each time.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
> Without this patch, the Plathome Openblocks AX3-4 board wouldn't
> boot on -next. It should affect every Armada XP board that require this
> fixup.
Ezequiel,
great catch! TBH, dealing with ranges is a PITA..
Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> drivers/bus/mvebu-mbus.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
> index b1e407a..b7f7836 100644
> --- a/drivers/bus/mvebu-mbus.c
> +++ b/drivers/bus/mvebu-mbus.c
> @@ -788,6 +788,21 @@ static int mvebu_mbus_of_fixup(struct device_node *root, void *context)
> ranges = xzalloc(lenp);
> of_property_read_u32_array(np, "ranges", ranges, lenp/4);
>
> + /*
> + * Iterate through each ranges tuple and fixup the custom
> + * window ranges low base address. Because Armada XP supports
> + * LPAE, it has 2 cells for the parent address:
> + * <windowid child_base high_base low_base size>
> + *
> + * whereas for Armada 370, there's just one:
> + * <windowid child_base base size>
> + *
> + * For instance, the following tuple:
> + * <MBUS_ID(0xf0, 0x01) child_base {0} base 0x100000>
> + *
> + * would be fixed-up like:
> + * <MBUS_ID(0xf0, 0x01) child_base {0} remap 0x100000>
> + */
> for (n = 0; n < lenp/4; n += size) {
> struct mbus_range *r;
> u32 mbusid = ranges[n];
> @@ -797,7 +812,7 @@ static int mvebu_mbus_of_fixup(struct device_node *root, void *context)
>
> list_for_each_entry(r, &mbus_ranges, list) {
> if (r->mbusid == mbusid)
> - ranges[n + na] = r->remap;
> + ranges[n + na + pa - 1] = r->remap;
> }
> }
>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bus: mvebu: fix ranges fixup
2014-08-02 5:12 [PATCH] bus: mvebu: fix ranges fixup Ezequiel Garcia
2014-08-02 8:44 ` Sebastian Hesselbarth
@ 2014-08-04 18:49 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-08-04 18:49 UTC (permalink / raw)
To: Ezequiel Garcia; +Cc: barebox
On Sat, Aug 02, 2014 at 02:12:52AM -0300, Ezequiel Garcia wrote:
> The current fixup code is slightly wrong, and only works when the
> root address cell number is one.
>
> However, Armada XP has a root address cell number of two. In this case
> we are currently applying the fixup on the child high base address,
> while it should be applied on the child low base address.
>
> Fix it and add some detailed explanation to avoid having to figure this
> out each time.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Applied, thanks
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] 3+ messages in thread
end of thread, other threads:[~2014-08-04 18:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-02 5:12 [PATCH] bus: mvebu: fix ranges fixup Ezequiel Garcia
2014-08-02 8:44 ` Sebastian Hesselbarth
2014-08-04 18:49 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox