freebsd-dev/sys/dev/iicbus
Andriy Gapon 4b869dd71d iicbb: rebuild the bit-banging algorithms using different primitives
I2C_SET was quite inflexible, it used too long delays as well as some
unnecessary delays.  The new building blocks are iicbb_clockin and
iicbb_clockout.  The former sets SDA and starts the high period of SCL,
the latter executes the low period of SCL.  What happens during the high
phase depends on the operation.  For writes we just hold both lines, for
reads we poll SDA.  S, Sr and P change SDA in the middle of the high
period.

Also, the calculation of udelay has been updated, so that the resulting
period more closely corresponds the requested bus frequency.  There is a
new knob, io_delay, that allows to further adjust udelay based on the
estimated latency of pin toggling operations.

Finally, I slightly changed debug tracing and added error indicators to
it.  The debug prints are compiled in but disabled by default.  This can
be of use if there is any fallout from this change.

Some ideas for further improvements:
- add a function for sub-microsecond delays (e.g., in units of 1/10th of
  a microsecond) and use it for more precise timing of short delays;
- account for the actual time spent in the pin I/O.

Some sample debug output with the new code follows.

Reading temperature and humidity from HTU21 in the bus hold mode:
  <<w80+ we3+ <w81+ .....r6d+ rac+ r94- >>
  <<w80+ we5+ <w81+ .............r47+ re2+ r84- >>
where '<<' is S, '<' is Sr, '>>' is P, '.' is one millisecond of clock
stretching by the slave.

Reading temperature and humidity in the no-hold mode:
  <<w80+ wf3+ >>
  <<w81- >>
  <<w81+ r6d+ r54+ raf- >>
  <<w80+ wf5+ >>
  <<w81- >>
  <<w81+ r48+ r4e+ r9c- >>
where '+' is Ack and '-' is NoAck.
We see that first read attempts are not acknowledged.

MFC after:	4 weeks
Differential Revision: https://reviews.freebsd.org/D22206
2020-06-11 05:34:31 +00:00
..
gpio Add TCA6416 GPIO expander support. 2020-05-25 15:31:43 +00:00
mux Remove some trailing whitespace; no functional changes. 2020-01-08 23:06:13 +00:00
rtc Introduce support for Epson RX-8803 RTC. 2020-05-25 15:40:02 +00:00
twsi twsi: Rework how we handle the i2c messages 2020-01-10 18:52:14 +00:00
acpi_iicbus.c acpi_iicbus: set device description in the probe method 2020-04-24 07:55:39 +00:00
ad7417.c Drop 'All rights reserved' 2020-03-06 21:32:42 +00:00
ad7418.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
adm1030.c
ads111x.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
adt746x.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
ds13rtc.c
ds1307.c
ds1307reg.h
ds1631.c Drop 'All rights reserved' 2020-03-06 21:24:09 +00:00
ds1672.c
ds1775.c Drop 'All rights reserved' 2020-03-06 21:26:35 +00:00
ds3231.c
ds3231reg.h
icee.c
if_ic.c
iic_recover_bus.c
iic_recover_bus.h
iic.c
iic.h
iicbb_if.m
iicbb.c iicbb: rebuild the bit-banging algorithms using different primitives 2020-06-11 05:34:31 +00:00
iicbus_if.m
iicbus.c iicbus(4): Add support for ACPI-based children enumeration 2020-03-09 20:31:38 +00:00
iicbus.h iicbus(4): Add support for ACPI-based children enumeration 2020-03-09 20:31:38 +00:00
iicoc_fdt.c
iicoc_pci.c
iicoc.c
iicoc.h
iiconf.c
iiconf.h
iicsmb.c
isl12xx.c
lm75.c
max6690.c - Drop 'All rights reserved' 2020-03-06 21:21:01 +00:00
nxprtc.c
ofw_iicbus.c
rtc8583.c
s35390a.c
sy8106a.c
syr827.c