]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ads111x.4
MFV r356143:
[FreeBSD/FreeBSD.git] / share / man / man4 / ads111x.4
1 .\"
2 .\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\"
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd September 2, 2019
28 .Dt ADS111x 4
29 .Os
30 .Sh NAME
31 .Nm ads111x
32 .Nd driver for ADS101x and ADS111x i2c analog to digital converters
33 .Sh SYNOPSIS
34 To compile this driver into the kernel,
35 place the following line in your
36 kernel configuration file:
37 .Bd -ragged -offset indent
38 .Cd "device ads111x"
39 .Ed
40 .Pp
41 Alternatively, to load the driver as a
42 module at boot time, place the following line in
43 .Xr loader.conf 5 :
44 .Bd -literal -offset indent
45 ads111x_load="YES"
46 .Ed
47 .Sh DESCRIPTION
48 The
49 .Nm
50 driver provides support for the ADS101x/ADS111x family of analog
51 to digital converter (ADC) devices.
52 The supported devices are all similar to each other, varying in
53 features such as resolution and number of input channels.
54 The devices offer a number of configuration options which can be
55 set via hints, FDT data, and
56 .Xr sysctl 8 .
57 .Pp
58 .Xr Sysctl 8
59 provides access to the voltage measurements made by the device.
60 Each time the
61 .Va dev.ads111x.<unit>.<channel>.voltage
62 variable is accessed for a given channel, the driver switches the
63 chip's internal mux to choose the right input pins for that channel,
64 directs it to make a single measurement, and returns the measured value
65 in microvolts.
66 The amount of time required to make the measurement is a function
67 of the sampling rate configured for the device.
68 While device is directed to make a single measurement, it still averages
69 the input values for the same amount of time as it would to emit one
70 sample if it were in continuous mode.
71 For example, if the sample rate were configured as 125 samples per
72 second, a single measurement would require 8 milliseconds.
73 .Pp
74 For devices that support multiple input pins, the device datasheet
75 describes mux settings to control how those pins are interpeted when
76 making either single-ended or differential measurements.
77 There are eight possible ways to combine the inputs from the four pins.
78 The
79 .Nm
80 driver models that by creating a separate output channel for each of
81 the eight combinations.
82 To make a measurement on a given pin or pair of pins, you simply access
83 the voltage variable for the channel number that corresponds the mux
84 setting number (0 through 7) shown in the datasheet.
85 When the driver is configured with hints or FDT data, it creates
86 sysctl variables for just the channels specified in the config data.
87 When there is no channel config data, it creates all eight possible
88 channels so that you can access whichever one(s) you need.
89 .Pp
90 For devices that include an
91 .Va alert
92 output pin, the
93 .Nm
94 driver does not directly support the pin in terms of sensing or
95 acting on changes in the pin state.
96 However, you may connect the pin to a gpio input or fan controller
97 or other external device, and use the driver's sysctl variables to
98 configure behavior and threshold values for the pin.
99 The driver avoids perturbing your settings as it does other
100 manipulations to the config register.
101 .Sh SYSCTL VARIABLES
102 Sysctl variables are used to access the voltage measurements, and to
103 change the configuration of the channels.
104 All writeable variables may also be set as
105 .Xr loader 8
106 tunables.
107 Channel numbers in these sysctl variables range from 0 through 7.
108 .Bl -tag -width indent
109 .It Va dev.ads111x.<unit>.config
110 Provides access to the configuration register bits that control the
111 alert pin configuration.
112 Other bits which are controlled by the driver are masked out, and
113 cannot be viewed or changed using this variable.
114 .It Va dev.ads111x.<unit>.lo_thresh
115 Sets the low threshold for activating the alert pin.
116 .It Va dev.ads111x.<unit>.hi_thresh
117 Sets the high threshold for activating the alert pin.
118 .It Va dev.ads111x.<unit>.<channel>.rate_index
119 Sets the sample rate for the channel.
120 The device datasheet documents eight available sample rates, chosen
121 by setting a value of 0 through 7 into the corresponding control
122 register bits.
123 This variable sets the value used for those bits when making a
124 measurement on the given channel.
125 .Pp
126 Because measurements are always made in single-shot mode, think of
127 this variable as controlling the averaging time for a single sample;
128 the time to make a measurement is 1 / samplerate.
129 .It Va dev.ads111x.<unit>.<channel>.gain_index
130 Sets the programmable gain amplifier for the channel on devices
131 which have an internal amplifier.
132 The device datasheet documents eight available gain values, chosen
133 by setting a value of 0 through 7 into the corresponding control
134 register bits.
135 This variable sets the value used for those bits when making a
136 measurement on the given channel.
137 .It Va dev.ads111x.<unit>.<channel>.voltage
138 Reading this variable causes the device to make a measurement on
139 the corresponding input pin(s) and return the voltage in microvolts.
140 .Pp
141 Note that this variable does not appear when you list multiple
142 sysctl variables -- you must access it specifically by name, because
143 accessing it triggers device I/O.
144 .El
145 .Sh HARDWARE
146 The
147 .Nm
148 driver provides support for the following devices:
149 .Pp
150 .Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
151 .It ADS1013 Ta ADS1113
152 .It ADS1014 Ta ADS1114
153 .It ADS1015 Ta ADS1115
154 .El
155 .Sh FDT CONFIGURATION
156 On an
157 .Xr fdt 4
158 based system, the
159 .Nm
160 device is defined as a slave device subnode
161 of the i2c bus controller node.
162 All properties documented in the
163 .Va ads1015.txt
164 bindings document can be used with the
165 .Nm
166 device.
167 .Pp
168 The following properties are required in the
169 .Nm
170 device subnode:
171 .Bl -tag -width indent
172 .It Va compatible
173 One of the following:
174 .Bl -column -compact -offset indent ".Dq ti,ads1013" ".Dq ti,ads1113"
175 .It Dq ti,ads1013 Ta Dq ti,ads1113
176 .It Dq ti,ads1014 Ta Dq ti,ads1114
177 .It Dq ti,ads1015 Ta Dq ti,ads1115
178 .El
179 .It Va reg
180 I2c slave address of device.
181 .El
182 .Pp
183 Specific channels can be configured by adding child nodes to the
184 .Nm
185 node, as described in the standard ads1015.txt bindings document.
186 If no channels are configured, sysctl variables will be created
187 for all possible channels supported by the device type, otherwise
188 only the specified channels are created.
189 .Ss Example including channel configuration
190 .Bd -unfilled -offset indent
191 adc@48 {
192     compatible = "ti,ads1115";
193     reg = <0x48>;
194     status = "okay";
195     #address-cells = <1>;
196     #size-cells = <0>;
197
198     channel@6 {
199         reg = <6>;
200         ti,gain = <3>;
201         ti,datarate = <4>;
202     };
203     channel@7 {
204         reg = <7>;
205         ti,gain = <1>;
206         ti,datarate = <7>;
207     };
208 };
209 .Ed
210 .Sh HINTS CONFIGURATION
211 On a
212 .Xr device.hints 5
213 based system, such as
214 .Li MIPS ,
215 these values are configurable for
216 .Nm :
217 .Bl -tag -width indent
218 .It Va hint.ads111x.<unit>.at
219 The iicbus instance the
220 .Nm
221 instance is attached to.
222 .It Va hint.ads111x.<unit>.<channel>.gain_index
223 The amplifier gain, as described above for the sysctl variable
224 .Va dev.ads111x.<unit>.<channel>.gain_index .
225 .It Va hint.ads111x.<unit>.<channel>.rate_index
226 The sample rate, as described above for the sysctl variable
227 .Va dev.ads111x.<unit>.<channel>.rate_index .
228 .El
229 .Pp
230 If no channels are configured, sysctl variables will be created
231 for all possible channels supported by the device type, otherwise
232 only the specified channels are created.
233 .Sh SEE ALSO
234 .Xr fdt 4 ,
235 .Xr sysctl 8
236 .Sh HISTORY
237 The
238 .Nm
239 driver first appeared in
240 .Fx 13.0 .