From patchwork Thu Feb 7 10:49:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 157688 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp487750jaa; Thu, 7 Feb 2019 02:49:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IY+zk3YmQkEC2Pk7w26mSVzIUP2LFVkQXjpdrZDTVMrMbaVSgms8lzkXx9Gu78A6WKEJ5PE X-Received: by 2002:a62:81c1:: with SMTP id t184mr15935339pfd.40.1549536597227; Thu, 07 Feb 2019 02:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549536597; cv=none; d=google.com; s=arc-20160816; b=PsOhdk9ujXnyAbt69w6DJbQnj76LCaJwWq1d4SsQ7Q/edD341HTuKiXXh26WliCRBh LM3aAbHL/7gBY7R1QY5cOX6TAHZFVtxhcI1iRU9o6Dfnvr622jrSOlEgSO5t+4efgLho f1lSSLlaxUN7k3zksmIuCfRZjCCYaYrDrR14Su0Hh/gtHAAFqrzhCc5KHDYaG4Np6Rzm 1/IgF302uWfo+S97EHh1SUlvMHLITYr5ZKQu/1oV+3I0eCiYOe1PyiTkAr2q7LOXuGNN DbLkX/ZEOIT0ElXaiXn+DIOLL1fkK4nn1Hfm/eDYNPD+y0Q5LbIUTlK/KfHqZbrQ7RMw Vj+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=kVT9iAxvzOjKqSkEyh9thKD23Da+mMk5HveGSav0+r8=; b=lWB5DxHFM+RQOa6jOa7tLvAdGUIDFbIbjbp/JFe9xBm9M2b4QaC4MwZkISbj4v+jmd J4g4F83XBTq2V9DNHkzk3JIjZi7ltJtvsRkjBDu40F7lj9ywAGCfI6ZJnLpdb0OHL8Cc 1Hks2Ngel2DoYxMzdVL5xRTXBTSUGnno0/RfDxmj4khFU2Ko6O54qS2WcQNufxOlfPLY TWIlvg+h83RMSlbRK6HM07GciBzHkFgBQ8osPjWYXIhCaYvY/2QUVQ/2WAbP6sVspQMe 8WVAd9KSYYQfYu+ZoG+CKRoAOxMB1mrE2v4FZlOFSKzcjpi7gr2SHtSxDYdr49JEq39N XeNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cJSyOcn3; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 b6si8289538pls.367.2019.02.07.02.49.56; Thu, 07 Feb 2019 02:49:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=cJSyOcn3; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726852AbfBGKt4 (ORCPT + 15 others); Thu, 7 Feb 2019 05:49:56 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:40406 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbfBGKtz (ORCPT ); Thu, 7 Feb 2019 05:49:55 -0500 Received: by mail-yw1-f65.google.com with SMTP id c67so465920ywa.7 for ; Thu, 07 Feb 2019 02:49:55 -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=kVT9iAxvzOjKqSkEyh9thKD23Da+mMk5HveGSav0+r8=; b=cJSyOcn3O6VQmC0G+0Rwys4o9ETADrqDB2S7j1ltvl0TljqhCPfYrhLSStZe+0RRtl xE2R7gQjO3avbDSJArCS3mC3gEE7tAXcKnA5sxrEVtEer+nv7MaqjklmUHpibOsjL2Yd rvZ/ydoZvZ35PG1a68eyVB5P6bTIQpVTE7+In76wUG8tixN4OZyhPX9bQaVxgMHMWeoC 59xVyg4nU11Gz65F32+jDKlUUAvF2ViIq4AEfdl43thk5jhDnYypciPvKd0dN8Wlylej 63dtLGde6WQsxInMxpgVAevxojynFEFRDQNU0AnWGXkJ3vhrpYCiT1p8k5z8CQzaSfeI T4dw== 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=kVT9iAxvzOjKqSkEyh9thKD23Da+mMk5HveGSav0+r8=; b=TgJRqMadPiYKeHE7VsBZ8fQ0bG9tIhL9lLDM87HPLklKK29CaT41DWVS22t6AAJQw4 q/THYgwAC9JRgstihMjaHOwlGoV6Swt+Qjj4azCqBNsFJSMrMycfXtTeYH1qkbSvDmhr BhObQqdc6BMU9wYIVjJLxziogGm4RPTPJtsgLMDPYxCOFGClIwpDS8mVmxyLnqwNOZAL th5Yow8UJuUnmBkuosmUKQQfRTiDbDobtdgP/o9efNIaO5TprivUvtjqHDW8HalXRYpu xzlV2B5qOOuRBQvQLafEYrxufDoUnZ0qLixh+FCUAkn3F0L7Cg0xxNLMwG6RxoBKbt2Q VyqQ== X-Gm-Message-State: AHQUAubRjF7TwHsgMWR4bi+WnUC6RBF4bl6KRITzdMumZY9Ua3DAvglF ulvxhfQQ7PkDNHG3xIjbzcnN2w== X-Received: by 2002:a81:3c14:: with SMTP id j20mr12375875ywa.139.1549536594553; Thu, 07 Feb 2019 02:49:54 -0800 (PST) Received: from localhost ([49.248.196.115]) by smtp.gmail.com with ESMTPSA id s126sm430287ywc.11.2019.02.07.02.49.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 02:49:53 -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 v1 00/24] thermal: tsens: Refactor to use regmap_field Date: Thu, 7 Feb 2019 16:19:18 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 a necessity 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 and qcs404. I will test this more thoroughly on msm8916, msm8996, msm8998 but it is still pending. 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 Regards, Amit 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: Print 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 | 263 ++++++++++++++++++ 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 | 172 +++++++++--- .../qcom/{tsens-8974.c => tsens-v0_1.c} | 167 ++++++++++- drivers/thermal/qcom/tsens-v1.c | 229 +++++++++++++++ drivers/thermal/qcom/tsens-v2.c | 148 ++++++---- drivers/thermal/qcom/tsens.c | 100 ++++--- drivers/thermal/qcom/tsens.h | 238 ++++++++++++++-- 11 files changed, 1191 insertions(+), 333 deletions(-) delete mode 100644 drivers/thermal/qcom/tsens-8916.c rename drivers/thermal/qcom/{tsens-8974.c => tsens-v0_1.c} (55%) create mode 100644 drivers/thermal/qcom/tsens-v1.c -- 2.17.1