Skip to contentSkip to conversation

thermal: exynos: Re-structure driver and add support for exynos5440

PATCH Superseded Amit Daniel Kachhap 2 participants 86 messages Jun 17, 2013 – Jun 24, 2013 Page 2 of 2

Subsystems (7)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#56 lore raw

Re: [PATCH V6 18/30] thermal: exynos: Add support to handle many instances of TMU

In reply to Eduardo Valentin

Hi Eduardo,

Quoted 203 lines · Eduardo Valentin
Quoted 202 lines · Amit Daniel Kachhap

This patch adds support to handle multiple instances of the TMU controllers. This is done by removing the static structure to register with the core thermal and creating it dynamically for each instance of the TMU controller. The interrupt is made shared type to handle shared interrupts. Also the identifier of the TMU controller is extracted from device tree alias.

---
 drivers/thermal/samsung/exynos_thermal_common.h |    1 +
 drivers/thermal/samsung/exynos_tmu.c            |  147 ++++++++++++++++-------
 drivers/thermal/samsung/exynos_tmu.h            |   13 ++
 drivers/thermal/samsung/exynos_tmu_data.c       |  145 ++++++++++++----------
 drivers/thermal/samsung/exynos_tmu_data.h       |    4 +-
 5 files changed, 197 insertions(+), 113 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.h +1 -0
index dd0077e..0c189d6 100644
@@ -84,6 +84,7 @@ struct thermal_sensor_conf {
      struct thermal_cooling_conf cooling_data;
      void *driver_data;
      void *pzone_data;
+     struct device *dev;
 };
 
 /*Functions used exynos based thermal sensor driver*/
drivers/thermal/samsung/exynos_tmu.c +74 -26
index 4356118..1880c4e 100644
@@ -26,15 +26,32 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
 #include "exynos_tmu_data.h"
 
+/**
+ * struct exynos_tmu_data : A structure to hold the private data of the TMU
+     driver
+ * @id: identifier of the one instance of the TMU controller.
+ * @pdata: pointer to the tmu platform/configuration data
+ * @base: base address of the single instance of the TMU controller.
+ * @irq: irq number of the TMU controller.
+ * @soc: id of the SOC type.
+ * @irq_work: pointer to the irq work structure.
+ * @lock: lock to implement synchronization.
+ * @clk: pointer to the clock structure.
+ * @temp_error1: fused value of the first point trim.
+ * @temp_error2: fused value of the second point trim.
+ * @reg_conf: pointer to structure to register with core thermal.
+ */
 struct exynos_tmu_data {
+     int id;
      struct exynos_tmu_platform_data *pdata;
-     struct resource *mem;
      void __iomem *base;
      int irq;
      enum soc_type soc;
@@ -42,6 +59,7 @@ struct exynos_tmu_data {
      struct mutex lock;
      struct clk *clk;
      u8 temp_error1, temp_error2;
+     struct thermal_sensor_conf *reg_conf;
 };
 
 /*
@@ -345,12 +363,6 @@ static int exynos_tmu_set_emulation(void *drv_data,      unsigned long temp)
      { return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
 
-static struct thermal_sensor_conf exynos_sensor_conf = {
-     .name                   = "exynos-therm",
-     .read_temperature       = (int (*)(void *))exynos_tmu_read,
-     .write_emul_temp        = exynos_tmu_set_emulation,
-};
-
 static void exynos_tmu_work(struct work_struct *work)
 {
      struct exynos_tmu_data *data = container_of(work,
@@ -359,7 +371,7 @@ static void exynos_tmu_work(struct work_struct *work)
      const struct exynos_tmu_registers *reg = pdata->registers;
      unsigned int val_irq;
 
-     exynos_report_trigger(&exynos_sensor_conf);
+     exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
      clk_enable(data->clk);
 
@@ -404,33 +416,73 @@ MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 #endif
 
 static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-                     struct platform_device *pdev)
+                     struct platform_device *pdev, int id)
 {
+     struct  exynos_tmu_init_data *data_table;
+     struct exynos_tmu_platform_data *tmu_data;
 #ifdef CONFIG_OF
      if (pdev->dev.of_node) {
              const struct of_device_id *match;
              match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
              if (!match)
                      return NULL;
-             return (struct exynos_tmu_platform_data *) match->data;
+             data_table = (struct exynos_tmu_init_data *) match->data;
+             if (!data_table || id >= data_table->tmu_count)
+                     return NULL;
+             tmu_data = data_table->tmu_data;
+             return (struct exynos_tmu_platform_data *) (tmu_data + id);
      }
 #endif
      return NULL;
 }
 
-static int exynos_tmu_probe(struct platform_device *pdev)
+static int exynos_map_dt_data(struct platform_device *pdev)
 {
-     struct exynos_tmu_data *data;
-     struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data;
-     int ret, i;
+     struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+     struct exynos_tmu_platform_data *pdata;
+     struct resource res;
 
-     if (!pdata)
-             pdata = exynos_get_driver_data(pdev);
+     if (!data)
+             return -ENODEV;
+
+     data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
+     if (data->id < 0)
+             data->id = 0;
 
+     data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+     if (data->irq <= 0) {
+             dev_err(&pdev->dev, "failed to get IRQ\n");
+             return -ENODEV;
+     }
+
+     if (of_address_to_resource(pdev->dev.of_node, 0, &res)) {
+             dev_err(&pdev->dev, "failed to get Resource 0\n");
+             return -ENODEV;
+     }
+
+     data->base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
+     if (!data->base) {
+             dev_err(&pdev->dev, "Failed to ioremap memory\n");
+             return -EADDRNOTAVAIL;
+     }
+
+     pdata = exynos_get_driver_data(pdev, data->id);
      if (!pdata) {
              dev_err(&pdev->dev, "No platform init data supplied.\n");
              return -ENODEV;
      }
+     data->pdata = pdata;
+
+     return 0;
+}
+
+static int exynos_tmu_probe(struct platform_device *pdev)
+{
+     struct exynos_tmu_data *data;
+     struct exynos_tmu_platform_data *pdata;
+     struct thermal_sensor_conf *sensor_conf;
+     int ret, i;
+
      data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
                                      GFP_KERNEL);
      if (!data) {
@@ -438,21 +490,18 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return -ENOMEM;
      }
 
-     data->irq = platform_get_irq(pdev, 0);
-     if (data->irq < 0) {
-             dev_err(&pdev->dev, "Failed to get platform irq\n");
-             return data->irq;
-     }
+     platform_set_drvdata(pdev, data);
+     mutex_init(&data->lock);
 
-     INIT_WORK(&data->irq_work, exynos_tmu_work);
+     ret = exynos_map_dt_data(pdev);
+     if (ret)
+             return ret;
 
-     data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     data->base = devm_ioremap_resource(&pdev->dev, data->mem);
-     if (IS_ERR(data->base))
-             return PTR_ERR(data->base);
+     pdata = data->pdata;
 
Quoted 9 lines

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 504

Quoted 4 lines
drivers/thermal/samsung/exynos_tmu.c +2 -1
+     INIT_WORK(&data->irq_work, exynos_tmu_work);
      ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
-             IRQF_TRIGGER_RISING, "exynos-tmu", data);
+             IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);

Lets think about this poing: You request the IRQ before data->reg_conf is allocated (below). Does it mean, from this point you can get called to the IRQ handler even if reg_conf is not set? What happens then? I see your irqhandler/worker use it.

Good catch. Will put a check in the IRQ handler.

Thanks,
Amit Daniel

Quoted 296 lines
Quoted 279 lines
drivers/thermal/samsung/exynos_tmu.c +26 -18
      if (ret) {
              dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
              return ret;
@@ -477,10 +526,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              goto err_clk;
      }
 
-     data->pdata = pdata;
-     platform_set_drvdata(pdev, data);
-     mutex_init(&data->lock);
-
      ret = exynos_tmu_initialize(pdev);
      if (ret) {
              dev_err(&pdev->dev, "Failed to initialize TMU\n");
@@ -489,31 +534,43 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
      exynos_tmu_control(pdev, true);
 
-     /* Register the sensor with thermal management interface */
-     (&exynos_sensor_conf)->driver_data = data;
-     exynos_sensor_conf.trip_data.trip_count = pdata->trigger_enable[0] +
+     /* Allocate a structure to register with the exynos core thermal */
+     sensor_conf = devm_kzalloc(&pdev->dev,
+                             sizeof(struct thermal_sensor_conf), GFP_KERNEL);
+     if (!sensor_conf) {
+             dev_err(&pdev->dev, "Failed to allocate registration struct\n");
+             ret = -ENOMEM;
+             goto err_clk;
+     }
+     data->reg_conf = sensor_conf;
+     sprintf(sensor_conf->name, "therm_zone%d", data->id);
+     sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
+     sensor_conf->write_emul_temp =
+             (int (*)(void *, unsigned long))exynos_tmu_set_emulation;
+     sensor_conf->driver_data = data;
+     sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
                      pdata->trigger_enable[1] + pdata->trigger_enable[2]+
                      pdata->trigger_enable[3];
 
-     for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) {
-             exynos_sensor_conf.trip_data.trip_val[i] =
+     for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
+             sensor_conf->trip_data.trip_val[i] =
                      pdata->threshold + pdata->trigger_levels[i];
-             exynos_sensor_conf.trip_data.trip_type[i] =
+             sensor_conf->trip_data.trip_type[i] =
                                      pdata->trigger_type[i];
      }
 
-     exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling;
+     sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-     exynos_sensor_conf.cooling_data.freq_clip_count =
-                                             pdata->freq_tab_count;
+     sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
      for (i = 0; i < pdata->freq_tab_count; i++) {
-             exynos_sensor_conf.cooling_data.freq_data[i].freq_clip_max =
+             sensor_conf->cooling_data.freq_data[i].freq_clip_max =
                                      pdata->freq_tab[i].freq_clip_max;
-             exynos_sensor_conf.cooling_data.freq_data[i].temp_level =
+             sensor_conf->cooling_data.freq_data[i].temp_level =
                                      pdata->freq_tab[i].temp_level;
      }
-
-     ret = exynos_register_thermal(&exynos_sensor_conf);
+     sensor_conf->dev = &pdev->dev;
+     /* Register the sensor with thermal management interface */
+     ret = exynos_register_thermal(sensor_conf);
      if (ret) {
              dev_err(&pdev->dev, "Failed to register thermal interface\n");
              goto err_clk;
@@ -531,7 +588,7 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
      exynos_tmu_control(pdev, false);
 
-     exynos_unregister_thermal(&exynos_sensor_conf);
+     exynos_unregister_thermal(data->reg_conf);
 
      clk_unprepare(data->clk);
 
drivers/thermal/samsung/exynos_tmu.h +13 -0
index 619a34c..b614407 100644
@@ -248,4 +248,17 @@ struct exynos_tmu_platform_data {
      unsigned int freq_tab_count;
      const struct exynos_tmu_registers *registers;
 };
+
+/**
+ * struct exynos_tmu_init_data
+ * @tmu_count: number of TMU instances.
+ * @tmu_data: platform data of all TMU instances.
+ * This structure is required to store data for multi-instance exynos tmu
+ * driver.
+ */
+struct exynos_tmu_init_data {
+     int tmu_count;
+     struct exynos_tmu_platform_data tmu_data[];
+};
+
 #endif /* _EXYNOS_TMU_H */
drivers/thermal/samsung/exynos_tmu_data.c +79 -66
index 7fcf183..06ecfb0 100644
@@ -48,38 +48,44 @@ static const struct exynos_tmu_registers exynos4210_tmu_registers = {
      .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
      .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 };
-struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
-     .threshold = 80,
-     .trigger_levels[0] = 5,
-     .trigger_levels[1] = 20,
-     .trigger_levels[2] = 30,
-     .trigger_enable[0] = 1,
-     .trigger_enable[1] = 1,
-     .trigger_enable[2] = 1,
-     .trigger_enable[3] = 0,
-     .trigger_type[0] = THROTTLE_ACTIVE,
-     .trigger_type[1] = THROTTLE_ACTIVE,
-     .trigger_type[2] = SW_TRIP,
-     .max_trigger_level = 4,
-     .gain = 15,
-     .reference_voltage = 7,
-     .cal_type = TYPE_ONE_POINT_TRIMMING,
-     .min_efuse_value = 40,
-     .max_efuse_value = 100,
-     .first_point_trim = 25,
-     .second_point_trim = 85,
-     .default_temp_offset = 50,
-     .freq_tab[0] = {
-             .freq_clip_max = 800 * 1000,
-             .temp_level = 85,
-     },
-     .freq_tab[1] = {
-             .freq_clip_max = 200 * 1000,
-             .temp_level = 100,
+
+struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
+     .tmu_data = {
+             {
+             .threshold = 80,
+             .trigger_levels[0] = 5,
+             .trigger_levels[1] = 20,
+             .trigger_levels[2] = 30,
+             .trigger_enable[0] = 1,
+             .trigger_enable[1] = 1,
+             .trigger_enable[2] = 1,
+             .trigger_enable[3] = 0,
+             .trigger_type[0] = THROTTLE_ACTIVE,
+             .trigger_type[1] = THROTTLE_ACTIVE,
+             .trigger_type[2] = SW_TRIP,
+             .max_trigger_level = 4,
+             .gain = 15,
+             .reference_voltage = 7,
+             .cal_type = TYPE_ONE_POINT_TRIMMING,
+             .min_efuse_value = 40,
+             .max_efuse_value = 100,
+             .first_point_trim = 25,
+             .second_point_trim = 85,
+             .default_temp_offset = 50,
+             .freq_tab[0] = {
+                     .freq_clip_max = 800 * 1000,
+                     .temp_level = 85,
+                     },
+             .freq_tab[1] = {
+                     .freq_clip_max = 200 * 1000,
+                     .temp_level = 100,
+             },
+             .freq_tab_count = 2,
+             .type = SOC_ARCH_EXYNOS4210,
+             .registers = &exynos4210_tmu_registers,
+             },
      },
-     .freq_tab_count = 2,
-     .type = SOC_ARCH_EXYNOS4210,
-     .registers = &exynos4210_tmu_registers,
+     .tmu_count = 1,
 };
 #endif
 
@@ -120,41 +126,48 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
      .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
      .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
 };
-struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
-     .threshold_falling = 10,
-     .trigger_levels[0] = 85,
-     .trigger_levels[1] = 103,
-     .trigger_levels[2] = 110,
-     .trigger_levels[3] = 120,
-     .trigger_enable[0] = 1,
-     .trigger_enable[1] = 1,
-     .trigger_enable[2] = 1,
-     .trigger_enable[3] = 0,
-     .trigger_type[0] = THROTTLE_ACTIVE,
-     .trigger_type[1] = THROTTLE_ACTIVE,
-     .trigger_type[2] = SW_TRIP,
-     .trigger_type[3] = HW_TRIP,
-     .max_trigger_level = 4,
-     .gain = 8,
-     .reference_voltage = 16,
-     .noise_cancel_mode = 4,
-     .cal_type = TYPE_ONE_POINT_TRIMMING,
-     .efuse_value = 55,
-     .min_efuse_value = 40,
-     .max_efuse_value = 100,
-     .first_point_trim = 25,
-     .second_point_trim = 85,
-     .default_temp_offset = 50,
-     .freq_tab[0] = {
-             .freq_clip_max = 800 * 1000,
-             .temp_level = 85,
-     },
-     .freq_tab[1] = {
-             .freq_clip_max = 200 * 1000,
-             .temp_level = 103,
-     },
-     .freq_tab_count = 2,
-     .type = SOC_ARCH_EXYNOS,
+
+#define EXYNOS5250_TMU_DATA \
+     .threshold_falling = 10, \
+     .trigger_levels[0] = 85, \
+     .trigger_levels[1] = 103, \
+     .trigger_levels[2] = 110, \
+     .trigger_levels[3] = 120, \
+     .trigger_enable[0] = 1, \
+     .trigger_enable[1] = 1, \
+     .trigger_enable[2] = 1, \
+     .trigger_enable[3] = 0, \
+     .trigger_type[0] = THROTTLE_ACTIVE, \
+     .trigger_type[1] = THROTTLE_ACTIVE, \
+     .trigger_type[2] = SW_TRIP, \
+     .trigger_type[3] = HW_TRIP, \
+     .max_trigger_level = 4, \
+     .gain = 8, \
+     .reference_voltage = 16, \
+     .noise_cancel_mode = 4, \
+     .cal_type = TYPE_ONE_POINT_TRIMMING, \
+     .efuse_value = 55, \
+     .min_efuse_value = 40, \
+     .max_efuse_value = 100, \
+     .first_point_trim = 25, \
+     .second_point_trim = 85, \
+     .default_temp_offset = 50, \
+     .freq_tab[0] = { \
+             .freq_clip_max = 800 * 1000, \
+             .temp_level = 85, \
+     }, \
+     .freq_tab[1] = { \
+             .freq_clip_max = 200 * 1000, \
+             .temp_level = 103, \
+     }, \
+     .freq_tab_count = 2, \
+     .type = SOC_ARCH_EXYNOS, \
      .registers = &exynos5250_tmu_registers,
+
+struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
+     .tmu_data = {
+             { EXYNOS5250_TMU_DATA },
+     },
+     .tmu_count = 1,
 };
 #endif
drivers/thermal/samsung/exynos_tmu_data.h +1 -1
index 4acf070..139dbbb 100644
@@ -94,14 +94,14 @@
 #define EXYNOS_MAX_TRIGGER_PER_REG   4
 
 #if defined(CONFIG_CPU_EXYNOS4210)
-extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
+extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)

drivers/thermal/samsung/exynos_tmu_data.h line 107

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.h +1 -1
 #else
 #define EXYNOS4210_TMU_DRV_DATA (NULL)
 #endif
 
 #if (defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412))
-extern struct exynos_tmu_platform_data const exynos5250_default_tmu_data;
+extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
 #define EXYNOS5250_TMU_DRV_DATA (&exynos5250_default_tmu_data)
 #else
 #define EXYNOS5250_TMU_DRV_DATA (NULL)

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#57 lore raw

Re: [PATCH V6 18/30] thermal: exynos: Add support to handle many instances of TMU

Quoted 217 lines · amit daniel kachhap

Hi Eduardo,

Quoted 203 lines · Eduardo Valentin
Quoted 202 lines · Amit Daniel Kachhap

This patch adds support to handle multiple instances of the TMU controllers. This is done by removing the static structure to register with the core thermal and creating it dynamically for each instance of the TMU controller. The interrupt is made shared type to handle shared interrupts. Also the identifier of the TMU controller is extracted from device tree alias.

---
 drivers/thermal/samsung/exynos_thermal_common.h |    1 +
 drivers/thermal/samsung/exynos_tmu.c            |  147 ++++++++++++++++-------
 drivers/thermal/samsung/exynos_tmu.h            |   13 ++
 drivers/thermal/samsung/exynos_tmu_data.c       |  145 ++++++++++++----------
 drivers/thermal/samsung/exynos_tmu_data.h       |    4 +-
 5 files changed, 197 insertions(+), 113 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.h +1 -0
index dd0077e..0c189d6 100644
@@ -84,6 +84,7 @@ struct thermal_sensor_conf {
      struct thermal_cooling_conf cooling_data;
      void *driver_data;
      void *pzone_data;
+     struct device *dev;
 };
 
 /*Functions used exynos based thermal sensor driver*/
drivers/thermal/samsung/exynos_tmu.c +74 -26
index 4356118..1880c4e 100644
@@ -26,15 +26,32 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
 #include "exynos_tmu_data.h"
 
+/**
+ * struct exynos_tmu_data : A structure to hold the private data of the TMU
+     driver
+ * @id: identifier of the one instance of the TMU controller.
+ * @pdata: pointer to the tmu platform/configuration data
+ * @base: base address of the single instance of the TMU controller.
+ * @irq: irq number of the TMU controller.
+ * @soc: id of the SOC type.
+ * @irq_work: pointer to the irq work structure.
+ * @lock: lock to implement synchronization.
+ * @clk: pointer to the clock structure.
+ * @temp_error1: fused value of the first point trim.
+ * @temp_error2: fused value of the second point trim.
+ * @reg_conf: pointer to structure to register with core thermal.
+ */
 struct exynos_tmu_data {
+     int id;
      struct exynos_tmu_platform_data *pdata;
-     struct resource *mem;
      void __iomem *base;
      int irq;
      enum soc_type soc;
@@ -42,6 +59,7 @@ struct exynos_tmu_data {
      struct mutex lock;
      struct clk *clk;
      u8 temp_error1, temp_error2;
+     struct thermal_sensor_conf *reg_conf;
 };
 
 /*
@@ -345,12 +363,6 @@ static int exynos_tmu_set_emulation(void *drv_data,      unsigned long temp)
      { return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
 
-static struct thermal_sensor_conf exynos_sensor_conf = {
-     .name                   = "exynos-therm",
-     .read_temperature       = (int (*)(void *))exynos_tmu_read,
-     .write_emul_temp        = exynos_tmu_set_emulation,
-};
-
 static void exynos_tmu_work(struct work_struct *work)
 {
      struct exynos_tmu_data *data = container_of(work,
@@ -359,7 +371,7 @@ static void exynos_tmu_work(struct work_struct *work)
      const struct exynos_tmu_registers *reg = pdata->registers;
      unsigned int val_irq;
 
-     exynos_report_trigger(&exynos_sensor_conf);
+     exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
      clk_enable(data->clk);
 
@@ -404,33 +416,73 @@ MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 #endif
 
 static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-                     struct platform_device *pdev)
+                     struct platform_device *pdev, int id)
 {
+     struct  exynos_tmu_init_data *data_table;
+     struct exynos_tmu_platform_data *tmu_data;
 #ifdef CONFIG_OF
      if (pdev->dev.of_node) {
              const struct of_device_id *match;
              match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
              if (!match)
                      return NULL;
-             return (struct exynos_tmu_platform_data *) match->data;
+             data_table = (struct exynos_tmu_init_data *) match->data;
+             if (!data_table || id >= data_table->tmu_count)
+                     return NULL;
+             tmu_data = data_table->tmu_data;
+             return (struct exynos_tmu_platform_data *) (tmu_data + id);
      }
 #endif
      return NULL;
 }
 
-static int exynos_tmu_probe(struct platform_device *pdev)
+static int exynos_map_dt_data(struct platform_device *pdev)
 {
-     struct exynos_tmu_data *data;
-     struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data;
-     int ret, i;
+     struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+     struct exynos_tmu_platform_data *pdata;
+     struct resource res;
 
-     if (!pdata)
-             pdata = exynos_get_driver_data(pdev);
+     if (!data)
+             return -ENODEV;
+
+     data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
+     if (data->id < 0)
+             data->id = 0;
 
+     data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+     if (data->irq <= 0) {
+             dev_err(&pdev->dev, "failed to get IRQ\n");
+             return -ENODEV;
+     }
+
+     if (of_address_to_resource(pdev->dev.of_node, 0, &res)) {
+             dev_err(&pdev->dev, "failed to get Resource 0\n");
+             return -ENODEV;
+     }
+
+     data->base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
+     if (!data->base) {
+             dev_err(&pdev->dev, "Failed to ioremap memory\n");
+             return -EADDRNOTAVAIL;
+     }
+
+     pdata = exynos_get_driver_data(pdev, data->id);
      if (!pdata) {
              dev_err(&pdev->dev, "No platform init data supplied.\n");
              return -ENODEV;
      }
+     data->pdata = pdata;
+
+     return 0;
+}
+
+static int exynos_tmu_probe(struct platform_device *pdev)
+{
+     struct exynos_tmu_data *data;
+     struct exynos_tmu_platform_data *pdata;
+     struct thermal_sensor_conf *sensor_conf;
+     int ret, i;
+
      data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
                                      GFP_KERNEL);
      if (!data) {
@@ -438,21 +490,18 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return -ENOMEM;
      }
 
-     data->irq = platform_get_irq(pdev, 0);
-     if (data->irq < 0) {
-             dev_err(&pdev->dev, "Failed to get platform irq\n");
-             return data->irq;
-     }
+     platform_set_drvdata(pdev, data);
+     mutex_init(&data->lock);
 
-     INIT_WORK(&data->irq_work, exynos_tmu_work);
+     ret = exynos_map_dt_data(pdev);
+     if (ret)
+             return ret;
 
-     data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     data->base = devm_ioremap_resource(&pdev->dev, data->mem);
-     if (IS_ERR(data->base))
-             return PTR_ERR(data->base);
+     pdata = data->pdata;
 
Quoted 9 lines

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 504

Quoted 4 lines
drivers/thermal/samsung/exynos_tmu.c +2 -1
+     INIT_WORK(&data->irq_work, exynos_tmu_work);
      ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
-             IRQF_TRIGGER_RISING, "exynos-tmu", data);
+             IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);

Lets think about this poing: You request the IRQ before data->reg_conf is allocated (below). Does it mean, from this point you can get called to the IRQ handler even if reg_conf is not set? What happens then? I see your irqhandler/worker use it.

Quoted 1 line

Good catch. Will put a check in the IRQ handler.

Consider also moving the IRQ request to a point where your driver is capable of serving IRQs already.

Quoted 301 lines

Thanks,
Amit Daniel

Quoted 296 lines
Quoted 279 lines
drivers/thermal/samsung/exynos_tmu.c +26 -18
      if (ret) {
              dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
              return ret;
@@ -477,10 +526,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              goto err_clk;
      }
 
-     data->pdata = pdata;
-     platform_set_drvdata(pdev, data);
-     mutex_init(&data->lock);
-
      ret = exynos_tmu_initialize(pdev);
      if (ret) {
              dev_err(&pdev->dev, "Failed to initialize TMU\n");
@@ -489,31 +534,43 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
      exynos_tmu_control(pdev, true);
 
-     /* Register the sensor with thermal management interface */
-     (&exynos_sensor_conf)->driver_data = data;
-     exynos_sensor_conf.trip_data.trip_count = pdata->trigger_enable[0] +
+     /* Allocate a structure to register with the exynos core thermal */
+     sensor_conf = devm_kzalloc(&pdev->dev,
+                             sizeof(struct thermal_sensor_conf), GFP_KERNEL);
+     if (!sensor_conf) {
+             dev_err(&pdev->dev, "Failed to allocate registration struct\n");
+             ret = -ENOMEM;
+             goto err_clk;
+     }
+     data->reg_conf = sensor_conf;
+     sprintf(sensor_conf->name, "therm_zone%d", data->id);
+     sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
+     sensor_conf->write_emul_temp =
+             (int (*)(void *, unsigned long))exynos_tmu_set_emulation;
+     sensor_conf->driver_data = data;
+     sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
                      pdata->trigger_enable[1] + pdata->trigger_enable[2]+
                      pdata->trigger_enable[3];
 
-     for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) {
-             exynos_sensor_conf.trip_data.trip_val[i] =
+     for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
+             sensor_conf->trip_data.trip_val[i] =
                      pdata->threshold + pdata->trigger_levels[i];
-             exynos_sensor_conf.trip_data.trip_type[i] =
+             sensor_conf->trip_data.trip_type[i] =
                                      pdata->trigger_type[i];
      }
 
-     exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling;
+     sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-     exynos_sensor_conf.cooling_data.freq_clip_count =
-                                             pdata->freq_tab_count;
+     sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
      for (i = 0; i < pdata->freq_tab_count; i++) {
-             exynos_sensor_conf.cooling_data.freq_data[i].freq_clip_max =
+             sensor_conf->cooling_data.freq_data[i].freq_clip_max =
                                      pdata->freq_tab[i].freq_clip_max;
-             exynos_sensor_conf.cooling_data.freq_data[i].temp_level =
+             sensor_conf->cooling_data.freq_data[i].temp_level =
                                      pdata->freq_tab[i].temp_level;
      }
-
-     ret = exynos_register_thermal(&exynos_sensor_conf);
+     sensor_conf->dev = &pdev->dev;
+     /* Register the sensor with thermal management interface */
+     ret = exynos_register_thermal(sensor_conf);
      if (ret) {
              dev_err(&pdev->dev, "Failed to register thermal interface\n");
              goto err_clk;
@@ -531,7 +588,7 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
      exynos_tmu_control(pdev, false);
 
-     exynos_unregister_thermal(&exynos_sensor_conf);
+     exynos_unregister_thermal(data->reg_conf);
 
      clk_unprepare(data->clk);
 
drivers/thermal/samsung/exynos_tmu.h +13 -0
index 619a34c..b614407 100644
@@ -248,4 +248,17 @@ struct exynos_tmu_platform_data {
      unsigned int freq_tab_count;
      const struct exynos_tmu_registers *registers;
 };
+
+/**
+ * struct exynos_tmu_init_data
+ * @tmu_count: number of TMU instances.
+ * @tmu_data: platform data of all TMU instances.
+ * This structure is required to store data for multi-instance exynos tmu
+ * driver.
+ */
+struct exynos_tmu_init_data {
+     int tmu_count;
+     struct exynos_tmu_platform_data tmu_data[];
+};
+
 #endif /* _EXYNOS_TMU_H */
drivers/thermal/samsung/exynos_tmu_data.c +79 -66
index 7fcf183..06ecfb0 100644
@@ -48,38 +48,44 @@ static const struct exynos_tmu_registers exynos4210_tmu_registers = {
      .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
      .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 };
-struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
-     .threshold = 80,
-     .trigger_levels[0] = 5,
-     .trigger_levels[1] = 20,
-     .trigger_levels[2] = 30,
-     .trigger_enable[0] = 1,
-     .trigger_enable[1] = 1,
-     .trigger_enable[2] = 1,
-     .trigger_enable[3] = 0,
-     .trigger_type[0] = THROTTLE_ACTIVE,
-     .trigger_type[1] = THROTTLE_ACTIVE,
-     .trigger_type[2] = SW_TRIP,
-     .max_trigger_level = 4,
-     .gain = 15,
-     .reference_voltage = 7,
-     .cal_type = TYPE_ONE_POINT_TRIMMING,
-     .min_efuse_value = 40,
-     .max_efuse_value = 100,
-     .first_point_trim = 25,
-     .second_point_trim = 85,
-     .default_temp_offset = 50,
-     .freq_tab[0] = {
-             .freq_clip_max = 800 * 1000,
-             .temp_level = 85,
-     },
-     .freq_tab[1] = {
-             .freq_clip_max = 200 * 1000,
-             .temp_level = 100,
+
+struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
+     .tmu_data = {
+             {
+             .threshold = 80,
+             .trigger_levels[0] = 5,
+             .trigger_levels[1] = 20,
+             .trigger_levels[2] = 30,
+             .trigger_enable[0] = 1,
+             .trigger_enable[1] = 1,
+             .trigger_enable[2] = 1,
+             .trigger_enable[3] = 0,
+             .trigger_type[0] = THROTTLE_ACTIVE,
+             .trigger_type[1] = THROTTLE_ACTIVE,
+             .trigger_type[2] = SW_TRIP,
+             .max_trigger_level = 4,
+             .gain = 15,
+             .reference_voltage = 7,
+             .cal_type = TYPE_ONE_POINT_TRIMMING,
+             .min_efuse_value = 40,
+             .max_efuse_value = 100,
+             .first_point_trim = 25,
+             .second_point_trim = 85,
+             .default_temp_offset = 50,
+             .freq_tab[0] = {
+                     .freq_clip_max = 800 * 1000,
+                     .temp_level = 85,
+                     },
+             .freq_tab[1] = {
+                     .freq_clip_max = 200 * 1000,
+                     .temp_level = 100,
+             },
+             .freq_tab_count = 2,
+             .type = SOC_ARCH_EXYNOS4210,
+             .registers = &exynos4210_tmu_registers,
+             },
      },
-     .freq_tab_count = 2,
-     .type = SOC_ARCH_EXYNOS4210,
-     .registers = &exynos4210_tmu_registers,
+     .tmu_count = 1,
 };
 #endif
 
@@ -120,41 +126,48 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
      .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
      .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
 };
-struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
-     .threshold_falling = 10,
-     .trigger_levels[0] = 85,
-     .trigger_levels[1] = 103,
-     .trigger_levels[2] = 110,
-     .trigger_levels[3] = 120,
-     .trigger_enable[0] = 1,
-     .trigger_enable[1] = 1,
-     .trigger_enable[2] = 1,
-     .trigger_enable[3] = 0,
-     .trigger_type[0] = THROTTLE_ACTIVE,
-     .trigger_type[1] = THROTTLE_ACTIVE,
-     .trigger_type[2] = SW_TRIP,
-     .trigger_type[3] = HW_TRIP,
-     .max_trigger_level = 4,
-     .gain = 8,
-     .reference_voltage = 16,
-     .noise_cancel_mode = 4,
-     .cal_type = TYPE_ONE_POINT_TRIMMING,
-     .efuse_value = 55,
-     .min_efuse_value = 40,
-     .max_efuse_value = 100,
-     .first_point_trim = 25,
-     .second_point_trim = 85,
-     .default_temp_offset = 50,
-     .freq_tab[0] = {
-             .freq_clip_max = 800 * 1000,
-             .temp_level = 85,
-     },
-     .freq_tab[1] = {
-             .freq_clip_max = 200 * 1000,
-             .temp_level = 103,
-     },
-     .freq_tab_count = 2,
-     .type = SOC_ARCH_EXYNOS,
+
+#define EXYNOS5250_TMU_DATA \
+     .threshold_falling = 10, \
+     .trigger_levels[0] = 85, \
+     .trigger_levels[1] = 103, \
+     .trigger_levels[2] = 110, \
+     .trigger_levels[3] = 120, \
+     .trigger_enable[0] = 1, \
+     .trigger_enable[1] = 1, \
+     .trigger_enable[2] = 1, \
+     .trigger_enable[3] = 0, \
+     .trigger_type[0] = THROTTLE_ACTIVE, \
+     .trigger_type[1] = THROTTLE_ACTIVE, \
+     .trigger_type[2] = SW_TRIP, \
+     .trigger_type[3] = HW_TRIP, \
+     .max_trigger_level = 4, \
+     .gain = 8, \
+     .reference_voltage = 16, \
+     .noise_cancel_mode = 4, \
+     .cal_type = TYPE_ONE_POINT_TRIMMING, \
+     .efuse_value = 55, \
+     .min_efuse_value = 40, \
+     .max_efuse_value = 100, \
+     .first_point_trim = 25, \
+     .second_point_trim = 85, \
+     .default_temp_offset = 50, \
+     .freq_tab[0] = { \
+             .freq_clip_max = 800 * 1000, \
+             .temp_level = 85, \
+     }, \
+     .freq_tab[1] = { \
+             .freq_clip_max = 200 * 1000, \
+             .temp_level = 103, \
+     }, \
+     .freq_tab_count = 2, \
+     .type = SOC_ARCH_EXYNOS, \
      .registers = &exynos5250_tmu_registers,
+
+struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
+     .tmu_data = {
+             { EXYNOS5250_TMU_DATA },
+     },
+     .tmu_count = 1,
 };
 #endif
drivers/thermal/samsung/exynos_tmu_data.h +1 -1
index 4acf070..139dbbb 100644
@@ -94,14 +94,14 @@
 #define EXYNOS_MAX_TRIGGER_PER_REG   4
 
 #if defined(CONFIG_CPU_EXYNOS4210)
-extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
+extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)

drivers/thermal/samsung/exynos_tmu_data.h line 107

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.h +1 -1
 #else
 #define EXYNOS4210_TMU_DRV_DATA (NULL)
 #endif
 
 #if (defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412))
-extern struct exynos_tmu_platform_data const exynos5250_default_tmu_data;
+extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
 #define EXYNOS5250_TMU_DRV_DATA (&exynos5250_default_tmu_data)
 #else
 #define EXYNOS5250_TMU_DRV_DATA (NULL)

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#58 lore raw

PATCH v6 19/30 thermal: exynos: Add TMU features to check instead of using SOC type

In reply to Amit Daniel Kachhap

This patch adds several features supported by TMU as bitfields. This features varies across different SOC type and comparing the features present in the TMU is more logical than comparing the soc itself.

---
 drivers/thermal/samsung/exynos_tmu.c      |   26 +++++++++++++++---------
 drivers/thermal/samsung/exynos_tmu.h      |   31 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.c |    6 ++++-
 3 files changed, 52 insertions(+), 11 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +16 -10
index 1880c4e..877dab8 100644
@@ -142,13 +142,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	status = readb(data->base + reg->tmu_status);
-	if (!status) {
-		ret = -EBUSY;
-		goto out;
+	if (TMU_SUPPORTS(pdata, READY_STATUS)) {
+		status = readb(data->base + reg->tmu_status);
+		if (!status) {
+			ret = -EBUSY;
+			goto out;
+		}
 	}
 
-	if (data->soc == SOC_ARCH_EXYNOS)
+	if (TMU_SUPPORTS(pdata, TRIM_RELOAD))
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
 	/* Save trimming info in order to perform calibration */
@@ -287,7 +289,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 			pdata->trigger_enable[2] << reg->inten_rise2_shift |
 			pdata->trigger_enable[1] << reg->inten_rise1_shift |
 			pdata->trigger_enable[0] << reg->inten_rise0_shift;
-		if (pdata->threshold_falling)
+		if (TMU_SUPPORTS(pdata, FALLING_TRIP))
 			interrupt_en |=
 				interrupt_en << reg->inten_fall0_shift;
 	} else {
@@ -329,7 +331,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	unsigned int val;
 	int ret = -EINVAL;
 
-	if (data->soc == SOC_ARCH_EXYNOS4210)
+	if (!TMU_SUPPORTS(pdata, EMULATION))
 		goto out;
 
 	if (temp && temp < MCELSIUS)
@@ -343,9 +345,13 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	if (temp) {
 		temp /= MCELSIUS;
 
-		val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) |
-			(temp_to_code(data, temp)
-			 << reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE;
+		if (TMU_SUPPORTS(pdata, EMUL_TIME)) {
+			val &= ~(EXYNOS_EMUL_TIME_MASK << reg->emul_time_shift);
+			val |= (EXYNOS_EMUL_TIME << reg->emul_time_shift);
+		}
+		val &= ~(EXYNOS_EMUL_DATA_MASK << reg->emul_temp_shift);
+		val |= (temp_to_code(data, temp) << reg->emul_temp_shift) |
+			EXYNOS_EMUL_ENABLE;
 	} else {
 		val &= ~EXYNOS_EMUL_ENABLE;
 	}
drivers/thermal/samsung/exynos_tmu.h +31 -0
index b614407..6f55673 100644
@@ -41,6 +41,34 @@ enum soc_type {
 };
 
 /**
+ * EXYNOS TMU supported features.
+ * TMU_SUPPORT_EMULATION - This features is used to set user defined
+ *			temperature to the TMU controller.
+ * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
+ *			has many instances of TMU.
+ * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can
+ *			be reloaded.
+ * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
+ *			be registered for falling trips also.
+ * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current
+ *			state(active/idle) can be checked.
+ * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
+ *			sample time.
+ * TMU_SUPPORT_SHARED_MEMORY - This feature tells that the different TMU
+ *			sensors shares some common registers.
+ * TMU_SUPPORT - macro to compare the above features with the supplied.
+ */
+#define TMU_SUPPORT_EMULATION			BIT(0)
+#define TMU_SUPPORT_MULTI_INST			BIT(1)
+#define TMU_SUPPORT_TRIM_RELOAD			BIT(2)
+#define TMU_SUPPORT_FALLING_TRIP		BIT(3)
+#define TMU_SUPPORT_READY_STATUS		BIT(4)
+#define TMU_SUPPORT_EMUL_TIME			BIT(5)
+#define TMU_SUPPORT_SHARED_MEMORY		BIT(6)
+
+#define TMU_SUPPORTS(a, b)	(a->features & TMU_SUPPORT_ ## b)
+
+/**
  * struct exynos_tmu_register - register descriptors to access registers and
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
@@ -220,6 +248,8 @@ struct exynos_tmu_registers {
  *	applicable to only some of the trigger levels.
  * @registers: Pointer to structure containing all the TMU controller registers
  *	and bitfields shifts and masks.
+ * @features: a bitfield value indicating the features supported in SOC like
+ *	emulation, multi instance etc
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -247,6 +277,7 @@ struct exynos_tmu_platform_data {
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 	const struct exynos_tmu_registers *registers;
+	unsigned int features;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.c +5 -1
index 06ecfb0..694557e 100644
@@ -83,6 +83,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		.registers = &exynos4210_tmu_registers,
+		.features = TMU_SUPPORT_READY_STATUS,
 		},
 	},
 	.tmu_count = 1,
@@ -162,7 +163,10 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
 	}, \
 	.freq_tab_count = 2, \
 	.type = SOC_ARCH_EXYNOS, \
-	.registers = &exynos5250_tmu_registers,
+	.registers = &exynos5250_tmu_registers, \
+	.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
+			TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
+			TMU_SUPPORT_EMUL_TIME)
 
 struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.tmu_data = {
Signature · 1 line
1.7.1
Acked-by on v6 19/30
#59 lore raw

Re: [PATCH V6 19/30] thermal: exynos: Add TMU features to check instead of using SOC type

Quoted 8 lines · Amit Daniel Kachhap

This patch adds several features supported by TMU as bitfields. This features varies across different SOC type and comparing the features present in the TMU is more logical than comparing the soc itself.

Quoted 147 lines
---
 drivers/thermal/samsung/exynos_tmu.c      |   26 +++++++++++++++---------
 drivers/thermal/samsung/exynos_tmu.h      |   31 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.c |    6 ++++-
 3 files changed, 52 insertions(+), 11 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +16 -10
index 1880c4e..877dab8 100644
@@ -142,13 +142,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	status = readb(data->base + reg->tmu_status);
-	if (!status) {
-		ret = -EBUSY;
-		goto out;
+	if (TMU_SUPPORTS(pdata, READY_STATUS)) {
+		status = readb(data->base + reg->tmu_status);
+		if (!status) {
+			ret = -EBUSY;
+			goto out;
+		}
 	}
 
-	if (data->soc == SOC_ARCH_EXYNOS)
+	if (TMU_SUPPORTS(pdata, TRIM_RELOAD))
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
 	/* Save trimming info in order to perform calibration */
@@ -287,7 +289,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 			pdata->trigger_enable[2] << reg->inten_rise2_shift |
 			pdata->trigger_enable[1] << reg->inten_rise1_shift |
 			pdata->trigger_enable[0] << reg->inten_rise0_shift;
-		if (pdata->threshold_falling)
+		if (TMU_SUPPORTS(pdata, FALLING_TRIP))
 			interrupt_en |=
 				interrupt_en << reg->inten_fall0_shift;
 	} else {
@@ -329,7 +331,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	unsigned int val;
 	int ret = -EINVAL;
 
-	if (data->soc == SOC_ARCH_EXYNOS4210)
+	if (!TMU_SUPPORTS(pdata, EMULATION))
 		goto out;
 
 	if (temp && temp < MCELSIUS)
@@ -343,9 +345,13 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	if (temp) {
 		temp /= MCELSIUS;
 
-		val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) |
-			(temp_to_code(data, temp)
-			 << reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE;
+		if (TMU_SUPPORTS(pdata, EMUL_TIME)) {
+			val &= ~(EXYNOS_EMUL_TIME_MASK << reg->emul_time_shift);
+			val |= (EXYNOS_EMUL_TIME << reg->emul_time_shift);
+		}
+		val &= ~(EXYNOS_EMUL_DATA_MASK << reg->emul_temp_shift);
+		val |= (temp_to_code(data, temp) << reg->emul_temp_shift) |
+			EXYNOS_EMUL_ENABLE;
 	} else {
 		val &= ~EXYNOS_EMUL_ENABLE;
 	}
drivers/thermal/samsung/exynos_tmu.h +31 -0
index b614407..6f55673 100644
@@ -41,6 +41,34 @@ enum soc_type {
 };
 
 /**
+ * EXYNOS TMU supported features.
+ * TMU_SUPPORT_EMULATION - This features is used to set user defined
+ *			temperature to the TMU controller.
+ * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
+ *			has many instances of TMU.
+ * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can
+ *			be reloaded.
+ * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
+ *			be registered for falling trips also.
+ * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current
+ *			state(active/idle) can be checked.
+ * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
+ *			sample time.
+ * TMU_SUPPORT_SHARED_MEMORY - This feature tells that the different TMU
+ *			sensors shares some common registers.
+ * TMU_SUPPORT - macro to compare the above features with the supplied.
+ */
+#define TMU_SUPPORT_EMULATION			BIT(0)
+#define TMU_SUPPORT_MULTI_INST			BIT(1)
+#define TMU_SUPPORT_TRIM_RELOAD			BIT(2)
+#define TMU_SUPPORT_FALLING_TRIP		BIT(3)
+#define TMU_SUPPORT_READY_STATUS		BIT(4)
+#define TMU_SUPPORT_EMUL_TIME			BIT(5)
+#define TMU_SUPPORT_SHARED_MEMORY		BIT(6)
+
+#define TMU_SUPPORTS(a, b)	(a->features & TMU_SUPPORT_ ## b)
+
+/**
  * struct exynos_tmu_register - register descriptors to access registers and
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
@@ -220,6 +248,8 @@ struct exynos_tmu_registers {
  *	applicable to only some of the trigger levels.
  * @registers: Pointer to structure containing all the TMU controller registers
  *	and bitfields shifts and masks.
+ * @features: a bitfield value indicating the features supported in SOC like
+ *	emulation, multi instance etc
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -247,6 +277,7 @@ struct exynos_tmu_platform_data {
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 	const struct exynos_tmu_registers *registers;
+	unsigned int features;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.c +5 -1
index 06ecfb0..694557e 100644
@@ -83,6 +83,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		.registers = &exynos4210_tmu_registers,
+		.features = TMU_SUPPORT_READY_STATUS,
 		},
 	},
 	.tmu_count = 1,
@@ -162,7 +163,10 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
 	}, \
 	.freq_tab_count = 2, \
 	.type = SOC_ARCH_EXYNOS, \
-	.registers = &exynos5250_tmu_registers,
+	.registers = &exynos5250_tmu_registers, \
+	.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
+			TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
+			TMU_SUPPORT_EMUL_TIME)
 
 struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.tmu_data = {
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#60 lore raw

PATCH v6 20/30 thermal: exynos: use device resource management infrastructure

In reply to Amit Daniel Kachhap

This patch uses the device pointer stored in the configuration structure and converts to dev_* prints and devm API's.

---
 drivers/thermal/samsung/exynos_thermal_common.c |   39 ++++++++++++++--------
 1 files changed, 25 insertions(+), 14 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +25 -14
index 2873ca3..59b47e3 100644
@@ -52,7 +52,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 {
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	if (!th_zone) {
-		pr_notice("thermal zone not registered\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"thermal zone not registered\n");
 		return 0;
 	}
 
@@ -68,8 +69,9 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 
 	th_zone->mode = mode;
 	thermal_zone_device_update(thermal);
-	pr_info("thermal polling set for duration=%d msec\n",
-				thermal->polling_delay);
+	dev_dbg(th_zone->sensor_conf->dev,
+		"thermal polling set for duration=%d msec\n",
+		thermal->polling_delay);
 	return 0;
 }
 
@@ -159,7 +161,8 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 		case WARN_ZONE:
 			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
 								level, 0)) {
-				pr_err("error binding cdev inst %d\n", i);
+				dev_err(data->dev,
+					"error unbinding cdev inst=%d\n", i);
 				ret = -EINVAL;
 			}
 			th_zone->bind = true;
@@ -204,7 +207,8 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 		case WARN_ZONE:
 			if (thermal_zone_unbind_cooling_device(thermal, i,
 								cdev)) {
-				pr_err("error unbinding cdev inst=%d\n", i);
+				dev_err(data->dev,
+					"error unbinding cdev inst=%d\n", i);
 				ret = -EINVAL;
 			}
 			th_zone->bind = false;
@@ -224,7 +228,8 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 	void *data;
 
 	if (!th_zone->sensor_conf) {
-		pr_info("Temperature sensor not initialised\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 	data = th_zone->sensor_conf->driver_data;
@@ -243,7 +248,8 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 
 	if (!th_zone->sensor_conf) {
-		pr_info("Temperature sensor not initialised\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 	data = th_zone->sensor_conf->driver_data;
@@ -337,11 +343,13 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 	struct exynos_thermal_zone *th_zone;
 
 	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
+		dev_err(sensor_conf->dev,
+				"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 
-	th_zone = kzalloc(sizeof(struct exynos_thermal_zone), GFP_KERNEL);
+	th_zone = devm_kzalloc(sensor_conf->dev,
+				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
 	if (!th_zone)
 		return -ENOMEM;
 
@@ -350,7 +358,8 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 		cpumask_set_cpu(0, &mask_val);
 		th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
 		if (IS_ERR(th_zone->cool_dev[0])) {
-			pr_err("Failed to register cpufreq cooling device\n");
+			dev_err(sensor_conf->dev,
+				"Failed to register cpufreq cooling device\n");
 			ret = -EINVAL;
 			goto err_unregister;
 		}
@@ -364,14 +373,16 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 			IDLE_INTERVAL);
 
 	if (IS_ERR(th_zone->therm_dev)) {
-		pr_err("Failed to register thermal zone device\n");
+		dev_err(sensor_conf->dev,
+			"Failed to register thermal zone device\n");
 		ret = PTR_ERR(th_zone->therm_dev);
 		goto err_unregister;
 	}
 	th_zone->mode = THERMAL_DEVICE_ENABLED;
 	sensor_conf->pzone_data = th_zone;
 
-	pr_info("Exynos: Kernel Thermal management registered\n");
+	dev_info(sensor_conf->dev,
+		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
 
 	return 0;
 
@@ -397,6 +408,6 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
-	kfree(th_zone);
-	pr_info("Exynos: Kernel Thermal management unregistered\n");
+	dev_info(sensor_conf->dev,
+		"Exynos: Kernel Thermal management unregistered\n");
 }
Signature · 1 line
1.7.1
Acked-by on v6 20/30
#61 lore raw

Re: [PATCH V6 20/30] thermal: exynos: use device resource management infrastructure

Quoted 6 lines · Amit Daniel Kachhap

This patch uses the device pointer stored in the configuration structure and converts to dev_* prints and devm API's.

Quoted 125 lines
---
 drivers/thermal/samsung/exynos_thermal_common.c |   39 ++++++++++++++--------
 1 files changed, 25 insertions(+), 14 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +25 -14
index 2873ca3..59b47e3 100644
@@ -52,7 +52,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 {
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	if (!th_zone) {
-		pr_notice("thermal zone not registered\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"thermal zone not registered\n");
 		return 0;
 	}
 
@@ -68,8 +69,9 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 
 	th_zone->mode = mode;
 	thermal_zone_device_update(thermal);
-	pr_info("thermal polling set for duration=%d msec\n",
-				thermal->polling_delay);
+	dev_dbg(th_zone->sensor_conf->dev,
+		"thermal polling set for duration=%d msec\n",
+		thermal->polling_delay);
 	return 0;
 }
 
@@ -159,7 +161,8 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 		case WARN_ZONE:
 			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
 								level, 0)) {
-				pr_err("error binding cdev inst %d\n", i);
+				dev_err(data->dev,
+					"error unbinding cdev inst=%d\n", i);
 				ret = -EINVAL;
 			}
 			th_zone->bind = true;
@@ -204,7 +207,8 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 		case WARN_ZONE:
 			if (thermal_zone_unbind_cooling_device(thermal, i,
 								cdev)) {
-				pr_err("error unbinding cdev inst=%d\n", i);
+				dev_err(data->dev,
+					"error unbinding cdev inst=%d\n", i);
 				ret = -EINVAL;
 			}
 			th_zone->bind = false;
@@ -224,7 +228,8 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 	void *data;
 
 	if (!th_zone->sensor_conf) {
-		pr_info("Temperature sensor not initialised\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 	data = th_zone->sensor_conf->driver_data;
@@ -243,7 +248,8 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 
 	if (!th_zone->sensor_conf) {
-		pr_info("Temperature sensor not initialised\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 	data = th_zone->sensor_conf->driver_data;
@@ -337,11 +343,13 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 	struct exynos_thermal_zone *th_zone;
 
 	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
+		dev_err(sensor_conf->dev,
+				"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 
-	th_zone = kzalloc(sizeof(struct exynos_thermal_zone), GFP_KERNEL);
+	th_zone = devm_kzalloc(sensor_conf->dev,
+				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
 	if (!th_zone)
 		return -ENOMEM;
 
@@ -350,7 +358,8 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 		cpumask_set_cpu(0, &mask_val);
 		th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
 		if (IS_ERR(th_zone->cool_dev[0])) {
-			pr_err("Failed to register cpufreq cooling device\n");
+			dev_err(sensor_conf->dev,
+				"Failed to register cpufreq cooling device\n");
 			ret = -EINVAL;
 			goto err_unregister;
 		}
@@ -364,14 +373,16 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 			IDLE_INTERVAL);
 
 	if (IS_ERR(th_zone->therm_dev)) {
-		pr_err("Failed to register thermal zone device\n");
+		dev_err(sensor_conf->dev,
+			"Failed to register thermal zone device\n");
 		ret = PTR_ERR(th_zone->therm_dev);
 		goto err_unregister;
 	}
 	th_zone->mode = THERMAL_DEVICE_ENABLED;
 	sensor_conf->pzone_data = th_zone;
 
-	pr_info("Exynos: Kernel Thermal management registered\n");
+	dev_info(sensor_conf->dev,
+		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
 
 	return 0;
 
@@ -397,6 +408,6 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
-	kfree(th_zone);
-	pr_info("Exynos: Kernel Thermal management unregistered\n");
+	dev_info(sensor_conf->dev,
+		"Exynos: Kernel Thermal management unregistered\n");
 }
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#62 lore raw

PATCH v6 21/30 ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal bindings

In reply to Amit Daniel Kachhap

From: Lukasz Majewski <[email protected]>

Proper description for Exynos4 bindings added to Documentation/devicetree/ bindings

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   25 ++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +25 -0
new file mode 100644
index 0000000..535fd0e
@@ -0,0 +1,25 @@
+* Exynos Thermal Management Unit (TMU)
+
+** Required properties:
+
+- compatible : One of the following:
+	       "samsung,exynos4412-tmu"
+	       "samsung,exynos4210-tmu"
+	       "samsung,exynos5250-tmu"
+- interrupt-parent : The phandle for the interrupt controller
+- reg : Address range of the thermal registers
+- interrupts : Should contain interrupt for thermal system
+- clocks : The main clock for TMU device
+- clock-names : Thermal system clock name
+
+Example:
+
+	tmu@100C0000 {
+		compatible = "samsung,exynos4412-tmu";
+		interrupt-parent = <&combiner>;
+		reg = <0x100C0000 0x100>;
+		interrupts = <2 4>;
+		clocks = <&clock 383>;
+		clock-names = "tmu_apbif";
+		status = "disabled";
+	};
Signature · 1 line
1.7.1
#63 lore raw

Re: [PATCH V6 21/30] ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal bindings

Quoted 23 lines · Amit Daniel Kachhap

From: Lukasz Majewski <[email protected]>

Proper description for Exynos4 bindings added to Documentation/devicetree/ bindings

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   25 ++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +3 -0
new file mode 100644
index 0000000..535fd0e
@@ -0,0 +1,25 @@
+* Exynos Thermal Management Unit (TMU)
+
+** Required properties:

Documentation/devicetree/bindings/thermal/exynos-thermal.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +10 -0
+
+- compatible : One of the following:
+	       "samsung,exynos4412-tmu"
+	       "samsung,exynos4210-tmu"
+	       "samsung,exynos5250-tmu"
+- interrupt-parent : The phandle for the interrupt controller
+- reg : Address range of the thermal registers
+- interrupts : Should contain interrupt for thermal system
+- clocks : The main clock for TMU device
+- clock-names : Thermal system clock name

Should this include the documentation on the alias needed by patch 18? tmuctrl?

Quoted 13 lines
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +12 -0
+
+Example:
+
+	tmu@100C0000 {
+		compatible = "samsung,exynos4412-tmu";
+		interrupt-parent = <&combiner>;
+		reg = <0x100C0000 0x100>;
+		interrupts = <2 4>;
+		clocks = <&clock 383>;
+		clock-names = "tmu_apbif";
+		status = "disabled";
+	};
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#64 lore raw

Re: [PATCH V6 21/30] ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal bindings

Quoted 59 lines · Eduardo Valentin
Quoted 23 lines · Amit Daniel Kachhap

From: Lukasz Majewski <[email protected]>

Proper description for Exynos4 bindings added to Documentation/devicetree/ bindings

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   25 ++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +3 -0
new file mode 100644
index 0000000..535fd0e
@@ -0,0 +1,25 @@
+* Exynos Thermal Management Unit (TMU)
+
+** Required properties:

Documentation/devicetree/bindings/thermal/exynos-thermal.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +10 -0
+
+- compatible : One of the following:
+            "samsung,exynos4412-tmu"
+            "samsung,exynos4210-tmu"
+            "samsung,exynos5250-tmu"
+- interrupt-parent : The phandle for the interrupt controller
+- reg : Address range of the thermal registers
+- interrupts : Should contain interrupt for thermal system
+- clocks : The main clock for TMU device
+- clock-names : Thermal system clock name

Should this include the documentation on the alias needed by patch 18?
tmuctrl?
Yes right it should be there. Actually It is there in the later patches. Will re-submit this patch in proper order.

Documentation/devicetree/bindings/thermal/exynos-thermal.txt line 25

Quoted 13 lines
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +12 -0
+
+Example:
+
+     tmu@100C0000 {
+             compatible = "samsung,exynos4412-tmu";
+             interrupt-parent = <&combiner>;
+             reg = <0x100C0000 0x100>;
+             interrupts = <2 4>;
+             clocks = <&clock 383>;
+             clock-names = "tmu_apbif";
+             status = "disabled";
+     };

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#65 lore raw

PATCH v6 22/30 thermal: exynos: Add support to access common register for multistance

In reply to Amit Daniel Kachhap

This patch adds support to parse one more common set of TMU register. First set of register belongs to each instance of TMU and second set belongs to common TMU registers.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |    6 +++++-
 drivers/thermal/samsung/exynos_tmu.c               |   20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +5 -1
index 535fd0e..0ea33f7 100644
@@ -7,7 +7,11 @@
 	       "samsung,exynos4210-tmu"
 	       "samsung,exynos5250-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For soc's which has multiple
+	instances of TMU and some registers are shared across all TMU's like
+	interrupt related then 2 set of register has to supplied. First set
+	belongs	to each instance of TMU and second set belongs to common TMU
+	registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
drivers/thermal/samsung/exynos_tmu.c +20 -0
index 877dab8..150a869 100644
@@ -40,6 +40,7 @@
  * @id: identifier of the one instance of the TMU controller.
  * @pdata: pointer to the tmu platform/configuration data
  * @base: base address of the single instance of the TMU controller.
+ * @base_common: base address of the common registers of the TMU controller.
  * @irq: irq number of the TMU controller.
  * @soc: id of the SOC type.
  * @irq_work: pointer to the irq work structure.
@@ -53,6 +54,7 @@ struct exynos_tmu_data {
 	int id;
 	struct exynos_tmu_platform_data *pdata;
 	void __iomem *base;
+	void __iomem *base_common;
 	int irq;
 	enum soc_type soc;
 	struct work_struct irq_work;
@@ -478,6 +480,24 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -ENODEV;
 	}
 	data->pdata = pdata;
+	/*
+	 * Check if the TMU shares some registers and then try to map the
+	 * memory of common registers.
+	 */
+	if (!TMU_SUPPORTS(pdata, SHARED_MEMORY))
+		return 0;
+
+	if (of_address_to_resource(pdev->dev.of_node, 1, &res)) {
+		dev_err(&pdev->dev, "failed to get Resource 1\n");
+		return -ENODEV;
+	}
+
+	data->base_common = devm_ioremap(&pdev->dev, res.start,
+					resource_size(&res));
+	if (!data->base) {
+		dev_err(&pdev->dev, "Failed to ioremap memory\n");
+		return -ENOMEM;
+	}
 
 	return 0;
 }
Signature · 1 line
1.7.1
Acked-by on v6 22/30
#66 lore raw

Re: [PATCH V6 22/30] thermal: exynos: Add support to access common register for multistance

Quoted 7 lines · Amit Daniel Kachhap

This patch adds support to parse one more common set of TMU register. First set of register belongs to each instance of TMU and second set belongs to common TMU registers.

This patch is fine:

But please read my concern on next patch.

Quoted 68 lines
---
 .../devicetree/bindings/thermal/exynos-thermal.txt |    6 +++++-
 drivers/thermal/samsung/exynos_tmu.c               |   20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +5 -1
index 535fd0e..0ea33f7 100644
@@ -7,7 +7,11 @@
 	       "samsung,exynos4210-tmu"
 	       "samsung,exynos5250-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For soc's which has multiple
+	instances of TMU and some registers are shared across all TMU's like
+	interrupt related then 2 set of register has to supplied. First set
+	belongs	to each instance of TMU and second set belongs to common TMU
+	registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
drivers/thermal/samsung/exynos_tmu.c +20 -0
index 877dab8..150a869 100644
@@ -40,6 +40,7 @@
  * @id: identifier of the one instance of the TMU controller.
  * @pdata: pointer to the tmu platform/configuration data
  * @base: base address of the single instance of the TMU controller.
+ * @base_common: base address of the common registers of the TMU controller.
  * @irq: irq number of the TMU controller.
  * @soc: id of the SOC type.
  * @irq_work: pointer to the irq work structure.
@@ -53,6 +54,7 @@ struct exynos_tmu_data {
 	int id;
 	struct exynos_tmu_platform_data *pdata;
 	void __iomem *base;
+	void __iomem *base_common;
 	int irq;
 	enum soc_type soc;
 	struct work_struct irq_work;
@@ -478,6 +480,24 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -ENODEV;
 	}
 	data->pdata = pdata;
+	/*
+	 * Check if the TMU shares some registers and then try to map the
+	 * memory of common registers.
+	 */
+	if (!TMU_SUPPORTS(pdata, SHARED_MEMORY))
+		return 0;
+
+	if (of_address_to_resource(pdev->dev.of_node, 1, &res)) {
+		dev_err(&pdev->dev, "failed to get Resource 1\n");
+		return -ENODEV;
+	}
+
+	data->base_common = devm_ioremap(&pdev->dev, res.start,
+					resource_size(&res));
+	if (!data->base) {
+		dev_err(&pdev->dev, "Failed to ioremap memory\n");
+		return -ENOMEM;
+	}
 
 	return 0;
 }
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#67 lore raw

PATCH v6 23/30 thermal: exynos: Add driver support for exynos5440 TMU sensor

In reply to Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   24 ++++++++-
 drivers/thermal/samsung/exynos_thermal_common.h    |    2 +-
 drivers/thermal/samsung/exynos_tmu.c               |   54 +++++++++++++++++---
 drivers/thermal/samsung/exynos_tmu.h               |    6 ++
 drivers/thermal/samsung/exynos_tmu_data.h          |   36 +++++++++++++
 5 files changed, 112 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +23 -1
index 0ea33f7..e6386ea 100644
@@ -6,6 +6,7 @@
 	       "samsung,exynos4412-tmu"
 	       "samsung,exynos4210-tmu"
 	       "samsung,exynos5250-tmu"
+	       "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
 - reg : Address range of the thermal registers. For soc's which has multiple
 	instances of TMU and some registers are shared across all TMU's like
@@ -16,7 +17,7 @@
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
 	tmu@100C0000 {
 		compatible = "samsung,exynos4412-tmu";
@@ -27,3 +28,24 @@ Example:
 		clock-names = "tmu_apbif";
 		status = "disabled";
 	};
+
+Example 2):
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+	tmuctrl0 = &tmuctrl_0;
+	tmuctrl1 = &tmuctrl_1;
+	tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_thermal_common.h +1 -1
index 0c189d6..7d7c29a 100644
@@ -27,7 +27,7 @@
 #define SENSOR_NAME_LEN	16
 #define MAX_TRIP_COUNT	8
 #define MAX_COOLING_DEVICE 4
-#define MAX_THRESHOLD_LEVS 4
+#define MAX_THRESHOLD_LEVS 5
 
 #define ACTIVE_INTERVAL 500
 #define IDLE_INTERVAL 10000
drivers/thermal/samsung/exynos_tmu.c +46 -8

95 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu.h +6 -0
index 6f55673..73aaed7 100644
@@ -38,6 +38,7 @@ enum calibration_mode {
 enum soc_type {
 	SOC_ARCH_EXYNOS4210 = 1,
 	SOC_ARCH_EXYNOS,
+	SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -129,6 +130,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
 	u32	triminfo_data;
@@ -196,6 +199,9 @@ struct exynos_tmu_registers {
 	u32	emul_temp_shift;
 	u32	emul_time_shift;
 	u32	emul_time_mask;
+
+	u32	tmu_irqstatus;
+	u32	tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +36 -0
index 139dbbb..ad263e9 100644
@@ -93,6 +93,42 @@
 
 #define EXYNOS_MAX_TRIGGER_PER_REG	4
 
+/*exynos5440 specific registers*/
+#define EXYNOS5440_TMU_S0_7_TRIM		0x000
+#define EXYNOS5440_TMU_S0_7_CTRL		0x020
+#define EXYNOS5440_TMU_S0_7_DEBUG		0x040
+#define EXYNOS5440_TMU_S0_7_STATUS		0x060
+#define EXYNOS5440_TMU_S0_7_TEMP		0x0f0
+#define EXYNOS5440_TMU_S0_7_TH0			0x110
+#define EXYNOS5440_TMU_S0_7_TH1			0x130
+#define EXYNOS5440_TMU_S0_7_TH2			0x150
+#define EXYNOS5440_TMU_S0_7_EVTEN		0x1F0
+#define EXYNOS5440_TMU_S0_7_IRQEN		0x210
+#define EXYNOS5440_TMU_S0_7_IRQ			0x230
+/* exynos5440 common registers */
+#define EXYNOS5440_TMU_IRQ_STATUS		0x000
+#define EXYNOS5440_TMU_PMIN			0x004
+#define EXYNOS5440_TMU_TEMP			0x008
+
+#define EXYNOS5440_TMU_RISE_INT_MASK		0xf
+#define EXYNOS5440_TMU_RISE_INT_SHIFT		0
+#define EXYNOS5440_TMU_FALL_INT_MASK		0xf
+#define EXYNOS5440_TMU_FALL_INT_SHIFT		4
+#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT	0
+#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT	1
+#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT	2
+#define EXYNOS5440_TMU_INTEN_RISE3_SHIFT	3
+#define EXYNOS5440_TMU_INTEN_FALL0_SHIFT	4
+#define EXYNOS5440_TMU_INTEN_FALL1_SHIFT	5
+#define EXYNOS5440_TMU_INTEN_FALL2_SHIFT	6
+#define EXYNOS5440_TMU_INTEN_FALL3_SHIFT	7
+#define EXYNOS5440_TMU_TH_RISE0_SHIFT		0
+#define EXYNOS5440_TMU_TH_RISE1_SHIFT		8
+#define EXYNOS5440_TMU_TH_RISE2_SHIFT		16
+#define EXYNOS5440_TMU_TH_RISE3_SHIFT		24
+#define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
+#define EXYNOS5440_EFUSE_SWAP_OFFSET		8
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
Signature · 1 line
1.7.1
#68 lore raw

Re: [PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor

Quoted 82 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   24 ++++++++-
 drivers/thermal/samsung/exynos_thermal_common.h    |    2 +-
 drivers/thermal/samsung/exynos_tmu.c               |   54 +++++++++++++++++---
 drivers/thermal/samsung/exynos_tmu.h               |    6 ++
 drivers/thermal/samsung/exynos_tmu_data.h          |   36 +++++++++++++
 5 files changed, 112 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +23 -1
index 0ea33f7..e6386ea 100644
@@ -6,6 +6,7 @@
 	       "samsung,exynos4412-tmu"
 	       "samsung,exynos4210-tmu"
 	       "samsung,exynos5250-tmu"
+	       "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
 - reg : Address range of the thermal registers. For soc's which has multiple
 	instances of TMU and some registers are shared across all TMU's like
@@ -16,7 +17,7 @@
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
 	tmu@100C0000 {
 		compatible = "samsung,exynos4412-tmu";
@@ -27,3 +28,24 @@ Example:
 		clock-names = "tmu_apbif";
 		status = "disabled";
 	};
+
+Example 2):
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+	tmuctrl0 = &tmuctrl_0;
+	tmuctrl1 = &tmuctrl_1;
+	tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_thermal_common.h +1 -1
index 0c189d6..7d7c29a 100644
@@ -27,7 +27,7 @@
 #define SENSOR_NAME_LEN	16
 #define MAX_TRIP_COUNT	8
 #define MAX_COOLING_DEVICE 4
-#define MAX_THRESHOLD_LEVS 4
+#define MAX_THRESHOLD_LEVS 5
 
 #define ACTIVE_INTERVAL 500
 #define IDLE_INTERVAL 10000
drivers/thermal/samsung/exynos_tmu.c +0 -0
index 150a869..db4035d 100644

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 159

Quoted 5 lines
drivers/thermal/samsung/exynos_tmu.c +1 -1
@@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
 	/* Save trimming info in order to perform calibration */
-	trim_info = readl(data->base + reg->triminfo_data);
+	if (data->soc == SOC_ARCH_EXYNOS5440) {

should this become some bit at your pdata->features? TMU_SUPPORTS(pdata, TRIMINFO) for instance?

Quoted 34 lines
drivers/thermal/samsung/exynos_tmu.c +21 -1
+		/*
+		 * For exynos5440 soc triminfo value is swapped between TMU0 and
+		 * TMU2, so the below logic is needed.
+		 */
+		switch (data->id) {
+		case 0:
+			trim_info = readl(data->base +
+			EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data);
+			break;
+		case 1:
+			trim_info = readl(data->base + reg->triminfo_data);
+			break;
+		case 2:
+			trim_info = readl(data->base -
+			EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data);
+		}
+	} else {
+		trim_info = readl(data->base + reg->triminfo_data);
+	}
 	data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
 	data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
 				EXYNOS_TMU_TEMP_MASK);
@@ -201,7 +220,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
 		writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-	} else if (data->soc == SOC_ARCH_EXYNOS) {
+	} else if (data->soc == SOC_ARCH_EXYNOS ||
+			data->soc == SOC_ARCH_EXYNOS5440) {
 		/* Write temperature code for rising and falling threshold */
 		for (i = 0;
 		i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
@@ -241,14 +261,24 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 				ret = threshold_code;

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 268

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +5 -3
 				goto out;
 			}
-			rising_threshold |= threshold_code << 8 * i;
-			writel(rising_threshold,
-				data->base + reg->threshold_th0);
+			if (data->soc == SOC_ARCH_EXYNOS) {
+				rising_threshold |= threshold_code << 8 * i;
+				writel(rising_threshold,
+					data->base + reg->threshold_th0);
+			} else if (data->soc == SOC_ARCH_EXYNOS5440) {

Can these ifs be translated to some TMU_SUPPORTS()?

Just wondering if it is possible to get rid of data->soc flags and use only features or represent the shifts as fields inside your pdata.

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 281

Quoted 13 lines
drivers/thermal/samsung/exynos_tmu.c +8 -0
+				rising_threshold =
+				threshold_code << reg->threshold_th3_l0_shift;
+				writel(rising_threshold,
+					data->base + reg->threshold_th2);
+			}
 			con = readl(data->base + reg->tmu_ctrl);
 			con |= (1 << reg->therm_trip_en_shift);
 			writel(con, data->base + reg->tmu_ctrl);
 		}
 	}
+	/*Clear the PMIN in the common TMU register*/
+	if (reg->tmu_pmin && !data->id)
+		writel(0, data->base_common + reg->tmu_pmin);

What happens to other TMU instances when one of them performs this operation? does it need to serialized?

Quoted 117 lines
drivers/thermal/samsung/exynos_tmu.c +11 -3
 out:
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
@@ -377,7 +407,14 @@ static void exynos_tmu_work(struct work_struct *work)
 			struct exynos_tmu_data, irq_work);
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	const struct exynos_tmu_registers *reg = pdata->registers;
-	unsigned int val_irq;
+	unsigned int val_irq, val_type;
+
+	/* Find which sensor generated this interrupt */
+	if (reg->tmu_irqstatus) {
+		val_type = readl(data->base_common + reg->tmu_irqstatus);
+		if (!((val_type >> data->id) & 0x1))
+			goto out;
+	}
 
 	exynos_report_trigger(data->reg_conf);
 	mutex_lock(&data->lock);
@@ -390,7 +427,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
-
+out:
 	enable_irq(data->irq);
 }
 
@@ -544,7 +581,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		return ret;
 
 	if (pdata->type == SOC_ARCH_EXYNOS ||
-				pdata->type == SOC_ARCH_EXYNOS4210)
+		pdata->type == SOC_ARCH_EXYNOS4210 ||
+				pdata->type == SOC_ARCH_EXYNOS5440)
 		data->soc = pdata->type;
 	else {
 		ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 6f55673..73aaed7 100644
@@ -38,6 +38,7 @@ enum calibration_mode {
 enum soc_type {
 	SOC_ARCH_EXYNOS4210 = 1,
 	SOC_ARCH_EXYNOS,
+	SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -129,6 +130,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
 	u32	triminfo_data;
@@ -196,6 +199,9 @@ struct exynos_tmu_registers {
 	u32	emul_temp_shift;
 	u32	emul_time_shift;
 	u32	emul_time_mask;
+
+	u32	tmu_irqstatus;
+	u32	tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +36 -0
index 139dbbb..ad263e9 100644
@@ -93,6 +93,42 @@
 
 #define EXYNOS_MAX_TRIGGER_PER_REG	4
 
+/*exynos5440 specific registers*/
+#define EXYNOS5440_TMU_S0_7_TRIM		0x000
+#define EXYNOS5440_TMU_S0_7_CTRL		0x020
+#define EXYNOS5440_TMU_S0_7_DEBUG		0x040
+#define EXYNOS5440_TMU_S0_7_STATUS		0x060
+#define EXYNOS5440_TMU_S0_7_TEMP		0x0f0
+#define EXYNOS5440_TMU_S0_7_TH0			0x110
+#define EXYNOS5440_TMU_S0_7_TH1			0x130
+#define EXYNOS5440_TMU_S0_7_TH2			0x150
+#define EXYNOS5440_TMU_S0_7_EVTEN		0x1F0
+#define EXYNOS5440_TMU_S0_7_IRQEN		0x210
+#define EXYNOS5440_TMU_S0_7_IRQ			0x230
+/* exynos5440 common registers */
+#define EXYNOS5440_TMU_IRQ_STATUS		0x000
+#define EXYNOS5440_TMU_PMIN			0x004
+#define EXYNOS5440_TMU_TEMP			0x008
+
+#define EXYNOS5440_TMU_RISE_INT_MASK		0xf
+#define EXYNOS5440_TMU_RISE_INT_SHIFT		0
+#define EXYNOS5440_TMU_FALL_INT_MASK		0xf
+#define EXYNOS5440_TMU_FALL_INT_SHIFT		4
+#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT	0
+#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT	1
+#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT	2
+#define EXYNOS5440_TMU_INTEN_RISE3_SHIFT	3
+#define EXYNOS5440_TMU_INTEN_FALL0_SHIFT	4
+#define EXYNOS5440_TMU_INTEN_FALL1_SHIFT	5
+#define EXYNOS5440_TMU_INTEN_FALL2_SHIFT	6
+#define EXYNOS5440_TMU_INTEN_FALL3_SHIFT	7
+#define EXYNOS5440_TMU_TH_RISE0_SHIFT		0
+#define EXYNOS5440_TMU_TH_RISE1_SHIFT		8
+#define EXYNOS5440_TMU_TH_RISE2_SHIFT		16
+#define EXYNOS5440_TMU_TH_RISE3_SHIFT		24
+#define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
+#define EXYNOS5440_EFUSE_SWAP_OFFSET		8
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#69 lore raw

Re: [PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor

Hi Eduardo,

Quoted 85 lines · Eduardo Valentin
Quoted 84 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   24 ++++++++-
 drivers/thermal/samsung/exynos_thermal_common.h    |    2 +-
 drivers/thermal/samsung/exynos_tmu.c               |   54 +++++++++++++++++---
 drivers/thermal/samsung/exynos_tmu.h               |    6 ++
 drivers/thermal/samsung/exynos_tmu_data.h          |   36 +++++++++++++
 5 files changed, 112 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +23 -1
index 0ea33f7..e6386ea 100644
@@ -6,6 +6,7 @@
             "samsung,exynos4412-tmu"
             "samsung,exynos4210-tmu"
             "samsung,exynos5250-tmu"
+            "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
 - reg : Address range of the thermal registers. For soc's which has multiple
      instances of TMU and some registers are shared across all TMU's like
@@ -16,7 +17,7 @@
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
      tmu@100C0000 {
              compatible = "samsung,exynos4412-tmu";
@@ -27,3 +28,24 @@ Example:
              clock-names = "tmu_apbif";
              status = "disabled";
      };
+
+Example 2):
+
+     tmuctrl_0: tmuctrl@160118 {
+             compatible = "samsung,exynos5440-tmu";
+             reg = <0x160118 0x230>, <0x160368 0x10>;
+             interrupts = <0 58 0>;
+             clocks = <&clock 21>;
+             clock-names = "tmu_apbif";
+     };
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+     tmuctrl0 = &tmuctrl_0;
+     tmuctrl1 = &tmuctrl_1;
+     tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_thermal_common.h +1 -1
index 0c189d6..7d7c29a 100644
@@ -27,7 +27,7 @@
 #define SENSOR_NAME_LEN      16
 #define MAX_TRIP_COUNT       8
 #define MAX_COOLING_DEVICE 4
-#define MAX_THRESHOLD_LEVS 4
+#define MAX_THRESHOLD_LEVS 5
 
 #define ACTIVE_INTERVAL 500
 #define IDLE_INTERVAL 10000
drivers/thermal/samsung/exynos_tmu.c +0 -0
index 150a869..db4035d 100644
@@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
              __raw_writel(1, data->base + reg->triminfo_ctrl);
 
Quoted 6 lines

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 159

Quoted 3 lines
drivers/thermal/samsung/exynos_tmu.c +1 -1
      /* Save trimming info in order to perform calibration */
-     trim_info = readl(data->base + reg->triminfo_data);
+     if (data->soc == SOC_ARCH_EXYNOS5440) {

should this become some bit at your pdata->features? TMU_SUPPORTS(pdata, TRIMINFO) for instance?

Initially I also thought of getting rid of SOC checks completely but they have been retained in some rare cases.
Here this a limitation in the h/w and very specific to exynos5440. So not sure if this can be added as a feature.

Quoted 48 lines
Quoted 35 lines
drivers/thermal/samsung/exynos_tmu.c +21 -1
+             /*
+              * For exynos5440 soc triminfo value is swapped between TMU0 and
+              * TMU2, so the below logic is needed.
+              */
+             switch (data->id) {
+             case 0:
+                     trim_info = readl(data->base +
+                     EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data);
+                     break;
+             case 1:
+                     trim_info = readl(data->base + reg->triminfo_data);
+                     break;
+             case 2:
+                     trim_info = readl(data->base -
+                     EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data);
+             }
+     } else {
+             trim_info = readl(data->base + reg->triminfo_data);
+     }
      data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
      data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
                              EXYNOS_TMU_TEMP_MASK);
@@ -201,7 +220,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                      reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
              writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-     } else if (data->soc == SOC_ARCH_EXYNOS) {
+     } else if (data->soc == SOC_ARCH_EXYNOS ||
+                     data->soc == SOC_ARCH_EXYNOS5440) {
              /* Write temperature code for rising and falling threshold */
              for (i = 0;
              i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
@@ -241,14 +261,24 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                              ret = threshold_code;

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 268

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +5 -3
                              goto out;
                      }
-                     rising_threshold |= threshold_code << 8 * i;
-                     writel(rising_threshold,
-                             data->base + reg->threshold_th0);
+                     if (data->soc == SOC_ARCH_EXYNOS) {
+                             rising_threshold |= threshold_code << 8 * i;
+                             writel(rising_threshold,
+                                     data->base + reg->threshold_th0);
+                     } else if (data->soc == SOC_ARCH_EXYNOS5440) {

Can these ifs be translated to some TMU_SUPPORTS()?

Quoted 2 lines

Just wondering if it is possible to get rid of data->soc flags and use only features or represent the shifts as fields inside your pdata.

Here soc check can be removed. Will repost with this change.

Quoted 15 lines
Quoted 4 lines
drivers/thermal/samsung/exynos_tmu.c +3 -0
+                             rising_threshold =
+                             threshold_code << reg->threshold_th3_l0_shift;
+                             writel(rising_threshold,

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 281

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +5 -0
+                                     data->base + reg->threshold_th2);
+                     }
                      con = readl(data->base + reg->tmu_ctrl);
                      con |= (1 << reg->therm_trip_en_shift);
                      writel(con, data->base + reg->tmu_ctrl);
              }
      }
+     /*Clear the PMIN in the common TMU register*/
+     if (reg->tmu_pmin && !data->id)
+             writel(0, data->base_common + reg->tmu_pmin);
Quoted 2 lines

What happens to other TMU instances when one of them performs this operation? does it need to serialized?

This is one time setting for all the instances and currently I have done it for first TMU with aliad ID as 0. This register belongs to the common set.

Quoted 125 lines
Quoted 108 lines
drivers/thermal/samsung/exynos_tmu.c +11 -3
 out:
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
@@ -377,7 +407,14 @@ static void exynos_tmu_work(struct work_struct *work)
                      struct exynos_tmu_data, irq_work);
      struct exynos_tmu_platform_data *pdata = data->pdata;
      const struct exynos_tmu_registers *reg = pdata->registers;
-     unsigned int val_irq;
+     unsigned int val_irq, val_type;
+
+     /* Find which sensor generated this interrupt */
+     if (reg->tmu_irqstatus) {
+             val_type = readl(data->base_common + reg->tmu_irqstatus);
+             if (!((val_type >> data->id) & 0x1))
+                     goto out;
+     }
 
      exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
@@ -390,7 +427,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
-
+out:
      enable_irq(data->irq);
 }
 
@@ -544,7 +581,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return ret;
 
      if (pdata->type == SOC_ARCH_EXYNOS ||
-                             pdata->type == SOC_ARCH_EXYNOS4210)
+             pdata->type == SOC_ARCH_EXYNOS4210 ||
+                             pdata->type == SOC_ARCH_EXYNOS5440)
              data->soc = pdata->type;
      else {
              ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 6f55673..73aaed7 100644
@@ -38,6 +38,7 @@ enum calibration_mode {
 enum soc_type {
      SOC_ARCH_EXYNOS4210 = 1,
      SOC_ARCH_EXYNOS,
+     SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -129,6 +130,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
      u32     triminfo_data;
@@ -196,6 +199,9 @@ struct exynos_tmu_registers {
      u32     emul_temp_shift;
      u32     emul_time_shift;
      u32     emul_time_mask;
+
+     u32     tmu_irqstatus;
+     u32     tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +29 -0
index 139dbbb..ad263e9 100644
@@ -93,6 +93,42 @@
 
 #define EXYNOS_MAX_TRIGGER_PER_REG   4
 
+/*exynos5440 specific registers*/
+#define EXYNOS5440_TMU_S0_7_TRIM             0x000
+#define EXYNOS5440_TMU_S0_7_CTRL             0x020
+#define EXYNOS5440_TMU_S0_7_DEBUG            0x040
+#define EXYNOS5440_TMU_S0_7_STATUS           0x060
+#define EXYNOS5440_TMU_S0_7_TEMP             0x0f0
+#define EXYNOS5440_TMU_S0_7_TH0                      0x110
+#define EXYNOS5440_TMU_S0_7_TH1                      0x130
+#define EXYNOS5440_TMU_S0_7_TH2                      0x150
+#define EXYNOS5440_TMU_S0_7_EVTEN            0x1F0
+#define EXYNOS5440_TMU_S0_7_IRQEN            0x210
+#define EXYNOS5440_TMU_S0_7_IRQ                      0x230
+/* exynos5440 common registers */
+#define EXYNOS5440_TMU_IRQ_STATUS            0x000
+#define EXYNOS5440_TMU_PMIN                  0x004
+#define EXYNOS5440_TMU_TEMP                  0x008
+
+#define EXYNOS5440_TMU_RISE_INT_MASK         0xf
+#define EXYNOS5440_TMU_RISE_INT_SHIFT                0
+#define EXYNOS5440_TMU_FALL_INT_MASK         0xf
+#define EXYNOS5440_TMU_FALL_INT_SHIFT                4
+#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT     0
+#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT     1
+#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT     2
+#define EXYNOS5440_TMU_INTEN_RISE3_SHIFT     3
+#define EXYNOS5440_TMU_INTEN_FALL0_SHIFT     4
+#define EXYNOS5440_TMU_INTEN_FALL1_SHIFT     5
+#define EXYNOS5440_TMU_INTEN_FALL2_SHIFT     6
+#define EXYNOS5440_TMU_INTEN_FALL3_SHIFT     7

drivers/thermal/samsung/exynos_tmu_data.h line 134

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.h +7 -0
+#define EXYNOS5440_TMU_TH_RISE0_SHIFT                0
+#define EXYNOS5440_TMU_TH_RISE1_SHIFT                8
+#define EXYNOS5440_TMU_TH_RISE2_SHIFT                16
+#define EXYNOS5440_TMU_TH_RISE3_SHIFT                24
+#define EXYNOS5440_TMU_TH_RISE4_SHIFT                24
+#define EXYNOS5440_EFUSE_SWAP_OFFSET         8
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#70 lore raw

PATCH v6 24/30 thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor

In reply to Amit Daniel Kachhap

This patch adds configuration data for exynos5440 soc. Also register definations for the controller are added.

---
 drivers/thermal/samsung/exynos_tmu.c      |    4 ++
 drivers/thermal/samsung/exynos_tmu_data.c |   71 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |    7 +++
 3 files changed, 82 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +4 -0
index db4035d..a4dbc84 100644
@@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = {
 		.compatible = "samsung,exynos5250-tmu",
 		.data = (void *)EXYNOS5250_TMU_DRV_DATA,
 	},
+	{
+		.compatible = "samsung,exynos5440-tmu",
+		.data = (void *)EXYNOS5440_TMU_DRV_DATA,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
drivers/thermal/samsung/exynos_tmu_data.c +71 -0

74 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.h +7 -0
index ad263e9..43ce5fb 100644
@@ -143,4 +143,11 @@ extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
 #define EXYNOS5250_TMU_DRV_DATA (NULL)
 #endif
 
+#if defined(CONFIG_SOC_EXYNOS5440)
+extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
+#define EXYNOS5440_TMU_DRV_DATA (&exynos5440_default_tmu_data)
+#else
+#define EXYNOS5440_TMU_DRV_DATA (NULL)
+#endif
+
 #endif /*_EXYNOS_TMU_DATA_H*/
Signature · 1 line
1.7.1
#71 lore raw

Re: [PATCH V6 24/30] thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor

Quoted 70 lines · Amit Daniel Kachhap

This patch adds configuration data for exynos5440 soc. Also register definations for the controller are added.

---
 drivers/thermal/samsung/exynos_tmu.c      |    4 ++
 drivers/thermal/samsung/exynos_tmu_data.c |   71 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |    7 +++
 3 files changed, 82 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +4 -0
index db4035d..a4dbc84 100644
@@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = {
 		.compatible = "samsung,exynos5250-tmu",
 		.data = (void *)EXYNOS5250_TMU_DRV_DATA,
 	},
+	{
+		.compatible = "samsung,exynos5440-tmu",
+		.data = (void *)EXYNOS5440_TMU_DRV_DATA,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
drivers/thermal/samsung/exynos_tmu_data.c +35 -0
index 694557e..b34e726 100644
@@ -175,3 +175,74 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.tmu_count = 1,
 };
 #endif
+
+#if defined(CONFIG_SOC_EXYNOS5440)
+static const struct exynos_tmu_registers exynos5440_tmu_registers = {
+	.triminfo_data = EXYNOS5440_TMU_S0_7_TRIM,
+	.triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
+	.triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
+	.tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL,
+	.buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
+	.buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
+	.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
+	.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
+	.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
+	.buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
+	.buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
+	.core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
+	.tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
+	.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
+	.threshold_th0 = EXYNOS5440_TMU_S0_7_TH0,
+	.threshold_th1 = EXYNOS5440_TMU_S0_7_TH1,
+	.threshold_th2 = EXYNOS5440_TMU_S0_7_TH2,
+	.threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT,
+	.tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN,
+	.inten_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
+	.inten_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT,
+	.inten_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
+	.inten_fall_shift = EXYNOS5440_TMU_FALL_INT_SHIFT,
+	.inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT,
+	.inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT,
+	.inten_rise2_shift = EXYNOS5440_TMU_INTEN_RISE2_SHIFT,
+	.inten_rise3_shift = EXYNOS5440_TMU_INTEN_RISE3_SHIFT,
+	.inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT,
+	.tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ,
+	.tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ,
+	.tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
+	.emul_con = EXYNOS5440_TMU_S0_7_DEBUG,

drivers/thermal/samsung/exynos_tmu_data.c struct exynos_tmu_init_data const exynos5250_default_tmu_data = { · line 222

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+	.emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
+	.tmu_pmin = EXYNOS5440_TMU_PMIN,
+};
+
+#define EXYNOS5440_TMU_DATA \
+	.trigger_levels[0] = 100, \
+	.trigger_levels[4] = 105, \
+	.trigger_enable[0] = 1, \
+	.trigger_type[0] = SW_TRIP, \
+	.trigger_type[4] = HW_TRIP, \

No active / passive cooling?

Quoted 6 lines
drivers/thermal/samsung/exynos_tmu_data.c +6 -0
+	.max_trigger_level = 5, \
+	.gain = 5, \
+	.reference_voltage = 16, \
+	.noise_cancel_mode = 4, \
+	.cal_type = TYPE_ONE_POINT_TRIMMING, \
+	.cal_mode = 0, \

drivers/thermal/samsung/exynos_tmu_data.c struct exynos_tmu_init_data const exynos5250_default_tmu_data = { · line 238

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+	.efuse_value = 0x5b2d, \
+	.min_efuse_value = 16, \
+	.max_efuse_value = 76, \
+	.first_point_trim = 25, \
+	.second_point_trim = 70, \
+	.default_temp_offset = 25, \
+	.type = SOC_ARCH_EXYNOS5440, \
+	.registers = &exynos5440_tmu_registers, \
+	.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
+			TMU_SUPPORT_MULTI_INST | TMU_SUPPORT_SHARED_MEMORY),

No freq table on 5440? hmm.. So no cpufreq_cooling then? Any reason why not? I suppose one of these 3 sensors are on your CPU domain, right?

Quoted 27 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+
+struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
+	.tmu_data = {
+		{ EXYNOS5440_TMU_DATA } ,
+		{ EXYNOS5440_TMU_DATA } ,
+		{ EXYNOS5440_TMU_DATA } ,
+	},
+	.tmu_count = 3,
+};
+#endif
drivers/thermal/samsung/exynos_tmu_data.h +7 -0
index ad263e9..43ce5fb 100644
@@ -143,4 +143,11 @@ extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
 #define EXYNOS5250_TMU_DRV_DATA (NULL)
 #endif
 
+#if defined(CONFIG_SOC_EXYNOS5440)
+extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
+#define EXYNOS5440_TMU_DRV_DATA (&exynos5440_default_tmu_data)
+#else
+#define EXYNOS5440_TMU_DRV_DATA (NULL)
+#endif
+
 #endif /*_EXYNOS_TMU_DATA_H*/
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#72 lore raw

Re: [PATCH V6 24/30] thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor

Hi,

Quoted 101 lines · Eduardo Valentin
Quoted 70 lines · Amit Daniel Kachhap

This patch adds configuration data for exynos5440 soc. Also register definations for the controller are added.

---
 drivers/thermal/samsung/exynos_tmu.c      |    4 ++
 drivers/thermal/samsung/exynos_tmu_data.c |   71 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |    7 +++
 3 files changed, 82 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +4 -0
index db4035d..a4dbc84 100644
@@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = {
              .compatible = "samsung,exynos5250-tmu",
              .data = (void *)EXYNOS5250_TMU_DRV_DATA,
      },
+     {
+             .compatible = "samsung,exynos5440-tmu",
+             .data = (void *)EXYNOS5440_TMU_DRV_DATA,
+     },
      {},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
drivers/thermal/samsung/exynos_tmu_data.c +35 -0
index 694557e..b34e726 100644
@@ -175,3 +175,74 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
      .tmu_count = 1,
 };
 #endif
+
+#if defined(CONFIG_SOC_EXYNOS5440)
+static const struct exynos_tmu_registers exynos5440_tmu_registers = {
+     .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM,
+     .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
+     .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
+     .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL,
+     .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
+     .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
+     .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
+     .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
+     .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
+     .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
+     .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
+     .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
+     .tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
+     .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
+     .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0,
+     .threshold_th1 = EXYNOS5440_TMU_S0_7_TH1,
+     .threshold_th2 = EXYNOS5440_TMU_S0_7_TH2,
+     .threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT,
+     .tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN,
+     .inten_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
+     .inten_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT,
+     .inten_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
+     .inten_fall_shift = EXYNOS5440_TMU_FALL_INT_SHIFT,
+     .inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT,
+     .inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT,
+     .inten_rise2_shift = EXYNOS5440_TMU_INTEN_RISE2_SHIFT,
+     .inten_rise3_shift = EXYNOS5440_TMU_INTEN_RISE3_SHIFT,
+     .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT,
+     .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ,
+     .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ,
+     .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
+     .emul_con = EXYNOS5440_TMU_S0_7_DEBUG,

drivers/thermal/samsung/exynos_tmu_data.c struct exynos_tmu_init_data const exynos5250_default_tmu_data = { · line 222

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+     .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
+     .tmu_pmin = EXYNOS5440_TMU_PMIN,
+};
+
+#define EXYNOS5440_TMU_DATA \
+     .trigger_levels[0] = 100, \
+     .trigger_levels[4] = 105, \
+     .trigger_enable[0] = 1, \
+     .trigger_type[0] = SW_TRIP, \
+     .trigger_type[4] = HW_TRIP, \

No active / passive cooling?

Quoted 6 lines
drivers/thermal/samsung/exynos_tmu_data.c +6 -0
+     .max_trigger_level = 5, \
+     .gain = 5, \
+     .reference_voltage = 16, \
+     .noise_cancel_mode = 4, \
+     .cal_type = TYPE_ONE_POINT_TRIMMING, \
+     .cal_mode = 0, \

drivers/thermal/samsung/exynos_tmu_data.c struct exynos_tmu_init_data const exynos5250_default_tmu_data = { · line 238

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+     .efuse_value = 0x5b2d, \
+     .min_efuse_value = 16, \
+     .max_efuse_value = 76, \
+     .first_point_trim = 25, \
+     .second_point_trim = 70, \
+     .default_temp_offset = 25, \
+     .type = SOC_ARCH_EXYNOS5440, \
+     .registers = &exynos5440_tmu_registers, \
+     .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
+                     TMU_SUPPORT_MULTI_INST | TMU_SUPPORT_SHARED_MEMORY),
Quoted 2 lines

No freq table on 5440? hmm.. So no cpufreq_cooling then? Any reason why not? I suppose one of these 3 sensors are on your CPU domain, right?

In 5440 no cpufreq cooling is needed. Only sw trip and hw trip is sufficient.

Thanks,
Amit Daniel

Quoted 35 lines
Quoted 18 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+
+struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
+     .tmu_data = {
+             { EXYNOS5440_TMU_DATA } ,
+             { EXYNOS5440_TMU_DATA } ,
+             { EXYNOS5440_TMU_DATA } ,
+     },
+     .tmu_count = 3,
+};
+#endif
drivers/thermal/samsung/exynos_tmu_data.h +0 -0
index ad263e9..43ce5fb 100644
@@ -143,4 +143,11 @@ extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
 #define EXYNOS5250_TMU_DRV_DATA (NULL)

drivers/thermal/samsung/exynos_tmu_data.h extern struct exynos_tmu_init_data const exynos5250_default_tmu_data; · line 153

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.h +7 -0
 #endif
 
+#if defined(CONFIG_SOC_EXYNOS5440)
+extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
+#define EXYNOS5440_TMU_DRV_DATA (&exynos5440_default_tmu_data)
+#else
+#define EXYNOS5440_TMU_DRV_DATA (NULL)
+#endif
+
 #endif /*_EXYNOS_TMU_DATA_H*/

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#73 lore raw

Re: [PATCH V6 24/30] thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor

Quoted 105 lines · amit daniel kachhap

Hi,

Quoted 101 lines · Eduardo Valentin
Quoted 70 lines · Amit Daniel Kachhap

This patch adds configuration data for exynos5440 soc. Also register definations for the controller are added.

---
 drivers/thermal/samsung/exynos_tmu.c      |    4 ++
 drivers/thermal/samsung/exynos_tmu_data.c |   71 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |    7 +++
 3 files changed, 82 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +4 -0
index db4035d..a4dbc84 100644
@@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = {
              .compatible = "samsung,exynos5250-tmu",
              .data = (void *)EXYNOS5250_TMU_DRV_DATA,
      },
+     {
+             .compatible = "samsung,exynos5440-tmu",
+             .data = (void *)EXYNOS5440_TMU_DRV_DATA,
+     },
      {},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
drivers/thermal/samsung/exynos_tmu_data.c +35 -0
index 694557e..b34e726 100644
@@ -175,3 +175,74 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
      .tmu_count = 1,
 };
 #endif
+
+#if defined(CONFIG_SOC_EXYNOS5440)
+static const struct exynos_tmu_registers exynos5440_tmu_registers = {
+     .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM,
+     .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
+     .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
+     .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL,
+     .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
+     .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
+     .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
+     .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
+     .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
+     .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
+     .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
+     .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
+     .tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
+     .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
+     .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0,
+     .threshold_th1 = EXYNOS5440_TMU_S0_7_TH1,
+     .threshold_th2 = EXYNOS5440_TMU_S0_7_TH2,
+     .threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT,
+     .tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN,
+     .inten_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
+     .inten_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT,
+     .inten_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
+     .inten_fall_shift = EXYNOS5440_TMU_FALL_INT_SHIFT,
+     .inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT,
+     .inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT,
+     .inten_rise2_shift = EXYNOS5440_TMU_INTEN_RISE2_SHIFT,
+     .inten_rise3_shift = EXYNOS5440_TMU_INTEN_RISE3_SHIFT,
+     .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT,
+     .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ,
+     .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ,
+     .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
+     .emul_con = EXYNOS5440_TMU_S0_7_DEBUG,

drivers/thermal/samsung/exynos_tmu_data.c struct exynos_tmu_init_data const exynos5250_default_tmu_data = { · line 222

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+     .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
+     .tmu_pmin = EXYNOS5440_TMU_PMIN,
+};
+
+#define EXYNOS5440_TMU_DATA \
+     .trigger_levels[0] = 100, \
+     .trigger_levels[4] = 105, \
+     .trigger_enable[0] = 1, \
+     .trigger_type[0] = SW_TRIP, \
+     .trigger_type[4] = HW_TRIP, \

No active / passive cooling?

Quoted 16 lines
drivers/thermal/samsung/exynos_tmu_data.c +16 -0
+     .max_trigger_level = 5, \
+     .gain = 5, \
+     .reference_voltage = 16, \
+     .noise_cancel_mode = 4, \
+     .cal_type = TYPE_ONE_POINT_TRIMMING, \
+     .cal_mode = 0, \
+     .efuse_value = 0x5b2d, \
+     .min_efuse_value = 16, \
+     .max_efuse_value = 76, \
+     .first_point_trim = 25, \
+     .second_point_trim = 70, \
+     .default_temp_offset = 25, \
+     .type = SOC_ARCH_EXYNOS5440, \
+     .registers = &exynos5440_tmu_registers, \
+     .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
+                     TMU_SUPPORT_MULTI_INST | TMU_SUPPORT_SHARED_MEMORY),
Quoted 3 lines
Quoted 2 lines

No freq table on 5440? hmm.. So no cpufreq_cooling then? Any reason why not? I suppose one of these 3 sensors are on your CPU domain, right?

In 5440 no cpufreq cooling is needed. Only sw trip and hw trip is sufficient.

Infact all sensors are cpu related at some positions.

Quoted 38 lines

Thanks,
Amit Daniel

Quoted 35 lines
Quoted 18 lines
drivers/thermal/samsung/exynos_tmu_data.c +10 -0
+
+struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
+     .tmu_data = {
+             { EXYNOS5440_TMU_DATA } ,
+             { EXYNOS5440_TMU_DATA } ,
+             { EXYNOS5440_TMU_DATA } ,
+     },
+     .tmu_count = 3,
+};
+#endif
drivers/thermal/samsung/exynos_tmu_data.h +0 -0
index ad263e9..43ce5fb 100644
@@ -143,4 +143,11 @@ extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
 #define EXYNOS5250_TMU_DRV_DATA (NULL)

drivers/thermal/samsung/exynos_tmu_data.h extern struct exynos_tmu_init_data const exynos5250_default_tmu_data; · line 153

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu_data.h +7 -0
 #endif
 
+#if defined(CONFIG_SOC_EXYNOS5440)
+extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
+#define EXYNOS5440_TMU_DRV_DATA (&exynos5440_default_tmu_data)
+#else
+#define EXYNOS5440_TMU_DRV_DATA (NULL)
+#endif
+
 #endif /*_EXYNOS_TMU_DATA_H*/

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#74 lore raw

PATCH v6 25/30 thermal: exynos: Fix to set the second point correction value

In reply to Amit Daniel Kachhap

This patch sets the second point trimming value according to the platform data if the register value is 0.

---
 drivers/thermal/samsung/exynos_tmu.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +9 -4
index a4dbc84..af0e6ca 100644
@@ -180,10 +180,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
 				EXYNOS_TMU_TEMP_MASK);
 
-	if ((pdata->min_efuse_value > data->temp_error1) ||
-			(data->temp_error1 > pdata->max_efuse_value) ||
-			(data->temp_error2 != 0))
-		data->temp_error1 = pdata->efuse_value;
+	if (!data->temp_error1 ||
+		(pdata->min_efuse_value > data->temp_error1) ||
+		(data->temp_error1 > pdata->max_efuse_value))
+		data->temp_error1 = pdata->efuse_value & EXYNOS_TMU_TEMP_MASK;
+
+	if (!data->temp_error2)
+		data->temp_error2 =
+			(pdata->efuse_value >> reg->triminfo_85_shift) &
+			EXYNOS_TMU_TEMP_MASK;
 
 	if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) {
 		dev_err(&pdev->dev, "Invalid max trigger level\n");
Signature · 1 line
1.7.1
Acked-by on v6 25/30
#75 lore raw

Re: [PATCH V6 25/30] thermal: exynos: Fix to set the second point correction value

Quoted 6 lines · Amit Daniel Kachhap

This patch sets the second point trimming value according to the platform data if the register value is 0.

Quoted 29 lines
---
 drivers/thermal/samsung/exynos_tmu.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +9 -4
index a4dbc84..af0e6ca 100644
@@ -180,10 +180,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
 				EXYNOS_TMU_TEMP_MASK);
 
-	if ((pdata->min_efuse_value > data->temp_error1) ||
-			(data->temp_error1 > pdata->max_efuse_value) ||
-			(data->temp_error2 != 0))
-		data->temp_error1 = pdata->efuse_value;
+	if (!data->temp_error1 ||
+		(pdata->min_efuse_value > data->temp_error1) ||
+		(data->temp_error1 > pdata->max_efuse_value))
+		data->temp_error1 = pdata->efuse_value & EXYNOS_TMU_TEMP_MASK;
+
+	if (!data->temp_error2)
+		data->temp_error2 =
+			(pdata->efuse_value >> reg->triminfo_85_shift) &
+			EXYNOS_TMU_TEMP_MASK;
 
 	if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) {
 		dev_err(&pdev->dev, "Invalid max trigger level\n");
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#76 lore raw

PATCH v6 26/30 thermal: exynos: Add hardware mode thermal calibration support

In reply to Amit Daniel Kachhap

This patch adds support for h/w mode calibration in the TMU controller. soc's like 5440 support this features.

---
 drivers/thermal/samsung/exynos_tmu.c      |   15 +++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h      |    6 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 drivers/thermal/samsung/exynos_tmu_data.h |    2 ++
 4 files changed, 25 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +15 -0
index af0e6ca..7a259f4 100644
@@ -73,6 +73,9 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	int temp_code;
 
+	if (pdata->cal_mode == HW_MODE)
+		return temp;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210)
 		/* temp should range between 25 and 125 */
 		if (temp < 25 || temp > 125) {
@@ -107,6 +110,9 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	int temp;
 
+	if (pdata->cal_mode == HW_MODE)
+		return temp_code;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210)
 		/* temp_code should range between 75 and 175 */
 		if (temp_code < 75 || temp_code > 175) {
@@ -155,6 +161,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	if (TMU_SUPPORTS(pdata, TRIM_RELOAD))
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
+	if (pdata->cal_mode == HW_MODE)
+		goto skip_calib_data;
+
 	/* Save trimming info in order to perform calibration */
 	if (data->soc == SOC_ARCH_EXYNOS5440) {
 		/*
@@ -190,6 +199,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			(pdata->efuse_value >> reg->triminfo_85_shift) &
 			EXYNOS_TMU_TEMP_MASK;
 
+skip_calib_data:
 	if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) {
 		dev_err(&pdev->dev, "Invalid max trigger level\n");
 		goto out;
@@ -319,6 +329,11 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 		con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift);
 	}
 
+	if (pdata->cal_mode == HW_MODE) {
+		con &= ~(reg->calib_mode_mask << reg->calib_mode_shift);
+		con |= pdata->cal_type << reg->calib_mode_shift;
+	}
+
 	if (on) {
 		con |= (1 << reg->core_en_shift);
 		interrupt_en =
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 73aaed7..abfa1eb 100644
@@ -88,6 +88,10 @@ enum soc_type {
  * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
 	register.
  * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
+ * @calib_mode_shift: shift bits of calibration mode value in tmu_ctrl
+	register.
+ * @calib_mode_mask: mask bits of calibration mode value in tmu_ctrl
+	register.
  * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
 	tmu_ctrl register.
  * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
@@ -149,6 +153,8 @@ struct exynos_tmu_registers {
 	u32	therm_trip_en_shift;
 	u32	buf_slope_sel_shift;
 	u32	buf_slope_sel_mask;
+	u32	calib_mode_shift;
+	u32	calib_mode_mask;
 	u32	therm_trip_tq_en_shift;
 	u32	core_en_shift;
 
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index b34e726..47c5d6b 100644
@@ -189,6 +189,8 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
 	.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
 	.buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
 	.buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
+	.calib_mode_shift = EXYNOS_TMU_CALIB_MODE_SHIFT,
+	.calib_mode_mask = EXYNOS_TMU_CALIB_MODE_MASK,
 	.core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
 	.tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
 	.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 43ce5fb..dc7feb5 100644
@@ -75,6 +75,8 @@
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
 #define EXYNOS_TMU_TRIP_MODE_MASK	0x7
 #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT	12
+#define EXYNOS_TMU_CALIB_MODE_SHIFT	4
+#define EXYNOS_TMU_CALIB_MODE_MASK	0x3
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
 #define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
Signature · 1 line
1.7.1
#77 lore raw

Re: [PATCH V6 26/30] thermal: exynos: Add hardware mode thermal calibration support

Quoted 56 lines · Amit Daniel Kachhap

This patch adds support for h/w mode calibration in the TMU controller. soc's like 5440 support this features.

---
 drivers/thermal/samsung/exynos_tmu.c      |   15 +++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h      |    6 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 drivers/thermal/samsung/exynos_tmu_data.h |    2 ++
 4 files changed, 25 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +10 -0
index af0e6ca..7a259f4 100644
@@ -73,6 +73,9 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	int temp_code;
 
+	if (pdata->cal_mode == HW_MODE)
+		return temp;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210)
 		/* temp should range between 25 and 125 */
 		if (temp < 25 || temp > 125) {
@@ -107,6 +110,9 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	int temp;
 
+	if (pdata->cal_mode == HW_MODE)
+		return temp_code;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210)
 		/* temp_code should range between 75 and 175 */
 		if (temp_code < 75 || temp_code > 175) {
@@ -155,6 +161,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	if (TMU_SUPPORTS(pdata, TRIM_RELOAD))
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
+	if (pdata->cal_mode == HW_MODE)
+		goto skip_calib_data;
+
 	/* Save trimming info in order to perform calibration */
 	if (data->soc == SOC_ARCH_EXYNOS5440) {
 		/*
@@ -190,6 +199,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			(pdata->efuse_value >> reg->triminfo_85_shift) &
 			EXYNOS_TMU_TEMP_MASK;
 
+skip_calib_data:
 	if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) {
 		dev_err(&pdev->dev, "Invalid max trigger level\n");
 		goto out;

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_control(struct platform_device *pdev, bool on) · line 334

Quoted 6 lines
drivers/thermal/samsung/exynos_tmu.c +3 -0
@@ -319,6 +329,11 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 		con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift);
 	}
 
+	if (pdata->cal_mode == HW_MODE) {
+		con &= ~(reg->calib_mode_mask << reg->calib_mode_shift);
+		con |= pdata->cal_type << reg->calib_mode_shift;

cal_type is an enum and you don't set any constant value to those enumerations. are you sure you want to rely on it for bit field handling?

Quoted 56 lines
drivers/thermal/samsung/exynos_tmu.c +2 -0
+	}
+
 	if (on) {
 		con |= (1 << reg->core_en_shift);
 		interrupt_en =
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 73aaed7..abfa1eb 100644
@@ -88,6 +88,10 @@ enum soc_type {
  * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
 	register.
  * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
+ * @calib_mode_shift: shift bits of calibration mode value in tmu_ctrl
+	register.
+ * @calib_mode_mask: mask bits of calibration mode value in tmu_ctrl
+	register.
  * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
 	tmu_ctrl register.
  * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
@@ -149,6 +153,8 @@ struct exynos_tmu_registers {
 	u32	therm_trip_en_shift;
 	u32	buf_slope_sel_shift;
 	u32	buf_slope_sel_mask;
+	u32	calib_mode_shift;
+	u32	calib_mode_mask;
 	u32	therm_trip_tq_en_shift;
 	u32	core_en_shift;
 
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index b34e726..47c5d6b 100644
@@ -189,6 +189,8 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
 	.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
 	.buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
 	.buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
+	.calib_mode_shift = EXYNOS_TMU_CALIB_MODE_SHIFT,
+	.calib_mode_mask = EXYNOS_TMU_CALIB_MODE_MASK,
 	.core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
 	.tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
 	.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 43ce5fb..dc7feb5 100644
@@ -75,6 +75,8 @@
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
 #define EXYNOS_TMU_TRIP_MODE_MASK	0x7
 #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT	12
+#define EXYNOS_TMU_CALIB_MODE_SHIFT	4
+#define EXYNOS_TMU_CALIB_MODE_MASK	0x3
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
 #define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#78 lore raw

PATCH v6 27/30 Documentation: thermal: Explain the exynos thermal driver model

In reply to Amit Daniel Kachhap

This patch updates the documentation to explain the driver model and file layout.

---
 Documentation/thermal/exynos_thermal |   43 ++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 9 deletions(-)
Documentation/thermal/exynos_thermal +34 -9
index 2b46f67..9010c44 100644
@@ -1,17 +1,17 @@
-Kernel driver exynos4_tmu
+Kernel driver exynos_tmu
 =================
 
 Supported chips:
-* ARM SAMSUNG EXYNOS4 series of SoC
-  Prefix: 'exynos4-tmu'
+* ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC
   Datasheet: Not publicly available
 
 Authors: Donggeun Kim <[email protected]>
+Authors: Amit Daniel <[email protected]>
 
-Description
------------
+TMU controller Description:
+---------------------------
 
-This driver allows to read temperature inside SAMSUNG EXYNOS4 series of SoC.
+This driver allows to read temperature inside SAMSUNG EXYNOS4/5 series of SoC.
 
 The chip only exposes the measured 8-bit temperature code value
 through a register.
@@ -34,9 +34,9 @@ The three equations are:
   TI2: Trimming info for 85 degree Celsius (stored at TRIMINFO register)
        Temperature code measured at 85 degree Celsius which is unchanged
 
-TMU(Thermal Management Unit) in EXYNOS4 generates interrupt
+TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt
 when temperature exceeds pre-defined levels.
-The maximum number of configurable threshold is four.
+The maximum number of configurable threshold is five.
 The threshold levels are defined as follows:
   Level_0: current temperature > trigger_level_0 + threshold
   Level_1: current temperature > trigger_level_1 + threshold
@@ -47,6 +47,31 @@ The threshold levels are defined as follows:
   through the corresponding registers.
 
 When an interrupt occurs, this driver notify kernel thermal framework
-with the function exynos4_report_trigger.
+with the function exynos_report_trigger.
 Although an interrupt condition for level_0 can be set,
 it can be used to synchronize the cooling action.
+
+TMU driver description:
+-----------------------
+
+The exynos thermal driver is structured as,
+
+					Kernel Core thermal framework
+				(thermal_core.c, step_wise.c, cpu_cooling.c)
+								^
+								|
+								|
+TMU configuration data -------> TMU Driver  <------> Exynos Core thermal wrapper
+(exynos_tmu_data.c)	      (exynos_tmu.c)	   (exynos_thermal_common.c)
+(exynos_tmu_data.h)	      (exynos_tmu.h)	   (exynos_thermal_common.h)
+
+a) TMU configuration data: This consist of TMU register offsets/bitfields
+		described through structure exynos_tmu_registers. Also several
+		other platform data (struct exynos_tmu_platform_data) members
+		are used to configure the TMU.
+b) TMU driver: This component initialises the TMU controller and sets different
+		thresholds. It invokes core thermal implementation with the call
+		exynos_report_trigger.
+c) Exynos Core thermal wrapper: This provides 3 wrapper function to use the
+		Kernel core thermal framework. They are exynos_unregister_thermal,
+		exynos_register_thermal and exynos_report_trigger.
Signature · 1 line
1.7.1
Acked-by on v6 27/30
#79 lore raw

Re: [PATCH V6 27/30] Documentation: thermal: Explain the exynos thermal driver model

Quoted 6 lines · Amit Daniel Kachhap

This patch updates the documentation to explain the driver model and file layout.

Quoted 78 lines
---
 Documentation/thermal/exynos_thermal |   43 ++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 9 deletions(-)
Documentation/thermal/exynos_thermal +34 -9
index 2b46f67..9010c44 100644
@@ -1,17 +1,17 @@
-Kernel driver exynos4_tmu
+Kernel driver exynos_tmu
 =================
 
 Supported chips:
-* ARM SAMSUNG EXYNOS4 series of SoC
-  Prefix: 'exynos4-tmu'
+* ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC
   Datasheet: Not publicly available
 
 Authors: Donggeun Kim <[email protected]>
+Authors: Amit Daniel <[email protected]>
 
-Description
------------
+TMU controller Description:
+---------------------------
 
-This driver allows to read temperature inside SAMSUNG EXYNOS4 series of SoC.
+This driver allows to read temperature inside SAMSUNG EXYNOS4/5 series of SoC.
 
 The chip only exposes the measured 8-bit temperature code value
 through a register.
@@ -34,9 +34,9 @@ The three equations are:
   TI2: Trimming info for 85 degree Celsius (stored at TRIMINFO register)
        Temperature code measured at 85 degree Celsius which is unchanged
 
-TMU(Thermal Management Unit) in EXYNOS4 generates interrupt
+TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt
 when temperature exceeds pre-defined levels.
-The maximum number of configurable threshold is four.
+The maximum number of configurable threshold is five.
 The threshold levels are defined as follows:
   Level_0: current temperature > trigger_level_0 + threshold
   Level_1: current temperature > trigger_level_1 + threshold
@@ -47,6 +47,31 @@ The threshold levels are defined as follows:
   through the corresponding registers.
 
 When an interrupt occurs, this driver notify kernel thermal framework
-with the function exynos4_report_trigger.
+with the function exynos_report_trigger.
 Although an interrupt condition for level_0 can be set,
 it can be used to synchronize the cooling action.
+
+TMU driver description:
+-----------------------
+
+The exynos thermal driver is structured as,
+
+					Kernel Core thermal framework
+				(thermal_core.c, step_wise.c, cpu_cooling.c)
+								^
+								|
+								|
+TMU configuration data -------> TMU Driver  <------> Exynos Core thermal wrapper
+(exynos_tmu_data.c)	      (exynos_tmu.c)	   (exynos_thermal_common.c)
+(exynos_tmu_data.h)	      (exynos_tmu.h)	   (exynos_thermal_common.h)
+
+a) TMU configuration data: This consist of TMU register offsets/bitfields
+		described through structure exynos_tmu_registers. Also several
+		other platform data (struct exynos_tmu_platform_data) members
+		are used to configure the TMU.
+b) TMU driver: This component initialises the TMU controller and sets different
+		thresholds. It invokes core thermal implementation with the call
+		exynos_report_trigger.
+c) Exynos Core thermal wrapper: This provides 3 wrapper function to use the
+		Kernel core thermal framework. They are exynos_unregister_thermal,
+		exynos_register_thermal and exynos_report_trigger.
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#80 lore raw

PATCH v6 28/30 thermal: exynos: Support for TMU regulator defined at device tree

In reply to Amit Daniel Kachhap

TMU probe function now checks for a device tree defined regulator. For compatibility reasons it is allowed to probe driver even without this regulator defined.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |    4 +++
 drivers/thermal/samsung/exynos_tmu.c               |   23 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +4 -0
index e6386ea..284f530 100644
@@ -16,6 +16,9 @@
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
+- vtmu-supply: This entry is optional and provides the regulator node supplying
+		voltage to TMU. If needed this entry can be placed inside
+		board/platform specific dts file.
 
 Example 1):
 
@@ -27,6 +30,7 @@ Example 1):
 		clocks = <&clock 383>;
 		clock-names = "tmu_apbif";
 		status = "disabled";
+		vtmu-supply = <&tmu_regulator_node>;
 	};
 
 Example 2):
drivers/thermal/samsung/exynos_tmu.c +23 -0
index 7a259f4..441efd5 100644
@@ -29,6 +29,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
@@ -48,6 +49,7 @@
  * @clk: pointer to the clock structure.
  * @temp_error1: fused value of the first point trim.
  * @temp_error2: fused value of the second point trim.
+ * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  */
 struct exynos_tmu_data {
@@ -61,6 +63,7 @@ struct exynos_tmu_data {
 	struct mutex lock;
 	struct clk *clk;
 	u8 temp_error1, temp_error2;
+	struct regulator *regulator;
 	struct thermal_sensor_conf *reg_conf;
 };
 
@@ -510,10 +513,27 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
 	struct exynos_tmu_platform_data *pdata;
 	struct resource res;
+	int ret;
 
 	if (!data)
 		return -ENODEV;
 
+	/*
+	 * Try enabling the regulator if found
+	 * TODO: Add regulator as an SOC feature, so that regulator enable
+	 * is a compulsory call.
+	 */
+	data->regulator = devm_regulator_get(&pdev->dev, "vtmu");
+	if (!IS_ERR(data->regulator)) {
+		ret = regulator_enable(data->regulator);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to enable vtmu\n");
+			return ret;
+		}
+	} else {
+		dev_info(&pdev->dev, "Regulator node (vtmu) not found\n");
+	}
+
 	data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
 	if (data->id < 0)
 		data->id = 0;
@@ -680,6 +700,9 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
 	clk_unprepare(data->clk);
 
+	if (!IS_ERR(data->regulator))
+		regulator_disable(data->regulator);
+
 	return 0;
 }
 
Signature · 1 line
1.7.1
Acked-by on v6 28/30
#81 lore raw

Re: [PATCH V6 28/30] thermal: exynos: Support for TMU regulator defined at device tree

Quoted 8 lines · Amit Daniel Kachhap

TMU probe function now checks for a device tree defined regulator. For compatibility reasons it is allowed to probe driver even without this regulator defined.

Quoted 94 lines
---
 .../devicetree/bindings/thermal/exynos-thermal.txt |    4 +++
 drivers/thermal/samsung/exynos_tmu.c               |   23 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +4 -0
index e6386ea..284f530 100644
@@ -16,6 +16,9 @@
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
+- vtmu-supply: This entry is optional and provides the regulator node supplying
+		voltage to TMU. If needed this entry can be placed inside
+		board/platform specific dts file.
 
 Example 1):
 
@@ -27,6 +30,7 @@ Example 1):
 		clocks = <&clock 383>;
 		clock-names = "tmu_apbif";
 		status = "disabled";
+		vtmu-supply = <&tmu_regulator_node>;
 	};
 
 Example 2):
drivers/thermal/samsung/exynos_tmu.c +23 -0
index 7a259f4..441efd5 100644
@@ -29,6 +29,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
@@ -48,6 +49,7 @@
  * @clk: pointer to the clock structure.
  * @temp_error1: fused value of the first point trim.
  * @temp_error2: fused value of the second point trim.
+ * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  */
 struct exynos_tmu_data {
@@ -61,6 +63,7 @@ struct exynos_tmu_data {
 	struct mutex lock;
 	struct clk *clk;
 	u8 temp_error1, temp_error2;
+	struct regulator *regulator;
 	struct thermal_sensor_conf *reg_conf;
 };
 
@@ -510,10 +513,27 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
 	struct exynos_tmu_platform_data *pdata;
 	struct resource res;
+	int ret;
 
 	if (!data)
 		return -ENODEV;
 
+	/*
+	 * Try enabling the regulator if found
+	 * TODO: Add regulator as an SOC feature, so that regulator enable
+	 * is a compulsory call.
+	 */
+	data->regulator = devm_regulator_get(&pdev->dev, "vtmu");
+	if (!IS_ERR(data->regulator)) {
+		ret = regulator_enable(data->regulator);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to enable vtmu\n");
+			return ret;
+		}
+	} else {
+		dev_info(&pdev->dev, "Regulator node (vtmu) not found\n");
+	}
+
 	data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
 	if (data->id < 0)
 		data->id = 0;
@@ -680,6 +700,9 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
 	clk_unprepare(data->clk);
 
+	if (!IS_ERR(data->regulator))
+		regulator_disable(data->regulator);
+
 	return 0;
 }
 
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#82 lore raw

PATCH v6 29/30 ARM: dts: Add device tree node for exynos5440 TMU controller

In reply to Amit Daniel Kachhap

This patch adds device node for TMU controller. There are 3 instances of the controllers so 3 nodes are created.

---
 arch/arm/boot/dts/exynos5440.dtsi |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5440.dtsi +30 -0
index f6b1c89..716e90c 100644
@@ -16,6 +16,12 @@
 
 	interrupt-parent = <&gic>;
 
+	aliases {
+		tmuctrl0 = &tmuctrl_0;
+		tmuctrl1 = &tmuctrl_1;
+		tmuctrl2 = &tmuctrl_2;
+	};
+
 	clock: clock-controller@0x160000 {
 		compatible = "samsung,exynos5440-clock";
 		reg = <0x160000 0x1000>;
@@ -216,4 +222,28 @@
 		clock-names = "rtc";
 		status = "disabled";
 	};
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+	tmuctrl_1: tmuctrl@16011C {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x16011C 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+	tmuctrl_2: tmuctrl@160120 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160120 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
 };
Signature · 1 line
1.7.1
Reviewed-by on v6 29/30
#83 lore raw

Re: [PATCH V6 29/30] ARM: dts: Add device tree node for exynos5440 TMU controller

Quoted 6 lines · Amit Daniel Kachhap

This patch adds device node for TMU controller. There are 3 instances of the controllers so 3 nodes are created.

Quoted 51 lines
---
 arch/arm/boot/dts/exynos5440.dtsi |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5440.dtsi +30 -0
index f6b1c89..716e90c 100644
@@ -16,6 +16,12 @@
 
 	interrupt-parent = <&gic>;
 
+	aliases {
+		tmuctrl0 = &tmuctrl_0;
+		tmuctrl1 = &tmuctrl_1;
+		tmuctrl2 = &tmuctrl_2;
+	};
+
 	clock: clock-controller@0x160000 {
 		compatible = "samsung,exynos5440-clock";
 		reg = <0x160000 0x1000>;
@@ -216,4 +222,28 @@
 		clock-names = "rtc";
 		status = "disabled";
 	};
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+	tmuctrl_1: tmuctrl@16011C {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x16011C 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+	tmuctrl_2: tmuctrl@160120 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160120 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
 };
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#84 lore raw

PATCH v6 30/30 arm: exynos: enable ARCH_HAS_BANDGAP

In reply to Amit Daniel Kachhap

This patch enables ARCH_HAS_BANDGAP config for exynos4210, 4212, 4412, 5250 and 5440 SOC. This config symbol is recently added to allow the platforms to enable bandgap based temperature sensor.

---
 arch/arm/mach-exynos/Kconfig |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-exynos/Kconfig +5 -0
index d19edff..d3cb5c7 100644
@@ -33,6 +33,7 @@ config CPU_EXYNOS4210
 	bool "SAMSUNG EXYNOS4210"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_BANDGAP
 	select ARM_CPU_SUSPEND if PM
 	select PM_GENERIC_DOMAINS
 	select S5P_PM if PM
@@ -45,6 +46,7 @@ config SOC_EXYNOS4212
 	bool "SAMSUNG EXYNOS4212"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_BANDGAP
 	select S5P_PM if PM
 	select S5P_SLEEP if PM
 	select SAMSUNG_DMADEV
@@ -55,6 +57,7 @@ config SOC_EXYNOS4412
 	bool "SAMSUNG EXYNOS4412"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_BANDGAP
 	select SAMSUNG_DMADEV
 	help
 	  Enable EXYNOS4412 SoC support
@@ -63,6 +66,7 @@ config SOC_EXYNOS5250
 	bool "SAMSUNG EXYNOS5250"
 	default y
 	depends on ARCH_EXYNOS5
+	select ARCH_HAS_BANDGAP
 	select PM_GENERIC_DOMAINS if PM
 	select S5P_PM if PM
 	select S5P_SLEEP if PM
@@ -76,6 +80,7 @@ config SOC_EXYNOS5440
 	default y
 	depends on ARCH_EXYNOS5
 	select ARCH_HAS_OPP
+	select ARCH_HAS_BANDGAP
 	select ARM_ARCH_TIMER
 	select AUTO_ZRELADDR
 	select PINCTRL
Signature · 1 line
1.7.1
Acked-by on v6 30/30
#85 lore raw

Re: [PATCH V6 30/30] arm: exynos: enable ARCH_HAS_BANDGAP

Quoted 6 lines · Amit Daniel Kachhap

This patch enables ARCH_HAS_BANDGAP config for exynos4210, 4212, 4412, 5250 and 5440 SOC. This config symbol is recently added to allow the platforms to enable bandgap based temperature sensor.

Quoted 49 lines
---
 arch/arm/mach-exynos/Kconfig |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-exynos/Kconfig +5 -0
index d19edff..d3cb5c7 100644
@@ -33,6 +33,7 @@ config CPU_EXYNOS4210
 	bool "SAMSUNG EXYNOS4210"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_BANDGAP
 	select ARM_CPU_SUSPEND if PM
 	select PM_GENERIC_DOMAINS
 	select S5P_PM if PM
@@ -45,6 +46,7 @@ config SOC_EXYNOS4212
 	bool "SAMSUNG EXYNOS4212"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_BANDGAP
 	select S5P_PM if PM
 	select S5P_SLEEP if PM
 	select SAMSUNG_DMADEV
@@ -55,6 +57,7 @@ config SOC_EXYNOS4412
 	bool "SAMSUNG EXYNOS4412"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_BANDGAP
 	select SAMSUNG_DMADEV
 	help
 	  Enable EXYNOS4412 SoC support
@@ -63,6 +66,7 @@ config SOC_EXYNOS5250
 	bool "SAMSUNG EXYNOS5250"
 	default y
 	depends on ARCH_EXYNOS5
+	select ARCH_HAS_BANDGAP
 	select PM_GENERIC_DOMAINS if PM
 	select S5P_PM if PM
 	select S5P_SLEEP if PM
@@ -76,6 +80,7 @@ config SOC_EXYNOS5440
 	default y
 	depends on ARCH_EXYNOS5
 	select ARCH_HAS_OPP
+	select ARCH_HAS_BANDGAP
 	select ARM_ARCH_TIMER
 	select AUTO_ZRELADDR
 	select PINCTRL
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin