Thank you all for providing inputs and comments on previous versions of
this patchset.
Especially thanks to the (Eduardo, Dmitry, Heiko,....).
This series patchs are working for RK3368 on Rockchip platform.
-----
This patchset are based on linus master branch.
Note: Need add the following thermal patchs for thermal driver before
apply this series patchs.
(the patchs 1) 2) 3) 4) have merged in thermal-soc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git)
1) thermal: rockchip: fix handling of invalid readings
(https://patchwork.kernel.org/patch/6973101/)
2) thermal: rockhip: fix setting thermal shutdown polarity
(https://patchwork.kernel.org/patch/6973131/)
3) dt-bindings: rockchip-thermal: Add the pinctrl states in this document
(https://patchwork.kernel.org/patch/7472021/)
4) thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r
(https://patchwork.kernel.org/patch/7472051/)
5) thermal: rockchip: fix compile error
(https://patchwork.kernel.org/patch/7578271/)
The git log oneline my local branch as follows:
9a3d129 arm64: dts: Enable the Thermal on R88 board
4299e7a arm64: dts: Add main Thermal info to rk3368.dtsi
b95724c arm64: dts: Add the thermal data found on RK3368
c76f603 thermal: rockchip: Support the RK3368 SoCs in thermal drivers
a3f4fdd thermal: rockchip: consistently use int for temperatures
558b4d1ce thermal: rockchip: Add the sort flag for adc value increment or decrement
2438be4 thermal: rockchip: improve the conversion function
74b701d thermal: rockchip: trivial: fix typo in commit
2d85d32 thermal: rockchip: better to compatible the driver for different SoCs
1f2ef67 dt-bindings: rockchip-thermal: Support the RK3368 SoCs compatible
87d83ce thermal: rockchip: fix compile error
c0a5991 thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r
11e4d6c dt-bindings: rockchip-thermal: Add the pinctrl states in this document
6d30517 thermal: rockhip: fix setting thermal shutdown polarity
2b50ab8 thermal: rockchip: fix handling of invalid readings
ce5c2d2 arm64: fixup for mm renames
ad804a0 Merge branch 'akpm' (patches from Andrew)
ab9f2fa Merge tag 'for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma
75021d2 Merge branch 'for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
6f1da31 Merge branch 'for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
99aaa9c Merge branch 'for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching
----
This series are tested on RK3368 board.
build on arm & x86, and tested the r88 board.
Sorry for the v3 series patchs compiling error.
root@rk3368_32:/ # cat proc/version
Linux version 4.3.0+ (wxt@ubuntu) (gcc version 4.9 20140514 (prerelease) (GCC) ) #6 SMP PREEMPT Mon Nov 9 12:35:52 CST 2015
while true;do ls >/dev/null; done&
while true; do grep "" /sys/class/thermal/thermal_zone[0-1]/temp; sleep
.5; done &
You can get the temperature form sensors.
/sys/class/thermal/thermal_zone1/temp:30000
/sys/class/thermal/thermal_zone0/temp:22500
/sys/class/thermal/thermal_zone1/temp:30000
/sys/class/thermal/thermal_zone0/temp:25000
/sys/class/thermal/thermal_zone1/temp:30000
/sys/class/thermal/thermal_zone0/temp:25000
/sys/class/thermal/thermal_zone1/temp:32500
/sys/class/thermal/thermal_zone0/temp:25000
/sys/class/thermal/thermal_zone1/temp:30000
/sys/class/thermal/thermal_zone0/temp:27500
/sys/class/thermal/thermal_zone1/temp:30000
/sys/class/thermal/thermal_zone0/temp:27500
/sys/class/thermal/thermal_zone1/temp:32500
/sys/class/thermal/thermal_zone0/temp:27500
....
Changes in v4:
- rename the flag as mode.
- with enum type instead of bool type.
- fix the warning from the print message.
- :%s/sort_flag/mode.
- rename the 'drivers' to 'driver' in subject.
- Missing the ";" caused compile error.
Changes in v3:
- As Eduardo comments, let's change data_mask type with 'u32' instead of
'unsigned long'.
- rename the flag-> sort_flag.
- fix the indentation.
- change the pr_err information.
- As the Patch v2 comments, Add a new patch to fix it.
- :%s/flag/sort_flag
- fix the rk3368 sort_flag as increment mode.
Changes in v2:
- As Eduardo comments on patch v1, split in smaller changes.
- make the conversion table in as a parameter both code_to_temp
and temp_to_code function.
- remove some unused, completed on other patchs.
- fix a copy wrong name.
Changes in v1:
- %s/thermal/rockchip-thermal in subject.
- add a new patch for thermal driver to support more SoCs.
- As Dmitry comment, make the conversion table in as a parameterm.
- support the opt gpio pinctrl state.
Caesar Wang (10):
dt-bindings: rockchip-thermal: Support the RK3368 SoCs compatible
thermal: rockchip: better to compatible the driver for different SoCs
thermal: rockchip: trivial: fix typo in commit
thermal: rockchip: improve the conversion function
thermal: rockchip: Add the sort mode for adc value increment or
decrement
thermal: rockchip: consistently use int for temperatures
thermal: rockchip: Support the RK3368 SoCs in thermal driver
arm64: dts: Add the thermal data found on RK3368
arm64: dts: Add main Thermal info to rk3368.dtsi
arm64: dts: Enable the Thermal on R88 board
.../bindings/thermal/rockchip-thermal.txt | 4 +-
arch/arm64/boot/dts/rockchip/rk3368-r88.dts | 6 +
arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi | 112 +++++++
arch/arm64/boot/dts/rockchip/rk3368.dtsi | 36 +++
drivers/thermal/rockchip_thermal.c | 328 +++++++++++++++------
5 files changed, 397 insertions(+), 89 deletions(-)
create mode 100644 arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi
--
1.9.1
This patchset attempts to new compatible for thermal founding
on RK3368 SoCs.
Signed-off-by: Caesar Wang <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
Changes in v1:
- %s/thermal/rockchip-thermal in subject.
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
index b38200d..0dfa60d 100644
--- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
@@ -1,7 +1,9 @@
* Temperature Sensor ADC (TSADC) on rockchip SoCs
Required properties:
-- compatible : "rockchip,rk3288-tsadc"
+- compatible : should be "rockchip,<name>-tsadc"
+ "rockchip,rk3288-tsadc": found on RK3288 SoCs
+ "rockchip,rk3368-tsadc": found on RK3368 SoCs
- reg : physical base address of the controller and length of memory mapped
region.
- interrupts : The interrupt number to the cpu. The interrupt specifier format
--
1.9.1
The current driver is default to register the two thermal sensors
in probe since some SoCs maybe only have one sensor for thermal.
In some cases, the channel 0 is not always the cpu or gpu sensor.
So add the channel can be configured for sensors.
Signed-off-by: Caesar Wang <[email protected]>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
Changes in v1:
- add a new patch for thermal driver to support more SoCs.
drivers/thermal/rockchip_thermal.c | 86 +++++++++++++++++++++-----------------
1 file changed, 48 insertions(+), 38 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 9787e8a..e72a69d 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -45,15 +45,25 @@ enum tshut_polarity {
};
/**
- * The system has three Temperature Sensors. channel 0 is reserved,
- * channel 1 is for CPU, and channel 2 is for GPU.
+ * The system has two Temperature Sensors.
+ * sensor0 is for CPU, and sensor1 is for GPU.
*/
enum sensor_id {
- SENSOR_CPU = 1,
+ SENSOR_CPU = 0,
SENSOR_GPU,
};
+/**
+ * The max sensors is two in rockchip SoCs.
+ * Two sensors: CPU and GPU sensor.
+ */
+#define SOC_MAX_SENSORS 2
+
struct rockchip_tsadc_chip {
+ /* The sensor id of chip correspond to the ADC channel */
+ int chn_id[SOC_MAX_SENSORS];
+ int chn_num;
+
/* The hardware-controlled tshut property */
long tshut_temp;
enum tshut_mode tshut_mode;
@@ -73,17 +83,15 @@ struct rockchip_tsadc_chip {
struct rockchip_thermal_sensor {
struct rockchip_thermal_data *thermal;
struct thermal_zone_device *tzd;
- enum sensor_id id;
+ int id;
};
-#define NUM_SENSORS 2 /* Ignore unused sensor 0 */
-
struct rockchip_thermal_data {
const struct rockchip_tsadc_chip *chip;
struct platform_device *pdev;
struct reset_control *reset;
- struct rockchip_thermal_sensor sensors[NUM_SENSORS];
+ struct rockchip_thermal_sensor sensors[SOC_MAX_SENSORS];
struct clk *clk;
struct clk *pclk;
@@ -95,7 +103,7 @@ struct rockchip_thermal_data {
enum tshut_polarity tshut_polarity;
};
-/* TSADC V2 Sensor info define: */
+/* TSADC Sensor info define: */
#define TSADCV2_AUTO_CON 0x04
#define TSADCV2_INT_EN 0x08
#define TSADCV2_INT_PD 0x0c
@@ -318,6 +326,10 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
}
static const struct rockchip_tsadc_chip rk3288_tsadc_data = {
+ .chn_id[SENSOR_CPU] = 1, /* cpu sensor is channel 1 */
+ .chn_id[SENSOR_GPU] = 2, /* gpu sensor is channel 2 */
+ .chn_num = 2, /* two channels for tsadc */
+
.tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */
.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
.tshut_temp = 95000,
@@ -357,7 +369,7 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev)
thermal->chip->irq_ack(thermal->regs);
- for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
+ for (i = 0; i < thermal->chip->chn_num; i++)
thermal_zone_device_update(thermal->sensors[i].tzd);
return IRQ_HANDLED;
@@ -442,7 +454,7 @@ static int
rockchip_thermal_register_sensor(struct platform_device *pdev,
struct rockchip_thermal_data *thermal,
struct rockchip_thermal_sensor *sensor,
- enum sensor_id id)
+ int id)
{
const struct rockchip_tsadc_chip *tsadc = thermal->chip;
int error;
@@ -481,7 +493,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
const struct of_device_id *match;
struct resource *res;
int irq;
- int i;
+ int i, j;
int error;
match = of_match_node(of_rockchip_thermal_match, np);
@@ -556,22 +568,19 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
thermal->chip->initialize(thermal->regs, thermal->tshut_polarity);
- error = rockchip_thermal_register_sensor(pdev, thermal,
- &thermal->sensors[0],
- SENSOR_CPU);
- if (error) {
- dev_err(&pdev->dev,
- "failed to register CPU thermal sensor: %d\n", error);
- goto err_disable_pclk;
- }
-
- error = rockchip_thermal_register_sensor(pdev, thermal,
- &thermal->sensors[1],
- SENSOR_GPU);
- if (error) {
- dev_err(&pdev->dev,
- "failed to register GPU thermal sensor: %d\n", error);
- goto err_unregister_cpu_sensor;
+ for (i = 0; i < thermal->chip->chn_num; i++) {
+ error = rockchip_thermal_register_sensor(pdev, thermal,
+ &thermal->sensors[i],
+ thermal->chip->chn_id[i]);
+ if (error) {
+ dev_err(&pdev->dev,
+ "failed to register sensor[%d] : error = %d\n",
+ i, error);
+ for (j = 0; j < i; j++)
+ thermal_zone_of_sensor_unregister(&pdev->dev,
+ thermal->sensors[j].tzd);
+ goto err_disable_pclk;
+ }
}
error = devm_request_threaded_irq(&pdev->dev, irq, NULL,
@@ -581,22 +590,23 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
if (error) {
dev_err(&pdev->dev,
"failed to request tsadc irq: %d\n", error);
- goto err_unregister_gpu_sensor;
+ goto err_unregister_sensor;
}
thermal->chip->control(thermal->regs, true);
- for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
+ for (i = 0; i < thermal->chip->chn_num; i++)
rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
platform_set_drvdata(pdev, thermal);
return 0;
-err_unregister_gpu_sensor:
- thermal_zone_of_sensor_unregister(&pdev->dev, thermal->sensors[1].tzd);
-err_unregister_cpu_sensor:
- thermal_zone_of_sensor_unregister(&pdev->dev, thermal->sensors[0].tzd);
+err_unregister_sensor:
+ while (i--)
+ thermal_zone_of_sensor_unregister(&pdev->dev,
+ thermal->sensors[i].tzd);
+
err_disable_pclk:
clk_disable_unprepare(thermal->pclk);
err_disable_clk:
@@ -610,7 +620,7 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev);
int i;
- for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) {
+ for (i = 0; i < thermal->chip->chn_num; i++) {
struct rockchip_thermal_sensor *sensor = &thermal->sensors[i];
rockchip_thermal_toggle_sensor(sensor, false);
@@ -631,7 +641,7 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev);
int i;
- for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
+ for (i = 0; i < thermal->chip->chn_num; i++)
rockchip_thermal_toggle_sensor(&thermal->sensors[i], false);
thermal->chip->control(thermal->regs, false);
@@ -663,8 +673,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
thermal->chip->initialize(thermal->regs, thermal->tshut_polarity);
- for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) {
- enum sensor_id id = thermal->sensors[i].id;
+ for (i = 0; i < thermal->chip->chn_num; i++) {
+ int id = thermal->sensors[i].id;
thermal->chip->set_tshut_mode(id, thermal->regs,
thermal->tshut_mode);
@@ -674,7 +684,7 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
thermal->chip->control(thermal->regs, true);
- for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
+ for (i = 0; i < thermal->chip->chn_num; i++)
rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
pinctrl_pm_select_default_state(dev);
--
1.9.1
Signed-off-by: Caesar Wang <[email protected]>
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- As Eduardo comments on patch v1, split in smaller changes.
Changes in v1: None
drivers/thermal/rockchip_thermal.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index e72a69d..907a317 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -237,15 +237,19 @@ static int rk_tsadcv2_code_to_temp(u32 code, int *temp)
}
/**
- * rk_tsadcv2_initialize - initialize TASDC Controller
- * (1) Set TSADCV2_AUTO_PERIOD, configure the interleave between
- * every two accessing of TSADC in normal operation.
- * (2) Set TSADCV2_AUTO_PERIOD_HT, configure the interleave between
- * every two accessing of TSADC after the temperature is higher
- * than COM_SHUT or COM_INT.
- * (3) Set TSADCV2_HIGH_INT_DEBOUNCE and TSADC_HIGHT_TSHUT_DEBOUNCE,
- * if the temperature is higher than COMP_INT or COMP_SHUT for
- * "debounce" times, TSADC controller will generate interrupt or TSHUT.
+ * rk_tsadcv2_initialize - initialize TASDC Controller.
+ *
+ * (1) Set TSADC_V2_AUTO_PERIOD:
+ * Configure the interleave between every two accessing of
+ * TSADC in normal operation.
+ *
+ * (2) Set TSADCV2_AUTO_PERIOD_HT:
+ * Configure the interleave between every two accessing of
+ * TSADC after the temperature is higher than COM_SHUT or COM_INT.
+ *
+ * (3) Set TSADCV2_HIGH_INT_DEBOUNCE and TSADC_HIGHT_TSHUT_DEBOUNCE:
+ * If the temperature is higher than COMP_INT or COMP_SHUT for
+ * "debounce" times, TSADC controller will generate interrupt or TSHUT.
*/
static void rk_tsadcv2_initialize(void __iomem *regs,
enum tshut_polarity tshut_polarity)
--
1.9.1
We should make the conversion table in as a parameter since the different
SoCs have the different conversionion table.
Signed-off-by: Caesar Wang <[email protected]>
---
Changes in v4: None
Changes in v3:
- As Eduardo comments, let's change data_mask type with 'u32' instead of
'unsigned long'.
Changes in v2:
- make the conversion table in as a parameter both code_to_temp
and temp_to_code function.
Changes in v1:
- As Dmitry comment, make the conversion table in as a parameterm.
drivers/thermal/rockchip_thermal.c | 82 +++++++++++++++++++++++++-------------
1 file changed, 55 insertions(+), 27 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 907a317..bbf082c 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -59,6 +59,16 @@ enum sensor_id {
*/
#define SOC_MAX_SENSORS 2
+struct chip_tsadc_table {
+ const struct tsadc_table *id;
+
+ /* the array table size*/
+ unsigned int length;
+
+ /* that analogic mask data */
+ u32 data_mask;
+};
+
struct rockchip_tsadc_chip {
/* The sensor id of chip correspond to the ADC channel */
int chn_id[SOC_MAX_SENSORS];
@@ -75,9 +85,14 @@ struct rockchip_tsadc_chip {
void (*control)(void __iomem *reg, bool on);
/* Per-sensor methods */
- int (*get_temp)(int chn, void __iomem *reg, int *temp);
- void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
+ int (*get_temp)(struct chip_tsadc_table table,
+ int chn, void __iomem *reg, int *temp);
+ void (*set_tshut_temp)(struct chip_tsadc_table table,
+ int chn, void __iomem *reg, long temp);
void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
+
+ /* Per-table methods */
+ struct chip_tsadc_table table;
};
struct rockchip_thermal_sensor {
@@ -173,21 +188,22 @@ static const struct tsadc_table v2_code_table[] = {
{3421, 125000},
};
-static u32 rk_tsadcv2_temp_to_code(long temp)
+static u32 rk_tsadcv2_temp_to_code(struct chip_tsadc_table table,
+ long temp)
{
int high, low, mid;
low = 0;
- high = ARRAY_SIZE(v2_code_table) - 1;
+ high = table.length - 1;
mid = (high + low) / 2;
- if (temp < v2_code_table[low].temp || temp > v2_code_table[high].temp)
+ if (temp < table.id[low].temp || temp > table.id[high].temp)
return 0;
while (low <= high) {
- if (temp == v2_code_table[mid].temp)
- return v2_code_table[mid].code;
- else if (temp < v2_code_table[mid].temp)
+ if (temp == table.id[mid].temp)
+ return table.id[mid].code;
+ else if (temp < table.id[mid].temp)
high = mid - 1;
else
low = mid + 1;
@@ -197,25 +213,26 @@ static u32 rk_tsadcv2_temp_to_code(long temp)
return 0;
}
-static int rk_tsadcv2_code_to_temp(u32 code, int *temp)
+static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
+ int *temp)
{
unsigned int low = 1;
- unsigned int high = ARRAY_SIZE(v2_code_table) - 1;
+ unsigned int high = table.length - 1;
unsigned int mid = (low + high) / 2;
unsigned int num;
unsigned long denom;
- BUILD_BUG_ON(ARRAY_SIZE(v2_code_table) < 2);
+ WARN_ON(table.length < 2);
- code &= TSADCV2_DATA_MASK;
- if (code < v2_code_table[high].code)
+ code &= table.data_mask;
+ if (code < table.id[high].code)
return -EAGAIN; /* Incorrect reading */
while (low <= high) {
- if (code >= v2_code_table[mid].code &&
- code < v2_code_table[mid - 1].code)
+ if (code >= table.id[mid].code &&
+ code < table.id[mid - 1].code)
break;
- else if (code < v2_code_table[mid].code)
+ else if (code < table.id[mid].code)
low = mid + 1;
else
high = mid - 1;
@@ -228,10 +245,10 @@ static int rk_tsadcv2_code_to_temp(u32 code, int *temp)
* temperature between 2 table entries is linear and interpolate
* to produce less granular result.
*/
- num = v2_code_table[mid].temp - v2_code_table[mid - 1].temp;
- num *= v2_code_table[mid - 1].code - code;
- denom = v2_code_table[mid - 1].code - v2_code_table[mid].code;
- *temp = v2_code_table[mid - 1].temp + (num / denom);
+ num = table.id[mid].temp - v2_code_table[mid - 1].temp;
+ num *= table.id[mid - 1].code - code;
+ denom = table.id[mid - 1].code - table.id[mid].code;
+ *temp = table.id[mid - 1].temp + (num / denom);
return 0;
}
@@ -291,20 +308,22 @@ static void rk_tsadcv2_control(void __iomem *regs, bool enable)
writel_relaxed(val, regs + TSADCV2_AUTO_CON);
}
-static int rk_tsadcv2_get_temp(int chn, void __iomem *regs, int *temp)
+static int rk_tsadcv2_get_temp(struct chip_tsadc_table table,
+ int chn, void __iomem *regs, int *temp)
{
u32 val;
val = readl_relaxed(regs + TSADCV2_DATA(chn));
- return rk_tsadcv2_code_to_temp(val, temp);
+ return rk_tsadcv2_code_to_temp(table, val, temp);
}
-static void rk_tsadcv2_tshut_temp(int chn, void __iomem *regs, long temp)
+static void rk_tsadcv2_tshut_temp(struct chip_tsadc_table table,
+ int chn, void __iomem *regs, long temp)
{
u32 tshut_value, val;
- tshut_value = rk_tsadcv2_temp_to_code(temp);
+ tshut_value = rk_tsadcv2_temp_to_code(table, temp);
writel_relaxed(tshut_value, regs + TSADCV2_COMP_SHUT(chn));
/* TSHUT will be valid */
@@ -344,6 +363,12 @@ static const struct rockchip_tsadc_chip rk3288_tsadc_data = {
.get_temp = rk_tsadcv2_get_temp,
.set_tshut_temp = rk_tsadcv2_tshut_temp,
.set_tshut_mode = rk_tsadcv2_tshut_mode,
+
+ .table = {
+ .id = v2_code_table,
+ .length = ARRAY_SIZE(v2_code_table),
+ .data_mask = TSADCV2_DATA_MASK,
+ },
};
static const struct of_device_id of_rockchip_thermal_match[] = {
@@ -386,7 +411,8 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
int retval;
- retval = tsadc->get_temp(sensor->id, thermal->regs, out_temp);
+ retval = tsadc->get_temp(tsadc->table,
+ sensor->id, thermal->regs, out_temp);
dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n",
sensor->id, *out_temp, retval);
@@ -464,7 +490,8 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
int error;
tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode);
- tsadc->set_tshut_temp(id, thermal->regs, thermal->tshut_temp);
+ tsadc->set_tshut_temp(tsadc->table, id, thermal->regs,
+ thermal->tshut_temp);
sensor->thermal = thermal;
sensor->id = id;
@@ -682,7 +709,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
thermal->chip->set_tshut_mode(id, thermal->regs,
thermal->tshut_mode);
- thermal->chip->set_tshut_temp(id, thermal->regs,
+ thermal->chip->set_tshut_temp(thermal->chip->table,
+ id, thermal->regs,
thermal->tshut_temp);
}
--
1.9.1
The conversion table has the adc value and temperature.
In fact, the adc value only has the increment or decrement mode in
conversion table.
Moment, we can add the sort mode to be better support the *code_to_temp*
for differenr SoCs.
Signed-off-by: Caesar Wang <[email protected]>
---
Changes in v4:
- rename the flag as mode.
- with enum type instead of bool type.
Changes in v3:
- rename the flag-> sort_flag.
- fix the indentation.
- change the pr_err information.
Changes in v2: None
Changes in v1: None
drivers/thermal/rockchip_thermal.c | 68 +++++++++++++++++++++++++++++---------
1 file changed, 53 insertions(+), 15 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index bbf082c..7c5b784 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -54,6 +54,16 @@ enum sensor_id {
};
/**
+* The conversion table has the adc value and temperature.
+* ADC_DECREMENT is the adc value decremnet.(e.g. v2_code_table)
+* ADC_INCREMNET is the adc value incremnet.(e.g. v3_code_table)
+*/
+enum adc_sort_mode {
+ ADC_DECREMENT = 0,
+ ADC_INCREMENT,
+};
+
+/**
* The max sensors is two in rockchip SoCs.
* Two sensors: CPU and GPU sensor.
*/
@@ -67,6 +77,9 @@ struct chip_tsadc_table {
/* that analogic mask data */
u32 data_mask;
+
+ /* the sort mode is adc value that increment or decrement in table */
+ enum adc_sort_mode mode;
};
struct rockchip_tsadc_chip {
@@ -224,19 +237,43 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
WARN_ON(table.length < 2);
- code &= table.data_mask;
- if (code < table.id[high].code)
- return -EAGAIN; /* Incorrect reading */
-
- while (low <= high) {
- if (code >= table.id[mid].code &&
- code < table.id[mid - 1].code)
- break;
- else if (code < table.id[mid].code)
- low = mid + 1;
- else
- high = mid - 1;
- mid = (low + high) / 2;
+ switch (table.mode) {
+ case ADC_DECREMENT:
+ code &= table.data_mask;
+ if (code < table.id[high].code)
+ return -EAGAIN; /* Incorrect reading */
+
+ while (low <= high) {
+ if (code >= table.id[mid].code &&
+ code < table.id[mid - 1].code)
+ break;
+ else if (code < table.id[mid].code)
+ low = mid + 1;
+ else
+ high = mid - 1;
+
+ mid = (low + high) / 2;
+ }
+ break;
+ case ADC_INCREMENT:
+ code &= table.data_mask;
+ if (code < table.id[low].code)
+ return -EAGAIN; /* Incorrect reading */
+
+ while (low <= high) {
+ if (code >= table.id[mid - 1].code &&
+ code < table.id[mid].code)
+ break;
+ else if (code > table.id[mid].code)
+ low = mid + 1;
+ else
+ high = mid - 1;
+
+ mid = (low + high) / 2;
+ }
+ break;
+ default:
+ pr_err("Invalid the conversion table\n");
}
/*
@@ -246,8 +283,8 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
* to produce less granular result.
*/
num = table.id[mid].temp - v2_code_table[mid - 1].temp;
- num *= table.id[mid - 1].code - code;
- denom = table.id[mid - 1].code - table.id[mid].code;
+ num *= abs(table.id[mid - 1].code - code);
+ denom = abs(table.id[mid - 1].code - table.id[mid].code);
*temp = table.id[mid - 1].temp + (num / denom);
return 0;
@@ -368,6 +405,7 @@ static const struct rockchip_tsadc_chip rk3288_tsadc_data = {
.id = v2_code_table,
.length = ARRAY_SIZE(v2_code_table),
.data_mask = TSADCV2_DATA_MASK,
+ .mode = ADC_DECREMENT,
},
};
--
1.9.1
As Temperature is currently represented as int not long in the thermal
framework since use int intead of unsigned long/long to represent
temperature to avoid bogus overheat detection when negative temperature
reported.
Signed-off-by: Caesar Wang <[email protected]>
---
Changes in v4:
- fix the warning from the print message.
Changes in v3:
- As the Patch v2 comments, Add a new patch to fix it.
Changes in v2: None
Changes in v1: None
drivers/thermal/rockchip_thermal.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 7c5b784..73d47f8 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -88,7 +88,7 @@ struct rockchip_tsadc_chip {
int chn_num;
/* The hardware-controlled tshut property */
- long tshut_temp;
+ int tshut_temp;
enum tshut_mode tshut_mode;
enum tshut_polarity tshut_polarity;
@@ -101,7 +101,7 @@ struct rockchip_tsadc_chip {
int (*get_temp)(struct chip_tsadc_table table,
int chn, void __iomem *reg, int *temp);
void (*set_tshut_temp)(struct chip_tsadc_table table,
- int chn, void __iomem *reg, long temp);
+ int chn, void __iomem *reg, int temp);
void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
/* Per-table methods */
@@ -126,7 +126,7 @@ struct rockchip_thermal_data {
void __iomem *regs;
- long tshut_temp;
+ int tshut_temp;
enum tshut_mode tshut_mode;
enum tshut_polarity tshut_polarity;
};
@@ -160,7 +160,7 @@ struct rockchip_thermal_data {
struct tsadc_table {
u32 code;
- long temp;
+ int temp;
};
static const struct tsadc_table v2_code_table[] = {
@@ -202,7 +202,7 @@ static const struct tsadc_table v2_code_table[] = {
};
static u32 rk_tsadcv2_temp_to_code(struct chip_tsadc_table table,
- long temp)
+ int temp)
{
int high, low, mid;
@@ -356,7 +356,7 @@ static int rk_tsadcv2_get_temp(struct chip_tsadc_table table,
}
static void rk_tsadcv2_tshut_temp(struct chip_tsadc_table table,
- int chn, void __iomem *regs, long temp)
+ int chn, void __iomem *regs, int temp)
{
u32 tshut_value, val;
@@ -469,7 +469,7 @@ static int rockchip_configure_from_dt(struct device *dev,
if (of_property_read_u32(np, "rockchip,hw-tshut-temp", &shut_temp)) {
dev_warn(dev,
- "Missing tshut temp property, using default %ld\n",
+ "Missing tshut temp property, using default %d\n",
thermal->chip->tshut_temp);
thermal->tshut_temp = thermal->chip->tshut_temp;
} else {
@@ -477,7 +477,7 @@ static int rockchip_configure_from_dt(struct device *dev,
}
if (thermal->tshut_temp > INT_MAX) {
- dev_err(dev, "Invalid tshut temperature specified: %ld\n",
+ dev_err(dev, "Invalid tshut temperature specified: %d\n",
thermal->tshut_temp);
return -ERANGE;
}
--
1.9.1
The RK3368 SoCs support to 2 channel TS-ADC, the temperature criteria
of each channel can be configurable.
The system has two Temperature Sensors, channel 0 is for CPU,
and channel 1 is for GPU.
Signed-off-by: Caesar Wang <[email protected]>
---
Changes in v4:
- :%s/sort_flag/mode.
- rename the 'drivers' to 'driver' in subject.
Changes in v3:
- :%s/flag/sort_flag
- fix the rk3368 sort_flag as increment mode.
Changes in v2:
- remove some unused, completed on other patchs.
Changes in v1: None
drivers/thermal/rockchip_thermal.c | 72 ++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 73d47f8..e845841 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -1,6 +1,9 @@
/*
* Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
*
+ * Copyright (c) 2015, Fuzhou Rockchip Electronics Co., Ltd
+ * Caesar Wang <[email protected]>
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
@@ -153,6 +156,8 @@ struct rockchip_thermal_data {
#define TSADCV2_INT_PD_CLEAR_MASK ~BIT(8)
#define TSADCV2_DATA_MASK 0xfff
+#define TSADCV3_DATA_MASK 0x3ff
+
#define TSADCV2_HIGHT_INT_DEBOUNCE_COUNT 4
#define TSADCV2_HIGHT_TSHUT_DEBOUNCE_COUNT 4
#define TSADCV2_AUTO_PERIOD_TIME 250 /* msec */
@@ -201,6 +206,45 @@ static const struct tsadc_table v2_code_table[] = {
{3421, 125000},
};
+static const struct tsadc_table v3_code_table[] = {
+ {0, -40000},
+ {106, -40000},
+ {108, -35000},
+ {110, -30000},
+ {112, -25000},
+ {114, -20000},
+ {116, -15000},
+ {118, -10000},
+ {120, -5000},
+ {122, 0},
+ {124, 5000},
+ {126, 10000},
+ {128, 15000},
+ {130, 20000},
+ {132, 25000},
+ {134, 30000},
+ {136, 35000},
+ {138, 40000},
+ {140, 45000},
+ {142, 50000},
+ {144, 55000},
+ {146, 60000},
+ {148, 65000},
+ {150, 70000},
+ {152, 75000},
+ {154, 80000},
+ {156, 85000},
+ {158, 90000},
+ {160, 95000},
+ {162, 100000},
+ {163, 105000},
+ {165, 110000},
+ {167, 115000},
+ {169, 120000},
+ {171, 125000},
+ {TSADCV3_DATA_MASK, 125000},
+};
+
static u32 rk_tsadcv2_temp_to_code(struct chip_tsadc_table table,
int temp)
{
@@ -409,11 +453,39 @@ static const struct rockchip_tsadc_chip rk3288_tsadc_data = {
},
};
+static const struct rockchip_tsadc_chip rk3368_tsadc_data = {
+ .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */
+ .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */
+ .chn_num = 2, /* two channels for tsadc */
+
+ .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */
+ .tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
+ .tshut_temp = 95000,
+
+ .initialize = rk_tsadcv2_initialize,
+ .irq_ack = rk_tsadcv2_irq_ack,
+ .control = rk_tsadcv2_control,
+ .get_temp = rk_tsadcv2_get_temp,
+ .set_tshut_temp = rk_tsadcv2_tshut_temp,
+ .set_tshut_mode = rk_tsadcv2_tshut_mode,
+
+ .table = {
+ .id = v3_code_table,
+ .length = ARRAY_SIZE(v3_code_table),
+ .data_mask = TSADCV3_DATA_MASK,
+ .mode = ADC_INCREMENT,
+ },
+};
+
static const struct of_device_id of_rockchip_thermal_match[] = {
{
.compatible = "rockchip,rk3288-tsadc",
.data = (void *)&rk3288_tsadc_data,
},
+ {
+ .compatible = "rockchip,rk3368-tsadc",
+ .data = (void *)&rk3368_tsadc_data,
+ },
{ /* end */ },
};
MODULE_DEVICE_TABLE(of, of_rockchip_thermal_match);
--
1.9.1
This patchset add the thermal for RK3368 dts,
Since the two CPU clusters, with four CPU core for each cluster,
One cluster is optimized for high-performance(big cluster) and the othe
is optimized for low power(little cluster).
This patch adds the second order for thermal throttle, and the critical
temperature for thermal over-tempeature protection on Software.
Signed-off-by: Caesar Wang <[email protected]>
Acked-by: Eduardo Valentin <[email protected]>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
Changes in v1: None
arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi | 112 +++++++++++++++++++++++
1 file changed, 112 insertions(+)
create mode 100644 arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi
diff --git a/arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi b/arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi
new file mode 100644
index 0000000..a10010f
--- /dev/null
+++ b/arch/arm64/boot/dts/rockchip/rk3368-thermal.dtsi
@@ -0,0 +1,112 @@
+/*
+ * Device Tree Source for RK3368 SoC thermal
+ *
+ * Copyright (c) 2015, Fuzhou Rockchip Electronics Co., Ltd
+ * Caesar Wang <[email protected]>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ * a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ * b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+cpu_thermal: cpu_thermal {
+ polling-delay-passive = <100>; /* milliseconds */
+ polling-delay = <5000>; /* milliseconds */
+
+ thermal-sensors = <&tsadc 0>;
+
+ trips {
+ cpu_alert0: cpu_alert0 {
+ temperature = <75000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ cpu_alert1: cpu_alert1 {
+ temperature = <80000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ cpu_crit: cpu_crit {
+ temperature = <95000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_alert0>;
+ cooling-device =
+ <&cpu_b0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ map1 {
+ trip = <&cpu_alert1>;
+ cooling-device =
+ <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+};
+
+gpu_thermal: gpu_thermal {
+ polling-delay-passive = <100>; /* milliseconds */
+ polling-delay = <5000>; /* milliseconds */
+
+ thermal-sensors = <&tsadc 1>;
+
+ trips {
+ gpu_alert0: gpu_alert0 {
+ temperature = <80000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ gpu_crit: gpu_crit {
+ temperature = <1150000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&gpu_alert0>;
+ cooling-device =
+ <&cpu_b0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+};
--
1.9.1
This patch add the thermal needed info on RK3368.
Meanwhile, support the trips to throttle for thermal.
Signed-off-by: Caesar Wang <[email protected]>
Acked-by: Eduardo Valentin <[email protected]>
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- fix a copy wrong name.
Changes in v1:
- support the opt gpio pinctrl state.
arch/arm64/boot/dts/rockchip/rk3368.dtsi | 36 ++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index cc093a4..83a2bd2 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -45,6 +45,7 @@
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/pinctrl/rockchip.h>
+#include <dt-bindings/thermal/thermal.h>
/ {
compatible = "rockchip,rk3368";
@@ -123,6 +124,8 @@
reg = <0x0 0x0>;
cpu-idle-states = <&cpu_sleep>;
enable-method = "psci";
+
+ #cooling-cells = <2>; /* min followed by max */
};
cpu_l1: cpu@1 {
@@ -155,6 +158,8 @@
reg = <0x0 0x100>;
cpu-idle-states = <&cpu_sleep>;
enable-method = "psci";
+
+ #cooling-cells = <2>; /* min followed by max */
};
cpu_b1: cpu@101 {
@@ -404,6 +409,27 @@
status = "disabled";
};
+ thermal-zones {
+ #include "rk3368-thermal.dtsi"
+ };
+
+ tsadc: tsadc@ff280000 {
+ compatible = "rockchip,rk3368-tsadc";
+ reg = <0x0 0xff280000 0x0 0x100>;
+ interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
+ clock-names = "tsadc", "apb_pclk";
+ resets = <&cru SRST_TSADC>;
+ reset-names = "tsadc-apb";
+ pinctrl-names = "init", "default", "sleep";
+ pinctrl-0 = <&otp_gpio>;
+ pinctrl-1 = <&otp_out>;
+ pinctrl-2 = <&otp_gpio>;
+ #thermal-sensor-cells = <1>;
+ rockchip,hw-tshut-temp = <95000>;
+ status = "disabled";
+ };
+
gmac: ethernet@ff290000 {
compatible = "rockchip,rk3368-gmac";
reg = <0x0 0xff290000 0x0 0x10000>;
@@ -829,6 +855,16 @@
};
};
+ tsadc {
+ otp_gpio: otp-gpio {
+ rockchip,pins = <0 10 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+
+ otp_out: otp-out {
+ rockchip,pins = <0 10 RK_FUNC_1 &pcfg_pull_none>;
+ };
+ };
+
uart0 {
uart0_xfer: uart0-xfer {
rockchip,pins = <2 24 RK_FUNC_1 &pcfg_pull_up>,
--
1.9.1
This patch enable the TS-ADC.
When a thermal temperature is invoked use the CRU to reset the chip
on R88 board. TSHUT is low active on this board.
Signed-off-by: Caesar Wang <[email protected]>
Acked-by: Eduardo Valentin <[email protected]>
---
Changes in v4:
- Missing the ";" caused compile error.
Changes in v3: None
Changes in v2: None
Changes in v1: None
arch/arm64/boot/dts/rockchip/rk3368-r88.dts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/boot/dts/rockchip/rk3368-r88.dts b/arch/arm64/boot/dts/rockchip/rk3368-r88.dts
index 401a812..104cbee 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368-r88.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3368-r88.dts
@@ -336,6 +336,12 @@
status = "okay";
};
+&tsadc {
+ rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
+ rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */
+ status = "okay";
+};
+
&uart2 {
status = "okay";
};
--
1.9.1
On Mon, Nov 09, 2015 at 12:48:52PM +0800, Caesar Wang wrote:
> Thank you all for providing inputs and comments on previous versions of
> this patchset.
> Especially thanks to the (Eduardo, Dmitry, Heiko,....).
>
> This series patchs are working for RK3368 on Rockchip platform.
Do you have any results on existing support? Is the driver still in one
piece for rk3288?
I am planing to send your series in next rc cycles. It won't appear in
linux-next until merge window finishes.
BR,
Eduardo Valentin
On Thu, Nov 12, 2015 at 10:29:52AM -0800, Eduardo Valentin wrote:
> On Mon, Nov 09, 2015 at 12:48:52PM +0800, Caesar Wang wrote:
> > Thank you all for providing inputs and comments on previous versions of
> > this patchset.
> > Especially thanks to the (Eduardo, Dmitry, Heiko,....).
> >
> > This series patchs are working for RK3368 on Rockchip platform.
>
> Do you have any results on existing support? Is the driver still in one
> piece for rk3288?
>
> I am planing to send your series in next rc cycles. It won't appear in
> linux-next until merge window finishes.
To be more specific, only patches 1-7. DT bindings go via the right
machine tree.
Thanks
>
> BR,
>
> Eduardo Valentin
Hi Eduardo,
Am Donnerstag, 12. November 2015, 10:29:52 schrieb Eduardo Valentin:
> On Mon, Nov 09, 2015 at 12:48:52PM +0800, Caesar Wang wrote:
> > Thank you all for providing inputs and comments on previous versions of
> > this patchset.
> > Especially thanks to the (Eduardo, Dmitry, Heiko,....).
> >
> > This series patchs are working for RK3368 on Rockchip platform.
>
> Do you have any results on existing support? Is the driver still in one
> piece for rk3288?
I've tested this series on a rk3288-veyron-jerry and everything still
runs just fine, so
Tested-by: Heiko Stuebner <[email protected]>
Eduardo,
在 2015年11月13日 02:29, Eduardo Valentin 写道:
> On Mon, Nov 09, 2015 at 12:48:52PM +0800, Caesar Wang wrote:
>> Thank you all for providing inputs and comments on previous versions of
>> this patchset.
>> Especially thanks to the (Eduardo, Dmitry, Heiko,....).
>>
>> This series patchs are working for RK3368 on Rockchip platform.
> Do you have any results on existing support? Is the driver still in one
> piece for rk3288?
Yep. that's still happy work for rk3288 SoCs.
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp; sleep
.5; done
...
/sys/class/thermal/thermal_zone1/temp:70833
/sys/class/thermal/thermal_zone2/temp:69615
/sys/class/thermal/thermal_zone1/temp:70416
/sys/class/thermal/thermal_zone2/temp:68846
/sys/class/thermal/thermal_zone1/temp:70416
/sys/class/thermal/thermal_zone2/temp:70833
/sys/class/thermal/thermal_zone1/temp:70833
/sys/class/thermal/thermal_zone2/temp:69615
/sys/class/thermal/thermal_zone1/temp:71666
/sys/class/thermal/thermal_zone2/temp:69615
/sys/class/thermal/thermal_zone1/temp:70416
/sys/class/thermal/thermal_zone2/temp:69615
/sys/class/thermal/thermal_zone1/temp:70833
> I am planing to send your series in next rc cycles. It won't appear in
> linux-next until merge window finishes.
Thanks!
>
> BR,
>
> Eduardo Valentin
>
> _______________________________________________
> Linux-rockchip mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
--
caesar wang | software engineer | [email protected]
在 2015年11月13日 06:14, Heiko Stuebner 写道:
> Hi Eduardo,
>
> Am Donnerstag, 12. November 2015, 10:29:52 schrieb Eduardo Valentin:
>> On Mon, Nov 09, 2015 at 12:48:52PM +0800, Caesar Wang wrote:
>>> Thank you all for providing inputs and comments on previous versions of
>>> this patchset.
>>> Especially thanks to the (Eduardo, Dmitry, Heiko,....).
>>>
>>> This series patchs are working for RK3368 on Rockchip platform.
>> Do you have any results on existing support? Is the driver still in one
>> piece for rk3288?
> I've tested this series on a rk3288-veyron-jerry and everything still
> runs just fine, so
>
> Tested-by: Heiko Stuebner <[email protected]>
Thanks Heiko for testing.:-)
>
> _______________________________________________
> Linux-rockchip mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
--
caesar wang | software engineer | [email protected]
Am Donnerstag, 12. November 2015, 10:31:20 schrieb Eduardo Valentin:
> On Thu, Nov 12, 2015 at 10:29:52AM -0800, Eduardo Valentin wrote:
> > On Mon, Nov 09, 2015 at 12:48:52PM +0800, Caesar Wang wrote:
> > > Thank you all for providing inputs and comments on previous versions of
> > > this patchset.
> > > Especially thanks to the (Eduardo, Dmitry, Heiko,....).
> > >
> > > This series patchs are working for RK3368 on Rockchip platform.
> >
> > Do you have any results on existing support? Is the driver still in one
> > piece for rk3288?
> >
> > I am planing to send your series in next rc cycles. It won't appear in
> > linux-next until merge window finishes.
>
> To be more specific, only patches 1-7. DT bindings go via the right
> machine tree.
after seeing these 7 patches in your next-branch, I've now applied the 3
dts patches to my dts64 branch for 4.5 as well.
Thanks
Heiko
Hi Caesar,
On Mon, Nov 09, 2015 at 12:48:58PM +0800, Caesar Wang wrote:
> As Temperature is currently represented as int not long in the thermal
> framework since use int intead of unsigned long/long to represent
> temperature to avoid bogus overheat detection when negative temperature
> reported.
>
> Signed-off-by: Caesar Wang <[email protected]>
>
> ---
>
> Changes in v4:
> - fix the warning from the print message.
>
> Changes in v3:
> - As the Patch v2 comments, Add a new patch to fix it.
>
> Changes in v2: None
> Changes in v1: None
>
> drivers/thermal/rockchip_thermal.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 7c5b784..73d47f8 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -88,7 +88,7 @@ struct rockchip_tsadc_chip {
> int chn_num;
>
> /* The hardware-controlled tshut property */
> - long tshut_temp;
> + int tshut_temp;
> enum tshut_mode tshut_mode;
> enum tshut_polarity tshut_polarity;
>
...
> @@ -126,7 +126,7 @@ struct rockchip_thermal_data {
>
> void __iomem *regs;
>
> - long tshut_temp;
> + int tshut_temp;
FYI, this change is triggering a new warning in Coverity, below:
> enum tshut_mode tshut_mode;
> enum tshut_polarity tshut_polarity;
> };
...
> @@ -477,7 +477,7 @@ static int rockchip_configure_from_dt(struct device *dev,
> }
>
> if (thermal->tshut_temp > INT_MAX) {
CID 1341498: Integer handling issues (CONSTANT_EXPRESSION_RESULT)
"thermal->tshut_temp > 2147483647 /* (int)(~0U >> 1) */" is always false regardless of the values of its operands. This occurs as the logical operand of if.
I don't think this condition is even useful any more, so maybe we should
just kill the 'if' block.
> - dev_err(dev, "Invalid tshut temperature specified: %ld\n",
> + dev_err(dev, "Invalid tshut temperature specified: %d\n",
> thermal->tshut_temp);
> return -ERANGE;
> }
Brian
Hi Caesar,
On Thu, Dec 03, 2015 at 08:42:38AM +0800, Caesar Wang wrote:
> ? 2015?12?03? 02:38, Brian Norris ??:
>
> [.....]
> > if (thermal->tshut_temp > INT_MAX) {
> > CID 1341498: Integer handling issues (CONSTANT_EXPRESSION_RESULT)
> > "thermal->tshut_temp > 2147483647 /* (int)(~0U >> 1) */" is always false regardless of the values of its operands. This occurs as the logical operand of if.
> >
> >I don't think this condition is even useful any more, so maybe we should
> >just kill the 'if' block.
>
> See the patch to fix
> it.----->(https://patchwork.kernel.org/patch/7720601/)
> <https://patchwork.kernel.org/patch/7720601/>
- if (thermal->tshut_temp > INT_MAX) {
+ if (!(thermal->tshut_temp < INT_MAX)) {
Huh? That still doesn't make much sense. The condition is still
impossible, since thermal->tshut_temp is an int. You've just made it
slightly harder for static analyzers to notice the impossibility.
> This patch is merged into kernel 4.4-rc3.
No it isn't, and I'm glad. The patch is silly.
Brian
Hi Brain,
于 2015年12月03日 08:49, Brian Norris 写道:
> Hi Caesar,
>
> On Thu, Dec 03, 2015 at 08:42:38AM +0800, Caesar Wang wrote:
>> ? 2015?12?03? 02:38, Brian Norris ??:
>>
>> [.....]
>>> if (thermal->tshut_temp > INT_MAX) {
>>> CID 1341498: Integer handling issues (CONSTANT_EXPRESSION_RESULT)
>>> "thermal->tshut_temp > 2147483647 /* (int)(~0U >> 1) */" is always false regardless of the values of its operands. This occurs as the logical operand of if.
>>>
>>> I don't think this condition is even useful any more, so maybe we should
>>> just kill the 'if' block.
>> See the patch to fix
>> it.----->(https://patchwork.kernel.org/patch/7720601/)
>> <https://patchwork.kernel.org/patch/7720601/>
> - if (thermal->tshut_temp > INT_MAX) {
> + if (!(thermal->tshut_temp < INT_MAX)) {
>
> Huh? That still doesn't make much sense. The condition is still
> impossible, since thermal->tshut_temp is an int. You've just made it
> slightly harder for static analyzers to notice the impossibility.
Okay, that's possible remove this condition as you said.
- if (thermal->tshut_temp > INT_MAX) {
- dev_err(dev, "Invalid tshut temperature specified: %d\n",
- thermal->tshut_temp);
- return -ERANGE;
- }
Thanks!
>
>> This patch is merged into kernel 4.4-rc3.
> No it isn't, and I'm glad. The patch is silly.
>
> Brian
>
>
>