i2c-stub 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. You need to provide a chip address as a module parameter when loading
  7. this driver, which will then only react to SMBus commands to this address.
  8. No hardware is needed nor associated with this module. It will accept write
  9. quick commands to one address; it will respond to the other commands (also
  10. to one address) by reading from or writing to an array in memory. It will
  11. also spam the kernel logs for every command it handles.
  12. A pointer register with auto-increment is implemented for all byte
  13. operations. This allows for continuous byte reads like those supported by
  14. EEPROMs, among others.
  15. The typical use-case is like this:
  16. 1. load this module
  17. 2. use i2cset (from lm_sensors project) to pre-load some data
  18. 3. load the target sensors chip driver module
  19. 4. observe its behavior in the kernel log
  20. PARAMETERS:
  21. int chip_addr:
  22. The SMBus address to emulate a chip at.
  23. CAVEATS:
  24. There are independent arrays for byte/data and word/data commands. Depending
  25. on if/how a target driver mixes them, you'll need to be careful.
  26. If your target driver polls some byte or word waiting for it to change, the
  27. stub could lock it up. Use i2cset to unlock it.
  28. If the hardware for your driver has banked registers (e.g. Winbond sensors
  29. chips) this module will not work well - although it could be extended to
  30. support that pretty easily.
  31. Only one chip address is supported - although this module could be
  32. extended to support more.
  33. If you spam it hard enough, printk can be lossy. This module really wants
  34. something like relayfs.