msm: rtb: Add support for device tree
Add support for setting up RTB via matching in the device tree
in addition to the platform_data driven model. Also add
the corresponding device for 8974 in the device tree.
Change-Id: I76615fc75ff4fe428cab16a4aa161b032e548983
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/arch/arm/boot/dts/msm8974.dtsi b/arch/arm/boot/dts/msm8974.dtsi
index 220a660..0d1d818 100644
--- a/arch/arm/boot/dts/msm8974.dtsi
+++ b/arch/arm/boot/dts/msm8974.dtsi
@@ -573,6 +573,12 @@
qcom,slope = <1134 1122 1142 1123 1176 1176 1176 1186 1176
1176 1176>;
};
+
+ qcom,msm-rtb {
+ compatible = "qcom,msm-rtb";
+ qcom,memory-reservation-type = "EBI1";
+ qcom,memory-reservation-size = <0x100000>; /* 1M EBI1 buffer */
+ };
};
/include/ "msm-pm8x41-rpm-regulator.dtsi"
diff --git a/arch/arm/mach-msm/msm_rtb.c b/arch/arm/mach-msm/msm_rtb.c
index 9dbf9c1..a60c213 100644
--- a/arch/arm/mach-msm/msm_rtb.c
+++ b/arch/arm/mach-msm/msm_rtb.c
@@ -16,11 +16,13 @@
#include <linux/kernel.h>
#include <linux/memory_alloc.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/atomic.h>
+#include <linux/of.h>
#include <asm/io.h>
#include <asm-generic/sizes.h>
#include <mach/memory.h>
@@ -31,6 +33,8 @@
#define SENTINEL_BYTE_2 0xAA
#define SENTINEL_BYTE_3 0xFF
+#define RTB_COMPAT_STR "qcom,msm-rtb"
+
/* Write
* 1) 3 bytes sentinel
* 2) 1 bytes of log type
@@ -227,8 +231,22 @@
#if defined(CONFIG_MSM_RTB_SEPARATE_CPUS)
unsigned int cpu;
#endif
+ int ret;
- msm_rtb.size = d->size;
+ if (!pdev->dev.of_node) {
+ msm_rtb.size = d->size;
+ } else {
+ int size;
+
+ ret = of_property_read_u32((&pdev->dev)->of_node,
+ "qcom,memory-reservation-size",
+ &size);
+
+ if (ret < 0)
+ return ret;
+
+ msm_rtb.size = size;
+ }
if (msm_rtb.size <= 0 || msm_rtb.size > SZ_1M)
return -EINVAL;
@@ -275,10 +293,17 @@
return 0;
}
+static struct of_device_id msm_match_table[] = {
+ {.compatible = RTB_COMPAT_STR},
+ {},
+};
+EXPORT_COMPAT(RTB_COMPAT_STR);
+
static struct platform_driver msm_rtb_driver = {
.driver = {
.name = "msm_rtb",
- .owner = THIS_MODULE
+ .owner = THIS_MODULE,
+ .of_match_table = msm_match_table
},
};