mbox series

[v3,0/4] arm64: dts: qcom: sdm845: Add thermal zones for PM8998 ADC

Message ID 20211005032531.2251928-1-bjorn.andersson@linaro.org
Headers show
Series arm64: dts: qcom: sdm845: Add thermal zones for PM8998 ADC | expand

Message

Bjorn Andersson Oct. 5, 2021, 3:25 a.m. UTC
Describe ADC channels, related thermal monitor channels and add thermal
zones for these.

Bjorn Andersson (4):
  dt-bindings: thermal: qcom: add HC variant of adc-thermal monitor
    bindings
  thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant
  arm64: dts: qcom: pm8998: Add ADC Thermal Monitor node
  arm64: dts: qcom: sdm845: mtp: Add vadc channels and thermal zones

 .../bindings/thermal/qcom-spmi-adc-tm-hc.yaml | 149 ++++++++++++++++++
 arch/arm64/boot/dts/qcom/pm8998.dtsi          |  10 ++
 arch/arm64/boot/dts/qcom/sdm845-mtp.dts       | 140 ++++++++++++++++
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |  41 ++++-
 4 files changed, 339 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml

Comments

Dmitry Baryshkov Oct. 15, 2021, 12:20 a.m. UTC | #1
On 05/10/2021 06:25, Bjorn Andersson wrote:
> The variant of the ADC Thermal Monitor block found in e.g. PM8998 is
> "HC", add support for this variant to the ADC TM5 driver in order to
> support using VADC channels as thermal_zones on SDM845 et al.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
> 
> Changes since v2:
> - Dropped conditional return ret right before unconditionatl return ret;
> 
>   drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 41 +++++++++++++++++++++++-
>   1 file changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> index 8494cc04aa21..824671cf494a 100644
> --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> @@ -82,6 +82,7 @@ struct adc_tm5_data {
>   	const u32	full_scale_code_volt;
>   	unsigned int	*decimation;
>   	unsigned int	*hw_settle;
> +	bool		is_hc;
>   };
>   
>   enum adc_tm5_cal_method {
> @@ -146,6 +147,14 @@ static const struct adc_tm5_data adc_tm5_data_pmic = {
>   					 64000, 128000 },
>   };
>   
> +static const struct adc_tm5_data adc_tm_hc_data_pmic = {
> +	.full_scale_code_volt = 0x70e4,
> +	.decimation = (unsigned int []) { 256, 512, 1024 },
> +	.hw_settle = (unsigned int []) { 0, 100, 200, 300, 400, 500, 600, 700,
> +					 1000, 2000, 4000, 6000, 8000, 10000 },
> +	.is_hc = true,
> +};
> +
>   static int adc_tm5_read(struct adc_tm5_chip *adc_tm, u16 offset, u8 *data, int len)
>   {
>   	return regmap_bulk_read(adc_tm->regmap, adc_tm->base + offset, data, len);
> @@ -375,6 +384,29 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
>   	return 0;
>   }
>   
> +static int adc_tm_hc_init(struct adc_tm5_chip *chip)
> +{
> +	unsigned int i;
> +	u8 buf[2];
> +	int ret;
> +
> +	for (i = 0; i < chip->nchannels; i++) {
> +		if (chip->channels[i].channel >= ADC_TM5_NUM_CHANNELS) {
> +			dev_err(chip->dev, "Invalid channel %d\n", chip->channels[i].channel);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	buf[0] = chip->decimation;
> +	buf[1] = chip->avg_samples | ADC_TM5_FAST_AVG_EN;
> +
> +	ret = adc_tm5_write(chip, ADC_TM5_ADC_DIG_PARAM, buf, sizeof(buf));
> +	if (ret)
> +		dev_err(chip->dev, "block write failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
>   static int adc_tm5_init(struct adc_tm5_chip *chip)
>   {
>   	u8 buf[4], channels_available;
> @@ -591,7 +623,10 @@ static int adc_tm5_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	ret = adc_tm5_init(adc_tm);
> +	if (adc_tm->data->is_hc)
> +		ret = adc_tm_hc_init(adc_tm);
> +	else
> +		ret = adc_tm5_init(adc_tm);
>   	if (ret) {
>   		dev_err(dev, "adc-tm init failed\n");
>   		return ret;
> @@ -612,6 +647,10 @@ static const struct of_device_id adc_tm5_match_table[] = {
>   		.compatible = "qcom,spmi-adc-tm5",
>   		.data = &adc_tm5_data_pmic,
>   	},
> +	{
> +		.compatible = "qcom,spmi-adc-tm-hc",
> +		.data = &adc_tm_hc_data_pmic,
> +	},
>   	{ }
>   };
>   MODULE_DEVICE_TABLE(of, adc_tm5_match_table);
>
Daniel Lezcano Oct. 15, 2021, 7:12 a.m. UTC | #2
Hi,

I will pick patches 1 et 2

Thanks

  -- Daniel


On 05/10/2021 05:25, Bjorn Andersson wrote:
> Describe ADC channels, related thermal monitor channels and add thermal
> zones for these.
> 
> Bjorn Andersson (4):
>   dt-bindings: thermal: qcom: add HC variant of adc-thermal monitor
>     bindings
>   thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant
>   arm64: dts: qcom: pm8998: Add ADC Thermal Monitor node
>   arm64: dts: qcom: sdm845: mtp: Add vadc channels and thermal zones
> 
>  .../bindings/thermal/qcom-spmi-adc-tm-hc.yaml | 149 ++++++++++++++++++
>  arch/arm64/boot/dts/qcom/pm8998.dtsi          |  10 ++
>  arch/arm64/boot/dts/qcom/sdm845-mtp.dts       | 140 ++++++++++++++++
>  drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |  41 ++++-
>  4 files changed, 339 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml
>
Vinod Koul Dec. 15, 2021, 4:04 a.m. UTC | #3
On 04-10-21, 20:25, Bjorn Andersson wrote:
> Add a node for the ADC Thermal Monitor found in the PM8998 PMIC. This is
> used to connect thermal zones with ADC channels.

Reviewed-by: Vinod Koul <vkoul@kernel.org>
Vinod Koul Dec. 15, 2021, 4:04 a.m. UTC | #4
On 04-10-21, 20:25, Bjorn Andersson wrote:
> Downstream defines four ADC channels related to thermal sensors external
> to the PM8998 and two channels for internal voltage measurements.
> 
> Add these to the upstream SDM845 MTP, describe the thermal monitor
> channels and add thermal_zones for these.

Reviewed-by: Vinod Koul <vkoul@kernel.org>
Bjorn Andersson Dec. 15, 2021, 10:27 p.m. UTC | #5
On Mon, 4 Oct 2021 20:25:27 -0700, Bjorn Andersson wrote:
> Describe ADC channels, related thermal monitor channels and add thermal
> zones for these.
> 
> Bjorn Andersson (4):
>   dt-bindings: thermal: qcom: add HC variant of adc-thermal monitor
>     bindings
>   thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant
>   arm64: dts: qcom: pm8998: Add ADC Thermal Monitor node
>   arm64: dts: qcom: sdm845: mtp: Add vadc channels and thermal zones
> 
> [...]

Applied, thanks!

[3/4] arm64: dts: qcom: pm8998: Add ADC Thermal Monitor node
      commit: 4cc7c85cccc87e436a86b4281ddcd886eb0bf58f
[4/4] arm64: dts: qcom: sdm845: mtp: Add vadc channels and thermal zones
      commit: d5e12f3823aed1e35ee2411bdf0ab61dc1011387

Best regards,