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/regmap.h>
11 #include <linux/of_device.h>
12 #include <linux/spi/spi.h>
16 static const struct regmap_config adxl372_spi_regmap_config
= {
20 .read_flag_mask
= BIT(0),
21 .readable_noinc_reg
= adxl372_readable_noinc_reg
,
24 static int adxl372_spi_probe(struct spi_device
*spi
)
26 const struct spi_device_id
*id
= spi_get_device_id(spi
);
27 struct regmap
*regmap
;
29 regmap
= devm_regmap_init_spi(spi
, &adxl372_spi_regmap_config
);
31 return PTR_ERR(regmap
);
33 return adxl372_probe(&spi
->dev
, regmap
, spi
->irq
, id
->name
);
36 static const struct spi_device_id adxl372_spi_id
[] = {
40 MODULE_DEVICE_TABLE(spi
, adxl372_spi_id
);
42 static const struct of_device_id adxl372_of_match
[] = {
43 { .compatible
= "adi,adxl372" },
46 MODULE_DEVICE_TABLE(of
, adxl372_of_match
);
48 static struct spi_driver adxl372_spi_driver
= {
50 .name
= "adxl372_spi",
51 .of_match_table
= adxl372_of_match
,
53 .probe
= adxl372_spi_probe
,
54 .id_table
= adxl372_spi_id
,
57 module_spi_driver(adxl372_spi_driver
);
59 MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>");
60 MODULE_DESCRIPTION("Analog Devices ADXL372 3-axis accelerometer SPI driver");
61 MODULE_LICENSE("GPL");