* [PATCH 0/2] meson-saradc: temperature sensor support for Meson8b/Meson8m2
@ 2018-12-27 21:50 Martin Blumenstingl
2018-12-27 21:50 ` [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support Martin Blumenstingl
2018-12-27 21:50 ` [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs Martin Blumenstingl
0 siblings, 2 replies; 7+ messages in thread
From: Martin Blumenstingl @ 2018-12-27 21:50 UTC (permalink / raw)
To: linux-amlogic, devicetree, linux-iio, jic23, lars, pmeerw,
robh+dt, mark.rutland
Cc: balbes-150, Martin Blumenstingl, linux-kernel, linux-arm-kernel
This adds support for the temperature sensor on Meson8b and Meson8m2
(both are sharing the same logic).
These SoCs can use most of the existing infrastructure that we already
have for Meson8:
- parsing the TSC (calibration data) from an nvmem-cell
- the math to calculate millicelsius from the register values
What this series adds on top of the existing infrastructure:
- The TSC data is 5-bit wide instead of 4-bit. The upper-most bit has t
be written into a register in the HHI area (which is outside the ADC
register space). Thus this adds a new device tree property to pass the
HHI syscon to the SAR ADC and we set up this register during SAR ADC
driver initialization
- the multiplier and divider values (to convert the raw register value
to celsius / millicelsius) are different compared to Meson8
This was successfully tested on multiple boards:
- Meson8b Odroid-C1 (me)
- Meson8b EC-100 (me)
- Meson8m2 M8S (not upstream yet, me)
- Meson8m2 MXIII-Plus (an earlier version of this series, Oleg Ivanov)
Martin Blumenstingl (2):
dt-bindings: iio: adc: meson-saradc: update temperature sensor support
iio: adc: meson-saradc: enable the temperature sensor two more SoCs
.../bindings/iio/adc/amlogic,meson-saradc.txt | 4 +++
drivers/iio/adc/meson_saradc.c | 33 +++++++++++++++++++
2 files changed, 37 insertions(+)
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support
2018-12-27 21:50 [PATCH 0/2] meson-saradc: temperature sensor support for Meson8b/Meson8m2 Martin Blumenstingl
@ 2018-12-27 21:50 ` Martin Blumenstingl
2019-01-03 23:02 ` Rob Herring
2018-12-27 21:50 ` [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs Martin Blumenstingl
1 sibling, 1 reply; 7+ messages in thread
From: Martin Blumenstingl @ 2018-12-27 21:50 UTC (permalink / raw)
To: linux-amlogic, devicetree, linux-iio, jic23, lars, pmeerw,
robh+dt, mark.rutland
Cc: balbes-150, Martin Blumenstingl, linux-kernel, linux-arm-kernel
Meson8b and Meson8m2 use a 5-bit wide TSC (temperature sensor
coefficient). The SAR ADC registers however can only store (the lower)
4 bits. The fifth (upper-most) bit is stored inside the
MESON_HHI_DPLL_TOP_0[9] register from the HHI register area.
This adds a syscon property to the HHI register area so a driver can
fetch the HHI register map and store the fifth TSC bit in there.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../devicetree/bindings/iio/adc/amlogic,meson-saradc.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
index 325090e43ce6..75c775954102 100644
--- a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
@@ -23,6 +23,10 @@ Required properties:
- #io-channel-cells: must be 1, see ../iio-bindings.txt
Optional properties:
+- amlogic,hhi-sysctrl: phandle to the syscon which contains the 5th bit
+ of the TSC (temperature sensor coefficient) on
+ Meson8b and Meson8m2 (which used to calibrate the
+ temperature sensor)
- nvmem-cells: phandle to the temperature_calib eFuse cells
- nvmem-cell-names: if present (to enable the temperature sensor
calibration) this must contain "temperature_calib"
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs
2018-12-27 21:50 [PATCH 0/2] meson-saradc: temperature sensor support for Meson8b/Meson8m2 Martin Blumenstingl
2018-12-27 21:50 ` [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support Martin Blumenstingl
@ 2018-12-27 21:50 ` Martin Blumenstingl
2019-01-05 16:41 ` Jonathan Cameron
2019-01-05 16:44 ` Jonathan Cameron
1 sibling, 2 replies; 7+ messages in thread
From: Martin Blumenstingl @ 2018-12-27 21:50 UTC (permalink / raw)
To: linux-amlogic, devicetree, linux-iio, jic23, lars, pmeerw,
robh+dt, mark.rutland
Cc: balbes-150, Martin Blumenstingl, linux-kernel, linux-arm-kernel
Meson8b and Meson8m2 use the same logic to convert the ADC register
value to celsius, which is different from Meson8:
- Meson8 has different multiplier and divider values
- Meson8 uses a 4-bit TSC (temperature sensor coefficient) which fits
into the 4-bit field in the MESON_SAR_ADC_DELTA_10 register:
MESON_SAR_ADC_DELTA_10_TS_C_MASK. Meson8b and Meson8m2 have a 5-bit
TSC which requires writing the upper-most bit into the
MESON_HHI_DPLL_TOP_0[9] register from the HHI register area.
This adds support for the temperature sensor on the Meson8b and Meson8m2
SoCs by implementing the logic to write the upper-most TSC bit into the
HHI register area. The SoC-specific values (temperature_trimming_bits,
temperature_multiplier, temperature_divider) are added - these simply
integrate into the existing infrastructure (which was implemented for
Meson8) and thus require no further changes to the existing temperature
calculation logic.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/iio/adc/meson_saradc.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 729becb2d3d9..f8600fbcdfe3 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -26,6 +26,7 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
+#include <linux/mfd/syscon.h>
#define MESON_SAR_ADC_REG0 0x00
#define MESON_SAR_ADC_REG0_PANEL_DETECT BIT(31)
@@ -174,6 +175,9 @@
#define MESON_SAR_ADC_EFUSE_BYTE3_UPPER_ADC_VAL GENMASK(6, 0)
#define MESON_SAR_ADC_EFUSE_BYTE3_IS_CALIBRATED BIT(7)
+#define MESON_HHI_DPLL_TOP_0 0x318
+#define MESON_HHI_DPLL_TOP_0_TSC_BIT4 BIT(9)
+
/* for use with IIO_VAL_INT_PLUS_MICRO */
#define MILLION 1000000
@@ -280,6 +284,7 @@ struct meson_sar_adc_priv {
struct completion done;
int calibbias;
int calibscale;
+ struct regmap *tsc_regmap;
bool temperature_sensor_calibrated;
u8 temperature_sensor_coefficient;
u16 temperature_sensor_adc_val;
@@ -727,6 +732,15 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
return ret;
}
+ priv->tsc_regmap =
+ syscon_regmap_lookup_by_phandle(indio_dev->dev.parent->of_node,
+ "amlogic,hhi-sysctrl");
+ if (IS_ERR(priv->tsc_regmap)) {
+ dev_err(indio_dev->dev.parent,
+ "failed to get amlogic,hhi-sysctrl regmap\n");
+ return PTR_ERR(priv->tsc_regmap);
+ }
+
read_len = MESON_SAR_ADC_EFUSE_BYTES;
buf = nvmem_cell_read(temperature_calib, &read_len);
if (IS_ERR(buf)) {
@@ -861,6 +875,22 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
priv->temperature_sensor_coefficient);
regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10,
MESON_SAR_ADC_DELTA_10_TS_C_MASK, regval);
+
+ if (priv->param->temperature_trimming_bits == 5) {
+ if (priv->temperature_sensor_coefficient & BIT(4))
+ regval = MESON_HHI_DPLL_TOP_0_TSC_BIT4;
+ else
+ regval = 0;
+
+ /*
+ * bit [4] (the 5th bit when starting to count at 1)
+ * of the TSC is located in the HHI register area.
+ */
+ regmap_update_bits(priv->tsc_regmap,
+ MESON_HHI_DPLL_TOP_0,
+ MESON_HHI_DPLL_TOP_0_TSC_BIT4,
+ regval);
+ }
} else {
regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10,
MESON_SAR_ADC_DELTA_10_TS_REVE1, 0);
@@ -1064,6 +1094,9 @@ static const struct meson_sar_adc_param meson_sar_adc_meson8b_param = {
.bandgap_reg = MESON_SAR_ADC_DELTA_10,
.regmap_config = &meson_sar_adc_regmap_config_meson8,
.resolution = 10,
+ .temperature_trimming_bits = 5,
+ .temperature_multiplier = 10,
+ .temperature_divider = 32,
};
static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = {
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support
2018-12-27 21:50 ` [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support Martin Blumenstingl
@ 2019-01-03 23:02 ` Rob Herring
2019-01-05 16:39 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2019-01-03 23:02 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: mark.rutland, devicetree, lars, linux-iio, linux-kernel,
balbes-150, robh+dt, linux-arm-kernel, pmeerw, linux-amlogic,
Martin Blumenstingl, jic23
On Thu, 27 Dec 2018 22:50:19 +0100, Martin Blumenstingl wrote:
> Meson8b and Meson8m2 use a 5-bit wide TSC (temperature sensor
> coefficient). The SAR ADC registers however can only store (the lower)
> 4 bits. The fifth (upper-most) bit is stored inside the
> MESON_HHI_DPLL_TOP_0[9] register from the HHI register area.
> This adds a syscon property to the HHI register area so a driver can
> fetch the HHI register map and store the fifth TSC bit in there.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> .../devicetree/bindings/iio/adc/amlogic,meson-saradc.txt | 4 ++++
> 1 file changed, 4 insertions(+)
>
Reviewed-by: Rob Herring <robh@kernel.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support
2019-01-03 23:02 ` Rob Herring
@ 2019-01-05 16:39 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2019-01-05 16:39 UTC (permalink / raw)
To: Rob Herring
Cc: mark.rutland, devicetree, lars, Martin Blumenstingl, balbes-150,
linux-kernel, linux-iio, robh+dt, pmeerw, linux-amlogic,
linux-arm-kernel
On Thu, 3 Jan 2019 17:02:09 -0600
Rob Herring <robh@kernel.org> wrote:
> On Thu, 27 Dec 2018 22:50:19 +0100, Martin Blumenstingl wrote:
> > Meson8b and Meson8m2 use a 5-bit wide TSC (temperature sensor
> > coefficient). The SAR ADC registers however can only store (the lower)
> > 4 bits. The fifth (upper-most) bit is stored inside the
> > MESON_HHI_DPLL_TOP_0[9] register from the HHI register area.
> > This adds a syscon property to the HHI register area so a driver can
> > fetch the HHI register map and store the fifth TSC bit in there.
> >
> > Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > ---
> > .../devicetree/bindings/iio/adc/amlogic,meson-saradc.txt | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
>
> Reviewed-by: Rob Herring <robh@kernel.org>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs
2018-12-27 21:50 ` [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs Martin Blumenstingl
@ 2019-01-05 16:41 ` Jonathan Cameron
2019-01-05 16:44 ` Jonathan Cameron
1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2019-01-05 16:41 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: mark.rutland, devicetree, lars, linux-iio, linux-kernel,
balbes-150, robh+dt, pmeerw, linux-amlogic, linux-arm-kernel
On Thu, 27 Dec 2018 22:50:20 +0100
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
> Meson8b and Meson8m2 use the same logic to convert the ADC register
> value to celsius, which is different from Meson8:
> - Meson8 has different multiplier and divider values
> - Meson8 uses a 4-bit TSC (temperature sensor coefficient) which fits
> into the 4-bit field in the MESON_SAR_ADC_DELTA_10 register:
> MESON_SAR_ADC_DELTA_10_TS_C_MASK. Meson8b and Meson8m2 have a 5-bit
> TSC which requires writing the upper-most bit into the
> MESON_HHI_DPLL_TOP_0[9] register from the HHI register area.
>
> This adds support for the temperature sensor on the Meson8b and Meson8m2
> SoCs by implementing the logic to write the upper-most TSC bit into the
> HHI register area. The SoC-specific values (temperature_trimming_bits,
> temperature_multiplier, temperature_divider) are added - these simply
> integrate into the existing infrastructure (which was implemented for
> Meson8) and thus require no further changes to the existing temperature
> calculation logic.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/adc/meson_saradc.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 729becb2d3d9..f8600fbcdfe3 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -26,6 +26,7 @@
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/mfd/syscon.h>
>
> #define MESON_SAR_ADC_REG0 0x00
> #define MESON_SAR_ADC_REG0_PANEL_DETECT BIT(31)
> @@ -174,6 +175,9 @@
> #define MESON_SAR_ADC_EFUSE_BYTE3_UPPER_ADC_VAL GENMASK(6, 0)
> #define MESON_SAR_ADC_EFUSE_BYTE3_IS_CALIBRATED BIT(7)
>
> +#define MESON_HHI_DPLL_TOP_0 0x318
> +#define MESON_HHI_DPLL_TOP_0_TSC_BIT4 BIT(9)
> +
> /* for use with IIO_VAL_INT_PLUS_MICRO */
> #define MILLION 1000000
>
> @@ -280,6 +284,7 @@ struct meson_sar_adc_priv {
> struct completion done;
> int calibbias;
> int calibscale;
> + struct regmap *tsc_regmap;
> bool temperature_sensor_calibrated;
> u8 temperature_sensor_coefficient;
> u16 temperature_sensor_adc_val;
> @@ -727,6 +732,15 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
> return ret;
> }
>
> + priv->tsc_regmap =
> + syscon_regmap_lookup_by_phandle(indio_dev->dev.parent->of_node,
> + "amlogic,hhi-sysctrl");
> + if (IS_ERR(priv->tsc_regmap)) {
> + dev_err(indio_dev->dev.parent,
> + "failed to get amlogic,hhi-sysctrl regmap\n");
> + return PTR_ERR(priv->tsc_regmap);
> + }
> +
> read_len = MESON_SAR_ADC_EFUSE_BYTES;
> buf = nvmem_cell_read(temperature_calib, &read_len);
> if (IS_ERR(buf)) {
> @@ -861,6 +875,22 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
> priv->temperature_sensor_coefficient);
> regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10,
> MESON_SAR_ADC_DELTA_10_TS_C_MASK, regval);
> +
> + if (priv->param->temperature_trimming_bits == 5) {
> + if (priv->temperature_sensor_coefficient & BIT(4))
> + regval = MESON_HHI_DPLL_TOP_0_TSC_BIT4;
> + else
> + regval = 0;
> +
> + /*
> + * bit [4] (the 5th bit when starting to count at 1)
> + * of the TSC is located in the HHI register area.
> + */
> + regmap_update_bits(priv->tsc_regmap,
> + MESON_HHI_DPLL_TOP_0,
> + MESON_HHI_DPLL_TOP_0_TSC_BIT4,
> + regval);
> + }
> } else {
> regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10,
> MESON_SAR_ADC_DELTA_10_TS_REVE1, 0);
> @@ -1064,6 +1094,9 @@ static const struct meson_sar_adc_param meson_sar_adc_meson8b_param = {
> .bandgap_reg = MESON_SAR_ADC_DELTA_10,
> .regmap_config = &meson_sar_adc_regmap_config_meson8,
> .resolution = 10,
> + .temperature_trimming_bits = 5,
> + .temperature_multiplier = 10,
> + .temperature_divider = 32,
> };
>
> static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = {
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs
2018-12-27 21:50 ` [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs Martin Blumenstingl
2019-01-05 16:41 ` Jonathan Cameron
@ 2019-01-05 16:44 ` Jonathan Cameron
1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2019-01-05 16:44 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: mark.rutland, devicetree, lars, linux-iio, linux-kernel,
balbes-150, robh+dt, pmeerw, linux-amlogic, linux-arm-kernel
On Thu, 27 Dec 2018 22:50:20 +0100
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
> Meson8b and Meson8m2 use the same logic to convert the ADC register
> value to celsius, which is different from Meson8:
> - Meson8 has different multiplier and divider values
> - Meson8 uses a 4-bit TSC (temperature sensor coefficient) which fits
> into the 4-bit field in the MESON_SAR_ADC_DELTA_10 register:
> MESON_SAR_ADC_DELTA_10_TS_C_MASK. Meson8b and Meson8m2 have a 5-bit
> TSC which requires writing the upper-most bit into the
> MESON_HHI_DPLL_TOP_0[9] register from the HHI register area.
>
> This adds support for the temperature sensor on the Meson8b and Meson8m2
> SoCs by implementing the logic to write the upper-most TSC bit into the
> HHI register area. The SoC-specific values (temperature_trimming_bits,
> temperature_multiplier, temperature_divider) are added - these simply
> integrate into the existing infrastructure (which was implemented for
> Meson8) and thus require no further changes to the existing temperature
> calculation logic.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/adc/meson_saradc.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 729becb2d3d9..f8600fbcdfe3 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -26,6 +26,7 @@
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/mfd/syscon.h>
>
> #define MESON_SAR_ADC_REG0 0x00
> #define MESON_SAR_ADC_REG0_PANEL_DETECT BIT(31)
> @@ -174,6 +175,9 @@
> #define MESON_SAR_ADC_EFUSE_BYTE3_UPPER_ADC_VAL GENMASK(6, 0)
> #define MESON_SAR_ADC_EFUSE_BYTE3_IS_CALIBRATED BIT(7)
>
> +#define MESON_HHI_DPLL_TOP_0 0x318
> +#define MESON_HHI_DPLL_TOP_0_TSC_BIT4 BIT(9)
> +
> /* for use with IIO_VAL_INT_PLUS_MICRO */
> #define MILLION 1000000
>
> @@ -280,6 +284,7 @@ struct meson_sar_adc_priv {
> struct completion done;
> int calibbias;
> int calibscale;
> + struct regmap *tsc_regmap;
> bool temperature_sensor_calibrated;
> u8 temperature_sensor_coefficient;
> u16 temperature_sensor_adc_val;
> @@ -727,6 +732,15 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
> return ret;
> }
>
> + priv->tsc_regmap =
> + syscon_regmap_lookup_by_phandle(indio_dev->dev.parent->of_node,
> + "amlogic,hhi-sysctrl");
> + if (IS_ERR(priv->tsc_regmap)) {
> + dev_err(indio_dev->dev.parent,
> + "failed to get amlogic,hhi-sysctrl regmap\n");
> + return PTR_ERR(priv->tsc_regmap);
> + }
> +
> read_len = MESON_SAR_ADC_EFUSE_BYTES;
> buf = nvmem_cell_read(temperature_calib, &read_len);
> if (IS_ERR(buf)) {
> @@ -861,6 +875,22 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
> priv->temperature_sensor_coefficient);
> regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10,
> MESON_SAR_ADC_DELTA_10_TS_C_MASK, regval);
> +
> + if (priv->param->temperature_trimming_bits == 5) {
> + if (priv->temperature_sensor_coefficient & BIT(4))
> + regval = MESON_HHI_DPLL_TOP_0_TSC_BIT4;
> + else
> + regval = 0;
> +
> + /*
> + * bit [4] (the 5th bit when starting to count at 1)
> + * of the TSC is located in the HHI register area.
> + */
> + regmap_update_bits(priv->tsc_regmap,
> + MESON_HHI_DPLL_TOP_0,
> + MESON_HHI_DPLL_TOP_0_TSC_BIT4,
> + regval);
> + }
> } else {
> regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10,
> MESON_SAR_ADC_DELTA_10_TS_REVE1, 0);
> @@ -1064,6 +1094,9 @@ static const struct meson_sar_adc_param meson_sar_adc_meson8b_param = {
> .bandgap_reg = MESON_SAR_ADC_DELTA_10,
> .regmap_config = &meson_sar_adc_regmap_config_meson8,
> .resolution = 10,
> + .temperature_trimming_bits = 5,
> + .temperature_multiplier = 10,
> + .temperature_divider = 32,
> };
>
> static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = {
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-01-05 16:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-27 21:50 [PATCH 0/2] meson-saradc: temperature sensor support for Meson8b/Meson8m2 Martin Blumenstingl
2018-12-27 21:50 ` [PATCH 1/2] dt-bindings: iio: adc: meson-saradc: update temperature sensor support Martin Blumenstingl
2019-01-03 23:02 ` Rob Herring
2019-01-05 16:39 ` Jonathan Cameron
2018-12-27 21:50 ` [PATCH 2/2] iio: adc: meson-saradc: enable the temperature sensor two more SoCs Martin Blumenstingl
2019-01-05 16:41 ` Jonathan Cameron
2019-01-05 16:44 ` Jonathan Cameron
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).