aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/bmp085-i2c.c
diff options
context:
space:
mode:
authorEric Andersson <eric.andersson@unixphere.com>2012-04-09 16:16:17 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-18 17:57:14 -0400
commit985087dbcb0265f46e8651fdc7e974f8a7184423 (patch)
treeaad96003f89022623f4c8bf940267300530a9eb2 /drivers/misc/bmp085-i2c.c
parentc5a86ab6dd6e424c56826421a80b855e24f7caa1 (diff)
misc: add support for bmp18x chips to the bmp085 driver
The bmp18x chip family comes in an I2C respectively SPI variant. Hence, the bmp085 driver was split to support both buses. Tested-by: Zhengguang Guo <zhengguang.guo@bosch-sensortec.com> Reviewed-by: Stefan Nilsson <stefan.nilsson@unixphere.com> Signed-off-by: Eric Andersson <eric.andersson@unixphere.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/bmp085-i2c.c')
-rw-r--r--drivers/misc/bmp085-i2c.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/drivers/misc/bmp085-i2c.c b/drivers/misc/bmp085-i2c.c
new file mode 100644
index 000000000000..9943971c13e3
--- /dev/null
+++ b/drivers/misc/bmp085-i2c.c
@@ -0,0 +1,91 @@
1/*
2 * Copyright (c) 2012 Bosch Sensortec GmbH
3 * Copyright (c) 2012 Unixphere AB
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#include <linux/module.h>
21#include <linux/i2c.h>
22#include <linux/err.h>
23#include "bmp085.h"
24
25#define BMP085_I2C_ADDRESS 0x77
26
27static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS,
28 I2C_CLIENT_END };
29
30static int bmp085_i2c_detect(struct i2c_client *client,
31 struct i2c_board_info *info)
32{
33 if (client->addr != BMP085_I2C_ADDRESS)
34 return -ENODEV;
35
36 return bmp085_detect(&client->dev);
37}
38
39static int __devinit bmp085_i2c_probe(struct i2c_client *client,
40 const struct i2c_device_id *id)
41{
42 int err;
43 struct regmap *regmap = devm_regmap_init_i2c(client,
44 &bmp085_regmap_config);
45
46 if (IS_ERR(regmap)) {
47 err = PTR_ERR(regmap);
48 dev_err(&client->dev, "Failed to init regmap: %d\n", err);
49 return err;
50 }
51
52 return bmp085_probe(&client->dev, regmap);
53}
54
55static int bmp085_i2c_remove(struct i2c_client *client)
56{
57 return bmp085_remove(&client->dev);
58}
59
60static const struct of_device_id bmp085_of_match[] = {
61 { .compatible = "bosch,bmp085", },
62 { },
63};
64MODULE_DEVICE_TABLE(of, bmp085_of_match);
65
66static const struct i2c_device_id bmp085_id[] = {
67 { BMP085_NAME, 0 },
68 { "bmp180", 0 },
69 { }
70};
71MODULE_DEVICE_TABLE(i2c, bmp085_id);
72
73static struct i2c_driver bmp085_i2c_driver = {
74 .driver = {
75 .owner = THIS_MODULE,
76 .name = BMP085_NAME,
77 .of_match_table = bmp085_of_match
78 },
79 .id_table = bmp085_id,
80 .probe = bmp085_i2c_probe,
81 .remove = __devexit_p(bmp085_i2c_remove),
82
83 .detect = bmp085_i2c_detect,
84 .address_list = normal_i2c
85};
86
87module_i2c_driver(bmp085_i2c_driver);
88
89MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
90MODULE_DESCRIPTION("BMP085 I2C bus driver");
91MODULE_LICENSE("GPL");