linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] thermal: rockchip: fix up thermal driver
@ 2019-04-01  6:43 Elaine Zhang
  2019-04-01  6:43 ` [PATCH v1 1/3] thermal: rockchip: add pinctrl control Elaine Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Elaine Zhang @ 2019-04-01  6:43 UTC (permalink / raw)
  To: heiko
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	linux-pm, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel, xxx, xf, huangtao, Elaine Zhang

1. add pinctrl control.
2. support PX30 soc

Elaine Zhang (3):
  thermal: rockchip: add pinctrl control
  dt-bindings: rockchip-thermal: Support the PX30 SoC compatible
  thermal: rockchip: Support the PX30 SoC in thermal driver

 .../bindings/thermal/rockchip-thermal.txt          |   1 +
 drivers/thermal/rockchip_thermal.c                 | 100 ++++++++++++++++++---
 2 files changed, 90 insertions(+), 11 deletions(-)

-- 
1.9.1




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 1/3] thermal: rockchip: add pinctrl control
  2019-04-01  6:43 [PATCH v1 0/3] thermal: rockchip: fix up thermal driver Elaine Zhang
@ 2019-04-01  6:43 ` Elaine Zhang
  2019-04-04  3:03   ` Daniel Lezcano
  2019-04-01  6:43 ` [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible Elaine Zhang
  2019-04-01  6:43 ` [PATCH v1 3/3] thermal: rockchip: Support the PX30 SoC in thermal driver Elaine Zhang
  2 siblings, 1 reply; 11+ messages in thread
From: Elaine Zhang @ 2019-04-01  6:43 UTC (permalink / raw)
  To: heiko
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	linux-pm, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel, xxx, xf, huangtao, Elaine Zhang

Based on the TSADC Tshut mode to select pinctrl,
instead of setting pinctrl based on architecture
(Not depends on pinctrl setting by "init" or "default").
And it requires setting the tshut polarity before select pinctrl.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
---
 drivers/thermal/rockchip_thermal.c | 61 +++++++++++++++++++++++++++++++-------
 1 file changed, 50 insertions(+), 11 deletions(-)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 9c7643d62ed7..faa6c7792155 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -34,7 +34,7 @@
  */
 enum tshut_mode {
 	TSHUT_MODE_CRU = 0,
-	TSHUT_MODE_GPIO,
+	TSHUT_MODE_OTP,
 };
 
 /**
@@ -172,6 +172,9 @@ struct rockchip_thermal_data {
 	int tshut_temp;
 	enum tshut_mode tshut_mode;
 	enum tshut_polarity tshut_polarity;
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *gpio_state;
+	struct pinctrl_state *otp_state;
 };
 
 /**
@@ -807,7 +810,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	u32 val;
 
 	val = readl_relaxed(regs + TSADCV2_INT_EN);
-	if (mode == TSHUT_MODE_GPIO) {
+	if (mode == TSHUT_MODE_OTP) {
 		val &= ~TSADCV2_SHUT_2CRU_SRC_EN(chn);
 		val |= TSADCV2_SHUT_2GPIO_SRC_EN(chn);
 	} else {
@@ -822,7 +825,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
 	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
 	.tshut_temp = 95000,
 
@@ -846,7 +849,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
 	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
 	.tshut_temp = 95000,
 
@@ -871,7 +874,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
 	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
 	.tshut_temp = 95000,
 
@@ -919,7 +922,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
 	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
 	.tshut_temp = 95000,
 
@@ -944,7 +947,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
 	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
 	.tshut_temp = 95000,
 
@@ -969,7 +972,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
 	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
 	.tshut_temp = 95000,
 
@@ -1080,6 +1083,20 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
 	.set_trips = rockchip_thermal_set_trips,
 };
 
+static void thermal_pinctrl_select_otp(struct rockchip_thermal_data *thermal)
+{
+	if (!IS_ERR(thermal->pinctrl) && !IS_ERR_OR_NULL(thermal->otp_state))
+		pinctrl_select_state(thermal->pinctrl,
+				     thermal->otp_state);
+}
+
+static void thermal_pinctrl_select_gpio(struct rockchip_thermal_data *thermal)
+{
+	if (!IS_ERR(thermal->pinctrl) && !IS_ERR_OR_NULL(thermal->gpio_state))
+		pinctrl_select_state(thermal->pinctrl,
+				     thermal->gpio_state);
+}
+
 static int rockchip_configure_from_dt(struct device *dev,
 				      struct device_node *np,
 				      struct rockchip_thermal_data *thermal)
@@ -1103,7 +1120,7 @@ static int rockchip_configure_from_dt(struct device *dev,
 	if (of_property_read_u32(np, "rockchip,hw-tshut-mode", &tshut_mode)) {
 		dev_warn(dev,
 			 "Missing tshut mode property, using default (%s)\n",
-			 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ?
+			 thermal->chip->tshut_mode == TSHUT_MODE_OTP ?
 				"gpio" : "cru");
 		thermal->tshut_mode = thermal->chip->tshut_mode;
 	} else {
@@ -1242,6 +1259,8 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
 		return error;
 	}
 
+	thermal->chip->control(thermal->regs, false);
+
 	error = clk_prepare_enable(thermal->clk);
 	if (error) {
 		dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
@@ -1267,6 +1286,24 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
 	thermal->chip->initialize(thermal->grf, thermal->regs,
 				  thermal->tshut_polarity);
 
+	if (thermal->tshut_mode == TSHUT_MODE_OTP) {
+		thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
+		if (IS_ERR(thermal->pinctrl))
+			dev_err(&pdev->dev, "failed to find thermal pinctrl\n");
+
+		thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl,
+							   "gpio");
+		if (IS_ERR_OR_NULL(thermal->gpio_state))
+			dev_err(&pdev->dev, "failed to find thermal gpio state\n");
+
+		thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl,
+							  "otpout");
+		if (IS_ERR_OR_NULL(thermal->otp_state))
+			dev_err(&pdev->dev, "failed to find thermal otpout state\n");
+
+		thermal_pinctrl_select_otp(thermal);
+	}
+
 	for (i = 0; i < thermal->chip->chn_num; i++) {
 		error = rockchip_thermal_register_sensor(pdev, thermal,
 						&thermal->sensors[i],
@@ -1338,7 +1375,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
 	clk_disable(thermal->pclk);
 	clk_disable(thermal->clk);
 
-	pinctrl_pm_select_sleep_state(dev);
+	if (thermal->tshut_mode == TSHUT_MODE_OTP)
+		thermal_pinctrl_select_gpio(thermal);
 
 	return 0;
 }
@@ -1383,7 +1421,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
 	for (i = 0; i < thermal->chip->chn_num; i++)
 		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
 
-	pinctrl_pm_select_default_state(dev);
+	if (thermal->tshut_mode == TSHUT_MODE_OTP)
+		thermal_pinctrl_select_otp(thermal);
 
 	return 0;
 }
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible
  2019-04-01  6:43 [PATCH v1 0/3] thermal: rockchip: fix up thermal driver Elaine Zhang
  2019-04-01  6:43 ` [PATCH v1 1/3] thermal: rockchip: add pinctrl control Elaine Zhang
@ 2019-04-01  6:43 ` Elaine Zhang
  2019-04-04  3:04   ` Daniel Lezcano
  2019-04-06  6:06   ` Rob Herring
  2019-04-01  6:43 ` [PATCH v1 3/3] thermal: rockchip: Support the PX30 SoC in thermal driver Elaine Zhang
  2 siblings, 2 replies; 11+ messages in thread
From: Elaine Zhang @ 2019-04-01  6:43 UTC (permalink / raw)
  To: heiko
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	linux-pm, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel, xxx, xf, huangtao, Elaine Zhang

Add a new compatible for thermal founding on PX30 SoCs.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
---
 Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
index 43d744e5305e..c6aac9bcacf1 100644
--- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
@@ -2,6 +2,7 @@
 
 Required properties:
 - compatible : should be "rockchip,<name>-tsadc"
+   "rockchip,px30-tsadc":   found on PX30 SoCs
    "rockchip,rv1108-tsadc": found on RV1108 SoCs
    "rockchip,rk3228-tsadc": found on RK3228 SoCs
    "rockchip,rk3288-tsadc": found on RK3288 SoCs
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 3/3] thermal: rockchip: Support the PX30 SoC in thermal driver
  2019-04-01  6:43 [PATCH v1 0/3] thermal: rockchip: fix up thermal driver Elaine Zhang
  2019-04-01  6:43 ` [PATCH v1 1/3] thermal: rockchip: add pinctrl control Elaine Zhang
  2019-04-01  6:43 ` [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible Elaine Zhang
@ 2019-04-01  6:43 ` Elaine Zhang
  2019-04-04  3:08   ` Daniel Lezcano
  2 siblings, 1 reply; 11+ messages in thread
From: Elaine Zhang @ 2019-04-01  6:43 UTC (permalink / raw)
  To: heiko
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	linux-pm, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel, xxx, xf, huangtao, Elaine Zhang

PX30 SOC has two Temperature Sensors for CPU and GPU.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
---
 drivers/thermal/rockchip_thermal.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index faa6c7792155..d5c161e63361 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -225,11 +225,15 @@ struct rockchip_thermal_data {
 #define GRF_TSADC_TESTBIT_L			0x0e648
 #define GRF_TSADC_TESTBIT_H			0x0e64c
 
+#define PX30_GRF_SOC_CON2			0x0408
+
 #define GRF_SARADC_TESTBIT_ON			(0x10001 << 2)
 #define GRF_TSADC_TESTBIT_H_ON			(0x10001 << 2)
 #define GRF_TSADC_VCM_EN_L			(0x10001 << 7)
 #define GRF_TSADC_VCM_EN_H			(0x10001 << 7)
 
+#define GRF_CON_TSADC_CH_INV			(0x10001 << 1)
+
 /**
  * struct tsadc_table - code to temperature conversion table
  * @code: the value of adc channel
@@ -692,6 +696,14 @@ static void rk_tsadcv3_initialize(struct regmap *grf, void __iomem *regs,
 			       regs + TSADCV2_AUTO_CON);
 }
 
+static void rk_tsadcv4_initialize(struct regmap *grf, void __iomem *regs,
+				  enum tshut_polarity tshut_polarity)
+{
+	rk_tsadcv2_initialize(grf, regs, tshut_polarity);
+	if (!IS_ERR(grf))
+		regmap_write(grf, PX30_GRF_SOC_CON2, GRF_CON_TSADC_CH_INV);
+}
+
 static void rk_tsadcv2_irq_ack(void __iomem *regs)
 {
 	u32 val;
@@ -821,6 +833,30 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 	writel_relaxed(val, regs + TSADCV2_INT_EN);
 }
 
+static const struct rockchip_tsadc_chip px30_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, /* 2 channels for tsadc */
+
+	.tshut_mode = TSHUT_MODE_CRU, /* default TSHUT via CRU */
+	.tshut_temp = 95000,
+
+	.initialize = rk_tsadcv4_initialize,
+	.irq_ack = rk_tsadcv3_irq_ack,
+	.control = rk_tsadcv3_control,
+	.get_temp = rk_tsadcv2_get_temp,
+	.set_alarm_temp = rk_tsadcv2_alarm_temp,
+	.set_tshut_temp = rk_tsadcv2_tshut_temp,
+	.set_tshut_mode = rk_tsadcv2_tshut_mode,
+
+	.table = {
+		.id = rk3328_code_table,
+		.length = ARRAY_SIZE(rk3328_code_table),
+		.data_mask = TSADCV2_DATA_MASK,
+		.mode = ADC_INCREMENT,
+	},
+};
+
 static const struct rockchip_tsadc_chip rv1108_tsadc_data = {
 	.chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */
 	.chn_num = 1, /* one channel for tsadc */
@@ -993,6 +1029,9 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
 };
 
 static const struct of_device_id of_rockchip_thermal_match[] = {
+	{	.compatible = "rockchip,px30-tsadc",
+		.data = (void *)&px30_tsadc_data,
+	},
 	{
 		.compatible = "rockchip,rv1108-tsadc",
 		.data = (void *)&rv1108_tsadc_data,
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/3] thermal: rockchip: add pinctrl control
  2019-04-01  6:43 ` [PATCH v1 1/3] thermal: rockchip: add pinctrl control Elaine Zhang
@ 2019-04-04  3:03   ` Daniel Lezcano
  2019-04-11  7:46     ` elaine.zhang
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Lezcano @ 2019-04-04  3:03 UTC (permalink / raw)
  To: Elaine Zhang, heiko
  Cc: rui.zhang, edubezval, robh+dt, mark.rutland, linux-pm,
	devicetree, linux-arm-kernel, linux-rockchip, linux-kernel, xxx,
	xf, huangtao

On 01/04/2019 08:43, Elaine Zhang wrote:
> Based on the TSADC Tshut mode to select pinctrl,
> instead of setting pinctrl based on architecture
> (Not depends on pinctrl setting by "init" or "default").
> And it requires setting the tshut polarity before select pinctrl.

I'm not sure to fully read the description. Can you rephrase/elaborate
the changelog?

> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
> ---
>  drivers/thermal/rockchip_thermal.c | 61 +++++++++++++++++++++++++++++++-------
>  1 file changed, 50 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 9c7643d62ed7..faa6c7792155 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -34,7 +34,7 @@
>   */
>  enum tshut_mode {
>  	TSHUT_MODE_CRU = 0,
> -	TSHUT_MODE_GPIO,
> +	TSHUT_MODE_OTP,

Why do you change the enum name? The impact on the patch is much higher,
no ?

>  };
>  
>  /**
> @@ -172,6 +172,9 @@ struct rockchip_thermal_data {
>  	int tshut_temp;
>  	enum tshut_mode tshut_mode;
>  	enum tshut_polarity tshut_polarity;
> +	struct pinctrl *pinctrl;
> +	struct pinctrl_state *gpio_state;
> +	struct pinctrl_state *otp_state;
>  };
>  
>  /**
> @@ -807,7 +810,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	u32 val;
>  
>  	val = readl_relaxed(regs + TSADCV2_INT_EN);
> -	if (mode == TSHUT_MODE_GPIO) {
> +	if (mode == TSHUT_MODE_OTP) {
>  		val &= ~TSADCV2_SHUT_2CRU_SRC_EN(chn);
>  		val |= TSADCV2_SHUT_2GPIO_SRC_EN(chn);
>  	} else {
> @@ -822,7 +825,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>  	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>  	.tshut_temp = 95000,
>  
> @@ -846,7 +849,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>  	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>  	.tshut_temp = 95000,
>  
> @@ -871,7 +874,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>  	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>  	.tshut_temp = 95000,
>  
> @@ -919,7 +922,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>  	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>  	.tshut_temp = 95000,
>  
> @@ -944,7 +947,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>  	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>  	.tshut_temp = 95000,
>  
> @@ -969,7 +972,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>  	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>  	.tshut_temp = 95000,
>  
> @@ -1080,6 +1083,20 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
>  	.set_trips = rockchip_thermal_set_trips,
>  };
>  
> +static void thermal_pinctrl_select_otp(struct rockchip_thermal_data *thermal)
> +{
> +	if (!IS_ERR(thermal->pinctrl) && !IS_ERR_OR_NULL(thermal->otp_state))
> +		pinctrl_select_state(thermal->pinctrl,
> +				     thermal->otp_state);
> +}
> +
> +static void thermal_pinctrl_select_gpio(struct rockchip_thermal_data *thermal)
> +{
> +	if (!IS_ERR(thermal->pinctrl) && !IS_ERR_OR_NULL(thermal->gpio_state))
> +		pinctrl_select_state(thermal->pinctrl,
> +				     thermal->gpio_state);
> +}

You should not have to create a couple of specific functions just to
check the pinctrl pointers are set. The caller should do that.

>  static int rockchip_configure_from_dt(struct device *dev,
>  				      struct device_node *np,
>  				      struct rockchip_thermal_data *thermal)
> @@ -1103,7 +1120,7 @@ static int rockchip_configure_from_dt(struct device *dev,
>  	if (of_property_read_u32(np, "rockchip,hw-tshut-mode", &tshut_mode)) {
>  		dev_warn(dev,
>  			 "Missing tshut mode property, using default (%s)\n",
> -			 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ?
> +			 thermal->chip->tshut_mode == TSHUT_MODE_OTP ?
>  				"gpio" : "cru");
>  		thermal->tshut_mode = thermal->chip->tshut_mode;
>  	} else {
> @@ -1242,6 +1259,8 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>  		return error;
>  	}
>  
> +	thermal->chip->control(thermal->regs, false);
> +
>  	error = clk_prepare_enable(thermal->clk);
>  	if (error) {
>  		dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
> @@ -1267,6 +1286,24 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>  	thermal->chip->initialize(thermal->grf, thermal->regs,
>  				  thermal->tshut_polarity);
>  
> +	if (thermal->tshut_mode == TSHUT_MODE_OTP) {
> +		thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
> +		if (IS_ERR(thermal->pinctrl))
> +			dev_err(&pdev->dev, "failed to find thermal pinctrl\n");
> +
> +		thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl,
> +							   "gpio");
> +		if (IS_ERR_OR_NULL(thermal->gpio_state))
> +			dev_err(&pdev->dev, "failed to find thermal gpio state\n");
> +
> +		thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl,
> +							  "otpout");
> +		if (IS_ERR_OR_NULL(thermal->otp_state))
> +			dev_err(&pdev->dev, "failed to find thermal otpout state\n");

What is the meaning for the rest of the code if the lookup fails for any
of those ?

> +		thermal_pinctrl_select_otp(thermal);
> +	}
> +
>  	for (i = 0; i < thermal->chip->chn_num; i++) {
>  		error = rockchip_thermal_register_sensor(pdev, thermal,
>  						&thermal->sensors[i],
> @@ -1338,7 +1375,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
>  	clk_disable(thermal->pclk);
>  	clk_disable(thermal->clk);
>  
> -	pinctrl_pm_select_sleep_state(dev);
> +	if (thermal->tshut_mode == TSHUT_MODE_OTP)
> +		thermal_pinctrl_select_gpio(thermal);
>  
>  	return 0;
>  }
> @@ -1383,7 +1421,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
>  	for (i = 0; i < thermal->chip->chn_num; i++)
>  		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
>  
> -	pinctrl_pm_select_default_state(dev);
> +	if (thermal->tshut_mode == TSHUT_MODE_OTP)
> +		thermal_pinctrl_select_otp(thermal);
>  
>  	return 0;
>  }
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible
  2019-04-01  6:43 ` [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible Elaine Zhang
@ 2019-04-04  3:04   ` Daniel Lezcano
  2019-04-06  6:06   ` Rob Herring
  1 sibling, 0 replies; 11+ messages in thread
From: Daniel Lezcano @ 2019-04-04  3:04 UTC (permalink / raw)
  To: Elaine Zhang, heiko
  Cc: rui.zhang, edubezval, robh+dt, mark.rutland, linux-pm,
	devicetree, linux-arm-kernel, linux-rockchip, linux-kernel, xxx,
	xf, huangtao

On 01/04/2019 08:43, Elaine Zhang wrote:
> Add a new compatible for thermal founding on PX30 SoCs.
> 
> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
> ---
>  Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> index 43d744e5305e..c6aac9bcacf1 100644
> --- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
> @@ -2,6 +2,7 @@
>  
>  Required properties:
>  - compatible : should be "rockchip,<name>-tsadc"
> +   "rockchip,px30-tsadc":   found on PX30 SoCs
>     "rockchip,rv1108-tsadc": found on RV1108 SoCs
>     "rockchip,rk3228-tsadc": found on RK3228 SoCs
>     "rockchip,rk3288-tsadc": found on RK3288 SoCs

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 3/3] thermal: rockchip: Support the PX30 SoC in thermal driver
  2019-04-01  6:43 ` [PATCH v1 3/3] thermal: rockchip: Support the PX30 SoC in thermal driver Elaine Zhang
@ 2019-04-04  3:08   ` Daniel Lezcano
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Lezcano @ 2019-04-04  3:08 UTC (permalink / raw)
  To: Elaine Zhang, heiko
  Cc: rui.zhang, edubezval, robh+dt, mark.rutland, linux-pm,
	devicetree, linux-arm-kernel, linux-rockchip, linux-kernel, xxx,
	xf, huangtao

On 01/04/2019 08:43, Elaine Zhang wrote:
> PX30 SOC has two Temperature Sensors for CPU and GPU.
> 
> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
> ---
>  drivers/thermal/rockchip_thermal.c | 39 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index faa6c7792155..d5c161e63361 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -225,11 +225,15 @@ struct rockchip_thermal_data {
>  #define GRF_TSADC_TESTBIT_L			0x0e648
>  #define GRF_TSADC_TESTBIT_H			0x0e64c
>  
> +#define PX30_GRF_SOC_CON2			0x0408
> +
>  #define GRF_SARADC_TESTBIT_ON			(0x10001 << 2)
>  #define GRF_TSADC_TESTBIT_H_ON			(0x10001 << 2)
>  #define GRF_TSADC_VCM_EN_L			(0x10001 << 7)
>  #define GRF_TSADC_VCM_EN_H			(0x10001 << 7)
>  
> +#define GRF_CON_TSADC_CH_INV			(0x10001 << 1)
> +
>  /**
>   * struct tsadc_table - code to temperature conversion table
>   * @code: the value of adc channel
> @@ -692,6 +696,14 @@ static void rk_tsadcv3_initialize(struct regmap *grf, void __iomem *regs,
>  			       regs + TSADCV2_AUTO_CON);
>  }
>  
> +static void rk_tsadcv4_initialize(struct regmap *grf, void __iomem *regs,
> +				  enum tshut_polarity tshut_polarity)
> +{
> +	rk_tsadcv2_initialize(grf, regs, tshut_polarity);
> +	if (!IS_ERR(grf))

Why this test ? grf is not modified by the 'rk_tsadcv2_initialize' function.

> +		regmap_write(grf, PX30_GRF_SOC_CON2, GRF_CON_TSADC_CH_INV);
> +}
> +
>  static void rk_tsadcv2_irq_ack(void __iomem *regs)
>  {
>  	u32 val;
> @@ -821,6 +833,30 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  	writel_relaxed(val, regs + TSADCV2_INT_EN);
>  }
>  
> +static const struct rockchip_tsadc_chip px30_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, /* 2 channels for tsadc */
> +
> +	.tshut_mode = TSHUT_MODE_CRU, /* default TSHUT via CRU */
> +	.tshut_temp = 95000,
> +
> +	.initialize = rk_tsadcv4_initialize,
> +	.irq_ack = rk_tsadcv3_irq_ack,
> +	.control = rk_tsadcv3_control,
> +	.get_temp = rk_tsadcv2_get_temp,
> +	.set_alarm_temp = rk_tsadcv2_alarm_temp,
> +	.set_tshut_temp = rk_tsadcv2_tshut_temp,
> +	.set_tshut_mode = rk_tsadcv2_tshut_mode,
> +
> +	.table = {
> +		.id = rk3328_code_table,
> +		.length = ARRAY_SIZE(rk3328_code_table),
> +		.data_mask = TSADCV2_DATA_MASK,
> +		.mode = ADC_INCREMENT,
> +	},
> +};
> +
>  static const struct rockchip_tsadc_chip rv1108_tsadc_data = {
>  	.chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */
>  	.chn_num = 1, /* one channel for tsadc */
> @@ -993,6 +1029,9 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>  };
>  
>  static const struct of_device_id of_rockchip_thermal_match[] = {
> +	{	.compatible = "rockchip,px30-tsadc",
> +		.data = (void *)&px30_tsadc_data,
> +	},
>  	{
>  		.compatible = "rockchip,rv1108-tsadc",
>  		.data = (void *)&rv1108_tsadc_data,
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible
  2019-04-01  6:43 ` [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible Elaine Zhang
  2019-04-04  3:04   ` Daniel Lezcano
@ 2019-04-06  6:06   ` Rob Herring
  1 sibling, 0 replies; 11+ messages in thread
From: Rob Herring @ 2019-04-06  6:06 UTC (permalink / raw)
  To: Elaine Zhang
  Cc: heiko, rui.zhang, edubezval, daniel.lezcano, robh+dt,
	mark.rutland, linux-pm, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, xxx, xf, huangtao, Elaine Zhang

On Mon,  1 Apr 2019 14:43:04 +0800, Elaine Zhang wrote:
> Add a new compatible for thermal founding on PX30 SoCs.
> 
> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
> ---
>  Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 1 +
>  1 file changed, 1 insertion(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/3] thermal: rockchip: add pinctrl control
  2019-04-04  3:03   ` Daniel Lezcano
@ 2019-04-11  7:46     ` elaine.zhang
  2019-04-16 10:12       ` Daniel Lezcano
  0 siblings, 1 reply; 11+ messages in thread
From: elaine.zhang @ 2019-04-11  7:46 UTC (permalink / raw)
  To: Daniel Lezcano, heiko
  Cc: rui.zhang, edubezval, robh+dt, mark.rutland, linux-pm,
	devicetree, linux-arm-kernel, linux-rockchip, linux-kernel, xxx,
	xf, huangtao

hi,

在 2019/4/4 上午11:03, Daniel Lezcano 写道:
> On 01/04/2019 08:43, Elaine Zhang wrote:
>> Based on the TSADC Tshut mode to select pinctrl,
>> instead of setting pinctrl based on architecture
>> (Not depends on pinctrl setting by "init" or "default").
>> And it requires setting the tshut polarity before select pinctrl.
> I'm not sure to fully read the description. Can you rephrase/elaborate
> the changelog?
Example:
         tsadc: tsadc@ff250000 {
                     compatible = "rockchip,rk3328-tsadc";
                     .....
                 pinctrl-names = "init", "default", "sleep";
                     pinctrl-0 = <&otp_gpio>;
                     pinctrl-1 = <&otp_out>;
                     pinctrl-2 = <&otp_gpio>;
                     status = "disabled";
                 .....
             };
         &tsadc {
                 rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
                 status = "okay";
         };
     Application on the product, hope tsadc overtemperature reset cru to 
restart.
     But when pinctrl is initialized, it will setting pinctrl by "init" 
and "default".
     So the pinctrl will set iomux to "otp_out", which may be make 
system crash.
     tsadc gpio iomux:
     "otp_gpio" : just normal gpio, keep default level.
     "otp_out" : tsadc shut down io, when overtemperature,this io may be 
trigger high
     level or low level(depend on the tsadc polarity).

     After correction:
     if rockchip,hw-tshut-mode = <0>; (tsadc overtemperature reset cru 
to restart)
     select pinctrl to otp_gpio
     if rockchip,hw-tshut-mode = <1>;(tsadc overtemperature IO triggers 
output at high or low levels)
     select pinctrl to otp_out.
     Actively select iomux based on rockchip,hw-tshut-mode,
     rather than relying on the pinctrl framework to select iomux.
>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>> ---
>>   drivers/thermal/rockchip_thermal.c | 61 +++++++++++++++++++++++++++++++-------
>>   1 file changed, 50 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
>> index 9c7643d62ed7..faa6c7792155 100644
>> --- a/drivers/thermal/rockchip_thermal.c
>> +++ b/drivers/thermal/rockchip_thermal.c
>> @@ -34,7 +34,7 @@
>>    */
>>   enum tshut_mode {
>>   	TSHUT_MODE_CRU = 0,
>> -	TSHUT_MODE_GPIO,
>> +	TSHUT_MODE_OTP,
> Why do you change the enum name? The impact on the patch is much higher,
> no ?

I just want to make it a little bit more intuitive to understand the 
definition of mode.

TSHUT_MODE_CRU: pinctrl select iomux to otp_gpio,the io is normal io.
TSHUT_MODE_OTP: pinctrl select iomux to otp_out, the io is tsadc shut io.

>
>>   };
>>   
>>   /**
>> @@ -172,6 +172,9 @@ struct rockchip_thermal_data {
>>   	int tshut_temp;
>>   	enum tshut_mode tshut_mode;
>>   	enum tshut_polarity tshut_polarity;
>> +	struct pinctrl *pinctrl;
>> +	struct pinctrl_state *gpio_state;
>> +	struct pinctrl_state *otp_state;
>>   };
>>   
>>   /**
>> @@ -807,7 +810,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	u32 val;
>>   
>>   	val = readl_relaxed(regs + TSADCV2_INT_EN);
>> -	if (mode == TSHUT_MODE_GPIO) {
>> +	if (mode == TSHUT_MODE_OTP) {
>>   		val &= ~TSADCV2_SHUT_2CRU_SRC_EN(chn);
>>   		val |= TSADCV2_SHUT_2GPIO_SRC_EN(chn);
>>   	} else {
>> @@ -822,7 +825,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>>   	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>>   	.tshut_temp = 95000,
>>   
>> @@ -846,7 +849,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>>   	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>>   	.tshut_temp = 95000,
>>   
>> @@ -871,7 +874,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>>   	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>>   	.tshut_temp = 95000,
>>   
>> @@ -919,7 +922,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>>   	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>>   	.tshut_temp = 95000,
>>   
>> @@ -944,7 +947,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>>   	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>>   	.tshut_temp = 95000,
>>   
>> @@ -969,7 +972,7 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
>>   	.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_mode = TSHUT_MODE_OTP, /* default TSHUT via GPIO give PMIC */
>>   	.tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */
>>   	.tshut_temp = 95000,
>>   
>> @@ -1080,6 +1083,20 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
>>   	.set_trips = rockchip_thermal_set_trips,
>>   };
>>   
>> +static void thermal_pinctrl_select_otp(struct rockchip_thermal_data *thermal)
>> +{
>> +	if (!IS_ERR(thermal->pinctrl) && !IS_ERR_OR_NULL(thermal->otp_state))
>> +		pinctrl_select_state(thermal->pinctrl,
>> +				     thermal->otp_state);
>> +}
>> +
>> +static void thermal_pinctrl_select_gpio(struct rockchip_thermal_data *thermal)
>> +{
>> +	if (!IS_ERR(thermal->pinctrl) && !IS_ERR_OR_NULL(thermal->gpio_state))
>> +		pinctrl_select_state(thermal->pinctrl,
>> +				     thermal->gpio_state);
>> +}
> You should not have to create a couple of specific functions just to
> check the pinctrl pointers are set. The caller should do that.
Because there are several places where the call is made,create a couple 
of specific functions reduce a lot of duplicated code.
>
>>   static int rockchip_configure_from_dt(struct device *dev,
>>   				      struct device_node *np,
>>   				      struct rockchip_thermal_data *thermal)
>> @@ -1103,7 +1120,7 @@ static int rockchip_configure_from_dt(struct device *dev,
>>   	if (of_property_read_u32(np, "rockchip,hw-tshut-mode", &tshut_mode)) {
>>   		dev_warn(dev,
>>   			 "Missing tshut mode property, using default (%s)\n",
>> -			 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ?
>> +			 thermal->chip->tshut_mode == TSHUT_MODE_OTP ?
>>   				"gpio" : "cru");
>>   		thermal->tshut_mode = thermal->chip->tshut_mode;
>>   	} else {
>> @@ -1242,6 +1259,8 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>>   		return error;
>>   	}
>>   
>> +	thermal->chip->control(thermal->regs, false);
>> +
>>   	error = clk_prepare_enable(thermal->clk);
>>   	if (error) {
>>   		dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
>> @@ -1267,6 +1286,24 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>>   	thermal->chip->initialize(thermal->grf, thermal->regs,
>>   				  thermal->tshut_polarity);
>>   
>> +	if (thermal->tshut_mode == TSHUT_MODE_OTP) {
>> +		thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
>> +		if (IS_ERR(thermal->pinctrl))
>> +			dev_err(&pdev->dev, "failed to find thermal pinctrl\n");
>> +
>> +		thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl,
>> +							   "gpio");
>> +		if (IS_ERR_OR_NULL(thermal->gpio_state))
>> +			dev_err(&pdev->dev, "failed to find thermal gpio state\n");
>> +
>> +		thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl,
>> +							  "otpout");
>> +		if (IS_ERR_OR_NULL(thermal->otp_state))
>> +			dev_err(&pdev->dev, "failed to find thermal otpout state\n");
> What is the meaning for the rest of the code if the lookup fails for any
> of those ?
If the lookup fails for any of those, The pinctrl is no longer set and 
remains in its default state(otp_gpio normal io).
>
>> +		thermal_pinctrl_select_otp(thermal);
>> +	}
>> +
>>   	for (i = 0; i < thermal->chip->chn_num; i++) {
>>   		error = rockchip_thermal_register_sensor(pdev, thermal,
>>   						&thermal->sensors[i],
>> @@ -1338,7 +1375,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
>>   	clk_disable(thermal->pclk);
>>   	clk_disable(thermal->clk);
>>   
>> -	pinctrl_pm_select_sleep_state(dev);
>> +	if (thermal->tshut_mode == TSHUT_MODE_OTP)
>> +		thermal_pinctrl_select_gpio(thermal);
>>   
>>   	return 0;
>>   }
>> @@ -1383,7 +1421,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
>>   	for (i = 0; i < thermal->chip->chn_num; i++)
>>   		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
>>   
>> -	pinctrl_pm_select_default_state(dev);
>> +	if (thermal->tshut_mode == TSHUT_MODE_OTP)
>> +		thermal_pinctrl_select_otp(thermal);
>>   
>>   	return 0;
>>   }
>>
>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/3] thermal: rockchip: add pinctrl control
  2019-04-11  7:46     ` elaine.zhang
@ 2019-04-16 10:12       ` Daniel Lezcano
  2019-04-17  3:22         ` elaine.zhang
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Lezcano @ 2019-04-16 10:12 UTC (permalink / raw)
  To: elaine.zhang, heiko
  Cc: rui.zhang, edubezval, robh+dt, mark.rutland, linux-pm,
	devicetree, linux-arm-kernel, linux-rockchip, linux-kernel, xxx,
	xf, huangtao


Hi Elaine,

On 11/04/2019 09:46, elaine.zhang wrote:
> hi,
> 
> 在 2019/4/4 上午11:03, Daniel Lezcano 写道:
>> On 01/04/2019 08:43, Elaine Zhang wrote:
>>> Based on the TSADC Tshut mode to select pinctrl,
>>> instead of setting pinctrl based on architecture
>>> (Not depends on pinctrl setting by "init" or "default").
>>> And it requires setting the tshut polarity before select pinctrl.
>> I'm not sure to fully read the description. Can you rephrase/elaborate
>> the changelog?
> Example:
>         tsadc: tsadc@ff250000 {
>                     compatible = "rockchip,rk3328-tsadc";
>                     .....
>                 pinctrl-names = "init", "default", "sleep";
>                     pinctrl-0 = <&otp_gpio>;
>                     pinctrl-1 = <&otp_out>;
>                     pinctrl-2 = <&otp_gpio>;
>                     status = "disabled";
>                 .....
>             };
>         &tsadc {
>                 rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
>                 status = "okay";
>         };
>     Application on the product, hope tsadc overtemperature reset cru to
> restart.
>     But when pinctrl is initialized, it will setting pinctrl by "init"
> and "default".
>     So the pinctrl will set iomux to "otp_out", which may be make system
> crash.

why?

>     tsadc gpio iomux:
>     "otp_gpio" : just normal gpio, keep default level.
>     "otp_out" : tsadc shut down io, when overtemperature,this io may be
> trigger high
>     level or low level(depend on the tsadc polarity).
> 
>     After correction:
>     if rockchip,hw-tshut-mode = <0>; (tsadc overtemperature reset cru to
> restart)
>     select pinctrl to otp_gpio
>     if rockchip,hw-tshut-mode = <1>;(tsadc overtemperature IO triggers
> output at high or low levels)
>     select pinctrl to otp_out.
>     Actively select iomux based on rockchip,hw-tshut-mode,
>     rather than relying on the pinctrl framework to select iomux.

Let me rephrase it and tell me if I understood correctly:

"When the temperature sensor mode is set to 0, it will automatically
reset the board via the Clock-Reset-Unit (CRU) if the over temperature
threshold is reached. However, when the pinctrl initializes, it does a
transition to "otp_out" which may lead the SoC to crash (why?)

Explicitly use the pinctrl to set/unset the right mode instead of
relying on the pinctrl init mode"

So this patch is a fix and it must contain the Fixes: ... tag.


>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>> ---
>>>   drivers/thermal/rockchip_thermal.c | 61
>>> +++++++++++++++++++++++++++++++-------
>>>   1 file changed, 50 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/thermal/rockchip_thermal.c
>>> b/drivers/thermal/rockchip_thermal.c
>>> index 9c7643d62ed7..faa6c7792155 100644
>>> --- a/drivers/thermal/rockchip_thermal.c
>>> +++ b/drivers/thermal/rockchip_thermal.c
>>> @@ -34,7 +34,7 @@
>>>    */
>>>   enum tshut_mode {
>>>       TSHUT_MODE_CRU = 0,
>>> -    TSHUT_MODE_GPIO,
>>> +    TSHUT_MODE_OTP,
>> Why do you change the enum name? The impact on the patch is much higher,
>> no ?
> 
> I just want to make it a little bit more intuitive to understand the
> definition of mode.
> 
> TSHUT_MODE_CRU: pinctrl select iomux to otp_gpio,the io is normal io.
> TSHUT_MODE_OTP: pinctrl select iomux to otp_out, the io is tsadc shut io.

I understand, but at the end the changes for this patch are counter
intuitive, so it is preferable to keep it as is so we can review the
important part.

[ ... ]

>>>   +static void thermal_pinctrl_select_otp(struct
>>> rockchip_thermal_data *thermal)
>>> +{
>>> +    if (!IS_ERR(thermal->pinctrl) &&
>>> !IS_ERR_OR_NULL(thermal->otp_state))
>>> +        pinctrl_select_state(thermal->pinctrl,
>>> +                     thermal->otp_state);
>>> +}
>>> +
>>> +static void thermal_pinctrl_select_gpio(struct rockchip_thermal_data
>>> *thermal)
>>> +{
>>> +    if (!IS_ERR(thermal->pinctrl) &&
>>> !IS_ERR_OR_NULL(thermal->gpio_state))
>>> +        pinctrl_select_state(thermal->pinctrl,
>>> +                     thermal->gpio_state);
>>> +}
>> You should not have to create a couple of specific functions just to
>> check the pinctrl pointers are set. The caller should do that.
> Because there are several places where the call is made,create a couple
> of specific functions reduce a lot of duplicated code.

No, that does not reduce a lot of duplicated code, it hides the fact
there is no control from the caller. See the comments below.

[ ... ]

>>>   static int rockchip_configure_from_dt(struct device *dev,
>>>                         struct device_node *np,
>>>                         struct rockchip_thermal_data *thermal)
>>> @@ -1103,7 +1120,7 @@ static int rockchip_configure_from_dt(struct
>>> device *dev,
>>>       if (of_property_read_u32(np, "rockchip,hw-tshut-mode",
>>> &tshut_mode)) {
>>>           dev_warn(dev,
>>>                "Missing tshut mode property, using default (%s)\n",
>>> -             thermal->chip->tshut_mode == TSHUT_MODE_GPIO ?
>>> +             thermal->chip->tshut_mode == TSHUT_MODE_OTP ?
>>>                   "gpio" : "cru");
>>>           thermal->tshut_mode = thermal->chip->tshut_mode;
>>>       } else {
>>> @@ -1242,6 +1259,8 @@ static int rockchip_thermal_probe(struct
>>> platform_device *pdev)
>>>           return error;
>>>       }
>>>   +    thermal->chip->control(thermal->regs, false);
>>> +
>>>       error = clk_prepare_enable(thermal->clk);
>>>       if (error) {
>>>           dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
>>> @@ -1267,6 +1286,24 @@ static int rockchip_thermal_probe(struct
>>> platform_device *pdev)
>>>       thermal->chip->initialize(thermal->grf, thermal->regs,
>>>                     thermal->tshut_polarity);
>>>   +    if (thermal->tshut_mode == TSHUT_MODE_OTP) {
>>> +        thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
>>> +        if (IS_ERR(thermal->pinctrl))
>>> +            dev_err(&pdev->dev, "failed to find thermal pinctrl\n");
>>> +
>>> +        thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl,
>>> +                               "gpio");

panic if devm_pinctrl_get fails.

>>> +        if (IS_ERR_OR_NULL(thermal->gpio_state))
>>> +            dev_err(&pdev->dev, "failed to find thermal gpio state\n");
>>> +
>>> +        thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl,
>>> +                              "otpout");
>>> +        if (IS_ERR_OR_NULL(thermal->otp_state))
>>> +            dev_err(&pdev->dev, "failed to find thermal otpout
>>> state\n");
>> What is the meaning for the rest of the code if the lookup fails for any
>> of those ?
> If the lookup fails for any of those, The pinctrl is no longer set and
> remains in its default state(otp_gpio normal io).
>>
>>> +        thermal_pinctrl_select_otp(thermal);
>>> +    }
>>> +

It is pointless to have a otp_state and a gpio_state field. Just use one
as the configuration tells you which lookup to do.

In case of error, just bail out. It is pointless to continue with a
broken configuration.

	thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(thermal->pinctrl)) {
		dev_err(&pdev->dev, "....");
		return PTR_ERR(thermal->pinctrl);
	}

	thermal->pinctrl_state =
		pinctrl_lookup_state(thermal->pinctrl,
			thermal->tshut_mode == TSHUT_MODE_OTP ?
			"otp" : "gpio");

	if (IS_ERR_OR_NULL(thermal->pinctrl_state)) {
		dev_err(&pdev->dev, "....");
		return -EINVAL;
	}


No need to use the thermal_pinctrl_select_otp/gpio wrappers, just
replace them with:

pinctrl_select_state(thermal->pinctrl, thermal->pinctrl_state);

and use it unconditionally.


>>>       for (i = 0; i < thermal->chip->chn_num; i++) {
>>>           error = rockchip_thermal_register_sensor(pdev, thermal,
>>>                           &thermal->sensors[i],
>>> @@ -1338,7 +1375,8 @@ static int __maybe_unused
>>> rockchip_thermal_suspend(struct device *dev)
>>>       clk_disable(thermal->pclk);
>>>       clk_disable(thermal->clk);
>>>   -    pinctrl_pm_select_sleep_state(dev);
>>> +    if (thermal->tshut_mode == TSHUT_MODE_OTP)
>>> +        thermal_pinctrl_select_gpio(thermal);
>>>         return 0;
>>>   }
>>> @@ -1383,7 +1421,8 @@ static int __maybe_unused
>>> rockchip_thermal_resume(struct device *dev)
>>>       for (i = 0; i < thermal->chip->chn_num; i++)
>>>           rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
>>>   -    pinctrl_pm_select_default_state(dev);
>>> +    if (thermal->tshut_mode == TSHUT_MODE_OTP)
>>> +        thermal_pinctrl_select_otp(thermal);
>>>         return 0;
>>>   }
>>>
>>
> 
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/3] thermal: rockchip: add pinctrl control
  2019-04-16 10:12       ` Daniel Lezcano
@ 2019-04-17  3:22         ` elaine.zhang
  0 siblings, 0 replies; 11+ messages in thread
From: elaine.zhang @ 2019-04-17  3:22 UTC (permalink / raw)
  To: Daniel Lezcano, heiko
  Cc: rui.zhang, edubezval, robh+dt, mark.rutland, linux-pm,
	devicetree, linux-arm-kernel, linux-rockchip, linux-kernel, xxx,
	xf, huangtao

hi,

在 2019/4/16 下午6:12, Daniel Lezcano 写道:
> Hi Elaine,
>
> On 11/04/2019 09:46, elaine.zhang wrote:
>> hi,
>>
>> 在 2019/4/4 上午11:03, Daniel Lezcano 写道:
>>> On 01/04/2019 08:43, Elaine Zhang wrote:
>>>> Based on the TSADC Tshut mode to select pinctrl,
>>>> instead of setting pinctrl based on architecture
>>>> (Not depends on pinctrl setting by "init" or "default").
>>>> And it requires setting the tshut polarity before select pinctrl.
>>> I'm not sure to fully read the description. Can you rephrase/elaborate
>>> the changelog?
>> Example:
>>          tsadc: tsadc@ff250000 {
>>                      compatible = "rockchip,rk3328-tsadc";
>>                      .....
>>                  pinctrl-names = "init", "default", "sleep";
>>                      pinctrl-0 = <&otp_gpio>;
>>                      pinctrl-1 = <&otp_out>;
>>                      pinctrl-2 = <&otp_gpio>;
>>                      status = "disabled";
>>                  .....
>>              };
>>          &tsadc {
>>                  rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
>>                  status = "okay";
>>          };
>>      Application on the product, hope tsadc overtemperature reset cru to
>> restart.
>>      But when pinctrl is initialized, it will setting pinctrl by "init"
>> and "default".
>>      So the pinctrl will set iomux to "otp_out", which may be make system
>> crash.
> why?
This "otp_out" IO may be connected to the RESET circuit on the hardware. 
If the IO is in the wrong state, it will trigger RESET (similar to the 
effect of pressing the RESET button), which will cause the system to 
restart all the time.
>
>>      tsadc gpio iomux:
>>      "otp_gpio" : just normal gpio, keep default level.
>>      "otp_out" : tsadc shut down io, when overtemperature,this io may be
>> trigger high
>>      level or low level(depend on the tsadc polarity).
>>
>>      After correction:
>>      if rockchip,hw-tshut-mode = <0>; (tsadc overtemperature reset cru to
>> restart)
>>      select pinctrl to otp_gpio
>>      if rockchip,hw-tshut-mode = <1>;(tsadc overtemperature IO triggers
>> output at high or low levels)
>>      select pinctrl to otp_out.
>>      Actively select iomux based on rockchip,hw-tshut-mode,
>>      rather than relying on the pinctrl framework to select iomux.
> Let me rephrase it and tell me if I understood correctly:
>
> "When the temperature sensor mode is set to 0, it will automatically
> reset the board via the Clock-Reset-Unit (CRU) if the over temperature
> threshold is reached. However, when the pinctrl initializes, it does a
> transition to "otp_out" which may lead the SoC to crash (why?)
>
> Explicitly use the pinctrl to set/unset the right mode instead of
> relying on the pinctrl init mode"
This explanation is correct.
>
> So this patch is a fix and it must contain the Fixes: ... tag.
OK, I'll fix that in the v2.
>
>
>>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>>> ---
>>>>    drivers/thermal/rockchip_thermal.c | 61
>>>> +++++++++++++++++++++++++++++++-------
>>>>    1 file changed, 50 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/thermal/rockchip_thermal.c
>>>> b/drivers/thermal/rockchip_thermal.c
>>>> index 9c7643d62ed7..faa6c7792155 100644
>>>> --- a/drivers/thermal/rockchip_thermal.c
>>>> +++ b/drivers/thermal/rockchip_thermal.c
>>>> @@ -34,7 +34,7 @@
>>>>     */
>>>>    enum tshut_mode {
>>>>        TSHUT_MODE_CRU = 0,
>>>> -    TSHUT_MODE_GPIO,
>>>> +    TSHUT_MODE_OTP,
>>> Why do you change the enum name? The impact on the patch is much higher,
>>> no ?
>> I just want to make it a little bit more intuitive to understand the
>> definition of mode.
>>
>> TSHUT_MODE_CRU: pinctrl select iomux to otp_gpio,the io is normal io.
>> TSHUT_MODE_OTP: pinctrl select iomux to otp_out, the io is tsadc shut io.
> I understand, but at the end the changes for this patch are counter
> intuitive, so it is preferable to keep it as is so we can review the
> important part.
>
> [ ... ]
OK, keep the enum name. I'll fix it in the V2.
>
>>>>    +static void thermal_pinctrl_select_otp(struct
>>>> rockchip_thermal_data *thermal)
>>>> +{
>>>> +    if (!IS_ERR(thermal->pinctrl) &&
>>>> !IS_ERR_OR_NULL(thermal->otp_state))
>>>> +        pinctrl_select_state(thermal->pinctrl,
>>>> +                     thermal->otp_state);
>>>> +}
>>>> +
>>>> +static void thermal_pinctrl_select_gpio(struct rockchip_thermal_data
>>>> *thermal)
>>>> +{
>>>> +    if (!IS_ERR(thermal->pinctrl) &&
>>>> !IS_ERR_OR_NULL(thermal->gpio_state))
>>>> +        pinctrl_select_state(thermal->pinctrl,
>>>> +                     thermal->gpio_state);
>>>> +}
>>> You should not have to create a couple of specific functions just to
>>> check the pinctrl pointers are set. The caller should do that.
>> Because there are several places where the call is made,create a couple
>> of specific functions reduce a lot of duplicated code.
> No, that does not reduce a lot of duplicated code, it hides the fact
> there is no control from the caller. See the comments below.
>
> [ ... ]
OK, I'll fix it in the V2.
>
>>>>    static int rockchip_configure_from_dt(struct device *dev,
>>>>                          struct device_node *np,
>>>>                          struct rockchip_thermal_data *thermal)
>>>> @@ -1103,7 +1120,7 @@ static int rockchip_configure_from_dt(struct
>>>> device *dev,
>>>>        if (of_property_read_u32(np, "rockchip,hw-tshut-mode",
>>>> &tshut_mode)) {
>>>>            dev_warn(dev,
>>>>                 "Missing tshut mode property, using default (%s)\n",
>>>> -             thermal->chip->tshut_mode == TSHUT_MODE_GPIO ?
>>>> +             thermal->chip->tshut_mode == TSHUT_MODE_OTP ?
>>>>                    "gpio" : "cru");
>>>>            thermal->tshut_mode = thermal->chip->tshut_mode;
>>>>        } else {
>>>> @@ -1242,6 +1259,8 @@ static int rockchip_thermal_probe(struct
>>>> platform_device *pdev)
>>>>            return error;
>>>>        }
>>>>    +    thermal->chip->control(thermal->regs, false);
>>>> +
>>>>        error = clk_prepare_enable(thermal->clk);
>>>>        if (error) {
>>>>            dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
>>>> @@ -1267,6 +1286,24 @@ static int rockchip_thermal_probe(struct
>>>> platform_device *pdev)
>>>>        thermal->chip->initialize(thermal->grf, thermal->regs,
>>>>                      thermal->tshut_polarity);
>>>>    +    if (thermal->tshut_mode == TSHUT_MODE_OTP) {
>>>> +        thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
>>>> +        if (IS_ERR(thermal->pinctrl))
>>>> +            dev_err(&pdev->dev, "failed to find thermal pinctrl\n");
>>>> +
>>>> +        thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl,
>>>> +                               "gpio");
> panic if devm_pinctrl_get fails.
OK, It's good advice. I'll fix it in the V2.
>
>>>> +        if (IS_ERR_OR_NULL(thermal->gpio_state))
>>>> +            dev_err(&pdev->dev, "failed to find thermal gpio state\n");
>>>> +
>>>> +        thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl,
>>>> +                              "otpout");
>>>> +        if (IS_ERR_OR_NULL(thermal->otp_state))
>>>> +            dev_err(&pdev->dev, "failed to find thermal otpout
>>>> state\n");
>>> What is the meaning for the rest of the code if the lookup fails for any
>>> of those ?
>> If the lookup fails for any of those, The pinctrl is no longer set and
>> remains in its default state(otp_gpio normal io).
>>>> +        thermal_pinctrl_select_otp(thermal);
>>>> +    }
>>>> +
> It is pointless to have a otp_state and a gpio_state field. Just use one
> as the configuration tells you which lookup to do.
>
> In case of error, just bail out. It is pointless to continue with a
> broken configuration.
If the DST node is not modified synchronously, which may cause the 
rockchip_thermal driver probe failed.
Should I ignore this?
>
> 	thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
> 	if (IS_ERR(thermal->pinctrl)) {
> 		dev_err(&pdev->dev, "....");
> 		return PTR_ERR(thermal->pinctrl);
> 	}
>
> 	thermal->pinctrl_state =
> 		pinctrl_lookup_state(thermal->pinctrl,
> 			thermal->tshut_mode == TSHUT_MODE_OTP ?
> 			"otp" : "gpio");
>
> 	if (IS_ERR_OR_NULL(thermal->pinctrl_state)) {
> 		dev_err(&pdev->dev, "....");
> 		return -EINVAL;
> 	}
>
>
> No need to use the thermal_pinctrl_select_otp/gpio wrappers, just
> replace them with:
>
> pinctrl_select_state(thermal->pinctrl, thermal->pinctrl_state);
>
> and use it unconditionally.
OK. I'll fix it in the V2.
>
>
>>>>        for (i = 0; i < thermal->chip->chn_num; i++) {
>>>>            error = rockchip_thermal_register_sensor(pdev, thermal,
>>>>                            &thermal->sensors[i],
>>>> @@ -1338,7 +1375,8 @@ static int __maybe_unused
>>>> rockchip_thermal_suspend(struct device *dev)
>>>>        clk_disable(thermal->pclk);
>>>>        clk_disable(thermal->clk);
>>>>    -    pinctrl_pm_select_sleep_state(dev);
>>>> +    if (thermal->tshut_mode == TSHUT_MODE_OTP)
>>>> +        thermal_pinctrl_select_gpio(thermal);
>>>>          return 0;
>>>>    }
>>>> @@ -1383,7 +1421,8 @@ static int __maybe_unused
>>>> rockchip_thermal_resume(struct device *dev)
>>>>        for (i = 0; i < thermal->chip->chn_num; i++)
>>>>            rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
>>>>    -    pinctrl_pm_select_default_state(dev);
>>>> +    if (thermal->tshut_mode == TSHUT_MODE_OTP)
>>>> +        thermal_pinctrl_select_otp(thermal);
>>>>          return 0;
>>>>    }
>>>>
>>
>



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-04-17  3:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01  6:43 [PATCH v1 0/3] thermal: rockchip: fix up thermal driver Elaine Zhang
2019-04-01  6:43 ` [PATCH v1 1/3] thermal: rockchip: add pinctrl control Elaine Zhang
2019-04-04  3:03   ` Daniel Lezcano
2019-04-11  7:46     ` elaine.zhang
2019-04-16 10:12       ` Daniel Lezcano
2019-04-17  3:22         ` elaine.zhang
2019-04-01  6:43 ` [PATCH v1 2/3] dt-bindings: rockchip-thermal: Support the PX30 SoC compatible Elaine Zhang
2019-04-04  3:04   ` Daniel Lezcano
2019-04-06  6:06   ` Rob Herring
2019-04-01  6:43 ` [PATCH v1 3/3] thermal: rockchip: Support the PX30 SoC in thermal driver Elaine Zhang
2019-04-04  3:08   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).