mvebu: backport mainline patches from kernel 3.12
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0065-bus-mvebu-mbus-Add-devicetree-binding.patch
1 From 442681ff6aca5e839fe41378ff919df1c340dc62 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 28 May 2013 07:58:31 -0300
4 Subject: [PATCH 065/203] bus: mvebu-mbus: Add devicetree binding
5
6 Introduce the devicetree binding for the mvebu MBus driver
7 avaiable in the mvebu SoCs (Armada 370/XP, Kirkwood, Dove, ...).
8
9 This binding provides an accurate model of the SoC address space,
10 and allows to declare the address and size of the decoding windows the MBus
11 needs to access the peripherals, together with the target ID and attribute
12 for those windows.
13
14 The binding is composed of two required nodes: one for the MBus bus
15 and one for the MBus controller.
16
17 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
18 Tested-by: Andrew Lunn <andrew@lunn.ch>
19 Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
20 ---
21  .../devicetree/bindings/bus/mvebu-mbus.txt         | 276 +++++++++++++++++++++
22  1 file changed, 276 insertions(+)
23  create mode 100644 Documentation/devicetree/bindings/bus/mvebu-mbus.txt
24
25 --- /dev/null
26 +++ b/Documentation/devicetree/bindings/bus/mvebu-mbus.txt
27 @@ -0,0 +1,276 @@
28 +
29 +* Marvell MBus
30 +
31 +Required properties:
32 +
33 +- compatible:   Should be set to one of the following:
34 +                marvell,armada370-mbus
35 +                marvell,armadaxp-mbus
36 +                marvell,armada370-mbus
37 +                marvell,armadaxp-mbus
38 +                marvell,kirkwood-mbus
39 +                marvell,dove-mbus
40 +                marvell,orion5x-88f5281-mbus
41 +                marvell,orion5x-88f5182-mbus
42 +                marvell,orion5x-88f5181-mbus
43 +                marvell,orion5x-88f6183-mbus
44 +                marvell,mv78xx0-mbus
45 +
46 +- address-cells: Must be '2'. The first cell for the MBus ID encoding,
47 +                 the second cell for the address offset within the window.
48 +
49 +- size-cells:    Must be '1'.
50 +
51 +- ranges:        Must be set up to provide a proper translation for each child.
52 +                See the examples below.
53 +
54 +- controller:    Contains a single phandle referring to the MBus controller
55 +                 node. This allows to specify the node that contains the
56 +                registers that control the MBus, which is typically contained
57 +                within the internal register window (see below).
58 +
59 +Optional properties:
60 +
61 +- pcie-mem-aperture:   This optional property contains the aperture for
62 +                       the memory region of the PCIe driver.
63 +                       If it's defined, it must encode the base address and
64 +                       size for the address decoding windows allocated for
65 +                       the PCIe memory region.
66 +
67 +- pcie-io-aperture:    Just as explained for the above property, this
68 +                       optional property contains the aperture for the
69 +                       I/O region of the PCIe driver.
70 +
71 +* Marvell MBus controller
72 +
73 +Required properties:
74 +
75 +- compatible:  Should be set to "marvell,mbus-controller".
76 +
77 +- reg:          Device's register space.
78 +               Two entries are expected (see the examples below):
79 +               the first one controls the devices decoding window and
80 +               the second one controls the SDRAM decoding window.
81 +
82 +Example:
83 +
84 +       soc {
85 +               compatible = "marvell,armada370-mbus", "simple-bus";
86 +               #address-cells = <2>;
87 +               #size-cells = <1>;
88 +               controller = <&mbusc>;
89 +               pcie-mem-aperture = <0xe0000000 0x8000000>;
90 +               pcie-io-aperture  = <0xe8000000 0x100000>;
91 +
92 +               internal-regs {
93 +                       compatible = "simple-bus";
94 +
95 +                       mbusc: mbus-controller@20000 {
96 +                               compatible = "marvell,mbus-controller";
97 +                               reg = <0x20000 0x100>, <0x20180 0x20>;
98 +                       };
99 +
100 +                       /* more children ...*/
101 +               };
102 +       };
103 +
104 +** MBus address decoding window specification
105 +
106 +The MBus children address space is comprised of two cells: the first one for
107 +the window ID and the second one for the offset within the window.
108 +In order to allow to describe valid and non-valid window entries, the
109 +following encoding is used:
110 +
111 +  0xSIAA0000 0x00oooooo
112 +
113 +Where:
114 +
115 +  S = 0x0 for a MBus valid window
116 +  S = 0xf for a non-valid window (see below)
117 +
118 +If S = 0x0, then:
119 +
120 +   I = 4-bit window target ID
121 +  AA = windpw attribute
122 +
123 +If S = 0xf, then:
124 +
125 +   I = don't care
126 +   AA = 1 for internal register
127 +
128 +Following the above encoding, for each ranges entry for a MBus valid window
129 +(S = 0x0), an address decoding window is allocated. On the other side,
130 +entries for translation that do not correspond to valid windows (S = 0xf)
131 +are skipped.
132 +
133 +       soc {
134 +               compatible = "marvell,armada370-mbus", "simple-bus";
135 +               #address-cells = <2>;
136 +               #size-cells = <1>;
137 +               controller = <&mbusc>;
138 +
139 +               ranges = <0xf0010000 0 0 0xd0000000 0x100000
140 +                         0x01e00000 0 0 0xfff00000 0x100000>;
141 +
142 +               bootrom {
143 +                       compatible = "marvell,bootrom";
144 +                       reg = <0x01e00000 0 0x100000>;
145 +               };
146 +
147 +               /* other children */
148 +               ...
149 +
150 +               internal-regs {
151 +                       compatible = "simple-bus";
152 +                       ranges = <0 0xf0010000 0 0x100000>;
153 +
154 +                       mbusc: mbus-controller@20000 {
155 +                               compatible = "marvell,mbus-controller";
156 +                               reg = <0x20000 0x100>, <0x20180 0x20>;
157 +                       };
158 +
159 +                       /* more children ...*/
160 +               };
161 +       };
162 +
163 +In the shown example, the translation entry in the 'ranges' property is what
164 +makes the MBus driver create a static decoding window for the corresponding
165 +given child device. Note that the binding does not require child nodes to be
166 +present. Of course, child nodes are needed to probe the devices.
167 +
168 +Since each window is identified by its target ID and attribute ID there's
169 +a special macro that can be use to simplify the translation entries:
170 +
171 +#define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
172 +
173 +Using this macro, the above example would be:
174 +
175 +       soc {
176 +               compatible = "marvell,armada370-mbus", "simple-bus";
177 +               #address-cells = <2>;
178 +               #size-cells = <1>;
179 +               controller = <&mbusc>;
180 +
181 +               ranges = < MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000
182 +                          MBUS_ID(0x01, 0xe0) 0 0 0xfff00000 0x100000>;
183 +
184 +               bootrom {
185 +                       compatible = "marvell,bootrom";
186 +                       reg = <MBUS_ID(0x01, 0xe0) 0 0x100000>;
187 +               };
188 +
189 +               /* other children */
190 +               ...
191 +
192 +               internal-regs {
193 +                       compatible = "simple-bus";
194 +                       #address-cells = <1>;
195 +                       #size-cells = <1>;
196 +                       ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>;
197 +
198 +                       mbusc: mbus-controller@20000 {
199 +                               compatible = "marvell,mbus-controller";
200 +                               reg = <0x20000 0x100>, <0x20180 0x20>;
201 +                       };
202 +
203 +                       /* other children */
204 +                       ...
205 +               };
206 +       };
207 +
208 +
209 +** About the window base address
210 +
211 +Remember the MBus controller allows a great deal of flexibility for choosing
212 +the decoding window base address. When planning the device tree layout it's
213 +possible to choose any address as the base address, provided of course there's
214 +a region large enough available, and with the required alignment.
215 +
216 +Yet in other words: there's nothing preventing us from setting a base address
217 +of 0xf0000000, or 0xd0000000 for the NOR device shown above, if such region is
218 +unused.
219 +
220 +** Window allocation policy
221 +
222 +The mbus-node ranges property defines a set of mbus windows that are expected
223 +to be set by the operating system and that are guaranteed to be free of overlaps
224 +with one another or with the system memory ranges.
225 +
226 +Each entry in the property refers to exactly one window. If the operating system
227 +choses to use a different set of mbus windows, it must ensure that any address
228 +translations performed from downstream devices are adapted accordingly.
229 +
230 +The operating system may insert additional mbus windows that do not conflict
231 +with the ones listed in the ranges, e.g. for mapping PCIe devices.
232 +As a special case, the internal register window must be set up by the boot
233 +loader at the address listed in the ranges property, since access to that region
234 +is needed to set up the other windows.
235 +
236 +** Example
237 +
238 +See the example below, where a more complete device tree is shown:
239 +
240 +       soc {
241 +               compatible = "marvell,armadaxp-mbus", "simple-bus";
242 +               controller = <&mbusc>;
243 +
244 +               ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000   /* internal-regs */
245 +                         MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
246 +                         MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x8000000>;
247 +
248 +               bootrom {
249 +                       compatible = "marvell,bootrom";
250 +                       reg = <MBUS_ID(0x01, 0x1d) 0 0x100000>;
251 +               };
252 +
253 +               devbus-bootcs {
254 +                       status = "okay";
255 +                       ranges = <0 MBUS_ID(0x01, 0x2f) 0 0x8000000>;
256 +
257 +                       /* NOR */
258 +                       nor {
259 +                               compatible = "cfi-flash";
260 +                               reg = <0 0x8000000>;
261 +                               bank-width = <2>;
262 +                       };
263 +               };
264 +
265 +               pcie-controller {
266 +                       compatible = "marvell,armada-xp-pcie";
267 +                       status = "okay";
268 +                       device_type = "pci";
269 +
270 +                       #address-cells = <3>;
271 +                       #size-cells = <2>;
272 +
273 +                       ranges =
274 +                              <0x82000000 0 0x40000 MBUS_ID(0xf0, 0x01) 0x40000 0 0x00002000   /* Port 0.0 registers */
275 +                               0x82000000 0 0x42000 MBUS_ID(0xf0, 0x01) 0x42000 0 0x00002000   /* Port 2.0 registers */
276 +                               0x82000000 0 0x44000 MBUS_ID(0xf0, 0x01) 0x44000 0 0x00002000   /* Port 0.1 registers */
277 +                               0x82000000 0 0x48000 MBUS_ID(0xf0, 0x01) 0x48000 0 0x00002000   /* Port 0.2 registers */
278 +                               0x82000000 0 0x4c000 MBUS_ID(0xf0, 0x01) 0x4c000 0 0x00002000   /* Port 0.3 registers */
279 +                               0x82000800 0 0xe0000000 MBUS_ID(0x04, 0xe8) 0xe0000000 0 0x08000000 /* Port 0.0 MEM */
280 +                               0x81000800 0 0          MBUS_ID(0x04, 0xe0) 0xe8000000 0 0x00100000 /* Port 0.0 IO */>;
281 +
282 +
283 +                       pcie@1,0 {
284 +                               /* Port 0, Lane 0 */
285 +                               status = "okay";
286 +                       };
287 +               };
288 +
289 +               internal-regs {
290 +                       compatible = "simple-bus";
291 +                       #address-cells = <1>;
292 +                       #size-cells = <1>;
293 +                       ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>;
294 +
295 +                       mbusc: mbus-controller@20000 {
296 +                               reg = <0x20000 0x100>, <0x20180 0x20>;
297 +                       };
298 +
299 +                       interrupt-controller@20000 {
300 +                             reg = <0x20a00 0x2d0>, <0x21070 0x58>;
301 +                       };
302 +               };
303 +       };