summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2014-08-20 19:37:05 +0000
committerloos <loos@FreeBSD.org>2014-08-20 19:37:05 +0000
commite4ebeceadb6a37e1ccf33800c4312cceabca6b57 (patch)
treee6d1dad9e555738abec006db57843693485d6beb
parent5efc9173fa69c32dee331f42b6cd63d4b6da7125 (diff)
downloadFreeBSD-src-e4ebeceadb6a37e1ccf33800c4312cceabca6b57.zip
FreeBSD-src-e4ebeceadb6a37e1ccf33800c4312cceabca6b57.tar.gz
MFC r267021:
FreeBSD, historically, has always used 8-bit addresses for i2c devices (7-bit device address << 1), always leaving the room for the read/write bit. This commit convert ti_i2c and revert r259127 on bcm2835_bsc to make them compatible with 8-bit addresses. Previous to this commit an i2c device would have different addresses depending on the controller it was attached to (by example, when compared to any iicbb(4) based i2c controller), which was a pretty annoying behavior. Also, update the PMIC i2c address on beaglebone* DTS files to match the new address scheme. Now the userland utilities need to do the correct slave address shifting (but it is going to work with any i2c controller on the system). Discussed with: ian MFC r267834: Clarify the expected usage of I2C 7-bit slave addresses on ioctl(2) interface. While here add the cross reference to iic(4) on iicbus(4). CR: D210 Suggested by: jmg
-rw-r--r--share/man/man4/iic.419
-rw-r--r--share/man/man4/iicbus.43
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_bsc.c2
-rw-r--r--sys/arm/ti/ti_i2c.c2
-rw-r--r--sys/boot/fdt/dts/arm/beaglebone-black.dts2
-rw-r--r--sys/boot/fdt/dts/arm/beaglebone.dts2
6 files changed, 22 insertions, 8 deletions
diff --git a/share/man/man4/iic.4 b/share/man/man4/iic.4
index 9f410a3..d82f574 100644
--- a/share/man/man4/iic.4
+++ b/share/man/man4/iic.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 6, 2006
+.Dd June 24, 2014
.Dt IIC 4
.Os
.Sh NAME
@@ -51,12 +51,20 @@ following ioctls:
Sends the start condition to the slave specified by the
.Va slave
element to the bus.
+The
+.Va slave
+element consists of a 7-bit address and a read/write bit
+(i.e., 7-bit address << 1 | r/w).
+If the read/write bit is set a read operation is initiated, if the read/write
+bit is cleared a write operation is initiated.
All other elements are ignored.
.It Dv I2CRPTSTART
.Pq Vt "struct iiccmd"
Sends the repeated start condition to the slave specified by the
.Va slave
element to the bus.
+The slave address should be specified as in
+.Dv I2CSTART .
All other elements are ignored.
.It Dv I2CSTOP
No argument is passed.
@@ -115,10 +123,15 @@ is set in
Otherwise the transfer is a write transfer.
The
.Va slave
-element specifies the 7-bit address for the transfer.
+element specifies the 7-bit address with the read/write bit for the transfer.
+The read/write bit will be handled by the iicbus stack based on the specified
+transfer operation.
The
.Va len
-element is the length of the data.
+element is the number of
+.Pq Vt "struct iic_msg"
+messages encoded on
+.Pq Vt "struct iic_rdwr_data" .
The
.Va buf
element is a buffer for that data.
diff --git a/share/man/man4/iicbus.4 b/share/man/man4/iicbus.4
index f9e5c58..e755a42 100644
--- a/share/man/man4/iicbus.4
+++ b/share/man/man4/iicbus.4
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 6, 1998
+.Dd June 24, 2014
.Dt IICBUS 4
.Os
.Sh NAME
@@ -104,6 +104,7 @@ Some I2C interfaces are available:
.It Sy bktr Ta "Brooktree848 video chipset, hardware and software master-only interface"
.El
.Sh SEE ALSO
+.Xr iic 4 ,
.Xr iicbb 4 ,
.Xr lpbb 4 ,
.Xr pcf 4
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
index 33e4769..1e486a4 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
@@ -407,7 +407,7 @@ bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
for (i = 0; i < nmsgs; i++) {
/* Write the slave address. */
- BCM_BSC_WRITE(sc, BCM_BSC_SLAVE, msgs[i].slave);
+ BCM_BSC_WRITE(sc, BCM_BSC_SLAVE, msgs[i].slave >> 1);
/* Write the data length. */
BCM_BSC_WRITE(sc, BCM_BSC_DLEN, msgs[i].len);
diff --git a/sys/arm/ti/ti_i2c.c b/sys/arm/ti/ti_i2c.c
index e4b7b58..19e2a89 100644
--- a/sys/arm/ti/ti_i2c.c
+++ b/sys/arm/ti/ti_i2c.c
@@ -747,7 +747,7 @@ ti_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
}
/* set the slave address */
- ti_i2c_write_reg(sc, I2C_REG_SA, msgs[i].slave);
+ ti_i2c_write_reg(sc, I2C_REG_SA, msgs[i].slave >> 1);
/* perform the read or write */
if (msgs[i].flags & IIC_M_RD) {
diff --git a/sys/boot/fdt/dts/arm/beaglebone-black.dts b/sys/boot/fdt/dts/arm/beaglebone-black.dts
index 0efae4d..3c9a0f1 100644
--- a/sys/boot/fdt/dts/arm/beaglebone-black.dts
+++ b/sys/boot/fdt/dts/arm/beaglebone-black.dts
@@ -149,7 +149,7 @@
i2c@44e0b000 {
pmic@24 {
compatible = "ti,am335x-pmic";
- reg = <0x24>;
+ reg = <0x48>;
};
};
};
diff --git a/sys/boot/fdt/dts/arm/beaglebone.dts b/sys/boot/fdt/dts/arm/beaglebone.dts
index 3f8e022..83b948f 100644
--- a/sys/boot/fdt/dts/arm/beaglebone.dts
+++ b/sys/boot/fdt/dts/arm/beaglebone.dts
@@ -133,7 +133,7 @@
i2c@44e0b000 {
pmic@24 {
compatible = "ti,am335x-pmic";
- reg = <0x24>;
+ reg = <0x48>;
};
};
};
OpenPOWER on IntegriCloud