@@ -610,18 +610,41 @@ static const struct iio_chan_spec ad7193_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(14),
};
+static void ad7192_parse_dt(struct device_node *np,
+ struct ad7192_platform_data *pdata)
+{
+ of_property_read_u16(np, "adi,reference-voltage-mv", &pdata->vref_mv);
+ of_property_read_u8(np, "adi,clock-source-select", &pdata->clock_source_sel);
+ of_property_read_u32(np, "adi,external-clock-Hz", &pdata->ext_clk_hz);
+ pdata->refin2_en = of_property_read_bool(np, "adi,refin2-pins-enable");
+ pdata->rej60_en = of_property_read_bool(np, "adi,rejection-60-Hz-enable");
+ pdata->sinc3_en = of_property_read_bool(np, "adi,sinc3-filter-enable");
+ pdata->chop_en = of_property_read_bool(np, "adi,chop-enable");
+ pdata->buf_en = of_property_read_bool(np, "adi,buffer-enable");
+ pdata->unipolar_en = of_property_read_bool(np, "adi,unipolar-enable");
+ pdata->burnout_curr_en = of_property_read_bool(np, "adi,burnout-currents-enable");
+}
+
static int ad7192_probe(struct spi_device *spi)
{
const struct ad7192_platform_data *pdata = dev_get_platdata(&spi->dev);
+ const struct device_node *of_node = dev_of_node(&spi->dev);
+ struct ad7192_platform_data lpdata;
struct ad7192_state *st;
struct iio_dev *indio_dev;
int ret, voltage_uv = 0;
- if (!pdata) {
- dev_err(&spi->dev, "no platform data?\n");
+ if (!pdata && !of_node) {
+ dev_err(&spi->dev, "no platform data or device tree configuration?\n");
return -ENODEV;
}
+ if (!pdata) {
+ memset(&lpdata, 0, sizeof(lpdata));
+ pdata = &lpdata;
+ ad7192_parse_dt(of_node, pdata);
weird how my compiler did not catch this const qualifier disregard....
though, this did work on an ARM64 [Raspberry Pi]
i guess i'll have to re-spin this as well