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