2 .\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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.
30 .Nd driver for ADS101x and ADS111x i2c analog to digital converters
32 To compile this driver into the kernel,
33 place the following line in your
34 kernel configuration file:
35 .Bd -ragged -offset indent
39 Alternatively, to load the driver as a
40 module at boot time, place the following line in
42 .Bd -literal -offset indent
48 driver provides support for the ADS101x/ADS111x family of analog
49 to digital converter (ADC) devices.
50 The supported devices are all similar to each other, varying in
51 features such as resolution and number of input channels.
52 The devices offer a number of configuration options which can be
53 set via hints, FDT data, and
58 utility provides access to the voltage measurements made by the device.
60 .Va dev.ads111x.<unit>.<channel>.voltage
61 variable is accessed for a given channel, the driver switches the
62 chip's internal mux to choose the right input pins for that channel,
63 directs it to make a single measurement, and returns the measured value
65 The amount of time required to make the measurement is a function
66 of the sampling rate configured for the device.
67 While device is directed to make a single measurement, it still averages
68 the input values for the same amount of time as it would to emit one
69 sample if it were in continuous mode.
70 For example, if the sample rate were configured as 125 samples per
71 second, a single measurement would require 8 milliseconds.
73 For devices that support multiple input pins, the device datasheet
74 describes mux settings to control how those pins are interpeted when
75 making either single-ended or differential measurements.
76 There are eight possible ways to combine the inputs from the four pins.
79 driver models that by creating a separate output channel for each of
80 the eight combinations.
81 To make a measurement on a given pin or pair of pins, you simply access
82 the voltage variable for the channel number that corresponds the mux
83 setting number (0 through 7) shown in the datasheet.
84 When the driver is configured with hints or FDT data, it creates
85 sysctl variables for just the channels specified in the config data.
86 When there is no channel config data, it creates all eight possible
87 channels so that you can access whichever one(s) you need.
89 For devices that include an
93 driver does not directly support the pin in terms of sensing or
94 acting on changes in the pin state.
95 However, you may connect the pin to a gpio input or fan controller
96 or other external device, and use the driver's sysctl variables to
97 configure behavior and threshold values for the pin.
98 The driver avoids perturbing your settings as it does other
99 manipulations to the config register.
101 Sysctl variables are used to access the voltage measurements, and to
102 change the configuration of the channels.
103 All writeable variables may also be set as
106 Channel numbers in these sysctl variables range from 0 through 7.
107 .Bl -tag -width indent
108 .It Va dev.ads111x.<unit>.config
109 Provides access to the configuration register bits that control the
110 alert pin configuration.
111 Other bits which are controlled by the driver are masked out, and
112 cannot be viewed or changed using this variable.
113 .It Va dev.ads111x.<unit>.lo_thresh
114 Sets the low threshold for activating the alert pin.
115 .It Va dev.ads111x.<unit>.hi_thresh
116 Sets the high threshold for activating the alert pin.
117 .It Va dev.ads111x.<unit>.<channel>.rate_index
118 Sets the sample rate for the channel.
119 The device datasheet documents eight available sample rates, chosen
120 by setting a value of 0 through 7 into the corresponding control
122 This variable sets the value used for those bits when making a
123 measurement on the given channel.
125 Because measurements are always made in single-shot mode, think of
126 this variable as controlling the averaging time for a single sample;
127 the time to make a measurement is 1 / samplerate.
128 .It Va dev.ads111x.<unit>.<channel>.gain_index
129 Sets the programmable gain amplifier for the channel on devices
130 which have an internal amplifier.
131 The device datasheet documents eight available gain values, chosen
132 by setting a value of 0 through 7 into the corresponding control
134 This variable sets the value used for those bits when making a
135 measurement on the given channel.
136 .It Va dev.ads111x.<unit>.<channel>.voltage
137 Reading this variable causes the device to make a measurement on
138 the corresponding input pin(s) and return the voltage in microvolts.
140 Note that this variable does not appear when you list multiple
141 sysctl variables -- you must access it specifically by name, because
142 accessing it triggers device I/O.
147 driver provides support for the following devices:
149 .Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
150 .It ADS1013 Ta ADS1113
151 .It ADS1014 Ta ADS1114
152 .It ADS1015 Ta ADS1115
154 .Sh FDT CONFIGURATION
159 device is defined as a slave device subnode
160 of the i2c bus controller node.
161 All properties documented in the
163 bindings document can be used with the
167 The following properties are required in the
170 .Bl -tag -width indent
172 One of the following:
173 .Bl -column -compact -offset indent ".Dq ti,ads1013" ".Dq ti,ads1113"
174 .It Dq ti,ads1013 Ta Dq ti,ads1113
175 .It Dq ti,ads1014 Ta Dq ti,ads1114
176 .It Dq ti,ads1015 Ta Dq ti,ads1115
179 I2c slave address of device.
182 Specific channels can be configured by adding child nodes to the
184 node, as described in the standard ads1015.txt bindings document.
185 If no channels are configured, sysctl variables will be created
186 for all possible channels supported by the device type, otherwise
187 only the specified channels are created.
188 .Ss Example including channel configuration
189 .Bd -unfilled -offset indent
191 compatible = "ti,ads1115";
194 #address-cells = <1>;
209 .Sh HINTS CONFIGURATION
212 based system, such as
214 these values are configurable for
216 .Bl -tag -width indent
217 .It Va hint.ads111x.<unit>.at
218 The iicbus instance the
220 instance is attached to.
221 .It Va hint.ads111x.<unit>.<channel>.gain_index
222 The amplifier gain, as described above for the sysctl variable
223 .Va dev.ads111x.<unit>.<channel>.gain_index .
224 .It Va hint.ads111x.<unit>.<channel>.rate_index
225 The sample rate, as described above for the sysctl variable
226 .Va dev.ads111x.<unit>.<channel>.rate_index .
229 If no channels are configured, sysctl variables will be created
230 for all possible channels supported by the device type, otherwise
231 only the specified channels are created.
238 driver first appeared in