Skip to content

Commit 6839cfa

Browse files
ezequielgarciaJason Cooper
authored andcommitted
bus: mvebu-mbus: Introduce device tree binding
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>
1 parent 6bd6b3c commit 6839cfa

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

drivers/bus/mvebu-mbus.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,52 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
900900
sdramwins_phys_base,
901901
sdramwins_size);
902902
}
903+
904+
#ifdef CONFIG_OF
905+
int __init mvebu_mbus_dt_init(void)
906+
{
907+
struct resource mbuswins_res, sdramwins_res;
908+
struct device_node *np, *controller;
909+
const struct of_device_id *of_id;
910+
const __be32 *prop;
911+
int ret;
912+
913+
np = of_find_matching_node(NULL, of_mvebu_mbus_ids);
914+
if (!np) {
915+
pr_err("could not find a matching SoC family\n");
916+
return -ENODEV;
917+
}
918+
919+
of_id = of_match_node(of_mvebu_mbus_ids, np);
920+
mbus_state.soc = of_id->data;
921+
922+
prop = of_get_property(np, "controller", NULL);
923+
if (!prop) {
924+
pr_err("required 'controller' property missing\n");
925+
return -EINVAL;
926+
}
927+
928+
controller = of_find_node_by_phandle(be32_to_cpup(prop));
929+
if (!controller) {
930+
pr_err("could not find an 'mbus-controller' node\n");
931+
return -ENODEV;
932+
}
933+
934+
if (of_address_to_resource(controller, 0, &mbuswins_res)) {
935+
pr_err("cannot get MBUS register address\n");
936+
return -EINVAL;
937+
}
938+
939+
if (of_address_to_resource(controller, 1, &sdramwins_res)) {
940+
pr_err("cannot get SDRAM register address\n");
941+
return -EINVAL;
942+
}
943+
944+
ret = mvebu_mbus_common_init(&mbus_state,
945+
mbuswins_res.start,
946+
resource_size(&mbuswins_res),
947+
sdramwins_res.start,
948+
resource_size(&sdramwins_res));
949+
return ret;
950+
}
951+
#endif

include/linux/mbus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ int mvebu_mbus_del_window(phys_addr_t base, size_t size);
7474
int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
7575
size_t mbus_size, phys_addr_t sdram_phys_base,
7676
size_t sdram_size);
77+
int mvebu_mbus_dt_init(void);
7778

7879
#endif /* __LINUX_MBUS_H */

0 commit comments

Comments
 (0)