Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * IIO accel I2C driver for Freescale MMA7455L 3-axis 10-bit accelerometer
0004  * Copyright 2015 Joachim Eastwood <manabian@gmail.com>
0005  */
0006 
0007 #include <linux/i2c.h>
0008 #include <linux/module.h>
0009 #include <linux/regmap.h>
0010 
0011 #include "mma7455.h"
0012 
0013 static int mma7455_i2c_probe(struct i2c_client *i2c,
0014                  const struct i2c_device_id *id)
0015 {
0016     struct regmap *regmap;
0017     const char *name = NULL;
0018 
0019     regmap = devm_regmap_init_i2c(i2c, &mma7455_core_regmap);
0020     if (IS_ERR(regmap))
0021         return PTR_ERR(regmap);
0022 
0023     if (id)
0024         name = id->name;
0025 
0026     return mma7455_core_probe(&i2c->dev, regmap, name);
0027 }
0028 
0029 static int mma7455_i2c_remove(struct i2c_client *i2c)
0030 {
0031     mma7455_core_remove(&i2c->dev);
0032 
0033     return 0;
0034 }
0035 
0036 static const struct i2c_device_id mma7455_i2c_ids[] = {
0037     { "mma7455", 0 },
0038     { "mma7456", 0 },
0039     { }
0040 };
0041 MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
0042 
0043 static const struct of_device_id mma7455_of_match[] = {
0044     { .compatible = "fsl,mma7455" },
0045     { .compatible = "fsl,mma7456" },
0046     { }
0047 };
0048 MODULE_DEVICE_TABLE(of, mma7455_of_match);
0049 
0050 static struct i2c_driver mma7455_i2c_driver = {
0051     .probe = mma7455_i2c_probe,
0052     .remove = mma7455_i2c_remove,
0053     .id_table = mma7455_i2c_ids,
0054     .driver = {
0055         .name   = "mma7455-i2c",
0056         .of_match_table = mma7455_of_match,
0057     },
0058 };
0059 module_i2c_driver(mma7455_i2c_driver);
0060 
0061 MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
0062 MODULE_DESCRIPTION("Freescale MMA7455L I2C accelerometer driver");
0063 MODULE_LICENSE("GPL v2");
0064 MODULE_IMPORT_NS(IIO_MMA7455);