1761b7910SDaniel Baluta /* 2761b7910SDaniel Baluta * 3-axis magnetometer driver supporting following I2C Bosch-Sensortec chips: 3761b7910SDaniel Baluta * - BMC150 4761b7910SDaniel Baluta * - BMC156 5761b7910SDaniel Baluta * 6761b7910SDaniel Baluta * Copyright (c) 2016, Intel Corporation. 7761b7910SDaniel Baluta * 8761b7910SDaniel Baluta * This program is free software; you can redistribute it and/or modify it 9761b7910SDaniel Baluta * under the terms and conditions of the GNU General Public License, 10761b7910SDaniel Baluta * version 2, as published by the Free Software Foundation. 11761b7910SDaniel Baluta * 12761b7910SDaniel Baluta * This program is distributed in the hope it will be useful, but WITHOUT 13761b7910SDaniel Baluta * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14761b7910SDaniel Baluta * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15761b7910SDaniel Baluta * more details. 16761b7910SDaniel Baluta */ 17761b7910SDaniel Baluta #include <linux/device.h> 18761b7910SDaniel Baluta #include <linux/mod_devicetable.h> 19761b7910SDaniel Baluta #include <linux/i2c.h> 20761b7910SDaniel Baluta #include <linux/module.h> 21761b7910SDaniel Baluta #include <linux/acpi.h> 22761b7910SDaniel Baluta #include <linux/regmap.h> 23761b7910SDaniel Baluta 24761b7910SDaniel Baluta #include "bmc150_magn.h" 25761b7910SDaniel Baluta 26761b7910SDaniel Baluta static int bmc150_magn_i2c_probe(struct i2c_client *client, 27761b7910SDaniel Baluta const struct i2c_device_id *id) 28761b7910SDaniel Baluta { 29761b7910SDaniel Baluta struct regmap *regmap; 30761b7910SDaniel Baluta const char *name = NULL; 31761b7910SDaniel Baluta 32761b7910SDaniel Baluta regmap = devm_regmap_init_i2c(client, &bmc150_magn_regmap_config); 33761b7910SDaniel Baluta if (IS_ERR(regmap)) { 34761b7910SDaniel Baluta dev_err(&client->dev, "Failed to initialize i2c regmap\n"); 35761b7910SDaniel Baluta return PTR_ERR(regmap); 36761b7910SDaniel Baluta } 37761b7910SDaniel Baluta 38761b7910SDaniel Baluta if (id) 39761b7910SDaniel Baluta name = id->name; 40761b7910SDaniel Baluta 41761b7910SDaniel Baluta return bmc150_magn_probe(&client->dev, regmap, client->irq, name); 42761b7910SDaniel Baluta } 43761b7910SDaniel Baluta 44761b7910SDaniel Baluta static int bmc150_magn_i2c_remove(struct i2c_client *client) 45761b7910SDaniel Baluta { 46761b7910SDaniel Baluta return bmc150_magn_remove(&client->dev); 47761b7910SDaniel Baluta } 48761b7910SDaniel Baluta 49761b7910SDaniel Baluta static const struct acpi_device_id bmc150_magn_acpi_match[] = { 50761b7910SDaniel Baluta {"BMC150B", 0}, 51761b7910SDaniel Baluta {"BMC156B", 0}, 52761b7910SDaniel Baluta {}, 53761b7910SDaniel Baluta }; 54761b7910SDaniel Baluta MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match); 55761b7910SDaniel Baluta 56761b7910SDaniel Baluta static const struct i2c_device_id bmc150_magn_i2c_id[] = { 57761b7910SDaniel Baluta {"bmc150_magn", 0}, 58761b7910SDaniel Baluta {"bmc156_magn", 0}, 59761b7910SDaniel Baluta {} 60761b7910SDaniel Baluta }; 61761b7910SDaniel Baluta MODULE_DEVICE_TABLE(i2c, bmc150_magn_i2c_id); 62761b7910SDaniel Baluta 63761b7910SDaniel Baluta static struct i2c_driver bmc150_magn_driver = { 64761b7910SDaniel Baluta .driver = { 65761b7910SDaniel Baluta .name = "bmc150_magn_i2c", 66761b7910SDaniel Baluta .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match), 67761b7910SDaniel Baluta .pm = &bmc150_magn_pm_ops, 68761b7910SDaniel Baluta }, 69761b7910SDaniel Baluta .probe = bmc150_magn_i2c_probe, 70761b7910SDaniel Baluta .remove = bmc150_magn_i2c_remove, 71761b7910SDaniel Baluta .id_table = bmc150_magn_i2c_id, 72761b7910SDaniel Baluta }; 73761b7910SDaniel Baluta module_i2c_driver(bmc150_magn_driver); 74761b7910SDaniel Baluta 75761b7910SDaniel Baluta MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com"); 76761b7910SDaniel Baluta MODULE_LICENSE("GPL v2"); 77761b7910SDaniel Baluta MODULE_DESCRIPTION("BMC150 I2C magnetometer driver"); 78