Skip to contentSkip to conversation

thermal: ti-soc-thermal: dra7: Implement Workaround for Errata i814 - Bandgap Temperature read Dtemp can be corrupted

PATCH Superseded Keerthy 3 participants 5 messages Mar 27, 2015 – Apr 10, 2015

Subsystems (2)
lore
Share & tools
lore

Keerthy

author maintainer
#0 lore raw

PATCH v2 1/1 thermal: ti-soc-thermal: dra7: Implement Workaround for Errata i814 - Bandgap Temperature read Dtemp can be corrupted

Bandgap Temperature read Dtemp can be corrupted

DESCRIPTION
Read accesses to registers listed below can be corrupted due to incorrect resynchronization between clock domains.

Read access to registers below can be corrupted :
• CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
• CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n

WORKAROUND
Multiple reads to CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA[9:0]:
BGAP_DTEMPMPU/GPU/CORE/DSPEVE/IVA is needed to discard false value and read right value:
1. Perform two successive reads to BGAP_DTEMP bit field.
(a) If read1 returns Val1 and read2 returns Val1, then right value is Val1.
(b) If read1 returns Val1, read 2 returns Val2, a third read is needed.
2. Perform third read
(a) If read3 returns Val2 then right value is Val2.
(b) If read3 returns Val3, then right value is Val3.

---

Read all the temperatures from the 5 sensors and saw that they were sane with time.

Ran cpuloadgen and saw that temperatures rising on all the sensors and cooled down as soon as the load was reduced.

 .../thermal/ti-soc-thermal/dra752-thermal-data.c   |  3 +-
 drivers/thermal/ti-soc-thermal/ti-bandgap.c        | 37 +++++++++++++++++++++-
 drivers/thermal/ti-soc-thermal/ti-bandgap.h        |  4 +++
 3 files changed, 42 insertions(+), 2 deletions(-)
drivers/thermal/ti-soc-thermal/dra752-thermal-data.c +2 -1
index a492927..58b5c66 100644
@@ -420,7 +420,8 @@ const struct ti_bandgap_data dra752_data = {
 			TI_BANDGAP_FEATURE_FREEZE_BIT |
 			TI_BANDGAP_FEATURE_TALERT |
 			TI_BANDGAP_FEATURE_COUNTER_DELAY |
-			TI_BANDGAP_FEATURE_HISTORY_BUFFER,
+			TI_BANDGAP_FEATURE_HISTORY_BUFFER |
+			TI_BANDGAP_FEATURE_ERRATA_814,
 	.fclock_name = "l3instr_ts_gclk_div",
 	.div_ck_name = "l3instr_ts_gclk_div",
 	.conv_table = dra752_adc_to_temp,
drivers/thermal/ti-soc-thermal/ti-bandgap.c +36 -1
index 74c0e34..baf822e 100644
@@ -119,6 +119,37 @@ exit:
 }
 
 /**
+ * ti_dra7_bandgap_read_temp() - helper function to read dra7 sensor temperature
+ * @bgp: pointer to ti_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Function to read dra7 bandgap sensor temperature. This is done separately
+ * so as to workaround the errata "Bandgap Temperature read Dtemp can be
+ * corrupted" - Errata ID: i814".
+ * Read accesses to registers listed below can be corrupted due to incorrect
+ * resynchronization between clock domains.
+ * Read access to registers below can be corrupted :
+ * CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
+ * CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n
+ *
+ * Return: the register value.
+ */
+static u32 ti_dra7_bandgap_read_temp(struct ti_bandgap *bgp,  u32 reg)
+{
+	u32 val1, val2;
+
+	val1 = ti_bandgap_readl(bgp, reg);
+	val2 = ti_bandgap_readl(bgp, reg);
+
+/* If both times we read the same value then that is right */
+	if (val1 == val2)
+		return val1;
+
+/* if val1 and val2 are different read it third time */
+	return ti_bandgap_readl(bgp, reg);
+}
+
+/**
  * ti_bandgap_read_temp() - helper function to read sensor temperature
  * @bgp: pointer to ti_bandgap structure
  * @id: bandgap sensor id
@@ -148,7 +179,11 @@ static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
 	}
 
 	/* read temperature */
-	temp = ti_bandgap_readl(bgp, reg);
+	if (TI_BANDGAP_HAS(bgp, ERRATA_814))
+		temp = ti_dra7_bandgap_read_temp(bgp, reg);
+	else
+		temp = ti_bandgap_readl(bgp, reg);
+
 	temp &= tsr->bgap_dtemp_mask;
 
 	if (TI_BANDGAP_HAS(bgp, FREEZE_BIT))
drivers/thermal/ti-soc-thermal/ti-bandgap.h +4 -0
index b3adf72..b2da3fc 100644
@@ -318,6 +318,9 @@ struct ti_temp_sensor {
  * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
  *	a history buffer of temperatures.
  *
+ * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
+ *	has Errata 814
+ *
  * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
  *      specific feature (above) or not. Return non-zero, if yes.
  */
@@ -331,6 +334,7 @@ struct ti_temp_sensor {
 #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
 #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_ERRATA_814		BIT(10)
 #define TI_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

Hi Eduardo,

Quoted 10 lines · Keerthy

Bandgap Temperature read Dtemp can be corrupted

DESCRIPTION
Read accesses to registers listed below can be corrupted due to incorrect resynchronization between clock domains.

Read access to registers below can be corrupted :
• CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
• CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n

Quoted 10 lines

WORKAROUND
Multiple reads to CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA[9:0]:
BGAP_DTEMPMPU/GPU/CORE/DSPEVE/IVA is needed to discard false value and read right value:
1. Perform two successive reads to BGAP_DTEMP bit field.
(a) If read1 returns Val1 and read2 returns Val1, then right value is Val1.
(b) If read1 returns Val1, read 2 returns Val2, a third read is needed.
2. Perform third read
(a) If read3 returns Val2 then right value is Val2.
(b) If read3 returns Val3, then right value is Val3.

A gentle ping on this.

Quoted 106 lines

---

Read all the temperatures from the 5 sensors and saw that they were sane with time.

Ran cpuloadgen and saw that temperatures rising on all the sensors and cooled down as soon as the load was reduced.

  .../thermal/ti-soc-thermal/dra752-thermal-data.c   |  3 +-
  drivers/thermal/ti-soc-thermal/ti-bandgap.c        | 37 +++++++++++++++++++++-
  drivers/thermal/ti-soc-thermal/ti-bandgap.h        |  4 +++
  3 files changed, 42 insertions(+), 2 deletions(-)
drivers/thermal/ti-soc-thermal/dra752-thermal-data.c +2 -1
index a492927..58b5c66 100644
@@ -420,7 +420,8 @@ const struct ti_bandgap_data dra752_data = {
  			TI_BANDGAP_FEATURE_FREEZE_BIT |
  			TI_BANDGAP_FEATURE_TALERT |
  			TI_BANDGAP_FEATURE_COUNTER_DELAY |
-			TI_BANDGAP_FEATURE_HISTORY_BUFFER,
+			TI_BANDGAP_FEATURE_HISTORY_BUFFER |
+			TI_BANDGAP_FEATURE_ERRATA_814,
  	.fclock_name = "l3instr_ts_gclk_div",
  	.div_ck_name = "l3instr_ts_gclk_div",
  	.conv_table = dra752_adc_to_temp,
drivers/thermal/ti-soc-thermal/ti-bandgap.c +36 -1
index 74c0e34..baf822e 100644
@@ -119,6 +119,37 @@ exit:
  }
 
  /**
+ * ti_dra7_bandgap_read_temp() - helper function to read dra7 sensor temperature
+ * @bgp: pointer to ti_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Function to read dra7 bandgap sensor temperature. This is done separately
+ * so as to workaround the errata "Bandgap Temperature read Dtemp can be
+ * corrupted" - Errata ID: i814".
+ * Read accesses to registers listed below can be corrupted due to incorrect
+ * resynchronization between clock domains.
+ * Read access to registers below can be corrupted :
+ * CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
+ * CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n
+ *
+ * Return: the register value.
+ */
+static u32 ti_dra7_bandgap_read_temp(struct ti_bandgap *bgp,  u32 reg)
+{
+	u32 val1, val2;
+
+	val1 = ti_bandgap_readl(bgp, reg);
+	val2 = ti_bandgap_readl(bgp, reg);
+
+/* If both times we read the same value then that is right */
+	if (val1 == val2)
+		return val1;
+
+/* if val1 and val2 are different read it third time */
+	return ti_bandgap_readl(bgp, reg);
+}
+
+/**
   * ti_bandgap_read_temp() - helper function to read sensor temperature
   * @bgp: pointer to ti_bandgap structure
   * @id: bandgap sensor id
@@ -148,7 +179,11 @@ static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
  	}
 
  	/* read temperature */
-	temp = ti_bandgap_readl(bgp, reg);
+	if (TI_BANDGAP_HAS(bgp, ERRATA_814))
+		temp = ti_dra7_bandgap_read_temp(bgp, reg);
+	else
+		temp = ti_bandgap_readl(bgp, reg);
+
  	temp &= tsr->bgap_dtemp_mask;
 
  	if (TI_BANDGAP_HAS(bgp, FREEZE_BIT))
drivers/thermal/ti-soc-thermal/ti-bandgap.h +4 -0
index b3adf72..b2da3fc 100644
@@ -318,6 +318,9 @@ struct ti_temp_sensor {
   * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
   *	a history buffer of temperatures.
   *
+ * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
+ *	has Errata 814
+ *
   * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
   *      specific feature (above) or not. Return non-zero, if yes.
   */
@@ -331,6 +334,7 @@ struct ti_temp_sensor {
  #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
  #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
  #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_ERRATA_814		BIT(10)
  #define TI_BANDGAP_HAS(b, f)			\
  			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 
maintainer
#2 lore raw

Hello K,

Quoted 22 lines · Keerthy

Hi Eduardo,

Quoted 19 lines · Keerthy

Bandgap Temperature read Dtemp can be corrupted

DESCRIPTION
Read accesses to registers listed below can be corrupted due to incorrect resynchronization between clock domains.

Read access to registers below can be corrupted :
• CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
• CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n

WORKAROUND
Multiple reads to CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA[9:0]:
BGAP_DTEMPMPU/GPU/CORE/DSPEVE/IVA is needed to discard false value and read right value:
1. Perform two successive reads to BGAP_DTEMP bit field.
(a) If read1 returns Val1 and read2 returns Val1, then right value is Val1.
(b) If read1 returns Val1, read 2 returns Val2, a third read is needed.
2. Perform third read
(a) If read3 returns Val2 then right value is Val2.
(b) If read3 returns Val3, then right value is Val3.

The third read description (b) is misleading/confusing. Does it mean third read value is always correct or do we need to compare against val1 and val2? if val3 != val2 && val3 != val1, which one is correct? none?

Quoted 2 lines
Quoted 1 line

Thanks for the detailed errata description.

Quoted 2 lines

A gentle ping on this.

Sorry for the late answer. (minor) Comment below:

Quoted 44 lines
Quoted 44 lines

---

Read all the temperatures from the 5 sensors and saw that they were sane with time.

Ran cpuloadgen and saw that temperatures rising on all the sensors and cooled down as soon as the load was reduced.

 .../thermal/ti-soc-thermal/dra752-thermal-data.c   |  3 +-
 drivers/thermal/ti-soc-thermal/ti-bandgap.c        | 37 +++++++++++++++++++++-
 drivers/thermal/ti-soc-thermal/ti-bandgap.h        |  4 +++
 3 files changed, 42 insertions(+), 2 deletions(-)
drivers/thermal/ti-soc-thermal/dra752-thermal-data.c +2 -1
index a492927..58b5c66 100644
@@ -420,7 +420,8 @@ const struct ti_bandgap_data dra752_data = {
 			TI_BANDGAP_FEATURE_FREEZE_BIT |
 			TI_BANDGAP_FEATURE_TALERT |
 			TI_BANDGAP_FEATURE_COUNTER_DELAY |
-			TI_BANDGAP_FEATURE_HISTORY_BUFFER,
+			TI_BANDGAP_FEATURE_HISTORY_BUFFER |
+			TI_BANDGAP_FEATURE_ERRATA_814,
 	.fclock_name = "l3instr_ts_gclk_div",
 	.div_ck_name = "l3instr_ts_gclk_div",
 	.conv_table = dra752_adc_to_temp,
drivers/thermal/ti-soc-thermal/ti-bandgap.c +8 -0
index 74c0e34..baf822e 100644
@@ -119,6 +119,37 @@ exit:
 }
 
 /**
+ * ti_dra7_bandgap_read_temp() - helper function to read dra7 sensor temperature
+ * @bgp: pointer to ti_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Function to read dra7 bandgap sensor temperature. This is done separately
+ * so as to workaround the errata "Bandgap Temperature read Dtemp can be
+ * corrupted" - Errata ID: i814".
+ * Read accesses to registers listed below can be corrupted due to incorrect
Quoted 8 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 137

Quoted 8 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +8 -0
+ * resynchronization between clock domains.
+ * Read access to registers below can be corrupted :
+ * CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
+ * CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n
+ *
+ * Return: the register value.
+ */
+static u32 ti_dra7_bandgap_read_temp(struct ti_bandgap *bgp,  u32 reg)

Are you sure this bug affects only DRA7? I would prefer you name this not specific to soc version. Maybe bind it to the errata:

+static u32 ti_i814_bandgap_read_temp(struct ti_bandgap *bgp, u32 reg)

Quoted 7 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 144

Quoted 7 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +7 -0
+{
+	u32 val1, val2;
+
+	val1 = ti_bandgap_readl(bgp, reg);
+	val2 = ti_bandgap_readl(bgp, reg);
+
+/* If both times we read the same value then that is right */

Please, indent the comments too.

Quoted 4 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 148

Quoted 4 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +4 -0
+	if (val1 == val2)
+		return val1;
+
+/* if val1 and val2 are different read it third time */

ditto.

Quoted 1 line

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 149

Quoted 1 line
drivers/thermal/ti-soc-thermal/ti-bandgap.c +1 -0
+	return ti_bandgap_readl(bgp, reg);

Actually, if I understood the errata description correctly, you need to:
1. read a third time (val3)
2. compare val3 against val2, and return val2 if they are same

If they are different, the errata is not clear. Can you please clarify?

Quoted 42 lines
Quoted 42 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +8 -1
+}
+
+/**
  * ti_bandgap_read_temp() - helper function to read sensor temperature
  * @bgp: pointer to ti_bandgap structure
  * @id: bandgap sensor id
@@ -148,7 +179,11 @@ static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
 	}
 
 	/* read temperature */
-	temp = ti_bandgap_readl(bgp, reg);
+	if (TI_BANDGAP_HAS(bgp, ERRATA_814))
+		temp = ti_dra7_bandgap_read_temp(bgp, reg);
+	else
+		temp = ti_bandgap_readl(bgp, reg);
+
 	temp &= tsr->bgap_dtemp_mask;
 
 	if (TI_BANDGAP_HAS(bgp, FREEZE_BIT))
drivers/thermal/ti-soc-thermal/ti-bandgap.h +4 -0
index b3adf72..b2da3fc 100644
@@ -318,6 +318,9 @@ struct ti_temp_sensor {
  * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
  *	a history buffer of temperatures.
  *
+ * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
+ *	has Errata 814
+ *
  * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
  *      specific feature (above) or not. Return non-zero, if yes.
  */
@@ -331,6 +334,7 @@ struct ti_temp_sensor {
 #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
 #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_ERRATA_814		BIT(10)
 #define TI_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 
#3 lore raw

Hi Eduardo,

Thanks for the review comments.

Quoted 26 lines · Eduardo Valentin

Hello K,

Quoted 22 lines · Keerthy

Hi Eduardo,

Quoted 19 lines · Keerthy

Bandgap Temperature read Dtemp can be corrupted

DESCRIPTION
Read accesses to registers listed below can be corrupted due to incorrect resynchronization between clock domains.

Read access to registers below can be corrupted :
• CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
• CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n

WORKAROUND
Multiple reads to CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA[9:0]:
BGAP_DTEMPMPU/GPU/CORE/DSPEVE/IVA is needed to discard false value and read right value:
1. Perform two successive reads to BGAP_DTEMP bit field.
(a) If read1 returns Val1 and read2 returns Val1, then right value is Val1.
(b) If read1 returns Val1, read 2 returns Val2, a third read is needed.
2. Perform third read
(a) If read3 returns Val2 then right value is Val2.
(b) If read3 returns Val3, then right value is Val3.

Quoted 3 lines

The third read description (b) is misleading/confusing. Does it mean third read value is always correct or do we need to compare against val1 and val2? if val3 != val2 && val3 != val1, which one is correct? none?

That is all is given in the errata description. Seems to assume third one is right value always.

Quoted 58 lines
Quoted 3 lines
Quoted 2 lines

Thanks for the detailed errata description.

Quoted 2 lines

A gentle ping on this.

Sorry for the late answer. (minor) Comment below:

Quoted 47 lines
Quoted 47 lines

---

Read all the temperatures from the 5 sensors and saw that they were sane with time.

Ran cpuloadgen and saw that temperatures rising on all the sensors and cooled down as soon as the load was reduced.

  .../thermal/ti-soc-thermal/dra752-thermal-data.c   |  3 +-
  drivers/thermal/ti-soc-thermal/ti-bandgap.c        | 37 +++++++++++++++++++++-
  drivers/thermal/ti-soc-thermal/ti-bandgap.h        |  4 +++
  3 files changed, 42 insertions(+), 2 deletions(-)
drivers/thermal/ti-soc-thermal/dra752-thermal-data.c +2 -1
index a492927..58b5c66 100644
@@ -420,7 +420,8 @@ const struct ti_bandgap_data dra752_data = {
  			TI_BANDGAP_FEATURE_FREEZE_BIT |
  			TI_BANDGAP_FEATURE_TALERT |
  			TI_BANDGAP_FEATURE_COUNTER_DELAY |
-			TI_BANDGAP_FEATURE_HISTORY_BUFFER,
+			TI_BANDGAP_FEATURE_HISTORY_BUFFER |
+			TI_BANDGAP_FEATURE_ERRATA_814,
  	.fclock_name = "l3instr_ts_gclk_div",
  	.div_ck_name = "l3instr_ts_gclk_div",
  	.conv_table = dra752_adc_to_temp,
drivers/thermal/ti-soc-thermal/ti-bandgap.c +11 -0
index 74c0e34..baf822e 100644
@@ -119,6 +119,37 @@ exit:
  }
 
  /**
+ * ti_dra7_bandgap_read_temp() - helper function to read dra7 sensor temperature
+ * @bgp: pointer to ti_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Function to read dra7 bandgap sensor temperature. This is done separately
+ * so as to workaround the errata "Bandgap Temperature read Dtemp can be
+ * corrupted" - Errata ID: i814".
+ * Read accesses to registers listed below can be corrupted due to incorrect
+ * resynchronization between clock domains.
+ * Read access to registers below can be corrupted :
+ * CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
Quoted 8 lines
Quoted 5 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 137

Quoted 5 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +5 -0
+ * CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n
+ *
+ * Return: the register value.
+ */
+static u32 ti_dra7_bandgap_read_temp(struct ti_bandgap *bgp,  u32 reg)

Are you sure this bug affects only DRA7? I would prefer you name this not specific to soc version. Maybe bind it to the errata:

AFAIK it is impacting DRA7 not sure of OMAP5 and OMAP4. Okay I can name it on the errata number. Yeah makes sense too. If other versions tend to have this then we can just add this errata feature to them also.

Quoted 12 lines

+static u32 ti_i814_bandgap_read_temp(struct ti_bandgap *bgp, u32 reg)

Quoted 7 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 144

Quoted 7 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +7 -0
+{
+	u32 val1, val2;
+
+	val1 = ti_bandgap_readl(bgp, reg);
+	val2 = ti_bandgap_readl(bgp, reg);
+
+/* If both times we read the same value then that is right */

Please, indent the comments too.

Okay.

Quoted 7 lines
Quoted 5 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 148

Quoted 5 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +4 -0
+	if (val1 == val2)
+		return val1;
+
+/* if val1 and val2 are different read it third time */

ditto.

Okay

Quoted 8 lines
Quoted 2 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 149

Quoted 2 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +1 -0
+	return ti_bandgap_readl(bgp, reg);

Actually, if I understood the errata description correctly, you need to:
1. read a third time (val3)
2. compare val3 against val2, and return val2 if they are same

If they are different, the errata is not clear. Can you please clarify?

2. Perform third read
(a) If read3 returns Val2 then right value is Val2.
(b) If read3 returns Val3, then right value is Val3.

Which means errata assumes third value is the good value no matter what.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +8 -1
+}
+
+/**
   * ti_bandgap_read_temp() - helper function to read sensor temperature
   * @bgp: pointer to ti_bandgap structure
   * @id: bandgap sensor id
@@ -148,7 +179,11 @@ static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
  	}
 
  	/* read temperature */
-	temp = ti_bandgap_readl(bgp, reg);
+	if (TI_BANDGAP_HAS(bgp, ERRATA_814))
+		temp = ti_dra7_bandgap_read_temp(bgp, reg);
+	else
+		temp = ti_bandgap_readl(bgp, reg);
+
  	temp &= tsr->bgap_dtemp_mask;
 
  	if (TI_BANDGAP_HAS(bgp, FREEZE_BIT))
drivers/thermal/ti-soc-thermal/ti-bandgap.h +3 -0
index b3adf72..b2da3fc 100644
@@ -318,6 +318,9 @@ struct ti_temp_sensor {
   * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
   *	a history buffer of temperatures.
   *
+ * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
+ *	has Errata 814
+ *
   * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
   *      specific feature (above) or not. Return non-zero, if yes.
   */
@@ -331,6 +334,7 @@ struct ti_temp_sensor {
Quoted 8 lines
Quoted 8 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.h struct ti_temp_sensor { · line 340

Quoted 8 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +1 -0
  #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
  #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
  #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_ERRATA_814		BIT(10)
  #define TI_BANDGAP_HAS(b, f)			\
  			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 

-Keerthy
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 40 lines · Keerthy

Hi Eduardo,

Thanks for the review comments.

Quoted 35 lines · Eduardo Valentin

Hello K,

Quoted 31 lines · Keerthy

Hi Eduardo,

Quoted 28 lines · Keerthy

Bandgap Temperature read Dtemp can be corrupted

DESCRIPTION
Read accesses to registers listed below can be corrupted
due to incorrect resynchronization between
clock domains.

Read access to registers below can be corrupted :
• CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0
to 4)
• CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n

WORKAROUND
Multiple reads to
CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA[9:0]:
BGAP_DTEMPMPU/GPU/CORE/DSPEVE/IVA is needed to discard
false value and read right value:
1. Perform two successive reads to BGAP_DTEMP bit
field.
(a) If read1 returns Val1 and read2 returns
Val1, then right value is Val1.
(b) If read1 returns Val1, read 2 returns
Val2, a third read is needed.
2. Perform third read
(a) If read3 returns Val2 then right value
is Val2.
(b) If read3 returns Val3, then right value
is Val3.

Quoted 6 lines
Quoted 3 lines

The third read description (b) is misleading/confusing. Does it mean third read value is always correct or do we need to compare against val1 and val2? if val3 != val2 && val3 != val1, which one is correct? none?

That is all is given in the errata description. Seems to assume third one is right value always.

Got a confirmation from the designer that synchronization shall be complete by third read hence it is the right value irrespective of the first and second..

Quoted 170 lines
Quoted 66 lines
Quoted 4 lines
Quoted 3 lines

Thanks for the detailed errata description.

Quoted 2 lines

A gentle ping on this.

Sorry for the late answer. (minor) Comment below:

Quoted 54 lines
Quoted 54 lines

---

Read all the temperatures from the 5 sensors and saw that they were sane with time.

Ran cpuloadgen and saw that temperatures rising on all the sensors and cooled down as soon as the load was reduced.

  .../thermal/ti-soc-thermal/dra752-thermal-data.c   |  3 +-
  drivers/thermal/ti-soc-thermal/ti-bandgap.c        | 37
+++++++++++++++++++++-
  drivers/thermal/ti-soc-thermal/ti-bandgap.h        |  4 +++
  3 files changed, 42 insertions(+), 2 deletions(-)
drivers/thermal/ti-soc-thermal/dra752-thermal-data.c +2 -1
index a492927..58b5c66 100644
@@ -420,7 +420,8 @@ const struct ti_bandgap_data dra752_data = {
              TI_BANDGAP_FEATURE_FREEZE_BIT |
              TI_BANDGAP_FEATURE_TALERT |
              TI_BANDGAP_FEATURE_COUNTER_DELAY |
-            TI_BANDGAP_FEATURE_HISTORY_BUFFER,
+            TI_BANDGAP_FEATURE_HISTORY_BUFFER |
+            TI_BANDGAP_FEATURE_ERRATA_814,
      .fclock_name = "l3instr_ts_gclk_div",
      .div_ck_name = "l3instr_ts_gclk_div",
      .conv_table = dra752_adc_to_temp,
drivers/thermal/ti-soc-thermal/ti-bandgap.c +1 -0
index 74c0e34..baf822e 100644
@@ -119,6 +119,37 @@ exit:
  }
 
  /**
+ * ti_dra7_bandgap_read_temp() - helper function to read dra7

sensor temperature
+ * @bgp: pointer to ti_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Function to read dra7 bandgap sensor temperature. This is done separately
+ * so as to workaround the errata "Bandgap Temperature read Dtemp can be
+ * corrupted" - Errata ID: i814".
+ * Read accesses to registers listed below can be corrupted due to incorrect
+ * resynchronization between clock domains.
+ * Read access to registers below can be corrupted :
+ * CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

+ * CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n
+ *
+ * Return: the register value.
+ */
+static u32 ti_dra7_bandgap_read_temp(struct ti_bandgap *bgp, u32 reg)

Are you sure this bug affects only DRA7? I would prefer you name this not specific to soc version. Maybe bind it to the errata:

AFAIK it is impacting DRA7 not sure of OMAP5 and OMAP4. Okay I can name it on the errata number. Yeah makes sense too. If other versions tend to have this then we can just add this errata feature to them also.

Quoted 12 lines

+static u32 ti_i814_bandgap_read_temp(struct ti_bandgap *bgp, u32 reg)

Quoted 7 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 144

Quoted 7 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +7 -0
+{
+    u32 val1, val2;
+
+    val1 = ti_bandgap_readl(bgp, reg);
+    val2 = ti_bandgap_readl(bgp, reg);
+
+/* If both times we read the same value then that is right */

Please, indent the comments too.

Okay.

Quoted 7 lines
Quoted 5 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c exit: · line 148

Quoted 5 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +4 -0
+    if (val1 == val2)
+        return val1;
+
+/* if val1 and val2 are different read it third time */

ditto.

Okay

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

+ return ti_bandgap_readl(bgp, reg);

Actually, if I understood the errata description correctly, you need to:
1. read a third time (val3)
2. compare val3 against val2, and return val2 if they are same

If they are different, the errata is not clear. Can you please clarify?

2. Perform third read
(a) If read3 returns Val2 then right value is Val2.
(b) If read3 returns Val3, then right value is Val3.

Which means errata assumes third value is the good value no matter what.

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +3 -0
+}
+
+/**
   * ti_bandgap_read_temp() - helper function to read sensor

temperature
* @bgp: pointer to ti_bandgap structure
* @id: bandgap sensor id

drivers/thermal/ti-soc-thermal/ti-bandgap.c +5 -1
@@ -148,7 +179,11 @@ static u32 ti_bandgap_read_temp(struct
 ti_bandgap *bgp, int id)
      }
 
      /* read temperature */
-    temp = ti_bandgap_readl(bgp, reg);
+    if (TI_BANDGAP_HAS(bgp, ERRATA_814))
+        temp = ti_dra7_bandgap_read_temp(bgp, reg);
+    else
+        temp = ti_bandgap_readl(bgp, reg);
+
      temp &= tsr->bgap_dtemp_mask;
 

if (TI_BANDGAP_HAS(bgp, FREEZE_BIT))

drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -0
index b3adf72..b2da3fc 100644
@@ -318,6 +318,9 @@ struct ti_temp_sensor {
   * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap

device features
* a history buffer of temperatures.
*
+ * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
+ * has Errata 814
+ *
* TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is
capable of a
* specific feature (above) or not. Return non-zero, if yes.
*/

drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -0
@@ -331,6 +334,7 @@ struct ti_temp_sensor {
Quoted 8 lines
Quoted 8 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.h struct ti_temp_sensor { · line 340

Quoted 8 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +1 -0
  #define TI_BANDGAP_FEATURE_FREEZE_BIT        BIT(7)
  #define TI_BANDGAP_FEATURE_COUNTER_DELAY    BIT(8)
  #define TI_BANDGAP_FEATURE_HISTORY_BUFFER    BIT(9)
+#define TI_BANDGAP_FEATURE_ERRATA_814        BIT(10)
  #define TI_BANDGAP_HAS(b, f)            \
              ((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 

-Keerthy