mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2025-03-02 20:05:55 +00:00
143 lines
4.8 KiB
Diff
143 lines
4.8 KiB
Diff
From e29ff40f91293fa328007a5619276acd9d3ed517 Mon Sep 17 00:00:00 2001
|
|
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
|
|
Date: Sat, 23 Mar 2024 20:30:02 +0100
|
|
Subject: [PATCH 20/58] FROMGIT(6.14): iio: adc: consistently use bool and enum
|
|
in struct meson_sar_adc_param
|
|
|
|
Consistently use bool for any register bit that enables/disables
|
|
functionality and enum for register values where there's a choice
|
|
between different settings. The aim is to make the code easier to read
|
|
and understand by being more consistent. No functional changes intended.
|
|
|
|
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
|
|
---
|
|
drivers/iio/adc/meson_saradc.c | 47 +++++++++++++++++++---------------
|
|
1 file changed, 27 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
|
|
index 4fe0688cb4d1..83849c2320e1 100644
|
|
--- a/drivers/iio/adc/meson_saradc.c
|
|
+++ b/drivers/iio/adc/meson_saradc.c
|
|
@@ -156,9 +156,9 @@
|
|
#define MESON_SAR_ADC_REG11 0x2c
|
|
#define MESON_SAR_ADC_REG11_BANDGAP_EN BIT(13)
|
|
#define MESON_SAR_ADC_REG11_CMV_SEL BIT(6)
|
|
- #define MESON_SAR_ADC_REG11_VREF_VOLTAGE BIT(5)
|
|
- #define MESON_SAR_ADC_REG11_EOC BIT(1)
|
|
- #define MESON_SAR_ADC_REG11_VREF_SEL BIT(0)
|
|
+ #define MESON_SAR_ADC_REG11_VREF_VOLTAGE BIT(5)
|
|
+ #define MESON_SAR_ADC_REG11_EOC BIT(1)
|
|
+ #define MESON_SAR_ADC_REG11_VREF_SEL BIT(0)
|
|
|
|
#define MESON_SAR_ADC_REG13 0x34
|
|
#define MESON_SAR_ADC_REG13_12BIT_CALIBRATION_MASK GENMASK(13, 8)
|
|
@@ -224,6 +224,11 @@ enum meson_sar_adc_vref_sel {
|
|
VREF_VDDA = 1,
|
|
};
|
|
|
|
+enum meson_sar_adc_vref_voltage {
|
|
+ VREF_VOLTAGE_0V9 = 0,
|
|
+ VREF_VOLTAGE_1V8 = 1,
|
|
+};
|
|
+
|
|
enum meson_sar_adc_avg_mode {
|
|
NO_AVERAGING = 0x0,
|
|
MEAN_AVERAGING = 0x1,
|
|
@@ -321,13 +326,13 @@ struct meson_sar_adc_param {
|
|
u8 temperature_trimming_bits;
|
|
unsigned int temperature_multiplier;
|
|
unsigned int temperature_divider;
|
|
- u8 disable_ring_counter;
|
|
+ bool disable_ring_counter;
|
|
bool has_reg11;
|
|
bool has_vref_select;
|
|
- u8 vref_select;
|
|
- u8 cmv_select;
|
|
- u8 adc_eoc;
|
|
- enum meson_sar_adc_vref_sel vref_voltage;
|
|
+ bool cmv_select;
|
|
+ bool adc_eoc;
|
|
+ enum meson_sar_adc_vref_sel vref_select;
|
|
+ enum meson_sar_adc_vref_voltage vref_voltage;
|
|
};
|
|
|
|
struct meson_sar_adc_data {
|
|
@@ -970,14 +975,16 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
|
|
MESON_SAR_ADC_DELTA_10_TS_REVE0);
|
|
}
|
|
|
|
- regval = FIELD_PREP(MESON_SAR_ADC_REG3_CTRL_CONT_RING_COUNTER_EN,
|
|
- priv->param->disable_ring_counter);
|
|
+ if (priv->param->disable_ring_counter)
|
|
+ regval = MESON_SAR_ADC_REG3_CTRL_CONT_RING_COUNTER_EN;
|
|
+ else
|
|
+ regval = 0;
|
|
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
|
|
MESON_SAR_ADC_REG3_CTRL_CONT_RING_COUNTER_EN,
|
|
regval);
|
|
|
|
if (priv->param->has_reg11) {
|
|
- regval = FIELD_PREP(MESON_SAR_ADC_REG11_EOC, priv->param->adc_eoc);
|
|
+ regval = priv->param->adc_eoc ? MESON_SAR_ADC_REG11_EOC : 0;
|
|
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
|
|
MESON_SAR_ADC_REG11_EOC, regval);
|
|
|
|
@@ -993,8 +1000,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
|
|
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
|
|
MESON_SAR_ADC_REG11_VREF_VOLTAGE, regval);
|
|
|
|
- regval = FIELD_PREP(MESON_SAR_ADC_REG11_CMV_SEL,
|
|
- priv->param->cmv_select);
|
|
+ regval = priv->param->cmv_select ? MESON_SAR_ADC_REG11_CMV_SEL : 0;
|
|
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
|
|
MESON_SAR_ADC_REG11_CMV_SEL, regval);
|
|
}
|
|
@@ -1212,8 +1218,8 @@ static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = {
|
|
.regmap_config = &meson_sar_adc_regmap_config_gxbb,
|
|
.resolution = 10,
|
|
.has_reg11 = true,
|
|
- .vref_voltage = 1,
|
|
- .cmv_select = 1,
|
|
+ .vref_voltage = VREF_VOLTAGE_1V8,
|
|
+ .cmv_select = true,
|
|
};
|
|
|
|
static const struct meson_sar_adc_param meson_sar_adc_gxl_param = {
|
|
@@ -1224,8 +1230,8 @@ static const struct meson_sar_adc_param meson_sar_adc_gxl_param = {
|
|
.resolution = 12,
|
|
.disable_ring_counter = 1,
|
|
.has_reg11 = true,
|
|
- .vref_voltage = 1,
|
|
- .cmv_select = 1,
|
|
+ .vref_voltage = VREF_VOLTAGE_1V8,
|
|
+ .cmv_select = true,
|
|
};
|
|
|
|
static const struct meson_sar_adc_param meson_sar_adc_axg_param = {
|
|
@@ -1236,10 +1242,10 @@ static const struct meson_sar_adc_param meson_sar_adc_axg_param = {
|
|
.resolution = 12,
|
|
.disable_ring_counter = 1,
|
|
.has_reg11 = true,
|
|
- .vref_voltage = 1,
|
|
+ .vref_voltage = VREF_VOLTAGE_1V8,
|
|
.has_vref_select = true,
|
|
.vref_select = VREF_VDDA,
|
|
- .cmv_select = 1,
|
|
+ .cmv_select = true,
|
|
};
|
|
|
|
static const struct meson_sar_adc_param meson_sar_adc_g12a_param = {
|
|
@@ -1250,7 +1256,8 @@ static const struct meson_sar_adc_param meson_sar_adc_g12a_param = {
|
|
.resolution = 12,
|
|
.disable_ring_counter = 1,
|
|
.has_reg11 = true,
|
|
- .adc_eoc = 1,
|
|
+ .vref_voltage = VREF_VOLTAGE_0V9,
|
|
+ .adc_eoc = true,
|
|
.has_vref_select = true,
|
|
.vref_select = VREF_VDDA,
|
|
};
|
|
--
|
|
2.34.1
|
|
|