Implement 1wire bus.
(also includes mfifles patches not yet in the tree)
Differential D2956
1 wire stuff: basics and temperature imp on Jun 30 2015, 2:24 PM. Authored by Tags None Referenced Files
Details
Diff Detail
Event TimelineThere are a very large number of changes, so older changes are hidden. Show Older Changes
Comment Actions Tested with Banana Pi and one DS1820 (or maybe DS18S20): owc0: <FDT GPIO attached one-wire bus> at pin(s) 275 on gpiobus0 ow0: <1 Wire Bus> on owc0 ow_temp0: <One Wire Temperature> romid 10:20:26:b6:00:08:00:c7 on ow0 # sysctl dev.ow_temp dev.ow_temp.0.parasite: 0 dev.ow_temp.0.reading_interval: 1000 dev.ow_temp.0.badread: 0 dev.ow_temp.0.badcrc: 14 dev.ow_temp.0.temperature: 363 dev.ow_temp.0.%parent: ow0 dev.ow_temp.0.%pnpinfo: romid=10:20:26:b6:00:08:00:c7 dev.ow_temp.0.%location: dev.ow_temp.0.%driver: ow_temp dev.ow_temp.0.%desc: One Wire Temperature dev.ow_temp.%parent: # sysctl dev.ow_temp.0.temperature | cut -f 2 -d: | awk '{ printf "%.4f\n", $1 / 16 }' 22.6875 I also added the following to build the 1-wire support in kernel (not as a module): Index: sys/conf/files =================================================================== --- sys/conf/files (revision 285250) +++ sys/conf/files (working copy) @@ -2014,6 +2014,13 @@ dev/ofw/ofwbus.c optional fdt dev/ofw/openfirm.c optional fdt dev/ofw/openfirmio.c optional fdt +dev/ow/ow.c optional ow \ + dependency "owll_if.h" \ + dependency "own_if.h" +dev/ow/owll_if.m optional ow +dev/ow/own_if.m optional ow +dev/ow/ow_temp.c optional ow_temp +dev/ow/owc_gpiobus.c optional owc gpio dev/patm/if_patm.c optional patm pci dev/patm/if_patm_attach.c optional patm pci dev/patm/if_patm_intr.c optional patm pci All the CRC errors I've seen so far are '0' that are read as '1': ow_temp0: ow_temp_event_thread: scratch reg: 2b:00:4b:46:ff:ff:03:10:4e == crc: 0x4e (CRC match) ow_temp0: ow_temp_event_thread: scratch reg: 2b:00:4b:46:ff:ff:02:10:8a == crc: 0x8a (CRC match) ow_temp0: ow_temp_event_thread: scratch reg: 2b:02:4b:46:ff:ff:02:10:8a == crc: 0xf0 ^^ ow_temp0: ow_temp_event_thread: scratch reg: 6b:00:4b:46:ff:ff:03:10:4e == crc: 0x7 ^^ ow_temp0: ow_temp_event_thread: scratch reg: 2b:00:4b:47:ff:ff:03:10:4e == crc: 0x83 ^^ ow_temp0: ow_temp_event_thread: scratch reg: 2b:00:6b:46:ff:ff:06:10:b1 == crc: 0x7 ^^ Do you think we need to GETBUS() and RELBUS() for each bit sent or received ? I think this is okay because it is the master that controls the slave timing, so this won't break the transfer if another child takes the bus between two bits. This was very well thought, thank you for making this happen.
Comment Actions Again, Phabricator is showing these as completely deleting the old version of the file and then completely adding the new one. That makes it very hard to tell what has changed, so please pardon fragmentary comments that might overlap old ones. There might be a way to submit the diff that would work better. I don't know, I use the web interface to avoid installing PHP.
Comment Actions Added, thanks.
This suggests that we're polling late. Perhaps DELAY is DELAYING too long? I'm away from my hardware right now, but I was thinking of getting the time before we drive the line low, drive the line low and let it float high and start polling and compute a the time after we see it float high to figure out if it is a zero or one. At least as a debugging process, if not for actual operation. It's a busy wait either way...
I don't think that we need to do this. The enumerate code is effectively single threaded.
You're welcome. Thanks for testing! Comment Actions Update based on Warren Block's feedback. Didn't do everything but should have done most things. Comment Actions Phabricator again has made it impossible to compare original with new. How about if I download the raw diff, edit the files, then send you a resulting diff? (Sorry.) Comment Actions Found a double free() while trying the modules. How to reproduce: kldload ow_temp And I need this include to fix a build error (missing definition of struct ow_timing) : --- sys/dev/ow/owll_if.m.orig 2015-07-15 21:53:38.524415000 -0300 +++ sys/dev/ow/owll_if.m 2015-07-15 21:53:46.177856000 -0300 @@ -27,6 +27,7 @@ # #include <sys/bus.h> +#include <dev/ow/owll.h> INTERFACE owll;
Comment Actions but owll.h includes owll_if.h which creates a circular dependency, no? only owll.h should be used. What's the compile error without this? Comment Actions Go to oversampling the read pulses. This increases accuracy, slightly, Poll for the rest pulse a little later to avoid some false positives Start reporting in milliKelvin. Changes to sysctl are needed for this |