w1.generic 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. The 1-wire (w1) subsystem
  2. ------------------------------------------------------------------
  3. The 1-wire bus is a simple master-slave bus that communicates via a single
  4. signal wire (plus ground, so two wires).
  5. Devices communicate on the bus by pulling the signal to ground via an open
  6. drain output and by sampling the logic level of the signal line.
  7. The w1 subsystem provides the framework for managing w1 masters and
  8. communication with slaves.
  9. All w1 slave devices must be connected to a w1 bus master device.
  10. Example w1 master devices:
  11. DS9490 usb device
  12. W1-over-GPIO
  13. DS2482 (i2c to w1 bridge)
  14. Emulated devices, such as a RS232 converter, parallel port adapter, etc
  15. What does the w1 subsystem do?
  16. ------------------------------------------------------------------
  17. When a w1 master driver registers with the w1 subsystem, the following occurs:
  18. - sysfs entries for that w1 master are created
  19. - the w1 bus is periodically searched for new slave devices
  20. When a device is found on the bus, w1 core checks if driver for it's family is
  21. loaded. If so, the family driver is attached to the slave.
  22. If there is no driver for the family, a simple sysfs entry is created
  23. for the slave device.
  24. W1 device families
  25. ------------------------------------------------------------------
  26. Slave devices are handled by a driver written for a family of w1 devices.
  27. A family driver populates a struct w1_family_ops (see w1_family.h) and
  28. registers with the w1 subsystem.
  29. Current family drivers:
  30. w1_therm - (ds18?20 thermal sensor family driver)
  31. provides temperature reading function which is bound to ->rbin() method
  32. of the above w1_family_ops structure.
  33. w1_smem - driver for simple 64bit memory cell provides ID reading method.
  34. You can call above methods by reading appropriate sysfs files.
  35. What does a w1 master driver need to implement?
  36. ------------------------------------------------------------------
  37. The driver for w1 bus master must provide at minimum two functions.
  38. Emulated devices must provide the ability to set the output signal level
  39. (write_bit) and sample the signal level (read_bit).
  40. Devices that support the 1-wire natively must provide the ability to write and
  41. sample a bit (touch_bit) and reset the bus (reset_bus).
  42. Most hardware provides higher-level functions that offload w1 handling.
  43. See struct w1_bus_master definition in w1.h for details.
  44. w1 master sysfs interface
  45. ------------------------------------------------------------------
  46. <xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial
  47. bus - (standard) symlink to the w1 bus
  48. driver - (standard) symlink to the w1 driver
  49. w1_master_attempts - the number of times a search was attempted
  50. w1_master_max_slave_count
  51. - the maximum slaves that may be attached to a master
  52. w1_master_name - the name of the device (w1_bus_masterX)
  53. w1_master_search - the number of searches left to do, -1=continual (default)
  54. w1_master_slave_count
  55. - the number of slaves found
  56. w1_master_slaves - the names of the slaves, one per line
  57. w1_master_timeout - the delay in seconds between searches
  58. If you have a w1 bus that never changes (you don't add or remove devices),
  59. you can set w1_master_search to a positive value to disable searches.
  60. w1 slave sysfs interface
  61. ------------------------------------------------------------------
  62. bus - (standard) symlink to the w1 bus
  63. driver - (standard) symlink to the w1 driver
  64. name - the device name, usually the same as the directory name
  65. w1_slave - (optional) a binary file whose meaning depends on the
  66. family driver