2 * Copyright (c) 2012 Bosch Sensortec GmbH
3 * Copyright (c) 2012 Unixphere AB
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.
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.
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.
20 #include <linux/module.h>
21 #include <linux/i2c.h>
22 #include <linux/err.h>
25 #define BMP085_I2C_ADDRESS 0x77
27 static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS,
30 static int bmp085_i2c_detect(struct i2c_client *client,
31 struct i2c_board_info *info)
33 if (client->addr != BMP085_I2C_ADDRESS)
36 return bmp085_detect(&client->dev);
39 static int bmp085_i2c_probe(struct i2c_client *client,
40 const struct i2c_device_id *id)
43 struct regmap *regmap = devm_regmap_init_i2c(client,
44 &bmp085_regmap_config);
47 err = PTR_ERR(regmap);
48 dev_err(&client->dev, "Failed to init regmap: %d\n", err);
52 return bmp085_probe(&client->dev, regmap, client->irq);
55 static int bmp085_i2c_remove(struct i2c_client *client)
57 return bmp085_remove(&client->dev);
60 static const struct i2c_device_id bmp085_id[] = {
65 MODULE_DEVICE_TABLE(i2c, bmp085_id);
67 static struct i2c_driver bmp085_i2c_driver = {
72 .id_table = bmp085_id,
73 .probe = bmp085_i2c_probe,
74 .remove = bmp085_i2c_remove,
76 .detect = bmp085_i2c_detect,
77 .address_list = normal_i2c
80 module_i2c_driver(bmp085_i2c_driver);
82 MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
83 MODULE_DESCRIPTION("BMP085 I2C bus driver");
84 MODULE_LICENSE("GPL");