Skip to content

Commit 3e4a7af

Browse files
committed
Merge tag 'iio-fixes-for-6.6b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus
Jonathan writes: 2nd set of IIO fixes for the 6.6 cycle. Note, given timing my expectation is these will be queued for the 6.7 merge window but they could go quicker if the 6.6 cycle ends up being extended. afe: * Allow for channels with offset but no scale. In this case the scale can be assumed to be 1. adi,ad74115: * Add missing dt-binding constraint on number of reset-gpios. samsung,exynos: * Don't request touchscreen interrupt if it is not going to be used, getting rid of an incorrect resulting warning message. xilinx,xadc: * Avoid changing preset voltage and themperature thresholds as they are typicaly set as part of FPGA image building so should be left alone. * Fix wrong temperature offset and scale for some devices. * tag 'iio-fixes-for-6.6b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: afe: rescale: Accept only offset channels iio: exynos-adc: request second interupt only when touchscreen mode is used iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds dt-bindings: iio: add missing reset-gpios constrain
2 parents a3fad2e + bee4483 commit 3e4a7af

File tree

8 files changed

+53
-43
lines changed

8 files changed

+53
-43
lines changed

Documentation/devicetree/bindings/iio/addac/adi,ad74115.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ properties:
3232

3333
spi-cpol: true
3434

35-
reset-gpios: true
35+
reset-gpios:
36+
maxItems: 1
3637

3738
interrupts:
3839
minItems: 1

Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ properties:
7878
- const: -1000
7979
- const: 22000
8080

81-
reset-gpios: true
81+
reset-gpios:
82+
maxItems: 1
8283

8384
adi,dc-dc-ilim-microamp:
8485
enum: [150000, 200000, 250000, 300000, 350000, 400000]

Documentation/devicetree/bindings/iio/health/ti,afe4403.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ properties:
2323
maxItems: 1
2424
description: Connected to ADC_RDY pin.
2525

26-
reset-gpios: true
26+
reset-gpios:
27+
maxItems: 1
2728

2829
required:
2930
- compatible

Documentation/devicetree/bindings/iio/health/ti,afe4404.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ properties:
2323
maxItems: 1
2424
description: Connected to ADC_RDY pin.
2525

26-
reset-gpios: true
26+
reset-gpios:
27+
maxItems: 1
2728

2829
additionalProperties: false
2930

drivers/iio/adc/exynos_adc.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -826,16 +826,26 @@ static int exynos_adc_probe(struct platform_device *pdev)
826826
}
827827
}
828828

829+
/* leave out any TS related code if unreachable */
830+
if (IS_REACHABLE(CONFIG_INPUT)) {
831+
has_ts = of_property_read_bool(pdev->dev.of_node,
832+
"has-touchscreen") || pdata;
833+
}
834+
829835
irq = platform_get_irq(pdev, 0);
830836
if (irq < 0)
831837
return irq;
832838
info->irq = irq;
833839

834-
irq = platform_get_irq(pdev, 1);
835-
if (irq == -EPROBE_DEFER)
836-
return irq;
840+
if (has_ts) {
841+
irq = platform_get_irq(pdev, 1);
842+
if (irq == -EPROBE_DEFER)
843+
return irq;
837844

838-
info->tsirq = irq;
845+
info->tsirq = irq;
846+
} else {
847+
info->tsirq = -1;
848+
}
839849

840850
info->dev = &pdev->dev;
841851

@@ -900,12 +910,6 @@ static int exynos_adc_probe(struct platform_device *pdev)
900910
if (info->data->init_hw)
901911
info->data->init_hw(info);
902912

903-
/* leave out any TS related code if unreachable */
904-
if (IS_REACHABLE(CONFIG_INPUT)) {
905-
has_ts = of_property_read_bool(pdev->dev.of_node,
906-
"has-touchscreen") || pdata;
907-
}
908-
909913
if (pdata)
910914
info->delay = pdata->delay;
911915
else

drivers/iio/adc/xilinx-xadc-core.c

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ static const struct xadc_ops xadc_zynq_ops = {
456456
.interrupt_handler = xadc_zynq_interrupt_handler,
457457
.update_alarm = xadc_zynq_update_alarm,
458458
.type = XADC_TYPE_S7,
459+
/* Temp in C = (val * 503.975) / 2**bits - 273.15 */
460+
.temp_scale = 503975,
461+
.temp_offset = 273150,
459462
};
460463

461464
static const unsigned int xadc_axi_reg_offsets[] = {
@@ -566,6 +569,9 @@ static const struct xadc_ops xadc_7s_axi_ops = {
566569
.interrupt_handler = xadc_axi_interrupt_handler,
567570
.flags = XADC_FLAGS_BUFFERED | XADC_FLAGS_IRQ_OPTIONAL,
568571
.type = XADC_TYPE_S7,
572+
/* Temp in C = (val * 503.975) / 2**bits - 273.15 */
573+
.temp_scale = 503975,
574+
.temp_offset = 273150,
569575
};
570576

571577
static const struct xadc_ops xadc_us_axi_ops = {
@@ -577,6 +583,12 @@ static const struct xadc_ops xadc_us_axi_ops = {
577583
.interrupt_handler = xadc_axi_interrupt_handler,
578584
.flags = XADC_FLAGS_BUFFERED | XADC_FLAGS_IRQ_OPTIONAL,
579585
.type = XADC_TYPE_US,
586+
/**
587+
* Values below are for UltraScale+ (SYSMONE4) using internal reference.
588+
* See https://docs.xilinx.com/v/u/en-US/ug580-ultrascale-sysmon
589+
*/
590+
.temp_scale = 509314,
591+
.temp_offset = 280231,
580592
};
581593

582594
static int _xadc_update_adc_reg(struct xadc *xadc, unsigned int reg,
@@ -945,16 +957,15 @@ static int xadc_read_raw(struct iio_dev *indio_dev,
945957
*val2 = bits;
946958
return IIO_VAL_FRACTIONAL_LOG2;
947959
case IIO_TEMP:
948-
/* Temp in C = (val * 503.975) / 2**bits - 273.15 */
949-
*val = 503975;
960+
*val = xadc->ops->temp_scale;
950961
*val2 = bits;
951962
return IIO_VAL_FRACTIONAL_LOG2;
952963
default:
953964
return -EINVAL;
954965
}
955966
case IIO_CHAN_INFO_OFFSET:
956967
/* Only the temperature channel has an offset */
957-
*val = -((273150 << bits) / 503975);
968+
*val = -((xadc->ops->temp_offset << bits) / xadc->ops->temp_scale);
958969
return IIO_VAL_INT;
959970
case IIO_CHAN_INFO_SAMP_FREQ:
960971
ret = xadc_read_samplerate(xadc);
@@ -1423,28 +1434,6 @@ static int xadc_probe(struct platform_device *pdev)
14231434
if (ret)
14241435
return ret;
14251436

1426-
/* Disable all alarms */
1427-
ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK,
1428-
XADC_CONF1_ALARM_MASK);
1429-
if (ret)
1430-
return ret;
1431-
1432-
/* Set thresholds to min/max */
1433-
for (i = 0; i < 16; i++) {
1434-
/*
1435-
* Set max voltage threshold and both temperature thresholds to
1436-
* 0xffff, min voltage threshold to 0.
1437-
*/
1438-
if (i % 8 < 4 || i == 7)
1439-
xadc->threshold[i] = 0xffff;
1440-
else
1441-
xadc->threshold[i] = 0;
1442-
ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i),
1443-
xadc->threshold[i]);
1444-
if (ret)
1445-
return ret;
1446-
}
1447-
14481437
/* Go to non-buffered mode */
14491438
xadc_postdisable(indio_dev);
14501439

drivers/iio/adc/xilinx-xadc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct xadc_ops {
8585

8686
unsigned int flags;
8787
enum xadc_type type;
88+
int temp_scale;
89+
int temp_offset;
8890
};
8991

9092
static inline int _xadc_read_adc_reg(struct xadc *xadc, unsigned int reg,

drivers/iio/afe/iio-rescale.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,18 @@ static int rescale_read_raw(struct iio_dev *indio_dev,
214214
return ret < 0 ? ret : -EOPNOTSUPP;
215215
}
216216

217-
ret = iio_read_channel_scale(rescale->source, &scale, &scale2);
218-
return rescale_process_offset(rescale, ret, scale, scale2,
217+
if (iio_channel_has_info(rescale->source->channel,
218+
IIO_CHAN_INFO_SCALE)) {
219+
ret = iio_read_channel_scale(rescale->source, &scale, &scale2);
220+
return rescale_process_offset(rescale, ret, scale, scale2,
221+
schan_off, val, val2);
222+
}
223+
224+
/*
225+
* If we get here we have no scale so scale 1:1 but apply
226+
* rescaler and offset, if any.
227+
*/
228+
return rescale_process_offset(rescale, IIO_VAL_FRACTIONAL, 1, 1,
219229
schan_off, val, val2);
220230
default:
221231
return -EINVAL;
@@ -280,8 +290,9 @@ static int rescale_configure_channel(struct device *dev,
280290
chan->type = rescale->cfg->type;
281291

282292
if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) &&
283-
iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) {
284-
dev_info(dev, "using raw+scale source channel\n");
293+
(iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE) ||
294+
iio_channel_has_info(schan, IIO_CHAN_INFO_OFFSET))) {
295+
dev_info(dev, "using raw+scale/offset source channel\n");
285296
} else if (iio_channel_has_info(schan, IIO_CHAN_INFO_PROCESSED)) {
286297
dev_info(dev, "using processed channel\n");
287298
rescale->chan_processed = true;

0 commit comments

Comments
 (0)