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.
32 .Nd driver for ADS101x and ADS111x i2c analog to digital converters
34 To compile this driver into the kernel,
35 place the following line in your
36 kernel configuration file:
37 .Bd -ragged -offset indent
41 Alternatively, to load the driver as a
42 module at boot time, place the following line in
44 .Bd -literal -offset indent
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
60 utility provides access to the voltage measurements made by the device.
62 .Va dev.ads111x.<unit>.<channel>.voltage
63 variable is accessed for a given channel, the driver switches the
64 chip's internal mux to choose the right input pins for that channel,
65 directs it to make a single measurement, and returns the measured value
67 The amount of time required to make the measurement is a function
68 of the sampling rate configured for the device.
69 While device is directed to make a single measurement, it still averages
70 the input values for the same amount of time as it would to emit one
71 sample if it were in continuous mode.
72 For example, if the sample rate were configured as 125 samples per
73 second, a single measurement would require 8 milliseconds.
75 For devices that support multiple input pins, the device datasheet
76 describes mux settings to control how those pins are interpeted when
77 making either single-ended or differential measurements.
78 There are eight possible ways to combine the inputs from the four pins.
81 driver models that by creating a separate output channel for each of
82 the eight combinations.
83 To make a measurement on a given pin or pair of pins, you simply access
84 the voltage variable for the channel number that corresponds the mux
85 setting number (0 through 7) shown in the datasheet.
86 When the driver is configured with hints or FDT data, it creates
87 sysctl variables for just the channels specified in the config data.
88 When there is no channel config data, it creates all eight possible
89 channels so that you can access whichever one(s) you need.
91 For devices that include an
95 driver does not directly support the pin in terms of sensing or
96 acting on changes in the pin state.
97 However, you may connect the pin to a gpio input or fan controller
98 or other external device, and use the driver's sysctl variables to
99 configure behavior and threshold values for the pin.
100 The driver avoids perturbing your settings as it does other
101 manipulations to the config register.
103 Sysctl variables are used to access the voltage measurements, and to
104 change the configuration of the channels.
105 All writeable variables may also be set as
108 Channel numbers in these sysctl variables range from 0 through 7.
109 .Bl -tag -width indent
110 .It Va dev.ads111x.<unit>.config
111 Provides access to the configuration register bits that control the
112 alert pin configuration.
113 Other bits which are controlled by the driver are masked out, and
114 cannot be viewed or changed using this variable.
115 .It Va dev.ads111x.<unit>.lo_thresh
116 Sets the low threshold for activating the alert pin.
117 .It Va dev.ads111x.<unit>.hi_thresh
118 Sets the high threshold for activating the alert pin.
119 .It Va dev.ads111x.<unit>.<channel>.rate_index
120 Sets the sample rate for the channel.
121 The device datasheet documents eight available sample rates, chosen
122 by setting a value of 0 through 7 into the corresponding control
124 This variable sets the value used for those bits when making a
125 measurement on the given channel.
127 Because measurements are always made in single-shot mode, think of
128 this variable as controlling the averaging time for a single sample;
129 the time to make a measurement is 1 / samplerate.
130 .It Va dev.ads111x.<unit>.<channel>.gain_index
131 Sets the programmable gain amplifier for the channel on devices
132 which have an internal amplifier.
133 The device datasheet documents eight available gain values, chosen
134 by setting a value of 0 through 7 into the corresponding control
136 This variable sets the value used for those bits when making a
137 measurement on the given channel.
138 .It Va dev.ads111x.<unit>.<channel>.voltage
139 Reading this variable causes the device to make a measurement on
140 the corresponding input pin(s) and return the voltage in microvolts.
142 Note that this variable does not appear when you list multiple
143 sysctl variables -- you must access it specifically by name, because
144 accessing it triggers device I/O.
149 driver provides support for the following devices:
151 .Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
152 .It ADS1013 Ta ADS1113
153 .It ADS1014 Ta ADS1114
154 .It ADS1015 Ta ADS1115
156 .Sh FDT CONFIGURATION
161 device is defined as a slave device subnode
162 of the i2c bus controller node.
163 All properties documented in the
165 bindings document can be used with the
169 The following properties are required in the
172 .Bl -tag -width indent
174 One of the following:
175 .Bl -column -compact -offset indent ".Dq ti,ads1013" ".Dq ti,ads1113"
176 .It Dq ti,ads1013 Ta Dq ti,ads1113
177 .It Dq ti,ads1014 Ta Dq ti,ads1114
178 .It Dq ti,ads1015 Ta Dq ti,ads1115
181 I2c slave address of device.
184 Specific channels can be configured by adding child nodes to the
186 node, as described in the standard ads1015.txt bindings document.
187 If no channels are configured, sysctl variables will be created
188 for all possible channels supported by the device type, otherwise
189 only the specified channels are created.
190 .Ss Example including channel configuration
191 .Bd -unfilled -offset indent
193 compatible = "ti,ads1115";
196 #address-cells = <1>;
211 .Sh HINTS CONFIGURATION
214 based system, such as
216 these values are configurable for
218 .Bl -tag -width indent
219 .It Va hint.ads111x.<unit>.at
220 The iicbus instance the
222 instance is attached to.
223 .It Va hint.ads111x.<unit>.<channel>.gain_index
224 The amplifier gain, as described above for the sysctl variable
225 .Va dev.ads111x.<unit>.<channel>.gain_index .
226 .It Va hint.ads111x.<unit>.<channel>.rate_index
227 The sample rate, as described above for the sysctl variable
228 .Va dev.ads111x.<unit>.<channel>.rate_index .
231 If no channels are configured, sysctl variables will be created
232 for all possible channels supported by the device type, otherwise
233 only the specified channels are created.
240 driver first appeared in