* [PATCH v6 1/6] iio: adc: meson: remove unused timestamp channel
2023-07-12 23:10 [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
@ 2023-07-12 23:10 ` George Stark
2023-07-12 23:10 ` [PATCH v6 2/6] iio: adc: meson: move enums declaration before variables declaration George Stark
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: George Stark @ 2023-07-12 23:10 UTC (permalink / raw)
To: jic23, lars, neil.armstrong, khilman, jbrunet,
martin.blumenstingl, andriy.shevchenko, nuno.sa, gnstark
Cc: linux-iio, linux-arm-kernel, linux-kernel, linux-amlogic, kernel,
George Stark
Remove IIO_CHAN_SOFT_TIMESTAMP channel because it's used only for
buffering mode which is not implemented.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
drivers/iio/adc/meson_saradc.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 18937a262af6..569ffc178935 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -211,7 +211,6 @@ static const struct iio_chan_spec meson_sar_adc_iio_channels[] = {
MESON_SAR_ADC_CHAN(5),
MESON_SAR_ADC_CHAN(6),
MESON_SAR_ADC_CHAN(7),
- IIO_CHAN_SOFT_TIMESTAMP(8),
};
static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = {
@@ -224,7 +223,6 @@ static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = {
MESON_SAR_ADC_CHAN(6),
MESON_SAR_ADC_CHAN(7),
MESON_SAR_ADC_TEMP_CHAN(8),
- IIO_CHAN_SOFT_TIMESTAMP(9),
};
enum meson_sar_adc_avg_mode {
--
2.38.4
_______________________________________________
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 v6 2/6] iio: adc: meson: move enums declaration before variables declaration
2023-07-12 23:10 [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
2023-07-12 23:10 ` [PATCH v6 1/6] iio: adc: meson: remove unused timestamp channel George Stark
@ 2023-07-12 23:10 ` George Stark
2023-07-12 23:10 ` [PATCH v6 3/6] iio: adc: meson: move meson_sar_adc_set_chan7_mux routine upper George Stark
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: George Stark @ 2023-07-12 23:10 UTC (permalink / raw)
To: jic23, lars, neil.armstrong, khilman, jbrunet,
martin.blumenstingl, andriy.shevchenko, nuno.sa, gnstark
Cc: linux-iio, linux-arm-kernel, linux-kernel, linux-amlogic, kernel,
George Stark
Allow to use enum items for variables initialization.
For this, move enums upper in the code.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
drivers/iio/adc/meson_saradc.c | 44 +++++++++++++++++-----------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 569ffc178935..98b6697a21f6 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -202,6 +202,28 @@
.datasheet_name = "TEMP_SENSOR", \
}
+enum meson_sar_adc_avg_mode {
+ NO_AVERAGING = 0x0,
+ MEAN_AVERAGING = 0x1,
+ MEDIAN_AVERAGING = 0x2,
+};
+
+enum meson_sar_adc_num_samples {
+ ONE_SAMPLE = 0x0,
+ TWO_SAMPLES = 0x1,
+ FOUR_SAMPLES = 0x2,
+ EIGHT_SAMPLES = 0x3,
+};
+
+enum meson_sar_adc_chan7_mux_sel {
+ CHAN7_MUX_VSS = 0x0,
+ CHAN7_MUX_VDD_DIV4 = 0x1,
+ CHAN7_MUX_VDD_DIV2 = 0x2,
+ CHAN7_MUX_VDD_MUL3_DIV4 = 0x3,
+ CHAN7_MUX_VDD = 0x4,
+ CHAN7_MUX_CH7_INPUT = 0x7,
+};
+
static const struct iio_chan_spec meson_sar_adc_iio_channels[] = {
MESON_SAR_ADC_CHAN(0),
MESON_SAR_ADC_CHAN(1),
@@ -225,28 +247,6 @@ static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = {
MESON_SAR_ADC_TEMP_CHAN(8),
};
-enum meson_sar_adc_avg_mode {
- NO_AVERAGING = 0x0,
- MEAN_AVERAGING = 0x1,
- MEDIAN_AVERAGING = 0x2,
-};
-
-enum meson_sar_adc_num_samples {
- ONE_SAMPLE = 0x0,
- TWO_SAMPLES = 0x1,
- FOUR_SAMPLES = 0x2,
- EIGHT_SAMPLES = 0x3,
-};
-
-enum meson_sar_adc_chan7_mux_sel {
- CHAN7_MUX_VSS = 0x0,
- CHAN7_MUX_VDD_DIV4 = 0x1,
- CHAN7_MUX_VDD_DIV2 = 0x2,
- CHAN7_MUX_VDD_MUL3_DIV4 = 0x3,
- CHAN7_MUX_VDD = 0x4,
- CHAN7_MUX_CH7_INPUT = 0x7,
-};
-
struct meson_sar_adc_param {
bool has_bl30_integration;
unsigned long clock_rate;
--
2.38.4
_______________________________________________
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 v6 3/6] iio: adc: meson: move meson_sar_adc_set_chan7_mux routine upper
2023-07-12 23:10 [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
2023-07-12 23:10 ` [PATCH v6 1/6] iio: adc: meson: remove unused timestamp channel George Stark
2023-07-12 23:10 ` [PATCH v6 2/6] iio: adc: meson: move enums declaration before variables declaration George Stark
@ 2023-07-12 23:10 ` George Stark
2023-07-12 23:10 ` [PATCH v6 4/6] iio: adc: meson: add enum for iio channel numbers George Stark
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: George Stark @ 2023-07-12 23:10 UTC (permalink / raw)
To: jic23, lars, neil.armstrong, khilman, jbrunet,
martin.blumenstingl, andriy.shevchenko, nuno.sa, gnstark
Cc: linux-iio, linux-arm-kernel, linux-kernel, linux-amlogic, kernel,
George Stark
meson_sar_adc_set_chan7_mux is a basic func() for writing single register,
defined as static. Moved it up so it could be used in more places.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
drivers/iio/adc/meson_saradc.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 98b6697a21f6..44ac6ce5e3aa 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -336,6 +336,19 @@ static int meson_sar_adc_wait_busy_clear(struct iio_dev *indio_dev)
1, 10000);
}
+static void meson_sar_adc_set_chan7_mux(struct iio_dev *indio_dev,
+ enum meson_sar_adc_chan7_mux_sel sel)
+{
+ struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
+ u32 regval;
+
+ regval = FIELD_PREP(MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, sel);
+ regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
+ MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, regval);
+
+ usleep_range(10, 20);
+}
+
static int meson_sar_adc_read_raw_sample(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
int *val)
@@ -432,19 +445,6 @@ static void meson_sar_adc_enable_channel(struct iio_dev *indio_dev,
}
}
-static void meson_sar_adc_set_chan7_mux(struct iio_dev *indio_dev,
- enum meson_sar_adc_chan7_mux_sel sel)
-{
- struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
- u32 regval;
-
- regval = FIELD_PREP(MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, sel);
- regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
- MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, regval);
-
- usleep_range(10, 20);
-}
-
static void meson_sar_adc_start_sample_engine(struct iio_dev *indio_dev)
{
struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
--
2.38.4
_______________________________________________
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 v6 4/6] iio: adc: meson: add enum for iio channel numbers
2023-07-12 23:10 [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
` (2 preceding siblings ...)
2023-07-12 23:10 ` [PATCH v6 3/6] iio: adc: meson: move meson_sar_adc_set_chan7_mux routine upper George Stark
@ 2023-07-12 23:10 ` George Stark
2023-07-12 23:10 ` [PATCH v6 5/6] iio: adc: meson: add channel labels George Stark
2023-07-13 12:12 ` [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs Andy Shevchenko
5 siblings, 0 replies; 7+ messages in thread
From: George Stark @ 2023-07-12 23:10 UTC (permalink / raw)
To: jic23, lars, neil.armstrong, khilman, jbrunet,
martin.blumenstingl, andriy.shevchenko, nuno.sa, gnstark
Cc: linux-iio, linux-arm-kernel, linux-kernel, linux-amlogic, kernel,
George Stark
Channels could be referenced in the driver code and using enum allows
to make it more robust.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
drivers/iio/adc/meson_saradc.c | 46 +++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 44ac6ce5e3aa..b14c66656bcc 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -224,27 +224,39 @@ enum meson_sar_adc_chan7_mux_sel {
CHAN7_MUX_CH7_INPUT = 0x7,
};
+enum meson_sar_adc_channel_index {
+ NUM_CHAN_0,
+ NUM_CHAN_1,
+ NUM_CHAN_2,
+ NUM_CHAN_3,
+ NUM_CHAN_4,
+ NUM_CHAN_5,
+ NUM_CHAN_6,
+ NUM_CHAN_7,
+ NUM_CHAN_TEMP,
+};
+
static const struct iio_chan_spec meson_sar_adc_iio_channels[] = {
- MESON_SAR_ADC_CHAN(0),
- MESON_SAR_ADC_CHAN(1),
- MESON_SAR_ADC_CHAN(2),
- MESON_SAR_ADC_CHAN(3),
- MESON_SAR_ADC_CHAN(4),
- MESON_SAR_ADC_CHAN(5),
- MESON_SAR_ADC_CHAN(6),
- MESON_SAR_ADC_CHAN(7),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_0),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_1),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_2),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_3),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_4),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_5),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_6),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_7),
};
static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = {
- MESON_SAR_ADC_CHAN(0),
- MESON_SAR_ADC_CHAN(1),
- MESON_SAR_ADC_CHAN(2),
- MESON_SAR_ADC_CHAN(3),
- MESON_SAR_ADC_CHAN(4),
- MESON_SAR_ADC_CHAN(5),
- MESON_SAR_ADC_CHAN(6),
- MESON_SAR_ADC_CHAN(7),
- MESON_SAR_ADC_TEMP_CHAN(8),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_0),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_1),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_2),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_3),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_4),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_5),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_6),
+ MESON_SAR_ADC_CHAN(NUM_CHAN_7),
+ MESON_SAR_ADC_TEMP_CHAN(NUM_CHAN_TEMP),
};
struct meson_sar_adc_param {
--
2.38.4
_______________________________________________
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 v6 5/6] iio: adc: meson: add channel labels
2023-07-12 23:10 [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
` (3 preceding siblings ...)
2023-07-12 23:10 ` [PATCH v6 4/6] iio: adc: meson: add enum for iio channel numbers George Stark
@ 2023-07-12 23:10 ` George Stark
2023-07-13 12:12 ` [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs Andy Shevchenko
5 siblings, 0 replies; 7+ messages in thread
From: George Stark @ 2023-07-12 23:10 UTC (permalink / raw)
To: jic23, lars, neil.armstrong, khilman, jbrunet,
martin.blumenstingl, andriy.shevchenko, nuno.sa, gnstark
Cc: linux-iio, linux-arm-kernel, linux-kernel, linux-amlogic, kernel,
George Stark
Add channel labels to provide human-readable names for the inputs.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
drivers/iio/adc/meson_saradc.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index b14c66656bcc..918bd5da3605 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -1055,8 +1055,20 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev)
return ret;
}
+static int read_label(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ char *label)
+{
+ if (chan->type == IIO_TEMP)
+ return sprintf(label, "temp-sensor\n");
+ if (chan->type == IIO_VOLTAGE)
+ return sprintf(label, "channel-%d\n", chan->channel);
+ return 0;
+}
+
static const struct iio_info meson_sar_adc_iio_info = {
.read_raw = meson_sar_adc_iio_info_read_raw,
+ .read_label = read_label,
};
static const struct meson_sar_adc_param meson_sar_adc_meson8_param = {
--
2.38.4
_______________________________________________
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 v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs
2023-07-12 23:10 [PATCH v6 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
` (4 preceding siblings ...)
2023-07-12 23:10 ` [PATCH v6 5/6] iio: adc: meson: add channel labels George Stark
@ 2023-07-13 12:12 ` Andy Shevchenko
5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-07-13 12:12 UTC (permalink / raw)
To: George Stark
Cc: jic23, lars, neil.armstrong, khilman, jbrunet,
martin.blumenstingl, nuno.sa, linux-iio, linux-arm-kernel,
linux-kernel, linux-amlogic, kernel
On Thu, Jul 13, 2023 at 02:10:41AM +0300, George Stark wrote:
> v5->v6:
We haven't settled down the things in v5, hence NAK to v6, sorry.
You have to pay respect to people who invested time in your work.
I hope you are going to answer to my questions and depending on
that we may see v7 in a better shape.
--
With Best Regards,
Andy Shevchenko
_______________________________________________
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