Commit 761b7910 authored by Daniel Baluta's avatar Daniel Baluta Committed by Jonathan Cameron

iio: magn: Split bmc150 driver in common/i2c parts

This is useful for easily adding SPI support in later patches.

Now bmc150_magn exports core functions to be used by I2C/SPI drivers
instances. For the moment only I2C driver is supported.
Signed-off-by: default avatarDaniel Baluta <daniel.baluta@intel.com>
Acked-by: default avatarIrina Tirdea <irina.tirdea@intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 922b3aa6
...@@ -27,22 +27,25 @@ config AK09911 ...@@ -27,22 +27,25 @@ config AK09911
Deprecated: AK09911 is now supported by AK8975 driver. Deprecated: AK09911 is now supported by AK8975 driver.
config BMC150_MAGN config BMC150_MAGN
tristate "Bosch BMC150 Magnetometer Driver" tristate
depends on I2C
select REGMAP_I2C
select IIO_BUFFER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for the BMC150 magnetometer.
Currently this only supports the device via an i2c interface. config BMC150_MAGN_I2C
tristate "Bosch BMC150 I2C Magnetometer Driver"
depends on I2C
select BMC150_MAGN
select REGMAP_I2C
help
Say yes here to build support for the BMC150 magnetometer with
I2C interface.
This is a combo module with both accelerometer and magnetometer. This is a combo module with both accelerometer and magnetometer.
This driver is only implementing magnetometer part, which has This driver is only implementing magnetometer part, which has
its own address and register map. its own address and register map.
To compile this driver as a module, choose M here: the module will be To compile this driver as a module, choose M here: the module will be
called bmc150_magn. called bmc150_magn_i2c.
config MAG3110 config MAG3110
tristate "Freescale MAG3110 3-Axis Magnetometer" tristate "Freescale MAG3110 3-Axis Magnetometer"
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
# When adding new entries keep the list in alphabetical order # When adding new entries keep the list in alphabetical order
obj-$(CONFIG_AK8975) += ak8975.o obj-$(CONFIG_AK8975) += ak8975.o
obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o
obj-$(CONFIG_BMC150_MAGN_I2C) += bmc150_magn_i2c.o
obj-$(CONFIG_MAG3110) += mag3110.o obj-$(CONFIG_MAG3110) += mag3110.o
obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o
obj-$(CONFIG_MMC35240) += mmc35240.o obj-$(CONFIG_MMC35240) += mmc35240.o
......
This diff is collapsed.
#ifndef _BMC150_MAGN_H_
#define _BMC150_MAGN_H_
extern const struct regmap_config bmc150_magn_regmap_config;
extern const struct dev_pm_ops bmc150_magn_pm_ops;
int bmc150_magn_probe(struct device *dev, struct regmap *regmap, int irq,
const char *name);
int bmc150_magn_remove(struct device *dev);
#endif /* _BMC150_MAGN_H_ */
/*
* 3-axis magnetometer driver supporting following I2C Bosch-Sensortec chips:
* - BMC150
* - BMC156
*
* Copyright (c) 2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/regmap.h>
#include "bmc150_magn.h"
static int bmc150_magn_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct regmap *regmap;
const char *name = NULL;
regmap = devm_regmap_init_i2c(client, &bmc150_magn_regmap_config);
if (IS_ERR(regmap)) {
dev_err(&client->dev, "Failed to initialize i2c regmap\n");
return PTR_ERR(regmap);
}
if (id)
name = id->name;
return bmc150_magn_probe(&client->dev, regmap, client->irq, name);
}
static int bmc150_magn_i2c_remove(struct i2c_client *client)
{
return bmc150_magn_remove(&client->dev);
}
static const struct acpi_device_id bmc150_magn_acpi_match[] = {
{"BMC150B", 0},
{"BMC156B", 0},
{},
};
MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
static const struct i2c_device_id bmc150_magn_i2c_id[] = {
{"bmc150_magn", 0},
{"bmc156_magn", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, bmc150_magn_i2c_id);
static struct i2c_driver bmc150_magn_driver = {
.driver = {
.name = "bmc150_magn_i2c",
.acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match),
.pm = &bmc150_magn_pm_ops,
},
.probe = bmc150_magn_i2c_probe,
.remove = bmc150_magn_i2c_remove,
.id_table = bmc150_magn_i2c_id,
};
module_i2c_driver(bmc150_magn_driver);
MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("BMC150 I2C magnetometer driver");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment