1 // SPDX-License-Identifier: GPL-2.0
3 * ScioSense ENS160 multi-gas sensor I2C driver
5 * Copyright (c) 2024 Gustavo Silva <gustavograzs@gmail.com>
7 * 7-Bit I2C slave address is:
8 * - 0x52 if ADDR pin LOW
9 * - 0x53 if ADDR pin HIGH
12 #include <linux/i2c.h>
13 #include <linux/module.h>
14 #include <linux/regmap.h>
18 static const struct regmap_config ens160_regmap_i2c_conf
= {
23 static int ens160_i2c_probe(struct i2c_client
*client
)
25 struct regmap
*regmap
;
27 regmap
= devm_regmap_init_i2c(client
, &ens160_regmap_i2c_conf
);
29 return dev_err_probe(&client
->dev
, PTR_ERR(regmap
),
30 "Failed to register i2c regmap\n");
32 return devm_ens160_core_probe(&client
->dev
, regmap
, client
->irq
,
36 static const struct i2c_device_id ens160_i2c_id
[] = {
40 MODULE_DEVICE_TABLE(i2c
, ens160_i2c_id
);
42 static const struct of_device_id ens160_of_i2c_match
[] = {
43 { .compatible
= "sciosense,ens160" },
46 MODULE_DEVICE_TABLE(of
, ens160_of_i2c_match
);
48 static struct i2c_driver ens160_i2c_driver
= {
51 .of_match_table
= ens160_of_i2c_match
,
52 .pm
= pm_sleep_ptr(&ens160_pm_ops
),
54 .probe
= ens160_i2c_probe
,
55 .id_table
= ens160_i2c_id
,
57 module_i2c_driver(ens160_i2c_driver
);
59 MODULE_AUTHOR("Gustavo Silva <gustavograzs@gmail.com>");
60 MODULE_DESCRIPTION("ScioSense ENS160 I2C driver");
61 MODULE_LICENSE("GPL v2");
62 MODULE_IMPORT_NS(IIO_ENS160
);