From patchwork Wed Mar 20 13:17:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 160667 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp281591jan; Wed, 20 Mar 2019 06:18:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqy54kyiN2Zqm7Rx6LTMAX6hYIISMi1AfdEYoKDBjU1DUrxF8OCb+TKMklsOjVymtobf4D0u X-Received: by 2002:a62:6306:: with SMTP id x6mr2741076pfb.244.1553087902760; Wed, 20 Mar 2019 06:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553087902; cv=none; d=google.com; s=arc-20160816; b=BdZEQon0JKAg9SyhFxAXthUUEEslyKTn9Sx2xKPy+n+2cT0Cn2XGKEwFlAaRZ77f8B AHZ9lIW20cAeeygeShEpLsYTKIFtgoqBvjVREmFuWUoB/Us5Qt1KnIQ51Y4oD7AwMJ+i 3Z+i/mUFI+HLU6e0AmM7ndb0f4QpxNVT9ZixNtnbnCEh5WtjaXFrI807sY/eg0nsYyXI Cd8z8NStApuv7hWoi5MMu1NJmIJRbBsFQP1X2n7JSk03H960kcoDRgtzf5h3hUrMPlyL lm8L3w5KMaTFZ4imhAFzEh7sYA3l+ISKmbK0bDuYYlcT8ZWP7dlAAH4NnxdK19RPiP9r 5b/w== 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=Mx/ZQ1fDyVdMP4lYY8bUX2uj2SipTV3Tq/A7NKtCdxg=; b=uQuOA7GPSlGocr96uqcmUWrHpCBKY51ErEGiiAtnmwblbVRbWIlRbD++Sh5l7AKE6s r2f/ubQ3W1nL6/AA7DlZYvb/+2IwwupIbGYGx7AP41+wMrXiaY5idlP4WtemzStX9kqe PNtDBl2Nq8OAk9sEf5W/mZVlRRSKadGQGAxxR1cXpmQyKj4LspdeG96y6U1+mFlWT1mg KN7j+SGOKHhXsRs8pSgeTTMZg+gfMoWhd71lm/CfGp3JVaoMaHKy68+70oi4/uqk8tGe 5DqatdS+jst0sYw6sSudY1DK7FWlG38i/2IDROECX688363q9tTl30bBqdKwPRQZZHNs LtxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WtbDJD1R; 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 r9si1638782pgp.193.2019.03.20.06.18.22; Wed, 20 Mar 2019 06:18:22 -0700 (PDT) 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=WtbDJD1R; 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 S1727625AbfCTNSV (ORCPT + 11 others); Wed, 20 Mar 2019 09:18:21 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43248 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727194AbfCTNSV (ORCPT ); Wed, 20 Mar 2019 09:18:21 -0400 Received: by mail-pf1-f194.google.com with SMTP id c8so1912173pfd.10 for ; Wed, 20 Mar 2019 06:18:21 -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; bh=Mx/ZQ1fDyVdMP4lYY8bUX2uj2SipTV3Tq/A7NKtCdxg=; b=WtbDJD1RCv7Le8iOj7X7F1V9DGOOEYXj5X7CyK2nuJ+EvY7VJpVAkTY6oM4x6FAwHm /El+vCZuACyabmKWVtgQLLoc5qfhkxPp8Fl0nDPunkuDlnqVE+/4kqFcoZwxcddtzalw +6gtQ8Qqbz8Ndh4gn61zmv41k+He+MqE51wvuLIGCQtAOc9FeiScXu2WdPFddsmaKfAq mDNul5Jc4IUqKwZpegBTXr+i6yZ33aj3k65WlGwJndjpr6Q/7xct5qGJKQxjxPbzK3ew RZsXhBrP77Y9jxMZPOSYbfGo15tarJ8OMisU0mnvq2ulBiC5qe36WVBUc5PrrnM0yIFc rKpA== 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=Mx/ZQ1fDyVdMP4lYY8bUX2uj2SipTV3Tq/A7NKtCdxg=; b=LvHZKhM5gcftgAPdtsaQWgDyPgm5GAdvyDb71N8RHhnMYg5RsNYNnIYyApNEoKk5yB OWjStKrT7JCOHx1Jo4U7jTiqj+nyIdbIVK2dHOLsYkF3ggpY+plqzMHaTGqv+F3X8jce rEMTSi2d/bQu73xwh5wxc5sUBtC19Mvl+aZghzOAu6XbyXjmLKJTX6U1Oy6LEld4RKrW Jz12AOwUaJbV/Z0kNyQCaKgv8sVB/jBpJH2c7L7Aebskvj4EHrJsohK6dNe1VI7Id4xy bSozQSISjI2gADS+QTDT++fQM4p3wjJMkaa0wqWrOQyoRFqL9htBhZekrVTZpQIEaMTW GZ6w== X-Gm-Message-State: APjAAAUD7K5uI28X+o85yDpaUL7girVH9s0M9g9j1fYJ/JsX0h2hpNiH 7AEGoLQ13T95ET3P18qvojG7bQ== X-Received: by 2002:a62:480d:: with SMTP id v13mr4767519pfa.125.1553087900481; Wed, 20 Mar 2019 06:18:20 -0700 (PDT) Received: from localhost ([114.143.122.221]) by smtp.gmail.com with ESMTPSA id v1sm3159165pff.9.2019.03.20.06.18.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 06:18:18 -0700 (PDT) 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: [PATCHv3 00/23] thermal: tsens: Refactor to use regmap_field Date: Wed, 20 Mar 2019 18:47:40 +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 pending from earlier reviews: - 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. Changes since v2: - Simplify qcs404 device tree by changing 'passive' trips on non-throttling devices to 'hot' type. Update the trip points too. - Replace IP version reads with just a version major number in the feature data structure. This is enough for differenting between IPs for different code paths for now. - Fix off-by-one typo in the REG_FIELD_FOR_EACH_ macro names. 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 Description ----------- 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-15: Clean ups, new functionality and bugfixes based on regmap_field - Patch 16-18: Refactor the get_temp routine. We expect to have a single get_temp routine once all the conversion is finished. - Patch 20-22: 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 (coming soon) c. Convert over 8960 to use regmap_field and as a result common functions Amit Kucheria (23): 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: 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 | 159 +++++++--- .../qcom/{tsens-8974.c => tsens-v0_1.c} | 166 +++++++++- drivers/thermal/qcom/tsens-v1.c | 193 ++++++++++++ drivers/thermal/qcom/tsens-v2.c | 111 +++---- drivers/thermal/qcom/tsens.c | 100 +++--- drivers/thermal/qcom/tsens.h | 291 ++++++++++++++++-- 11 files changed, 1166 insertions(+), 333 deletions(-) delete mode 100644 drivers/thermal/qcom/tsens-8916.c rename drivers/thermal/qcom/{tsens-8974.c => tsens-v0_1.c} (56%) create mode 100644 drivers/thermal/qcom/tsens-v1.c -- 2.17.1