Skip to contentSkip to conversation

iio: magnetometer: add Infineon TLE493D-W2B6 support

PATCH In review Viral Patel 2 participants 5 messages Nov 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover iio: magnetometer: add Infineon TLE493D-W2B6 support

This series adds support for the Infineon TLE493D-W2B6, a 3D Hall-effect sensor with an I2C interface, 12-bit X/Y/Z data and an integrated temperature sensor. It was tested with the TLE493D-W2B6 Shield2Go board (variant A0, I2C address 0x35) on a Raspberry Pi 5.

Why a new driver
================
The TLE493D-W2B6 is a second-generation sibling of the TLV493D-A1B6 (drivers/iio/magnetometer/tlv493d.c). Only the X/Y/Z bit packing is shared; everything else differs, so this adds a new driver rather than extending tlv493d.c, as agreed with Andy in the RFC [1]:

- Writes: the byte after the I2C address is a register address that also carries ADC trigger bits; tlv493d writes a raw stream starting at write register 0.
- Reads after reset: the sensor starts in a 2-byte read protocol that Linux cannot drive, so the first access must be a write that sets the PR bit to switch to plain reads starting at 0x00.
- Register map: a single unified map, 0x00-0x16.
- Mandatory odd parity bits (FP, CP). A wrong FP makes the sensor release the bus until it is reset, so FP is recomputed on every mode register write.
- Data validity: a Diag register (PD0/PD3, frame counter, bus parity) instead of the channel bits tlv493d polls in register 3.
- Temperature: 10-bit, with a different encoding and scale/offset.
- Different power modes and update rates, and a selectable short range (X2); the A1B6 has a single range.
- A dedicated I2C reset sequence.

The other Hall-effect drivers in drivers/iio/magnetometer (tmag5273, als31300, si7210) were also checked; none share the register map, the write format or the parity scheme.

Scope
=====
The driver supports master-controlled single-shot measurements of X/Y/Z and temperature at full range, via sysfs and a triggered buffer with a soft timestamp.

The temperature has 10 bits of resolution. It is reported as the 12-bit aligned register value, so in_temp_raw moves in steps of 4 and the scale and offset follow the datasheet's 12-bit LSB.

Not supported yet (possible follow-ups): wake-up thresholds, the built-in self-tests, low-power and fast modes, sampling-frequency control, and the short range.

Testing
=======
The series is based on iio.git togreg and build-tested there. Hardware testing was done on a Raspberry Pi 5 running the downstream rpi-6.18.y kernel (6.18.59). For v1 both patches were applied there unchanged apart from a Makefile context fix-up; for v2 the driver from this series was built as a module against that kernel and re-tested.

- Probe: the module autoloads from the DT compatible and the Version and ID registers match the A0 variant. With the sensor disconnected, probe fails cleanly with -EREMOTEIO (v1).
- Reset: the Pi's DesignWare adapter advertises I2C_FUNC_SMBUS_QUICK. An i2c/smbus trace of probe shows two Quick reads from 0x7f and two Quick writes to 0x00, each NACKed as expected, followed by the MOD1 write to 0x35.
- Raw reads via sysfs: with no magnet nearby, X/Y/Z read within +/-3 LSB of zero; temperature reads about 30-33 degC at room temperature, matching a userspace bring-up tool.
- Triggered buffer with an hrtimer trigger at 10, 100 and 500 Hz: no missed samples (20/20, 200/200 and 1000/1000 over 2 s). In v1 the mean period at 100 and 500 Hz was 10.000 ms and 2.000 ms with at most 3 us jitter.
- sysfs reads from four processes in parallel, and sysfs reads while streaming, work.
- 10 rmmod/modprobe cycles and unbind/bind: no errors.
- W=1, sparse, checkpatch --strict and dt_binding_check are clean apart from the Datasheet: tag line-length/link warnings.

Known limitation
================
After a sensor power-on reset while the driver is bound, reads return -ETIMEDOUT until the driver is rebound. The reset clears PR, so the sensor is back in its 2-byte read protocol, plain reads return 0xff, the frame counter never changes and the driver times out waiting for a new frame. Recovery is planned as a follow-up.

Use of AI tools
===============
Claude (Anthropic), used through Claude Code, assisted with this series. I gave it a specification of the hardware (register map, parity rules, I2C protocol, conversion constants and test vectors) based on the User Manual, together with the v1 scope and IIO style requirements. From that it produced the initial drafts of the driver, the binding and a userspace bring-up tool, and it reviewed my later changes. I did the hardware bring-up and the v1 testing on the Pi 5, including the device tree overlay and boot setup, analysed the power-loss behaviour, and fixed up and reviewed every patch.

For v2 I went through the review with Jonathan and Victor and decided how to address each point, including checking the TLV493D datasheet to confirm that its /INT also shares the SCL pin, which is what allows the binding to be merged. Claude then made the code changes and ran the re-test above on my Pi 5 setup. I reviewed every change and the results, and re-tested v2 on the Pi 5 myself: probe, and the triggered buffer at 100 Hz (200/200 samples, 10.000 ms period). I take responsibility for all of it.

[1] https://lore.kernel.org/linux-iio/[email protected]/

---
Changes in v2:
- Rebased onto current togreg
- dt-bindings: add the compatible to infineon,tlv493d-a1b6.yaml instead of a new file. interrupts is allowed as for the TLV493D, since both parts have /INT on SCL and Infineon recommends wiring it up (Jonathan)
- Use FIELD_GET() for the single-bit Diag flags (Jonathan)
- Comment on why Diag is cached before the error checks (Jonathan)
- Use guard() in read_raw() and mutex_lock()/mutex_unlock() in the trigger handler (Jonathan)
- Send the reset as SMBus Quick commands and skip it if the adapter lacks I2C_FUNC_SMBUS_QUICK (Jonathan)
- Declare the reset loop counter in the for statement (Jonathan)
- Comment on IICadr and on the 7-bit vs 8-bit addresses (Jonathan, Victor)
- Link the user manual in the driver commit message (Victor)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Viral Patel (2):
dt-bindings: iio: magnetometer: infineon,tlv493d-a1b6: add TLE493D-W2B6
iio: magnetometer: add Infineon TLE493D-W2B6 driver

 .../iio/magnetometer/infineon,tlv493d-a1b6.yaml    |  14 +-
 MAINTAINERS                                        |   7 +
 drivers/iio/magnetometer/Kconfig                   |  13 +
 drivers/iio/magnetometer/Makefile                  |   1 +
 drivers/iio/magnetometer/tle493d.c                 | 572 +++++++++++++++++++++
 5 files changed, 605 insertions(+), 2 deletions(-)

---
base-commit: 903941a9b06ae445c70646ab061b604c2dea17d3
change-id: 20261028-tle493d-14c38f2bd273

Best regards,

Signature · 1 line
Viral Patel <[email protected]>
#1 lore raw

PATCH v2 1/2 dt-bindings: iio: magnetometer: infineon,tlv493d-a1b6: add TLE493D-W2B6

Add the Infineon TLE493D-W2B6, a 3D Hall effect magnetic sensor with 12-bit resolution per axis and an integrated temperature sensor, accessed over I2C. It is a second-generation sibling of the TLV493D-A1B6 with a different register interface, so it gets its own compatible, but it has the same supply range and the same /INT output sharing the SCL pin, so it fits the existing binding.

The A0 to A3 variants of the part only differ in their default I2C address, so a single compatible covers all of them.

---
 .../bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml   | 14 ++++++++++++--
 MAINTAINERS                                                |  6 ++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml +12 -2
index dd23a9370a71..3f0058cbf538 100644
@@ -4,17 +4,27 @@
 $id: http://devicetree.org/schemas/iio/magnetometer/infineon,tlv493d-a1b6.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Infineon Technologies TLV493D Low-Power 3D Magnetic Sensor
+title: Infineon Technologies TLV493D and TLE493D 3D Magnetic Sensors
 
 maintainers:
   - Dixit Parmar <[email protected]>
+  - Viral Patel <[email protected]>
+
+description: |
+  3D Hall effect magnetic sensors with an I2C interface. The /INT output
+  shares a pin with SCL.
+
+  The A0 to A3 variants of the TLE493D-W2B6 only differ in their default
+  I2C address (0x35, 0x22, 0x78 and 0x44).
 
 properties:
   $nodename:
     pattern: '^magnetometer@[0-9a-f]+$'
 
   compatible:
-    const: infineon,tlv493d-a1b6
+    enum:
+      - infineon,tle493d-w2b6
+      - infineon,tlv493d-a1b6
 
   reg:
     maxItems: 1
MAINTAINERS +6 -0
index 02015eaec312..c3004f683e78 100644
@@ -13117,6 +13117,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/sound/infineon,peb2466.yaml
 F:	sound/soc/codecs/peb2466.c
 
+INFINEON TLE493D-W2B6 DRIVER
+M:	Viral Patel <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml
+
 INFINEON TLV493D Driver
 M:	Dixit Parmar <[email protected]>
 L:	[email protected]
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: iio: magnetometer: infineon,tlv493d-a1b6: add TLE493D-W2B6

Quoted 11 lines · On Sat, 21 Nov 2026 11:25:10 +0530 Viral Patel <[email protected]> wrote:

Add the Infineon TLE493D-W2B6, a 3D Hall effect magnetic sensor with 12-bit resolution per axis and an integrated temperature sensor, accessed over I2C. It is a second-generation sibling of the TLV493D-A1B6 with a different register interface, so it gets its own compatible, but it has the same supply range and the same /INT output sharing the SCL pin, so it fits the existing binding.

The A0 to A3 variants of the part only differ in their default I2C address, so a single compatible covers all of them.

Hi Viral

A few comments inline. Nothing to stop me merging this if nothing else comes up though!

Jonathan

Quoted 11 lines
---
 .../bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml   | 14 ++++++++++++--
 MAINTAINERS                                                |  6 ++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml +0 -0
index dd23a9370a71..3f0058cbf538 100644
@@ -4,17 +4,27 @@
 $id: http://devicetree.org/schemas/iio/magnetometer/infineon,tlv493d-a1b6.yaml#

Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml +4 -1
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Infineon Technologies TLV493D Low-Power 3D Magnetic Sensor
+title: Infineon Technologies TLV493D and TLE493D 3D Magnetic Sensors
 
 maintainers:
   - Dixit Parmar <[email protected]>
+  - Viral Patel <[email protected]>
+
+description: |

Don't need to retain line wraps so IIRC > rather than | is appropriate.

Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml line 18

Quoted 5 lines
Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml +5 -0
+  3D Hall effect magnetic sensors with an I2C interface. The /INT output
+  shares a pin with SCL.
+
+  The A0 to A3 variants of the TLE493D-W2B6 only differ in their default
+  I2C address (0x35, 0x22, 0x78 and 0x44).

For a binding I'm not sure we need this level of detail. Perhaps just keep the first sentence. I don't mind either way on this one.

Quoted 18 lines
Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml +3 -1
 properties:
   $nodename:
     pattern: '^magnetometer@[0-9a-f]+$'
 
   compatible:
-    const: infineon,tlv493d-a1b6
+    enum:
+      - infineon,tle493d-w2b6
+      - infineon,tlv493d-a1b6
 
   reg:
     maxItems: 1
MAINTAINERS +0 -0
index 02015eaec312..c3004f683e78 100644

MAINTAINERS S: Maintained · line 13124

Quoted 8 lines
MAINTAINERS +5 -0
@@ -13117,6 +13117,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/sound/infineon,peb2466.yaml
 F:	sound/soc/codecs/peb2466.c
 
+INFINEON TLE493D-W2B6 DRIVER
+M:	Viral Patel <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml

I guess this is fine for most scripts, but I wonder if anything will drip up over a file being listed in two maintainers entries. I wouldn't necessarily worry about adding the binding to here as you have that line in the actual file anyway to point people to include you on changes etc.

Quoted 5 lines
MAINTAINERS +1 -0
+
 INFINEON TLV493D Driver
 M:	Dixit Parmar <[email protected]>
 L:	[email protected]
#3 lore raw

PATCH v2 2/2 iio: magnetometer: add Infineon TLE493D-W2B6 driver

In reply to Viral Patel

Add a driver for the Infineon TLE493D-W2B6, a 3D Hall effect magnetic sensor with 12-bit resolution per axis and an integrated temperature sensor, accessed over I2C.

The sensor is run in master-controlled mode. Each measurement rewrites the Config register with the "trigger after write" bits set in the register address byte, which starts a single conversion, and then polls registers 0x00 to 0x06 until Diag reports a completed conversion with a new frame counter. Results with a fuse parity error, test mode flag or bad bus parity are rejected. FP and CP are recomputed on every write of MOD1 and Config, as a wrong FP makes the sensor release the bus until it is reset.

The /INT output shares a pin with SCL, so the interrupt is disabled and so is clock stretching. The sensor's reset sequence is four SMBus Quick commands, so it is sent during probe only if the adapter supports I2C_FUNC_SMBUS_QUICK.

Raw I2C transfers are used rather than regmap: once PR is set a plain read always starts at register 0x00, and the register address byte of a write carries trigger bits.

The X, Y and Z channels and the temperature channel are available through sysfs and through a triggered buffer with a software timestamp. Wake-up, self-test, low-power and fast modes, sampling frequency control and the short range are not supported yet.

This is not added to the tlv493d driver: apart from the X/Y/Z bit packing, the two parts differ in write format, read protocol after reset, register map and parity scheme.

Based on the TLE493D-W2B6 User Manual v1.11 and Datasheet v1.2. The user manual is provided by Infineon after a free registration:
https://www.infineon.com/gated/infineon-tle493d-w2b6-usermanual-en_dc6d4e62-cde1-4d4b-87bb-c3368e25e35c

Datasheet: https://www.infineon.com/assets/row/public/documents/30/49/infineon-tle493d-w2b6-datasheet-en.pdf

---
 MAINTAINERS                        |   1 +
 drivers/iio/magnetometer/Kconfig   |  13 +
 drivers/iio/magnetometer/Makefile  |   1 +
 drivers/iio/magnetometer/tle493d.c | 572 +++++++++++++++++++++++++++++++++++++
 4 files changed, 587 insertions(+)
MAINTAINERS +1 -0
index c3004f683e78..043988d9175a 100644
@@ -13122,6 +13122,7 @@ M:	Viral Patel <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/magnetometer/infineon,tlv493d-a1b6.yaml
+F:	drivers/iio/magnetometer/tle493d.c
 
 INFINEON TLV493D Driver
 M:	Dixit Parmar <[email protected]>
drivers/iio/magnetometer/Kconfig +13 -0
index d359003b248e..bc26fc4d78e2 100644
@@ -196,6 +196,19 @@ config IIO_ST_MAGN_SPI_3AXIS
 	  To compile this driver as a module, choose M here. The module
 	  will be called st_magn_spi.
 
+config INFINEON_TLE493D
+	tristate "Infineon TLE493D-W2B6 3D Magnetic Sensor"
+	depends on I2C
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
+	help
+	  Say Y here to add support for the Infineon TLE493D-W2B6 3D
+	  magnetic sensor.
+
+	  This driver can also be compiled as a module.
+	  To compile this driver as a module, choose M here: the module
+	  will be called tle493d.
+
 config INFINEON_TLV493D
 	tristate "Infineon TLV493D Low-Power 3D Magnetic Sensor"
 	depends on I2C
drivers/iio/magnetometer/Makefile +1 -0
index 8f2205975c1b..31df6a49459c 100644
@@ -25,6 +25,7 @@ st_magn-$(CONFIG_IIO_BUFFER) += st_magn_buffer.o
 obj-$(CONFIG_IIO_ST_MAGN_I2C_3AXIS) += st_magn_i2c.o
 obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.o
 
+obj-$(CONFIG_INFINEON_TLE493D)		+= tle493d.o
 obj-$(CONFIG_INFINEON_TLV493D)		+= tlv493d.o
 
 obj-$(CONFIG_QMC5883L)			+= qmc5883l.o
drivers/iio/magnetometer/tle493d.c new file +572 -0

572 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#4 lore raw

Re: [PATCH v2 2/2] iio: magnetometer: add Infineon TLE493D-W2B6 driver

Quoted 3 lines · On Sat, 21 Nov 2026 11:25:11 +0530 Viral Patel <[email protected]> wrote:

Add a driver for the Infineon TLE493D-W2B6, a 3D Hall effect magnetic sensor with 12-bit resolution per axis and an integrated temperature sensor, accessed over I2C.

This either suffers from copying LLM generated commit messages or is pretty much what the LLM came up with. They are way way too verbose as they generate something that hides the important details largely defeating the point of a commit message. I'm only interested in a couple of lines of 'what' followed by any 'why' stuff for less obvious decisions. A starting point of telling the LLM it is being to verbose and to keep to these aspects tends to help, but then it needs the human to edit even that for the bits that actually matter!

Quoted 9 lines

The sensor is run in master-controlled mode. Each measurement rewrites the Config register with the "trigger after write" bits set in the register address byte, which starts a single conversion, and then polls registers 0x00 to 0x06 until Diag reports a completed conversion with a new frame counter. Results with a fuse parity error, test mode flag or bad bus parity are rejected. FP and CP are recomputed on every write of MOD1 and Config, as a wrong FP makes the sensor release the bus until it is reset.

This is too much detail for a commit message. I'd just keep the first sentence about master-controlled mode. The rest should be clear from the code and if it isn't comments belong down there, not in a commit message no one normally sees.

Quoted 5 lines

The /INT output shares a pin with SCL, so the interrupt is disabled and so is clock stretching. The sensor's reset sequence is four SMBus Quick commands, so it is sent during probe only if the adapter supports I2C_FUNC_SMBUS_QUICK.

First sentence of this good. Second one see the code, no need to say.

Quoted 9 lines

Raw I2C transfers are used rather than regmap: once PR is set a plain read always starts at register 0x00, and the register address byte of a write carries trigger bits.

The X, Y and Z channels and the temperature channel are available through sysfs and through a triggered buffer with a software timestamp. Wake-up, self-test, low-power and fast modes, sampling frequency control and the short range are not supported yet.

Don't care about what you didn't support for a commit message. What you do support can be summarised as something like.

Both sysfs and triggered buffer capture of channels is supported.

Quoted 4 lines

This is not added to the tlv493d driver: apart from the X/Y/Z bit packing, the two parts differ in write format, read protocol after reset, register map and parity scheme.

That is cover letter detail. Not useful in here unless it was really borderline so discussion likely.

Quoted 4 lines

Based on the TLE493D-W2B6 User Manual v1.11 and Datasheet v1.2. The user manual is provided by Infineon after a free registration:
https://www.infineon.com/gated/infineon-tle493d-w2b6-usermanual-en_dc6d4e62-cde1-4d4b-87bb-c3368e25e35c

Add this manual as a second datasheet tag and drop that paragraph.

Quoted 3 lines

Datasheet: https://www.infineon.com/assets/row/public/documents/30/49/infineon-tle493d-w2b6-datasheet-en.pdf

A lot of the comments below are more things that I thought about asking for and then why I didn't! :)

I want to give others time to comment anyway so wouldn't have picked it up today, but if it wasn't for the commit message I might just have considere picking it up later in the week (possibly tweaking a few trivial things whilst applying).

Thanks,

Jonathan

drivers/iio/magnetometer/tle493d.c line 96

Quoted 11 lines
drivers/iio/magnetometer/tle493d.c new file +4 -0
new file mode 100644
index 000000000000..62b7e7ea7ec0
 
 
+#define TLE493D_RESET_DELAY_US	30
+/* A full range conversion takes about 175 us */
+#define TLE493D_POLL_US		100
+#define TLE493D_TIMEOUT_US	1000

That's a generous margin. I suppose it's still only a millisec so who cares!

drivers/iio/magnetometer/tle493d.c line 189

Quoted 13 lines
drivers/iio/magnetometer/tle493d.c new file +13 -0
+/*
+ * Write one register, updating its parity bit first. Only MOD1 and Config
+ * are written by this driver. The sensor drops off the bus until reset if
+ * MOD1 is written with a wrong FP.
+ */
+static int tle493d_write(struct tle493d_data *data, u8 reg, u8 val, u8 trig)
+{
+	u8 buf[2];
+	int ret;
+
+	switch (reg) {
+	case TLE493D_REG_MOD1:
+		val = tle493d_mod1_fp(val, data->regs[TLE493D_REG_MOD2]);

Why reuse val? I'd just write buf[1] directly here then no need to do so below.

drivers/iio/magnetometer/tle493d.c line 199

Quoted 10 lines
drivers/iio/magnetometer/tle493d.c new file +10 -0
+		break;
+	case TLE493D_REG_CONFIG:
+		val = tle493d_config_cp(data->regs, val);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	buf[0] = FIELD_PREP(TLE493D_ADDR_TRIG, trig) |
+		 FIELD_PREP(TLE493D_ADDR_REG, reg);

Given I'm suggesting writing buf[1] in the switch, maybe move this line ahead of that as seems weird to set buf[1] before buf[0].

Quoted 15 lines
drivers/iio/magnetometer/tle493d.c new file +13 -0
+	buf[1] = val;
+
+	ret = i2c_master_send(data->client, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(buf))
+		return -EIO;
+
+	data->regs[reg] = val;
+
+	return 0;
+}
 
 
+static irqreturn_t tle493d_trigger_handler(int irq, void *p)

drivers/iio/magnetometer/tle493d.c

Quoted 10 lines
drivers/iio/magnetometer/tle493d.c new file +10 -0
+{
+	struct iio_poll_func *pf = p;
+	struct iio_dev *indio_dev = pf->indio_dev;
+	struct tle493d_data *data = iio_priv(indio_dev);
+	u8 buf[TLE493D_DATA_LEN];
+	struct {
+		s16 magn[3];
+		u16 temp;
+		aligned_s64 timestamp;
+	} scan = { };

I messed around with a named structure type here then designated initialiser below but it ends up messier, so this is good. Just left a comment here for any other reviewers who wonder the same!

Quoted 30 lines
drivers/iio/magnetometer/tle493d.c new file +27 -0
+	int ret;
+
+	mutex_lock(&data->lock);
+	ret = tle493d_measure(data, buf);
+	mutex_unlock(&data->lock);
+	if (ret)
+		goto out;
+
+	scan.magn[0] = tle493d_get_channel_data(buf, TLE493D_AXIS_X);
+	scan.magn[1] = tle493d_get_channel_data(buf, TLE493D_AXIS_Y);
+	scan.magn[2] = tle493d_get_channel_data(buf, TLE493D_AXIS_Z);
+	scan.temp = tle493d_get_channel_data(buf, TLE493D_TEMPERATURE);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), pf->timestamp);
+
+out:
+	iio_trigger_notify_done(indio_dev->trig);
+
+	return IRQ_HANDLED;
+}
 
 
 
+static int Andreas Kemnade <[email protected]>(struct tle493d_data *data, unsigned int iicadr)
+{
+	struct device *dev = &data->client->dev;
+	unsigned int hwv, id;
+	u8 mod1;
+	int ret;
+
+	/*

drivers/iio/magnetometer/tle493d.c line 460

Quoted 10 lines
drivers/iio/magnetometer/tle493d.c new file +10 -0
+	 * After reset the sensor uses a 2-byte read protocol which plain I2C
+	 * reads cannot handle, so MOD1 has to be written before any read. MOD2
+	 * is not known yet and FP is computed with its reset value, PRD = 0.
+	 * Clock stretching and the interrupt are disabled because /INT shares
+	 * the SCL pin.
+	 *
+	 * Every MOD1 write also sets IICadr, which selects the address the
+	 * sensor responds on, so it must match the address the device is
+	 * already on or the sensor moves to another address.
+	 */

See below for where I'm requesting a cross reference to this comment. I wrote a nice paragraph asking for basically this text before scrolling up and seeing it here :)

Quoted 10 lines
drivers/iio/magnetometer/tle493d.c new file +10 -0
+
+static int tle493d_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct tle493d_data *data;
+	struct iio_dev *indio_dev;
+	unsigned int iicadr;
+	int ret;
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))

drivers/iio/magnetometer/tle493d.c line 509

Quoted 10 lines
drivers/iio/magnetometer/tle493d.c new file +10 -0
+		return dev_err_probe(dev, -EOPNOTSUPP, "plain I2C transfers not supported\n");
+
+	/* MOD1 writes need the IICadr value matching the current address */
+	for (iicadr = 0; iicadr < ARRAY_SIZE(tle493d_i2c_addrs); iicadr++) {
+		if (client->addr == tle493d_i2c_addrs[iicadr])
+			break;
+	}
+	if (iicadr == ARRAY_SIZE(tle493d_i2c_addrs))
+		return dev_err_probe(dev, -EINVAL, "unsupported I2C address 0x%02x\n",
+				     client->addr);

Add a reference here back to the more detailed comment above. /* Unable to support other addresses, see tl2493d_init() */

Otherwise this smells to much like an over restrictive limitation on devices to ones we know about. In this particular case it is a fundamental constraint!

Quoted 6 lines
drivers/iio/magnetometer/tle493d.c new file +4 -0
+
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;