mvebu: backport mainline patches from kernel 3.11
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-3.10 / 0029-arm-mvebu-don-t-hardcode-the-physical-address-for-mv.patch
1 From 070469397154c87b14fab48d2fc231ba83007c1b Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Wed, 5 Jun 2013 09:04:59 +0200
4 Subject: [PATCH 029/203] arm: mvebu: don't hardcode the physical address for
5 mvebu-mbus
6
7 Since the mvebu-mbus driver doesn't yet have a DT binding (and this DT
8 binding may not necessarily be ready for 3.11), the physical address
9 of the mvebu-mbus registers are currently hardcoded. This doesn't play
10 well with the fact that the internal registers base address may be
11 different depending on the bootloader.
12
13 In order to have only one central place for the physical address of
14 the internal registers, we now use of_translate_address() to translate
15 the mvebu-mbus register offsets into the real physical address, by
16 using DT-based address translation. This will go away once the
17 mvebu-mbus driver gains a proper DT binding.
18
19 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
20 Acked-by: Arnd Bergmann <arnd@arndb.de>
21 Signed-off-by: Jason Cooper <jason@lakedaemon.net>
22 ---
23 arch/arm/mach-mvebu/armada-370-xp.c | 38 ++++++++++++++++++++++++++-----------
24 arch/arm/mach-mvebu/armada-370-xp.h | 8 --------
25 2 files changed, 27 insertions(+), 19 deletions(-)
26
27 --- a/arch/arm/mach-mvebu/armada-370-xp.c
28 +++ b/arch/arm/mach-mvebu/armada-370-xp.c
29 @@ -14,6 +14,7 @@
30
31 #include <linux/kernel.h>
32 #include <linux/init.h>
33 +#include <linux/of_address.h>
34 #include <linux/of_platform.h>
35 #include <linux/io.h>
36 #include <linux/time-armada-370-xp.h>
37 @@ -34,29 +35,44 @@ static void __init armada_370_xp_map_io(
38 debug_ll_io_init();
39 }
40
41 -static void __init armada_370_xp_timer_and_clk_init(void)
42 +/*
43 + * This initialization will be replaced by a DT-based
44 + * initialization once the mvebu-mbus driver gains DT support.
45 + */
46 +
47 +#define ARMADA_370_XP_MBUS_WINS_OFFS 0x20000
48 +#define ARMADA_370_XP_MBUS_WINS_SIZE 0x100
49 +#define ARMADA_370_XP_SDRAM_WINS_OFFS 0x20180
50 +#define ARMADA_370_XP_SDRAM_WINS_SIZE 0x20
51 +
52 +static void __init armada_370_xp_mbus_init(void)
53 {
54 char *mbus_soc_name;
55 + struct device_node *dn;
56 + const __be32 mbus_wins_offs = cpu_to_be32(ARMADA_370_XP_MBUS_WINS_OFFS);
57 + const __be32 sdram_wins_offs = cpu_to_be32(ARMADA_370_XP_SDRAM_WINS_OFFS);
58
59 - mvebu_clocks_init();
60 - armada_370_xp_timer_init();
61 - coherency_init();
62 -
63 - /*
64 - * This initialization will be replaced by a DT-based
65 - * initialization once the mvebu-mbus driver gains DT support.
66 - */
67 if (of_machine_is_compatible("marvell,armada370"))
68 mbus_soc_name = "marvell,armada370-mbus";
69 else
70 mbus_soc_name = "marvell,armadaxp-mbus";
71
72 + dn = of_find_node_by_name(NULL, "internal-regs");
73 + BUG_ON(!dn);
74 +
75 mvebu_mbus_init(mbus_soc_name,
76 - ARMADA_370_XP_MBUS_WINS_BASE,
77 + of_translate_address(dn, &mbus_wins_offs),
78 ARMADA_370_XP_MBUS_WINS_SIZE,
79 - ARMADA_370_XP_SDRAM_WINS_BASE,
80 + of_translate_address(dn, &sdram_wins_offs),
81 ARMADA_370_XP_SDRAM_WINS_SIZE);
82 +}
83
84 +static void __init armada_370_xp_timer_and_clk_init(void)
85 +{
86 + mvebu_clocks_init();
87 + armada_370_xp_timer_init();
88 + coherency_init();
89 + armada_370_xp_mbus_init();
90 #ifdef CONFIG_CACHE_L2X0
91 l2x0_of_init(0, ~0UL);
92 #endif
93 --- a/arch/arm/mach-mvebu/armada-370-xp.h
94 +++ b/arch/arm/mach-mvebu/armada-370-xp.h
95 @@ -15,14 +15,6 @@
96 #ifndef __MACH_ARMADA_370_XP_H
97 #define __MACH_ARMADA_370_XP_H
98
99 -#define ARMADA_370_XP_REGS_PHYS_BASE 0xd0000000
100 -
101 -/* These defines can go away once mvebu-mbus has a DT binding */
102 -#define ARMADA_370_XP_MBUS_WINS_BASE (ARMADA_370_XP_REGS_PHYS_BASE + 0x20000)
103 -#define ARMADA_370_XP_MBUS_WINS_SIZE 0x100
104 -#define ARMADA_370_XP_SDRAM_WINS_BASE (ARMADA_370_XP_REGS_PHYS_BASE + 0x20180)
105 -#define ARMADA_370_XP_SDRAM_WINS_SIZE 0x20
106 -
107 #ifdef CONFIG_SMP
108 #include <linux/cpumask.h>
109