From: Jonathan Cameron <jic23@kernel.org>
To: Dixit Parmar <dixitparmar19@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 1/2] iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor
Date: Sat, 16 Aug 2025 14:04:48 +0100 [thread overview]
Message-ID: <20250816140448.37f38d0f@jic23-huawei> (raw)
In-Reply-To: <20250814-tlv493d-sensor-v6_16-rc5-v4-1-81b82805aae0@gmail.com>
On Thu, 14 Aug 2025 08:23:43 +0530
Dixit Parmar <dixitparmar19@gmail.com> wrote:
> The Infineon TLV493D is a Low-Power 3D Magnetic Sensor. The Sensor
> applications includes joysticks, control elements (white goods,
> multifunction knops), or electric meters (anti tampering) and any
> other application that requires accurate angular measurements at
> low power consumptions.
>
> The Sensor is configured over I2C, and as part of Sensor measurement
> data it provides 3-Axis magnetic fields and temperature core measurement.
>
> The driver supports raw value read and buffered input via external trigger
> to allow streaming values with the same sensing timestamp.
>
> While the sensor has an interrupt pin multiplexed with an I2C SCL pin.
> But for bus configurations interrupt(INT) is not recommended, unless timing
> constraints between I2C data transfers and interrupt pulses are monitored
> and aligned.
>
> The Sensor's I2C register map and mode information is described in product
> User Manual [1].
>
> Datasheet: https://www.infineon.com/assets/row/public/documents/24/49/infineon-tlv493d-a1b6-datasheet-en.pdf
> Link: https://www.mouser.com/pdfDocs/Infineon-TLV493D-A1B6_3DMagnetic-UserManual-v01_03-EN.pdf [1]
> Signed-off-by: Dixit Parmar <dixitparmar19@gmail.com>
Hi Dixit,
A couple of really minor things inline. Given Andy has been doing most of the review
work on this one I'll leave it for a few days to give him chance for a final look.
The stuff below is small so if nothing else comes up I can tweak it whilst applying
Thanks,
Jonathan
> diff --git a/drivers/iio/magnetometer/tlv493d.c b/drivers/iio/magnetometer/tlv493d.c
> new file mode 100644
> index 000000000000..ee72211576a6
> --- /dev/null
> +++ b/drivers/iio/magnetometer/tlv493d.c
> @@ -0,0 +1,530 @@
> + TLV493D_AXIS_X,
> + TLV493D_AXIS_Y,
> + TLV493D_AXIS_Z,
> + TLV493D_TEMPERATURE
As below.
> +};
> +
> +enum tlv493d_op_mode {
> + TLV493D_OP_MODE_POWERDOWN,
> + TLV493D_OP_MODE_FAST,
> + TLV493D_OP_MODE_LOWPOWER,
> + TLV493D_OP_MODE_ULTRA_LOWPOWER,
> + TLV493D_OP_MODE_MASTERCONTROLLED
This is not a terminating entry, so would typically have a trailing comma.
> +};
> +
> +static int tlv493d_init(struct tlv493d_data *data)
I think this is only called from probe, so it would be appropriate
to use return dev_err_probe() in all the error paths.
If nothing else comes up I might tweak that whilst applying.
> +{
> + int ret;
> + u8 buff[TLV493D_RD_REG_MAX];
> + struct device *dev = &data->client->dev;
> +
> + /*
> + * The sensor initialization requires below steps to be followed,
> + * 1. Power-up sensor.
> + * 2. Read and store read-registers map (0x0-0x9).
> + * 3. Copy values from read reserved registers to write reserved fields (0x0-0x3).
> + * 4. Set operating mode.
> + * 5. Write to all registers.
> + */
> + ret = i2c_master_recv(data->client, buff, ARRAY_SIZE(buff));
> + if (ret < 0) {
> + dev_err(dev, "i2c read failed, error %d\n", ret);
> + return ret;
> + }
> +
> + /* Write register 0x0 is reserved. Does not require to be updated.*/
> + data->wr_regs[0] = 0;
> + data->wr_regs[1] = buff[TLV493D_RD_REG_RES1] & TLV493D_RD_REG_RES1_WR_MASK;
> + data->wr_regs[2] = buff[TLV493D_RD_REG_RES2] & TLV493D_RD_REG_RES2_WR_MASK;
> + data->wr_regs[3] = buff[TLV493D_RD_REG_RES3] & TLV493D_RD_REG_RES3_WR_MASK;
> +
> + ret = tlv493d_set_operating_mode(data, data->mode);
> + if (ret < 0) {
> + dev_err(dev, "failed to set operating mode\n");
> + return ret;
> + }
> +
> + return 0;
> +}
next prev parent reply other threads:[~2025-08-16 13:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 2:53 [PATCH v4 0/2] iio: magnetometer: add support for Infineon TLV493D 3D Magnetic Sensor Dixit Parmar
2025-08-14 2:53 ` [PATCH v4 1/2] iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor Dixit Parmar
2025-08-16 13:04 ` Jonathan Cameron [this message]
2025-08-20 4:46 ` Dixit Parmar
2025-08-20 13:56 ` Andy Shevchenko
2025-08-20 14:08 ` Andy Shevchenko
2025-08-21 3:02 ` Dixit Parmar
2025-08-21 7:41 ` Andy Shevchenko
2025-08-22 2:40 ` Dixit Parmar
2025-08-22 6:11 ` Andy Shevchenko
2025-08-25 3:03 ` Dixit Parmar
2025-08-25 9:50 ` Jonathan Cameron
2025-08-26 2:52 ` Dixit Parmar
2025-08-26 3:02 ` Dixit Parmar
2025-08-30 14:53 ` Jonathan Cameron
2025-08-14 2:53 ` [PATCH v4 2/2] dt-bindings: iio: magnetometer: document Infineon TLV493D 3D Magnetic sensor Dixit Parmar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250816140448.37f38d0f@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dixitparmar19@gmail.com \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).