aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Gajdusek <atx@atalax.net>2014-07-22 11:02:00 -0400
committerJonathan Cameron <jic23@kernel.org>2014-07-23 16:48:20 -0400
commit5a059bd268a79376ebf9ea539c5bb645c5a854d5 (patch)
treef2dec4232edcbee0fc503fe8f417f4e669be2fae
parent585f7ce2a93296e634cb50deab418029fdffb23f (diff)
staging:iio:hmc5843: Add support for i2c hmc5983
This patch adds support for the hmc5983 i2c interface. This chip is almost identical to the hmc5883. The difference being added temperature compensation, additional available sample rate (220Hz) and an SPI interface. Signed-off-by: Josef Gajdusek <atx@atx.name> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt1
-rw-r--r--drivers/staging/iio/magnetometer/Kconfig2
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843.h1
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843_core.c20
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843_i2c.c6
5 files changed, 24 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt
index b8cbdd517abc..8e191eef014e 100644
--- a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt
+++ b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt
@@ -6,6 +6,7 @@ Required properties:
6 Other models which are supported with driver are: 6 Other models which are supported with driver are:
7 "honeywell,hmc5883" 7 "honeywell,hmc5883"
8 "honeywell,hmc5883l" 8 "honeywell,hmc5883l"
9 "honeywell,hmc5983"
9 - reg : the I2C address of the magnetometer - typically 0x1e 10 - reg : the I2C address of the magnetometer - typically 0x1e
10 11
11Optional properties: 12Optional properties:
diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig
index 0a27f987c201..c086f33b6311 100644
--- a/drivers/staging/iio/magnetometer/Kconfig
+++ b/drivers/staging/iio/magnetometer/Kconfig
@@ -20,6 +20,6 @@ config SENSORS_HMC5843_I2C
20 This driver can also be compiled as a set of modules. 20 This driver can also be compiled as a set of modules.
21 If so, these modules will be created: 21 If so, these modules will be created:
22 - hmc5843_core (core functions) 22 - hmc5843_core (core functions)
23 - hmc5843_i2c (support for HMC5843, HMC5883 and HMC5883L) 23 - hmc5843_i2c (support for HMC5843, HMC5883, HMC5883L and HMC5983)
24 24
25endmenu 25endmenu
diff --git a/drivers/staging/iio/magnetometer/hmc5843.h b/drivers/staging/iio/magnetometer/hmc5843.h
index 06b2712a67fd..b784e3eb4591 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.h
+++ b/drivers/staging/iio/magnetometer/hmc5843.h
@@ -29,6 +29,7 @@ enum hmc5843_ids {
29 HMC5843_ID, 29 HMC5843_ID,
30 HMC5883_ID, 30 HMC5883_ID,
31 HMC5883L_ID, 31 HMC5883L_ID,
32 HMC5983_ID,
32}; 33};
33 34
34struct hmc5843_data { 35struct hmc5843_data {
diff --git a/drivers/staging/iio/magnetometer/hmc5843_core.c b/drivers/staging/iio/magnetometer/hmc5843_core.c
index 08fb0be100ff..914ae1acd31d 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_core.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_core.c
@@ -101,6 +101,11 @@ static const int hmc5883_regval_to_samp_freq[][2] = {
101 {75, 0} 101 {75, 0}
102}; 102};
103 103
104static const int hmc5983_regval_to_samp_freq[][2] = {
105 {0, 750000}, {1, 500000}, {3, 0}, {7, 500000}, {15, 0}, {30, 0},
106 {75, 0}, {220, 0}
107};
108
104/* Describe chip variants */ 109/* Describe chip variants */
105struct hmc5843_chip_info { 110struct hmc5843_chip_info {
106 const struct iio_chan_spec *channels; 111 const struct iio_chan_spec *channels;
@@ -457,7 +462,7 @@ static const struct iio_chan_spec hmc5843_channels[] = {
457 IIO_CHAN_SOFT_TIMESTAMP(3), 462 IIO_CHAN_SOFT_TIMESTAMP(3),
458}; 463};
459 464
460/* Beware: Y and Z are exchanged on HMC5883 */ 465/* Beware: Y and Z are exchanged on HMC5883 and 5983 */
461static const struct iio_chan_spec hmc5883_channels[] = { 466static const struct iio_chan_spec hmc5883_channels[] = {
462 HMC5843_CHANNEL(X, 0), 467 HMC5843_CHANNEL(X, 0),
463 HMC5843_CHANNEL(Z, 1), 468 HMC5843_CHANNEL(Z, 1),
@@ -504,6 +509,15 @@ static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = {
504 .n_regval_to_nanoscale = 509 .n_regval_to_nanoscale =
505 ARRAY_SIZE(hmc5883l_regval_to_nanoscale), 510 ARRAY_SIZE(hmc5883l_regval_to_nanoscale),
506 }, 511 },
512 [HMC5983_ID] = {
513 .channels = hmc5883_channels,
514 .regval_to_samp_freq = hmc5983_regval_to_samp_freq,
515 .n_regval_to_samp_freq =
516 ARRAY_SIZE(hmc5983_regval_to_samp_freq),
517 .regval_to_nanoscale = hmc5883l_regval_to_nanoscale,
518 .n_regval_to_nanoscale =
519 ARRAY_SIZE(hmc5883l_regval_to_nanoscale),
520 }
507}; 521};
508 522
509static int hmc5843_init(struct hmc5843_data *data) 523static int hmc5843_init(struct hmc5843_data *data)
@@ -516,7 +530,7 @@ static int hmc5843_init(struct hmc5843_data *data)
516 if (ret < 0) 530 if (ret < 0)
517 return ret; 531 return ret;
518 if (id[0] != 'H' || id[1] != '4' || id[2] != '3') { 532 if (id[0] != 'H' || id[1] != '4' || id[2] != '3') {
519 dev_err(data->dev, "no HMC5843/5883/5883L sensor\n"); 533 dev_err(data->dev, "no HMC5843/5883/5883L/5983 sensor\n");
520 return -ENODEV; 534 return -ENODEV;
521 } 535 }
522 536
@@ -620,5 +634,5 @@ int hmc5843_common_remove(struct device *dev)
620EXPORT_SYMBOL(hmc5843_common_remove); 634EXPORT_SYMBOL(hmc5843_common_remove);
621 635
622MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com>"); 636MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com>");
623MODULE_DESCRIPTION("HMC5843/5883/5883L core driver"); 637MODULE_DESCRIPTION("HMC5843/5883/5883L/5983 core driver");
624MODULE_LICENSE("GPL"); 638MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
index 5593a7d93a1b..6acd614cdbc6 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * i2c driver for hmc5843/5843/5883/5883l 2 * i2c driver for hmc5843/5843/5883/5883l/5983
3 * 3 *
4 * Split from hmc5843.c 4 * Split from hmc5843.c
5 * Copyright (C) Josef Gajdusek <atx@atx.name> 5 * Copyright (C) Josef Gajdusek <atx@atx.name>
@@ -73,6 +73,7 @@ static const struct i2c_device_id hmc5843_id[] = {
73 { "hmc5843", HMC5843_ID }, 73 { "hmc5843", HMC5843_ID },
74 { "hmc5883", HMC5883_ID }, 74 { "hmc5883", HMC5883_ID },
75 { "hmc5883l", HMC5883L_ID }, 75 { "hmc5883l", HMC5883L_ID },
76 { "hmc5983", HMC5983_ID },
76 { } 77 { }
77}; 78};
78MODULE_DEVICE_TABLE(i2c, hmc5843_id); 79MODULE_DEVICE_TABLE(i2c, hmc5843_id);
@@ -81,6 +82,7 @@ static const struct of_device_id hmc5843_of_match[] = {
81 { .compatible = "honeywell,hmc5843", .data = (void *)HMC5843_ID }, 82 { .compatible = "honeywell,hmc5843", .data = (void *)HMC5843_ID },
82 { .compatible = "honeywell,hmc5883", .data = (void *)HMC5883_ID }, 83 { .compatible = "honeywell,hmc5883", .data = (void *)HMC5883_ID },
83 { .compatible = "honeywell,hmc5883l", .data = (void *)HMC5883L_ID }, 84 { .compatible = "honeywell,hmc5883l", .data = (void *)HMC5883L_ID },
85 { .compatible = "honeywell,hmc5983", .data = (void *)HMC5983_ID },
84 {} 86 {}
85}; 87};
86MODULE_DEVICE_TABLE(of, hmc5843_of_match); 88MODULE_DEVICE_TABLE(of, hmc5843_of_match);
@@ -98,5 +100,5 @@ static struct i2c_driver hmc5843_driver = {
98module_i2c_driver(hmc5843_driver); 100module_i2c_driver(hmc5843_driver);
99 101
100MODULE_AUTHOR("Josef Gajdusek <atx@atx.name>"); 102MODULE_AUTHOR("Josef Gajdusek <atx@atx.name>");
101MODULE_DESCRIPTION("HMC5843/5883/5883L i2c driver"); 103MODULE_DESCRIPTION("HMC5843/5883/5883L/5983 i2c driver");
102MODULE_LICENSE("GPL"); 104MODULE_LICENSE("GPL");