Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp940632pxb; Wed, 29 Sep 2021 13:03:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIo7na1AIwmrguy2XDPYt/5p/msAM6vawLKV77Iypz4AEV2MM5ItJwQWxfvgNglTilSj60 X-Received: by 2002:a50:d98d:: with SMTP id w13mr2245308edj.51.1632945796372; Wed, 29 Sep 2021 13:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632945796; cv=none; d=google.com; s=arc-20160816; b=Jn5TE1rty/H+ik7F1zBc5vv7ZIc5SJrnCBDd9POMQ80CzkXwDZs4nvK7nc7MokPSRJ 6Z3lRYEgOE5nbfcPEOptQ529+sASFznN8xORQ9uAtdL0nVXd8xFB7sYi0U7Vwv+VBQa5 qy+CKtG7LRu/SFT6RoBBwGS3eaT4qo0kl4m94hs4PMyS2a2xy3trSwojLqnEcetgCuBd Dhrp1babNX5Xcaf/3mByWKzPO4lCJgSgvaWfomBR1cRrNdDwNd6hs9pSpzdYhj49uFDD Uk25GD54v2piiScFIA5g5tv4sB3X42iHbj/Tm+8SnUCJ4jL0A5DciEGorPYcJsYx/AvN SO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=zIP+fT3P6R0yvKNN26znulCvOf0uZzhNp76ydFE5KGM=; b=f1IxwwI2rAFaJcRSmeVjw5Dt+Tx7VGh5/4IlVExt+SDpDe2wbSOPTMfjBA5teFdVaI l9Q1Q+icd0pBLhvEiFW6SwaCEx+D7Pd4FYzoDHJZ10j2CA5uCiZrmRFVzBV9OJCJQftE DXpOy9vjP71mBUy8bNcopCwqsngW5z1drWn9Nh/9/NS5d0fBZXYFwwI4s772VU/hoHBd ZnSFqCva6XRnmzaYqBELLK3+J4pOPe/18y92ShlUs1Pu87ygLydmL9itogZyThnW7tVm Ke7BUJtXkQdPscdXhXtvXvFYzhJrKRoXj+LXX4YHrOJYRlQMSE3IU65qdjdK/5tVfIWt nPbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oLH5VMnE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si876094eji.628.2021.09.29.13.02.44; Wed, 29 Sep 2021 13:03:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oLH5VMnE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346210AbhI2T5I (ORCPT + 99 others); Wed, 29 Sep 2021 15:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345870AbhI2T5D (ORCPT ); Wed, 29 Sep 2021 15:57:03 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4391DC06161C for ; Wed, 29 Sep 2021 12:55:22 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id u18so15450458lfd.12 for ; Wed, 29 Sep 2021 12:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zIP+fT3P6R0yvKNN26znulCvOf0uZzhNp76ydFE5KGM=; b=oLH5VMnESFf8hDlXdhtVvTI4OPGgZPLti9/yUSFcghvqOFR8+1q15z4q6upS+kTSvk K3BKlDD5vbLvfuGkR2znd52pJxoqID2YMqf24qVuId5hOO5io+aMo4+g4+HRMAu3dzsK WQcvLHMd+wdKtmts8MHrukqHFaEGyCQNH12etPoANPb3jeEU5R8zMZcmYOIOL4hl7xdy CpB+Vn7h9KkrmAa77QlZY8thzONOxPKcB4IRQJlb3BHdPdKW8OWixOY1zwrouOPXq2c0 noAeX2Yo54bebM4Tkd0sldYqTE5gbm9ZIjWf7tLIdntkLY/a8q4yXJQ/0+DST800MKRf rUJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zIP+fT3P6R0yvKNN26znulCvOf0uZzhNp76ydFE5KGM=; b=u/Imskqu0CBdcVo/YtcwQGQQJR8khGNwCIoLxSv5AwA1VZAX1LH6oPzBvFT46+49sE MbrXt5uuLUwKU0imnRhC7n5VB6V/RcsXnUZ5r5g+xxFR5Myea5btELljuJKSruQK0UT9 2o0ldgKHRpAtx7rtl7VwTQ6RrbK5o/fqPxV4HHzouKAW2CEU6P9jBIDDB0Jyl7ClO9yz zAB/ORxyqW5OrTno0oO+6T8fvMgMBzqLugQt+MR21RynHWD8X8DA+HQhS0CPrmVyKzrN xQfvOL1qZPZabTQfpGjB3mbAiYLsnPKqmL9TqaeJqf81sAJK9/OFE1FIhBf8hj0t09AV GG3A== X-Gm-Message-State: AOAM532og8DrMDBtNoQPTRxL0eYpSKzzc6I9mmZCx3T1Uc3PywftPZj0 s8gFapjWtBxZbyH0CHiP/cXebstCd6SrK1sE X-Received: by 2002:a05:6512:3f1a:: with SMTP id y26mr1524768lfa.372.1632945320615; Wed, 29 Sep 2021 12:55:20 -0700 (PDT) Received: from [192.168.10.17] (88-112-130-172.elisa-laajakaista.fi. [88.112.130.172]) by smtp.gmail.com with ESMTPSA id z8sm94311lfq.284.2021.09.29.12.55.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 12:55:20 -0700 (PDT) Subject: Re: [PATCH v2 2/4] thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant To: Bjorn Andersson , Andy Gross , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , Thara Gopinath , Dmitry Baryshkov Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210923212311.2877048-1-bjorn.andersson@linaro.org> <20210923212311.2877048-3-bjorn.andersson@linaro.org> From: Vladimir Zapolskiy Message-ID: <04bbf390-9e17-08fb-24dd-f1d71288aaaa@linaro.org> Date: Wed, 29 Sep 2021 22:55:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210923212311.2877048-3-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bjorn, On 9/24/21 12:23 AM, 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 > --- > > Changes since v1: > - New patch > > drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 43 +++++++++++++++++++++++- > 1 file changed, 42 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..7fe5cf28ae15 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,31 @@ 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; > + } if (ret) dev_err(chip->dev, "block write failed: %d\n", ret); above should be sufficient here and similarly in adc_tm5_init(). > + > + return ret; > +} > + > static int adc_tm5_init(struct adc_tm5_chip *chip) > { > u8 buf[4], channels_available; > @@ -591,7 +625,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 +649,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); > -- Best wishes, Vladimir