0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/kernel.h>
0011 #include <linux/module.h>
0012 #include <linux/mod_devicetable.h>
0013 #include <linux/spi/spi.h>
0014 #include <linux/slab.h>
0015 #include <linux/regmap.h>
0016
0017 #include "st_uvis25.h"
0018
0019 #define UVIS25_SENSORS_SPI_READ BIT(7)
0020 #define UVIS25_SPI_AUTO_INCREMENT BIT(6)
0021
0022 static const struct regmap_config st_uvis25_spi_regmap_config = {
0023 .reg_bits = 8,
0024 .val_bits = 8,
0025 .read_flag_mask = UVIS25_SENSORS_SPI_READ | UVIS25_SPI_AUTO_INCREMENT,
0026 .write_flag_mask = UVIS25_SPI_AUTO_INCREMENT,
0027 };
0028
0029 static int st_uvis25_spi_probe(struct spi_device *spi)
0030 {
0031 struct regmap *regmap;
0032
0033 regmap = devm_regmap_init_spi(spi, &st_uvis25_spi_regmap_config);
0034 if (IS_ERR(regmap)) {
0035 dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
0036 PTR_ERR(regmap));
0037 return PTR_ERR(regmap);
0038 }
0039
0040 return st_uvis25_probe(&spi->dev, spi->irq, regmap);
0041 }
0042
0043 static const struct of_device_id st_uvis25_spi_of_match[] = {
0044 { .compatible = "st,uvis25", },
0045 {},
0046 };
0047 MODULE_DEVICE_TABLE(of, st_uvis25_spi_of_match);
0048
0049 static const struct spi_device_id st_uvis25_spi_id_table[] = {
0050 { ST_UVIS25_DEV_NAME },
0051 {},
0052 };
0053 MODULE_DEVICE_TABLE(spi, st_uvis25_spi_id_table);
0054
0055 static struct spi_driver st_uvis25_driver = {
0056 .driver = {
0057 .name = "st_uvis25_spi",
0058 .pm = &st_uvis25_pm_ops,
0059 .of_match_table = st_uvis25_spi_of_match,
0060 },
0061 .probe = st_uvis25_spi_probe,
0062 .id_table = st_uvis25_spi_id_table,
0063 };
0064 module_spi_driver(st_uvis25_driver);
0065
0066 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>");
0067 MODULE_DESCRIPTION("STMicroelectronics uvis25 spi driver");
0068 MODULE_LICENSE("GPL v2");
0069 MODULE_IMPORT_NS(IIO_UVIS25);