OSDN Git Service

regulator: cpr4-mmss-ldo: Correct the GFX LDO CPR sensor count for sdm630
authorTirupathi Reddy <tirupath@codeaurora.org>
Thu, 16 Feb 2017 05:32:52 +0000 (11:02 +0530)
committerTirupathi Reddy <tirupath@codeaurora.org>
Thu, 16 Feb 2017 06:08:22 +0000 (11:38 +0530)
The GFX LDO CPR sensor count in sdm630 is different from that of sdm660.
Assign the correct sensor count under a soc-id comparison check.

CRs-Fixed: 2007621
Change-Id: I82231a30143dc3df0bee3421101316c1d9693d08
Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
drivers/regulator/cpr4-mmss-ldo-regulator.c

index 525f9d6..6c6d112 100644 (file)
@@ -135,9 +135,15 @@ static const int sdm660_mmss_fuse_ref_volt[SDM660_MMSS_FUSE_CORNERS] = {
 #define SDM660_MMSS_VOLTAGE_FUSE_SIZE  5
 
 #define SDM660_MMSS_CPR_SENSOR_COUNT           11
+#define SDM630_MMSS_CPR_SENSOR_COUNT           7
 
 #define SDM660_MMSS_CPR_CLOCK_RATE             19200000
 
+enum {
+       SDM660_SOC_ID,
+       SDM630_SOC_ID,
+};
+
 /**
  * cpr4_sdm660_mmss_read_fuse_data() - load MMSS specific fuse parameter
  *             values
@@ -594,7 +600,10 @@ static int cpr4_mmss_init_controller(struct cpr3_controller *ctrl)
                return rc;
        }
 
-       ctrl->sensor_count = SDM660_MMSS_CPR_SENSOR_COUNT;
+       if (ctrl->soc_revision == SDM660_SOC_ID)
+               ctrl->sensor_count = SDM660_MMSS_CPR_SENSOR_COUNT;
+       else if (ctrl->soc_revision == SDM630_SOC_ID)
+               ctrl->sensor_count = SDM630_MMSS_CPR_SENSOR_COUNT;
 
        /*
         * MMSS only has one thread (0) so the zeroed array does not need
@@ -632,9 +641,23 @@ static int cpr4_mmss_init_controller(struct cpr3_controller *ctrl)
        return 0;
 }
 
+/* Data corresponds to the SoC revision */
+static const struct of_device_id cpr4_mmss_regulator_match_table[] = {
+       {
+               .compatible = "qcom,cpr4-sdm660-mmss-ldo-regulator",
+               .data = (void *)(uintptr_t)SDM660_SOC_ID,
+       },
+       {
+               .compatible = "qcom,cpr4-sdm630-mmss-ldo-regulator",
+               .data = (void *)(uintptr_t)SDM630_SOC_ID,
+       },
+       { },
+};
+
 static int cpr4_mmss_regulator_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
+       const struct of_device_id *match;
        struct cpr3_controller *ctrl;
        int rc;
 
@@ -659,6 +682,12 @@ static int cpr4_mmss_regulator_probe(struct platform_device *pdev)
                return rc;
        }
 
+       match = of_match_node(cpr4_mmss_regulator_match_table, dev->of_node);
+       if (match)
+               ctrl->soc_revision = (uintptr_t)match->data;
+       else
+               cpr3_err(ctrl, "could not find compatible string match\n");
+
        rc = cpr3_map_fuse_base(ctrl, pdev);
        if (rc) {
                cpr3_err(ctrl, "could not map fuse base address\n");
@@ -731,19 +760,6 @@ static int cpr4_mmss_regulator_resume(struct platform_device *pdev)
        return cpr3_regulator_resume(ctrl);
 }
 
-/* Data corresponds to the SoC revision */
-static const struct of_device_id cpr4_mmss_regulator_match_table[] = {
-       {
-               .compatible = "qcom,cpr4-sdm660-mmss-ldo-regulator",
-               .data = (void *)NULL,
-       },
-       {
-               .compatible = "qcom,cpr4-sdm630-mmss-ldo-regulator",
-               .data = (void *)NULL,
-       },
-       { },
-};
-
 static struct platform_driver cpr4_mmss_regulator_driver = {
        .driver         = {
                .name           = "qcom,cpr4-mmss-ldo-regulator",