Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * BMI160 - Bosch IMU, SPI bits
0004  *
0005  * Copyright (c) 2016, Intel Corporation.
0006  *
0007  */
0008 #include <linux/mod_devicetable.h>
0009 #include <linux/module.h>
0010 #include <linux/regmap.h>
0011 #include <linux/spi/spi.h>
0012 
0013 #include "bmi160.h"
0014 
0015 static int bmi160_spi_probe(struct spi_device *spi)
0016 {
0017     struct regmap *regmap;
0018     const struct spi_device_id *id = spi_get_device_id(spi);
0019     const char *name;
0020 
0021     regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config);
0022     if (IS_ERR(regmap)) {
0023         dev_err(&spi->dev, "Failed to register spi regmap: %pe\n",
0024             regmap);
0025         return PTR_ERR(regmap);
0026     }
0027 
0028     if (id)
0029         name = id->name;
0030     else
0031         name = dev_name(&spi->dev);
0032 
0033     return bmi160_core_probe(&spi->dev, regmap, name, true);
0034 }
0035 
0036 static const struct spi_device_id bmi160_spi_id[] = {
0037     {"bmi160", 0},
0038     {}
0039 };
0040 MODULE_DEVICE_TABLE(spi, bmi160_spi_id);
0041 
0042 static const struct acpi_device_id bmi160_acpi_match[] = {
0043     {"BMI0160", 0},
0044     { },
0045 };
0046 MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
0047 
0048 static const struct of_device_id bmi160_of_match[] = {
0049     { .compatible = "bosch,bmi160" },
0050     { },
0051 };
0052 MODULE_DEVICE_TABLE(of, bmi160_of_match);
0053 
0054 static struct spi_driver bmi160_spi_driver = {
0055     .probe      = bmi160_spi_probe,
0056     .id_table   = bmi160_spi_id,
0057     .driver = {
0058         .acpi_match_table   = bmi160_acpi_match,
0059         .of_match_table     = bmi160_of_match,
0060         .name           = "bmi160_spi",
0061     },
0062 };
0063 module_spi_driver(bmi160_spi_driver);
0064 
0065 MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
0066 MODULE_DESCRIPTION("Bosch BMI160 SPI driver");
0067 MODULE_LICENSE("GPL v2");
0068 MODULE_IMPORT_NS(IIO_BMI160);