max6875 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Kernel driver max6875
  2. =====================
  3. Supported chips:
  4. * Maxim MAX6874, MAX6875
  5. Prefix: 'max6875'
  6. Addresses scanned: None (see below)
  7. Datasheet:
  8. http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
  9. Author: Ben Gardner <bgardner@wabtec.com>
  10. Description
  11. -----------
  12. The Maxim MAX6875 is an EEPROM-programmable power-supply sequencer/supervisor.
  13. It provides timed outputs that can be used as a watchdog, if properly wired.
  14. It also provides 512 bytes of user EEPROM.
  15. At reset, the MAX6875 reads the configuration EEPROM into its configuration
  16. registers. The chip then begins to operate according to the values in the
  17. registers.
  18. The Maxim MAX6874 is a similar, mostly compatible device, with more inputs
  19. and outputs:
  20. vin gpi vout
  21. MAX6874 6 4 8
  22. MAX6875 4 3 5
  23. See the datasheet for more information.
  24. Sysfs entries
  25. -------------
  26. eeprom - 512 bytes of user-defined EEPROM space.
  27. General Remarks
  28. ---------------
  29. Valid addresses for the MAX6875 are 0x50 and 0x52.
  30. Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56.
  31. The driver does not probe any address, so you explicitly instantiate the
  32. devices.
  33. Example:
  34. $ modprobe max6875
  35. $ echo max6875 0x50 > /sys/bus/i2c/devices/i2c-0/new_device
  36. The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple
  37. addresses. For example, for address 0x50, it also reserves 0x51.
  38. The even-address instance is called 'max6875', the odd one is 'dummy'.
  39. Programming the chip using i2c-dev
  40. ----------------------------------
  41. Use the i2c-dev interface to access and program the chips.
  42. Reads and writes are performed differently depending on the address range.
  43. The configuration registers are at addresses 0x00 - 0x45.
  44. Use i2c_smbus_write_byte_data() to write a register and
  45. i2c_smbus_read_byte_data() to read a register.
  46. The command is the register number.
  47. Examples:
  48. To write a 1 to register 0x45:
  49. i2c_smbus_write_byte_data(fd, 0x45, 1);
  50. To read register 0x45:
  51. value = i2c_smbus_read_byte_data(fd, 0x45);
  52. The configuration EEPROM is at addresses 0x8000 - 0x8045.
  53. The user EEPROM is at addresses 0x8100 - 0x82ff.
  54. Use i2c_smbus_write_word_data() to write a byte to EEPROM.
  55. The command is the upper byte of the address: 0x80, 0x81, or 0x82.
  56. The data word is the lower part of the address or'd with data << 8.
  57. cmd = address >> 8;
  58. val = (address & 0xff) | (data << 8);
  59. Example:
  60. To write 0x5a to address 0x8003:
  61. i2c_smbus_write_word_data(fd, 0x80, 0x5a03);
  62. Reading data from the EEPROM is a little more complicated.
  63. Use i2c_smbus_write_byte_data() to set the read address and then
  64. i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data.
  65. Example:
  66. To read data starting at offset 0x8100, first set the address:
  67. i2c_smbus_write_byte_data(fd, 0x81, 0x00);
  68. And then read the data
  69. value = i2c_smbus_read_byte(fd);
  70. or
  71. count = i2c_smbus_read_i2c_block_data(fd, 0x84, 16, buffer);
  72. The block read should read 16 bytes.
  73. 0x84 is the block read command.
  74. See the datasheet for more details.