Skip to content

Commit c40655e

Browse files
nxpfrankligroeck
authored andcommitted
hwmon: (tmp108) Add support for I3C device
Add support for I3C device in the tmp108 driver to handle the P3T1085 sensor. Register the I3C device driver to enable I3C functionality for the sensor. Signed-off-by: Frank Li <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent 700f325 commit c40655e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

drivers/hwmon/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,7 @@ config SENSORS_TMP108
22982298
tristate "Texas Instruments TMP108"
22992299
depends on I2C
23002300
select REGMAP_I2C
2301+
select REGMAP_I3C if I3C
23012302
help
23022303
If you say yes here you get support for Texas Instruments TMP108
23032304
sensor chips and NXP P3T1085.

drivers/hwmon/tmp108.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/mutex.h>
1414
#include <linux/of.h>
1515
#include <linux/i2c.h>
16+
#include <linux/i3c/device.h>
1617
#include <linux/init.h>
1718
#include <linux/jiffies.h>
1819
#include <linux/regmap.h>
@@ -440,7 +441,39 @@ static struct i2c_driver tmp108_driver = {
440441
.id_table = tmp108_i2c_ids,
441442
};
442443

443-
module_i2c_driver(tmp108_driver);
444+
static const struct i3c_device_id p3t1085_i3c_ids[] = {
445+
I3C_DEVICE(0x011b, 0x1529, NULL),
446+
{}
447+
};
448+
MODULE_DEVICE_TABLE(i3c, p3t1085_i3c_ids);
449+
450+
static int p3t1085_i3c_probe(struct i3c_device *i3cdev)
451+
{
452+
struct device *dev = i3cdev_to_dev(i3cdev);
453+
struct regmap *regmap;
454+
455+
#ifdef CONFIG_REGMAP_I3C
456+
regmap = devm_regmap_init_i3c(i3cdev, &tmp108_regmap_config);
457+
#else
458+
regmap = ERR_PTR(-ENODEV);
459+
#endif
460+
461+
if (IS_ERR(regmap))
462+
return dev_err_probe(dev, PTR_ERR(regmap),
463+
"Failed to register i3c regmap\n");
464+
465+
return tmp108_common_probe(dev, regmap, "p3t1085_i3c");
466+
}
467+
468+
static struct i3c_driver p3t1085_driver = {
469+
.driver = {
470+
.name = "p3t1085_i3c",
471+
},
472+
.probe = p3t1085_i3c_probe,
473+
.id_table = p3t1085_i3c_ids,
474+
};
475+
476+
module_i3c_i2c_driver(p3t1085_driver, &tmp108_driver)
444477

445478
MODULE_AUTHOR("John Muir <[email protected]>");
446479
MODULE_DESCRIPTION("Texas Instruments TMP108 temperature sensor driver");

0 commit comments

Comments
 (0)