1*4882a593Smuzhiyun===================== 2*4882a593SmuzhiyunKernel driver max6875 3*4882a593Smuzhiyun===================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunSupported chips: 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun * Maxim MAX6874, MAX6875 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun Prefix: 'max6875' 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun Addresses scanned: None (see below) 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunAuthor: Ben Gardner <bgardner@wabtec.com> 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunDescription 19*4882a593Smuzhiyun----------- 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunThe Maxim MAX6875 is an EEPROM-programmable power-supply sequencer/supervisor. 22*4882a593SmuzhiyunIt provides timed outputs that can be used as a watchdog, if properly wired. 23*4882a593SmuzhiyunIt also provides 512 bytes of user EEPROM. 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunAt reset, the MAX6875 reads the configuration EEPROM into its configuration 26*4882a593Smuzhiyunregisters. The chip then begins to operate according to the values in the 27*4882a593Smuzhiyunregisters. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunThe Maxim MAX6874 is a similar, mostly compatible device, with more inputs 30*4882a593Smuzhiyunand outputs: 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun=========== === === ==== 33*4882a593Smuzhiyun- vin gpi vout 34*4882a593Smuzhiyun=========== === === ==== 35*4882a593SmuzhiyunMAX6874 6 4 8 36*4882a593SmuzhiyunMAX6875 4 3 5 37*4882a593Smuzhiyun=========== === === ==== 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunSee the datasheet for more information. 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunSysfs entries 43*4882a593Smuzhiyun------------- 44*4882a593Smuzhiyun 45*4882a593Smuzhiyuneeprom - 512 bytes of user-defined EEPROM space. 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunGeneral Remarks 49*4882a593Smuzhiyun--------------- 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunValid addresses for the MAX6875 are 0x50 and 0x52. 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunValid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56. 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunThe driver does not probe any address, so you explicitly instantiate the 56*4882a593Smuzhiyundevices. 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunExample:: 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun $ modprobe max6875 61*4882a593Smuzhiyun $ echo max6875 0x50 > /sys/bus/i2c/devices/i2c-0/new_device 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunThe MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple 64*4882a593Smuzhiyunaddresses. For example, for address 0x50, it also reserves 0x51. 65*4882a593SmuzhiyunThe even-address instance is called 'max6875', the odd one is 'dummy'. 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun 68*4882a593SmuzhiyunProgramming the chip using i2c-dev 69*4882a593Smuzhiyun---------------------------------- 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunUse the i2c-dev interface to access and program the chips. 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunReads and writes are performed differently depending on the address range. 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunThe configuration registers are at addresses 0x00 - 0x45. 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunUse i2c_smbus_write_byte_data() to write a register and 78*4882a593Smuzhiyuni2c_smbus_read_byte_data() to read a register. 79*4882a593Smuzhiyun 80*4882a593SmuzhiyunThe command is the register number. 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunExamples: 83*4882a593Smuzhiyun 84*4882a593SmuzhiyunTo write a 1 to register 0x45:: 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun i2c_smbus_write_byte_data(fd, 0x45, 1); 87*4882a593Smuzhiyun 88*4882a593SmuzhiyunTo read register 0x45:: 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun value = i2c_smbus_read_byte_data(fd, 0x45); 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun 93*4882a593SmuzhiyunThe configuration EEPROM is at addresses 0x8000 - 0x8045. 94*4882a593Smuzhiyun 95*4882a593SmuzhiyunThe user EEPROM is at addresses 0x8100 - 0x82ff. 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunUse i2c_smbus_write_word_data() to write a byte to EEPROM. 98*4882a593Smuzhiyun 99*4882a593SmuzhiyunThe command is the upper byte of the address: 0x80, 0x81, or 0x82. 100*4882a593SmuzhiyunThe data word is the lower part of the address or'd with data << 8:: 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun cmd = address >> 8; 103*4882a593Smuzhiyun val = (address & 0xff) | (data << 8); 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunExample: 106*4882a593Smuzhiyun 107*4882a593SmuzhiyunTo write 0x5a to address 0x8003:: 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun i2c_smbus_write_word_data(fd, 0x80, 0x5a03); 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun 112*4882a593SmuzhiyunReading data from the EEPROM is a little more complicated. 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunUse i2c_smbus_write_byte_data() to set the read address and then 115*4882a593Smuzhiyuni2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data. 116*4882a593Smuzhiyun 117*4882a593SmuzhiyunExample: 118*4882a593Smuzhiyun 119*4882a593SmuzhiyunTo read data starting at offset 0x8100, first set the address:: 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun i2c_smbus_write_byte_data(fd, 0x81, 0x00); 122*4882a593Smuzhiyun 123*4882a593SmuzhiyunAnd then read the data:: 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun value = i2c_smbus_read_byte(fd); 126*4882a593Smuzhiyun 127*4882a593Smuzhiyunor:: 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun count = i2c_smbus_read_i2c_block_data(fd, 0x84, 16, buffer); 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunThe block read should read 16 bytes. 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun0x84 is the block read command. 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunSee the datasheet for more details. 136*4882a593Smuzhiyun 137