summaryrefslogtreecommitdiffstats
path: root/sys/dev/iicbus/iicbus.c
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2011-12-04 11:55:33 +0000
committeradrian <adrian@FreeBSD.org>2011-12-04 11:55:33 +0000
commit1753897673ab41a6d5c02010119b10aeddaac407 (patch)
treeab4a497dafccf9d80a8902ec45b48b4b714ea20a /sys/dev/iicbus/iicbus.c
parent79fb007af39a4d5179411241cb54f9282075972a (diff)
downloadFreeBSD-src-1753897673ab41a6d5c02010119b10aeddaac407.zip
FreeBSD-src-1753897673ab41a6d5c02010119b10aeddaac407.tar.gz
Allow the i2c node requirements to be slightly relaxed.
These realtek switch PHYs speak a variant of i2c with some slightly modified handling. From the submitter, slightly modified now that some further digging has been done: The I2C framework makes a assumption that the read/not-write bit of the first byte (the address) indicates whether reads or writes are to follow. The RTL8366 family uses the bus: after sending the address+read/not-write byte, two register address bytes are sent, then the 16-bit register value is sent or received. While the register write access can be performed as a 4-byte write, the read access requires the read bit to be set, but the first two bytes for the register address then need to be transmitted. This patch maintains the i2c protocol behaviour but allows it to be relaxed (for these kinds of switch PHYs, and whatever else Realtek may do with this almost-but-not-quite i2c bus) - by setting the "strict" hint to 0. The "strict" hint defaults to 1. Submitted by: Stefan Bethke <stb@lassitu.de>
Diffstat (limited to 'sys/dev/iicbus/iicbus.c')
-rw-r--r--sys/dev/iicbus/iicbus.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c
index 121b25b..d919277 100644
--- a/sys/dev/iicbus/iicbus.c
+++ b/sys/dev/iicbus/iicbus.c
@@ -92,10 +92,16 @@ iicbus_attach(device_t dev)
unsigned char addr;
#endif
struct iicbus_softc *sc = IICBUS_SOFTC(dev);
+ int strict;
sc->dev = dev;
mtx_init(&sc->lock, "iicbus", NULL, MTX_DEF);
iicbus_reset(dev, IIC_FASTEST, 0, NULL);
+ if (resource_int_value(device_get_name(dev),
+ device_get_unit(dev), "strict", &strict) == 0)
+ sc->strict = strict;
+ else
+ sc->strict = 1;
/* device probing is meaningless since the bus is supposed to be
* hot-plug. Moreover, some I2C chips do not appreciate random
OpenPOWER on IntegriCloud