Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476960 > unrolled thread

[PATCH 0/3] LEGO MINDSTORMS I2C support

Started byDavid Lechner <david@lechnology.com>
First post2016-09-05 22:50 +0200
Last post2016-09-05 22:50 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] LEGO MINDSTORMS I2C support David Lechner <david@lechnology.com> - 2016-09-05 22:50 +0200
    [PATCH 2/3] i2c: Add special case for detecting LEGO devices David Lechner <david@lechnology.com> - 2016-09-05 22:50 +0200

#1476960 — [PATCH 0/3] LEGO MINDSTORMS I2C support

FromDavid Lechner <david@lechnology.com>
Date2016-09-05 22:50 +0200
Subject[PATCH 0/3] LEGO MINDSTORMS I2C support
Message-ID<se905-nd-7@gated-at.bofh.it>
I'm working on getting LEGO MINDSTORMS[1] support in the Linux kernel.

They have a system of modular sensors that are hot-plugable, some of which use
I2C communications. Unfortunately, these don't necessary follow standard I2C
conventions, but they do have a well-defined register layout, so they are
easy to detect.

This set of patches addresses the hot-plugability of the sensors.

[1]: http://mindstorms.lego.com


David Lechner (3):
  i2c: Add class for LEGO MINDSTORMS sensors
  i2c: Add special case for detecting LEGO devices
  i2c: expose adapter probe and remove probed functions

 drivers/i2c/i2c-core.c | 62 ++++++++++++++++++++++++++++++++++++++------------
 include/linux/i2c.h    |  4 ++++
 2 files changed, 52 insertions(+), 14 deletions(-)

-- 
2.7.4

[toc] | [next] | [standalone]


#1476963 — [PATCH 2/3] i2c: Add special case for detecting LEGO devices

FromDavid Lechner <david@lechnology.com>
Date2016-09-05 22:50 +0200
Subject[PATCH 2/3] i2c: Add special case for detecting LEGO devices
Message-ID<se906-nd-23@gated-at.bofh.it>
In reply to#1476960
LEGO chose to ignore the I2C specification and has created devices with
I2C addresses of 0x01 and 0x02. i2c_check_7bit_addr_validity_strict()
disallows these addresses, so we need a special case to skip this for
LEGO sensors.

Furthermore, LEGO devices do not respond to i2c_default_probe(), so we
skip this as a special case as well.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/i2c/i2c-core.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index da3a02e..28436d9 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2591,12 +2591,14 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 	int addr = temp_client->addr;
 	int err;
 
-	/* Make sure the address is valid */
-	err = i2c_check_7bit_addr_validity_strict(addr);
-	if (err) {
-		dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
-			 addr);
-		return err;
+	/* Make sure the address is valid - LEGO devices break the rules */
+	if (!(driver->class & I2C_CLASS_LEGO)) {
+		err = i2c_check_7bit_addr_validity_strict(addr);
+		if (err) {
+			dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
+				 addr);
+			return err;
+		}
 	}
 
 	/* Skip if already in use (7 bit, no need to encode flags) */
@@ -2604,7 +2606,8 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 		return 0;
 
 	/* Make sure there is something at this address */
-	if (!i2c_default_probe(adapter, addr))
+	if (!(driver->class & I2C_CLASS_LEGO) &&
+	    !i2c_default_probe(adapter, addr))
 		return 0;
 
 	/* Finally call the custom detection function */
-- 
2.7.4

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web