Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * FXOS8700 - NXP IMU, SPI bits
0004  */
0005 #include <linux/acpi.h>
0006 #include <linux/module.h>
0007 #include <linux/mod_devicetable.h>
0008 #include <linux/regmap.h>
0009 #include <linux/spi/spi.h>
0010 
0011 #include "fxos8700.h"
0012 
0013 static int fxos8700_spi_probe(struct spi_device *spi)
0014 {
0015     struct regmap *regmap;
0016     const struct spi_device_id *id = spi_get_device_id(spi);
0017 
0018     regmap = devm_regmap_init_spi(spi, &fxos8700_regmap_config);
0019     if (IS_ERR(regmap)) {
0020         dev_err(&spi->dev, "Failed to register spi regmap %ld\n", PTR_ERR(regmap));
0021         return PTR_ERR(regmap);
0022     }
0023 
0024     return fxos8700_core_probe(&spi->dev, regmap, id->name, true);
0025 }
0026 
0027 static const struct spi_device_id fxos8700_spi_id[] = {
0028     {"fxos8700", 0},
0029     { }
0030 };
0031 MODULE_DEVICE_TABLE(spi, fxos8700_spi_id);
0032 
0033 static const struct acpi_device_id fxos8700_acpi_match[] = {
0034     {"FXOS8700", 0},
0035     { }
0036 };
0037 MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
0038 
0039 static const struct of_device_id fxos8700_of_match[] = {
0040     { .compatible = "nxp,fxos8700" },
0041     { }
0042 };
0043 MODULE_DEVICE_TABLE(of, fxos8700_of_match);
0044 
0045 static struct spi_driver fxos8700_spi_driver = {
0046     .probe          = fxos8700_spi_probe,
0047     .id_table       = fxos8700_spi_id,
0048     .driver = {
0049         .acpi_match_table       = ACPI_PTR(fxos8700_acpi_match),
0050         .of_match_table         = fxos8700_of_match,
0051         .name                   = "fxos8700_spi",
0052     },
0053 };
0054 module_spi_driver(fxos8700_spi_driver);
0055 
0056 MODULE_AUTHOR("Robert Jones <rjones@gateworks.com>");
0057 MODULE_DESCRIPTION("FXOS8700 SPI driver");
0058 MODULE_LICENSE("GPL v2");