Skip to content

thermal: tsens: Refactor to use regmap_field

Amit Kucheria linux-arm-msm linux-devicetree linux-pm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest23 patches 1 replyIn review
  2. v224 patches 0 repliesSuperseded
  3. v124 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- 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.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23drivers: thermal: tsens: Document the data structuresdrivers/thermal/qcom/tsens.h+28 -30 replies
2/23drivers: thermal: tsens: Rename tsens_datadrivers/thermal/qcom/tsens-8916.c drivers/thermal/qcom/tsens-8960.c drivers/thermal/qcom/tsens-8974.c +3 more+10 -100 replies
3/23drivers: thermal: tsens: Rename tsens_devicedrivers/thermal/qcom/tsens-8916.c drivers/thermal/qcom/tsens-8960.c drivers/thermal/qcom/tsens-8974.c +4 more+35 -350 replies
4/23drivers: thermal: tsens: Rename variable tmdevdrivers/thermal/qcom/tsens-8916.c drivers/thermal/qcom/tsens-8960.c drivers/thermal/qcom/tsens-8974.c +4 more+131 -1320 replies
5/23drivers: thermal: tsens: Use consistent names for variablesdrivers/thermal/qcom/tsens.c+3 -30 replies
6/23drivers: thermal: tsens: Function prototypes should have argument namesdrivers/thermal/qcom/tsens.h+12 -120 replies
7/23drivers: thermal: tsens: Rename tsens-8916 to prepare to merge with tsens-8974drivers/thermal/qcom/Makefile drivers/thermal/qcom/tsens-v0_1.c+1 -10 replies
8/23drivers: thermal: tsens: Rename constants to prepare to merge with tsens-8974drivers/thermal/qcom/tsens-v0_1.c+44 -440 replies
9/23drivers: thermal: tsens: Merge tsens-8974 into tsens-v0_1drivers/thermal/qcom/Makefile drivers/thermal/qcom/tsens-8974.c drivers/thermal/qcom/tsens-v0_1.c +1 more+236 -2390 replies
10/23drivers: thermal: tsens: Introduce reg_fields to deal with register descriptiondrivers/thermal/qcom/tsens-common.c drivers/thermal/qcom/tsens-v0_1.c drivers/thermal/qcom/tsens-v2.c +2 more+370 -580 replies
11/23drivers: thermal: tsens: Save reference to the device pointer and use itdrivers/thermal/qcom/tsens-common.c+8 -70 replies
12/23drivers: thermal: tsens: Don't print error message on -EPROBE_DEFERdrivers/thermal/qcom/tsens.c+2 -10 replies
13/23drivers: thermal: tsens: Add new operation to check if a sensor is enableddrivers/thermal/qcom/tsens-common.c drivers/thermal/qcom/tsens-v0_1.c drivers/thermal/qcom/tsens-v2.c +2 more+22 -00 replies
14/23drivers: thermal: tsens: change data type for sensor IDsdrivers/thermal/qcom/tsens.h+2 -20 replies
15/23drivers: thermal: tsens: Introduce IP-specific max_sensor countdrivers/thermal/qcom/tsens-common.c drivers/thermal/qcom/tsens-v0_1.c drivers/thermal/qcom/tsens-v2.c +1 more+6 -20 replies
16/23drivers: thermal: tsens: simplify get_temp_tsens_v2 routinedrivers/thermal/qcom/tsens-v2.c+17 -380 replies
17/23drivers: thermal: tsens: Move get_temp_tsens_v2 to allow sharingdrivers/thermal/qcom/tsens-common.c drivers/thermal/qcom/tsens-v2.c drivers/thermal/qcom/tsens.h+37 -360 replies
18/23drivers: thermal: tsens: Common get_temp() learns to do ADC conversiondrivers/thermal/qcom/tsens-common.c+9 -40 replies
19/23dt: thermal: tsens: Add bindings for qcs404Documentation/devicetree/bindings/thermal/qcom-tsens.txt+14 -00 replies
20/23drivers: thermal: tsens: Add generic support for TSENS v1 IPdrivers/thermal/qcom/Makefile drivers/thermal/qcom/tsens-v1.c drivers/thermal/qcom/tsens.c +1 more+202 -10 replies
21/23arm64: dts: qcom: qcs404: Add tsens controllerarch/arm64/boot/dts/qcom/qcs404.dtsi+20 -01 reply
22/23arm64: dts: qcom: qcs404: Add thermal zones for each sensorarch/arm64/boot/dts/qcom/qcs404.dtsi+252 -00 replies
23/23drivers: thermal: tsens: Move calibration constants to header filedrivers/thermal/qcom/tsens-common.c drivers/thermal/qcom/tsens.h+5 -50 replies

Reviews trailers per patch

1 of 23 patches has a Reviewed-by or Acked-by.

PatchRob Herring
1/23
2/23
3/23
4/23
5/23
6/23
7/23
8/23
9/23
10/23
11/23
12/23
13/23
14/23
15/23
16/23
17/23
18/23
19/23R-b
20/23
21/23
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCHv3 00/23] thermal: tsens: Refactor to use regmap_field

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
Signature · 1 line
2.17.1