* [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually
@ 2022-12-20 2:47 Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 01/15] dt-bindings: thermal: tsens: add msm8956 compat Dmitry Baryshkov
` (14 more replies)
0 siblings, 15 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
Historically the tsens driver fetches the calibration data as a blob and
then parses the blob on its own. This results in semi-duplicated code
spreading over the platform-specific functions.
This patch series changes tsens calibration code to per-value nvmem
cells rather than parsing the blob in the driver. For backwards
compatibility the old code is left in place for msm8916, msm8974 and
qcs404, the platforms which have in-tree DT files. For all other
affected platforms the old parsing code has been dropped as a part of
this series.
The code was tested on msm8916 and qcs404 only.
Note: the DTs changes depend on driver changes. Tsens driver will not
work if DT patches are merged, but the driver bits are not. As the
thermal sense is critical for device safety, I'd suggest merging binding
and driver during one merge window and then merging DT changes in the
next merge window.
Changes since v2:
- Made init_8956 static, as pointed out by the testing robot and by
AngeloGioacchino Del Regno.
Changes since the RFC:
- Sorted out the msm8976/msm8956, custom slopes are used only for msm8956,
- Implemented proper support for msm8974/apq8084,
- Added tsens_calibrate_common() and ops_v0_1 which can be used in
common cases,
- Removed superfluous identity hw_ids
- Fixed calibration calculation in tsens_calibrate_nvmem() for
ONE_PT_CALIB case
Dmitry Baryshkov (15):
dt-bindings: thermal: tsens: add msm8956 compat
dt-bindings: thermal: tsens: support per-sensor calibration cells
dt-bindings: thermal: tsens: add per-sensor cells for msm8974
thermal/drivers/tsens: Drop unnecessary hw_ids
thermal/drivers/tsens: Drop msm8976-specific defines
thermal/drivers/tsens: Sort out msm8976 vs msm8956 data
thermal/drivers/tsens: Support using nvmem cells for calibration data
thermal/drivers/tsens: Drop single-cell code for msm8939
thermal/drivers/tsens: Drop single-cell code for mdm9607
thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956
thermal/drivers/tsens: Support using nvmem cells for msm8974
calibration
arm64: dts: qcom: msm8916: specify per-sensor calibration cells
arm64: dts: qcom: qcs404: specify per-sensor calibration cells
ARM: dts: qcom-msm8974: specify per-sensor calibration cells
ARM: dts: qcom-apq8084: specify per-sensor calibration cells
.../bindings/thermal/qcom-tsens.yaml | 123 +++++++-
arch/arm/boot/dts/qcom-apq8084.dtsi | 262 ++++++++++++++++-
arch/arm/boot/dts/qcom-msm8974.dtsi | 262 ++++++++++++++++-
arch/arm64/boot/dts/qcom/msm8916.dtsi | 70 ++++-
arch/arm64/boot/dts/qcom/qcs404.dtsi | 121 +++++++-
drivers/thermal/qcom/tsens-v0_1.c | 267 ++++--------------
drivers/thermal/qcom/tsens-v1.c | 190 +++----------
drivers/thermal/qcom/tsens.c | 102 +++++++
drivers/thermal/qcom/tsens.h | 8 +-
9 files changed, 1002 insertions(+), 403 deletions(-)
--
2.35.1
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v3 01/15] dt-bindings: thermal: tsens: add msm8956 compat
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 02/15] dt-bindings: thermal: tsens: support per-sensor calibration cells Dmitry Baryshkov
` (13 subsequent siblings)
14 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Krzysztof Kozlowski
When adding support for msm8976 it was thought that msm8956 would reuse
the same compat. However checking the vendor kernel revealed that these
two platforms use different slope values for calculating the calibration
data.
Add new compatible for the tsens on msm8956 SoC.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Documentation/devicetree/bindings/thermal/qcom-tsens.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
index 0231f187b097..f3660af0b3bf 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -37,6 +37,7 @@ properties:
- description: v1 of TSENS
items:
- enum:
+ - qcom,msm8956-tsens
- qcom,msm8976-tsens
- qcom,qcs404-tsens
- const: qcom,tsens-v1
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 02/15] dt-bindings: thermal: tsens: support per-sensor calibration cells
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 01/15] dt-bindings: thermal: tsens: add msm8956 compat Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 03/15] dt-bindings: thermal: tsens: add per-sensor cells for msm8974 Dmitry Baryshkov
` (12 subsequent siblings)
14 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Krzysztof Kozlowski
Allow specifying the exact calibration mode and calibration data as nvmem
cells, rather than specifying just a single calibration data blob.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Amit Kucheria <amitk@kernel.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
.../bindings/thermal/qcom-tsens.yaml | 64 ++++++++++++++++---
1 file changed, 54 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
index f3660af0b3bf..da7b5bd4abd5 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -81,18 +81,62 @@ properties:
maxItems: 2
nvmem-cells:
- minItems: 1
- maxItems: 2
- description:
- Reference to an nvmem node for the calibration data
+ oneOf:
+ - minItems: 1
+ maxItems: 2
+ description:
+ Reference to an nvmem node for the calibration data
+ - minItems: 5
+ maxItems: 35
+ description: |
+ Reference to nvmem cells for the calibration mode, two calibration
+ bases and two cells per each sensor
nvmem-cell-names:
- minItems: 1
- items:
- - const: calib
- - enum:
- - calib_backup
- - calib_sel
+ oneOf:
+ - minItems: 1
+ items:
+ - const: calib
+ - enum:
+ - calib_backup
+ - calib_sel
+ - minItems: 5
+ items:
+ - const: mode
+ - const: base1
+ - const: base2
+ - const: s0_p1
+ - const: s0_p2
+ - const: s1_p1
+ - const: s1_p2
+ - const: s2_p1
+ - const: s2_p2
+ - const: s3_p1
+ - const: s3_p2
+ - const: s4_p1
+ - const: s4_p2
+ - const: s5_p1
+ - const: s5_p2
+ - const: s6_p1
+ - const: s6_p2
+ - const: s7_p1
+ - const: s7_p2
+ - const: s8_p1
+ - const: s8_p2
+ - const: s9_p1
+ - const: s9_p2
+ - const: s10_p1
+ - const: s10_p2
+ - const: s11_p1
+ - const: s11_p2
+ - const: s12_p1
+ - const: s12_p2
+ - const: s13_p1
+ - const: s13_p2
+ - const: s14_p1
+ - const: s14_p2
+ - const: s15_p1
+ - const: s15_p2
"#qcom,sensors":
description:
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 03/15] dt-bindings: thermal: tsens: add per-sensor cells for msm8974
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 01/15] dt-bindings: thermal: tsens: add msm8956 compat Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 02/15] dt-bindings: thermal: tsens: support per-sensor calibration cells Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 04/15] thermal/drivers/tsens: Drop unnecessary hw_ids Dmitry Baryshkov
` (11 subsequent siblings)
14 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Krzysztof Kozlowski
The msm8974 platform uses two sets of calibration data, add a special
case to handle both of them.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
.../bindings/thermal/qcom-tsens.yaml | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
index da7b5bd4abd5..3e6ba0509bd0 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -91,6 +91,11 @@ properties:
description: |
Reference to nvmem cells for the calibration mode, two calibration
bases and two cells per each sensor
+ # special case for msm8974 / apq8084
+ - maxItems: 51
+ description: |
+ Reference to nvmem cells for the calibration mode, two calibration
+ bases and two cells per each sensor, main and backup copies, plus use_backup cell
nvmem-cell-names:
oneOf:
@@ -137,6 +142,59 @@ properties:
- const: s14_p2
- const: s15_p1
- const: s15_p2
+ # special case for msm8974 / apq8084
+ - items:
+ - const: mode
+ - const: base1
+ - const: base2
+ - const: s0_p1
+ - const: s0_p2
+ - const: s1_p1
+ - const: s1_p2
+ - const: s2_p1
+ - const: s2_p2
+ - const: s3_p1
+ - const: s3_p2
+ - const: s4_p1
+ - const: s4_p2
+ - const: s5_p1
+ - const: s5_p2
+ - const: s6_p1
+ - const: s6_p2
+ - const: s7_p1
+ - const: s7_p2
+ - const: s8_p1
+ - const: s8_p2
+ - const: s9_p1
+ - const: s9_p2
+ - const: s10_p1
+ - const: s10_p2
+ - const: use_backup
+ - const: mode_backup
+ - const: base1_backup
+ - const: base2_backup
+ - const: s0_p1_backup
+ - const: s0_p2_backup
+ - const: s1_p1_backup
+ - const: s1_p2_backup
+ - const: s2_p1_backup
+ - const: s2_p2_backup
+ - const: s3_p1_backup
+ - const: s3_p2_backup
+ - const: s4_p1_backup
+ - const: s4_p2_backup
+ - const: s5_p1_backup
+ - const: s5_p2_backup
+ - const: s6_p1_backup
+ - const: s6_p2_backup
+ - const: s7_p1_backup
+ - const: s7_p2_backup
+ - const: s8_p1_backup
+ - const: s8_p2_backup
+ - const: s9_p1_backup
+ - const: s9_p2_backup
+ - const: s10_p1_backup
+ - const: s10_p2_backup
"#qcom,sensors":
description:
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 04/15] thermal/drivers/tsens: Drop unnecessary hw_ids
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (2 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 03/15] dt-bindings: thermal: tsens: add per-sensor cells for msm8974 Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:07 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 05/15] thermal/drivers/tsens: Drop msm8976-specific defines Dmitry Baryshkov
` (10 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
The tsens driver defaults to using hw_id equal to the index of the
sensor. Thus it is superfluous to declare such hw_id arrays. Drop such
arrays from mdm9607 and msm8976 data.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v0_1.c | 1 -
drivers/thermal/qcom/tsens-v1.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index 04d012e4f728..0bc4e5cec184 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -635,7 +635,6 @@ static const struct tsens_ops ops_9607 = {
struct tsens_plat_data data_9607 = {
.num_sensors = 5,
.ops = &ops_9607,
- .hw_ids = (unsigned int []){ 0, 1, 2, 3, 4 },
.feat = &tsens_v0_1_feat,
.fields = tsens_v0_1_regfields,
};
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 1d7f8a80bd13..96ef12d47bff 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -387,7 +387,6 @@ static const struct tsens_ops ops_8976 = {
struct tsens_plat_data data_8976 = {
.num_sensors = 11,
.ops = &ops_8976,
- .hw_ids = (unsigned int[]){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
.feat = &tsens_v1_feat,
.fields = tsens_v1_regfields,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 05/15] thermal/drivers/tsens: Drop msm8976-specific defines
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (3 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 04/15] thermal/drivers/tsens: Drop unnecessary hw_ids Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:08 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 06/15] thermal/drivers/tsens: Sort out msm8976 vs msm8956 data Dmitry Baryshkov
` (9 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, AngeloGioacchino Del Regno
Drop msm8976-specific defines, which duplicate generic ones.
Fixes: 0e580290170d ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v1.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 96ef12d47bff..a7f53966156b 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -78,11 +78,6 @@
#define MSM8976_CAL_SEL_MASK 0x3
-#define MSM8976_CAL_DEGC_PT1 30
-#define MSM8976_CAL_DEGC_PT2 120
-#define MSM8976_SLOPE_FACTOR 1000
-#define MSM8976_SLOPE_DEFAULT 3200
-
/* eeprom layout data for qcs404/405 (v1) */
#define BASE0_MASK 0x000007f8
#define BASE1_MASK 0x0007f800
@@ -160,8 +155,8 @@ static void compute_intercept_slope_8976(struct tsens_priv *priv,
priv->sensor[10].slope = 3286;
for (i = 0; i < priv->num_sensors; i++) {
- priv->sensor[i].offset = (p1[i] * MSM8976_SLOPE_FACTOR) -
- (MSM8976_CAL_DEGC_PT1 *
+ priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) -
+ (CAL_DEGC_PT1 *
priv->sensor[i].slope);
}
}
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 06/15] thermal/drivers/tsens: Sort out msm8976 vs msm8956 data
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (4 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 05/15] thermal/drivers/tsens: Drop msm8976-specific defines Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:09 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 07/15] thermal/drivers/tsens: Support using nvmem cells for calibration data Dmitry Baryshkov
` (8 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, AngeloGioacchino Del Regno
Tsens driver mentions that msm8976 data should be used for both msm8976
and msm8956 SoCs. This is not quite correct, as according to the
vendor kernels, msm8976 should use standard slope values (3200), while
msm8956 really uses the slope values found in the driver.
Add separate compatibility string for msm8956, move slope value
overrides to the corresponding init function and use the standard
compute_intercept_slope() function for both platforms.
Fixes: 0e580290170d ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v1.c | 56 ++++++++++++++++++---------------
drivers/thermal/qcom/tsens.c | 3 ++
drivers/thermal/qcom/tsens.h | 2 +-
3 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index a7f53966156b..83c2853546d0 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -137,30 +137,6 @@
#define CAL_SEL_MASK 7
#define CAL_SEL_SHIFT 0
-static void compute_intercept_slope_8976(struct tsens_priv *priv,
- u32 *p1, u32 *p2, u32 mode)
-{
- int i;
-
- priv->sensor[0].slope = 3313;
- priv->sensor[1].slope = 3275;
- priv->sensor[2].slope = 3320;
- priv->sensor[3].slope = 3246;
- priv->sensor[4].slope = 3279;
- priv->sensor[5].slope = 3257;
- priv->sensor[6].slope = 3234;
- priv->sensor[7].slope = 3269;
- priv->sensor[8].slope = 3255;
- priv->sensor[9].slope = 3239;
- priv->sensor[10].slope = 3286;
-
- for (i = 0; i < priv->num_sensors; i++) {
- priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) -
- (CAL_DEGC_PT1 *
- priv->sensor[i].slope);
- }
-}
-
static int calibrate_v1(struct tsens_priv *priv)
{
u32 base0 = 0, base1 = 0;
@@ -286,7 +262,7 @@ static int calibrate_8976(struct tsens_priv *priv)
break;
}
- compute_intercept_slope_8976(priv, p1, p2, mode);
+ compute_intercept_slope(priv, p1, p2, mode);
kfree(qfprom_cdata);
return 0;
@@ -360,6 +336,22 @@ static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = {
[TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0),
};
+static int __init init_8956(struct tsens_priv *priv) {
+ priv->sensor[0].slope = 3313;
+ priv->sensor[1].slope = 3275;
+ priv->sensor[2].slope = 3320;
+ priv->sensor[3].slope = 3246;
+ priv->sensor[4].slope = 3279;
+ priv->sensor[5].slope = 3257;
+ priv->sensor[6].slope = 3234;
+ priv->sensor[7].slope = 3269;
+ priv->sensor[8].slope = 3255;
+ priv->sensor[9].slope = 3239;
+ priv->sensor[10].slope = 3286;
+
+ return init_common(priv);
+}
+
static const struct tsens_ops ops_generic_v1 = {
.init = init_common,
.calibrate = calibrate_v1,
@@ -372,13 +364,25 @@ struct tsens_plat_data data_tsens_v1 = {
.fields = tsens_v1_regfields,
};
+static const struct tsens_ops ops_8956 = {
+ .init = init_8956,
+ .calibrate = calibrate_8976,
+ .get_temp = get_temp_tsens_valid,
+};
+
+struct tsens_plat_data data_8956 = {
+ .num_sensors = 11,
+ .ops = &ops_8956,
+ .feat = &tsens_v1_feat,
+ .fields = tsens_v1_regfields,
+};
+
static const struct tsens_ops ops_8976 = {
.init = init_common,
.calibrate = calibrate_8976,
.get_temp = get_temp_tsens_valid,
};
-/* Valid for both MSM8956 and MSM8976. */
struct tsens_plat_data data_8976 = {
.num_sensors = 11,
.ops = &ops_8976,
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index b5b136ff323f..b191e19df93d 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -983,6 +983,9 @@ static const struct of_device_id tsens_table[] = {
}, {
.compatible = "qcom,msm8939-tsens",
.data = &data_8939,
+ }, {
+ .compatible = "qcom,msm8956-tsens",
+ .data = &data_8956,
}, {
.compatible = "qcom,msm8960-tsens",
.data = &data_8960,
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index 899af128855f..7dd5fc246894 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -594,7 +594,7 @@ extern struct tsens_plat_data data_8960;
extern struct tsens_plat_data data_8916, data_8939, data_8974, data_9607;
/* TSENS v1 targets */
-extern struct tsens_plat_data data_tsens_v1, data_8976;
+extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956;
/* TSENS v2 targets */
extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 07/15] thermal/drivers/tsens: Support using nvmem cells for calibration data
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (5 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 06/15] thermal/drivers/tsens: Sort out msm8976 vs msm8956 data Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939 Dmitry Baryshkov
` (7 subsequent siblings)
14 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
Add a unified function using nvmem cells for parsing the calibration
data rather than parsing the calibration blob manually.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v0_1.c | 15 ++++++
drivers/thermal/qcom/tsens-v1.c | 6 ++-
drivers/thermal/qcom/tsens.c | 76 +++++++++++++++++++++++++++++++
drivers/thermal/qcom/tsens.h | 5 ++
4 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index 0bc4e5cec184..7f87b403c6fa 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -229,6 +229,11 @@ static int calibrate_8916(struct tsens_priv *priv)
u32 p1[5], p2[5];
int mode = 0;
u32 *qfprom_cdata, *qfprom_csel;
+ int ret;
+
+ ret = tsens_calibrate_nvmem(priv, 3);
+ if (!ret)
+ return 0;
qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
if (IS_ERR(qfprom_cdata))
@@ -286,6 +291,11 @@ static int calibrate_8939(struct tsens_priv *priv)
int mode = 0;
u32 *qfprom_cdata;
u32 cdata[6];
+ int ret;
+
+ ret = tsens_calibrate_common(priv);
+ if (!ret)
+ return 0;
qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
if (IS_ERR(qfprom_cdata))
@@ -491,6 +501,11 @@ static int calibrate_9607(struct tsens_priv *priv)
u32 p1[5], p2[5];
int mode = 0;
u32 *qfprom_cdata;
+ int ret;
+
+ ret = tsens_calibrate_common(priv);
+ if (!ret)
+ return 0;
qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
if (IS_ERR(qfprom_cdata))
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 83c2853546d0..89955522041d 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -143,7 +143,11 @@ static int calibrate_v1(struct tsens_priv *priv)
u32 p1[10], p2[10];
u32 mode = 0, lsb = 0, msb = 0;
u32 *qfprom_cdata;
- int i;
+ int i, ret;
+
+ ret = tsens_calibrate_common(priv);
+ if (!ret)
+ return 0;
qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
if (IS_ERR(qfprom_cdata))
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index b191e19df93d..68aef0ed6182 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -70,6 +70,82 @@ char *qfprom_read(struct device *dev, const char *cname)
return ret;
}
+int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
+{
+ u32 mode;
+ u32 base1, base2;
+ u32 p1[MAX_SENSORS], p2[MAX_SENSORS];
+ char name[] = "sXX_pY"; /* s10_p1 */
+ int i, ret;
+
+ if (priv->num_sensors > MAX_SENSORS)
+ return -EINVAL;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, "mode", &mode);
+ if (ret == -ENOENT)
+ dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n");
+ if (ret < 0)
+ return ret;
+
+ dev_dbg(priv->dev, "calibration mode is %d\n", mode);
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, "base1", &base1);
+ if (ret < 0)
+ return ret;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, "base2", &base2);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < priv->num_sensors; i++) {
+ ret = snprintf(name, sizeof(name), "s%d_p1", i);
+ if (ret < 0)
+ return ret;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p1[i]);
+ if (ret)
+ return ret;
+
+ ret = snprintf(name, sizeof(name), "s%d_p2", i);
+ if (ret < 0)
+ return ret;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p2[i]);
+ if (ret)
+ return ret;
+ }
+
+ switch (mode) {
+ case ONE_PT_CALIB:
+ for (i = 0; i < priv->num_sensors; i++)
+ p1[i] = p1[i] + (base1 << shift);
+ break;
+ case TWO_PT_CALIB:
+ for (i = 0; i < priv->num_sensors; i++)
+ p2[i] = (p2[i] + base2) << shift;
+ fallthrough;
+ case ONE_PT_CALIB2:
+ for (i = 0; i < priv->num_sensors; i++)
+ p1[i] = (p1[i] + base1) << shift;
+ break;
+ default:
+ dev_dbg(priv->dev, "calibrationless mode\n");
+ for (i = 0; i < priv->num_sensors; i++) {
+ p1[i] = 500;
+ p2[i] = 780;
+ }
+ }
+
+ compute_intercept_slope(priv, p1, p2, mode);
+
+ return 0;
+}
+
+int tsens_calibrate_common(struct tsens_priv *priv)
+{
+ return tsens_calibrate_nvmem(priv, 2);
+}
+
/*
* Use this function on devices where slope and offset calculations
* depend on calibration data read from qfprom. On others the slope
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index 7dd5fc246894..645ae02438fa 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -6,6 +6,7 @@
#ifndef __QCOM_TSENS_H__
#define __QCOM_TSENS_H__
+#define NO_PT_CALIB 0x0
#define ONE_PT_CALIB 0x1
#define ONE_PT_CALIB2 0x2
#define TWO_PT_CALIB 0x3
@@ -17,6 +18,8 @@
#define THRESHOLD_MAX_ADC_CODE 0x3ff
#define THRESHOLD_MIN_ADC_CODE 0x0
+#define MAX_SENSORS 16
+
#include <linux/interrupt.h>
#include <linux/thermal.h>
#include <linux/regmap.h>
@@ -582,6 +585,8 @@ struct tsens_priv {
};
char *qfprom_read(struct device *dev, const char *cname);
+int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift);
+int tsens_calibrate_common(struct tsens_priv *priv);
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(const struct tsens_sensor *s, int *temp);
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (6 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 07/15] thermal/drivers/tsens: Support using nvmem cells for calibration data Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:08 ` Bryan O'Donoghue
2022-12-20 14:02 ` Bryan O'Donoghue
2022-12-20 2:47 ` [PATCH v3 09/15] thermal/drivers/tsens: Drop single-cell code for mdm9607 Dmitry Baryshkov
` (6 subsequent siblings)
14 siblings, 2 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo,
Bryan O'Donoghue
There is no dtsi file for msm8939 in the kernel sources. Drop the
compatibility with unofficial dtsi and remove support for handling the
single-cell calibration data on msm8939.
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v0_1.c | 146 ++----------------------------
1 file changed, 7 insertions(+), 139 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index 7f87b403c6fa..8f1ea7075354 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -48,63 +48,6 @@
#define MSM8916_CAL_SEL_MASK 0xe0000000
#define MSM8916_CAL_SEL_SHIFT 29
-/* eeprom layout data for 8939 */
-#define MSM8939_BASE0_MASK 0x000000ff
-#define MSM8939_BASE1_MASK 0xff000000
-#define MSM8939_BASE0_SHIFT 0
-#define MSM8939_BASE1_SHIFT 24
-
-#define MSM8939_S0_P1_MASK 0x000001f8
-#define MSM8939_S1_P1_MASK 0x001f8000
-#define MSM8939_S2_P1_MASK_0_4 0xf8000000
-#define MSM8939_S2_P1_MASK_5 0x00000001
-#define MSM8939_S3_P1_MASK 0x00001f80
-#define MSM8939_S4_P1_MASK 0x01f80000
-#define MSM8939_S5_P1_MASK 0x00003f00
-#define MSM8939_S6_P1_MASK 0x03f00000
-#define MSM8939_S7_P1_MASK 0x0000003f
-#define MSM8939_S8_P1_MASK 0x0003f000
-#define MSM8939_S9_P1_MASK 0x07e00000
-
-#define MSM8939_S0_P2_MASK 0x00007e00
-#define MSM8939_S1_P2_MASK 0x07e00000
-#define MSM8939_S2_P2_MASK 0x0000007e
-#define MSM8939_S3_P2_MASK 0x0007e000
-#define MSM8939_S4_P2_MASK 0x7e000000
-#define MSM8939_S5_P2_MASK 0x000fc000
-#define MSM8939_S6_P2_MASK 0xfc000000
-#define MSM8939_S7_P2_MASK 0x00000fc0
-#define MSM8939_S8_P2_MASK 0x00fc0000
-#define MSM8939_S9_P2_MASK_0_4 0xf8000000
-#define MSM8939_S9_P2_MASK_5 0x00002000
-
-#define MSM8939_S0_P1_SHIFT 3
-#define MSM8939_S1_P1_SHIFT 15
-#define MSM8939_S2_P1_SHIFT_0_4 27
-#define MSM8939_S2_P1_SHIFT_5 0
-#define MSM8939_S3_P1_SHIFT 7
-#define MSM8939_S4_P1_SHIFT 19
-#define MSM8939_S5_P1_SHIFT 8
-#define MSM8939_S6_P1_SHIFT 20
-#define MSM8939_S7_P1_SHIFT 0
-#define MSM8939_S8_P1_SHIFT 12
-#define MSM8939_S9_P1_SHIFT 21
-
-#define MSM8939_S0_P2_SHIFT 9
-#define MSM8939_S1_P2_SHIFT 21
-#define MSM8939_S2_P2_SHIFT 1
-#define MSM8939_S3_P2_SHIFT 13
-#define MSM8939_S4_P2_SHIFT 25
-#define MSM8939_S5_P2_SHIFT 14
-#define MSM8939_S6_P2_SHIFT 26
-#define MSM8939_S7_P2_SHIFT 6
-#define MSM8939_S8_P2_SHIFT 18
-#define MSM8939_S9_P2_SHIFT_0_4 27
-#define MSM8939_S9_P2_SHIFT_5 13
-
-#define MSM8939_CAL_SEL_MASK 0x7
-#define MSM8939_CAL_SEL_SHIFT 0
-
/* eeprom layout data for 8974 */
#define BASE1_MASK 0xff
#define S0_P1_MASK 0x3f00
@@ -284,81 +227,6 @@ static int calibrate_8916(struct tsens_priv *priv)
return 0;
}
-static int calibrate_8939(struct tsens_priv *priv)
-{
- int base0 = 0, base1 = 0, i;
- u32 p1[10], p2[10];
- int mode = 0;
- u32 *qfprom_cdata;
- u32 cdata[6];
- int ret;
-
- ret = tsens_calibrate_common(priv);
- if (!ret)
- return 0;
-
- qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
- if (IS_ERR(qfprom_cdata))
- return PTR_ERR(qfprom_cdata);
-
- /* Mapping between qfprom nvmem and calibration data */
- cdata[0] = qfprom_cdata[12];
- cdata[1] = qfprom_cdata[13];
- cdata[2] = qfprom_cdata[0];
- cdata[3] = qfprom_cdata[1];
- cdata[4] = qfprom_cdata[22];
- cdata[5] = qfprom_cdata[21];
-
- mode = (cdata[0] & MSM8939_CAL_SEL_MASK) >> MSM8939_CAL_SEL_SHIFT;
- dev_dbg(priv->dev, "calibration mode is %d\n", mode);
-
- switch (mode) {
- case TWO_PT_CALIB:
- base1 = (cdata[3] & MSM8939_BASE1_MASK) >> MSM8939_BASE1_SHIFT;
- p2[0] = (cdata[0] & MSM8939_S0_P2_MASK) >> MSM8939_S0_P2_SHIFT;
- p2[1] = (cdata[0] & MSM8939_S1_P2_MASK) >> MSM8939_S1_P2_SHIFT;
- p2[2] = (cdata[1] & MSM8939_S2_P2_MASK) >> MSM8939_S2_P2_SHIFT;
- p2[3] = (cdata[1] & MSM8939_S3_P2_MASK) >> MSM8939_S3_P2_SHIFT;
- p2[4] = (cdata[1] & MSM8939_S4_P2_MASK) >> MSM8939_S4_P2_SHIFT;
- p2[5] = (cdata[2] & MSM8939_S5_P2_MASK) >> MSM8939_S5_P2_SHIFT;
- p2[6] = (cdata[2] & MSM8939_S6_P2_MASK) >> MSM8939_S6_P2_SHIFT;
- p2[7] = (cdata[3] & MSM8939_S7_P2_MASK) >> MSM8939_S7_P2_SHIFT;
- p2[8] = (cdata[3] & MSM8939_S8_P2_MASK) >> MSM8939_S8_P2_SHIFT;
- p2[9] = (cdata[4] & MSM8939_S9_P2_MASK_0_4) >> MSM8939_S9_P2_SHIFT_0_4;
- p2[9] |= ((cdata[5] & MSM8939_S9_P2_MASK_5) >> MSM8939_S9_P2_SHIFT_5) << 5;
- for (i = 0; i < priv->num_sensors; i++)
- p2[i] = (base1 + p2[i]) << 2;
- fallthrough;
- case ONE_PT_CALIB2:
- base0 = (cdata[2] & MSM8939_BASE0_MASK) >> MSM8939_BASE0_SHIFT;
- p1[0] = (cdata[0] & MSM8939_S0_P1_MASK) >> MSM8939_S0_P1_SHIFT;
- p1[1] = (cdata[0] & MSM8939_S1_P1_MASK) >> MSM8939_S1_P1_SHIFT;
- p1[2] = (cdata[0] & MSM8939_S2_P1_MASK_0_4) >> MSM8939_S2_P1_SHIFT_0_4;
- p1[2] |= ((cdata[1] & MSM8939_S2_P1_MASK_5) >> MSM8939_S2_P1_SHIFT_5) << 5;
- p1[3] = (cdata[1] & MSM8939_S3_P1_MASK) >> MSM8939_S3_P1_SHIFT;
- p1[4] = (cdata[1] & MSM8939_S4_P1_MASK) >> MSM8939_S4_P1_SHIFT;
- p1[5] = (cdata[2] & MSM8939_S5_P1_MASK) >> MSM8939_S5_P1_SHIFT;
- p1[6] = (cdata[2] & MSM8939_S6_P1_MASK) >> MSM8939_S6_P1_SHIFT;
- p1[7] = (cdata[3] & MSM8939_S7_P1_MASK) >> MSM8939_S7_P1_SHIFT;
- p1[8] = (cdata[3] & MSM8939_S8_P1_MASK) >> MSM8939_S8_P1_SHIFT;
- p1[9] = (cdata[4] & MSM8939_S9_P1_MASK) >> MSM8939_S9_P1_SHIFT;
- for (i = 0; i < priv->num_sensors; i++)
- p1[i] = ((base0) + p1[i]) << 2;
- break;
- default:
- for (i = 0; i < priv->num_sensors; i++) {
- p1[i] = 500;
- p2[i] = 780;
- }
- break;
- }
-
- compute_intercept_slope(priv, p1, p2, mode);
- kfree(qfprom_cdata);
-
- return 0;
-}
-
static int calibrate_8974(struct tsens_priv *priv)
{
int base1 = 0, base2 = 0, i;
@@ -598,6 +466,12 @@ static const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = {
[TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0),
};
+static const struct tsens_ops ops_v0_1 = {
+ .init = init_common,
+ .calibrate = tsens_calibrate_common,
+ .get_temp = get_temp_common,
+};
+
static const struct tsens_ops ops_8916 = {
.init = init_common,
.calibrate = calibrate_8916,
@@ -613,15 +487,9 @@ struct tsens_plat_data data_8916 = {
.fields = tsens_v0_1_regfields,
};
-static const struct tsens_ops ops_8939 = {
- .init = init_common,
- .calibrate = calibrate_8939,
- .get_temp = get_temp_common,
-};
-
struct tsens_plat_data data_8939 = {
.num_sensors = 10,
- .ops = &ops_8939,
+ .ops = &ops_v0_1,
.hw_ids = (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9, 10 },
.feat = &tsens_v0_1_feat,
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 09/15] thermal/drivers/tsens: Drop single-cell code for mdm9607
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (7 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939 Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:22 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956 Dmitry Baryshkov
` (5 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
There is no dtsi file for mdm9607 in the kernel sources. Drop the
compatibility with unofficial dtsi and remove support for handling the
single-cell calibration data on mdm9607.
Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v0_1.c | 95 +------------------------------
1 file changed, 1 insertion(+), 94 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index 8f1ea7075354..caffcf9905b9 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -133,39 +133,6 @@
#define BIT_APPEND 0x3
-/* eeprom layout data for mdm9607 */
-#define MDM9607_BASE0_MASK 0x000000ff
-#define MDM9607_BASE1_MASK 0x000ff000
-#define MDM9607_BASE0_SHIFT 0
-#define MDM9607_BASE1_SHIFT 12
-
-#define MDM9607_S0_P1_MASK 0x00003f00
-#define MDM9607_S1_P1_MASK 0x03f00000
-#define MDM9607_S2_P1_MASK 0x0000003f
-#define MDM9607_S3_P1_MASK 0x0003f000
-#define MDM9607_S4_P1_MASK 0x0000003f
-
-#define MDM9607_S0_P2_MASK 0x000fc000
-#define MDM9607_S1_P2_MASK 0xfc000000
-#define MDM9607_S2_P2_MASK 0x00000fc0
-#define MDM9607_S3_P2_MASK 0x00fc0000
-#define MDM9607_S4_P2_MASK 0x00000fc0
-
-#define MDM9607_S0_P1_SHIFT 8
-#define MDM9607_S1_P1_SHIFT 20
-#define MDM9607_S2_P1_SHIFT 0
-#define MDM9607_S3_P1_SHIFT 12
-#define MDM9607_S4_P1_SHIFT 0
-
-#define MDM9607_S0_P2_SHIFT 14
-#define MDM9607_S1_P2_SHIFT 26
-#define MDM9607_S2_P2_SHIFT 6
-#define MDM9607_S3_P2_SHIFT 18
-#define MDM9607_S4_P2_SHIFT 6
-
-#define MDM9607_CAL_SEL_MASK 0x00700000
-#define MDM9607_CAL_SEL_SHIFT 20
-
static int calibrate_8916(struct tsens_priv *priv)
{
int base0 = 0, base1 = 0, i;
@@ -363,60 +330,6 @@ static int calibrate_8974(struct tsens_priv *priv)
return 0;
}
-static int calibrate_9607(struct tsens_priv *priv)
-{
- int base, i;
- u32 p1[5], p2[5];
- int mode = 0;
- u32 *qfprom_cdata;
- int ret;
-
- ret = tsens_calibrate_common(priv);
- if (!ret)
- return 0;
-
- qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
- if (IS_ERR(qfprom_cdata))
- return PTR_ERR(qfprom_cdata);
-
- mode = (qfprom_cdata[2] & MDM9607_CAL_SEL_MASK) >> MDM9607_CAL_SEL_SHIFT;
- dev_dbg(priv->dev, "calibration mode is %d\n", mode);
-
- switch (mode) {
- case TWO_PT_CALIB:
- base = (qfprom_cdata[2] & MDM9607_BASE1_MASK) >> MDM9607_BASE1_SHIFT;
- p2[0] = (qfprom_cdata[0] & MDM9607_S0_P2_MASK) >> MDM9607_S0_P2_SHIFT;
- p2[1] = (qfprom_cdata[0] & MDM9607_S1_P2_MASK) >> MDM9607_S1_P2_SHIFT;
- p2[2] = (qfprom_cdata[1] & MDM9607_S2_P2_MASK) >> MDM9607_S2_P2_SHIFT;
- p2[3] = (qfprom_cdata[1] & MDM9607_S3_P2_MASK) >> MDM9607_S3_P2_SHIFT;
- p2[4] = (qfprom_cdata[2] & MDM9607_S4_P2_MASK) >> MDM9607_S4_P2_SHIFT;
- for (i = 0; i < priv->num_sensors; i++)
- p2[i] = ((base + p2[i]) << 2);
- fallthrough;
- case ONE_PT_CALIB2:
- base = (qfprom_cdata[0] & MDM9607_BASE0_MASK);
- p1[0] = (qfprom_cdata[0] & MDM9607_S0_P1_MASK) >> MDM9607_S0_P1_SHIFT;
- p1[1] = (qfprom_cdata[0] & MDM9607_S1_P1_MASK) >> MDM9607_S1_P1_SHIFT;
- p1[2] = (qfprom_cdata[1] & MDM9607_S2_P1_MASK) >> MDM9607_S2_P1_SHIFT;
- p1[3] = (qfprom_cdata[1] & MDM9607_S3_P1_MASK) >> MDM9607_S3_P1_SHIFT;
- p1[4] = (qfprom_cdata[2] & MDM9607_S4_P1_MASK) >> MDM9607_S4_P1_SHIFT;
- for (i = 0; i < priv->num_sensors; i++)
- p1[i] = ((base + p1[i]) << 2);
- break;
- default:
- for (i = 0; i < priv->num_sensors; i++) {
- p1[i] = 500;
- p2[i] = 780;
- }
- break;
- }
-
- compute_intercept_slope(priv, p1, p2, mode);
- kfree(qfprom_cdata);
-
- return 0;
-}
-
/* v0.1: 8916, 8939, 8974, 9607 */
static struct tsens_features tsens_v0_1_feat = {
@@ -509,15 +422,9 @@ struct tsens_plat_data data_8974 = {
.fields = tsens_v0_1_regfields,
};
-static const struct tsens_ops ops_9607 = {
- .init = init_common,
- .calibrate = calibrate_9607,
- .get_temp = get_temp_common,
-};
-
struct tsens_plat_data data_9607 = {
.num_sensors = 5,
- .ops = &ops_9607,
+ .ops = &ops_v0_1,
.feat = &tsens_v0_1_feat,
.fields = tsens_v0_1_regfields,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (8 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 09/15] thermal/drivers/tsens: Drop single-cell code for mdm9607 Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:24 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 11/15] thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration Dmitry Baryshkov
` (4 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, AngeloGioacchino Del Regno
There is no dtsi file for msm8976 in the kernel sources. Drop the
compatibility with unofficial dtsi and remove support for handling the
single-cell calibration data on msm8976.
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v1.c | 126 +-------------------------------
1 file changed, 2 insertions(+), 124 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 89955522041d..9151c1043a11 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -21,63 +21,6 @@
#define TM_HIGH_LOW_INT_STATUS_OFF 0x0088
#define TM_HIGH_LOW_Sn_INT_THRESHOLD_OFF 0x0090
-/* eeprom layout data for msm8956/76 (v1) */
-#define MSM8976_BASE0_MASK 0xff
-#define MSM8976_BASE1_MASK 0xff
-#define MSM8976_BASE1_SHIFT 8
-
-#define MSM8976_S0_P1_MASK 0x3f00
-#define MSM8976_S1_P1_MASK 0x3f00000
-#define MSM8976_S2_P1_MASK 0x3f
-#define MSM8976_S3_P1_MASK 0x3f000
-#define MSM8976_S4_P1_MASK 0x3f00
-#define MSM8976_S5_P1_MASK 0x3f00000
-#define MSM8976_S6_P1_MASK 0x3f
-#define MSM8976_S7_P1_MASK 0x3f000
-#define MSM8976_S8_P1_MASK 0x1f8
-#define MSM8976_S9_P1_MASK 0x1f8000
-#define MSM8976_S10_P1_MASK 0xf8000000
-#define MSM8976_S10_P1_MASK_1 0x1
-
-#define MSM8976_S0_P2_MASK 0xfc000
-#define MSM8976_S1_P2_MASK 0xfc000000
-#define MSM8976_S2_P2_MASK 0xfc0
-#define MSM8976_S3_P2_MASK 0xfc0000
-#define MSM8976_S4_P2_MASK 0xfc000
-#define MSM8976_S5_P2_MASK 0xfc000000
-#define MSM8976_S6_P2_MASK 0xfc0
-#define MSM8976_S7_P2_MASK 0xfc0000
-#define MSM8976_S8_P2_MASK 0x7e00
-#define MSM8976_S9_P2_MASK 0x7e00000
-#define MSM8976_S10_P2_MASK 0x7e
-
-#define MSM8976_S0_P1_SHIFT 8
-#define MSM8976_S1_P1_SHIFT 20
-#define MSM8976_S2_P1_SHIFT 0
-#define MSM8976_S3_P1_SHIFT 12
-#define MSM8976_S4_P1_SHIFT 8
-#define MSM8976_S5_P1_SHIFT 20
-#define MSM8976_S6_P1_SHIFT 0
-#define MSM8976_S7_P1_SHIFT 12
-#define MSM8976_S8_P1_SHIFT 3
-#define MSM8976_S9_P1_SHIFT 15
-#define MSM8976_S10_P1_SHIFT 27
-#define MSM8976_S10_P1_SHIFT_1 0
-
-#define MSM8976_S0_P2_SHIFT 14
-#define MSM8976_S1_P2_SHIFT 26
-#define MSM8976_S2_P2_SHIFT 6
-#define MSM8976_S3_P2_SHIFT 18
-#define MSM8976_S4_P2_SHIFT 14
-#define MSM8976_S5_P2_SHIFT 26
-#define MSM8976_S6_P2_SHIFT 6
-#define MSM8976_S7_P2_SHIFT 18
-#define MSM8976_S8_P2_SHIFT 9
-#define MSM8976_S9_P2_SHIFT 21
-#define MSM8976_S10_P2_SHIFT 1
-
-#define MSM8976_CAL_SEL_MASK 0x3
-
/* eeprom layout data for qcs404/405 (v1) */
#define BASE0_MASK 0x000007f8
#define BASE1_MASK 0x0007f800
@@ -207,71 +150,6 @@ static int calibrate_v1(struct tsens_priv *priv)
return 0;
}
-static int calibrate_8976(struct tsens_priv *priv)
-{
- int base0 = 0, base1 = 0, i;
- u32 p1[11], p2[11];
- int mode = 0, tmp = 0;
- u32 *qfprom_cdata;
-
- qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
- if (IS_ERR(qfprom_cdata))
- return PTR_ERR(qfprom_cdata);
-
- mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
- dev_dbg(priv->dev, "calibration mode is %d\n", mode);
-
- switch (mode) {
- case TWO_PT_CALIB:
- base1 = (qfprom_cdata[2] & MSM8976_BASE1_MASK) >> MSM8976_BASE1_SHIFT;
- p2[0] = (qfprom_cdata[0] & MSM8976_S0_P2_MASK) >> MSM8976_S0_P2_SHIFT;
- p2[1] = (qfprom_cdata[0] & MSM8976_S1_P2_MASK) >> MSM8976_S1_P2_SHIFT;
- p2[2] = (qfprom_cdata[1] & MSM8976_S2_P2_MASK) >> MSM8976_S2_P2_SHIFT;
- p2[3] = (qfprom_cdata[1] & MSM8976_S3_P2_MASK) >> MSM8976_S3_P2_SHIFT;
- p2[4] = (qfprom_cdata[2] & MSM8976_S4_P2_MASK) >> MSM8976_S4_P2_SHIFT;
- p2[5] = (qfprom_cdata[2] & MSM8976_S5_P2_MASK) >> MSM8976_S5_P2_SHIFT;
- p2[6] = (qfprom_cdata[3] & MSM8976_S6_P2_MASK) >> MSM8976_S6_P2_SHIFT;
- p2[7] = (qfprom_cdata[3] & MSM8976_S7_P2_MASK) >> MSM8976_S7_P2_SHIFT;
- p2[8] = (qfprom_cdata[4] & MSM8976_S8_P2_MASK) >> MSM8976_S8_P2_SHIFT;
- p2[9] = (qfprom_cdata[4] & MSM8976_S9_P2_MASK) >> MSM8976_S9_P2_SHIFT;
- p2[10] = (qfprom_cdata[5] & MSM8976_S10_P2_MASK) >> MSM8976_S10_P2_SHIFT;
-
- for (i = 0; i < priv->num_sensors; i++)
- p2[i] = ((base1 + p2[i]) << 2);
- fallthrough;
- case ONE_PT_CALIB2:
- base0 = qfprom_cdata[0] & MSM8976_BASE0_MASK;
- p1[0] = (qfprom_cdata[0] & MSM8976_S0_P1_MASK) >> MSM8976_S0_P1_SHIFT;
- p1[1] = (qfprom_cdata[0] & MSM8976_S1_P1_MASK) >> MSM8976_S1_P1_SHIFT;
- p1[2] = (qfprom_cdata[1] & MSM8976_S2_P1_MASK) >> MSM8976_S2_P1_SHIFT;
- p1[3] = (qfprom_cdata[1] & MSM8976_S3_P1_MASK) >> MSM8976_S3_P1_SHIFT;
- p1[4] = (qfprom_cdata[2] & MSM8976_S4_P1_MASK) >> MSM8976_S4_P1_SHIFT;
- p1[5] = (qfprom_cdata[2] & MSM8976_S5_P1_MASK) >> MSM8976_S5_P1_SHIFT;
- p1[6] = (qfprom_cdata[3] & MSM8976_S6_P1_MASK) >> MSM8976_S6_P1_SHIFT;
- p1[7] = (qfprom_cdata[3] & MSM8976_S7_P1_MASK) >> MSM8976_S7_P1_SHIFT;
- p1[8] = (qfprom_cdata[4] & MSM8976_S8_P1_MASK) >> MSM8976_S8_P1_SHIFT;
- p1[9] = (qfprom_cdata[4] & MSM8976_S9_P1_MASK) >> MSM8976_S9_P1_SHIFT;
- p1[10] = (qfprom_cdata[4] & MSM8976_S10_P1_MASK) >> MSM8976_S10_P1_SHIFT;
- tmp = (qfprom_cdata[5] & MSM8976_S10_P1_MASK_1) << MSM8976_S10_P1_SHIFT_1;
- p1[10] |= tmp;
-
- for (i = 0; i < priv->num_sensors; i++)
- p1[i] = (((base0) + p1[i]) << 2);
- break;
- default:
- for (i = 0; i < priv->num_sensors; i++) {
- p1[i] = 500;
- p2[i] = 780;
- }
- break;
- }
-
- compute_intercept_slope(priv, p1, p2, mode);
- kfree(qfprom_cdata);
-
- return 0;
-}
-
/* v1.x: msm8956,8976,qcs404,405 */
static struct tsens_features tsens_v1_feat = {
@@ -370,7 +248,7 @@ struct tsens_plat_data data_tsens_v1 = {
static const struct tsens_ops ops_8956 = {
.init = init_8956,
- .calibrate = calibrate_8976,
+ .calibrate = tsens_calibrate_common,
.get_temp = get_temp_tsens_valid,
};
@@ -383,7 +261,7 @@ struct tsens_plat_data data_8956 = {
static const struct tsens_ops ops_8976 = {
.init = init_common,
- .calibrate = calibrate_8976,
+ .calibrate = tsens_calibrate_common,
.get_temp = get_temp_tsens_valid,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 11/15] thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (9 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956 Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:38 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 12/15] arm64: dts: qcom: msm8916: specify per-sensor calibration cells Dmitry Baryshkov
` (3 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
MSM8974 has two sets of calibration data: main one and backup. Add
support for parsing both sets of calibration data from nvmem cells.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/thermal/qcom/tsens-v0_1.c | 50 +++++++++++++++++++++++++++++++
drivers/thermal/qcom/tsens.c | 39 +++++++++++++++++++-----
drivers/thermal/qcom/tsens.h | 1 +
3 files changed, 82 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index caffcf9905b9..6a11b8b196b9 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -3,6 +3,7 @@
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*/
+#include <linux/nvmem-consumer.h>
#include <linux/platform_device.h>
#include "tsens.h"
@@ -194,6 +195,50 @@ static int calibrate_8916(struct tsens_priv *priv)
return 0;
}
+static int calibrate_8974_nvmem(struct tsens_priv *priv)
+{
+ int i, ret, mode;
+ u32 p1[11], p2[11];
+ u32 backup;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, "use_backup", &backup);
+ if (ret == -ENOENT)
+ dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n");
+ if (ret < 0)
+ return ret;
+
+ mode = tsens_read_calibration(priv, 2, p1, p2, backup == BKP_SEL);
+ if (mode < 0)
+ return mode;
+
+ if (mode == NO_PT_CALIB) {
+ p1[0] += 2;
+ p1[1] += 9;
+ p1[2] += 3;
+ p1[3] += 9;
+ p1[4] += 5;
+ p1[5] += 9;
+ p1[6] += 7;
+ p1[7] += 10;
+ p1[8] += 8;
+ p1[9] += 9;
+ p1[10] += 8;
+ } else {
+ for (i = 0; i < priv->num_sensors; i++) {
+ /*
+ * ONE_PT_CALIB requires using addition here instead of
+ * using OR operation.
+ */
+ p1[i] += BIT_APPEND;
+ p2[i] += BIT_APPEND;
+ }
+ }
+
+ compute_intercept_slope(priv, p1, p2, mode);
+
+ return 0;
+}
+
static int calibrate_8974(struct tsens_priv *priv)
{
int base1 = 0, base2 = 0, i;
@@ -201,6 +246,11 @@ static int calibrate_8974(struct tsens_priv *priv)
int mode = 0;
u32 *calib, *bkp;
u32 calib_redun_sel;
+ int ret;
+
+ ret = calibrate_8974_nvmem(priv);
+ if (ret == 0)
+ return 0;
calib = (u32 *)qfprom_read(priv->dev, "calib");
if (IS_ERR(calib))
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 68aef0ed6182..83bf60fa9008 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -70,18 +70,21 @@ char *qfprom_read(struct device *dev, const char *cname)
return ret;
}
-int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
+int tsens_read_calibration(struct tsens_priv *priv, int shift, u32 *p1, u32 *p2, bool backup)
{
u32 mode;
u32 base1, base2;
- u32 p1[MAX_SENSORS], p2[MAX_SENSORS];
- char name[] = "sXX_pY"; /* s10_p1 */
+ char name[] = "sXX_pY_backup"; /* s10_p1_backup */
int i, ret;
if (priv->num_sensors > MAX_SENSORS)
return -EINVAL;
- ret = nvmem_cell_read_variable_le_u32(priv->dev, "mode", &mode);
+ ret = snprintf(name, sizeof(name), "mode%s", backup ? "_backup" : "");
+ if (ret < 0)
+ return ret;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &mode);
if (ret == -ENOENT)
dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n");
if (ret < 0)
@@ -89,16 +92,24 @@ int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
dev_dbg(priv->dev, "calibration mode is %d\n", mode);
- ret = nvmem_cell_read_variable_le_u32(priv->dev, "base1", &base1);
+ ret = snprintf(name, sizeof(name), "base1%s", backup ? "_backup" : "");
+ if (ret < 0)
+ return ret;
+
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base1);
+ if (ret < 0)
+ return ret;
+
+ ret = snprintf(name, sizeof(name), "base2%s", backup ? "_backup" : "");
if (ret < 0)
return ret;
- ret = nvmem_cell_read_variable_le_u32(priv->dev, "base2", &base2);
+ ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base2);
if (ret < 0)
return ret;
for (i = 0; i < priv->num_sensors; i++) {
- ret = snprintf(name, sizeof(name), "s%d_p1", i);
+ ret = snprintf(name, sizeof(name), "s%d_p1%s", i, backup ? "_backup" : "");
if (ret < 0)
return ret;
@@ -106,7 +117,7 @@ int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
if (ret)
return ret;
- ret = snprintf(name, sizeof(name), "s%d_p2", i);
+ ret = snprintf(name, sizeof(name), "s%d_p2%s", i, backup ? "_backup" : "");
if (ret < 0)
return ret;
@@ -136,6 +147,18 @@ int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
}
}
+ return mode;
+}
+
+int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
+{
+ u32 p1[MAX_SENSORS], p2[MAX_SENSORS];
+ int mode;
+
+ mode = tsens_read_calibration(priv, shift, p1, p2, false);
+ if (mode < 0)
+ return mode;
+
compute_intercept_slope(priv, p1, p2, mode);
return 0;
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index 645ae02438fa..a9ae8df9f810 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -585,6 +585,7 @@ struct tsens_priv {
};
char *qfprom_read(struct device *dev, const char *cname);
+int tsens_read_calibration(struct tsens_priv *priv, int shift, u32 *p1, u32 *p2, bool backup);
int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift);
int tsens_calibrate_common(struct tsens_priv *priv);
void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 mode);
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 12/15] arm64: dts: qcom: msm8916: specify per-sensor calibration cells
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (10 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 11/15] thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:53 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 13/15] arm64: dts: qcom: qcs404: " Dmitry Baryshkov
` (2 subsequent siblings)
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
Specify pre-parsed per-sensor calibration nvmem cells in the tsens
device node rather than parsing the whole data blob in the driver.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
arch/arm64/boot/dts/qcom/msm8916.dtsi | 70 ++++++++++++++++++++++++---
1 file changed, 64 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 2ca8e977fc2a..af7ba66bb7cd 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -442,11 +442,57 @@ qfprom: qfprom@5c000 {
reg = <0x0005c000 0x1000>;
#address-cells = <1>;
#size-cells = <1>;
- tsens_caldata: caldata@d0 {
- reg = <0xd0 0x8>;
+ tsens_base1: base1@d0 {
+ reg = <0xd0 0x1>;
+ bits = <0 7>;
};
- tsens_calsel: calsel@ec {
- reg = <0xec 0x4>;
+ tsens_s0_p1: s0_p1@d0 {
+ reg = <0xd0 0x2>;
+ bits = <7 5>;
+ };
+ tsens_s0_p2: s0_p2@d1 {
+ reg = <0xd1 0x2>;
+ bits = <4 5>;
+ };
+ tsens_s1_p1: s1_p1@d2 {
+ reg = <0xd2 0x1>;
+ bits = <1 5>;
+ };
+ tsens_s1_p2: s1_p2@d2 {
+ reg = <0xd2 0x2>;
+ bits = <6 5>;
+ };
+ tsens_s2_p1: s2_p1@d3 {
+ reg = <0xd3 0x1>;
+ bits = <3 5>;
+ };
+ tsens_s2_p2: s2_p2@d4 {
+ reg = <0xd4 0x1>;
+ bits = <0 5>;
+ };
+ tsens_s3_p1: s3_p1@d4 {
+ reg = <0xd4 0x2>;
+ bits = <5 5>;
+ };
+ tsens_s3_p2: s3_p2@d5 {
+ reg = <0xd5 0x1>;
+ bits = <2 5>;
+ };
+ tsens_s4_p1: s4_p1@d5 {
+ reg = <0xd5 0x2>;
+ bits = <7 5>;
+ };
+ tsens_s4_p2: s4_p2@d6 {
+ reg = <0xd6 0x2>;
+ bits = <4 5>;
+ };
+ tsens_base2: base2@d7 {
+ reg = <0xd7 0x1>;
+ bits = <1 7>;
+ };
+ tsens_mode: mode@ec {
+ reg = <0xef 0x1>;
+ bits = <5 3>;
};
};
@@ -473,8 +519,20 @@ tsens: thermal-sensor@4a9000 {
compatible = "qcom,msm8916-tsens", "qcom,tsens-v0_1";
reg = <0x004a9000 0x1000>, /* TM */
<0x004a8000 0x1000>; /* SROT */
- nvmem-cells = <&tsens_caldata>, <&tsens_calsel>;
- nvmem-cell-names = "calib", "calib_sel";
+ nvmem-cells = <&tsens_mode>,
+ <&tsens_base1>, <&tsens_base2>,
+ <&tsens_s0_p1>, <&tsens_s0_p2>,
+ <&tsens_s1_p1>, <&tsens_s1_p2>,
+ <&tsens_s2_p1>, <&tsens_s2_p2>,
+ <&tsens_s3_p1>, <&tsens_s3_p2>,
+ <&tsens_s4_p1>, <&tsens_s4_p2>;
+ nvmem-cell-names = "mode",
+ "base1", "base2",
+ "s0_p1", "s0_p2",
+ "s1_p1", "s1_p2",
+ "s2_p1", "s2_p2",
+ "s3_p1", "s3_p2",
+ "s4_p1", "s4_p2";
#qcom,sensors = <5>;
interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "uplow";
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 13/15] arm64: dts: qcom: qcs404: specify per-sensor calibration cells
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (11 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 12/15] arm64: dts: qcom: msm8916: specify per-sensor calibration cells Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 10:57 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 14/15] ARM: dts: qcom-msm8974: " Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 15/15] ARM: dts: qcom-apq8084: " Dmitry Baryshkov
14 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
Specify pre-parsed per-sensor calibration nvmem cells in the tsens
device node rather than parsing the whole data blob in the driver.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
arch/arm64/boot/dts/qcom/qcs404.dtsi | 121 +++++++++++++++++++++++++--
1 file changed, 116 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi b/arch/arm64/boot/dts/qcom/qcs404.dtsi
index a5324eecb50a..362764347006 100644
--- a/arch/arm64/boot/dts/qcom/qcs404.dtsi
+++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi
@@ -366,13 +366,102 @@ qfprom: qfprom@a4000 {
reg = <0x000a4000 0x1000>;
#address-cells = <1>;
#size-cells = <1>;
- tsens_caldata: caldata@d0 {
- reg = <0x1f8 0x14>;
- };
cpr_efuse_speedbin: speedbin@13c {
reg = <0x13c 0x4>;
bits = <2 3>;
};
+ tsens_s0_p1: s0_p1@1f8 {
+ reg = <0x1f8 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s0_p2: s0_p2@1f8 {
+ reg = <0x1f8 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s1_p1: s1_p1@1f9 {
+ reg = <0x1f9 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s1_p2: s1_p2@1fa {
+ reg = <0x1fa 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s2_p1: s2_p1@1fb {
+ reg = <0x1fb 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s2_p2: s2_p2@1fb {
+ reg = <0x1fb 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s3_p1: s3_p1@1fc {
+ reg = <0x1fc 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s3_p2: s3_p2@1fd {
+ reg = <0x1fd 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s4_p1: s4_p1@1fe {
+ reg = <0x1fe 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s4_p2: s4_p2@1fe {
+ reg = <0x1fe 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s5_p1: s5_p1@200 {
+ reg = <0x200 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s5_p2: s5_p2@200 {
+ reg = <0x200 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s6_p1: s6_p1@201 {
+ reg = <0x201 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s6_p2: s6_p2@202 {
+ reg = <0x202 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s7_p1: s7_p1@203 {
+ reg = <0x203 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s7_p2: s7_p2@203 {
+ reg = <0x203 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s8_p1: s8_p1@204 {
+ reg = <0x204 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s8_p2: s8_p2@205 {
+ reg = <0x205 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s9_p1: s9_p1@206 {
+ reg = <0x206 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s9_p2: s9_p2@206 {
+ reg = <0x206 0x2>;
+ bits = <6 6>;
+ };
+ tsens_mode: mode@208 {
+ reg = <0x208 1>;
+ bits = <0 3>;
+ };
+ tsens_base1: base1@208 {
+ reg = <0x208 2>;
+ bits = <3 8>;
+ };
+ tsens_base2: base2@208 {
+ reg = <0x209 2>;
+ bits = <3 8>;
+ };
cpr_efuse_quot_offset1: qoffset1@231 {
reg = <0x231 0x4>;
bits = <4 7>;
@@ -447,8 +536,30 @@ tsens: thermal-sensor@4a9000 {
compatible = "qcom,qcs404-tsens", "qcom,tsens-v1";
reg = <0x004a9000 0x1000>, /* TM */
<0x004a8000 0x1000>; /* SROT */
- nvmem-cells = <&tsens_caldata>;
- nvmem-cell-names = "calib";
+ nvmem-cells = <&tsens_mode>,
+ <&tsens_base1>, <&tsens_base2>,
+ <&tsens_s0_p1>, <&tsens_s0_p2>,
+ <&tsens_s1_p1>, <&tsens_s1_p2>,
+ <&tsens_s2_p1>, <&tsens_s2_p2>,
+ <&tsens_s3_p1>, <&tsens_s3_p2>,
+ <&tsens_s4_p1>, <&tsens_s4_p2>,
+ <&tsens_s5_p1>, <&tsens_s5_p2>,
+ <&tsens_s6_p1>, <&tsens_s6_p2>,
+ <&tsens_s7_p1>, <&tsens_s7_p2>,
+ <&tsens_s8_p1>, <&tsens_s8_p2>,
+ <&tsens_s9_p1>, <&tsens_s9_p2>;
+ nvmem-cell-names = "mode",
+ "base1", "base2",
+ "s0_p1", "s0_p2",
+ "s1_p1", "s1_p2",
+ "s2_p1", "s2_p2",
+ "s3_p1", "s3_p2",
+ "s4_p1", "s4_p2",
+ "s5_p1", "s5_p2",
+ "s6_p1", "s6_p2",
+ "s7_p1", "s7_p2",
+ "s8_p1", "s8_p2",
+ "s9_p1", "s9_p2";
#qcom,sensors = <10>;
interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "uplow";
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 14/15] ARM: dts: qcom-msm8974: specify per-sensor calibration cells
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (12 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 13/15] arm64: dts: qcom: qcs404: " Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 15/15] ARM: dts: qcom-apq8084: " Dmitry Baryshkov
14 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
Specify pre-parsed per-sensor calibration nvmem cells in the tsens
device node rather than parsing the whole data blob in the driver.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
arch/arm/boot/dts/qcom-msm8974.dtsi | 262 +++++++++++++++++++++++++++-
1 file changed, 256 insertions(+), 6 deletions(-)
diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
index 8d216a3c0851..774ed1b0be10 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -1119,8 +1119,60 @@ tsens: thermal-sensor@fc4a9000 {
compatible = "qcom,msm8974-tsens", "qcom,tsens-v0_1";
reg = <0xfc4a9000 0x1000>, /* TM */
<0xfc4a8000 0x1000>; /* SROT */
- nvmem-cells = <&tsens_calib>, <&tsens_backup>;
- nvmem-cell-names = "calib", "calib_backup";
+ nvmem-cells = <&tsens_mode>,
+ <&tsens_base1>, <&tsens_base2>,
+ <&tsens_s0_p1>, <&tsens_s0_p2>,
+ <&tsens_s1_p1>, <&tsens_s1_p2>,
+ <&tsens_s2_p1>, <&tsens_s2_p2>,
+ <&tsens_s3_p1>, <&tsens_s3_p2>,
+ <&tsens_s4_p1>, <&tsens_s4_p2>,
+ <&tsens_s5_p1>, <&tsens_s5_p2>,
+ <&tsens_s6_p1>, <&tsens_s6_p2>,
+ <&tsens_s7_p1>, <&tsens_s7_p2>,
+ <&tsens_s8_p1>, <&tsens_s8_p2>,
+ <&tsens_s9_p1>, <&tsens_s9_p2>,
+ <&tsens_s10_p1>, <&tsens_s10_p2>,
+ <&tsens_use_backup>,
+ <&tsens_mode_backup>,
+ <&tsens_base1_backup>, <&tsens_base2_backup>,
+ <&tsens_s0_p1_backup>, <&tsens_s0_p2_backup>,
+ <&tsens_s1_p1_backup>, <&tsens_s1_p2_backup>,
+ <&tsens_s2_p1_backup>, <&tsens_s2_p2_backup>,
+ <&tsens_s3_p1_backup>, <&tsens_s3_p2_backup>,
+ <&tsens_s4_p1_backup>, <&tsens_s4_p2_backup>,
+ <&tsens_s5_p1_backup>, <&tsens_s5_p2_backup>,
+ <&tsens_s6_p1_backup>, <&tsens_s6_p2_backup>,
+ <&tsens_s7_p1_backup>, <&tsens_s7_p2_backup>,
+ <&tsens_s8_p1_backup>, <&tsens_s8_p2_backup>,
+ <&tsens_s9_p1_backup>, <&tsens_s9_p2_backup>,
+ <&tsens_s10_p1_backup>, <&tsens_s10_p2_backup>;
+ nvmem-cell-names = "mode",
+ "base1", "base2",
+ "s0_p1", "s0_p2",
+ "s1_p1", "s1_p2",
+ "s2_p1", "s2_p2",
+ "s3_p1", "s3_p2",
+ "s4_p1", "s4_p2",
+ "s5_p1", "s5_p2",
+ "s6_p1", "s6_p2",
+ "s7_p1", "s7_p2",
+ "s8_p1", "s8_p2",
+ "s9_p1", "s9_p2",
+ "s10_p1", "s10_p2",
+ "use_backup",
+ "mode_backup",
+ "base1_backup", "base2_backup",
+ "s0_p1_backup", "s0_p2_backup",
+ "s1_p1_backup", "s1_p2_backup",
+ "s2_p1_backup", "s2_p2_backup",
+ "s3_p1_backup", "s3_p2_backup",
+ "s4_p1_backup", "s4_p2_backup",
+ "s5_p1_backup", "s5_p2_backup",
+ "s6_p1_backup", "s6_p2_backup",
+ "s7_p1_backup", "s7_p2_backup",
+ "s8_p1_backup", "s8_p2_backup",
+ "s9_p1_backup", "s9_p2_backup",
+ "s10_p1_backup", "s10_p2_backup";
#qcom,sensors = <11>;
interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "uplow";
@@ -1137,11 +1189,209 @@ qfprom: qfprom@fc4bc000 {
reg = <0xfc4bc000 0x1000>;
#address-cells = <1>;
#size-cells = <1>;
- tsens_calib: calib@d0 {
- reg = <0xd0 0x18>;
+ tsens_base1: base1@d0 {
+ reg = <0xd0 0x1>;
+ bits = <0 8>;
};
- tsens_backup: backup@440 {
- reg = <0x440 0x10>;
+ tsens_s0_p1: s0_p1@d1 {
+ reg = <0xd1 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s1_p1: s1_p1@d2 {
+ reg = <0xd1 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s2_p1: s2_p1@d2 {
+ reg = <0xd2 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s3_p1: s3_p1@d3 {
+ reg = <0xd3 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s4_p1: s4_p1@d4 {
+ reg = <0xd4 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s5_p1: s5_p1@d4 {
+ reg = <0xd4 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s6_p1: s6_p1@d5 {
+ reg = <0xd5 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s7_p1: s7_p1@d6 {
+ reg = <0xd6 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s8_p1: s8_p1@d7 {
+ reg = <0xd7 0x1>;
+ bits = <0 6>;
+ };
+ tsens_mode: mode@d7 {
+ reg = <0xd7 0x1>;
+ bits = <6 2>;
+ };
+ tsens_s9_p1: s9_p1@d8 {
+ reg = <0xd8 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s10_p1: s10_p1@d8 {
+ reg = <0xd8 0x2>;
+ bits = <6 6>;
+ };
+ tsens_base2: base2@d9 {
+ reg = <0xd9 0x2>;
+ bits = <4 8>;
+ };
+ tsens_s0_p2: s0_p2@da {
+ reg = <0xda 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s1_p2: s1_p2@db {
+ reg = <0xdb 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s2_p2: s2_p2@dc {
+ reg = <0xdc 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s3_p2: s3_p2@dc {
+ reg = <0xdc 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s4_p2: s4_p2@dd {
+ reg = <0xdd 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s5_p2: s5_p2@de {
+ reg = <0xde 0x2>;
+ bits = <2 6>;
+ };
+ tsens_s6_p2: s6_p2@df {
+ reg = <0xdf 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s7_p2: s7_p2@e0 {
+ reg = <0xe0 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s8_p2: s8_p2@e0 {
+ reg = <0xe0 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s9_p2: s9_p2@e1 {
+ reg = <0xe1 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s10_p2: s10_p2@e2 {
+ reg = <0xe2 0x2>;
+ bits = <2 6>;
+ };
+ tsens_s5_p2_backup: s5_p2_backup@e3 {
+ reg = <0xe3 0x2>;
+ bits = <0 6>;
+ };
+ tsens_mode_backup: mode_backup@e3 {
+ reg = <0xe3 0x1>;
+ bits = <6 2>;
+ };
+ tsens_s6_p2_backup: s6_p2_backup@e4 {
+ reg = <0xe4 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s7_p2_backup: s7_p2_backup@e4 {
+ reg = <0xe4 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s8_p2_backup: s8_p2_backup@e5 {
+ reg = <0xe5 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s9_p2_backup: s9_p2_backup@e6 {
+ reg = <0xe6 0x2>;
+ bits = <2 6>;
+ };
+ tsens_s10_p2_backup: s10_p2_backup@e7 {
+ reg = <0xe7 0x1>;
+ bits = <0 6>;
+ };
+ tsens_base1_backup: base1_backup@440 {
+ reg = <0x440 0x1>;
+ bits = <0 8>;
+ };
+ tsens_s0_p1_backup: s0_p1_backup@441 {
+ reg = <0x441 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s1_p1_backup: s1_p1_backup@442 {
+ reg = <0x441 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s2_p1_backup: s2_p1_backup@442 {
+ reg = <0x442 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s3_p1_backup: s3_p1_backup@443 {
+ reg = <0x443 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s4_p1_backup: s4_p1_backup@444 {
+ reg = <0x444 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s5_p1_backup: s5_p1_backup@444 {
+ reg = <0x444 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s6_p1_backup: s6_p1_backup@445 {
+ reg = <0x445 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s7_p1_backup: s7_p1_backup@446 {
+ reg = <0x446 0x1>;
+ bits = <2 6>;
+ };
+ tsens_use_backup: use_backup@447 {
+ reg = <0x447 0x1>;
+ bits = <5 3>;
+ };
+ tsens_s8_p1_backup: s8_p1_backup@448 {
+ reg = <0x448 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s9_p1_backup: s9_p1_backup@448 {
+ reg = <0x448 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s10_p1_backup: s10_p1_backup@449 {
+ reg = <0x449 0x2>;
+ bits = <4 6>;
+ };
+ tsens_base2_backup: base2_backup@44a {
+ reg = <0x44a 0x2>;
+ bits = <2 8>;
+ };
+ tsens_s0_p2_backup: s0_p2_backup@44b {
+ reg = <0x44b 0x3>;
+ bits = <2 6>;
+ };
+ tsens_s1_p2_backup: s1_p2_backup@44c {
+ reg = <0x44c 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s2_p2_backup: s2_p2_backup@44c {
+ reg = <0x44c 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s3_p2_backup: s3_p2_backup@44d {
+ reg = <0x44d 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s4_p2_backup: s4_p2_backup@44e {
+ reg = <0x44e 0x1>;
+ bits = <2 6>;
};
};
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v3 15/15] ARM: dts: qcom-apq8084: specify per-sensor calibration cells
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
` (13 preceding siblings ...)
2022-12-20 2:47 ` [PATCH v3 14/15] ARM: dts: qcom-msm8974: " Dmitry Baryshkov
@ 2022-12-20 2:47 ` Dmitry Baryshkov
14 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 2:47 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
Specify pre-parsed per-sensor calibration nvmem cells in the tsens
device node rather than parsing the whole data blob in the driver.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
arch/arm/boot/dts/qcom-apq8084.dtsi | 262 +++++++++++++++++++++++++++-
1 file changed, 256 insertions(+), 6 deletions(-)
diff --git a/arch/arm/boot/dts/qcom-apq8084.dtsi b/arch/arm/boot/dts/qcom-apq8084.dtsi
index fe30abfff90a..f0f788ac38f0 100644
--- a/arch/arm/boot/dts/qcom-apq8084.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8084.dtsi
@@ -249,11 +249,209 @@ qfprom: qfprom@fc4bc000 {
reg = <0xfc4bc000 0x1000>;
#address-cells = <1>;
#size-cells = <1>;
- tsens_calib: calib@d0 {
- reg = <0xd0 0x18>;
+ tsens_base1: base1@d0 {
+ reg = <0xd0 0x1>;
+ bits = <0 8>;
};
- tsens_backup: backup@440 {
- reg = <0x440 0x10>;
+ tsens_s0_p1: s0_p1@d1 {
+ reg = <0xd1 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s1_p1: s1_p1@d2 {
+ reg = <0xd1 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s2_p1: s2_p1@d2 {
+ reg = <0xd2 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s3_p1: s3_p1@d3 {
+ reg = <0xd3 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s4_p1: s4_p1@d4 {
+ reg = <0xd4 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s5_p1: s5_p1@d4 {
+ reg = <0xd4 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s6_p1: s6_p1@d5 {
+ reg = <0xd5 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s7_p1: s7_p1@d6 {
+ reg = <0xd6 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s8_p1: s8_p1@d7 {
+ reg = <0xd7 0x1>;
+ bits = <0 6>;
+ };
+ tsens_mode: mode@d7 {
+ reg = <0xd7 0x1>;
+ bits = <6 2>;
+ };
+ tsens_s9_p1: s9_p1@d8 {
+ reg = <0xd8 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s10_p1: s10_p1@d8 {
+ reg = <0xd8 0x2>;
+ bits = <6 6>;
+ };
+ tsens_base2: base2@d9 {
+ reg = <0xd9 0x2>;
+ bits = <4 8>;
+ };
+ tsens_s0_p2: s0_p2@da {
+ reg = <0xda 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s1_p2: s1_p2@db {
+ reg = <0xdb 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s2_p2: s2_p2@dc {
+ reg = <0xdc 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s3_p2: s3_p2@dc {
+ reg = <0xdc 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s4_p2: s4_p2@dd {
+ reg = <0xdd 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s5_p2: s5_p2@de {
+ reg = <0xde 0x2>;
+ bits = <2 6>;
+ };
+ tsens_s6_p2: s6_p2@df {
+ reg = <0xdf 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s7_p2: s7_p2@e0 {
+ reg = <0xe0 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s8_p2: s8_p2@e0 {
+ reg = <0xe0 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s9_p2: s9_p2@e1 {
+ reg = <0xe1 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s10_p2: s10_p2@e2 {
+ reg = <0xe2 0x2>;
+ bits = <2 6>;
+ };
+ tsens_s5_p2_backup: s5_p2_backup@e3 {
+ reg = <0xe3 0x2>;
+ bits = <0 6>;
+ };
+ tsens_mode_backup: mode_backup@e3 {
+ reg = <0xe3 0x1>;
+ bits = <6 2>;
+ };
+ tsens_s6_p2_backup: s6_p2_backup@e4 {
+ reg = <0xe4 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s7_p2_backup: s7_p2_backup@e4 {
+ reg = <0xe4 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s8_p2_backup: s8_p2_backup@e5 {
+ reg = <0xe5 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s9_p2_backup: s9_p2_backup@e6 {
+ reg = <0xe6 0x2>;
+ bits = <2 6>;
+ };
+ tsens_s10_p2_backup: s10_p2_backup@e7 {
+ reg = <0xe7 0x1>;
+ bits = <0 6>;
+ };
+ tsens_base1_backup: base1_backup@440 {
+ reg = <0x440 0x1>;
+ bits = <0 8>;
+ };
+ tsens_s0_p1_backup: s0_p1_backup@441 {
+ reg = <0x441 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s1_p1_backup: s1_p1_backup@442 {
+ reg = <0x441 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s2_p1_backup: s2_p1_backup@442 {
+ reg = <0x442 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s3_p1_backup: s3_p1_backup@443 {
+ reg = <0x443 0x1>;
+ bits = <2 6>;
+ };
+ tsens_s4_p1_backup: s4_p1_backup@444 {
+ reg = <0x444 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s5_p1_backup: s5_p1_backup@444 {
+ reg = <0x444 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s6_p1_backup: s6_p1_backup@445 {
+ reg = <0x445 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s7_p1_backup: s7_p1_backup@446 {
+ reg = <0x446 0x1>;
+ bits = <2 6>;
+ };
+ tsens_use_backup: use_backup@447 {
+ reg = <0x447 0x1>;
+ bits = <5 3>;
+ };
+ tsens_s8_p1_backup: s8_p1_backup@448 {
+ reg = <0x448 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s9_p1_backup: s9_p1_backup@448 {
+ reg = <0x448 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s10_p1_backup: s10_p1_backup@449 {
+ reg = <0x449 0x2>;
+ bits = <4 6>;
+ };
+ tsens_base2_backup: base2_backup@44a {
+ reg = <0x44a 0x2>;
+ bits = <2 8>;
+ };
+ tsens_s0_p2_backup: s0_p2_backup@44b {
+ reg = <0x44b 0x3>;
+ bits = <2 6>;
+ };
+ tsens_s1_p2_backup: s1_p2_backup@44c {
+ reg = <0x44c 0x1>;
+ bits = <0 6>;
+ };
+ tsens_s2_p2_backup: s2_p2_backup@44c {
+ reg = <0x44c 0x2>;
+ bits = <6 6>;
+ };
+ tsens_s3_p2_backup: s3_p2_backup@44d {
+ reg = <0x44d 0x2>;
+ bits = <4 6>;
+ };
+ tsens_s4_p2_backup: s4_p2_backup@44e {
+ reg = <0x44e 0x1>;
+ bits = <2 6>;
};
};
@@ -261,8 +459,60 @@ tsens: thermal-sensor@fc4a8000 {
compatible = "qcom,msm8974-tsens", "qcom,tsens-v0_1";
reg = <0xfc4a9000 0x1000>, /* TM */
<0xfc4a8000 0x1000>; /* SROT */
- nvmem-cells = <&tsens_calib>, <&tsens_backup>;
- nvmem-cell-names = "calib", "calib_backup";
+ nvmem-cells = <&tsens_mode>,
+ <&tsens_base1>, <&tsens_base2>,
+ <&tsens_s0_p1>, <&tsens_s0_p2>,
+ <&tsens_s1_p1>, <&tsens_s1_p2>,
+ <&tsens_s2_p1>, <&tsens_s2_p2>,
+ <&tsens_s3_p1>, <&tsens_s3_p2>,
+ <&tsens_s4_p1>, <&tsens_s4_p2>,
+ <&tsens_s5_p1>, <&tsens_s5_p2>,
+ <&tsens_s6_p1>, <&tsens_s6_p2>,
+ <&tsens_s7_p1>, <&tsens_s7_p2>,
+ <&tsens_s8_p1>, <&tsens_s8_p2>,
+ <&tsens_s9_p1>, <&tsens_s9_p2>,
+ <&tsens_s10_p1>, <&tsens_s10_p2>,
+ <&tsens_use_backup>,
+ <&tsens_mode_backup>,
+ <&tsens_base1_backup>, <&tsens_base2_backup>,
+ <&tsens_s0_p1_backup>, <&tsens_s0_p2_backup>,
+ <&tsens_s1_p1_backup>, <&tsens_s1_p2_backup>,
+ <&tsens_s2_p1_backup>, <&tsens_s2_p2_backup>,
+ <&tsens_s3_p1_backup>, <&tsens_s3_p2_backup>,
+ <&tsens_s4_p1_backup>, <&tsens_s4_p2_backup>,
+ <&tsens_s5_p1_backup>, <&tsens_s5_p2_backup>,
+ <&tsens_s6_p1_backup>, <&tsens_s6_p2_backup>,
+ <&tsens_s7_p1_backup>, <&tsens_s7_p2_backup>,
+ <&tsens_s8_p1_backup>, <&tsens_s8_p2_backup>,
+ <&tsens_s9_p1_backup>, <&tsens_s9_p2_backup>,
+ <&tsens_s10_p1_backup>, <&tsens_s10_p2_backup>;
+ nvmem-cell-names = "mode",
+ "base1", "base2",
+ "s0_p1", "s0_p2",
+ "s1_p1", "s1_p2",
+ "s2_p1", "s2_p2",
+ "s3_p1", "s3_p2",
+ "s4_p1", "s4_p2",
+ "s5_p1", "s5_p2",
+ "s6_p1", "s6_p2",
+ "s7_p1", "s7_p2",
+ "s8_p1", "s8_p2",
+ "s9_p1", "s9_p2",
+ "s10_p1", "s10_p2",
+ "use_backup",
+ "mode_backup",
+ "base1_backup", "base2_backup",
+ "s0_p1_backup", "s0_p2_backup",
+ "s1_p1_backup", "s1_p2_backup",
+ "s2_p1_backup", "s2_p2_backup",
+ "s3_p1_backup", "s3_p2_backup",
+ "s4_p1_backup", "s4_p2_backup",
+ "s5_p1_backup", "s5_p2_backup",
+ "s6_p1_backup", "s6_p2_backup",
+ "s7_p1_backup", "s7_p2_backup",
+ "s8_p1_backup", "s8_p2_backup",
+ "s9_p1_backup", "s9_p2_backup",
+ "s10_p1_backup", "s10_p2_backup";
#qcom,sensors = <11>;
interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "uplow";
--
2.35.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v3 04/15] thermal/drivers/tsens: Drop unnecessary hw_ids
2022-12-20 2:47 ` [PATCH v3 04/15] thermal/drivers/tsens: Drop unnecessary hw_ids Dmitry Baryshkov
@ 2022-12-20 10:07 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:07 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> The tsens driver defaults to using hw_id equal to the index of the
> sensor. Thus it is superfluous to declare such hw_id arrays. Drop such
> arrays from mdm9607 and msm8976 data.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Konrad
> drivers/thermal/qcom/tsens-v0_1.c | 1 -
> drivers/thermal/qcom/tsens-v1.c | 1 -
> 2 files changed, 2 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
> index 04d012e4f728..0bc4e5cec184 100644
> --- a/drivers/thermal/qcom/tsens-v0_1.c
> +++ b/drivers/thermal/qcom/tsens-v0_1.c
> @@ -635,7 +635,6 @@ static const struct tsens_ops ops_9607 = {
> struct tsens_plat_data data_9607 = {
> .num_sensors = 5,
> .ops = &ops_9607,
> - .hw_ids = (unsigned int []){ 0, 1, 2, 3, 4 },
> .feat = &tsens_v0_1_feat,
> .fields = tsens_v0_1_regfields,
> };
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index 1d7f8a80bd13..96ef12d47bff 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -387,7 +387,6 @@ static const struct tsens_ops ops_8976 = {
> struct tsens_plat_data data_8976 = {
> .num_sensors = 11,
> .ops = &ops_8976,
> - .hw_ids = (unsigned int[]){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
> .feat = &tsens_v1_feat,
> .fields = tsens_v1_regfields,
> };
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 2:47 ` [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939 Dmitry Baryshkov
@ 2022-12-20 10:08 ` Bryan O'Donoghue
2022-12-20 10:21 ` Konrad Dybcio
2022-12-20 14:02 ` Bryan O'Donoghue
1 sibling, 1 reply; 33+ messages in thread
From: Bryan O'Donoghue @ 2022-12-20 10:08 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Rob Herring, Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo
On 20/12/2022 02:47, Dmitry Baryshkov wrote:
> There is no dtsi file for msm8939 in the kernel sources. Drop the
> compatibility with unofficial dtsi and remove support for handling the
> single-cell calibration data on msm8939.
>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Maybe its a better idea to just - finally - get the 8939 dtsi upstream.
Is there anything that needs to change in this ? If not I'll just V2 in
in the next few hours.
tsens: thermal-sensor@4a9000 {
compatible = "qcom,msm8939-tsens", "qcom,tsens-v0_1";
reg = <0x004a9000 0x1000>, /* TM */
<0x004a8000 0x1000>; /* SROT */
nvmem-cells = <&tsens_caldata>;
nvmem-cell-names = "calib";
#qcom,sensors = <10>;
interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
https://git.linaro.org/people/bryan.odonoghue/kernel.git/commit/?h=linux-next-22-12-15-msm8939-no-cpr&id=146087a134306dfb6e1ec48b20b19a278f336b15
---
bod
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 05/15] thermal/drivers/tsens: Drop msm8976-specific defines
2022-12-20 2:47 ` [PATCH v3 05/15] thermal/drivers/tsens: Drop msm8976-specific defines Dmitry Baryshkov
@ 2022-12-20 10:08 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:08 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, AngeloGioacchino Del Regno
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> Drop msm8976-specific defines, which duplicate generic ones.
>
> Fixes: 0e580290170d ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Konrad
> drivers/thermal/qcom/tsens-v1.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index 96ef12d47bff..a7f53966156b 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -78,11 +78,6 @@
>
> #define MSM8976_CAL_SEL_MASK 0x3
>
> -#define MSM8976_CAL_DEGC_PT1 30
> -#define MSM8976_CAL_DEGC_PT2 120
> -#define MSM8976_SLOPE_FACTOR 1000
> -#define MSM8976_SLOPE_DEFAULT 3200
> -
> /* eeprom layout data for qcs404/405 (v1) */
> #define BASE0_MASK 0x000007f8
> #define BASE1_MASK 0x0007f800
> @@ -160,8 +155,8 @@ static void compute_intercept_slope_8976(struct tsens_priv *priv,
> priv->sensor[10].slope = 3286;
>
> for (i = 0; i < priv->num_sensors; i++) {
> - priv->sensor[i].offset = (p1[i] * MSM8976_SLOPE_FACTOR) -
> - (MSM8976_CAL_DEGC_PT1 *
> + priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) -
> + (CAL_DEGC_PT1 *
> priv->sensor[i].slope);
> }
> }
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 06/15] thermal/drivers/tsens: Sort out msm8976 vs msm8956 data
2022-12-20 2:47 ` [PATCH v3 06/15] thermal/drivers/tsens: Sort out msm8976 vs msm8956 data Dmitry Baryshkov
@ 2022-12-20 10:09 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:09 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, AngeloGioacchino Del Regno
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> Tsens driver mentions that msm8976 data should be used for both msm8976
> and msm8956 SoCs. This is not quite correct, as according to the
> vendor kernels, msm8976 should use standard slope values (3200), while
> msm8956 really uses the slope values found in the driver.
>
> Add separate compatibility string for msm8956, move slope value
> overrides to the corresponding init function and use the standard
> compute_intercept_slope() function for both platforms.
>
> Fixes: 0e580290170d ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Konrad
> drivers/thermal/qcom/tsens-v1.c | 56 ++++++++++++++++++---------------
> drivers/thermal/qcom/tsens.c | 3 ++
> drivers/thermal/qcom/tsens.h | 2 +-
> 3 files changed, 34 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index a7f53966156b..83c2853546d0 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -137,30 +137,6 @@
> #define CAL_SEL_MASK 7
> #define CAL_SEL_SHIFT 0
>
> -static void compute_intercept_slope_8976(struct tsens_priv *priv,
> - u32 *p1, u32 *p2, u32 mode)
> -{
> - int i;
> -
> - priv->sensor[0].slope = 3313;
> - priv->sensor[1].slope = 3275;
> - priv->sensor[2].slope = 3320;
> - priv->sensor[3].slope = 3246;
> - priv->sensor[4].slope = 3279;
> - priv->sensor[5].slope = 3257;
> - priv->sensor[6].slope = 3234;
> - priv->sensor[7].slope = 3269;
> - priv->sensor[8].slope = 3255;
> - priv->sensor[9].slope = 3239;
> - priv->sensor[10].slope = 3286;
> -
> - for (i = 0; i < priv->num_sensors; i++) {
> - priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) -
> - (CAL_DEGC_PT1 *
> - priv->sensor[i].slope);
> - }
> -}
> -
> static int calibrate_v1(struct tsens_priv *priv)
> {
> u32 base0 = 0, base1 = 0;
> @@ -286,7 +262,7 @@ static int calibrate_8976(struct tsens_priv *priv)
> break;
> }
>
> - compute_intercept_slope_8976(priv, p1, p2, mode);
> + compute_intercept_slope(priv, p1, p2, mode);
> kfree(qfprom_cdata);
>
> return 0;
> @@ -360,6 +336,22 @@ static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = {
> [TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0),
> };
>
> +static int __init init_8956(struct tsens_priv *priv) {
> + priv->sensor[0].slope = 3313;
> + priv->sensor[1].slope = 3275;
> + priv->sensor[2].slope = 3320;
> + priv->sensor[3].slope = 3246;
> + priv->sensor[4].slope = 3279;
> + priv->sensor[5].slope = 3257;
> + priv->sensor[6].slope = 3234;
> + priv->sensor[7].slope = 3269;
> + priv->sensor[8].slope = 3255;
> + priv->sensor[9].slope = 3239;
> + priv->sensor[10].slope = 3286;
> +
> + return init_common(priv);
> +}
> +
> static const struct tsens_ops ops_generic_v1 = {
> .init = init_common,
> .calibrate = calibrate_v1,
> @@ -372,13 +364,25 @@ struct tsens_plat_data data_tsens_v1 = {
> .fields = tsens_v1_regfields,
> };
>
> +static const struct tsens_ops ops_8956 = {
> + .init = init_8956,
> + .calibrate = calibrate_8976,
> + .get_temp = get_temp_tsens_valid,
> +};
> +
> +struct tsens_plat_data data_8956 = {
> + .num_sensors = 11,
> + .ops = &ops_8956,
> + .feat = &tsens_v1_feat,
> + .fields = tsens_v1_regfields,
> +};
> +
> static const struct tsens_ops ops_8976 = {
> .init = init_common,
> .calibrate = calibrate_8976,
> .get_temp = get_temp_tsens_valid,
> };
>
> -/* Valid for both MSM8956 and MSM8976. */
> struct tsens_plat_data data_8976 = {
> .num_sensors = 11,
> .ops = &ops_8976,
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index b5b136ff323f..b191e19df93d 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -983,6 +983,9 @@ static const struct of_device_id tsens_table[] = {
> }, {
> .compatible = "qcom,msm8939-tsens",
> .data = &data_8939,
> + }, {
> + .compatible = "qcom,msm8956-tsens",
> + .data = &data_8956,
> }, {
> .compatible = "qcom,msm8960-tsens",
> .data = &data_8960,
> diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
> index 899af128855f..7dd5fc246894 100644
> --- a/drivers/thermal/qcom/tsens.h
> +++ b/drivers/thermal/qcom/tsens.h
> @@ -594,7 +594,7 @@ extern struct tsens_plat_data data_8960;
> extern struct tsens_plat_data data_8916, data_8939, data_8974, data_9607;
>
> /* TSENS v1 targets */
> -extern struct tsens_plat_data data_tsens_v1, data_8976;
> +extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956;
>
> /* TSENS v2 targets */
> extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 10:08 ` Bryan O'Donoghue
@ 2022-12-20 10:21 ` Konrad Dybcio
2022-12-20 10:26 ` Bryan O'Donoghue
0 siblings, 1 reply; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:21 UTC (permalink / raw)
To: Bryan O'Donoghue, Dmitry Baryshkov, Andy Gross,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Amit Kucheria,
Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo
On 20.12.2022 11:08, Bryan O'Donoghue wrote:
> On 20/12/2022 02:47, Dmitry Baryshkov wrote:
>> There is no dtsi file for msm8939 in the kernel sources. Drop the
>> compatibility with unofficial dtsi and remove support for handling the
>> single-cell calibration data on msm8939.
>>
>> Cc: Shawn Guo <shawn.guo@linaro.org>
>> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>
> Maybe its a better idea to just - finally - get the 8939 dtsi upstream.
>
> Is there anything that needs to change in this ? If not I'll just V2 in in the next few hours.
The point of this patchset is to remove logic like this, as it's
very repetetive and all it does is read fuses with a ton of magic
offsets. Dmitry pushes that to DT with the generic nvmem API, so
that instead of these magic &s and <<s, one is simply supposed to
define QFPROM fuses at the correct offset and with a matching bits=<>
property. This does not remove any functionality, it just changes
how the fuses are accessed and makes the code more generic.
Konrad
>
> tsens: thermal-sensor@4a9000 {
> compatible = "qcom,msm8939-tsens", "qcom,tsens-v0_1";
> reg = <0x004a9000 0x1000>, /* TM */
> <0x004a8000 0x1000>; /* SROT */
> nvmem-cells = <&tsens_caldata>;
> nvmem-cell-names = "calib";
> #qcom,sensors = <10>;
> interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
> interrupt-names = "uplow";
> #thermal-sensor-cells = <1>;
> };
>
> https://git.linaro.org/people/bryan.odonoghue/kernel.git/commit/?h=linux-next-22-12-15-msm8939-no-cpr&id=146087a134306dfb6e1ec48b20b19a278f336b15
>
> ---
> bod
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 09/15] thermal/drivers/tsens: Drop single-cell code for mdm9607
2022-12-20 2:47 ` [PATCH v3 09/15] thermal/drivers/tsens: Drop single-cell code for mdm9607 Dmitry Baryshkov
@ 2022-12-20 10:22 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:22 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> There is no dtsi file for mdm9607 in the kernel sources. Drop the
> compatibility with unofficial dtsi and remove support for handling the
> single-cell calibration data on mdm9607.
>
> Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Konrad
> drivers/thermal/qcom/tsens-v0_1.c | 95 +------------------------------
> 1 file changed, 1 insertion(+), 94 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
> index 8f1ea7075354..caffcf9905b9 100644
> --- a/drivers/thermal/qcom/tsens-v0_1.c
> +++ b/drivers/thermal/qcom/tsens-v0_1.c
> @@ -133,39 +133,6 @@
>
> #define BIT_APPEND 0x3
>
> -/* eeprom layout data for mdm9607 */
> -#define MDM9607_BASE0_MASK 0x000000ff
> -#define MDM9607_BASE1_MASK 0x000ff000
> -#define MDM9607_BASE0_SHIFT 0
> -#define MDM9607_BASE1_SHIFT 12
> -
> -#define MDM9607_S0_P1_MASK 0x00003f00
> -#define MDM9607_S1_P1_MASK 0x03f00000
> -#define MDM9607_S2_P1_MASK 0x0000003f
> -#define MDM9607_S3_P1_MASK 0x0003f000
> -#define MDM9607_S4_P1_MASK 0x0000003f
> -
> -#define MDM9607_S0_P2_MASK 0x000fc000
> -#define MDM9607_S1_P2_MASK 0xfc000000
> -#define MDM9607_S2_P2_MASK 0x00000fc0
> -#define MDM9607_S3_P2_MASK 0x00fc0000
> -#define MDM9607_S4_P2_MASK 0x00000fc0
> -
> -#define MDM9607_S0_P1_SHIFT 8
> -#define MDM9607_S1_P1_SHIFT 20
> -#define MDM9607_S2_P1_SHIFT 0
> -#define MDM9607_S3_P1_SHIFT 12
> -#define MDM9607_S4_P1_SHIFT 0
> -
> -#define MDM9607_S0_P2_SHIFT 14
> -#define MDM9607_S1_P2_SHIFT 26
> -#define MDM9607_S2_P2_SHIFT 6
> -#define MDM9607_S3_P2_SHIFT 18
> -#define MDM9607_S4_P2_SHIFT 6
> -
> -#define MDM9607_CAL_SEL_MASK 0x00700000
> -#define MDM9607_CAL_SEL_SHIFT 20
> -
> static int calibrate_8916(struct tsens_priv *priv)
> {
> int base0 = 0, base1 = 0, i;
> @@ -363,60 +330,6 @@ static int calibrate_8974(struct tsens_priv *priv)
> return 0;
> }
>
> -static int calibrate_9607(struct tsens_priv *priv)
> -{
> - int base, i;
> - u32 p1[5], p2[5];
> - int mode = 0;
> - u32 *qfprom_cdata;
> - int ret;
> -
> - ret = tsens_calibrate_common(priv);
> - if (!ret)
> - return 0;
> -
> - qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
> - if (IS_ERR(qfprom_cdata))
> - return PTR_ERR(qfprom_cdata);
> -
> - mode = (qfprom_cdata[2] & MDM9607_CAL_SEL_MASK) >> MDM9607_CAL_SEL_SHIFT;
> - dev_dbg(priv->dev, "calibration mode is %d\n", mode);
> -
> - switch (mode) {
> - case TWO_PT_CALIB:
> - base = (qfprom_cdata[2] & MDM9607_BASE1_MASK) >> MDM9607_BASE1_SHIFT;
> - p2[0] = (qfprom_cdata[0] & MDM9607_S0_P2_MASK) >> MDM9607_S0_P2_SHIFT;
> - p2[1] = (qfprom_cdata[0] & MDM9607_S1_P2_MASK) >> MDM9607_S1_P2_SHIFT;
> - p2[2] = (qfprom_cdata[1] & MDM9607_S2_P2_MASK) >> MDM9607_S2_P2_SHIFT;
> - p2[3] = (qfprom_cdata[1] & MDM9607_S3_P2_MASK) >> MDM9607_S3_P2_SHIFT;
> - p2[4] = (qfprom_cdata[2] & MDM9607_S4_P2_MASK) >> MDM9607_S4_P2_SHIFT;
> - for (i = 0; i < priv->num_sensors; i++)
> - p2[i] = ((base + p2[i]) << 2);
> - fallthrough;
> - case ONE_PT_CALIB2:
> - base = (qfprom_cdata[0] & MDM9607_BASE0_MASK);
> - p1[0] = (qfprom_cdata[0] & MDM9607_S0_P1_MASK) >> MDM9607_S0_P1_SHIFT;
> - p1[1] = (qfprom_cdata[0] & MDM9607_S1_P1_MASK) >> MDM9607_S1_P1_SHIFT;
> - p1[2] = (qfprom_cdata[1] & MDM9607_S2_P1_MASK) >> MDM9607_S2_P1_SHIFT;
> - p1[3] = (qfprom_cdata[1] & MDM9607_S3_P1_MASK) >> MDM9607_S3_P1_SHIFT;
> - p1[4] = (qfprom_cdata[2] & MDM9607_S4_P1_MASK) >> MDM9607_S4_P1_SHIFT;
> - for (i = 0; i < priv->num_sensors; i++)
> - p1[i] = ((base + p1[i]) << 2);
> - break;
> - default:
> - for (i = 0; i < priv->num_sensors; i++) {
> - p1[i] = 500;
> - p2[i] = 780;
> - }
> - break;
> - }
> -
> - compute_intercept_slope(priv, p1, p2, mode);
> - kfree(qfprom_cdata);
> -
> - return 0;
> -}
> -
> /* v0.1: 8916, 8939, 8974, 9607 */
>
> static struct tsens_features tsens_v0_1_feat = {
> @@ -509,15 +422,9 @@ struct tsens_plat_data data_8974 = {
> .fields = tsens_v0_1_regfields,
> };
>
> -static const struct tsens_ops ops_9607 = {
> - .init = init_common,
> - .calibrate = calibrate_9607,
> - .get_temp = get_temp_common,
> -};
> -
> struct tsens_plat_data data_9607 = {
> .num_sensors = 5,
> - .ops = &ops_9607,
> + .ops = &ops_v0_1,
> .feat = &tsens_v0_1_feat,
> .fields = tsens_v0_1_regfields,
> };
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956
2022-12-20 2:47 ` [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956 Dmitry Baryshkov
@ 2022-12-20 10:24 ` Konrad Dybcio
2022-12-20 13:34 ` Dmitry Baryshkov
0 siblings, 1 reply; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:24 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, AngeloGioacchino Del Regno
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> There is no dtsi file for msm8976 in the kernel sources.
This is not true :/
But it has just been merged, if we get there fast, we can get
this patch going *and* convert the node to use fuses..
Unless breaking a platform that's only in linux-next would be
an issue.. Maybe we could prettyplease ask Bjorn to send a
-fixes pull with a "remove tsens node from 8976" commit?
Not sure if it's too late or not...
Konrad
Drop the
> compatibility with unofficial dtsi and remove support for handling the
> single-cell calibration data on msm8976.
>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> drivers/thermal/qcom/tsens-v1.c | 126 +-------------------------------
> 1 file changed, 2 insertions(+), 124 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index 89955522041d..9151c1043a11 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -21,63 +21,6 @@
> #define TM_HIGH_LOW_INT_STATUS_OFF 0x0088
> #define TM_HIGH_LOW_Sn_INT_THRESHOLD_OFF 0x0090
>
> -/* eeprom layout data for msm8956/76 (v1) */
> -#define MSM8976_BASE0_MASK 0xff
> -#define MSM8976_BASE1_MASK 0xff
> -#define MSM8976_BASE1_SHIFT 8
> -
> -#define MSM8976_S0_P1_MASK 0x3f00
> -#define MSM8976_S1_P1_MASK 0x3f00000
> -#define MSM8976_S2_P1_MASK 0x3f
> -#define MSM8976_S3_P1_MASK 0x3f000
> -#define MSM8976_S4_P1_MASK 0x3f00
> -#define MSM8976_S5_P1_MASK 0x3f00000
> -#define MSM8976_S6_P1_MASK 0x3f
> -#define MSM8976_S7_P1_MASK 0x3f000
> -#define MSM8976_S8_P1_MASK 0x1f8
> -#define MSM8976_S9_P1_MASK 0x1f8000
> -#define MSM8976_S10_P1_MASK 0xf8000000
> -#define MSM8976_S10_P1_MASK_1 0x1
> -
> -#define MSM8976_S0_P2_MASK 0xfc000
> -#define MSM8976_S1_P2_MASK 0xfc000000
> -#define MSM8976_S2_P2_MASK 0xfc0
> -#define MSM8976_S3_P2_MASK 0xfc0000
> -#define MSM8976_S4_P2_MASK 0xfc000
> -#define MSM8976_S5_P2_MASK 0xfc000000
> -#define MSM8976_S6_P2_MASK 0xfc0
> -#define MSM8976_S7_P2_MASK 0xfc0000
> -#define MSM8976_S8_P2_MASK 0x7e00
> -#define MSM8976_S9_P2_MASK 0x7e00000
> -#define MSM8976_S10_P2_MASK 0x7e
> -
> -#define MSM8976_S0_P1_SHIFT 8
> -#define MSM8976_S1_P1_SHIFT 20
> -#define MSM8976_S2_P1_SHIFT 0
> -#define MSM8976_S3_P1_SHIFT 12
> -#define MSM8976_S4_P1_SHIFT 8
> -#define MSM8976_S5_P1_SHIFT 20
> -#define MSM8976_S6_P1_SHIFT 0
> -#define MSM8976_S7_P1_SHIFT 12
> -#define MSM8976_S8_P1_SHIFT 3
> -#define MSM8976_S9_P1_SHIFT 15
> -#define MSM8976_S10_P1_SHIFT 27
> -#define MSM8976_S10_P1_SHIFT_1 0
> -
> -#define MSM8976_S0_P2_SHIFT 14
> -#define MSM8976_S1_P2_SHIFT 26
> -#define MSM8976_S2_P2_SHIFT 6
> -#define MSM8976_S3_P2_SHIFT 18
> -#define MSM8976_S4_P2_SHIFT 14
> -#define MSM8976_S5_P2_SHIFT 26
> -#define MSM8976_S6_P2_SHIFT 6
> -#define MSM8976_S7_P2_SHIFT 18
> -#define MSM8976_S8_P2_SHIFT 9
> -#define MSM8976_S9_P2_SHIFT 21
> -#define MSM8976_S10_P2_SHIFT 1
> -
> -#define MSM8976_CAL_SEL_MASK 0x3
> -
> /* eeprom layout data for qcs404/405 (v1) */
> #define BASE0_MASK 0x000007f8
> #define BASE1_MASK 0x0007f800
> @@ -207,71 +150,6 @@ static int calibrate_v1(struct tsens_priv *priv)
> return 0;
> }
>
> -static int calibrate_8976(struct tsens_priv *priv)
> -{
> - int base0 = 0, base1 = 0, i;
> - u32 p1[11], p2[11];
> - int mode = 0, tmp = 0;
> - u32 *qfprom_cdata;
> -
> - qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
> - if (IS_ERR(qfprom_cdata))
> - return PTR_ERR(qfprom_cdata);
> -
> - mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
> - dev_dbg(priv->dev, "calibration mode is %d\n", mode);
> -
> - switch (mode) {
> - case TWO_PT_CALIB:
> - base1 = (qfprom_cdata[2] & MSM8976_BASE1_MASK) >> MSM8976_BASE1_SHIFT;
> - p2[0] = (qfprom_cdata[0] & MSM8976_S0_P2_MASK) >> MSM8976_S0_P2_SHIFT;
> - p2[1] = (qfprom_cdata[0] & MSM8976_S1_P2_MASK) >> MSM8976_S1_P2_SHIFT;
> - p2[2] = (qfprom_cdata[1] & MSM8976_S2_P2_MASK) >> MSM8976_S2_P2_SHIFT;
> - p2[3] = (qfprom_cdata[1] & MSM8976_S3_P2_MASK) >> MSM8976_S3_P2_SHIFT;
> - p2[4] = (qfprom_cdata[2] & MSM8976_S4_P2_MASK) >> MSM8976_S4_P2_SHIFT;
> - p2[5] = (qfprom_cdata[2] & MSM8976_S5_P2_MASK) >> MSM8976_S5_P2_SHIFT;
> - p2[6] = (qfprom_cdata[3] & MSM8976_S6_P2_MASK) >> MSM8976_S6_P2_SHIFT;
> - p2[7] = (qfprom_cdata[3] & MSM8976_S7_P2_MASK) >> MSM8976_S7_P2_SHIFT;
> - p2[8] = (qfprom_cdata[4] & MSM8976_S8_P2_MASK) >> MSM8976_S8_P2_SHIFT;
> - p2[9] = (qfprom_cdata[4] & MSM8976_S9_P2_MASK) >> MSM8976_S9_P2_SHIFT;
> - p2[10] = (qfprom_cdata[5] & MSM8976_S10_P2_MASK) >> MSM8976_S10_P2_SHIFT;
> -
> - for (i = 0; i < priv->num_sensors; i++)
> - p2[i] = ((base1 + p2[i]) << 2);
> - fallthrough;
> - case ONE_PT_CALIB2:
> - base0 = qfprom_cdata[0] & MSM8976_BASE0_MASK;
> - p1[0] = (qfprom_cdata[0] & MSM8976_S0_P1_MASK) >> MSM8976_S0_P1_SHIFT;
> - p1[1] = (qfprom_cdata[0] & MSM8976_S1_P1_MASK) >> MSM8976_S1_P1_SHIFT;
> - p1[2] = (qfprom_cdata[1] & MSM8976_S2_P1_MASK) >> MSM8976_S2_P1_SHIFT;
> - p1[3] = (qfprom_cdata[1] & MSM8976_S3_P1_MASK) >> MSM8976_S3_P1_SHIFT;
> - p1[4] = (qfprom_cdata[2] & MSM8976_S4_P1_MASK) >> MSM8976_S4_P1_SHIFT;
> - p1[5] = (qfprom_cdata[2] & MSM8976_S5_P1_MASK) >> MSM8976_S5_P1_SHIFT;
> - p1[6] = (qfprom_cdata[3] & MSM8976_S6_P1_MASK) >> MSM8976_S6_P1_SHIFT;
> - p1[7] = (qfprom_cdata[3] & MSM8976_S7_P1_MASK) >> MSM8976_S7_P1_SHIFT;
> - p1[8] = (qfprom_cdata[4] & MSM8976_S8_P1_MASK) >> MSM8976_S8_P1_SHIFT;
> - p1[9] = (qfprom_cdata[4] & MSM8976_S9_P1_MASK) >> MSM8976_S9_P1_SHIFT;
> - p1[10] = (qfprom_cdata[4] & MSM8976_S10_P1_MASK) >> MSM8976_S10_P1_SHIFT;
> - tmp = (qfprom_cdata[5] & MSM8976_S10_P1_MASK_1) << MSM8976_S10_P1_SHIFT_1;
> - p1[10] |= tmp;
> -
> - for (i = 0; i < priv->num_sensors; i++)
> - p1[i] = (((base0) + p1[i]) << 2);
> - break;
> - default:
> - for (i = 0; i < priv->num_sensors; i++) {
> - p1[i] = 500;
> - p2[i] = 780;
> - }
> - break;
> - }
> -
> - compute_intercept_slope(priv, p1, p2, mode);
> - kfree(qfprom_cdata);
> -
> - return 0;
> -}
> -
> /* v1.x: msm8956,8976,qcs404,405 */
>
> static struct tsens_features tsens_v1_feat = {
> @@ -370,7 +248,7 @@ struct tsens_plat_data data_tsens_v1 = {
>
> static const struct tsens_ops ops_8956 = {
> .init = init_8956,
> - .calibrate = calibrate_8976,
> + .calibrate = tsens_calibrate_common,
> .get_temp = get_temp_tsens_valid,
> };
>
> @@ -383,7 +261,7 @@ struct tsens_plat_data data_8956 = {
>
> static const struct tsens_ops ops_8976 = {
> .init = init_common,
> - .calibrate = calibrate_8976,
> + .calibrate = tsens_calibrate_common,
> .get_temp = get_temp_tsens_valid,
> };
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 10:21 ` Konrad Dybcio
@ 2022-12-20 10:26 ` Bryan O'Donoghue
2022-12-20 10:32 ` Konrad Dybcio
0 siblings, 1 reply; 33+ messages in thread
From: Bryan O'Donoghue @ 2022-12-20 10:26 UTC (permalink / raw)
To: Konrad Dybcio, Bryan O'Donoghue, Dmitry Baryshkov, Andy Gross,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Amit Kucheria,
Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo
On 20/12/2022 10:21, Konrad Dybcio wrote:
> The point of this patchset is to remove logic like this, as it's
> very repetetive and all it does is read fuses with a ton of magic
> offsets. Dmitry pushes that to DT with the generic nvmem API, so
> that instead of these magic &s and <<s, one is simply supposed to
> define QFPROM fuses at the correct offset and with a matching bits=<>
> property. This does not remove any functionality, it just changes
> how the fuses are accessed and makes the code more generic.
>
> Konrad
Hmm but then there's extra work to get this working again on 8939 right?
Seems very dogmatic to drop working code for want of sending a dtsi out.
Certainly my preference is to keep exiting working code and just
complete landing the relevant dtsi, rather than eject working code and
have to do the same work all over again.
---
bod
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 10:26 ` Bryan O'Donoghue
@ 2022-12-20 10:32 ` Konrad Dybcio
2022-12-20 10:34 ` Bryan O'Donoghue
0 siblings, 1 reply; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:32 UTC (permalink / raw)
To: Bryan O'Donoghue, Bryan O'Donoghue, Dmitry Baryshkov,
Andy Gross, Bjorn Andersson, Rob Herring, Krzysztof Kozlowski,
Amit Kucheria, Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano,
Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo
On 20.12.2022 11:26, Bryan O'Donoghue wrote:
> On 20/12/2022 10:21, Konrad Dybcio wrote:
>> The point of this patchset is to remove logic like this, as it's
>> very repetetive and all it does is read fuses with a ton of magic
>> offsets. Dmitry pushes that to DT with the generic nvmem API, so
>> that instead of these magic &s and <<s, one is simply supposed to
>> define QFPROM fuses at the correct offset and with a matching bits=<>
>> property. This does not remove any functionality, it just changes
>> how the fuses are accessed and makes the code more generic.
>>
>> Konrad
>
> Hmm but then there's extra work to get this working again on 8939 right?
>
> Seems very dogmatic to drop working code for want of sending a dtsi out.
>
> Certainly my preference is to keep exiting working code and just complete landing the relevant dtsi, rather than eject working code and have to do the same work all over again.
Well, I don't really know how to say it in a way that wouldn't
make it sound mean, but trust me I don't want it to be mean..
Mainline does not and will not (for the most part) care about
out of tree code, so cleanups of parts like this with no users
are wholly expected if your DT hasn't landed upstream (or has been
stuck in review for a long long time like it is the case with
various parts of 8939).. Keeping this old iteration is blocking
progress, as the other similar ones (that *do* have mainline users)
are left in place just to be backwards compatible with old DTs
that may have been pulled from torvalds/linux by third party projects,
like U-Boot, *BSDs or something. Trimming away this now-duplicated
code will shrink the driver, reducing bloat for everyone that
compiles it in and doesn't use the 8939-specific path.
Konrad
>
> ---
> bod
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 10:32 ` Konrad Dybcio
@ 2022-12-20 10:34 ` Bryan O'Donoghue
2022-12-20 13:29 ` Dmitry Baryshkov
0 siblings, 1 reply; 33+ messages in thread
From: Bryan O'Donoghue @ 2022-12-20 10:34 UTC (permalink / raw)
To: Konrad Dybcio, Bryan O'Donoghue, Dmitry Baryshkov, Andy Gross,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Amit Kucheria,
Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo
On 20/12/2022 10:32, Konrad Dybcio wrote:
> Mainline does not and will not (for the most part) care about
> out of tree code, so cleanups of parts like this with no users
> are wholly expected if your DT hasn't landed upstream (or has been
> stuck in review for a long long time like it is the case with
> various parts of 8939).. Keeping this old iteration is blocking
> progress, as the other similar ones (that*do* have mainline users)
> are left in place just to be backwards compatible with old DTs
> that may have been pulled from torvalds/linux by third party projects,
> like U-Boot, *BSDs or something. Trimming away this now-duplicated
> code will shrink the driver, reducing bloat for everyone that
> compiles it in and doesn't use the 8939-specific path.
I entirely take your point on duration Konrad but, I think we can be
just a little more pragmatic and hold off on dropping working code and
land the dtsi.
We went to the trouble of upstreaming the enabling code for the 8939,
the right thing to do, IMO is to finish off the job.
---
bod
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 11/15] thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration
2022-12-20 2:47 ` [PATCH v3 11/15] thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration Dmitry Baryshkov
@ 2022-12-20 10:38 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:38 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> MSM8974 has two sets of calibration data: main one and backup. Add
> support for parsing both sets of calibration data from nvmem cells.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Konrad
> drivers/thermal/qcom/tsens-v0_1.c | 50 +++++++++++++++++++++++++++++++
> drivers/thermal/qcom/tsens.c | 39 +++++++++++++++++++-----
> drivers/thermal/qcom/tsens.h | 1 +
> 3 files changed, 82 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
> index caffcf9905b9..6a11b8b196b9 100644
> --- a/drivers/thermal/qcom/tsens-v0_1.c
> +++ b/drivers/thermal/qcom/tsens-v0_1.c
> @@ -3,6 +3,7 @@
> * Copyright (c) 2015, The Linux Foundation. All rights reserved.
> */
>
> +#include <linux/nvmem-consumer.h>
> #include <linux/platform_device.h>
> #include "tsens.h"
>
> @@ -194,6 +195,50 @@ static int calibrate_8916(struct tsens_priv *priv)
> return 0;
> }
>
> +static int calibrate_8974_nvmem(struct tsens_priv *priv)
> +{
> + int i, ret, mode;
> + u32 p1[11], p2[11];
> + u32 backup;
> +
> + ret = nvmem_cell_read_variable_le_u32(priv->dev, "use_backup", &backup);
> + if (ret == -ENOENT)
> + dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n");
> + if (ret < 0)
> + return ret;
> +
> + mode = tsens_read_calibration(priv, 2, p1, p2, backup == BKP_SEL);
> + if (mode < 0)
> + return mode;
> +
> + if (mode == NO_PT_CALIB) {
> + p1[0] += 2;
> + p1[1] += 9;
> + p1[2] += 3;
> + p1[3] += 9;
> + p1[4] += 5;
> + p1[5] += 9;
> + p1[6] += 7;
> + p1[7] += 10;
> + p1[8] += 8;
> + p1[9] += 9;
> + p1[10] += 8;
> + } else {
> + for (i = 0; i < priv->num_sensors; i++) {
> + /*
> + * ONE_PT_CALIB requires using addition here instead of
> + * using OR operation.
> + */
> + p1[i] += BIT_APPEND;
> + p2[i] += BIT_APPEND;
> + }
> + }
> +
> + compute_intercept_slope(priv, p1, p2, mode);
> +
> + return 0;
> +}
> +
> static int calibrate_8974(struct tsens_priv *priv)
> {
> int base1 = 0, base2 = 0, i;
> @@ -201,6 +246,11 @@ static int calibrate_8974(struct tsens_priv *priv)
> int mode = 0;
> u32 *calib, *bkp;
> u32 calib_redun_sel;
> + int ret;
> +
> + ret = calibrate_8974_nvmem(priv);
> + if (ret == 0)
> + return 0;
>
> calib = (u32 *)qfprom_read(priv->dev, "calib");
> if (IS_ERR(calib))
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 68aef0ed6182..83bf60fa9008 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -70,18 +70,21 @@ char *qfprom_read(struct device *dev, const char *cname)
> return ret;
> }
>
> -int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
> +int tsens_read_calibration(struct tsens_priv *priv, int shift, u32 *p1, u32 *p2, bool backup)
> {
> u32 mode;
> u32 base1, base2;
> - u32 p1[MAX_SENSORS], p2[MAX_SENSORS];
> - char name[] = "sXX_pY"; /* s10_p1 */
> + char name[] = "sXX_pY_backup"; /* s10_p1_backup */
> int i, ret;
>
> if (priv->num_sensors > MAX_SENSORS)
> return -EINVAL;
>
> - ret = nvmem_cell_read_variable_le_u32(priv->dev, "mode", &mode);
> + ret = snprintf(name, sizeof(name), "mode%s", backup ? "_backup" : "");
> + if (ret < 0)
> + return ret;
> +
> + ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &mode);
> if (ret == -ENOENT)
> dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n");
> if (ret < 0)
> @@ -89,16 +92,24 @@ int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
>
> dev_dbg(priv->dev, "calibration mode is %d\n", mode);
>
> - ret = nvmem_cell_read_variable_le_u32(priv->dev, "base1", &base1);
> + ret = snprintf(name, sizeof(name), "base1%s", backup ? "_backup" : "");
> + if (ret < 0)
> + return ret;
> +
> + ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base1);
> + if (ret < 0)
> + return ret;
> +
> + ret = snprintf(name, sizeof(name), "base2%s", backup ? "_backup" : "");
> if (ret < 0)
> return ret;
>
> - ret = nvmem_cell_read_variable_le_u32(priv->dev, "base2", &base2);
> + ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base2);
> if (ret < 0)
> return ret;
>
> for (i = 0; i < priv->num_sensors; i++) {
> - ret = snprintf(name, sizeof(name), "s%d_p1", i);
> + ret = snprintf(name, sizeof(name), "s%d_p1%s", i, backup ? "_backup" : "");
> if (ret < 0)
> return ret;
>
> @@ -106,7 +117,7 @@ int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
> if (ret)
> return ret;
>
> - ret = snprintf(name, sizeof(name), "s%d_p2", i);
> + ret = snprintf(name, sizeof(name), "s%d_p2%s", i, backup ? "_backup" : "");
> if (ret < 0)
> return ret;
>
> @@ -136,6 +147,18 @@ int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
> }
> }
>
> + return mode;
> +}
> +
> +int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift)
> +{
> + u32 p1[MAX_SENSORS], p2[MAX_SENSORS];
> + int mode;
> +
> + mode = tsens_read_calibration(priv, shift, p1, p2, false);
> + if (mode < 0)
> + return mode;
> +
> compute_intercept_slope(priv, p1, p2, mode);
>
> return 0;
> diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
> index 645ae02438fa..a9ae8df9f810 100644
> --- a/drivers/thermal/qcom/tsens.h
> +++ b/drivers/thermal/qcom/tsens.h
> @@ -585,6 +585,7 @@ struct tsens_priv {
> };
>
> char *qfprom_read(struct device *dev, const char *cname);
> +int tsens_read_calibration(struct tsens_priv *priv, int shift, u32 *p1, u32 *p2, bool backup);
> int tsens_calibrate_nvmem(struct tsens_priv *priv, int shift);
> int tsens_calibrate_common(struct tsens_priv *priv);
> void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 mode);
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 12/15] arm64: dts: qcom: msm8916: specify per-sensor calibration cells
2022-12-20 2:47 ` [PATCH v3 12/15] arm64: dts: qcom: msm8916: specify per-sensor calibration cells Dmitry Baryshkov
@ 2022-12-20 10:53 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:53 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> Specify pre-parsed per-sensor calibration nvmem cells in the tsens
> device node rather than parsing the whole data blob in the driver.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> arch/arm64/boot/dts/qcom/msm8916.dtsi | 70 ++++++++++++++++++++++++---
> 1 file changed, 64 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> index 2ca8e977fc2a..af7ba66bb7cd 100644
> --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> @@ -442,11 +442,57 @@ qfprom: qfprom@5c000 {
> reg = <0x0005c000 0x1000>;
> #address-cells = <1>;
> #size-cells = <1>;
> - tsens_caldata: caldata@d0 {
> - reg = <0xd0 0x8>;
> + tsens_base1: base1@d0 {
> + reg = <0xd0 0x1>;
> + bits = <0 7>;
> };
> - tsens_calsel: calsel@ec {
> - reg = <0xec 0x4>;
> + tsens_s0_p1: s0_p1@d0 {
No underscores in node names.
> + reg = <0xd0 0x2>;
> + bits = <7 5>;
> + };
> + tsens_s0_p2: s0_p2@d1 {
> + reg = <0xd1 0x2>;
> + bits = <4 5>;
> + };
> + tsens_s1_p1: s1_p1@d2 {
> + reg = <0xd2 0x1>;
> + bits = <1 5>;
> + };
> + tsens_s1_p2: s1_p2@d2 {
> + reg = <0xd2 0x2>;
> + bits = <6 5>;
> + };
> + tsens_s2_p1: s2_p1@d3 {
> + reg = <0xd3 0x1>;
> + bits = <3 5>;
> + };
> + tsens_s2_p2: s2_p2@d4 {
> + reg = <0xd4 0x1>;
> + bits = <0 5>;
> + };
> + tsens_s3_p1: s3_p1@d4 {
> + reg = <0xd4 0x2>;
> + bits = <5 5>;
> + };
> + tsens_s3_p2: s3_p2@d5 {
> + reg = <0xd5 0x1>;
> + bits = <2 5>;
> + };
> + tsens_s4_p1: s4_p1@d5 {
> + reg = <0xd5 0x2>;
> + bits = <7 5>;
> + };
> + tsens_s4_p2: s4_p2@d6 {
> + reg = <0xd6 0x2>;
> + bits = <4 5>;
> + };
> + tsens_base2: base2@d7 {
> + reg = <0xd7 0x1>;
> + bits = <1 7>;
> + };
> + tsens_mode: mode@ec {
> + reg = <0xef 0x1>;
> + bits = <5 3>;
> };
I (gotta admin, a bit painfully) went through all of these again
and they all seem correct!
Konrad
> };
>
> @@ -473,8 +519,20 @@ tsens: thermal-sensor@4a9000 {
> compatible = "qcom,msm8916-tsens", "qcom,tsens-v0_1";
> reg = <0x004a9000 0x1000>, /* TM */
> <0x004a8000 0x1000>; /* SROT */
> - nvmem-cells = <&tsens_caldata>, <&tsens_calsel>;
> - nvmem-cell-names = "calib", "calib_sel";
> + nvmem-cells = <&tsens_mode>,
> + <&tsens_base1>, <&tsens_base2>,
> + <&tsens_s0_p1>, <&tsens_s0_p2>,
> + <&tsens_s1_p1>, <&tsens_s1_p2>,
> + <&tsens_s2_p1>, <&tsens_s2_p2>,
> + <&tsens_s3_p1>, <&tsens_s3_p2>,
> + <&tsens_s4_p1>, <&tsens_s4_p2>;
> + nvmem-cell-names = "mode",
> + "base1", "base2",
> + "s0_p1", "s0_p2",
> + "s1_p1", "s1_p2",
> + "s2_p1", "s2_p2",
> + "s3_p1", "s3_p2",
> + "s4_p1", "s4_p2";
> #qcom,sensors = <5>;
> interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
> interrupt-names = "uplow";
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 13/15] arm64: dts: qcom: qcs404: specify per-sensor calibration cells
2022-12-20 2:47 ` [PATCH v3 13/15] arm64: dts: qcom: qcs404: " Dmitry Baryshkov
@ 2022-12-20 10:57 ` Konrad Dybcio
0 siblings, 0 replies; 33+ messages in thread
From: Konrad Dybcio @ 2022-12-20 10:57 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree
On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> Specify pre-parsed per-sensor calibration nvmem cells in the tsens
> device node rather than parsing the whole data blob in the driver.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> arch/arm64/boot/dts/qcom/qcs404.dtsi | 121 +++++++++++++++++++++++++--
> 1 file changed, 116 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi b/arch/arm64/boot/dts/qcom/qcs404.dtsi
> index a5324eecb50a..362764347006 100644
> --- a/arch/arm64/boot/dts/qcom/qcs404.dtsi
> +++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi
> @@ -366,13 +366,102 @@ qfprom: qfprom@a4000 {
> reg = <0x000a4000 0x1000>;
> #address-cells = <1>;
> #size-cells = <1>;
> - tsens_caldata: caldata@d0 {
> - reg = <0x1f8 0x14>;
> - };
> cpr_efuse_speedbin: speedbin@13c {
> reg = <0x13c 0x4>;
> bits = <2 3>;
> };
Oh wow, this list is even longer.. can you pinky-promise it's
correct? :P In any case, please add newlines between each
subnode and rename the nodes so that there aren't underscores
in the node names.
Konrad
> + tsens_s0_p1: s0_p1@1f8 {
> + reg = <0x1f8 0x1>;
> + bits = <0 6>;
> + };
> + tsens_s0_p2: s0_p2@1f8 {
> + reg = <0x1f8 0x2>;
> + bits = <6 6>;
> + };
> + tsens_s1_p1: s1_p1@1f9 {
> + reg = <0x1f9 0x2>;
> + bits = <4 6>;
> + };
> + tsens_s1_p2: s1_p2@1fa {
> + reg = <0x1fa 0x1>;
> + bits = <2 6>;
> + };
> + tsens_s2_p1: s2_p1@1fb {
> + reg = <0x1fb 0x1>;
> + bits = <0 6>;
> + };
> + tsens_s2_p2: s2_p2@1fb {
> + reg = <0x1fb 0x2>;
> + bits = <6 6>;
> + };
> + tsens_s3_p1: s3_p1@1fc {
> + reg = <0x1fc 0x2>;
> + bits = <4 6>;
> + };
> + tsens_s3_p2: s3_p2@1fd {
> + reg = <0x1fd 0x1>;
> + bits = <2 6>;
> + };
> + tsens_s4_p1: s4_p1@1fe {
> + reg = <0x1fe 0x1>;
> + bits = <0 6>;
> + };
> + tsens_s4_p2: s4_p2@1fe {
> + reg = <0x1fe 0x2>;
> + bits = <6 6>;
> + };
> + tsens_s5_p1: s5_p1@200 {
> + reg = <0x200 0x1>;
> + bits = <0 6>;
> + };
> + tsens_s5_p2: s5_p2@200 {
> + reg = <0x200 0x2>;
> + bits = <6 6>;
> + };
> + tsens_s6_p1: s6_p1@201 {
> + reg = <0x201 0x2>;
> + bits = <4 6>;
> + };
> + tsens_s6_p2: s6_p2@202 {
> + reg = <0x202 0x1>;
> + bits = <2 6>;
> + };
> + tsens_s7_p1: s7_p1@203 {
> + reg = <0x203 0x1>;
> + bits = <0 6>;
> + };
> + tsens_s7_p2: s7_p2@203 {
> + reg = <0x203 0x2>;
> + bits = <6 6>;
> + };
> + tsens_s8_p1: s8_p1@204 {
> + reg = <0x204 0x2>;
> + bits = <4 6>;
> + };
> + tsens_s8_p2: s8_p2@205 {
> + reg = <0x205 0x1>;
> + bits = <2 6>;
> + };
> + tsens_s9_p1: s9_p1@206 {
> + reg = <0x206 0x1>;
> + bits = <0 6>;
> + };
> + tsens_s9_p2: s9_p2@206 {
> + reg = <0x206 0x2>;
> + bits = <6 6>;
> + };
> + tsens_mode: mode@208 {
> + reg = <0x208 1>;
> + bits = <0 3>;
> + };
> + tsens_base1: base1@208 {
> + reg = <0x208 2>;
> + bits = <3 8>;
> + };
> + tsens_base2: base2@208 {
> + reg = <0x209 2>;
> + bits = <3 8>;
> + };
> cpr_efuse_quot_offset1: qoffset1@231 {
> reg = <0x231 0x4>;
> bits = <4 7>;
> @@ -447,8 +536,30 @@ tsens: thermal-sensor@4a9000 {
> compatible = "qcom,qcs404-tsens", "qcom,tsens-v1";
> reg = <0x004a9000 0x1000>, /* TM */
> <0x004a8000 0x1000>; /* SROT */
> - nvmem-cells = <&tsens_caldata>;
> - nvmem-cell-names = "calib";
> + nvmem-cells = <&tsens_mode>,
> + <&tsens_base1>, <&tsens_base2>,
> + <&tsens_s0_p1>, <&tsens_s0_p2>,
> + <&tsens_s1_p1>, <&tsens_s1_p2>,
> + <&tsens_s2_p1>, <&tsens_s2_p2>,
> + <&tsens_s3_p1>, <&tsens_s3_p2>,
> + <&tsens_s4_p1>, <&tsens_s4_p2>,
> + <&tsens_s5_p1>, <&tsens_s5_p2>,
> + <&tsens_s6_p1>, <&tsens_s6_p2>,
> + <&tsens_s7_p1>, <&tsens_s7_p2>,
> + <&tsens_s8_p1>, <&tsens_s8_p2>,
> + <&tsens_s9_p1>, <&tsens_s9_p2>;
> + nvmem-cell-names = "mode",
> + "base1", "base2",
> + "s0_p1", "s0_p2",
> + "s1_p1", "s1_p2",
> + "s2_p1", "s2_p2",
> + "s3_p1", "s3_p2",
> + "s4_p1", "s4_p2",
> + "s5_p1", "s5_p2",
> + "s6_p1", "s6_p2",
> + "s7_p1", "s7_p2",
> + "s8_p1", "s8_p2",
> + "s9_p1", "s9_p2";
> #qcom,sensors = <10>;
> interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
> interrupt-names = "uplow";
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 10:34 ` Bryan O'Donoghue
@ 2022-12-20 13:29 ` Dmitry Baryshkov
2022-12-20 13:51 ` Bryan O'Donoghue
0 siblings, 1 reply; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 13:29 UTC (permalink / raw)
To: Bryan O'Donoghue
Cc: Konrad Dybcio, Bryan O'Donoghue, Andy Gross, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, linux-arm-msm,
linux-pm, devicetree, Shawn Guo
Hello Bryan,
On Tue, 20 Dec 2022 at 12:34, Bryan O'Donoghue
<bryan.odonoghue@linaro.org> wrote:
>
> On 20/12/2022 10:32, Konrad Dybcio wrote:
> > Mainline does not and will not (for the most part) care about
> > out of tree code, so cleanups of parts like this with no users
> > are wholly expected if your DT hasn't landed upstream (or has been
> > stuck in review for a long long time like it is the case with
> > various parts of 8939).. Keeping this old iteration is blocking
> > progress, as the other similar ones (that*do* have mainline users)
> > are left in place just to be backwards compatible with old DTs
> > that may have been pulled from torvalds/linux by third party projects,
> > like U-Boot, *BSDs or something. Trimming away this now-duplicated
> > code will shrink the driver, reducing bloat for everyone that
> > compiles it in and doesn't use the 8939-specific path.
>
> I entirely take your point on duration Konrad but, I think we can be
> just a little more pragmatic and hold off on dropping working code and
> land the dtsi.
>
> We went to the trouble of upstreaming the enabling code for the 8939,
> the right thing to do, IMO is to finish off the job.
I'm pretty sorry to step on your toes here. It's up to the maintainers
of the platform and of the thermal subsystem. However I'd suggest
getting rid of this code.
Would me doing the dtsi patch for you to test on 8939 help you in any way?
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956
2022-12-20 10:24 ` Konrad Dybcio
@ 2022-12-20 13:34 ` Dmitry Baryshkov
0 siblings, 0 replies; 33+ messages in thread
From: Dmitry Baryshkov @ 2022-12-20 13:34 UTC (permalink / raw)
To: Konrad Dybcio
Cc: Andy Gross, Bjorn Andersson, Rob Herring, Krzysztof Kozlowski,
Amit Kucheria, Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano,
Zhang Rui, linux-arm-msm, linux-pm, devicetree,
AngeloGioacchino Del Regno
On Tue, 20 Dec 2022 at 12:24, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
>
> On 20.12.2022 03:47, Dmitry Baryshkov wrote:
> > There is no dtsi file for msm8976 in the kernel sources.
> This is not true :/
>
> But it has just been merged, if we get there fast, we can get
> this patch going *and* convert the node to use fuses..
> Unless breaking a platform that's only in linux-next would be
> an issue.. Maybe we could prettyplease ask Bjorn to send a
> -fixes pull with a "remove tsens node from 8976" commit?
> Not sure if it's too late or not...
Ugh. It's a pity that I missed the dtsi. Bjorn, Angelo, Marijn, any thoughts?
> Konrad
> Drop the
> > compatibility with unofficial dtsi and remove support for handling the
> > single-cell calibration data on msm8976.
> >
> > Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> > drivers/thermal/qcom/tsens-v1.c | 126 +-------------------------------
> > 1 file changed, 2 insertions(+), 124 deletions(-)
> >
> > diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> > index 89955522041d..9151c1043a11 100644
> > --- a/drivers/thermal/qcom/tsens-v1.c
> > +++ b/drivers/thermal/qcom/tsens-v1.c
> > @@ -21,63 +21,6 @@
> > #define TM_HIGH_LOW_INT_STATUS_OFF 0x0088
> > #define TM_HIGH_LOW_Sn_INT_THRESHOLD_OFF 0x0090
> >
> > -/* eeprom layout data for msm8956/76 (v1) */
> > -#define MSM8976_BASE0_MASK 0xff
> > -#define MSM8976_BASE1_MASK 0xff
> > -#define MSM8976_BASE1_SHIFT 8
> > -
> > -#define MSM8976_S0_P1_MASK 0x3f00
> > -#define MSM8976_S1_P1_MASK 0x3f00000
> > -#define MSM8976_S2_P1_MASK 0x3f
> > -#define MSM8976_S3_P1_MASK 0x3f000
> > -#define MSM8976_S4_P1_MASK 0x3f00
> > -#define MSM8976_S5_P1_MASK 0x3f00000
> > -#define MSM8976_S6_P1_MASK 0x3f
> > -#define MSM8976_S7_P1_MASK 0x3f000
> > -#define MSM8976_S8_P1_MASK 0x1f8
> > -#define MSM8976_S9_P1_MASK 0x1f8000
> > -#define MSM8976_S10_P1_MASK 0xf8000000
> > -#define MSM8976_S10_P1_MASK_1 0x1
> > -
> > -#define MSM8976_S0_P2_MASK 0xfc000
> > -#define MSM8976_S1_P2_MASK 0xfc000000
> > -#define MSM8976_S2_P2_MASK 0xfc0
> > -#define MSM8976_S3_P2_MASK 0xfc0000
> > -#define MSM8976_S4_P2_MASK 0xfc000
> > -#define MSM8976_S5_P2_MASK 0xfc000000
> > -#define MSM8976_S6_P2_MASK 0xfc0
> > -#define MSM8976_S7_P2_MASK 0xfc0000
> > -#define MSM8976_S8_P2_MASK 0x7e00
> > -#define MSM8976_S9_P2_MASK 0x7e00000
> > -#define MSM8976_S10_P2_MASK 0x7e
> > -
> > -#define MSM8976_S0_P1_SHIFT 8
> > -#define MSM8976_S1_P1_SHIFT 20
> > -#define MSM8976_S2_P1_SHIFT 0
> > -#define MSM8976_S3_P1_SHIFT 12
> > -#define MSM8976_S4_P1_SHIFT 8
> > -#define MSM8976_S5_P1_SHIFT 20
> > -#define MSM8976_S6_P1_SHIFT 0
> > -#define MSM8976_S7_P1_SHIFT 12
> > -#define MSM8976_S8_P1_SHIFT 3
> > -#define MSM8976_S9_P1_SHIFT 15
> > -#define MSM8976_S10_P1_SHIFT 27
> > -#define MSM8976_S10_P1_SHIFT_1 0
> > -
> > -#define MSM8976_S0_P2_SHIFT 14
> > -#define MSM8976_S1_P2_SHIFT 26
> > -#define MSM8976_S2_P2_SHIFT 6
> > -#define MSM8976_S3_P2_SHIFT 18
> > -#define MSM8976_S4_P2_SHIFT 14
> > -#define MSM8976_S5_P2_SHIFT 26
> > -#define MSM8976_S6_P2_SHIFT 6
> > -#define MSM8976_S7_P2_SHIFT 18
> > -#define MSM8976_S8_P2_SHIFT 9
> > -#define MSM8976_S9_P2_SHIFT 21
> > -#define MSM8976_S10_P2_SHIFT 1
> > -
> > -#define MSM8976_CAL_SEL_MASK 0x3
> > -
> > /* eeprom layout data for qcs404/405 (v1) */
> > #define BASE0_MASK 0x000007f8
> > #define BASE1_MASK 0x0007f800
> > @@ -207,71 +150,6 @@ static int calibrate_v1(struct tsens_priv *priv)
> > return 0;
> > }
> >
> > -static int calibrate_8976(struct tsens_priv *priv)
> > -{
> > - int base0 = 0, base1 = 0, i;
> > - u32 p1[11], p2[11];
> > - int mode = 0, tmp = 0;
> > - u32 *qfprom_cdata;
> > -
> > - qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
> > - if (IS_ERR(qfprom_cdata))
> > - return PTR_ERR(qfprom_cdata);
> > -
> > - mode = (qfprom_cdata[4] & MSM8976_CAL_SEL_MASK);
> > - dev_dbg(priv->dev, "calibration mode is %d\n", mode);
> > -
> > - switch (mode) {
> > - case TWO_PT_CALIB:
> > - base1 = (qfprom_cdata[2] & MSM8976_BASE1_MASK) >> MSM8976_BASE1_SHIFT;
> > - p2[0] = (qfprom_cdata[0] & MSM8976_S0_P2_MASK) >> MSM8976_S0_P2_SHIFT;
> > - p2[1] = (qfprom_cdata[0] & MSM8976_S1_P2_MASK) >> MSM8976_S1_P2_SHIFT;
> > - p2[2] = (qfprom_cdata[1] & MSM8976_S2_P2_MASK) >> MSM8976_S2_P2_SHIFT;
> > - p2[3] = (qfprom_cdata[1] & MSM8976_S3_P2_MASK) >> MSM8976_S3_P2_SHIFT;
> > - p2[4] = (qfprom_cdata[2] & MSM8976_S4_P2_MASK) >> MSM8976_S4_P2_SHIFT;
> > - p2[5] = (qfprom_cdata[2] & MSM8976_S5_P2_MASK) >> MSM8976_S5_P2_SHIFT;
> > - p2[6] = (qfprom_cdata[3] & MSM8976_S6_P2_MASK) >> MSM8976_S6_P2_SHIFT;
> > - p2[7] = (qfprom_cdata[3] & MSM8976_S7_P2_MASK) >> MSM8976_S7_P2_SHIFT;
> > - p2[8] = (qfprom_cdata[4] & MSM8976_S8_P2_MASK) >> MSM8976_S8_P2_SHIFT;
> > - p2[9] = (qfprom_cdata[4] & MSM8976_S9_P2_MASK) >> MSM8976_S9_P2_SHIFT;
> > - p2[10] = (qfprom_cdata[5] & MSM8976_S10_P2_MASK) >> MSM8976_S10_P2_SHIFT;
> > -
> > - for (i = 0; i < priv->num_sensors; i++)
> > - p2[i] = ((base1 + p2[i]) << 2);
> > - fallthrough;
> > - case ONE_PT_CALIB2:
> > - base0 = qfprom_cdata[0] & MSM8976_BASE0_MASK;
> > - p1[0] = (qfprom_cdata[0] & MSM8976_S0_P1_MASK) >> MSM8976_S0_P1_SHIFT;
> > - p1[1] = (qfprom_cdata[0] & MSM8976_S1_P1_MASK) >> MSM8976_S1_P1_SHIFT;
> > - p1[2] = (qfprom_cdata[1] & MSM8976_S2_P1_MASK) >> MSM8976_S2_P1_SHIFT;
> > - p1[3] = (qfprom_cdata[1] & MSM8976_S3_P1_MASK) >> MSM8976_S3_P1_SHIFT;
> > - p1[4] = (qfprom_cdata[2] & MSM8976_S4_P1_MASK) >> MSM8976_S4_P1_SHIFT;
> > - p1[5] = (qfprom_cdata[2] & MSM8976_S5_P1_MASK) >> MSM8976_S5_P1_SHIFT;
> > - p1[6] = (qfprom_cdata[3] & MSM8976_S6_P1_MASK) >> MSM8976_S6_P1_SHIFT;
> > - p1[7] = (qfprom_cdata[3] & MSM8976_S7_P1_MASK) >> MSM8976_S7_P1_SHIFT;
> > - p1[8] = (qfprom_cdata[4] & MSM8976_S8_P1_MASK) >> MSM8976_S8_P1_SHIFT;
> > - p1[9] = (qfprom_cdata[4] & MSM8976_S9_P1_MASK) >> MSM8976_S9_P1_SHIFT;
> > - p1[10] = (qfprom_cdata[4] & MSM8976_S10_P1_MASK) >> MSM8976_S10_P1_SHIFT;
> > - tmp = (qfprom_cdata[5] & MSM8976_S10_P1_MASK_1) << MSM8976_S10_P1_SHIFT_1;
> > - p1[10] |= tmp;
> > -
> > - for (i = 0; i < priv->num_sensors; i++)
> > - p1[i] = (((base0) + p1[i]) << 2);
> > - break;
> > - default:
> > - for (i = 0; i < priv->num_sensors; i++) {
> > - p1[i] = 500;
> > - p2[i] = 780;
> > - }
> > - break;
> > - }
> > -
> > - compute_intercept_slope(priv, p1, p2, mode);
> > - kfree(qfprom_cdata);
> > -
> > - return 0;
> > -}
> > -
> > /* v1.x: msm8956,8976,qcs404,405 */
> >
> > static struct tsens_features tsens_v1_feat = {
> > @@ -370,7 +248,7 @@ struct tsens_plat_data data_tsens_v1 = {
> >
> > static const struct tsens_ops ops_8956 = {
> > .init = init_8956,
> > - .calibrate = calibrate_8976,
> > + .calibrate = tsens_calibrate_common,
> > .get_temp = get_temp_tsens_valid,
> > };
> >
> > @@ -383,7 +261,7 @@ struct tsens_plat_data data_8956 = {
> >
> > static const struct tsens_ops ops_8976 = {
> > .init = init_common,
> > - .calibrate = calibrate_8976,
> > + .calibrate = tsens_calibrate_common,
> > .get_temp = get_temp_tsens_valid,
> > };
> >
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 13:29 ` Dmitry Baryshkov
@ 2022-12-20 13:51 ` Bryan O'Donoghue
0 siblings, 0 replies; 33+ messages in thread
From: Bryan O'Donoghue @ 2022-12-20 13:51 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Konrad Dybcio, Bryan O'Donoghue, Andy Gross, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, linux-arm-msm,
linux-pm, devicetree, Shawn Guo
On 20/12/2022 13:29, Dmitry Baryshkov wrote:
> Would me doing the dtsi patch for you to test on 8939 help you in any way?
Yep.
I'd be happy enough with whatever re-enabling work is required to offset
the removal.
---
bod
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939
2022-12-20 2:47 ` [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939 Dmitry Baryshkov
2022-12-20 10:08 ` Bryan O'Donoghue
@ 2022-12-20 14:02 ` Bryan O'Donoghue
1 sibling, 0 replies; 33+ messages in thread
From: Bryan O'Donoghue @ 2022-12-20 14:02 UTC (permalink / raw)
To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Rob Herring, Krzysztof Kozlowski, Amit Kucheria, Thara Gopinath,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: linux-arm-msm, linux-pm, devicetree, Shawn Guo
On 20/12/2022 02:47, Dmitry Baryshkov wrote:
> There is no dtsi file for msm8939 in the kernel sources. Drop the
> compatibility with unofficial dtsi and remove support for handling the
> single-cell calibration data on msm8939.
>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Happy to take an off-list or follow on patch from Dmitry to re-enable on
8939.
I will drop the relevant node on v2 of the 8939 patches in the interregnum.
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2022-12-20 14:02 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 2:47 [PATCH v3 00/15] thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 01/15] dt-bindings: thermal: tsens: add msm8956 compat Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 02/15] dt-bindings: thermal: tsens: support per-sensor calibration cells Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 03/15] dt-bindings: thermal: tsens: add per-sensor cells for msm8974 Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 04/15] thermal/drivers/tsens: Drop unnecessary hw_ids Dmitry Baryshkov
2022-12-20 10:07 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 05/15] thermal/drivers/tsens: Drop msm8976-specific defines Dmitry Baryshkov
2022-12-20 10:08 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 06/15] thermal/drivers/tsens: Sort out msm8976 vs msm8956 data Dmitry Baryshkov
2022-12-20 10:09 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 07/15] thermal/drivers/tsens: Support using nvmem cells for calibration data Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 08/15] thermal/drivers/tsens: Drop single-cell code for msm8939 Dmitry Baryshkov
2022-12-20 10:08 ` Bryan O'Donoghue
2022-12-20 10:21 ` Konrad Dybcio
2022-12-20 10:26 ` Bryan O'Donoghue
2022-12-20 10:32 ` Konrad Dybcio
2022-12-20 10:34 ` Bryan O'Donoghue
2022-12-20 13:29 ` Dmitry Baryshkov
2022-12-20 13:51 ` Bryan O'Donoghue
2022-12-20 14:02 ` Bryan O'Donoghue
2022-12-20 2:47 ` [PATCH v3 09/15] thermal/drivers/tsens: Drop single-cell code for mdm9607 Dmitry Baryshkov
2022-12-20 10:22 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 10/15] thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956 Dmitry Baryshkov
2022-12-20 10:24 ` Konrad Dybcio
2022-12-20 13:34 ` Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 11/15] thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration Dmitry Baryshkov
2022-12-20 10:38 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 12/15] arm64: dts: qcom: msm8916: specify per-sensor calibration cells Dmitry Baryshkov
2022-12-20 10:53 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 13/15] arm64: dts: qcom: qcs404: " Dmitry Baryshkov
2022-12-20 10:57 ` Konrad Dybcio
2022-12-20 2:47 ` [PATCH v3 14/15] ARM: dts: qcom-msm8974: " Dmitry Baryshkov
2022-12-20 2:47 ` [PATCH v3 15/15] ARM: dts: qcom-apq8084: " Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).