0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/module.h>
0009 #include <linux/mod_devicetable.h>
0010 #include <linux/regmap.h>
0011 #include <linux/spi/spi.h>
0012
0013 #include "adxl355.h"
0014
0015 static const struct regmap_config adxl355_spi_regmap_config = {
0016 .reg_bits = 7,
0017 .pad_bits = 1,
0018 .val_bits = 8,
0019 .read_flag_mask = BIT(0),
0020 .max_register = 0x2F,
0021 .rd_table = &adxl355_readable_regs_tbl,
0022 .wr_table = &adxl355_writeable_regs_tbl,
0023 };
0024
0025 static int adxl355_spi_probe(struct spi_device *spi)
0026 {
0027 const struct spi_device_id *id = spi_get_device_id(spi);
0028 struct regmap *regmap;
0029
0030 regmap = devm_regmap_init_spi(spi, &adxl355_spi_regmap_config);
0031 if (IS_ERR(regmap)) {
0032 dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
0033 PTR_ERR(regmap));
0034
0035 return PTR_ERR(regmap);
0036 }
0037
0038 return adxl355_core_probe(&spi->dev, regmap, id->name);
0039 }
0040
0041 static const struct spi_device_id adxl355_spi_id[] = {
0042 { "adxl355", 0 },
0043 { }
0044 };
0045 MODULE_DEVICE_TABLE(spi, adxl355_spi_id);
0046
0047 static const struct of_device_id adxl355_of_match[] = {
0048 { .compatible = "adi,adxl355" },
0049 { }
0050 };
0051 MODULE_DEVICE_TABLE(of, adxl355_of_match);
0052
0053 static struct spi_driver adxl355_spi_driver = {
0054 .driver = {
0055 .name = "adxl355_spi",
0056 .of_match_table = adxl355_of_match,
0057 },
0058 .probe = adxl355_spi_probe,
0059 .id_table = adxl355_spi_id,
0060 };
0061 module_spi_driver(adxl355_spi_driver);
0062
0063 MODULE_AUTHOR("Puranjay Mohan <puranjay12@gmail.com>");
0064 MODULE_DESCRIPTION("ADXL355 3-Axis Digital Accelerometer SPI driver");
0065 MODULE_LICENSE("GPL v2");
0066 MODULE_IMPORT_NS(IIO_ADXL355);