i2c-stub 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. MODULE: i2c-stub
  2. DESCRIPTION:
  3. This module is a very simple fake I2C/SMBus driver. It implements four
  4. types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and
  5. (r/w) word data.
  6. No hardware is needed nor associated with this module. It will accept write
  7. quick commands to all addresses; it will respond to the other commands (also
  8. to all addresses) by reading from or writing to an array in memory. It will
  9. also spam the kernel logs for every command it handles.
  10. A pointer register with auto-increment is implemented for all byte
  11. operations. This allows for continuous byte reads like those supported by
  12. EEPROMs, among others.
  13. The typical use-case is like this:
  14. 1. load this module
  15. 2. use i2cset (from lm_sensors project) to pre-load some data
  16. 3. load the target sensors chip driver module
  17. 4. observe its behavior in the kernel log
  18. CAVEATS:
  19. There are independent arrays for byte/data and word/data commands. Depending
  20. on if/how a target driver mixes them, you'll need to be careful.
  21. If your target driver polls some byte or word waiting for it to change, the
  22. stub could lock it up. Use i2cset to unlock it.
  23. If the hardware for your driver has banked registers (e.g. Winbond sensors
  24. chips) this module will not work well - although it could be extended to
  25. support that pretty easily.
  26. If you spam it hard enough, printk can be lossy. This module really wants
  27. something like relayfs.