root/drivers/iio/accel/bmc150-accel-i2c.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. bmc150_accel_probe
  2. bmc150_accel_remove

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * 3-axis accelerometer driver supporting following I2C Bosch-Sensortec chips:
   4  *  - BMC150
   5  *  - BMI055
   6  *  - BMA255
   7  *  - BMA250E
   8  *  - BMA222E
   9  *  - BMA280
  10  *
  11  * Copyright (c) 2014, Intel Corporation.
  12  */
  13 
  14 #include <linux/device.h>
  15 #include <linux/mod_devicetable.h>
  16 #include <linux/i2c.h>
  17 #include <linux/module.h>
  18 #include <linux/acpi.h>
  19 #include <linux/regmap.h>
  20 
  21 #include "bmc150-accel.h"
  22 
  23 static int bmc150_accel_probe(struct i2c_client *client,
  24                               const struct i2c_device_id *id)
  25 {
  26         struct regmap *regmap;
  27         const char *name = NULL;
  28         bool block_supported =
  29                 i2c_check_functionality(client->adapter, I2C_FUNC_I2C) ||
  30                 i2c_check_functionality(client->adapter,
  31                                         I2C_FUNC_SMBUS_READ_I2C_BLOCK);
  32 
  33         regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf);
  34         if (IS_ERR(regmap)) {
  35                 dev_err(&client->dev, "Failed to initialize i2c regmap\n");
  36                 return PTR_ERR(regmap);
  37         }
  38 
  39         if (id)
  40                 name = id->name;
  41 
  42         return bmc150_accel_core_probe(&client->dev, regmap, client->irq, name,
  43                                        block_supported);
  44 }
  45 
  46 static int bmc150_accel_remove(struct i2c_client *client)
  47 {
  48         return bmc150_accel_core_remove(&client->dev);
  49 }
  50 
  51 static const struct acpi_device_id bmc150_accel_acpi_match[] = {
  52         {"BSBA0150",    bmc150},
  53         {"BMC150A",     bmc150},
  54         {"BMI055A",     bmi055},
  55         {"BMA0255",     bma255},
  56         {"BMA250E",     bma250e},
  57         {"BMA222E",     bma222e},
  58         {"BMA0280",     bma280},
  59         {"BOSC0200"},
  60         { },
  61 };
  62 MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
  63 
  64 static const struct i2c_device_id bmc150_accel_id[] = {
  65         {"bmc150_accel",        bmc150},
  66         {"bmi055_accel",        bmi055},
  67         {"bma255",              bma255},
  68         {"bma250e",             bma250e},
  69         {"bma222e",             bma222e},
  70         {"bma280",              bma280},
  71         {}
  72 };
  73 
  74 MODULE_DEVICE_TABLE(i2c, bmc150_accel_id);
  75 
  76 static const struct of_device_id bmc150_accel_of_match[] = {
  77         { .compatible = "bosch,bmc150_accel" },
  78         { .compatible = "bosch,bmi055_accel" },
  79         { .compatible = "bosch,bma255" },
  80         { .compatible = "bosch,bma250e" },
  81         { .compatible = "bosch,bma222e" },
  82         { .compatible = "bosch,bma280" },
  83         { },
  84 };
  85 MODULE_DEVICE_TABLE(of, bmc150_accel_of_match);
  86 
  87 static struct i2c_driver bmc150_accel_driver = {
  88         .driver = {
  89                 .name   = "bmc150_accel_i2c",
  90                 .of_match_table = bmc150_accel_of_match,
  91                 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match),
  92                 .pm     = &bmc150_accel_pm_ops,
  93         },
  94         .probe          = bmc150_accel_probe,
  95         .remove         = bmc150_accel_remove,
  96         .id_table       = bmc150_accel_id,
  97 };
  98 module_i2c_driver(bmc150_accel_driver);
  99 
 100 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
 101 MODULE_LICENSE("GPL v2");
 102 MODULE_DESCRIPTION("BMC150 I2C accelerometer driver");

/* [<][>][^][v][top][bottom][index][help] */