[COMMON] thermal: samsung: Set NUM_PROBE value
authorHyeonseong Gil <hs.gil@samsung.com>
Wed, 3 Aug 2016 02:07:59 +0000 (11:07 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:13:19 +0000 (17:13 +0900)
After suspend and resume, NUM_PROBE value was initialized.
So, save the set value from bootloader at probe time
and write it to TMU_CONTROL1 SFR.

Change-Id: I102d8dbc75168540a06ca27c137fcd2bd0e2b7ba
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/samsung/exynos_tmu.c
drivers/thermal/samsung/exynos_tmu.h

index 99df78a2fbc8e9e56729f69f868fb3e76672b6d4..5d2db17ecf15a5c5e9c50d7ade5f54f6a99c7b6b 100644 (file)
@@ -54,6 +54,7 @@
 #define EXYNOS_TMU_REG_TRIMINFO1       0x4
 #define EXYNOS_TMU_REG_TRIMINFO2       0x8
 #define EXYNOS_TMU_REG_CONTROL         0x20
+#define EXYNOS_TMU_REG_CONTROL1                0x24
 #define EXYNOS_TMU_REG_STATUS          0x28
 #define EXYNOS_TMU_REG_CURRENT_TEMP1_0         0x40
 #define EXYNOS_TMU_REG_CURRENT_TEMP4_2  0x44
 #define EXYNOS_TMU_CLK_SENSE_ON_MASK           (0xffff)
 #define EXYNOS_TMU_TEM1456X_SENSE_VALUE                (0x0A28)
 
+#define EXYNOS_TMU_NUM_PROBE_SHIFT             (16)
+#define EXYNOS_TMU_NUM_PROBE_MASK              (0x7)
+
 #define TOTAL_SENSORS  8
 
 static bool suspended;
@@ -587,7 +591,7 @@ static void exynos8895_tmu_control(struct platform_device *pdev, bool on)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
        struct thermal_zone_device *tz = data->tzd;
-       unsigned int con, interrupt_en, trim_info, trim_info1, trim_info2;
+       unsigned int con, con1, interrupt_en, trim_info, trim_info1, trim_info2;
        unsigned int t_buf_vref_sel, t_buf_slope_sel;
        int i;
        u32 avg_con, avg_sel;
@@ -600,6 +604,11 @@ static void exynos8895_tmu_control(struct platform_device *pdev, bool on)
        writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
        con = 0;
 
+       con1 = readl(data->base + EXYNOS_TMU_REG_CONTROL1);
+       con1 &= ~(EXYNOS_TMU_NUM_PROBE_MASK << EXYNOS_TMU_NUM_PROBE_SHIFT);
+       con1 |= (data->num_probe << EXYNOS_TMU_NUM_PROBE_SHIFT);
+       writel(con1, data->base + EXYNOS_TMU_REG_CONTROL1);
+
        trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
        trim_info1 = readl(data->base + EXYNOS_TMU_REG_TRIMINFO1);
        trim_info2 = readl(data->base + EXYNOS_TMU_REG_TRIMINFO2);
@@ -1486,6 +1495,9 @@ static int exynos_tmu_probe(struct platform_device *pdev)
                goto err_sensor;
        }
 
+       data->num_probe = (readl(data->base + EXYNOS_TMU_REG_CONTROL1) >> EXYNOS_TMU_NUM_PROBE_SHIFT)
+                               & EXYNOS_TMU_NUM_PROBE_MASK;
+
        ret = exynos_tmu_initialize(pdev);
        if (ret) {
                dev_err(&pdev->dev, "Failed to initialize TMU\n");
index 50c587209efcaf07f5014a127bbea82c113a0d8d..e92ed25063d396d3ac7ccb846db0ac67a92e08f6 100644 (file)
@@ -120,6 +120,7 @@ struct sensor_info {
  * @lock: lock to implement synchronization.
  * @temp_error1: fused value of the first point trim.
  * @temp_error2: fused value of the second point trim.
+ * @num_probe: number of probe for TMU_CONTROL1 SFR setting.
  * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  * @ntrip: number of supported trip points.
@@ -147,6 +148,7 @@ struct exynos_tmu_data {
        struct thermal_cooling_device *cool_dev;
        struct list_head node;
        u32 sensors;
+       int num_probe;
        int num_of_sensors;
        struct sensor_info *sensor_info;
        int sensing_mode;