Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.1-rc4 110 lines 3.0 kB view raw
1/* 2 * 3-axis accelerometer driver supporting following I2C Bosch-Sensortec chips: 3 * - BMC150 4 * - BMI055 5 * - BMA255 6 * - BMA250E 7 * - BMA222E 8 * - BMA280 9 * 10 * Copyright (c) 2014, Intel Corporation. 11 * 12 * This program is free software; you can redistribute it and/or modify it 13 * under the terms and conditions of the GNU General Public License, 14 * version 2, as published by the Free Software Foundation. 15 * 16 * This program is distributed in the hope it will be useful, but WITHOUT 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 19 * more details. 20 */ 21 22#include <linux/device.h> 23#include <linux/mod_devicetable.h> 24#include <linux/i2c.h> 25#include <linux/module.h> 26#include <linux/acpi.h> 27#include <linux/regmap.h> 28 29#include "bmc150-accel.h" 30 31static int bmc150_accel_probe(struct i2c_client *client, 32 const struct i2c_device_id *id) 33{ 34 struct regmap *regmap; 35 const char *name = NULL; 36 bool block_supported = 37 i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || 38 i2c_check_functionality(client->adapter, 39 I2C_FUNC_SMBUS_READ_I2C_BLOCK); 40 41 regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf); 42 if (IS_ERR(regmap)) { 43 dev_err(&client->dev, "Failed to initialize i2c regmap\n"); 44 return PTR_ERR(regmap); 45 } 46 47 if (id) 48 name = id->name; 49 50 return bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, 51 block_supported); 52} 53 54static int bmc150_accel_remove(struct i2c_client *client) 55{ 56 return bmc150_accel_core_remove(&client->dev); 57} 58 59static const struct acpi_device_id bmc150_accel_acpi_match[] = { 60 {"BSBA0150", bmc150}, 61 {"BMC150A", bmc150}, 62 {"BMI055A", bmi055}, 63 {"BMA0255", bma255}, 64 {"BMA250E", bma250e}, 65 {"BMA222E", bma222e}, 66 {"BMA0280", bma280}, 67 {"BOSC0200"}, 68 { }, 69}; 70MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match); 71 72static const struct i2c_device_id bmc150_accel_id[] = { 73 {"bmc150_accel", bmc150}, 74 {"bmi055_accel", bmi055}, 75 {"bma255", bma255}, 76 {"bma250e", bma250e}, 77 {"bma222e", bma222e}, 78 {"bma280", bma280}, 79 {} 80}; 81 82MODULE_DEVICE_TABLE(i2c, bmc150_accel_id); 83 84static const struct of_device_id bmc150_accel_of_match[] = { 85 { .compatible = "bosch,bmc150_accel" }, 86 { .compatible = "bosch,bmi055_accel" }, 87 { .compatible = "bosch,bma255" }, 88 { .compatible = "bosch,bma250e" }, 89 { .compatible = "bosch,bma222e" }, 90 { .compatible = "bosch,bma280" }, 91 { }, 92}; 93MODULE_DEVICE_TABLE(of, bmc150_accel_of_match); 94 95static struct i2c_driver bmc150_accel_driver = { 96 .driver = { 97 .name = "bmc150_accel_i2c", 98 .of_match_table = bmc150_accel_of_match, 99 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match), 100 .pm = &bmc150_accel_pm_ops, 101 }, 102 .probe = bmc150_accel_probe, 103 .remove = bmc150_accel_remove, 104 .id_table = bmc150_accel_id, 105}; 106module_i2c_driver(bmc150_accel_driver); 107 108MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>"); 109MODULE_LICENSE("GPL v2"); 110MODULE_DESCRIPTION("BMC150 I2C accelerometer driver");