xref: /OK3568_Linux_fs/kernel/Documentation/hwmon/pcf8591.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunKernel driver pcf8591
2*4882a593Smuzhiyun=====================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunSupported chips:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun  * Philips/NXP PCF8591
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun    Prefix: 'pcf8591'
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun    Addresses scanned: none
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun    Datasheet: Publicly available at the NXP website
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun	       http://www.nxp.com/pip/PCF8591_6.html
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunAuthors:
17*4882a593Smuzhiyun      - Aurelien Jarno <aurelien@aurel32.net>
18*4882a593Smuzhiyun      - valuable contributions by Jan M. Sendler <sendler@sendler.de>,
19*4882a593Smuzhiyun      - Jean Delvare <jdelvare@suse.de>
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunDescription
23*4882a593Smuzhiyun-----------
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunThe PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one
26*4882a593Smuzhiyunanalog output) for the I2C bus produced by Philips Semiconductors (now NXP).
27*4882a593SmuzhiyunIt is designed to provide a byte I2C interface to up to 4 separate devices.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunThe PCF8591 has 4 analog inputs programmable as single-ended or
30*4882a593Smuzhiyundifferential inputs:
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun- mode 0 : four single ended inputs
33*4882a593Smuzhiyun	Pins AIN0 to AIN3 are single ended inputs for channels 0 to 3
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun- mode 1 : three differential inputs
36*4882a593Smuzhiyun	Pins AIN3 is the common negative differential input
37*4882a593Smuzhiyun	Pins AIN0 to AIN2 are positive differential inputs for channels 0 to 2
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun- mode 2 : single ended and differential mixed
40*4882a593Smuzhiyun	Pins AIN0 and AIN1 are single ended inputs for channels 0 and 1
41*4882a593Smuzhiyun	Pins AIN2 is the positive differential input for channel 3
42*4882a593Smuzhiyun	Pins AIN3 is the negative differential input for channel 3
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun- mode 3 : two differential inputs
45*4882a593Smuzhiyun	Pins AIN0 is the positive differential input for channel 0
46*4882a593Smuzhiyun	Pins AIN1 is the negative differential input for channel 0
47*4882a593Smuzhiyun	Pins AIN2 is the positive differential input for channel 1
48*4882a593Smuzhiyun	Pins AIN3 is the negative differential input for channel 1
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunSee the datasheet for details.
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunModule parameters
53*4882a593Smuzhiyun-----------------
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun* input_mode int
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun    Analog input mode:
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun	 - 0 = four single ended inputs
60*4882a593Smuzhiyun	 - 1 = three differential inputs
61*4882a593Smuzhiyun	 - 2 = single ended and differential mixed
62*4882a593Smuzhiyun	 - 3 = two differential inputs
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun
65*4882a593SmuzhiyunAccessing PCF8591 via /sys interface
66*4882a593Smuzhiyun-------------------------------------
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunThe PCF8591 is plainly impossible to detect! Thus the driver won't even
69*4882a593Smuzhiyuntry. You have to explicitly instantiate the device at the relevant
70*4882a593Smuzhiyunaddress (in the interval [0x48..0x4f]) either through platform data, or
71*4882a593Smuzhiyunusing the sysfs interface. See Documentation/i2c/instantiating-devices.rst
72*4882a593Smuzhiyunfor details.
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunDirectories are being created for each instantiated PCF8591:
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun/sys/bus/i2c/devices/<0>-<1>/
77*4882a593Smuzhiyun   where <0> is the bus the chip is connected to (e. g. i2c-0)
78*4882a593Smuzhiyun   and <1> the chip address ([48..4f])
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunInside these directories, there are such files:
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun   in0_input, in1_input, in2_input, in3_input, out0_enable, out0_output, name
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunName contains chip name.
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunThe in0_input, in1_input, in2_input and in3_input files are RO. Reading gives
87*4882a593Smuzhiyunthe value of the corresponding channel. Depending on the current analog inputs
88*4882a593Smuzhiyunconfiguration, files in2_input and in3_input may not exist. Values range
89*4882a593Smuzhiyunfrom 0 to 255 for single ended inputs and -128 to +127 for differential inputs
90*4882a593Smuzhiyun(8-bit ADC).
91*4882a593Smuzhiyun
92*4882a593SmuzhiyunThe out0_enable file is RW. Reading gives "1" for analog output enabled and
93*4882a593Smuzhiyun"0" for analog output disabled. Writing accepts "0" and "1" accordingly.
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunThe out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send
96*4882a593Smuzhiyunthe value to the digital-to-analog converter. Note that a voltage will
97*4882a593Smuzhiyunonly appears on AOUT pin if aout0_enable equals 1. Reading returns the last
98*4882a593Smuzhiyunvalue written.
99