aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/bmp085-spi.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-spi.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-spi.c')
-rw-r--r--drivers/misc/bmp085-spi.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/drivers/misc/bmp085-spi.c b/drivers/misc/bmp085-spi.c
new file mode 100644
index 000000000000..78aaff9b5231
--- /dev/null
+++ b/drivers/misc/bmp085-spi.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/spi/spi.h>
22#include <linux/err.h>
23#include "bmp085.h"
24
25static int __devinit bmp085_spi_probe(struct spi_device *client)
26{
27 int err;
28 struct regmap *regmap;
29
30 client->bits_per_word = 8;
31 err = spi_setup(client);
32 if (err < 0) {
33 dev_err(&client->dev, "spi_setup failed!\n");
34 return err;
35 }
36
37 regmap = devm_regmap_init_spi(client, &bmp085_regmap_config);
38 if (IS_ERR(regmap)) {
39 err = PTR_ERR(regmap);
40 dev_err(&client->dev, "Failed to init regmap: %d\n", err);
41 return err;
42 }
43
44 return bmp085_probe(&client->dev, regmap);
45}
46
47static int bmp085_spi_remove(struct spi_device *client)
48{
49 return bmp085_remove(&client->dev);
50}
51
52static const struct of_device_id bmp085_of_match[] = {
53 { .compatible = "bosch,bmp085", },
54 { },
55};
56MODULE_DEVICE_TABLE(of, bmp085_of_match);
57
58static const struct spi_device_id bmp085_id[] = {
59 { "bmp180", 0 },
60 { "bmp181", 0 },
61 { }
62};
63MODULE_DEVICE_TABLE(spi, bmp085_id);
64
65static struct spi_driver bmp085_spi_driver = {
66 .driver = {
67 .owner = THIS_MODULE,
68 .name = BMP085_NAME,
69 .of_match_table = bmp085_of_match
70 },
71 .id_table = bmp085_id,
72 .probe = bmp085_spi_probe,
73 .remove = __devexit_p(bmp085_spi_remove)
74};
75
76static int __init bmp085_spi_init(void)
77{
78 return spi_register_driver(&bmp085_spi_driver);
79}
80
81static void __exit bmp085_spi_exit(void)
82{
83 spi_unregister_driver(&bmp085_spi_driver);
84}
85
86MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
87MODULE_DESCRIPTION("BMP085 SPI bus driver");
88MODULE_LICENSE("GPL");
89
90module_init(bmp085_spi_init);
91module_exit(bmp085_spi_exit);