69 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * Driver for NXP FXAS21002C Gyroscope - I2C4 *5 * Copyright (C) 2018 Linaro Ltd.6 */7 8#include <linux/err.h>9#include <linux/i2c.h>10#include <linux/mod_devicetable.h>11#include <linux/module.h>12#include <linux/regmap.h>13 14#include "fxas21002c.h"15 16static const struct regmap_config fxas21002c_regmap_i2c_conf = {17 .reg_bits = 8,18 .val_bits = 8,19 .max_register = FXAS21002C_REG_CTRL3,20};21 22static int fxas21002c_i2c_probe(struct i2c_client *i2c)23{24 struct regmap *regmap;25 26 regmap = devm_regmap_init_i2c(i2c, &fxas21002c_regmap_i2c_conf);27 if (IS_ERR(regmap)) {28 dev_err(&i2c->dev, "Failed to register i2c regmap: %ld\n",29 PTR_ERR(regmap));30 return PTR_ERR(regmap);31 }32 33 return fxas21002c_core_probe(&i2c->dev, regmap, i2c->irq, i2c->name);34}35 36static void fxas21002c_i2c_remove(struct i2c_client *i2c)37{38 fxas21002c_core_remove(&i2c->dev);39}40 41static const struct i2c_device_id fxas21002c_i2c_id[] = {42 { "fxas21002c" },43 { }44};45MODULE_DEVICE_TABLE(i2c, fxas21002c_i2c_id);46 47static const struct of_device_id fxas21002c_i2c_of_match[] = {48 { .compatible = "nxp,fxas21002c", },49 { }50};51MODULE_DEVICE_TABLE(of, fxas21002c_i2c_of_match);52 53static struct i2c_driver fxas21002c_i2c_driver = {54 .driver = {55 .name = "fxas21002c_i2c",56 .pm = pm_ptr(&fxas21002c_pm_ops),57 .of_match_table = fxas21002c_i2c_of_match,58 },59 .probe = fxas21002c_i2c_probe,60 .remove = fxas21002c_i2c_remove,61 .id_table = fxas21002c_i2c_id,62};63module_i2c_driver(fxas21002c_i2c_driver);64 65MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");66MODULE_LICENSE("GPL v2");67MODULE_DESCRIPTION("FXAS21002C I2C Gyro driver");68MODULE_IMPORT_NS(IIO_FXAS21002C);69