Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * FXOS8700 - NXP IMU, I2C bits
0004  *
0005  * 7-bit I2C slave address determined by SA1 and SA0 logic level
0006  * inputs represented in the following table:
0007  *      SA1  |  SA0  |  Slave Address
0008  *      0    |  0    |  0x1E
0009  *      0    |  1    |  0x1D
0010  *      1    |  0    |  0x1C
0011  *      1    |  1    |  0x1F
0012  */
0013 #include <linux/acpi.h>
0014 #include <linux/i2c.h>
0015 #include <linux/module.h>
0016 #include <linux/mod_devicetable.h>
0017 #include <linux/regmap.h>
0018 
0019 #include "fxos8700.h"
0020 
0021 static int fxos8700_i2c_probe(struct i2c_client *client,
0022                   const struct i2c_device_id *id)
0023 {
0024     struct regmap *regmap;
0025     const char *name = NULL;
0026 
0027     regmap = devm_regmap_init_i2c(client, &fxos8700_regmap_config);
0028     if (IS_ERR(regmap)) {
0029         dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
0030         return PTR_ERR(regmap);
0031     }
0032 
0033     if (id)
0034         name = id->name;
0035 
0036     return fxos8700_core_probe(&client->dev, regmap, name, false);
0037 }
0038 
0039 static const struct i2c_device_id fxos8700_i2c_id[] = {
0040     {"fxos8700", 0},
0041     { }
0042 };
0043 MODULE_DEVICE_TABLE(i2c, fxos8700_i2c_id);
0044 
0045 static const struct acpi_device_id fxos8700_acpi_match[] = {
0046     {"FXOS8700", 0},
0047     { }
0048 };
0049 MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
0050 
0051 static const struct of_device_id fxos8700_of_match[] = {
0052     { .compatible = "nxp,fxos8700" },
0053     { }
0054 };
0055 MODULE_DEVICE_TABLE(of, fxos8700_of_match);
0056 
0057 static struct i2c_driver fxos8700_i2c_driver = {
0058     .driver = {
0059         .name                   = "fxos8700_i2c",
0060         .acpi_match_table       = ACPI_PTR(fxos8700_acpi_match),
0061         .of_match_table         = fxos8700_of_match,
0062     },
0063     .probe          = fxos8700_i2c_probe,
0064     .id_table       = fxos8700_i2c_id,
0065 };
0066 module_i2c_driver(fxos8700_i2c_driver);
0067 
0068 MODULE_AUTHOR("Robert Jones <rjones@gateworks.com>");
0069 MODULE_DESCRIPTION("FXOS8700 I2C driver");
0070 MODULE_LICENSE("GPL v2");