1 // SPDX-License-Identifier: GPL-2.0+
3 * ADXL372 3-Axis Digital Accelerometer SPI driver
5 * Copyright 2018 Analog Devices Inc.
8 #include <linux/module.h>
9 #include <linux/mod_devicetable.h>
10 #include <linux/regmap.h>
11 #include <linux/spi/spi.h>
15 static const struct regmap_config adxl372_spi_regmap_config
= {
19 .read_flag_mask
= BIT(0),
20 .readable_noinc_reg
= adxl372_readable_noinc_reg
,
23 static int adxl372_spi_probe(struct spi_device
*spi
)
25 const struct spi_device_id
*id
= spi_get_device_id(spi
);
26 struct regmap
*regmap
;
28 regmap
= devm_regmap_init_spi(spi
, &adxl372_spi_regmap_config
);
30 return PTR_ERR(regmap
);
32 return adxl372_probe(&spi
->dev
, regmap
, spi
->irq
, id
->name
);
35 static const struct spi_device_id adxl372_spi_id
[] = {
39 MODULE_DEVICE_TABLE(spi
, adxl372_spi_id
);
41 static const struct of_device_id adxl372_of_match
[] = {
42 { .compatible
= "adi,adxl372" },
45 MODULE_DEVICE_TABLE(of
, adxl372_of_match
);
47 static struct spi_driver adxl372_spi_driver
= {
49 .name
= "adxl372_spi",
50 .of_match_table
= adxl372_of_match
,
52 .probe
= adxl372_spi_probe
,
53 .id_table
= adxl372_spi_id
,
56 module_spi_driver(adxl372_spi_driver
);
58 MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>");
59 MODULE_DESCRIPTION("Analog Devices ADXL372 3-axis accelerometer SPI driver");
60 MODULE_LICENSE("GPL");
61 MODULE_IMPORT_NS(IIO_ADXL372
);