1 // SPDX-License-Identifier: GPL-2.0
3 * ScioSense ENS160 multi-gas sensor SPI driver
5 * Copyright (c) 2024 Gustavo Silva <gustavograzs@gmail.com>
8 #include <linux/module.h>
9 #include <linux/regmap.h>
10 #include <linux/spi/spi.h>
14 #define ENS160_SPI_READ BIT(0)
16 static const struct regmap_config ens160_regmap_spi_conf
= {
20 .read_flag_mask
= ENS160_SPI_READ
,
23 static int ens160_spi_probe(struct spi_device
*spi
)
25 struct regmap
*regmap
;
27 regmap
= devm_regmap_init_spi(spi
, &ens160_regmap_spi_conf
);
29 return dev_err_probe(&spi
->dev
, PTR_ERR(regmap
),
30 "Failed to register spi regmap\n");
32 return devm_ens160_core_probe(&spi
->dev
, regmap
, spi
->irq
, "ens160");
35 static const struct of_device_id ens160_spi_of_match
[] = {
36 { .compatible
= "sciosense,ens160" },
39 MODULE_DEVICE_TABLE(of
, ens160_spi_of_match
);
41 static const struct spi_device_id ens160_spi_id
[] = {
45 MODULE_DEVICE_TABLE(spi
, ens160_spi_id
);
47 static struct spi_driver ens160_spi_driver
= {
50 .of_match_table
= ens160_spi_of_match
,
51 .pm
= pm_sleep_ptr(&ens160_pm_ops
),
53 .probe
= ens160_spi_probe
,
54 .id_table
= ens160_spi_id
,
56 module_spi_driver(ens160_spi_driver
);
58 MODULE_AUTHOR("Gustavo Silva <gustavograzs@gmail.com>");
59 MODULE_DESCRIPTION("ScioSense ENS160 SPI driver");
60 MODULE_LICENSE("GPL v2");
61 MODULE_IMPORT_NS(IIO_ENS160
);