Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * ADXL372 3-Axis Digital Accelerometer SPI driver
0004  *
0005  * Copyright 2018 Analog Devices Inc.
0006  */
0007 
0008 #include <linux/module.h>
0009 #include <linux/regmap.h>
0010 #include <linux/of.h>
0011 #include <linux/of_device.h>
0012 #include <linux/spi/spi.h>
0013 
0014 #include "adxl372.h"
0015 
0016 static const struct regmap_config adxl372_spi_regmap_config = {
0017     .reg_bits = 7,
0018     .pad_bits = 1,
0019     .val_bits = 8,
0020     .read_flag_mask = BIT(0),
0021     .readable_noinc_reg = adxl372_readable_noinc_reg,
0022 };
0023 
0024 static int adxl372_spi_probe(struct spi_device *spi)
0025 {
0026     const struct spi_device_id *id = spi_get_device_id(spi);
0027     struct regmap *regmap;
0028 
0029     regmap = devm_regmap_init_spi(spi, &adxl372_spi_regmap_config);
0030     if (IS_ERR(regmap))
0031         return PTR_ERR(regmap);
0032 
0033     return adxl372_probe(&spi->dev, regmap, spi->irq, id->name);
0034 }
0035 
0036 static const struct spi_device_id adxl372_spi_id[] = {
0037     { "adxl372", 0 },
0038     {}
0039 };
0040 MODULE_DEVICE_TABLE(spi, adxl372_spi_id);
0041 
0042 static const struct of_device_id adxl372_of_match[] = {
0043     { .compatible = "adi,adxl372" },
0044     { }
0045 };
0046 MODULE_DEVICE_TABLE(of, adxl372_of_match);
0047 
0048 static struct spi_driver adxl372_spi_driver = {
0049     .driver = {
0050         .name = "adxl372_spi",
0051         .of_match_table = adxl372_of_match,
0052     },
0053     .probe = adxl372_spi_probe,
0054     .id_table = adxl372_spi_id,
0055 };
0056 
0057 module_spi_driver(adxl372_spi_driver);
0058 
0059 MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>");
0060 MODULE_DESCRIPTION("Analog Devices ADXL372 3-axis accelerometer SPI driver");
0061 MODULE_LICENSE("GPL");
0062 MODULE_IMPORT_NS(IIO_ADXL372);