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