msm: rpm: Check and validate RPM driver version
An incompatible RPM driver version may cause Linux to boot with
RPM ignoring all requests from Linux, to prevent that, ensure
the versions are compatible before intializing the RPM driver.
Board will fail to boot if the RPM driver detects an incompatible
version.
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
diff --git a/arch/arm/mach-msm/rpm.c b/arch/arm/mach-msm/rpm.c
index a2b0ebc..ddd2c82 100644
--- a/arch/arm/mach-msm/rpm.c
+++ b/arch/arm/mach-msm/rpm.c
@@ -804,9 +804,20 @@
MSM_RPM_STATUS_ID_VERSION_BUILD);
pr_info("%s: RPM firmware %u.%u.%u\n", __func__, major, minor, build);
- msm_rpm_write(MSM_RPM_PAGE_CTRL, MSM_RPM_CTRL_VERSION_MAJOR, 2);
- msm_rpm_write(MSM_RPM_PAGE_CTRL, MSM_RPM_CTRL_VERSION_MINOR, 0);
- msm_rpm_write(MSM_RPM_PAGE_CTRL, MSM_RPM_CTRL_VERSION_BUILD, 0);
+ if (major != RPM_MAJOR_VER) {
+ pr_err("%s: RPM version %u.%u.%u incompatible with "
+ "this driver version %u.%u.%u\n", __func__,
+ major, minor, build,
+ RPM_MAJOR_VER, RPM_MINOR_VER, RPM_BUILD_VER);
+ return -EFAULT;
+ }
+
+ msm_rpm_write(MSM_RPM_PAGE_CTRL, MSM_RPM_CTRL_VERSION_MAJOR,
+ RPM_MAJOR_VER);
+ msm_rpm_write(MSM_RPM_PAGE_CTRL, MSM_RPM_CTRL_VERSION_MINOR,
+ RPM_MINOR_VER);
+ msm_rpm_write(MSM_RPM_PAGE_CTRL, MSM_RPM_CTRL_VERSION_BUILD,
+ RPM_BUILD_VER);
irq = msm_rpm_platform->irq_ack;