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