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