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/spi/spi.h>
22 #include <linux/err.h>
25 static int bmp085_spi_probe(struct spi_device
*client
)
28 struct regmap
*regmap
;
30 client
->bits_per_word
= 8;
31 err
= spi_setup(client
);
33 dev_err(&client
->dev
, "spi_setup failed!\n");
37 regmap
= devm_regmap_init_spi(client
, &bmp085_regmap_config
);
39 err
= PTR_ERR(regmap
);
40 dev_err(&client
->dev
, "Failed to init regmap: %d\n", err
);
44 return bmp085_probe(&client
->dev
, regmap
, client
->irq
);
47 static int bmp085_spi_remove(struct spi_device
*client
)
49 return bmp085_remove(&client
->dev
);
52 static const struct of_device_id bmp085_of_match
[] = {
53 { .compatible
= "bosch,bmp085", },
56 MODULE_DEVICE_TABLE(of
, bmp085_of_match
);
58 static const struct spi_device_id bmp085_id
[] = {
63 MODULE_DEVICE_TABLE(spi
, bmp085_id
);
65 static struct spi_driver bmp085_spi_driver
= {
68 .of_match_table
= bmp085_of_match
70 .id_table
= bmp085_id
,
71 .probe
= bmp085_spi_probe
,
72 .remove
= bmp085_spi_remove
75 module_spi_driver(bmp085_spi_driver
);
77 MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
78 MODULE_DESCRIPTION("BMP085 SPI bus driver");
79 MODULE_LICENSE("GPL");