From patchwork Thu Feb 28 12:20:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 159344 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp571372jad; Thu, 28 Feb 2019 04:21:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ3ootS2p9KCOvOwUcDjassWuxyaVEVm+QyXijc0q3jo+gk8O4BSuC7RUk531Y7mEg6PBib X-Received: by 2002:a62:ab04:: with SMTP id p4mr7150305pff.142.1551356492743; Thu, 28 Feb 2019 04:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551356492; cv=none; d=google.com; s=arc-20160816; b=YCqxN2en3D4gejecvYz0DO6bzkWg23NpxWLBCIeYuzyXLitBfNaUQB1KMhgqVP8RP1 sm5F5rWSivHbc5zo9ZL3TCUP7cCyH9Ad5Mo37KAUpBJOqsgUdIFgl2d0C+Z/oe6kG3M0 DzgzCSULqOrQPRpj74MldITC+vEMcR5BYrenKRPT8LoyLQXNJfPDg/f+xdtYUlORI1tc /dV6ZZrXzyANHff2/iZHA4vrV0iKDk+2r+oqDnxCl+MIjJKzVu4qYTHLZAlvu3jxGAN7 ojLUHtJ2RHL3PaZcJOKRw8gLu3f9mkueFe0DivYGGXuSKALk12+TZAro+ln5Z1Ciusyg /Dcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=NDmbND9e5ZqG8+uHYhtWAfDXUcra6/i5QSLjwnPDIVU=; b=psRE28+M3QIBikS870vsP8ty2Obe3g1SAteHaSMfIGek97MjmcNW4XuVi/OFPlaPhf qNi/tTj+njm31f/aqYPJz5BxSc9wuTysDyddjobxCew2pkKZg7KsMyecyTB+jgWx7SN7 CDv47yiGV9VgnI91ZYZw0+qmad1rGbNUDjP5MiIYHm4Pw36XUinzkfELmzh2LZbrm3q4 GdRjq76C9HtYYVNJ76fqWskgmo+UU3bQ1E4ccSWVUO3vDqm6yKBTdTdoVqL0wIVRdniE jKyMt5EkLeyVye+4vVvZljqetRovh0MszNCIa2C/DxbD8JtJGW/wkIrYICpRO8xGbtal WkhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rCinBtnc; 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 r192si331879pgr.331.2019.02.28.04.21.32; Thu, 28 Feb 2019 04:21:32 -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=rCinBtnc; 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 S1731072AbfB1MVb (ORCPT + 11 others); Thu, 28 Feb 2019 07:21:31 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39374 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727875AbfB1MVb (ORCPT ); Thu, 28 Feb 2019 07:21:31 -0500 Received: by mail-wm1-f65.google.com with SMTP id z84so8719637wmg.4 for ; Thu, 28 Feb 2019 04:21:29 -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; bh=NDmbND9e5ZqG8+uHYhtWAfDXUcra6/i5QSLjwnPDIVU=; b=rCinBtncxxIlJik5K2HnrlHXimWlAvYggR3/O4ZFjDclykzA6RvVoKa0Zy7kq6/rDD Pf8kYrergfXKjrUTddCozCe89khoYGzNgo1EXo0EEMf5JfZbgAW0YqUzmNWkGJFDlLPI 6M59YaQm7UmoVIX+j35/K9ZYRtG+umOuSZaI74WB7olE2Ok+UIlA6/k88xiR8c9CTunr MwBji94nhWT34aoMrDimuMqYCw80bJvdLxnmm+mS1ynfR9sVZbyY+gLKKf/tfgIj8M3U bijGBg3e+e17BefOJVcHbTRRPCzsoARD/jVwcN+WWbPDQOMzw4Ne+bhbNUXVO3P3jJoA WR4A== 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; bh=NDmbND9e5ZqG8+uHYhtWAfDXUcra6/i5QSLjwnPDIVU=; b=Q+3FiXJiyJnOB1CFSHcstvUPOnVNCKfN7E/nxLtziwASCdYkOrCgaum2jgGNEeqXLU V/jm/bLBMJPrxD4Q1lSH/7/imhfvNZgEHr2epYUVcmQ+sb+6bARZr0ILHC7NRg/koNuX PiH2m4N7wrGQkAtDK9bJMoU13yk3PS2ZAyLXeHhwNL+eGvF5HkZqKbiIoaNy8PJQ7jKd DjHilk8134ZYlUWqgvNCcY8uqKCWly8Hka4ajVQPlkJO/CCgD0txBCvJvYXJOLumhBeO vFLYi0uCSShMPcNGSZEuj4TA3ujAEKCBePGC3vznN6ET4QRJVJtMkaOEBdFTwZcpNFbu jbbQ== X-Gm-Message-State: AHQUAuY95lSwhYVqhcxmnBXSnogVp5yg3WcRZw8Ty6ubRX2+QjBZj4wM Kq/PZPQER9ghbX9fFDlbSJdpcA== X-Received: by 2002:a1c:6342:: with SMTP id x63mr2724034wmb.92.1551356488364; Thu, 28 Feb 2019 04:21:28 -0800 (PST) Received: from localhost ([49.248.54.130]) by smtp.gmail.com with ESMTPSA id z12sm3654238wmf.31.2019.02.28.04.21.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 04:21:27 -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: devicetree@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 00/24] thermal: tsens: Refactor to use regmap_field Date: Thu, 28 Feb 2019 17:50:50 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Changes since v1: - Anything not being throttled in the kernel converted to a hot trip point (no cooling-maps) - Don't print version number of the IP at boot Changes pending from review of v1: - Using macros from bits.h as suggested by Eduardo. I'd like to defer this change to a separate series where I can convert over all the files (v0.1, v1, v2) together. This series is getting quite long as it is. Short term bandaid fixes to add support for more versions of the TSENS IP is not proving to be very scalable. Here is a series to finally convert the driver's core to use regmap_fields so that register addresses and bitfields can be abstracted away from the code. This series is posted as one to give a complete view of where I'm going with this refactor. We can probably split it into smaller sets if required. Currently it consists of the following parts: - Patch 01-06: Style changes to make code easier to read (mostly naming related). This has no functional change in the driver, it is a series of search and replace operations. Ideally this will get merged first, otherwise everything else will become painful :-) - Patch 07-09: Merge the 8916 and 8974 source files into a single one called v0_1.c denoting the version of the IP and open up more opportunities for reuse. - Patch 10: This is the core patch that adds IP-specific data based on two data structures: tsens_features has bit flags to identify if a certain feature is available in a version or not and an array of reg_field pointers. regfield_ids list the important fields across IP versions and are used as an index. This patch converts over all platforms except 8960 which currently doesn't use DT data for tsens and has custom functions for everything. We will get to it eventually, but it's conversion is not necessary for this series to be merged. - Patch 11-16: Clean ups and new functionality based on regmap_field - Patch 17-19: Refactor the get_temp routine. We expect to have a single get_temp routine once all the conversion is finished. - Patch 20-23: Introduce qcs404 support using new regmap infrastructure. Testing ------- Since these changes affect every platform using TSENS, it should be clarified that I have only been focussing on developing/testing this on sdm845, msm8916, qcs404. Future work ----------- a. Get rid of get_temp_common in favour of get_temp_tsens_valid b. irq support c. Convert over 8960 to use regmap_field and as a result common functions Amit Kucheria (24): drivers: thermal: tsens: Document the data structures drivers: thermal: tsens: Rename tsens_data drivers: thermal: tsens: Rename tsens_device drivers: thermal: tsens: Rename variable tmdev drivers: thermal: tsens: Use consistent names for variables drivers: thermal: tsens: Function prototypes should have argument names drivers: thermal: tsens: Rename tsens-8916 to prepare to merge with tsens-8974 drivers: thermal: tsens: Rename constants to prepare to merge with tsens-8974 drivers: thermal: tsens: Merge tsens-8974 into tsens-v0_1 drivers: thermal: tsens: Introduce reg_fields to deal with register description drivers: thermal: tsens: Save reference to the device pointer and use it drivers: thermal: tsens: Don't print error message on -EPROBE_DEFER drivers: thermal: tsens: Track IP version drivers: thermal: tsens: Add new operation to check if a sensor is enabled drivers: thermal: tsens: change data type for sensor IDs drivers: thermal: tsens: Introduce IP-specific max_sensor count drivers: thermal: tsens: simplify get_temp_tsens_v2 routine drivers: thermal: tsens: Move get_temp_tsens_v2 to allow sharing drivers: thermal: tsens: Common get_temp() learns to do ADC conversion dt: thermal: tsens: Add bindings for qcs404 drivers: thermal: tsens: Add generic support for TSENS v1 IP arm64: dts: qcom: qcs404: Add tsens controller arm64: dts: qcom: qcs404: Add thermal zones for each sensor drivers: thermal: tsens: Move calibration constants to header file .../bindings/thermal/qcom-tsens.txt | 14 + arch/arm64/boot/dts/qcom/qcs404.dtsi | 272 ++++++++++++++ drivers/thermal/qcom/Makefile | 4 +- drivers/thermal/qcom/tsens-8916.c | 105 ------ drivers/thermal/qcom/tsens-8960.c | 84 ++--- drivers/thermal/qcom/tsens-common.c | 165 ++++++--- .../qcom/{tsens-8974.c => tsens-v0_1.c} | 158 +++++++- drivers/thermal/qcom/tsens-v1.c | 194 ++++++++++ drivers/thermal/qcom/tsens-v2.c | 124 ++++--- drivers/thermal/qcom/tsens.c | 100 ++--- drivers/thermal/qcom/tsens.h | 346 ++++++++++++++++-- 11 files changed, 1232 insertions(+), 334 deletions(-) delete mode 100644 drivers/thermal/qcom/tsens-8916.c rename drivers/thermal/qcom/{tsens-8974.c => tsens-v0_1.c} (58%) create mode 100644 drivers/thermal/qcom/tsens-v1.c -- 2.17.1