[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aIg_ohWU7QICMbMy@dixit>
Date: Tue, 29 Jul 2025 08:57:30 +0530
From: Dixit Parmar <dixitparmar19@...il.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH 1/2] iio: magnetometer: add support for Infineon TLV493D
3D Magentic sensor
On Sun, Jul 27, 2025 at 01:38:52PM +0100, Jonathan Cameron wrote:
> On Sat, 26 Jul 2025 15:44:03 -0500
> David Lechner <dlechner@...libre.com> wrote:
>
> > On 7/26/25 4:37 AM, Dixit Parmar 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.
> > >
> > > The device can be configured in to different operating modes by optional
> > > device-tree "mode" property. Also, the temperature sensing part requires
> > > raw offset captured at 25°C and that can be specified by "temp-offset"
> > > optional device-tree property.
> > >
> > > While sensor has interrupt pin multiplexed with 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
> > > [1] https://www.mouser.com/pdfDocs/Infineon-TLV493D-A1B6_3DMagnetic-UserManual-v01_03-EN.pdf
> > >
> > > Signed-off-by: Dixit Parmar <dixitparmar19@...il.com>
>
> > > +static const struct regmap_config tlv493d_regmap_config = {
> > > + .reg_bits = 8,
> > > + .val_bits = 8,
> > > + .max_register = TLV493D_RD_REG_RES3,
> > > + .volatile_table = &tlv493d_volatile_regs,
> > > +};
> > > +
> > > +static int tlv493d_probe(struct i2c_client *client)
> > > +{
> > > + struct device *dev = &client->dev;
> > > + struct iio_dev *indio_dev;
> > > + struct tlv493d_data *data;
> > > + int ret;
> > > +
> > > + indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> > > + if (!indio_dev)
> > > + return -ENOMEM;
> > > +
> > > + data = iio_priv(indio_dev);
> > > + data->dev = dev;
> > > + data->client = client;
> > > + i2c_set_clientdata(client, indio_dev);
> >
> > There is not i2c_get_clientdata(), so I don't think we need this.
> There's a dev_get_drvdata() that pairs with this in suspend and resume.
>
> I kind of wish the bus specific accessor would go away but there
> is too much history behind them :(
>
Thank you for the confirmation. Will keep it.
> > > +static int tlv493d_runtime_suspend(struct device *dev)
> > > +{
> > > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > > + struct tlv493d_data *data = iio_priv(indio_dev);
> > > +
> > > + return tlv493d_set_operating_mode(data, TLV493D_OP_MODE_POWERDOWN);
> > > +}
> > > +
> > > +static int tlv493d_runtime_resume(struct device *dev)
> > > +{
> > > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > > + struct tlv493d_data *data = iio_priv(indio_dev);
> > > +
> > > + return tlv493d_set_operating_mode(data, data->mode);
> > > +}
> > > +
> > > +static DEFINE_RUNTIME_DEV_PM_OPS(tlv493d_pm_ops,
> > > + tlv493d_runtime_suspend, tlv493d_runtime_resume, NULL);
> > > +
> > > +static const struct i2c_device_id tlv493d_id[] = {
> > > + { "tlv493d" },
> > > + { }
> > > +};
> > > +MODULE_DEVICE_TABLE(i2c, tlv493d_id);
> > > +
> > > +static const struct of_device_id tlv493d_of_match[] = {
> > > + { .compatible = "infineon,tlv493d-a1b6", },
> > > + { }
> > > +};
> > > +MODULE_DEVICE_TABLE(of, tlv493d_of_match);
> > > +
> > > +static struct i2c_driver tlv493d_driver = {
> > > + .driver = {
> > > + .name = "tlv493d",
> > > + .of_match_table = tlv493d_of_match,
> > > + .pm = pm_ptr(&tlv493d_pm_ops),
> > > + },
> > > + .probe = tlv493d_probe,
> > > + .id_table = tlv493d_id,
> > > +};
> > > +
> > > +module_i2c_driver(tlv493d_driver);
> > > +
> > > +MODULE_LICENSE("GPL");
> > > +MODULE_DESCRIPTION("Infineon TLV493D Low-Power 3D Magnetic Sensor");
> > > +MODULE_AUTHOR("Dixit Parmar <dixitparmar19@...il.com>");
> > >
> >
>
Powered by blists - more mailing lists