* [PATCH 1/5] thermal: rockchip: fix a trivial typo
2015-11-25 7:59 [PATCH 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for thermal driver Caesar Wang
@ 2015-11-25 7:59 ` Caesar Wang
2015-11-25 7:59 ` [PATCH 2/5] thermal: rockchip: fix a impossible condition caused by the warning Caesar Wang
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Caesar Wang @ 2015-11-25 7:59 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---
drivers/thermal/rockchip_thermal.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index e845841..85a7930 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -57,10 +57,10 @@ 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)
-*/
+ * The conversion table has the adc value and temperature.
+ * ADC_DECREMENT is the adc value decrement.(e.g. v2_code_table)
+ * ADC_INCREMNET is the adc value increment.(e.g. v3_code_table)
+ */
enum adc_sort_mode {
ADC_DECREMENT = 0,
ADC_INCREMENT,
@@ -617,7 +617,7 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
return 0;
}
-/*
+/**
* Reset TSADC Controller, reset all tsadc registers.
*/
static void rockchip_thermal_reset_controller(struct reset_control *reset)
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/5] thermal: rockchip: fix a impossible condition caused by the warning
2015-11-25 7:59 [PATCH 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for thermal driver Caesar Wang
2015-11-25 7:59 ` [PATCH 1/5] thermal: rockchip: fix a trivial typo Caesar Wang
@ 2015-11-25 7:59 ` Caesar Wang
2015-11-25 7:59 ` [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible Caesar Wang
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Caesar Wang @ 2015-11-25 7:59 UTC (permalink / raw)
To: linux-arm-kernel
As the Dan report the smatch check the thermal driver warning:
drivers/thermal/rockchip_thermal.c:551 rockchip_configure_from_dt()
warn: impossible condition '(thermal->tshut_temp > ((~0 >> 1))) =>
(s32min-s32max > s32max)'
Since the Temperature is currently represented as int not long in
the thermal driver.
Fixes: commit 437df2172e8d
("thermal: rockchip: consistently use int for temperatures")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---
drivers/thermal/rockchip_thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 85a7930..ab236a1 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -548,7 +548,7 @@ static int rockchip_configure_from_dt(struct device *dev,
thermal->tshut_temp = shut_temp;
}
- if (thermal->tshut_temp > INT_MAX) {
+ if (!(thermal->tshut_temp < INT_MAX)) {
dev_err(dev, "Invalid tshut temperature specified: %d\n",
thermal->tshut_temp);
return -ERANGE;
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible
2015-11-25 7:59 [PATCH 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for thermal driver Caesar Wang
2015-11-25 7:59 ` [PATCH 1/5] thermal: rockchip: fix a trivial typo Caesar Wang
2015-11-25 7:59 ` [PATCH 2/5] thermal: rockchip: fix a impossible condition caused by the warning Caesar Wang
@ 2015-11-25 7:59 ` Caesar Wang
2015-11-25 14:56 ` Heiko Stübner
2015-11-25 20:05 ` Rob Herring
2015-11-25 7:59 ` [PATCH 4/5] thermal: rockchip: Support the RK3228 SoCs in thermal driver Caesar Wang
2015-11-25 7:59 ` [PATCH 5/5] thermal: rockchip: Support the RK3399 " Caesar Wang
4 siblings, 2 replies; 9+ messages in thread
From: Caesar Wang @ 2015-11-25 7:59 UTC (permalink / raw)
To: linux-arm-kernel
This patchset attempts to new compatible for thermal founding
on RK3228/RK3399 SoCs.
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
index 0dfa60d..af5f802 100644
--- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
@@ -2,8 +2,10 @@
Required properties:
- compatible : should be "rockchip,<name>-tsadc"
+ "rockchip,rk3228-tsadc": found on RK3228 SoCs
"rockchip,rk3288-tsadc": found on RK3288 SoCs
"rockchip,rk3368-tsadc": found on RK3368 SoCs
+ "rockchip,rk3368-tsadc": found on RK3399 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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible
2015-11-25 7:59 ` [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible Caesar Wang
@ 2015-11-25 14:56 ` Heiko Stübner
2015-11-26 2:57 ` Caesar Wang
2015-11-25 20:05 ` Rob Herring
1 sibling, 1 reply; 9+ messages in thread
From: Heiko Stübner @ 2015-11-25 14:56 UTC (permalink / raw)
To: linux-arm-kernel
Am Mittwoch, 25. November 2015, 15:59:35 schrieb Caesar Wang:
> This patchset attempts to new compatible for thermal founding
> on RK3228/RK3399 SoCs.
>
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
> ---
>
> Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt index
> 0dfa60d..af5f802 100644
> --- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> @@ -2,8 +2,10 @@
>
> Required properties:
> - compatible : should be "rockchip,<name>-tsadc"
> + "rockchip,rk3228-tsadc": found on RK3228 SoCs
> "rockchip,rk3288-tsadc": found on RK3288 SoCs
> "rockchip,rk3368-tsadc": found on RK3368 SoCs
> + "rockchip,rk3368-tsadc": found on RK3399 SoCs
copy'n'paste error, should proably be
"rockchip,rk3399-tsadc": found on RK3399 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible
2015-11-25 14:56 ` Heiko Stübner
@ 2015-11-26 2:57 ` Caesar Wang
0 siblings, 0 replies; 9+ messages in thread
From: Caesar Wang @ 2015-11-26 2:57 UTC (permalink / raw)
To: linux-arm-kernel
? 2015?11?25? 22:56, Heiko St?bner ??:
> Am Mittwoch, 25. November 2015, 15:59:35 schrieb Caesar Wang:
>> This patchset attempts to new compatible for thermal founding
>> on RK3228/RK3399 SoCs.
>>
>> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
>> ---
>>
>> Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
>> b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt index
>> 0dfa60d..af5f802 100644
>> --- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
>> +++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
>> @@ -2,8 +2,10 @@
>>
>> Required properties:
>> - compatible : should be "rockchip,<name>-tsadc"
>> + "rockchip,rk3228-tsadc": found on RK3228 SoCs
>> "rockchip,rk3288-tsadc": found on RK3288 SoCs
>> "rockchip,rk3368-tsadc": found on RK3368 SoCs
>> + "rockchip,rk3368-tsadc": found on RK3399 SoCs
> copy'n'paste error, should proably be
> "rockchip,rk3399-tsadc": found on RK3399 SoCs
Fixed in next version, thanks!
>> - reg : physical base address of the controller and length of memory mapped
>> region.
>> - interrupts : The interrupt number to the cpu. The interrupt specifier
>> format
>
>
>
--
caesar wang | software engineer | wxt at rock-chip.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible
2015-11-25 7:59 ` [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible Caesar Wang
2015-11-25 14:56 ` Heiko Stübner
@ 2015-11-25 20:05 ` Rob Herring
1 sibling, 0 replies; 9+ messages in thread
From: Rob Herring @ 2015-11-25 20:05 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Nov 25, 2015 at 03:59:35PM +0800, Caesar Wang wrote:
> This patchset attempts to new compatible for thermal founding
> on RK3228/RK3399 SoCs.
>
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Acked-by: Rob Herring <robh@kernel.org>
> ---
>
> Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> index 0dfa60d..af5f802 100644
> --- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> @@ -2,8 +2,10 @@
>
> Required properties:
> - compatible : should be "rockchip,<name>-tsadc"
> + "rockchip,rk3228-tsadc": found on RK3228 SoCs
> "rockchip,rk3288-tsadc": found on RK3288 SoCs
> "rockchip,rk3368-tsadc": found on RK3368 SoCs
> + "rockchip,rk3368-tsadc": found on RK3399 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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/5] thermal: rockchip: Support the RK3228 SoCs in thermal driver
2015-11-25 7:59 [PATCH 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for thermal driver Caesar Wang
` (2 preceding siblings ...)
2015-11-25 7:59 ` [PATCH 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible Caesar Wang
@ 2015-11-25 7:59 ` Caesar Wang
2015-11-25 7:59 ` [PATCH 5/5] thermal: rockchip: Support the RK3399 " Caesar Wang
4 siblings, 0 replies; 9+ messages in thread
From: Caesar Wang @ 2015-11-25 7:59 UTC (permalink / raw)
To: linux-arm-kernel
The RK3228 SoCs has one Temperature Sensor, channel 0 is for CPU.
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---
drivers/thermal/rockchip_thermal.c | 81 ++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index ab236a1..c5079f9 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -153,6 +153,7 @@ struct rockchip_thermal_data {
#define TSADCV2_SHUT_2GPIO_SRC_EN(chn) BIT(4 + (chn))
#define TSADCV2_SHUT_2CRU_SRC_EN(chn) BIT(8 + (chn))
+#define TSADCV1_INT_PD_CLEAR_MASK ~BIT(16)
#define TSADCV2_INT_PD_CLEAR_MASK ~BIT(8)
#define TSADCV2_DATA_MASK 0xfff
@@ -168,6 +169,51 @@ struct tsadc_table {
int temp;
};
+/**
+ * Note:
+ * Code to Temperature mapping of the Temperature sensor is a piece wise linear
+ * curve.Any temperature, code faling between to 2 give temperatures can be
+ * linearly interpolated.
+ * Code to Temperature mapping should be updated based on sillcon results.
+ */
+static const struct tsadc_table v1_code_table[] = {
+ {TSADCV3_DATA_MASK, -40000},
+ {436, -40000},
+ {431, -35000},
+ {426, -30000},
+ {421, -25000},
+ {416, -20000},
+ {411, -15000},
+ {406, -10000},
+ {401, -5000},
+ {395, 0},
+ {390, 5000},
+ {385, 10000},
+ {380, 15000},
+ {375, 20000},
+ {370, 25000},
+ {364, 30000},
+ {359, 35000},
+ {354, 40000},
+ {349, 45000},
+ {343, 50000},
+ {338, 55000},
+ {333, 60000},
+ {328, 65000},
+ {322, 70000},
+ {317, 75000},
+ {312, 80000},
+ {307, 85000},
+ {301, 90000},
+ {296, 95000},
+ {291, 100000},
+ {286, 105000},
+ {280, 110000},
+ {275, 115000},
+ {270, 120000},
+ {264, 125000},
+};
+
static const struct tsadc_table v2_code_table[] = {
{TSADCV2_DATA_MASK, -40000},
{3800, -40000},
@@ -368,6 +414,14 @@ static void rk_tsadcv2_initialize(void __iomem *regs,
regs + TSADCV2_HIGHT_TSHUT_DEBOUNCE);
}
+static void rk_tsadcv1_irq_ack(void __iomem *regs)
+{
+ u32 val;
+
+ val = readl_relaxed(regs + TSADCV2_INT_PD);
+ writel_relaxed(val & TSADCV1_INT_PD_CLEAR_MASK, regs + TSADCV2_INT_PD);
+}
+
static void rk_tsadcv2_irq_ack(void __iomem *regs)
{
u32 val;
@@ -429,6 +483,29 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
writel_relaxed(val, regs + TSADCV2_INT_EN);
}
+static const struct rockchip_tsadc_chip rk3228_tsadc_data = {
+ .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */
+ .chn_num = 1, /* one channel 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_tsadcv1_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 = v1_code_table,
+ .length = ARRAY_SIZE(v1_code_table),
+ .data_mask = TSADCV3_DATA_MASK,
+ .mode = ADC_DECREMENT,
+ },
+};
+
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 */
@@ -479,6 +556,10 @@ static const struct rockchip_tsadc_chip rk3368_tsadc_data = {
static const struct of_device_id of_rockchip_thermal_match[] = {
{
+ .compatible = "rockchip,rk3228-tsadc",
+ .data = (void *)&rk3228_tsadc_data,
+ },
+ {
.compatible = "rockchip,rk3288-tsadc",
.data = (void *)&rk3288_tsadc_data,
},
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/5] thermal: rockchip: Support the RK3399 SoCs in thermal driver
2015-11-25 7:59 [PATCH 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for thermal driver Caesar Wang
` (3 preceding siblings ...)
2015-11-25 7:59 ` [PATCH 4/5] thermal: rockchip: Support the RK3228 SoCs in thermal driver Caesar Wang
@ 2015-11-25 7:59 ` Caesar Wang
4 siblings, 0 replies; 9+ messages in thread
From: Caesar Wang @ 2015-11-25 7:59 UTC (permalink / raw)
To: linux-arm-kernel
The RK3399 SoCs have two Temperature Sensors, channel 0 is for CPU.
channel 1 is for GPU.
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---
drivers/thermal/rockchip_thermal.c | 66 ++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index c5079f9..f863956 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -291,6 +291,44 @@ static const struct tsadc_table v3_code_table[] = {
{TSADCV3_DATA_MASK, 125000},
};
+static const struct tsadc_table v4_code_table[] = {
+ {TSADCV3_DATA_MASK, -40000},
+ {431, -40000},
+ {426, -35000},
+ {421, -30000},
+ {415, -25000},
+ {410, -20000},
+ {405, -15000},
+ {399, -10000},
+ {394, -5000},
+ {389, 0},
+ {383, 5000},
+ {378, 10000},
+ {373, 15000},
+ {367, 20000},
+ {362, 25000},
+ {357, 30000},
+ {351, 35000},
+ {346, 40000},
+ {340, 45000},
+ {335, 50000},
+ {330, 55000},
+ {324, 60000},
+ {319, 65000},
+ {313, 70000},
+ {308, 75000},
+ {302, 80000},
+ {297, 85000},
+ {291, 90000},
+ {286, 95000},
+ {281, 100000},
+ {275, 105000},
+ {270, 110000},
+ {264, 115000},
+ {259, 120000},
+ {253, 125000},
+};
+
static u32 rk_tsadcv2_temp_to_code(struct chip_tsadc_table table,
int temp)
{
@@ -554,6 +592,30 @@ static const struct rockchip_tsadc_chip rk3368_tsadc_data = {
},
};
+static const struct rockchip_tsadc_chip rk3399_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 = v4_code_table,
+ .length = ARRAY_SIZE(v4_code_table),
+ .data_mask = TSADCV3_DATA_MASK,
+ .mode = ADC_DECREMENT,
+ },
+};
+
static const struct of_device_id of_rockchip_thermal_match[] = {
{
.compatible = "rockchip,rk3228-tsadc",
@@ -567,6 +629,10 @@ static const struct of_device_id of_rockchip_thermal_match[] = {
.compatible = "rockchip,rk3368-tsadc",
.data = (void *)&rk3368_tsadc_data,
},
+ {
+ .compatible = "rockchip,rk3399-tsadc",
+ .data = (void *)&rk3399_tsadc_data,
+ },
{ /* end */ },
};
MODULE_DEVICE_TABLE(of, of_rockchip_thermal_match);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread