i2c-stub 1.6 KB

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