From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796455295; b=Cn9pNeKUOie/tAUKZ4mrY70hFOr9XhP7KOqii3Aqe7t46XxVD16Xjm1Hbue4m+iFoG+I reRza2N2JDhaHAOPx1cwFOUv503E5Nj+hwuVb+JhwCeZ2aIjrhrypQIYG7PqsGoz6+QtZ xpd3sJLJzFvCbTiUYgvnU7HtN2vZ9I49hqkPFQH4R6uyXTNtH6fYsTD5Z7NleMiq5/fjO 7wpT6k0IoXF9EDnmCnsbyz6TA3zAyrL/8pVYs+617GVm9Av3KvddnJQV+R58PI2AQdOhZ 9mMDDTvAQrH/9W8ncgeD7e8CMET2yEpMEquqGteeKsfR76KmniEOtN+tq3mgq+jPs5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796455295; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=amF68ov2vJSRTjErR4o1pGVGjB3jf0CN6zb6niI1+KM=; b=PjU9O2f8U9OWqFEF76KZdKnsONPpp8n10btH1rcl39S6RoyOxxWjNJZ8pm9S8mQSU62H Bj99idWjC03MOgfj95E+OsjwMNWycohmnApSv5W44Hpv5xLE0ZaswouzAhMfxqce8jaFo oZUKn1+QeeImy+nNk1euurxKd4PqYw1yeoJAZzPzQ06uCJo8Z0yzAx9Z0vJL1knGBdbdL Fq8hdeZVHgZYiXQsySAhbNQJ+cQR4MQxyTwGLBUEI2DT/3WmcOadQUb6bwH2WGzfWaTeu AHrWiHIsKQYqeK5b4AD3pexXTJ4EyBjzaSuLhnMlg71oRZEZs0L1GnKDunIVopqAPwA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=usw70NyG; arc=none smtp.remote-ip=74.125.82.182 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40508606A32F for ; Sat, 5 Dec 2026 07:21:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 40508606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=usw70NyG Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-385d8a00598so2369294eec.1 for ; Fri, 04 Dec 2026 23:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796455294; x=1797060094; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=amF68ov2vJSRTjErR4o1pGVGjB3jf0CN6zb6niI1+KM=; b=usw70NyGMFEWRa1FTxvhxiq3eCYAHrEqOGH/xLn1U9zlbfo+e2L4nkxpu4eGQAdF9m vHKGT+3dcR/9XrhcOws3NlvOG334BSU3mPBeMK2JXi6qx5lYXqQh9+fvxrs7DMVM+eY2 cj66AJnWRO/XNxHSjRlAQAKwxJ+n9rWWxQ9nq06Xj8W7PzBiYui2X7Sa4V6/GOZORKct uTIux7f2AWjKJIXkuys6FOaqj2qc34xxx+FW+adJTN29vbPfXPw7xjiSXaR34yT5JAC0 Z0Y1rMEQ8rnNWJaory8X190oXXnFOWNpPdHnkEYKHYnb3DmoLuR/Wdmdl/RQian5UQ9n q4Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796455294; x=1797060094; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=amF68ov2vJSRTjErR4o1pGVGjB3jf0CN6zb6niI1+KM=; b=t2dcgh+EYguJQtnVOSalL6vdByJAoM+kAdEfAStrT2w6MSjpazKiNgfZBlhGWQtYRA 7l1mjYBFmOSS5vs+NUOFr+iKCdvgh7HtTbpqUq4lMyAYtcE6yE8fYAGQEdLybH3bb0Am 2fOkpv16Qx3W3MxJKz1xsDZbQDN6Ka1KYafPdBdM408OOLB4LgMocjB27PnW2cUSLpCN A8Dr2Ynw4OIOME+Q6SfkCAsu5oUsClSjBXnfKzJisj1RpBYrlDrONkWEo/iQflfvr5sq jNasDoDIzZG/DrUmJG0k7HbZWOSLM8vApi8MhNqHrTPoYNet7hNevyOAPkEl7Cq+PPsE XYuw== X-Forwarded-Encrypted: i=1; AL+hErHss4jPfWVnJOkXz02y7KozJm8e2rxzueJngPUuodYNduj82P0DeYvbPPHbqEXnuYZHAKpRzfkrswo=@vger.kernel.org X-Gm-Message-State: AB4q+uEel2GmGVJ9UMPpoMNjs/dv93mGmkOKLtPvYQNMcFtC2JkzkuOw gaIy4yu3MGS9EHLMU0lRCdFuaqH9MDOXQQx0SHx3jJiOPG45BhlBJ4e9zXAIC3IsKI4o8Q== X-Gm-Gg: AZFdTZfPBOqzruIGrvxGSvdldVhCHrSsGMzT2319GQor9N9hhxwfYR/hmUhIvZuJFhS 6smKW9YxBdXX3Ye4uVsGPXcBN7xKJDYyJUOafiPK0Hmy6Lvxofed/E0JTRFD9ksGf01mJ/XTI0d 8bTxTQUPyBNejCgG9WMPSKekxqm7Jincoa7qtdH3SZYvmxEL18273zi02NBdDKIlxzFqrimA8eT s7Q6mY+JQZfF6uD7Ot3CmhElZ6EvP0Uywy7/bRGS47sgXSEs0xcy0y2nz0jcamhLKnMhwha4fim XGFQCDk2GkIo1Zh81hBdGjmxCtJb2fh4jbcZUqc52JEG5wQ8exUlyAF+GgeOazNgQOa2+Xbzy4j yLEgod4CWDdd7fka7G4SWywThUKB1XVyUQeOvppONw01hXuFRW+hOx29cmLGGbFC/BJyEG4+J/a x38UqcAHf8mHiJrf7XYv51cuBbzCCj8If3F38zBnoM200kijwCFHHzeIGjJz24lB/Iqa/HXqSr8 ypdOMNN5ClT2bzQvTvrZ2Bksanh2Ioh2iHkFrmbWkPyamctIBmMVoUq46sO5bauUfyBfq//Ce2m pnTGosDqAWs3Pgl5TxCPf8AlF9sb1xrE X-Received: by 2002:a05:7301:f24:b0:386:b0ea:327d with SMTP id 5a478bee46e88-38751fc5337mr4359535eec.5.1796455294279; Fri, 04 Dec 2026 23:21:34 -0800 (PST) Received: from [127.0.1.1] ([2405:201:201e:8863:2c39:1352:d693:d1ad]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387522491dasm16150988eec.28.2026.12.04.23.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 23:21:33 -0800 (PST) From: Viral Patel Subject: [PATCH v3 0/2] iio: magnetometer: add Infineon TLE493D-W2B6 support Date: Sat, 05 Dec 2026 12:51:23 +0530 Message-Id: <20261205-tle493d-v3-0-19fc44f81339@gmail.com> X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAHO7E2sC/02Myw6CMBBFf4V0bU1nWh515X8YF9gO0ISHaUmjI fy7BRNleW7uOQsL5B0FdskW5im64KYxgTxlzHT12BJ3NjFDgQUIrPjck9LSclBGVg0+LJaSpff TU+Nee+l2T9y5ME/+vYcjbOu3ASL/NSJwwSWqgjRQIbW6tkPt+rOZBrY1Ih48hL+HydNoS8pLQ 6bSR29d1w+lBxp31gAAAA== To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dixit Parmar Cc: Victor Chernyakin , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Viral Patel X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796455288; l=8535; i=viral8854@gmail.com; s=20261014; h=from:subject:message-id; bh=W1R7HAsCoYxyfgP3IYeUY1+hpQ5UBMqkQYyoRvqNhxE=; b=7Q3l2TLcSwqBb61YuuhdA78xIClo3jK5dMqRTIK7ZaVGynIkPj4i2qt92QrxkyvZg7dpDaxbG uFE+HkQ1BUACeotQzwDSe2nH1soxykui7zrDjnpNOzfgrPa88q+yDEC X-Developer-Key: i=viral8854@gmail.com; a=ed25519; pk=UC+UDB53t70pTK4wncXf3tfh0hsYMCqpxYnTaKX3MYA= 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. W=1, sparse, checkpatch --strict and dt_binding_check are clean apart from the Datasheet: tag line-length/link warnings. The v3 changes were build-tested only, as the hardware was not available for this revision. They are review clean-ups; the parity helpers rewritten with parity8() were checked against the v2 versions on 2 million random inputs in userspace. The hardware results below are from v1 and v2, 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. 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 =============== My part: I wrote the hardware specification the driver is based on (register map, parity rules, I2C protocol, conversion constants and test vectors, from the User Manual). I did the bring-up and the v1 hardware testing on the Pi 5, including the device tree overlay and boot setup, analysed the power-loss behaviour, and checked the TLV493D datasheet to confirm the binding can be shared. I decided how to address each round of review, re-tested v2 myself and wrote the v3 driver commit message. I reviewed every patch and take responsibility for all of it. Claude (Anthropic), used through Claude Code, wrote the initial drafts of the driver, the binding and a userspace bring-up tool from my specification and the IIO style requirements I gave it. It also made the v2 and v3 code changes, analysed the v3 review comments, ran the v2 re-test on my setup and drafted parts of this cover letter. [1] https://lore.kernel.org/linux-iio/atyPf0msZ85z2m19@ashevche-desk.local/ Signed-off-by: Viral Patel --- Changes in v3: - dt-bindings: use a folded description and drop the A0-A3 address paragraph (Jonathan) - Move the MAINTAINERS entry to the driver patch, without the binding F: line (Jonathan) - Pick up Rob's Reviewed-by on the binding - Shorten the driver commit message (Jonathan) - Link the user manual with a second Datasheet: tag (Jonathan). Andy suggested Link:, I followed Jonathan's request for Datasheet: - tle493d_write(): fill buf[0] first, write buf[1] in the switch (Jonathan) - Comment on why only the four IICadr addresses work (Jonathan) - Use parity8() for FP, CP and the data parity check (Andy) - Declare loop counters in the for statements (Andy) - Add a helper for the Diag frame counter (Andy) - Sleep for the 175 us conversion time before polling, then poll every 50 us; timeout as (1 * USEC_PER_MSEC) (Andy) - Add tle493d_measure_locked() using guard(), used by read_raw() and the trigger handler instead of mutex_lock()/mutex_unlock() (Andy) - Write the scan mask with BIT()s (Andy) - Drop linux/bits.h (Andy) - Andy asked whether the temperature can be negative: over the -40 to 125 degC operating range the raw value is about 909 to 1597 (1180 at 25 degC, 0.24 K/LSB), so the top bit is never set - Andy asked whether tle493d_init() needs a rollback: it only configures sensor registers and vdd is released through devm, so there is nothing to undo on remove - Link to v2: https://lore.kernel.org/r/20261121-tle493d-v2-0-92d7e57cec89@gmail.com 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/20261105-tle493d-v1-0-3246e91e6394@gmail.com --- 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 | 11 +- MAINTAINERS | 6 + drivers/iio/magnetometer/Kconfig | 13 + drivers/iio/magnetometer/Makefile | 1 + drivers/iio/magnetometer/tle493d.c | 580 +++++++++++++++++++++ 5 files changed, 609 insertions(+), 2 deletions(-) --- base-commit: fba506008a5b548ad2708bc2765a039cb00a47ab change-id: 20261028-tle493d-14c38f2bd273 Best regards, -- Viral Patel