From patchwork Thu Feb 7 10:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 157689 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp487864jaa; Thu, 7 Feb 2019 02:50:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IavAS3NgtDMn/Y/S6lddIZdj5tQUREPFG8k68W+yDl+KhC3h/Yodesy+lDLT/wMXbB2BSOx X-Received: by 2002:a17:902:ab8f:: with SMTP id f15mr2078480plr.218.1549536604179; Thu, 07 Feb 2019 02:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549536604; cv=none; d=google.com; s=arc-20160816; b=C6sKdCTem0b1PC0szxSRi01WXb/c5h5Nma1av9NSYCW+RoYqpW5TfZqqxmOpZqQO3P N+CyVneINbVpO4WRHlrBshzvV1pzUtKhDfyF8Kj/nebJ9Cw+t30s2EFTl923mGTBfWdg SKmG5Q8rEHJ5FQ4LM++a0IsxX16Yk3wdlo82RQnTYZ2pOOOl8JHljY/iaS5gePtG2wh8 LwEEc7WiLGdoRv5JW8z6gJIM3YFa/lhxaAbLL90Wq/Q2QduYAx5JsM/dpkW3dMVDJ7JV vLhY045sfxtokjEWoZFK0smB3EyVJR+HZnQNsEt4pA6OQmLIo543UyzY2RTFS+mAKC5P mOow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=H2crl7RmZMvIJT00kHO5k98tCahG1bLmtk7Nv322/6A=; b=Vb836nHD3BR+QvrJ2RQGIwuFyz261uTJCr0i8KxsKu2moDUKpHcWxMLvpan/+O07W+ k9zUWkm3rDEXU3qMpQjaIbBZF6Kss9cgEdTR8Alkq1LN8yoRadxg1IrYARCJJ3wpPSqT gOCldOHUv2v0giHwqpNqJLOXVnRoK/akBWYEG4l230prbwZ7ftfRwi0/xZFSBcA56Jbk pNTbvbE8nNRt1loYQHWhGuUEG/5lCRHHEDLfgUrLTJW62L11dlSscp8MJo03aL2fz2m9 p9MDp5t1g5vq3t1yBSSz0koYd3IfPti3KFtHGUzkhExi4OBRDh1Jl7qSbz0QPHBrWwMi 9hxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=woMmpAbv; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id w62si8859545pfk.73.2019.02.07.02.50.03; Thu, 07 Feb 2019 02:50:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=woMmpAbv; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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 S1726985AbfBGKuD (ORCPT + 11 others); Thu, 7 Feb 2019 05:50:03 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44458 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfBGKuD (ORCPT ); Thu, 7 Feb 2019 05:50:03 -0500 Received: by mail-wr1-f65.google.com with SMTP id v16so9126455wrn.11 for ; Thu, 07 Feb 2019 02:50:01 -0800 (PST) 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 :in-reply-to:references; bh=H2crl7RmZMvIJT00kHO5k98tCahG1bLmtk7Nv322/6A=; b=woMmpAbvOB6OAKBWoHY/WgFkqOflUkOdg3Vm0er4QEBoZU7IqZm1lCqnEx7Y96OPaK iH+F7H4/gwJCqvko0pwphaML5ZFTF8p472cuMSj9KUx55y/S3obdknFha/JWtdBc5MYH HciZLy7gx0VqnRRZUQbdAeK5rtjlhoPfZPDg7STgYZZiEnEJBMH5l2dppVr/m/sAlN4u A+zenUaj6QahFzLwhUGMib6Pgv6tJjUHWALyQPp/ziCXbqZvFFGpdAVOpomACsPmrKbW sp1EgUSSdzffKRcAM5lXIwniD0ExKTkcbL8gPnYXQ+6SGzwV2K+/Y7uL9K6daKNmd+9K R4xg== 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:in-reply-to:references; bh=H2crl7RmZMvIJT00kHO5k98tCahG1bLmtk7Nv322/6A=; b=NbbFk+5w2Jhz7Yz5Xd0k317XZLQaCNs63smD0bWfM3Is7sAfFIr1G/yexGxO9ORA+y hvB7i6kf0/dqM1e79JexQKJnoBYZC0pSwNwarBOj+qKNnr8F2q2ldLeRTnfIFbuMZfRr fdAT+w1LBKGE1j08xqF6r5Ab/VHos4+oO50PqOc7aA0VDJAaBltvPCdBvuiAr7W/VafA +QrZf6q9XVrtl+TO2Uqkyl0Uh8zks/ZtfTPTHlgwtvsc8lfobg3KasK+GPL25NSgDFQK G1DakYhSw2LPYkpgRx6l5o9BPK+q1GVRclZHb8I/zzP2059oI91IXzT4VNzKGXPfA47K DLGg== X-Gm-Message-State: AHQUAuYsEFJXgqxxF4xLpqk90JvGStokp/GxRmpRhMu/WWmY9I9ZbqgB kqkRjOL4ZxS5UbGctZpDM3BzoQ== X-Received: by 2002:a5d:6803:: with SMTP id w3mr12013788wru.272.1549536600901; Thu, 07 Feb 2019 02:50:00 -0800 (PST) Received: from localhost ([49.248.196.115]) by smtp.gmail.com with ESMTPSA id a62sm24387481wmf.47.2019.02.07.02.49.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 02:50:00 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v1 01/24] drivers: thermal: tsens: Document the data structures Date: Thu, 7 Feb 2019 16:19:19 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Describe how the TSENS device and the various sensors connected to it are described in the driver Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 7b7feee5dc46..89318523c848 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -14,6 +14,16 @@ struct tsens_device; +/** + * struct tsens_sensor - data for each sensor connected to the tsens device + * @tmdev: tsens device instance that this sensor is connected to + * @tzd: pointer to the thermal zone that this sensor is in + * @offset: offset of temperature adjustment curve + * @id: Sensor ID + * @hw_id: HW ID can be used in case of platform-specific IDs + * @slope: slope of temperature adjustment curve + * @status: 8960-specific variable to track 8960 and 8660 status register offset + */ struct tsens_sensor { struct tsens_device *tmdev; struct thermal_zone_device *tzd; @@ -55,8 +65,8 @@ enum reg_list { }; /** - * struct tsens_data - tsens instance specific data - * @num_sensors: Max number of sensors supported by platform + * struct tsens_data - tsens platform data + * @num_sensors: Number of sensors supported by platform * @ops: operations the tsens instance supports * @hw_ids: Subset of sensors ids supported by platform, if not the first n * @reg_offsets: Register offsets for commonly used registers @@ -68,12 +78,27 @@ struct tsens_data { unsigned int *hw_ids; }; -/* Registers to be saved/restored across a context loss */ +/** + * struct tsens_context - Registers to be saved/restored across a context loss + */ struct tsens_context { int threshold; int control; }; +/** + * struct tsens_device - private data for each instance of the tsens IP + * @dev: pointer to struct device + * @num_sensors: number of sensors enabled on this device + * @tm_map: pointer to TM register address space + * @srot_map: pointer to SROT register address space + * @tm_offset: deal with old device trees that don't address TM and SROT + * address space separately + * @reg_offsets: array of offsets to important regs for this version of IP + * @ctx: registers to be saved and restored during suspend/resume + * @ops: pointer to list of callbacks supported by this device + * @sensor: list of sensors attached to this device + */ struct tsens_device { struct device *dev; u32 num_sensors; From patchwork Thu Feb 7 10:49:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 157692 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp488204jaa; Thu, 7 Feb 2019 02:50:25 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib740ifSJz0JryCyUEmIFnV6eSuTKV45Ltx7cJ4LJ5vhYC6qRfVS3XpQd818cZRMhHkzGeg X-Received: by 2002:a63:d709:: with SMTP id d9mr6421134pgg.157.1549536624960; Thu, 07 Feb 2019 02:50:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549536624; cv=none; d=google.com; s=arc-20160816; b=MhWl1RbUmlqRrj7O3k7/maSEZA2FGFHeoA+z9xmZ7JowAH8p+3RK5KDNDCnmYEok6H qy4zfB8/Uz0DFfF42t5GwlqQXO3F8tzbChhUaTasFvl9eayDVRznFONatkNghgq7q2Ii LCj6KmLB9ABJ7sgpJHIjOcuxXAW5lmDEPzcnaxWnu7D5nQel0+IP/llyysarwhCwh0gy 1dCrII3IAl8a/BhkB1oKD1n3rpAaeIjhCEuN/GkeUdI95VqKyRDzEygW6zi9VyXNtKj/ 4oWX313zbgXa8Bf5ircQtulW3QKTAm9SzachYngqq38LrXJguFrkTb2vsnjiKJQ+zN69 NaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=3oKLYEtp34qQzSU/4qu4XNpq94BvIIyZ8kLyNwL2S7o=; b=IUcIwDNUvELrHu28iHF4h1/jGegYlHtuqP7hs+oOlBskZhmZ64MOfECSSHhyo0XsPh mxz+TrqMOzTDMDmM6zXDIWW+wfjDHvmvF9m/DLShNw/jZyEWZc9Y8gM5LldFjGeWvVso LhtTCHedHd62yeP+lebbNDWH5NlGdekxt2tOq07q5hBSazeGezQDsHPA0qyqOS8W2yrQ dVg/SHz2gfgytFvMtC2veO7J65G8VKEaaOBoDQ8LhEoKoQTF83xUMJ8R+IXFlgyPuEYX Ic7CL3ivoJ99b6pP48XD1OIhHWdXgDov4qXPbOQ+V88hLgI2m6F/s2ZAx2bDH1m1pTnv L/ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKiMYPzw; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d9si7967402pgv.123.2019.02.07.02.50.24; Thu, 07 Feb 2019 02:50:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKiMYPzw; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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 S1727103AbfBGKuY (ORCPT + 11 others); Thu, 7 Feb 2019 05:50:24 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40990 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbfBGKuY (ORCPT ); Thu, 7 Feb 2019 05:50:24 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so10965888wrs.8 for ; Thu, 07 Feb 2019 02:50:21 -0800 (PST) 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 :in-reply-to:references; bh=3oKLYEtp34qQzSU/4qu4XNpq94BvIIyZ8kLyNwL2S7o=; b=xKiMYPzwqQutDnmk1DHPMvHrWqMFgHQtWScQHRE9WfQDLCHyAd2ngLfTTLr8fwiXXD PDpwjh7p/gdcYQzN1z9+rFYHHh5Mz5roKG60V0VJr02hlJsPvAw2mF9XulcLjXQ0Rwsm u2YaKDKM6JR4mCF0Q46+o9EWc48GUvxTuaoKOwh90dya2RjXvpsUtBkrJkLOsuYCxOxA TJwe6KyYN9HKVIYPZYB6TYXrUpFEVOuQWT9NXxq3/Ka31c0tiYpVXEMaRdVqfspjSJX+ 5xtIMc6+TidcCNjiVnnBFuuEyA7bXap6CXbAtFOQVDkxGxW5ZvjThe4F0Y5aRLPF/Sw/ S9mg== 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:in-reply-to:references; bh=3oKLYEtp34qQzSU/4qu4XNpq94BvIIyZ8kLyNwL2S7o=; b=j8bwL4z3fnzMDehLjPs68YWiDhcOz0ARs7AN5CdFvGyoOjYPhr2E4nAqpwJ4lQrGtm PBlKBBO7UtY4/KnlRzkLNhYxYpcNV7zjHi7AiwVDHX0fk18jK3RGCtEPoxWgCwTU3m7c 5NKfjZg7WYI8DMShkiEHNQs7ZvvzxUr6u4cGCTwfOS1av0v86f/0Yld0zJs4doJ1S2Fo V7GNf252hbttjgEtcMy+iqaqsobSL4FMZSW7Pnk8f1ALEM9GuFlddO23FC5yIhYAhIwD tHHWHxvU54nu4UPTve9094LfPAIIkpIcj1THUbael+9LTlW85hyfuXb5EqPGs/YqJsfi RmjQ== X-Gm-Message-State: AHQUAub0xOHB01wpezR8yVb6eR/5681zOKEvAZnxXinEjE+EpQOPv4w4 zsRAAypMQvwpI8VSZIPpAqBhWg== X-Received: by 2002:adf:fbc7:: with SMTP id d7mr11282347wrs.275.1549536620675; Thu, 07 Feb 2019 02:50:20 -0800 (PST) Received: from localhost ([49.248.196.115]) by smtp.gmail.com with ESMTPSA id o5sm14698324wrw.46.2019.02.07.02.50.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 02:50:20 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v1 04/24] drivers: thermal: tsens: Rename variable tmdev Date: Thu, 7 Feb 2019 16:19:22 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org tmdev seems to imply that this is a device pointer when in fact it is just private platform data for each tsens device. Rename it to priv improve code readability. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-8916.c | 16 +++--- drivers/thermal/qcom/tsens-8960.c | 82 ++++++++++++++--------------- drivers/thermal/qcom/tsens-8974.c | 16 +++--- drivers/thermal/qcom/tsens-common.c | 52 +++++++++--------- drivers/thermal/qcom/tsens-v2.c | 12 ++--- drivers/thermal/qcom/tsens.c | 80 ++++++++++++++-------------- drivers/thermal/qcom/tsens.h | 4 +- 7 files changed, 131 insertions(+), 131 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-8916.c b/drivers/thermal/qcom/tsens-8916.c index 7b8f83c9a033..d4ad4082c800 100644 --- a/drivers/thermal/qcom/tsens-8916.c +++ b/drivers/thermal/qcom/tsens-8916.c @@ -39,23 +39,23 @@ #define CAL_SEL_MASK 0xe0000000 #define CAL_SEL_SHIFT 29 -static int calibrate_8916(struct tsens_priv *tmdev) +static int calibrate_8916(struct tsens_priv *priv) { int base0 = 0, base1 = 0, i; u32 p1[5], p2[5]; int mode = 0; u32 *qfprom_cdata, *qfprom_csel; - qfprom_cdata = (u32 *)qfprom_read(tmdev->dev, "calib"); + qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib"); if (IS_ERR(qfprom_cdata)) return PTR_ERR(qfprom_cdata); - qfprom_csel = (u32 *)qfprom_read(tmdev->dev, "calib_sel"); + qfprom_csel = (u32 *)qfprom_read(priv->dev, "calib_sel"); if (IS_ERR(qfprom_csel)) return PTR_ERR(qfprom_csel); mode = (qfprom_csel[0] & CAL_SEL_MASK) >> CAL_SEL_SHIFT; - dev_dbg(tmdev->dev, "calibration mode is %d\n", mode); + dev_dbg(priv->dev, "calibration mode is %d\n", mode); switch (mode) { case TWO_PT_CALIB: @@ -65,7 +65,7 @@ static int calibrate_8916(struct tsens_priv *tmdev) p2[2] = (qfprom_cdata[1] & S2_P2_MASK) >> S2_P2_SHIFT; p2[3] = (qfprom_cdata[1] & S3_P2_MASK) >> S3_P2_SHIFT; p2[4] = (qfprom_cdata[1] & S4_P2_MASK) >> S4_P2_SHIFT; - for (i = 0; i < tmdev->num_sensors; i++) + for (i = 0; i < priv->num_sensors; i++) p2[i] = ((base1 + p2[i]) << 3); /* Fall through */ case ONE_PT_CALIB2: @@ -75,18 +75,18 @@ static int calibrate_8916(struct tsens_priv *tmdev) p1[2] = (qfprom_cdata[0] & S2_P1_MASK) >> S2_P1_SHIFT; p1[3] = (qfprom_cdata[1] & S3_P1_MASK) >> S3_P1_SHIFT; p1[4] = (qfprom_cdata[1] & S4_P1_MASK) >> S4_P1_SHIFT; - for (i = 0; i < tmdev->num_sensors; i++) + for (i = 0; i < priv->num_sensors; i++) p1[i] = (((base0) + p1[i]) << 3); break; default: - for (i = 0; i < tmdev->num_sensors; i++) { + for (i = 0; i < priv->num_sensors; i++) { p1[i] = 500; p2[i] = 780; } break; } - compute_intercept_slope(tmdev, p1, p2, mode); + compute_intercept_slope(priv, p1, p2, mode); return 0; } diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 7e340eea48da..8d9b721dadb6 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -56,21 +56,21 @@ #define TRDY_MASK BIT(7) #define TIMEOUT_US 100 -static int suspend_8960(struct tsens_priv *tmdev) +static int suspend_8960(struct tsens_priv *priv) { int ret; unsigned int mask; - struct regmap *map = tmdev->tm_map; + struct regmap *map = priv->tm_map; - ret = regmap_read(map, THRESHOLD_ADDR, &tmdev->ctx.threshold); + ret = regmap_read(map, THRESHOLD_ADDR, &priv->ctx.threshold); if (ret) return ret; - ret = regmap_read(map, CNTL_ADDR, &tmdev->ctx.control); + ret = regmap_read(map, CNTL_ADDR, &priv->ctx.control); if (ret) return ret; - if (tmdev->num_sensors > 1) + if (priv->num_sensors > 1) mask = SLP_CLK_ENA | EN; else mask = SLP_CLK_ENA_8660 | EN; @@ -82,10 +82,10 @@ static int suspend_8960(struct tsens_priv *tmdev) return 0; } -static int resume_8960(struct tsens_priv *tmdev) +static int resume_8960(struct tsens_priv *priv) { int ret; - struct regmap *map = tmdev->tm_map; + struct regmap *map = priv->tm_map; ret = regmap_update_bits(map, CNTL_ADDR, SW_RST, SW_RST); if (ret) @@ -95,80 +95,80 @@ static int resume_8960(struct tsens_priv *tmdev) * Separate CONFIG restore is not needed only for 8660 as * config is part of CTRL Addr and its restored as such */ - if (tmdev->num_sensors > 1) { + if (priv->num_sensors > 1) { ret = regmap_update_bits(map, CONFIG_ADDR, CONFIG_MASK, CONFIG); if (ret) return ret; } - ret = regmap_write(map, THRESHOLD_ADDR, tmdev->ctx.threshold); + ret = regmap_write(map, THRESHOLD_ADDR, priv->ctx.threshold); if (ret) return ret; - ret = regmap_write(map, CNTL_ADDR, tmdev->ctx.control); + ret = regmap_write(map, CNTL_ADDR, priv->ctx.control); if (ret) return ret; return 0; } -static int enable_8960(struct tsens_priv *tmdev, int id) +static int enable_8960(struct tsens_priv *priv, int id) { int ret; u32 reg, mask; - ret = regmap_read(tmdev->tm_map, CNTL_ADDR, ®); + ret = regmap_read(priv->tm_map, CNTL_ADDR, ®); if (ret) return ret; mask = BIT(id + SENSOR0_SHIFT); - ret = regmap_write(tmdev->tm_map, CNTL_ADDR, reg | SW_RST); + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg | SW_RST); if (ret) return ret; - if (tmdev->num_sensors > 1) + if (priv->num_sensors > 1) reg |= mask | SLP_CLK_ENA | EN; else reg |= mask | SLP_CLK_ENA_8660 | EN; - ret = regmap_write(tmdev->tm_map, CNTL_ADDR, reg); + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg); if (ret) return ret; return 0; } -static void disable_8960(struct tsens_priv *tmdev) +static void disable_8960(struct tsens_priv *priv) { int ret; u32 reg_cntl; u32 mask; - mask = GENMASK(tmdev->num_sensors - 1, 0); + mask = GENMASK(priv->num_sensors - 1, 0); mask <<= SENSOR0_SHIFT; mask |= EN; - ret = regmap_read(tmdev->tm_map, CNTL_ADDR, ®_cntl); + ret = regmap_read(priv->tm_map, CNTL_ADDR, ®_cntl); if (ret) return; reg_cntl &= ~mask; - if (tmdev->num_sensors > 1) + if (priv->num_sensors > 1) reg_cntl &= ~SLP_CLK_ENA; else reg_cntl &= ~SLP_CLK_ENA_8660; - regmap_write(tmdev->tm_map, CNTL_ADDR, reg_cntl); + regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); } -static int init_8960(struct tsens_priv *tmdev) +static int init_8960(struct tsens_priv *priv) { int ret, i; u32 reg_cntl; - tmdev->tm_map = dev_get_regmap(tmdev->dev, NULL); - if (!tmdev->tm_map) + priv->tm_map = dev_get_regmap(priv->dev, NULL); + if (!priv->tm_map) return -ENODEV; /* @@ -177,21 +177,21 @@ static int init_8960(struct tsens_priv *tmdev) * but the control registers stay in the same place, i.e * directly after the first 5 status registers. */ - for (i = 0; i < tmdev->num_sensors; i++) { + for (i = 0; i < priv->num_sensors; i++) { if (i >= 5) - tmdev->sensor[i].status = S0_STATUS_ADDR + 40; - tmdev->sensor[i].status += i * 4; + priv->sensor[i].status = S0_STATUS_ADDR + 40; + priv->sensor[i].status += i * 4; } reg_cntl = SW_RST; - ret = regmap_update_bits(tmdev->tm_map, CNTL_ADDR, SW_RST, reg_cntl); + ret = regmap_update_bits(priv->tm_map, CNTL_ADDR, SW_RST, reg_cntl); if (ret) return ret; - if (tmdev->num_sensors > 1) { + if (priv->num_sensors > 1) { reg_cntl |= SLP_CLK_ENA | (MEASURE_PERIOD << 18); reg_cntl &= ~SW_RST; - ret = regmap_update_bits(tmdev->tm_map, CONFIG_ADDR, + ret = regmap_update_bits(priv->tm_map, CONFIG_ADDR, CONFIG_MASK, CONFIG); } else { reg_cntl |= SLP_CLK_ENA_8660 | (MEASURE_PERIOD << 16); @@ -199,30 +199,30 @@ static int init_8960(struct tsens_priv *tmdev) reg_cntl |= CONFIG_8660 << CONFIG_SHIFT_8660; } - reg_cntl |= GENMASK(tmdev->num_sensors - 1, 0) << SENSOR0_SHIFT; - ret = regmap_write(tmdev->tm_map, CNTL_ADDR, reg_cntl); + reg_cntl |= GENMASK(priv->num_sensors - 1, 0) << SENSOR0_SHIFT; + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); if (ret) return ret; reg_cntl |= EN; - ret = regmap_write(tmdev->tm_map, CNTL_ADDR, reg_cntl); + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); if (ret) return ret; return 0; } -static int calibrate_8960(struct tsens_priv *tmdev) +static int calibrate_8960(struct tsens_priv *priv) { int i; char *data; - ssize_t num_read = tmdev->num_sensors; - struct tsens_sensor *s = tmdev->sensor; + ssize_t num_read = priv->num_sensors; + struct tsens_sensor *s = priv->sensor; - data = qfprom_read(tmdev->dev, "calib"); + data = qfprom_read(priv->dev, "calib"); if (IS_ERR(data)) - data = qfprom_read(tmdev->dev, "calib_backup"); + data = qfprom_read(priv->dev, "calib_backup"); if (IS_ERR(data)) return PTR_ERR(data); @@ -243,21 +243,21 @@ static inline int code_to_mdegC(u32 adc_code, const struct tsens_sensor *s) return adc_code * slope + offset; } -static int get_temp_8960(struct tsens_priv *tmdev, int id, int *temp) +static int get_temp_8960(struct tsens_priv *priv, int id, int *temp) { int ret; u32 code, trdy; - const struct tsens_sensor *s = &tmdev->sensor[id]; + const struct tsens_sensor *s = &priv->sensor[id]; unsigned long timeout; timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); do { - ret = regmap_read(tmdev->tm_map, INT_STATUS_ADDR, &trdy); + ret = regmap_read(priv->tm_map, INT_STATUS_ADDR, &trdy); if (ret) return ret; if (!(trdy & TRDY_MASK)) continue; - ret = regmap_read(tmdev->tm_map, s->status, &code); + ret = regmap_read(priv->tm_map, s->status, &code); if (ret) return ret; *temp = code_to_mdegC(code, s); diff --git a/drivers/thermal/qcom/tsens-8974.c b/drivers/thermal/qcom/tsens-8974.c index f983f98f2176..303157fd00be 100644 --- a/drivers/thermal/qcom/tsens-8974.c +++ b/drivers/thermal/qcom/tsens-8974.c @@ -91,7 +91,7 @@ #define BIT_APPEND 0x3 -static int calibrate_8974(struct tsens_priv *tmdev) +static int calibrate_8974(struct tsens_priv *priv) { int base1 = 0, base2 = 0, i; u32 p1[11], p2[11]; @@ -99,11 +99,11 @@ static int calibrate_8974(struct tsens_priv *tmdev) u32 *calib, *bkp; u32 calib_redun_sel; - calib = (u32 *)qfprom_read(tmdev->dev, "calib"); + calib = (u32 *)qfprom_read(priv->dev, "calib"); if (IS_ERR(calib)) return PTR_ERR(calib); - bkp = (u32 *)qfprom_read(tmdev->dev, "calib_backup"); + bkp = (u32 *)qfprom_read(priv->dev, "calib_backup"); if (IS_ERR(bkp)) return PTR_ERR(bkp); @@ -184,25 +184,25 @@ static int calibrate_8974(struct tsens_priv *tmdev) switch (mode) { case ONE_PT_CALIB: - for (i = 0; i < tmdev->num_sensors; i++) + for (i = 0; i < priv->num_sensors; i++) p1[i] += (base1 << 2) | BIT_APPEND; break; case TWO_PT_CALIB: - for (i = 0; i < tmdev->num_sensors; i++) { + for (i = 0; i < priv->num_sensors; i++) { p2[i] += base2; p2[i] <<= 2; p2[i] |= BIT_APPEND; } /* Fall through */ case ONE_PT_CALIB2: - for (i = 0; i < tmdev->num_sensors; i++) { + for (i = 0; i < priv->num_sensors; i++) { p1[i] += base1; p1[i] <<= 2; p1[i] |= BIT_APPEND; } break; default: - for (i = 0; i < tmdev->num_sensors; i++) + for (i = 0; i < priv->num_sensors; i++) p2[i] = 780; p1[0] = 502; p1[1] = 509; @@ -218,7 +218,7 @@ static int calibrate_8974(struct tsens_priv *tmdev) break; } - compute_intercept_slope(tmdev, p1, p2, mode); + compute_intercept_slope(priv, p1, p2, mode); return 0; } diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 128ee3621b41..af87216ee407 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -46,18 +46,18 @@ char *qfprom_read(struct device *dev, const char *cname) * and offset values are derived from tz->tzp->slope and tz->tzp->offset * resp. */ -void compute_intercept_slope(struct tsens_priv *tmdev, u32 *p1, +void compute_intercept_slope(struct tsens_priv *priv, u32 *p1, u32 *p2, u32 mode) { int i; int num, den; - for (i = 0; i < tmdev->num_sensors; i++) { - dev_dbg(tmdev->dev, + for (i = 0; i < priv->num_sensors; i++) { + dev_dbg(priv->dev, "sensor%d - data_point1:%#x data_point2:%#x\n", i, p1[i], p2[i]); - tmdev->sensor[i].slope = SLOPE_DEFAULT; + priv->sensor[i].slope = SLOPE_DEFAULT; if (mode == TWO_PT_CALIB) { /* * slope (m) = adc_code2 - adc_code1 (y2 - y1)/ @@ -66,13 +66,13 @@ void compute_intercept_slope(struct tsens_priv *tmdev, u32 *p1, num = p2[i] - p1[i]; num *= SLOPE_FACTOR; den = CAL_DEGC_PT2 - CAL_DEGC_PT1; - tmdev->sensor[i].slope = num / den; + priv->sensor[i].slope = num / den; } - tmdev->sensor[i].offset = (p1[i] * SLOPE_FACTOR) - + priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) - (CAL_DEGC_PT1 * - tmdev->sensor[i].slope); - dev_dbg(tmdev->dev, "offset:%d\n", tmdev->sensor[i].offset); + priv->sensor[i].slope); + dev_dbg(priv->dev, "offset:%d\n", priv->sensor[i].offset); } } @@ -95,15 +95,15 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } -int get_temp_common(struct tsens_priv *tmdev, int id, int *temp) +int get_temp_common(struct tsens_priv *priv, int id, int *temp) { - struct tsens_sensor *s = &tmdev->sensor[id]; + struct tsens_sensor *s = &priv->sensor[id]; u32 code; unsigned int status_reg; int last_temp = 0, ret; - status_reg = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * SN_ADDR_OFFSET; - ret = regmap_read(tmdev->tm_map, status_reg, &code); + status_reg = priv->tm_offset + STATUS_OFFSET + s->hw_id * SN_ADDR_OFFSET; + ret = regmap_read(priv->tm_map, status_reg, &code); if (ret) return ret; last_temp = code & SN_ST_TEMP_MASK; @@ -127,34 +127,34 @@ static const struct regmap_config tsens_srot_config = { .reg_stride = 4, }; -int __init init_common(struct tsens_priv *tmdev) +int __init init_common(struct tsens_priv *priv) { void __iomem *tm_base, *srot_base; struct resource *res; u32 code; int ret; - struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); - u16 ctrl_offset = tmdev->reg_offsets[SROT_CTRL_OFFSET]; + struct platform_device *op = of_find_device_by_node(priv->dev->of_node); + u16 ctrl_offset = priv->reg_offsets[SROT_CTRL_OFFSET]; if (!op) return -EINVAL; if (op->num_resources > 1) { /* DT with separate SROT and TM address space */ - tmdev->tm_offset = 0; + priv->tm_offset = 0; res = platform_get_resource(op, IORESOURCE_MEM, 1); srot_base = devm_ioremap_resource(&op->dev, res); if (IS_ERR(srot_base)) return PTR_ERR(srot_base); - tmdev->srot_map = devm_regmap_init_mmio(tmdev->dev, srot_base, + priv->srot_map = devm_regmap_init_mmio(priv->dev, srot_base, &tsens_srot_config); - if (IS_ERR(tmdev->srot_map)) - return PTR_ERR(tmdev->srot_map); + if (IS_ERR(priv->srot_map)) + return PTR_ERR(priv->srot_map); } else { /* old DTs where SROT and TM were in a contiguous 2K block */ - tmdev->tm_offset = 0x1000; + priv->tm_offset = 0x1000; } res = platform_get_resource(op, IORESOURCE_MEM, 0); @@ -162,16 +162,16 @@ int __init init_common(struct tsens_priv *tmdev) if (IS_ERR(tm_base)) return PTR_ERR(tm_base); - tmdev->tm_map = devm_regmap_init_mmio(tmdev->dev, tm_base, &tsens_config); - if (IS_ERR(tmdev->tm_map)) - return PTR_ERR(tmdev->tm_map); + priv->tm_map = devm_regmap_init_mmio(priv->dev, tm_base, &tsens_config); + if (IS_ERR(priv->tm_map)) + return PTR_ERR(priv->tm_map); - if (tmdev->srot_map) { - ret = regmap_read(tmdev->srot_map, ctrl_offset, &code); + if (priv->srot_map) { + ret = regmap_read(priv->srot_map, ctrl_offset, &code); if (ret) return ret; if (!(code & TSENS_EN)) { - dev_err(tmdev->dev, "tsens device is not enabled\n"); + dev_err(priv->dev, "tsens device is not enabled\n"); return -ENODEV; } } diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index d812fd3f4567..8b700772d903 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -12,16 +12,16 @@ #define LAST_TEMP_MASK 0xfff #define STATUS_VALID_BIT BIT(21) -static int get_temp_tsens_v2(struct tsens_priv *tmdev, int id, int *temp) +static int get_temp_tsens_v2(struct tsens_priv *priv, int id, int *temp) { - struct tsens_sensor *s = &tmdev->sensor[id]; + struct tsens_sensor *s = &priv->sensor[id]; u32 code; unsigned int status_reg; u32 last_temp = 0, last_temp2 = 0, last_temp3 = 0; int ret; - status_reg = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 4; - ret = regmap_read(tmdev->tm_map, status_reg, &code); + status_reg = priv->tm_offset + STATUS_OFFSET + s->hw_id * 4; + ret = regmap_read(priv->tm_map, status_reg, &code); if (ret) return ret; last_temp = code & LAST_TEMP_MASK; @@ -29,7 +29,7 @@ static int get_temp_tsens_v2(struct tsens_priv *tmdev, int id, int *temp) goto done; /* Try a second time */ - ret = regmap_read(tmdev->tm_map, status_reg, &code); + ret = regmap_read(priv->tm_map, status_reg, &code); if (ret) return ret; if (code & STATUS_VALID_BIT) { @@ -40,7 +40,7 @@ static int get_temp_tsens_v2(struct tsens_priv *tmdev, int id, int *temp) } /* Try a third/last time */ - ret = regmap_read(tmdev->tm_map, status_reg, &code); + ret = regmap_read(priv->tm_map, status_reg, &code); if (ret) return ret; if (code & STATUS_VALID_BIT) { diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 074fbb4d70f2..4582d2b30e94 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -15,38 +15,38 @@ static int tsens_get_temp(void *data, int *temp) { const struct tsens_sensor *s = data; - struct tsens_priv *tmdev = s->tmdev; + struct tsens_priv *priv = s->priv; - return tmdev->ops->get_temp(tmdev, s->id, temp); + return priv->ops->get_temp(priv, s->id, temp); } static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend) { const struct tsens_sensor *s = p; - struct tsens_priv *tmdev = s->tmdev; + struct tsens_priv *priv = s->priv; - if (tmdev->ops->get_trend) - return tmdev->ops->get_trend(tmdev, s->id, trend); + if (priv->ops->get_trend) + return priv->ops->get_trend(priv, s->id, trend); return -ENOTSUPP; } static int __maybe_unused tsens_suspend(struct device *dev) { - struct tsens_priv *tmdev = dev_get_drvdata(dev); + struct tsens_priv *priv = dev_get_drvdata(dev); - if (tmdev->ops && tmdev->ops->suspend) - return tmdev->ops->suspend(tmdev); + if (priv->ops && priv->ops->suspend) + return priv->ops->suspend(priv); return 0; } static int __maybe_unused tsens_resume(struct device *dev) { - struct tsens_priv *tmdev = dev_get_drvdata(dev); + struct tsens_priv *priv = dev_get_drvdata(dev); - if (tmdev->ops && tmdev->ops->resume) - return tmdev->ops->resume(tmdev); + if (priv->ops && priv->ops->resume) + return priv->ops->resume(priv); return 0; } @@ -76,22 +76,22 @@ static const struct thermal_zone_of_device_ops tsens_of_ops = { .get_trend = tsens_get_trend, }; -static int tsens_register(struct tsens_priv *tmdev) +static int tsens_register(struct tsens_priv *priv) { int i; struct thermal_zone_device *tzd; - for (i = 0; i < tmdev->num_sensors; i++) { - tmdev->sensor[i].tmdev = tmdev; - tmdev->sensor[i].id = i; - tzd = devm_thermal_zone_of_sensor_register(tmdev->dev, i, - &tmdev->sensor[i], + for (i = 0; i < priv->num_sensors; i++) { + priv->sensor[i].priv = priv; + priv->sensor[i].id = i; + tzd = devm_thermal_zone_of_sensor_register(priv->dev, i, + &priv->sensor[i], &tsens_of_ops); if (IS_ERR(tzd)) continue; - tmdev->sensor[i].tzd = tzd; - if (tmdev->ops->enable) - tmdev->ops->enable(tmdev, i); + priv->sensor[i].tzd = tzd; + if (priv->ops->enable) + priv->ops->enable(priv, i); } return 0; } @@ -101,7 +101,7 @@ static int tsens_probe(struct platform_device *pdev) int ret, i; struct device *dev; struct device_node *np; - struct tsens_priv *tmdev; + struct tsens_priv *priv; const struct tsens_plat_data *data; const struct of_device_id *id; u32 num_sensors; @@ -129,55 +129,55 @@ static int tsens_probe(struct platform_device *pdev) return -EINVAL; } - tmdev = devm_kzalloc(dev, - struct_size(tmdev, sensor, num_sensors), + priv = devm_kzalloc(dev, + struct_size(priv, sensor, num_sensors), GFP_KERNEL); - if (!tmdev) + if (!priv) return -ENOMEM; - tmdev->dev = dev; - tmdev->num_sensors = num_sensors; - tmdev->ops = data->ops; - for (i = 0; i < tmdev->num_sensors; i++) { + priv->dev = dev; + priv->num_sensors = num_sensors; + priv->ops = data->ops; + for (i = 0; i < priv->num_sensors; i++) { if (data->hw_ids) - tmdev->sensor[i].hw_id = data->hw_ids[i]; + priv->sensor[i].hw_id = data->hw_ids[i]; else - tmdev->sensor[i].hw_id = i; + priv->sensor[i].hw_id = i; } for (i = 0; i < REG_ARRAY_SIZE; i++) { - tmdev->reg_offsets[i] = data->reg_offsets[i]; + priv->reg_offsets[i] = data->reg_offsets[i]; } - if (!tmdev->ops || !tmdev->ops->init || !tmdev->ops->get_temp) + if (!priv->ops || !priv->ops->init || !priv->ops->get_temp) return -EINVAL; - ret = tmdev->ops->init(tmdev); + ret = priv->ops->init(priv); if (ret < 0) { dev_err(dev, "tsens init failed\n"); return ret; } - if (tmdev->ops->calibrate) { - ret = tmdev->ops->calibrate(tmdev); + if (priv->ops->calibrate) { + ret = priv->ops->calibrate(priv); if (ret < 0) { dev_err(dev, "tsens calibration failed\n"); return ret; } } - ret = tsens_register(tmdev); + ret = tsens_register(priv); - platform_set_drvdata(pdev, tmdev); + platform_set_drvdata(pdev, priv); return ret; } static int tsens_remove(struct platform_device *pdev) { - struct tsens_priv *tmdev = platform_get_drvdata(pdev); + struct tsens_priv *priv = platform_get_drvdata(pdev); - if (tmdev->ops->disable) - tmdev->ops->disable(tmdev); + if (priv->ops->disable) + priv->ops->disable(priv); return 0; } diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 936bdc7b1bc2..61ca2905ee7a 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -16,7 +16,7 @@ struct tsens_priv; /** * struct tsens_sensor - data for each sensor connected to the tsens device - * @tmdev: tsens device instance that this sensor is connected to + * @priv: tsens device instance that this sensor is connected to * @tzd: pointer to the thermal zone that this sensor is in * @offset: offset of temperature adjustment curve * @id: Sensor ID @@ -25,7 +25,7 @@ struct tsens_priv; * @status: 8960-specific variable to track 8960 and 8660 status register offset */ struct tsens_sensor { - struct tsens_priv *tmdev; + struct tsens_priv *priv; struct thermal_zone_device *tzd; int offset; int id; From patchwork Thu Feb 7 10:49:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 157734 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp610044jaa; Thu, 7 Feb 2019 04:56:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IYDUZabgiq/jSF/c+pykQfEWLuN6qQNC11tVmH8fT4UNmsJJLJKaT/y0vkLgerCihIByRJG X-Received: by 2002:a17:902:209:: with SMTP id 9mr16499996plc.288.1549544184677; Thu, 07 Feb 2019 04:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549544184; cv=none; d=google.com; s=arc-20160816; b=0l6Y3kqAhMnsC9DDkk5M7mheZvZxx9JiI1gpNtrbQiCQZCoiGE8bbUL709LeLAeqYW SYjaq8G4wpBgJsytWp307XJT8Aor4phpAvunKNrbPdDSJRo8VWQnjwObFmiRPsQB7MsS koOsn8FGF1+jJxn/zhOKTSETZsxqgxEUE19j/AfaGtg8xDIBneuxgTNQrclhUHM/Dqvk KYSp0cLZulv+vb7AS4lltyHTGdqQ4fgVl7jDyUH4hTK+3UvCL5H8LILgUav139jKFZxS qp+EItDTBL5+KpHPUclktlPUpk/UNu9ulQxFEvrrwL+7xom1SlHzjm+GRlK/hJRTqL+F UfsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=Tf/kMCCdkeqQnWWFTTv8/xc1yH66O1Xq3Z4kaU9bVds=; b=JCdIvgenbVy4C7+yJyXtYdSB6QkVL4CPJoCdzHs+bK86PPuYQQJbA8zrLLxROvZEJt bTseuX7zvXBRPQyn40H6FC4CB49RcJSHGbLqbIzxNH6xT4QDDtoiTvTp8oqxrWgR9Dox jMuzblqFuAlZwGqs5DzZiYir6wx6aXGIOhZzPE8scU9x2/VxrKm1r+ZFLBkCXFysHoFv ZOfdqG9MK8T2KgPjbeOCFAFnEpyIWm+myI/CW1TjKZX4S6Do5hPUnQUOKWTt2YdKd4Yg 1pQzfFV1Hj05WEMwBH4FB4wyz2cAbEQtDt+EDmSqtVCN5ZtnSxVWWlQyNeWUWM0zit9n gJMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sU0v9qq5; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id a11si9338061pla.20.2019.02.07.04.56.24; Thu, 07 Feb 2019 04:56:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sU0v9qq5; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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 S1727166AbfBGM4X (ORCPT + 11 others); Thu, 7 Feb 2019 07:56:23 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37914 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbfBGM4X (ORCPT ); Thu, 7 Feb 2019 07:56:23 -0500 Received: by mail-pg1-f196.google.com with SMTP id g189so4456518pgc.5 for ; Thu, 07 Feb 2019 04:56:23 -0800 (PST) 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 :in-reply-to:references; bh=Tf/kMCCdkeqQnWWFTTv8/xc1yH66O1Xq3Z4kaU9bVds=; b=sU0v9qq55wH6RZ1IqLcOLRepVD1ccpTpRFppGRa4VCWQUbnzgIyNWV+du9D14r6IXV SMAH+vcKVAmm7wXBodx14h8gf+pPYJQvfmjDQFjZVnjRPWSVqj/gYrLRmdAzFIqj0+nU aTPkmaRsbf3w1Getc4x67lOB4e3t3mlqED+pPmlTUEvtvxBh2P2NjzTgPROB1ONzvR+P GF1OMJalZfmh2MB/wiNatnsMQ27h3Iw/YKtQogXolYFRXwG2wfuLwGsSVK3aU/nvISFx GeTnAuoJx8f2jnSlqqzx18tO9y5VtExoyTRYCT//p0kVZcPs+1W9oRUrr8OqTetvmEgf Cvjw== 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:in-reply-to:references; bh=Tf/kMCCdkeqQnWWFTTv8/xc1yH66O1Xq3Z4kaU9bVds=; b=jfOn4MwM1mbBXatiSHDxs8BIqJ0OP5j1fjF3MBJl3dFoQYlrnS/u0t4kzn/HXfitVG ltDaHlbQmOImD7wWNo005RSFpUh3JTn+xSlyHWlM7/b+D+/Wz8mse2KBOOQrR3SnyEtM ojBMb0cH77B1TRrezrJuoq0vALFfpe3A6cq9vskz0AbsSt9iUXMvbr7XKgF80TQv+xFI 4hZkUfKlWsccDdHJHl5XSUZRdtt0A2pfzizhEyYs8ypjNVsWa+D3Z2cD4snZEavhi8GJ gzhuWelUBg9HQ5/7TodagQMfVDO1mTlWxUg1RzbtfUdy0gQyhjt1lqmWQ3nfF1CH/Jul RYAg== X-Gm-Message-State: AHQUAubdEPWAL3jqthbBaHOgn9+geajA3u4L+FllcFwbdDhlfivxpveY JOvUBgfxkUHLao26UCjvlJe89w== X-Received: by 2002:a63:1e17:: with SMTP id e23mr1052210pge.130.1549544182620; Thu, 07 Feb 2019 04:56:22 -0800 (PST) Received: from localhost ([2402:3a80:c80:4138:75dd:3900:1d90:762f]) by smtp.gmail.com with ESMTPSA id y6sm13045892pfd.104.2019.02.07.04.56.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 04:56:22 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v1 15/24] drivers: thermal: tsens: change data type for sensor IDs Date: Thu, 7 Feb 2019 16:19:33 +0530 Message-Id: <86ff4442dc1cae50a5f63aaa06c831bd3ee76d9c.1549525708.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The IDs cannot be negative, fix the data type. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index da4cfb23dfe9..e0c1ca1a7467 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -29,8 +29,8 @@ struct tsens_sensor { struct tsens_priv *priv; struct thermal_zone_device *tzd; int offset; - int id; - int hw_id; + unsigned int id; + unsigned int hw_id; int slope; u32 status; }; From patchwork Thu Feb 7 10:49:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 157737 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp610687jaa; Thu, 7 Feb 2019 04:57:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IaZjAb4SMNupHQZLLZqtabC3HS8tuPwq3ikIKqqqKQrT/0GuKBwfufmL57tf1JNoKILs1TD X-Received: by 2002:a17:902:8203:: with SMTP id x3mr16418583pln.285.1549544225989; Thu, 07 Feb 2019 04:57:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549544225; cv=none; d=google.com; s=arc-20160816; b=V44Knlyd3eG6/T+5xFDHfeXS2kNTDlIeHZNEYCQ1WnMnH16bdpCh4wGv1dMAPQFusa yI5M5WPjJY3DZYSjGuhFgU/ttFAKBovC1kAQUQL2PkBy/ONzuASTcYn7pTh73KT9Pa09 9A42kD5P1nJrYqoLVKWhv6OULe2dPl+TzP48mGoFVvgMRAHjSo3PWToNzEw4/Q6DeLR3 InFxLieYqaQ6dQ1RyagsbQU7V92Vh6MG8WLLcvIxSCxKJrPsAwzM0KpFOH0czz4aTUCH wlqZCC6bz56Sjk01bC+6XHrIqmyjQM8FF6ATWwqXHwxoro6QJ+nrn95uY5h13JesHwU8 wudg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=wVxETCRj9csXkr178RqwaQ70WDjkLA5uLcl3mAGgLOI=; b=RtMRI7iJAvTTjBxie2q45ucBUY4z6J469KNNu61dS/3/BTpqofO1NejwFUJucWR2W0 XqDoZqRnLTehOLV8m0+zZjoMeVxHWmf/MD8HGguyguomHuV2wqDDDehFRsaVdvz0W/n3 XNCjemcApj927H3roM+WfYc7hDzo4u8Ain2OUqhaCoxLT7K4C5KCw776LH9Req2nbBc8 KwIEH3yZLfTEM+BathPMfmg5L8/r0DxRdStAkdT8bi9P95mmnyMESvL6k7K4NfhlkpMj +zAlaav/NDDcVk3YSXFWC4Y/cf5RSFxFXtdSakLS87qhLGxuclFnI2v0pbQA2z5bAAab vH9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UW9DDb/p"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id q20si8654317pgl.268.2019.02.07.04.57.05; Thu, 07 Feb 2019 04:57:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UW9DDb/p"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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 S1727212AbfBGM5F (ORCPT + 11 others); Thu, 7 Feb 2019 07:57:05 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43587 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727200AbfBGM5E (ORCPT ); Thu, 7 Feb 2019 07:57:04 -0500 Received: by mail-pg1-f195.google.com with SMTP id v28so4445199pgk.10 for ; Thu, 07 Feb 2019 04:57:04 -0800 (PST) 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 :in-reply-to:references; bh=wVxETCRj9csXkr178RqwaQ70WDjkLA5uLcl3mAGgLOI=; b=UW9DDb/pi65Xvl3Vz6Dw/OUA3Fl59q2P8ug5ik4Lqrdku78njfs4S7lYoVItyoKwSS 0Jki7sO0+S3jNoH006zE3qz+5wKYGMmrzS5X5ddkHMtPV322cM/zL/bsSZP5t8iII9n8 l2mf+IDhm+NGDwIuFQ3JP2bmyNVO2NtB3ldcuMT0pFfuDVmv8fsojOhgkwOdMGZ0sF5J YvckbF/fXCv0PBXq3dYxqBNjrD7+P3qDvZ6h2mSsqjBd73D0T6tECYz9Cqb8+QtChgSI FVODwGrNHYkr6u9xokCGlkRK5tC1GJkoMfms/w8fpwfbFTUEWQpFTU/7HxNIwXcSMwuO 6aKw== 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:in-reply-to:references; bh=wVxETCRj9csXkr178RqwaQ70WDjkLA5uLcl3mAGgLOI=; b=pSPxCeARe+65nVxpsd2a6fH2TbUMctDuZekZvJwO/1Bt/GsFGLOx4oRTcCjBxtTmBO BFXfUVvfD675RtshC7uQHJnFqoWNW8R6HxIxh8ilrDRWX6HYI/HnWCJaJjmuoKlcnjDg 3hFNdno29TJk6uQOy8VTRoaS1V5r0fBp6CjNnv7s4fOGR2lohxvKsd0EePsDhg3lKFiH qWM/K9I1RiSnBWxwNtu6mEqoNxkJ4LMIo9eJFzyF0HJfeRncwRiYzKWbUL4koJQpvAeI vYS0AHrcmjp53oNh3yWjGwMrUVzUxLEOZRmRbTKmIPjoxpEkfnyBtOi7z6eSIcPBmL3N szig== X-Gm-Message-State: AHQUAubdSfu43cJFq5aaVXShevhW78u6xGfFzb4HAm441XUbsXMD4t5N PVPk1e2uVTF4yLZYbZtUTWNTkA== X-Received: by 2002:a63:4d22:: with SMTP id a34mr12920642pgb.432.1549544223702; Thu, 07 Feb 2019 04:57:03 -0800 (PST) Received: from localhost ([2402:3a80:c80:4138:75dd:3900:1d90:762f]) by smtp.gmail.com with ESMTPSA id l74sm19418631pfb.145.2019.02.07.04.57.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 04:57:03 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v1 18/24] drivers: thermal: tsens: Move get_temp_tsens_v2 to allow sharing Date: Thu, 7 Feb 2019 16:19:36 +0530 Message-Id: <461cc91a35b5766fe1b44a5fae647c40e4de7f80.1549525708.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Just rename the function and move it to allow code sharing with future versions of TSENS IP Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 35 +++++++++++++++++++++++++++ drivers/thermal/qcom/tsens-v2.c | 37 +---------------------------- drivers/thermal/qcom/tsens.h | 1 + 3 files changed, 37 insertions(+), 36 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index d981effed493..ed975a2430d9 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -102,6 +102,41 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } +int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) +{ + struct tsens_sensor *s = &priv->sensor[i]; + u32 temp_idx = LAST_TEMP_0 + s->hw_id; + u32 valid_idx = VALID_0 + s->hw_id; + u32 last_temp = 0, valid, mask; + int ret; + + ret = regmap_field_read(priv->rf[valid_idx], &valid); + if (ret) + return ret; + while (!valid) { + /* Valid bit is 0 for 6 AHB clock cycles. + * At 19.2MHz, 1 AHB clock is ~60ns. + * We should enter this loop very, very rarely. + */ + ndelay(400); + ret = regmap_field_read(priv->rf[valid_idx], &valid); + if (ret) + return ret; + } + + /* Valid bit is set, OK to read the temperature */ + ret = regmap_field_read(priv->rf[temp_idx], &last_temp); + if (ret) + return ret; + + mask = GENMASK(priv->fields[LAST_TEMP_0].msb, + priv->fields[LAST_TEMP_0].lsb); + /* Convert temperature from deciCelsius to milliCelsius */ + *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + + return 0; +} + int get_temp_common(struct tsens_priv *priv, int i, int *temp) { struct tsens_sensor *s = &priv->sensor[i]; diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index 0ea93b89bc65..d436b96a6f18 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -25,41 +25,6 @@ #define TM_Sn_STATUS_OFF 0x00a0 #define TM_TRDY_OFF 0x00e4 -static int get_temp_tsens_v2(struct tsens_priv *priv, int i, int *temp) -{ - struct tsens_sensor *s = &priv->sensor[i]; - u32 temp_idx = LAST_TEMP_0 + s->hw_id; - u32 valid_idx = VALID_0 + s->hw_id; - u32 last_temp = 0, valid, mask; - int ret; - - ret = regmap_field_read(priv->rf[valid_idx], &valid); - if (ret) - return ret; - while (!valid) { - /* Valid bit is 0 for 6 AHB clock cycles. - * At 19.2MHz, 1 AHB clock is ~60ns. - * We should enter this loop very, very rarely. - */ - ndelay(400); - ret = regmap_field_read(priv->rf[valid_idx], &valid); - if (ret) - return ret; - } - - /* Valid bit is set, OK to read the temperature */ - ret = regmap_field_read(priv->rf[temp_idx], &last_temp); - if (ret) - return ret; - - mask = GENMASK(priv->fields[LAST_TEMP_0].msb, - priv->fields[LAST_TEMP_0].lsb); - /* Convert temperature from deciCelsius to milliCelsius */ - *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; - - return 0; -} - /* v2.x: 8996, 8998, sdm845 */ const struct tsens_features tsens_v2_feat = { @@ -136,7 +101,7 @@ const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = { static const struct tsens_ops ops_generic_v2 = { .init = init_common, - .get_temp = get_temp_tsens_v2, + .get_temp = get_temp_tsens_valid, }; const struct tsens_plat_data data_tsens_v2 = { diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 9db89dffb719..4b3d71b26c97 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -255,6 +255,7 @@ struct tsens_priv { char *qfprom_read(struct device *dev, const char *cname); void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 mode); int init_common(struct tsens_priv *priv); +int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp); int get_temp_common(struct tsens_priv *priv, int i, int *temp); bool is_sensor_enabled(struct tsens_priv *priv, u32 hw_id);