mvebu: backport mainline patches from kernel 3.11
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-3.10 / 0044-bus-mvebu-mbus-Introduce-device-tree-binding.patch
1 From e4123095febc94c547c0459db752e7879db79d76 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 21 May 2013 10:48:54 -0300
4 Subject: [PATCH 044/203] bus: mvebu-mbus: Introduce device tree binding
5
6 This patch adds the most fundamental device-tree initialization.
7 We only introduce what's required to be able to probe the mvebu-mbus
8 driver from the DT. Follow-up patches will extend the device tree binding,
9 allowing to describe static address decoding windows.
10
11 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
12 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
13 Tested-by: Andrew Lunn <andrew@lunn.ch>
14 Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
15 ---
16 drivers/bus/mvebu-mbus.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
17 include/linux/mbus.h | 1 +
18 2 files changed, 50 insertions(+)
19
20 --- a/drivers/bus/mvebu-mbus.c
21 +++ b/drivers/bus/mvebu-mbus.c
22 @@ -900,3 +900,52 @@ int __init mvebu_mbus_init(const char *s
23 sdramwins_phys_base,
24 sdramwins_size);
25 }
26 +
27 +#ifdef CONFIG_OF
28 +int __init mvebu_mbus_dt_init(void)
29 +{
30 + struct resource mbuswins_res, sdramwins_res;
31 + struct device_node *np, *controller;
32 + const struct of_device_id *of_id;
33 + const __be32 *prop;
34 + int ret;
35 +
36 + np = of_find_matching_node(NULL, of_mvebu_mbus_ids);
37 + if (!np) {
38 + pr_err("could not find a matching SoC family\n");
39 + return -ENODEV;
40 + }
41 +
42 + of_id = of_match_node(of_mvebu_mbus_ids, np);
43 + mbus_state.soc = of_id->data;
44 +
45 + prop = of_get_property(np, "controller", NULL);
46 + if (!prop) {
47 + pr_err("required 'controller' property missing\n");
48 + return -EINVAL;
49 + }
50 +
51 + controller = of_find_node_by_phandle(be32_to_cpup(prop));
52 + if (!controller) {
53 + pr_err("could not find an 'mbus-controller' node\n");
54 + return -ENODEV;
55 + }
56 +
57 + if (of_address_to_resource(controller, 0, &mbuswins_res)) {
58 + pr_err("cannot get MBUS register address\n");
59 + return -EINVAL;
60 + }
61 +
62 + if (of_address_to_resource(controller, 1, &sdramwins_res)) {
63 + pr_err("cannot get SDRAM register address\n");
64 + return -EINVAL;
65 + }
66 +
67 + ret = mvebu_mbus_common_init(&mbus_state,
68 + mbuswins_res.start,
69 + resource_size(&mbuswins_res),
70 + sdramwins_res.start,
71 + resource_size(&sdramwins_res));
72 + return ret;
73 +}
74 +#endif
75 --- a/include/linux/mbus.h
76 +++ b/include/linux/mbus.h
77 @@ -74,5 +74,6 @@ int mvebu_mbus_del_window(phys_addr_t ba
78 int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
79 size_t mbus_size, phys_addr_t sdram_phys_base,
80 size_t sdram_size);
81 +int mvebu_mbus_dt_init(void);
82
83 #endif /* __LINUX_MBUS_H */