[PATCH 14/26] MIPS: CDMM: Allow CDMM base address to be specified via DT

From: Paul Burton
Date: Fri Aug 26 2016 - 11:41:47 EST


Allow systems to specify the base address for the CDMM using device
tree. This removes the need for it to be specified by platform specific
code, preparing for generic kernels which can run without any.

Signed-off-by: Paul Burton <paul.burton@xxxxxxxxxx>
---

drivers/bus/mips_cdmm.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index cad49bc..311ce54 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -13,6 +13,8 @@
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/smp.h>
@@ -340,6 +342,17 @@ static phys_addr_t mips_cdmm_cur_base(void)
*/
phys_addr_t __weak mips_cdmm_phys_base(void)
{
+ struct device_node *cdmm_node;
+ struct resource res;
+ int err;
+
+ cdmm_node = of_find_compatible_node(of_root, NULL, "mti,mips-cdmm");
+ if (cdmm_node) {
+ err = of_address_to_resource(cdmm_node, 0, &res);
+ if (!err)
+ return res.start;
+ }
+
return 0;
}

--
2.9.3