From patchwork Mon Sep 14 15:48:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 256775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79337C43461 for ; Mon, 14 Sep 2020 15:57:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A3CC20756 for ; Mon, 14 Sep 2020 15:57:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ah7wZk7H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbgINP5p (ORCPT ); Mon, 14 Sep 2020 11:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbgINPsY (ORCPT ); Mon, 14 Sep 2020 11:48:24 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D2B9C0612F2 for ; Mon, 14 Sep 2020 08:48:24 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id s205so88285lja.7 for ; Mon, 14 Sep 2020 08:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u+ec5e/iUjJ8qDBtGE9xKBCADcm1RI8srVHT5OLXlvU=; b=Ah7wZk7H4a1YXb3siR+1ZjnwbjtSkXQdarNonG4apXmKK1RU7RgA3q5ffNCULhdZvv szBF+ywo3gSiAmVakhVSgrzGXibgJEBf0zLpay43DWkEfJks/Sxn9RKntWuRWYaevQev lg3aSW2BNqdhGyZe/JNz3NltDhgf8++D85FQcp14KLyjLf7D4vi1YLxZTZvklHXZ9T8Y Un2iIgaxXMW8MTzeluqSCr7BmwGpo0sk+04aycaYPhknOLHiqpydFmz5ZYsXOE0v/Gbs S1YPClKB3VqmlDYAnn14//BI+/N1syiPKkvqMZDzc7xAJueJPfZwiiaWpHxrUtoA2par bnCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u+ec5e/iUjJ8qDBtGE9xKBCADcm1RI8srVHT5OLXlvU=; b=U1Qqa5pHWRmgIsFtnWujKdrv4V0bLyhHuec5lA5W4HfufFetvvLc8ogp09/p26iJNx xzsf9mfzKzn+vks6qtlZEvlgo/DgrIFcr2xqYrJNAAwsJCdMhU7QeWZWKW5JrmHooKvG AShcubSEjvQ1uCcIc1bPnOSxDkGhACLy6gQ3yCEJ1lWggf1mqsh2lfUPAUkA1EEZQGUT olzVwflHhuimbUuKP+fyRH3aC+NV+E5TJfBwmY2KiMmokYCngjXneJkojkMpbxlCMW+0 Y9TLb6y8IU0KUV0OurOcZpHJt82c7QfORdEg4X+PAcvMzsXLGtDKlJ+WulfJzz3b8HRS dhZQ== X-Gm-Message-State: AOAM5317HaXiZHNGSYtprWCT/f2xRiCzkXjbpNhDLqPNS3FmxkBThePQ N+MY5AaW7ZDZxsQhSgSeIqRudw== X-Google-Smtp-Source: ABdhPJzURBwsNbRnRIeAcecDmShpK8ebYE54NKbCVaKVQd6J/us5aq97BPTZiiIzM3WGoHHWH2cIzQ== X-Received: by 2002:a2e:780d:: with SMTP id t13mr5681189ljc.324.1600098502656; Mon, 14 Sep 2020 08:48:22 -0700 (PDT) Received: from eriador.lan ([188.162.64.187]) by smtp.gmail.com with ESMTPSA id f19sm3834650lfs.85.2020.09.14.08.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 08:48:22 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam , Craig Tatlor , Jonathan Cameron Subject: [PATCH v5 2/9] fixp-arith: add a linear interpolation function Date: Mon, 14 Sep 2020 18:48:02 +0300 Message-Id: <20200914154809.192174-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> References: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Craig Tatlor Adds a function to interpolate against two points, this is carried arount as a helper function by tons of drivers. Signed-off-by: Craig Tatlor Signed-off-by: Dmitry Baryshkov Acked-by: Jonathan Cameron --- include/linux/fixp-arith.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/fixp-arith.h b/include/linux/fixp-arith.h index 8396013785ef..281cb4f83dbe 100644 --- a/include/linux/fixp-arith.h +++ b/include/linux/fixp-arith.h @@ -141,4 +141,23 @@ static inline s32 fixp_sin32_rad(u32 radians, u32 twopi) #define fixp_cos32_rad(rad, twopi) \ fixp_sin32_rad(rad + twopi / 4, twopi) +/** + * fixp_linear_interpolate() - interpolates a value from two known points + * + * @x0: x value of point 0 + * @y0: y value of point 0 + * @x1: x value of point 1 + * @y1: y value of point 1 + * @x: the linear interpolant + */ +static inline int fixp_linear_interpolate(int x0, int y0, int x1, int y1, int x) +{ + if (y0 == y1 || x == x0) + return y0; + if (x1 == x0 || x == x1) + return y1; + + return y0 + ((y1 - y0) * (x - x0) / (x1 - x0)); +} + #endif From patchwork Mon Sep 14 15:48:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 303474 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp1748728ilg; Mon, 14 Sep 2020 08:57:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2BSLxXdxCizAUMJRZ8m59dtKJnD3MRQruIbk7TC+YkuwpPF3XAn1/E9EBtLTXfUCcEXkt X-Received: by 2002:aa7:d88a:: with SMTP id u10mr18078951edq.217.1600099054522; Mon, 14 Sep 2020 08:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600099054; cv=none; d=google.com; s=arc-20160816; b=YDWDcs5HG0ibyOCLkZN9yjEl6BDM0RTD0Kv+u0S0axK60+wKcrGUl60VUosbx5YpEw yh0hKg3QK8dANTx+y1Ierg+XitcLfgIJciDx22St2IyJGig8krG3vdg47v8MdZKjW/hg j5Pb3kHhv8qucaT6OKs0JRSv1n3XazbOktJ02Qv/mP28Wk34tPDfq3BHIr9aFKJnZcmK ZiBaVMICvPhNdu2vDXONxViYa6M41bo7BVLmP2JaHCsaRzKOurOCXjRyY5WvdDiMP19H S3MmmQ6lq/Zrxh+TTmHzPJFIpRbTlwfM3JIMVT+x7p+NNQ//XIGrXjt92+uzfJm2uiqI 8vjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JBF3uLUf/ZUhgh6mGdQvvNaF8GSfsySai+h7lBFUhRU=; b=oaQgzLX3NFQLeCupXu8R3iaNs8y22YjjfbCvTGvhs52RlDswuBMmlFF0SDZ8cK809N dMfEXRNPOdqP2Ok0hTdsQlo+L/LbE1YfSrrC1VC/SepIU0XuPx2OPKNlNmADgIJL0HrS O4y7GEiohMewWJqAZD9ieSQoicUm0hEczyPZ+Oy8GfmiBl5lhrp4VBzd8TB9FgDfFjEi 2lPdRjFeMYWWTOAtg5FizXXmV+gwnG73TCIokn0eVwahSrqfAYUwbJwgPPjOTmqgYc6a BVIWrqTg/IeEBk4Vo0+Up8Nhkw/AsaSjvrovmx85K3VkKKM+C1OKZQddHSfHFbAVPE8J zGMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MHAcrp1D; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 l12si7523298edt.99.2020.09.14.08.57.34; Mon, 14 Sep 2020 08:57:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=MHAcrp1D; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1726019AbgINP52 (ORCPT + 10 others); Mon, 14 Sep 2020 11:57:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbgINPs1 (ORCPT ); Mon, 14 Sep 2020 11:48:27 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72D28C06121F for ; Mon, 14 Sep 2020 08:48:26 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id u8so13977931lff.1 for ; Mon, 14 Sep 2020 08:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JBF3uLUf/ZUhgh6mGdQvvNaF8GSfsySai+h7lBFUhRU=; b=MHAcrp1DIu+7X1MMvIqj8iO10ePD6MAHM7QGaKsy1vPSsC8LWVyzstsV20l33Oiks7 oRYg2yst66/tcD8Ws/E0N07mCSFakO1pFbwSYm0spQE4WHpY8esZf70LfAfq+SYloNoi HEsgpgWnqDpPwVn+jDf1jR03xTyKZLypKafCoXFhW+VJDecJLcim1qP02pR+Scm8YQ9H If9HlsAIFsOleKBHqoPW6GeDCJcyD9TawhVmM1Zaks5pvDZHM+fZPQiT2nj5293TKL1a 9QLOmAV124fClgDLuZfBr65eLj0LQ3aXtba+Eyc490dpezgqThZcYpk9Mfofl1etsNdf Arjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JBF3uLUf/ZUhgh6mGdQvvNaF8GSfsySai+h7lBFUhRU=; b=arlpbuP87ZuedgDUFJFDrgGpXdeAXoRVDdmYQAM5MbWhKNECU1m9U7m5WE//APjhh2 qI+JsMwvSynmN/5V6s0zasQYSy5NrGFWtzf5UmZyXt1abmjRzArUVDj59oGIuWrOsdBN 04Qba3SK303YbEvI69v5094hagTgrykJA5QpTnCTcTdXTefdqn9Zvy3sdviOS1Y9Jova LuoUIRQyiAoU0Y2y4QgiJmADrcEMRY67mRswwXOiwnIBwegGdMQaS/rsI4+kjqhd4nC0 K7FOeOFGH+wwGX3j7i43crkdVYyh6g0tEVUq9KkyClVRhFZd0jzW1tJqoY4BpBNIPcNT vWSg== X-Gm-Message-State: AOAM533gjPBQ+r6UwNpptuhKOEIlgLmE1R/VQgaS6fD26+oEIgeeGJjK iBkDH6qk4Beh9xeXQhi7cXmg3A== X-Received: by 2002:a19:c7d3:: with SMTP id x202mr5518322lff.66.1600098504836; Mon, 14 Sep 2020 08:48:24 -0700 (PDT) Received: from eriador.lan ([188.162.64.187]) by smtp.gmail.com with ESMTPSA id f19sm3834650lfs.85.2020.09.14.08.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 08:48:24 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam , Jonathan Cameron Subject: [PATCH v5 3/9] iio: adc: qcom-vadc: move several adc5 functions to common file Date: Mon, 14 Sep 2020 18:48:03 +0300 Message-Id: <20200914154809.192174-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> References: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org ADC-TM5 driver will make use of several functions from ADC5 driver. Move them to qcom-vadc-common driver. Signed-off-by: Dmitry Baryshkov Reviewed-by: Jonathan Cameron --- drivers/iio/adc/qcom-spmi-adc5.c | 75 +++--------------------------- drivers/iio/adc/qcom-vadc-common.c | 68 ++++++++++++++++++++++++++- drivers/iio/adc/qcom-vadc-common.h | 10 +++- 3 files changed, 82 insertions(+), 71 deletions(-) -- 2.28.0 diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c index c10aa28be70a..c2da8f068b87 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -154,18 +154,6 @@ struct adc5_chip { const struct adc5_data *data; }; -static const struct vadc_prescale_ratio adc5_prescale_ratios[] = { - {.num = 1, .den = 1}, - {.num = 1, .den = 3}, - {.num = 1, .den = 4}, - {.num = 1, .den = 6}, - {.num = 1, .den = 20}, - {.num = 1, .den = 8}, - {.num = 10, .den = 81}, - {.num = 1, .den = 10}, - {.num = 1, .den = 16} -}; - static int adc5_read(struct adc5_chip *adc, u16 offset, u8 *data, int len) { return regmap_bulk_read(adc->regmap, adc->base + offset, data, len); @@ -181,55 +169,6 @@ static int adc5_masked_write(struct adc5_chip *adc, u16 offset, u8 mask, u8 val) return regmap_update_bits(adc->regmap, adc->base + offset, mask, val); } -static int adc5_prescaling_from_dt(u32 num, u32 den) -{ - unsigned int pre; - - for (pre = 0; pre < ARRAY_SIZE(adc5_prescale_ratios); pre++) - if (adc5_prescale_ratios[pre].num == num && - adc5_prescale_ratios[pre].den == den) - break; - - if (pre == ARRAY_SIZE(adc5_prescale_ratios)) - return -EINVAL; - - return pre; -} - -static int adc5_hw_settle_time_from_dt(u32 value, - const unsigned int *hw_settle) -{ - unsigned int i; - - for (i = 0; i < VADC_HW_SETTLE_SAMPLES_MAX; i++) { - if (value == hw_settle[i]) - return i; - } - - return -EINVAL; -} - -static int adc5_avg_samples_from_dt(u32 value) -{ - if (!is_power_of_2(value) || value > ADC5_AVG_SAMPLES_MAX) - return -EINVAL; - - return __ffs(value); -} - -static int adc5_decimation_from_dt(u32 value, - const unsigned int *decimation) -{ - unsigned int i; - - for (i = 0; i < ADC5_DECIMATION_SAMPLES_MAX; i++) { - if (value == decimation[i]) - return i; - } - - return -EINVAL; -} - static int adc5_read_voltage_data(struct adc5_chip *adc, u16 *data) { int ret; @@ -511,7 +450,7 @@ static int adc_read_raw_common(struct iio_dev *indio_dev, return ret; ret = qcom_adc5_hw_scale(prop->scale_fn_type, - &adc5_prescale_ratios[prop->prescale], + prop->prescale, adc->data, adc_code_volt, val); if (ret) @@ -717,7 +656,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc, ret = of_property_read_u32(node, "qcom,decimation", &value); if (!ret) { - ret = adc5_decimation_from_dt(value, data->decimation); + ret = qcom_adc5_decimation_from_dt(value, data->decimation); if (ret < 0) { dev_err(dev, "%02x invalid decimation %d\n", chan, value); @@ -730,7 +669,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc, ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2); if (!ret) { - ret = adc5_prescaling_from_dt(varr[0], varr[1]); + ret = qcom_adc5_prescaling_from_dt(varr[0], varr[1]); if (ret < 0) { dev_err(dev, "%02x invalid pre-scaling <%d %d>\n", chan, varr[0], varr[1]); @@ -759,11 +698,9 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc, if ((dig_version[0] >= ADC5_HW_SETTLE_DIFF_MINOR && dig_version[1] >= ADC5_HW_SETTLE_DIFF_MAJOR) || adc->data->info == &adc7_info) - ret = adc5_hw_settle_time_from_dt(value, - data->hw_settle_2); + ret = qcom_adc5_hw_settle_time_from_dt(value, data->hw_settle_2); else - ret = adc5_hw_settle_time_from_dt(value, - data->hw_settle_1); + ret = qcom_adc5_hw_settle_time_from_dt(value, data->hw_settle_1); if (ret < 0) { dev_err(dev, "%02x invalid hw-settle-time %d us\n", @@ -777,7 +714,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc, ret = of_property_read_u32(node, "qcom,avg-samples", &value); if (!ret) { - ret = adc5_avg_samples_from_dt(value); + ret = qcom_adc5_avg_samples_from_dt(value); if (ret < 0) { dev_err(dev, "%02x invalid avg-samples %d\n", chan, value); diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index 5113aaa6ba67..d11f3343ad52 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -278,6 +278,18 @@ static const struct vadc_map_pt adcmap7_100k[] = { { 2420, 130048 } }; +static const struct vadc_prescale_ratio adc5_prescale_ratios[] = { + {.num = 1, .den = 1}, + {.num = 1, .den = 3}, + {.num = 1, .den = 4}, + {.num = 1, .den = 6}, + {.num = 1, .den = 20}, + {.num = 1, .den = 8}, + {.num = 10, .den = 81}, + {.num = 1, .den = 10}, + {.num = 1, .den = 16} +}; + static int qcom_vadc_scale_hw_calib_volt( const struct vadc_prescale_ratio *prescale, const struct adc5_data *data, @@ -647,10 +659,12 @@ int qcom_vadc_scale(enum vadc_scale_fn_type scaletype, EXPORT_SYMBOL(qcom_vadc_scale); int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, - const struct vadc_prescale_ratio *prescale, + unsigned int prescale_ratio, const struct adc5_data *data, u16 adc_code, int *result) { + const struct vadc_prescale_ratio *prescale = &adc5_prescale_ratios[prescale_ratio]; + if (!(scaletype >= SCALE_HW_CALIB_DEFAULT && scaletype < SCALE_HW_CALIB_INVALID)) { pr_err("Invalid scale type %d\n", scaletype); @@ -662,6 +676,58 @@ int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, } EXPORT_SYMBOL(qcom_adc5_hw_scale); +int qcom_adc5_prescaling_from_dt(u32 num, u32 den) +{ + unsigned int pre; + + for (pre = 0; pre < ARRAY_SIZE(adc5_prescale_ratios); pre++) + if (adc5_prescale_ratios[pre].num == num && + adc5_prescale_ratios[pre].den == den) + break; + + if (pre == ARRAY_SIZE(adc5_prescale_ratios)) + return -EINVAL; + + return pre; +} +EXPORT_SYMBOL(qcom_adc5_prescaling_from_dt); + +int qcom_adc5_hw_settle_time_from_dt(u32 value, + const unsigned int *hw_settle) +{ + unsigned int i; + + for (i = 0; i < VADC_HW_SETTLE_SAMPLES_MAX; i++) { + if (value == hw_settle[i]) + return i; + } + + return -EINVAL; +} +EXPORT_SYMBOL(qcom_adc5_hw_settle_time_from_dt); + +int qcom_adc5_avg_samples_from_dt(u32 value) +{ + if (!is_power_of_2(value) || value > ADC5_AVG_SAMPLES_MAX) + return -EINVAL; + + return __ffs(value); +} +EXPORT_SYMBOL(qcom_adc5_avg_samples_from_dt); + +int qcom_adc5_decimation_from_dt(u32 value, const unsigned int *decimation) +{ + unsigned int i; + + for (i = 0; i < ADC5_DECIMATION_SAMPLES_MAX; i++) { + if (value == decimation[i]) + return i; + } + + return -EINVAL; +} +EXPORT_SYMBOL(qcom_adc5_decimation_from_dt); + int qcom_vadc_decimation_from_dt(u32 value) { if (!is_power_of_2(value) || value < VADC_DECIMATION_MIN || diff --git a/drivers/iio/adc/qcom-vadc-common.h b/drivers/iio/adc/qcom-vadc-common.h index 17b2fc4d8bf2..7e5f6428e311 100644 --- a/drivers/iio/adc/qcom-vadc-common.h +++ b/drivers/iio/adc/qcom-vadc-common.h @@ -168,10 +168,18 @@ struct qcom_adc5_scale_type { }; int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, - const struct vadc_prescale_ratio *prescale, + unsigned int prescale_ratio, const struct adc5_data *data, u16 adc_code, int *result_mdec); +int qcom_adc5_prescaling_from_dt(u32 num, u32 den); + +int qcom_adc5_hw_settle_time_from_dt(u32 value, const unsigned int *hw_settle); + +int qcom_adc5_avg_samples_from_dt(u32 value); + +int qcom_adc5_decimation_from_dt(u32 value, const unsigned int *decimation); + int qcom_vadc_decimation_from_dt(u32 value); #endif /* QCOM_VADC_COMMON_H */ From patchwork Mon Sep 14 15:48:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 256776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A983DC433E2 for ; Mon, 14 Sep 2020 15:57:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DC4620E65 for ; Mon, 14 Sep 2020 15:57:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NDjOuKuq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726003AbgINP5Z (ORCPT ); Mon, 14 Sep 2020 11:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgINPsd (ORCPT ); Mon, 14 Sep 2020 11:48:33 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C05C061221 for ; Mon, 14 Sep 2020 08:48:31 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id y2so13945731lfy.10 for ; Mon, 14 Sep 2020 08:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SyrNRlrzgocwFtm4m1D+vgyjZWlJZcz7p/Dz+/oWD3I=; b=NDjOuKuq0ir6imwOA3BARFgMik89YDK4R/uxZnkdax0YDfc0nrWUbA7C3SYaWWJjm/ DMOwc5DDkuEKFdcd9o5Qd8M+G2xp8OqqdTDwlu2xVylKW4suTKLoJdbW/cp546payEQg wS9JgwqQFW/LLynwetNH8vHnJuJ/69KtgANHCPx8d447klqqSPGJw1a/ER3nyxeYiwtr Q/SLCMOAP/ZjhXlCX4ozanJpJtmxgBTLYgaSO6oNHNjtdNe5XTnz9h5+ZfNq+kR8Lafe bRcTcf3n2xVZ6x6Ddk2tn99EUePeODiAUfEW7DSJlat1ov/mSzSCWKQ/g/DsgPOIyqUJ QGVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SyrNRlrzgocwFtm4m1D+vgyjZWlJZcz7p/Dz+/oWD3I=; b=SKQbxrGvYg0eojapZlpbH7gu8MGMmEDjk4Ouuba2ilyJlwhZmbonABySyuJCXfTI6q +fWbXsUB8fZTlg84LvIclcDzp/8oO+LLEIrm8VrPpAILuHmDZtQbDKCjhtTpjYNWITl7 M9W9n2hyjTajuQj6+d/M/DkYTwBYSP67eWVj0hz1kDSS4NFNGFopBF8OpHwLJrCMZwKn HdaJrXaa+f7X3NsgaJCkSUrehG7nG7CKccvUXUNS15h+zHBqnA+7XxuMbqcqkqutVd9r PMN53YaTlVeGv72JYgINikj7NFFN8DONk9sqDuNpercCqHtBssjNwohYjOX8HRnuv2WU aw+g== X-Gm-Message-State: AOAM5310eAQ21Yd5f6keC46Kq7GreRJOyBj/LoqG8BBYZtx+ZhmVUa0T rM5En8oGSUeDR3Akv8sxB8+2Xw== X-Google-Smtp-Source: ABdhPJx8oyBJT0AivzVhkW6/0QdA3t2Lg4Oc9CjKM0/HsAL0AaGJL1UOLAg2Wpj8H8OFw2Ad0Mo+LQ== X-Received: by 2002:ac2:4903:: with SMTP id n3mr4161358lfi.588.1600098509573; Mon, 14 Sep 2020 08:48:29 -0700 (PDT) Received: from eriador.lan ([188.162.64.187]) by smtp.gmail.com with ESMTPSA id f19sm3834650lfs.85.2020.09.14.08.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 08:48:28 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam , Jonathan Cameron Subject: [PATCH v5 4/9] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Mon, 14 Sep 2020 18:48:04 +0300 Message-Id: <20200914154809.192174-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> References: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use new function fixp_linear_interpolate() instead of hand-coding the linear interpolation. Signed-off-by: Dmitry Baryshkov Reviewed-by: Jonathan Cameron --- drivers/iio/adc/qcom-vadc-common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index d11f3343ad52..40d77b3af1bb 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -368,10 +369,9 @@ static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts, } else { /* result is between search_index and search_index-1 */ /* interpolate linearly */ - *output = (((s32)((pts[i].y - pts[i - 1].y) * - (input - pts[i - 1].x)) / - (pts[i].x - pts[i - 1].x)) + - pts[i - 1].y); + *output = fixp_linear_interpolate(pts[i - 1].x, pts[i - 1].y, + pts[i].x, pts[i].y, + input); } return 0; From patchwork Mon Sep 14 15:48:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 256777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E582C43461 for ; Mon, 14 Sep 2020 15:57:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13709208DB for ; Mon, 14 Sep 2020 15:57:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DvEdx7uD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726098AbgINP5F (ORCPT ); Mon, 14 Sep 2020 11:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726486AbgINPtQ (ORCPT ); Mon, 14 Sep 2020 11:49:16 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765BFC0611C2 for ; Mon, 14 Sep 2020 08:48:39 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id u8so13978668lff.1 for ; Mon, 14 Sep 2020 08:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T0dKj6g81Qnwj432BHav6MjrRFfi+Md37xffdodCkkE=; b=DvEdx7uD1/Zm3rie/uQ6tlufOEMmdWvcII2jHXVVel4u2swQZFQSMvH6BqNLhvfD9+ 5+6yCk7Z1zPLfj4pjx3x0WSitD+lB0ZySJw0mufbyM7v7C+JfVgHvS0esu59ICNHzuhQ nDSLHSeSpsIZxjWRPGeeLlUdBFeWQxSs4Z/6DyBd9rMGt4VmiXw2591CAp6h++6E6msB L90gSFQ0g1lBouovnGPDpAOecxNoDCKqhL00hf0SIxVcm890ghJFpjLo60gPV4UvI+SI YI79imbUY6rDDEfcxKd47KravGlMLrRZhyOumMe7z9KdNJd7D1CZuYsZs7vHO5vbq5nB jOxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T0dKj6g81Qnwj432BHav6MjrRFfi+Md37xffdodCkkE=; b=q4B16r+UHoKAN17oMAgLy+37rOqVySME8eFkUvkpplNKz72MZljpLgrgh9LTzEW6jQ ta7H/c7s6iLcK8rBd7RsL7r90Inu7g4sb8Ero1/D571TtTf9HYp4tLk9J34XaOxE1Zfu k25tA2iF3UhjeLsVsPFpLXBGbR45ntCPB7W28UnQR/jdgOiwcqJAJfH5mG8SSlQZeuui 0lMqju78ewlSGp4cmYGY2lUwIN9jH2JGyZqF7Ct9yHsuvte7VdPmrdnWth+49VpaANn1 ZXeOQTvI2pscBj78Kzj7MNZRdKl/SpYHWuAMSv2lJCTxlAMmNywUjSAnaqNV+/f6S3NU 1bhw== X-Gm-Message-State: AOAM531rcZMb/RUA3Z2vFjWkLqXL83KE7FETXJfZg2qOHWubejZLT6vg tJMSZlc1ihPRzn2wqUoMOFEL4g== X-Google-Smtp-Source: ABdhPJxpreMtAjyot/Y1yFq/EFSN298wN9LEBfZrtPeSJ5Df+KCkBFo+mxAaspxhUPh+O8mvCi7GUw== X-Received: by 2002:ac2:5586:: with SMTP id v6mr5523469lfg.71.1600098517844; Mon, 14 Sep 2020 08:48:37 -0700 (PDT) Received: from eriador.lan ([188.162.64.187]) by smtp.gmail.com with ESMTPSA id f19sm3834650lfs.85.2020.09.14.08.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 08:48:37 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam , Jonathan Cameron Subject: [PATCH v5 6/9] iio: provide of_iio_channel_get_by_name() and devm_ version it Date: Mon, 14 Sep 2020 18:48:06 +0300 Message-Id: <20200914154809.192174-7-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> References: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There might be cases when the IIO channel is attached to the device subnode instead of being attached to the main device node. Allow drivers to query IIO channels by using device tree nodes. Signed-off-by: Dmitry Baryshkov Reviewed-by: Jonathan Cameron --- drivers/iio/inkern.c | 34 ++++++++++++++++++++++++++-------- include/linux/iio/consumer.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index ede99e0d5371..8ff0ac472de3 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -180,8 +180,8 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index) return ERR_PTR(err); } -static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, - const char *name) +struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, + const char *name) { struct iio_channel *chan = NULL; @@ -219,6 +219,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, return chan; } +EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name); static struct iio_channel *of_iio_channel_get_all(struct device *dev) { @@ -261,12 +262,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev) #else /* CONFIG_OF */ -static inline struct iio_channel * -of_iio_channel_get_by_name(struct device_node *np, const char *name) -{ - return NULL; -} - static inline struct iio_channel *of_iio_channel_get_all(struct device *dev) { return NULL; @@ -382,6 +377,29 @@ struct iio_channel *devm_iio_channel_get(struct device *dev, } EXPORT_SYMBOL_GPL(devm_iio_channel_get); +struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev, + struct device_node *np, + const char *channel_name) +{ + struct iio_channel **ptr, *channel; + + ptr = devres_alloc(devm_iio_channel_free, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + channel = of_iio_channel_get_by_name(np, channel_name); + if (IS_ERR(channel)) { + devres_free(ptr); + return channel; + } + + *ptr = channel; + devres_add(dev, ptr); + + return channel; +} +EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name); + struct iio_channel *iio_channel_get_all(struct device *dev) { const char *name; diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index c4118dcb8e05..0a90ba8fa1bb 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -13,6 +13,7 @@ struct iio_dev; struct iio_chan_spec; struct device; +struct device_node; /** * struct iio_channel - everything needed for a consumer to use a channel @@ -97,6 +98,41 @@ void iio_channel_release_all(struct iio_channel *chan); */ struct iio_channel *devm_iio_channel_get_all(struct device *dev); +/** + * of_iio_channel_get_by_name() - get description of all that is needed to access channel. + * @np: Pointer to consumer device tree node + * @consumer_channel: Unique name to identify the channel on the consumer + * side. This typically describes the channels use within + * the consumer. E.g. 'battery_voltage' + */ +#ifdef CONFIG_OF +struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, const char *name); +#else +static inline struct iio_channel * +of_iio_channel_get_by_name(struct device_node *np, const char *name) +{ + return NULL; +} +#endif + +/** + * devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name(). + * @dev: Pointer to consumer device. + * @np: Pointer to consumer device tree node + * @consumer_channel: Unique name to identify the channel on the consumer + * side. This typically describes the channels use within + * the consumer. E.g. 'battery_voltage' + * + * Returns a pointer to negative errno if it is not able to get the iio channel + * otherwise returns valid pointer for iio channel. + * + * The allocated iio channel is automatically released when the device is + * unbound. + */ +struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev, + struct device_node *np, + const char *consumer_channel); + struct iio_cb_buffer; /** * iio_channel_get_all_cb() - register callback for triggered capture From patchwork Mon Sep 14 15:48:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 256778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9C92C2BC11 for ; Mon, 14 Sep 2020 15:56:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96F5A2074B for ; Mon, 14 Sep 2020 15:56:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Vi6FXpnu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725999AbgINP4v (ORCPT ); Mon, 14 Sep 2020 11:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbgINPtQ (ORCPT ); Mon, 14 Sep 2020 11:49:16 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D06C061A10 for ; Mon, 14 Sep 2020 08:48:43 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id q8so13995827lfb.6 for ; Mon, 14 Sep 2020 08:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rflyFynNnBW4dG747SrCFXgcIAs909F2gibnTOq3B0k=; b=Vi6FXpnu6OJLsSniRomWNhFMcykZMY+WXQn2OzVoBGtoACfKPJKdkupRmxBVTk+TLA JGWyZu4TCcv1hb66J6FWfToZWPNZ56oBO2XEmGU/k4BOoBqiyABIafKTSght6I1a42It nKWcySi0v7wmK4FgoWirad6EYq5h+y8iP+jmI2xUPy3bdhMjzSkFFjy/qCqxJED32NQu dkZVvn9fuoH4T9QoYRe5C1OpqDSAB0UDT16kwN1DlwkzNdJzpqMKN/nKGZtGJxunvg7j /rYeIz/3b/+LUfon1rhOkzAUCkrMHMslefrhaJV8hC5JSeRMpYlP1M4dyqcdxktOZwhW CFZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rflyFynNnBW4dG747SrCFXgcIAs909F2gibnTOq3B0k=; b=RJI1BY8cHaI553S/UCS+DMCpR1iI0857A4iFC+YnO1JgxUh6IAWj80GY9wzP2QouUO XE6yo3oJWCp7b/S9OaEWiyi2JK8t0dCyVze1VCIHtOyuSFNMO2mlMR74+Brqrob53OIQ Z6kCqI6coIdryxpIy77yDudCJ93u/LtvEMXafMkh3Y5JT+KQCF9l0UsJdOchmfomvcLa AW5VeWqTsLoU8q4QiZHjWVpeu0T25x1PcMao6szKksaKM8qQ4AydKPPtudlmxGr5Z0+k BBJ8kQZgaDOH4EDcNexoCBbTpYsp0jyZvITHN7rQJ4+eVcLIpHKVrXMGAkGs2ZZgTjP3 CCWg== X-Gm-Message-State: AOAM531dzC+lt+eF/WyWq3POeG8BTkAAPPc+J0EQ265PztjZZbhy8y8b dxPyuOVGYKZjSH8aDX5hOZjm4g== X-Google-Smtp-Source: ABdhPJy9/N98pPIuLPzox9VIlgn2OvbXO+kDoXGMM/BWtVkBQAiPyxd8+YdDHP6q4RWrcbgpCbmujA== X-Received: by 2002:a19:7605:: with SMTP id c5mr5326765lff.116.1600098521751; Mon, 14 Sep 2020 08:48:41 -0700 (PDT) Received: from eriador.lan ([188.162.64.187]) by smtp.gmail.com with ESMTPSA id f19sm3834650lfs.85.2020.09.14.08.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 08:48:41 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 8/9] arm64: dts: qcom: pm8150x: add definitions for adc-tm5 part Date: Mon, 14 Sep 2020 18:48:08 +0300 Message-Id: <20200914154809.192174-9-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> References: <20200914154809.192174-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Define adc-tm5 thermal monitoring part. Individual channes and thermal zones are to be configured in per-device dts files. Signed-off-by: Dmitry Baryshkov Acked-by: Manivannan Sadhasivam --- arch/arm64/boot/dts/qcom/pm8150.dtsi | 10 ++++++++++ arch/arm64/boot/dts/qcom/pm8150b.dtsi | 10 ++++++++++ arch/arm64/boot/dts/qcom/pm8150l.dtsi | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/pm8150.dtsi b/arch/arm64/boot/dts/qcom/pm8150.dtsi index 1b6406927509..b1b518c6a2c9 100644 --- a/arch/arm64/boot/dts/qcom/pm8150.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150.dtsi @@ -97,6 +97,16 @@ die-temp@6 { }; }; + pm8150_adc_tm: adc-tm@3500 { + compatible = "qcom,spmi-adc-tm5"; + reg = <0x3500>; + interrupts = <0x0 0x35 0x0 IRQ_TYPE_EDGE_RISING>; + #thermal-sensor-cells = <1>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + rtc@6000 { compatible = "qcom,pm8941-rtc"; reg = <0x6000>; diff --git a/arch/arm64/boot/dts/qcom/pm8150b.dtsi b/arch/arm64/boot/dts/qcom/pm8150b.dtsi index e112e8876db6..8e2f3250c914 100644 --- a/arch/arm64/boot/dts/qcom/pm8150b.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150b.dtsi @@ -95,6 +95,16 @@ chg-temp@9 { }; }; + pm8150b_adc_tm: adc-tm@3500 { + compatible = "qcom,spmi-adc-tm5"; + reg = <0x3500>; + interrupts = <0x2 0x35 0x0 IRQ_TYPE_EDGE_RISING>; + #thermal-sensor-cells = <1>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + pm8150b_gpios: gpio@c000 { compatible = "qcom,pm8150b-gpio"; reg = <0xc000>; diff --git a/arch/arm64/boot/dts/qcom/pm8150l.dtsi b/arch/arm64/boot/dts/qcom/pm8150l.dtsi index 62139538b7d9..9f214ceec2b7 100644 --- a/arch/arm64/boot/dts/qcom/pm8150l.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150l.dtsi @@ -89,6 +89,16 @@ die-temp@6 { }; }; + pm8150l_adc_tm: adc-tm@3500 { + compatible = "qcom,spmi-adc-tm5"; + reg = <0x3500>; + interrupts = <0x4 0x35 0x0 IRQ_TYPE_EDGE_RISING>; + #thermal-sensor-cells = <1>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + pm8150l_gpios: gpio@c000 { compatible = "qcom,pm8150l-gpio"; reg = <0xc000>;