aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Andersson <eric.andersson@unixphere.com>2012-04-09 16:16:16 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-18 17:56:36 -0400
commitc5a86ab6dd6e424c56826421a80b855e24f7caa1 (patch)
tree684ff235e5a6391a7e2f1e37fdb9fb038b92affd
parente939ca0a63627d6b2205dd945833ee7da4fc181a (diff)
misc: bmp085: add device tree properties
Reviewed-by: Stefan Nilsson <stefan.nilsson@unixphere.com> Signed-off-by: Eric Andersson <eric.andersson@unixphere.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/devicetree/bindings/misc/bmp085.txt20
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt1
-rw-r--r--drivers/misc/bmp085.c37
3 files changed, 57 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/misc/bmp085.txt b/Documentation/devicetree/bindings/misc/bmp085.txt
new file mode 100644
index 000000000000..91dfda2e4e11
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/bmp085.txt
@@ -0,0 +1,20 @@
1BMP085/BMP18x digital pressure sensors
2
3Required properties:
4- compatible: bosch,bmp085
5
6Optional properties:
7- chip-id: configurable chip id for non-default chip revisions
8- temp-measurement-period: temperature measurement period (milliseconds)
9- default-oversampling: default oversampling value to be used at startup,
10 value range is 0-3 with rising sensitivity.
11
12Example:
13
14pressure@77 {
15 compatible = "bosch,bmp085";
16 reg = <0x77>;
17 chip-id = <10>;
18 temp-measurement-period = <100>;
19 default-oversampling = <2>;
20};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 82ac057a24a9..107d8addf0e4 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -8,6 +8,7 @@ amcc Applied Micro Circuits Corporation (APM, formally AMCC)
8apm Applied Micro Circuits Corporation (APM) 8apm Applied Micro Circuits Corporation (APM)
9arm ARM Ltd. 9arm ARM Ltd.
10atmel Atmel Corporation 10atmel Atmel Corporation
11bosch Bosch Sensortec GmbH
11cavium Cavium, Inc. 12cavium Cavium, Inc.
12chrp Common Hardware Reference Platform 13chrp Common Hardware Reference Platform
13cortina Cortina Systems, Inc. 14cortina Cortina Systems, Inc.
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 6f572bc21879..6adde9e1a0d1 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -50,6 +50,7 @@
50#include <linux/i2c.h> 50#include <linux/i2c.h>
51#include <linux/slab.h> 51#include <linux/slab.h>
52#include <linux/delay.h> 52#include <linux/delay.h>
53#include <linux/of.h>
53 54
54#define BMP085_NAME "bmp085" 55#define BMP085_NAME "bmp085"
55#define BMP085_I2C_ADDRESS 0x77 56#define BMP085_I2C_ADDRESS 0x77
@@ -85,6 +86,7 @@ struct bmp085_data {
85 u32 raw_pressure; 86 u32 raw_pressure;
86 u32 temp_measurement_period; 87 u32 temp_measurement_period;
87 unsigned long last_temp_measurement; 88 unsigned long last_temp_measurement;
89 u8 chip_id;
88 s32 b6; /* calculated temperature correction coefficient */ 90 s32 b6; /* calculated temperature correction coefficient */
89}; 91};
90 92
@@ -385,6 +387,27 @@ static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info)
385 return 0; 387 return 0;
386} 388}
387 389
390static void __init bmp085_get_of_properties(struct i2c_client *client,
391 struct bmp085_data *data)
392{
393#ifdef CONFIG_OF
394 struct device_node *np = client->dev.of_node;
395 u32 prop;
396
397 if (!np)
398 return;
399
400 if (!of_property_read_u32(np, "chip-id", &prop))
401 data->chip_id = prop & 0xff;
402
403 if (!of_property_read_u32(np, "temp-measurement-period", &prop))
404 data->temp_measurement_period = (prop/100)*HZ;
405
406 if (!of_property_read_u32(np, "default-oversampling", &prop))
407 data->oversampling_setting = prop & 0xff;
408#endif
409}
410
388static int bmp085_init_client(struct i2c_client *client) 411static int bmp085_init_client(struct i2c_client *client)
389{ 412{
390 struct bmp085_data *data = i2c_get_clientdata(client); 413 struct bmp085_data *data = i2c_get_clientdata(client);
@@ -393,10 +416,15 @@ static int bmp085_init_client(struct i2c_client *client)
393 if (status < 0) 416 if (status < 0)
394 return status; 417 return status;
395 418
419 /* default settings */
396 data->client = client; 420 data->client = client;
421 data->chip_id = BMP085_CHIP_ID;
397 data->last_temp_measurement = 0; 422 data->last_temp_measurement = 0;
398 data->temp_measurement_period = 1*HZ; 423 data->temp_measurement_period = 1*HZ;
399 data->oversampling_setting = 3; 424 data->oversampling_setting = 3;
425
426 bmp085_get_of_properties(client, data);
427
400 mutex_init(&data->lock); 428 mutex_init(&data->lock);
401 429
402 return 0; 430 return 0;
@@ -446,6 +474,12 @@ static int __devexit bmp085_remove(struct i2c_client *client)
446 return 0; 474 return 0;
447} 475}
448 476
477static const struct of_device_id bmp085_of_match[] = {
478 { .compatible = "bosch,bmp085", },
479 { },
480};
481MODULE_DEVICE_TABLE(of, bmp085_of_match);
482
449static const struct i2c_device_id bmp085_id[] = { 483static const struct i2c_device_id bmp085_id[] = {
450 { BMP085_NAME, 0 }, 484 { BMP085_NAME, 0 },
451 { } 485 { }
@@ -455,7 +489,8 @@ MODULE_DEVICE_TABLE(i2c, bmp085_id);
455static struct i2c_driver bmp085_driver = { 489static struct i2c_driver bmp085_driver = {
456 .driver = { 490 .driver = {
457 .owner = THIS_MODULE, 491 .owner = THIS_MODULE,
458 .name = BMP085_NAME 492 .name = BMP085_NAME,
493 .of_match_table = bmp085_of_match
459 }, 494 },
460 .id_table = bmp085_id, 495 .id_table = bmp085_id,
461 .probe = bmp085_probe, 496 .probe = bmp085_probe,