]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bus: mvebu-mbus: Introduce device tree binding
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Fri, 26 Jul 2013 13:17:45 +0000 (10:17 -0300)
committerJason Cooper <jason@lakedaemon.net>
Tue, 6 Aug 2013 14:10:26 +0000 (14:10 +0000)
This patch adds the most fundamental device-tree initialization.
We only introduce what's required to be able to probe the mvebu-mbus
driver from the DT. Follow-up patches will extend the device tree binding,
allowing to describe static address decoding windows.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
drivers/bus/mvebu-mbus.c
include/linux/mbus.h

index 1b17954600aa5c47a8eb7b7417c6fd9106de6d63..44a07c4ee4eac819c30738574055bf1379b9d85b 100644 (file)
@@ -900,3 +900,52 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
                        sdramwins_phys_base,
                        sdramwins_size);
 }
+
+#ifdef CONFIG_OF
+int __init mvebu_mbus_dt_init(void)
+{
+       struct resource mbuswins_res, sdramwins_res;
+       struct device_node *np, *controller;
+       const struct of_device_id *of_id;
+       const __be32 *prop;
+       int ret;
+
+       np = of_find_matching_node(NULL, of_mvebu_mbus_ids);
+       if (!np) {
+               pr_err("could not find a matching SoC family\n");
+               return -ENODEV;
+       }
+
+       of_id = of_match_node(of_mvebu_mbus_ids, np);
+       mbus_state.soc = of_id->data;
+
+       prop = of_get_property(np, "controller", NULL);
+       if (!prop) {
+               pr_err("required 'controller' property missing\n");
+               return -EINVAL;
+       }
+
+       controller = of_find_node_by_phandle(be32_to_cpup(prop));
+       if (!controller) {
+               pr_err("could not find an 'mbus-controller' node\n");
+               return -ENODEV;
+       }
+
+       if (of_address_to_resource(controller, 0, &mbuswins_res)) {
+               pr_err("cannot get MBUS register address\n");
+               return -EINVAL;
+       }
+
+       if (of_address_to_resource(controller, 1, &sdramwins_res)) {
+               pr_err("cannot get SDRAM register address\n");
+               return -EINVAL;
+       }
+
+       ret = mvebu_mbus_common_init(&mbus_state,
+                                    mbuswins_res.start,
+                                    resource_size(&mbuswins_res),
+                                    sdramwins_res.start,
+                                    resource_size(&sdramwins_res));
+       return ret;
+}
+#endif
index 9245b663e720af5ea266c459a4b321929879f38a..eadefd687a0bb3a7466b09e44fe5e1fd07b1c040 100644 (file)
@@ -74,5 +74,6 @@ int mvebu_mbus_del_window(phys_addr_t base, size_t size);
 int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
                    size_t mbus_size, phys_addr_t sdram_phys_base,
                    size_t sdram_size);
+int mvebu_mbus_dt_init(void);
 
 #endif /* __LINUX_MBUS_H */