Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / iio / magnetometer / bmc150_magn_i2c.c
blob8cbeda924bdaa343f2a0507032d169a1010c70ea
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * 3-axis magnetometer driver supporting following I2C Bosch-Sensortec chips:
4 * - BMC150
5 * - BMC156
6 * - BMM150
8 * Copyright (c) 2016, Intel Corporation.
9 */
10 #include <linux/device.h>
11 #include <linux/mod_devicetable.h>
12 #include <linux/i2c.h>
13 #include <linux/module.h>
14 #include <linux/regmap.h>
16 #include "bmc150_magn.h"
18 static int bmc150_magn_i2c_probe(struct i2c_client *client)
20 const struct i2c_device_id *id = i2c_client_get_device_id(client);
21 struct regmap *regmap;
22 const char *name = NULL;
24 regmap = devm_regmap_init_i2c(client, &bmc150_magn_regmap_config);
25 if (IS_ERR(regmap)) {
26 dev_err(&client->dev, "Failed to initialize i2c regmap\n");
27 return PTR_ERR(regmap);
30 if (id)
31 name = id->name;
33 return bmc150_magn_probe(&client->dev, regmap, client->irq, name);
36 static void bmc150_magn_i2c_remove(struct i2c_client *client)
38 bmc150_magn_remove(&client->dev);
41 static const struct i2c_device_id bmc150_magn_i2c_id[] = {
42 { "bmc150_magn" },
43 { "bmc156_magn" },
44 { "bmm150_magn" },
47 MODULE_DEVICE_TABLE(i2c, bmc150_magn_i2c_id);
49 static const struct of_device_id bmc150_magn_of_match[] = {
50 { .compatible = "bosch,bmc150_magn" },
51 { .compatible = "bosch,bmc156_magn" },
52 { .compatible = "bosch,bmm150_magn" }, /* deprecated compatible */
53 { .compatible = "bosch,bmm150" },
54 { }
56 MODULE_DEVICE_TABLE(of, bmc150_magn_of_match);
58 static struct i2c_driver bmc150_magn_driver = {
59 .driver = {
60 .name = "bmc150_magn_i2c",
61 .of_match_table = bmc150_magn_of_match,
62 .pm = &bmc150_magn_pm_ops,
64 .probe = bmc150_magn_i2c_probe,
65 .remove = bmc150_magn_i2c_remove,
66 .id_table = bmc150_magn_i2c_id,
68 module_i2c_driver(bmc150_magn_driver);
70 MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
71 MODULE_LICENSE("GPL v2");
72 MODULE_DESCRIPTION("BMC150 I2C magnetometer driver");
73 MODULE_IMPORT_NS("IIO_BMC150_MAGN");