lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140722150250.GE7845@dashie>
Date:	Tue, 22 Jul 2014 17:02:50 +0200
From:	Josef Gajdusek <atx@...lax.net>
To:	linux-iio@...r.kernel.org
Cc:	devel@...verdev.osuosl.org, gregkh@...uxfoundation.org,
	jic23@...nel.org, linux-kernel@...r.kernel.org, pmeerw@...erw.net,
	dan.carpenter@...cle.com, lars@...afoo.de
Subject: [PATCH v5 (staging-next) 4/5] 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@....name>
---
 .../devicetree/bindings/iio/magnetometer/hmc5843.txt |  1 +
 drivers/staging/iio/magnetometer/Kconfig             |  2 +-
 drivers/staging/iio/magnetometer/hmc5843.h           |  1 +
 drivers/staging/iio/magnetometer/hmc5843_core.c      | 20 +++++++++++++++++---
 drivers/staging/iio/magnetometer/hmc5843_i2c.c       |  6 ++++--
 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 b8cbdd5..8e191ee 100644
--- a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt
+++ b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt
@@ -6,6 +6,7 @@ Required properties:
   Other models which are supported with driver are:
 	"honeywell,hmc5883"
 	"honeywell,hmc5883l"
+	"honeywell,hmc5983"
   - reg : the I2C address of the magnetometer - typically 0x1e
 
 Optional properties:
diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig
index 0a27f98..c086f33 100644
--- a/drivers/staging/iio/magnetometer/Kconfig
+++ b/drivers/staging/iio/magnetometer/Kconfig
@@ -20,6 +20,6 @@ config SENSORS_HMC5843_I2C
 	  This driver can also be compiled as a set of modules.
 	  If so, these modules will be created:
 	  - hmc5843_core (core functions)
-	  - hmc5843_i2c (support for HMC5843, HMC5883 and HMC5883L)
+	  - hmc5843_i2c (support for HMC5843, HMC5883, HMC5883L and HMC5983)
 
 endmenu
diff --git a/drivers/staging/iio/magnetometer/hmc5843.h b/drivers/staging/iio/magnetometer/hmc5843.h
index 06b2712..b784e3e 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.h
+++ b/drivers/staging/iio/magnetometer/hmc5843.h
@@ -29,6 +29,7 @@ enum hmc5843_ids {
 	HMC5843_ID,
 	HMC5883_ID,
 	HMC5883L_ID,
+	HMC5983_ID,
 };
 
 struct hmc5843_data {
diff --git a/drivers/staging/iio/magnetometer/hmc5843_core.c b/drivers/staging/iio/magnetometer/hmc5843_core.c
index 08fb0be..914ae1a 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] = {
 	{75, 0}
 };
 
+static const int hmc5983_regval_to_samp_freq[][2] = {
+	{0, 750000}, {1, 500000}, {3, 0}, {7, 500000}, {15, 0}, {30, 0},
+	{75, 0}, {220, 0}
+};
+
 /* Describe chip variants */
 struct hmc5843_chip_info {
 	const struct iio_chan_spec *channels;
@@ -457,7 +462,7 @@ static const struct iio_chan_spec hmc5843_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
-/* Beware: Y and Z are exchanged on HMC5883 */
+/* Beware: Y and Z are exchanged on HMC5883 and 5983 */
 static const struct iio_chan_spec hmc5883_channels[] = {
 	HMC5843_CHANNEL(X, 0),
 	HMC5843_CHANNEL(Z, 1),
@@ -504,6 +509,15 @@ static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = {
 		.n_regval_to_nanoscale =
 				ARRAY_SIZE(hmc5883l_regval_to_nanoscale),
 	},
+	[HMC5983_ID] = {
+		.channels = hmc5883_channels,
+		.regval_to_samp_freq = hmc5983_regval_to_samp_freq,
+		.n_regval_to_samp_freq =
+				ARRAY_SIZE(hmc5983_regval_to_samp_freq),
+		.regval_to_nanoscale = hmc5883l_regval_to_nanoscale,
+		.n_regval_to_nanoscale =
+				ARRAY_SIZE(hmc5883l_regval_to_nanoscale),
+	}
 };
 
 static int hmc5843_init(struct hmc5843_data *data)
@@ -516,7 +530,7 @@ static int hmc5843_init(struct hmc5843_data *data)
 	if (ret < 0)
 		return ret;
 	if (id[0] != 'H' || id[1] != '4' || id[2] != '3') {
-		dev_err(data->dev, "no HMC5843/5883/5883L sensor\n");
+		dev_err(data->dev, "no HMC5843/5883/5883L/5983 sensor\n");
 		return -ENODEV;
 	}
 
@@ -620,5 +634,5 @@ int hmc5843_common_remove(struct device *dev)
 EXPORT_SYMBOL(hmc5843_common_remove);
 
 MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@...com>");
-MODULE_DESCRIPTION("HMC5843/5883/5883L core driver");
+MODULE_DESCRIPTION("HMC5843/5883/5883L/5983 core driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
index 5593a7d..6acd614 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
@@ -1,5 +1,5 @@
 /*
- * i2c driver for hmc5843/5843/5883/5883l
+ * i2c driver for hmc5843/5843/5883/5883l/5983
  *
  * Split from hmc5843.c
  * Copyright (C) Josef Gajdusek <atx@....name>
@@ -73,6 +73,7 @@ static const struct i2c_device_id hmc5843_id[] = {
 	{ "hmc5843", HMC5843_ID },
 	{ "hmc5883", HMC5883_ID },
 	{ "hmc5883l", HMC5883L_ID },
+	{ "hmc5983", HMC5983_ID },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, hmc5843_id);
@@ -81,6 +82,7 @@ static const struct of_device_id hmc5843_of_match[] = {
 	{ .compatible = "honeywell,hmc5843", .data = (void *)HMC5843_ID },
 	{ .compatible = "honeywell,hmc5883", .data = (void *)HMC5883_ID },
 	{ .compatible = "honeywell,hmc5883l", .data = (void *)HMC5883L_ID },
+	{ .compatible = "honeywell,hmc5983", .data = (void *)HMC5983_ID },
 	{}
 };
 MODULE_DEVICE_TABLE(of, hmc5843_of_match);
@@ -98,5 +100,5 @@ static struct i2c_driver hmc5843_driver = {
 module_i2c_driver(hmc5843_driver);
 
 MODULE_AUTHOR("Josef Gajdusek <atx@....name>");
-MODULE_DESCRIPTION("HMC5843/5883/5883L i2c driver");
+MODULE_DESCRIPTION("HMC5843/5883/5883L/5983 i2c driver");
 MODULE_LICENSE("GPL");
-- 
1.8.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ