Thread (21 messages) 21 messages, 4 authors, 2025-02-01

Re: [PATCH v3 07/10] iio: adc: adi-axi-adc: add support for AD7606 register writing

From: Jonathan Cameron <jic23@kernel.org>
Date: 2025-02-01 13:07:53
Also in: linux-devicetree, linux-iio, lkml

quoted hunk ↗ jump to hunk
+static int ad7606_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val)
+{
+	struct adi_axi_adc_state *st = iio_backend_get_priv(back);
+	u32 buf;
+
+	guard(mutex)(&st->lock);
+
+	/*
+	 * The address is written on the highest weight byte, and the MSB set
+	 * at 1 indicates a read operation.
+	 */
+	buf = FIELD_PREP(ADI_AXI_REG_ADDRESS_MASK, reg) | ADI_AXI_REG_READ_BIT;
+	axi_adc_raw_write(back, &buf, sizeof(buf));
+	axi_adc_raw_read(back, val, 4);
sizeof(*val)
quoted hunk ↗ jump to hunk
+
+	/* Write 0x0 on the bus to get back to ADC mode */
+	buf = 0;
+	axi_adc_raw_write(back, &buf, sizeof(buf));
+	return 0;
+}
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help