Commit e967b60e authored by Miquel Raynal's avatar Miquel Raynal Committed by Lee Jones

mfd: ti_am335x_tscadc: Clarify the maximum values for DT entries

Clearly define the maximum open delay and sample delay. Use these
definitions in place of a mask (which works because this is the first
field in the register) and an open-coded value. While at it reword a
little bit the error messages to make them look clearer and similar.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20211015081506.933180-29-miquel.raynal@bootlin.com
parent b7cb7bf1
...@@ -126,7 +126,7 @@ static void tiadc_step_config(struct iio_dev *indio_dev) ...@@ -126,7 +126,7 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
chan = adc_dev->channel_line[i]; chan = adc_dev->channel_line[i];
if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) { if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
dev_warn(dev, "chan %d step_avg truncating to %ld\n", dev_warn(dev, "chan %d: wrong step avg, truncated to %ld\n",
chan, STEPCONFIG_AVG_16); chan, STEPCONFIG_AVG_16);
adc_dev->step_avg[i] = STEPCONFIG_AVG_16; adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
} }
...@@ -147,16 +147,16 @@ static void tiadc_step_config(struct iio_dev *indio_dev) ...@@ -147,16 +147,16 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
STEPCONFIG_RFP_VREFP | STEPCONFIG_RFP_VREFP |
STEPCONFIG_RFM_VREFN); STEPCONFIG_RFM_VREFN);
if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) { if (adc_dev->open_delay[i] > STEPCONFIG_MAX_OPENDLY) {
dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n", dev_warn(dev, "chan %d: wrong open delay, truncated to 0x%lX\n",
chan); chan, STEPCONFIG_MAX_OPENDLY);
adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK; adc_dev->open_delay[i] = STEPCONFIG_MAX_OPENDLY;
} }
if (adc_dev->sample_delay[i] > 0xFF) { if (adc_dev->sample_delay[i] > STEPCONFIG_MAX_SAMPLE) {
dev_warn(dev, "chan %d sample delay truncating to 0xFF\n", dev_warn(dev, "chan %d: wrong sample delay, truncated to 0x%lX\n",
chan); chan, STEPCONFIG_MAX_SAMPLE);
adc_dev->sample_delay[i] = 0xFF; adc_dev->sample_delay[i] = STEPCONFIG_MAX_SAMPLE;
} }
tiadc_writel(adc_dev, REG_STEPDELAY(steps), tiadc_writel(adc_dev, REG_STEPDELAY(steps),
......
...@@ -84,7 +84,9 @@ ...@@ -84,7 +84,9 @@
#define STEPCONFIG_OPENDLY STEPDELAY_OPEN(0x098) #define STEPCONFIG_OPENDLY STEPDELAY_OPEN(0x098)
#define STEPDELAY_SAMPLE_MASK GENMASK(31, 24) #define STEPDELAY_SAMPLE_MASK GENMASK(31, 24)
#define STEPDELAY_SAMPLE(val) FIELD_PREP(STEPDELAY_SAMPLE_MASK, (val)) #define STEPDELAY_SAMPLE(val) FIELD_PREP(STEPDELAY_SAMPLE_MASK, (val))
#define STEPCONFIG_MAX_OPENDLY GENMASK(17, 0)
#define STEPCONFIG_SAMPLEDLY STEPDELAY_SAMPLE(0) #define STEPCONFIG_SAMPLEDLY STEPDELAY_SAMPLE(0)
#define STEPCONFIG_MAX_SAMPLE GENMASK(7, 0)
/* Charge Config */ /* Charge Config */
#define STEPCHARGE_RFP_MASK GENMASK(14, 12) #define STEPCHARGE_RFP_MASK GENMASK(14, 12)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment