diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2013-07-26 09:17:44 -0400 |
---|---|---|
committer | Jason Cooper <jason@lakedaemon.net> | 2013-08-06 10:10:22 -0400 |
commit | 6bd6b3cb82d55e3b9f3080b6d2c648ceffc7b08a (patch) | |
tree | cd9b98c21a81351c429a24f534cc6b742523a887 | |
parent | 89a7fbfb52e2c7337a3e7b37a3b8e1bde30ded78 (diff) |
bus: mvebu-mbus: Factor out initialization details
We introduce a common initialization function mvebu_mbus_common_init()
that will be used by both legacy and device-tree initialization code.
This patch is an intermediate step, which will allow to introduce the
DT binding for this driver in a less intrusive way.
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>
-rw-r--r-- | drivers/bus/mvebu-mbus.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 827468abb236..1b17954600aa 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c | |||
@@ -847,26 +847,14 @@ static __init int mvebu_mbus_debugfs_init(void) | |||
847 | } | 847 | } |
848 | fs_initcall(mvebu_mbus_debugfs_init); | 848 | fs_initcall(mvebu_mbus_debugfs_init); |
849 | 849 | ||
850 | int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, | 850 | static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus, |
851 | size_t mbuswins_size, | 851 | phys_addr_t mbuswins_phys_base, |
852 | phys_addr_t sdramwins_phys_base, | 852 | size_t mbuswins_size, |
853 | size_t sdramwins_size) | 853 | phys_addr_t sdramwins_phys_base, |
854 | size_t sdramwins_size) | ||
854 | { | 855 | { |
855 | struct mvebu_mbus_state *mbus = &mbus_state; | ||
856 | const struct of_device_id *of_id; | ||
857 | int win; | 856 | int win; |
858 | 857 | ||
859 | for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++) | ||
860 | if (!strcmp(of_id->compatible, soc)) | ||
861 | break; | ||
862 | |||
863 | if (!of_id->compatible) { | ||
864 | pr_err("could not find a matching SoC family\n"); | ||
865 | return -ENODEV; | ||
866 | } | ||
867 | |||
868 | mbus->soc = of_id->data; | ||
869 | |||
870 | mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size); | 858 | mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size); |
871 | if (!mbus->mbuswins_base) | 859 | if (!mbus->mbuswins_base) |
872 | return -ENOMEM; | 860 | return -ENOMEM; |
@@ -887,3 +875,28 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, | |||
887 | 875 | ||
888 | return 0; | 876 | return 0; |
889 | } | 877 | } |
878 | |||
879 | int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, | ||
880 | size_t mbuswins_size, | ||
881 | phys_addr_t sdramwins_phys_base, | ||
882 | size_t sdramwins_size) | ||
883 | { | ||
884 | const struct of_device_id *of_id; | ||
885 | |||
886 | for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++) | ||
887 | if (!strcmp(of_id->compatible, soc)) | ||
888 | break; | ||
889 | |||
890 | if (!of_id->compatible) { | ||
891 | pr_err("could not find a matching SoC family\n"); | ||
892 | return -ENODEV; | ||
893 | } | ||
894 | |||
895 | mbus_state.soc = of_id->data; | ||
896 | |||
897 | return mvebu_mbus_common_init(&mbus_state, | ||
898 | mbuswins_phys_base, | ||
899 | mbuswins_size, | ||
900 | sdramwins_phys_base, | ||
901 | sdramwins_size); | ||
902 | } | ||