xref: /freebsd/share/man/man4/ads111x.4 (revision 42249ef2)
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
34To compile this driver into the kernel,
35place the following line in your
36kernel configuration file:
37.Bd -ragged -offset indent
38.Cd "device ads111x"
39.Ed
40.Pp
41Alternatively, to load the driver as a
42module at boot time, place the following line in
43.Xr loader.conf 5 :
44.Bd -literal -offset indent
45ads111x_load="YES"
46.Ed
47.Sh DESCRIPTION
48The
49.Nm
50driver provides support for the ADS101x/ADS111x family of analog
51to digital converter (ADC) devices.
52The supported devices are all similar to each other, varying in
53features such as resolution and number of input channels.
54The devices offer a number of configuration options which can be
55set via hints, FDT data, and
56.Xr sysctl 8 .
57.Pp
58.Xr Sysctl 8
59provides access to the voltage measurements made by the device.
60Each time the
61.Va dev.ads111x.<unit>.<channel>.voltage
62variable is accessed for a given channel, the driver switches the
63chip's internal mux to choose the right input pins for that channel,
64directs it to make a single measurement, and returns the measured value
65in microvolts.
66The amount of time required to make the measurement is a function
67of the sampling rate configured for the device.
68While device is directed to make a single measurement, it still averages
69the input values for the same amount of time as it would to emit one
70sample if it were in continuous mode.
71For example, if the sample rate were configured as 125 samples per
72second, a single measurement would require 8 milliseconds.
73.Pp
74For devices that support multiple input pins, the device datasheet
75describes mux settings to control how those pins are interpeted when
76making either single-ended or differential measurements.
77There are eight possible ways to combine the inputs from the four pins.
78The
79.Nm
80driver models that by creating a separate output channel for each of
81the eight combinations.
82To make a measurement on a given pin or pair of pins, you simply access
83the voltage variable for the channel number that corresponds the mux
84setting number (0 through 7) shown in the datasheet.
85When the driver is configured with hints or FDT data, it creates
86sysctl variables for just the channels specified in the config data.
87When there is no channel config data, it creates all eight possible
88channels so that you can access whichever one(s) you need.
89.Pp
90For devices that include an
91.Va alert
92output pin, the
93.Nm
94driver does not directly support the pin in terms of sensing or
95acting on changes in the pin state.
96However, you may connect the pin to a gpio input or fan controller
97or other external device, and use the driver's sysctl variables to
98configure behavior and threshold values for the pin.
99The driver avoids perturbing your settings as it does other
100manipulations to the config register.
101.Sh SYSCTL VARIABLES
102Sysctl variables are used to access the voltage measurements, and to
103change the configuration of the channels.
104All writeable variables may also be set as
105.Xr loader 8
106tunables.
107Channel numbers in these sysctl variables range from 0 through 7.
108.Bl -tag -width indent
109.It Va dev.ads111x.<unit>.config
110Provides access to the configuration register bits that control the
111alert pin configuration.
112Other bits which are controlled by the driver are masked out, and
113cannot be viewed or changed using this variable.
114.It Va dev.ads111x.<unit>.lo_thresh
115Sets the low threshold for activating the alert pin.
116.It Va dev.ads111x.<unit>.hi_thresh
117Sets the high threshold for activating the alert pin.
118.It Va dev.ads111x.<unit>.<channel>.rate_index
119Sets the sample rate for the channel.
120The device datasheet documents eight available sample rates, chosen
121by setting a value of 0 through 7 into the corresponding control
122register bits.
123This variable sets the value used for those bits when making a
124measurement on the given channel.
125.Pp
126Because measurements are always made in single-shot mode, think of
127this variable as controlling the averaging time for a single sample;
128the time to make a measurement is 1 / samplerate.
129.It Va dev.ads111x.<unit>.<channel>.gain_index
130Sets the programmable gain amplifier for the channel on devices
131which have an internal amplifier.
132The device datasheet documents eight available gain values, chosen
133by setting a value of 0 through 7 into the corresponding control
134register bits.
135This variable sets the value used for those bits when making a
136measurement on the given channel.
137.It Va dev.ads111x.<unit>.<channel>.voltage
138Reading this variable causes the device to make a measurement on
139the corresponding input pin(s) and return the voltage in microvolts.
140.Pp
141Note that this variable does not appear when you list multiple
142sysctl variables -- you must access it specifically by name, because
143accessing it triggers device I/O.
144.El
145.Sh HARDWARE
146The
147.Nm
148driver 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
156On an
157.Xr fdt 4
158based system, the
159.Nm
160device is defined as a slave device subnode
161of the i2c bus controller node.
162All properties documented in the
163.Va ads1015.txt
164bindings document can be used with the
165.Nm
166device.
167.Pp
168The following properties are required in the
169.Nm
170device subnode:
171.Bl -tag -width indent
172.It Va compatible
173One 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
180I2c slave address of device.
181.El
182.Pp
183Specific channels can be configured by adding child nodes to the
184.Nm
185node, as described in the standard ads1015.txt bindings document.
186If no channels are configured, sysctl variables will be created
187for all possible channels supported by the device type, otherwise
188only the specified channels are created.
189.Ss Example including channel configuration
190.Bd -unfilled -offset indent
191adc@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
211On a
212.Xr device.hints 5
213based system, such as
214.Li MIPS ,
215these values are configurable for
216.Nm :
217.Bl -tag -width indent
218.It Va hint.ads111x.<unit>.at
219The iicbus instance the
220.Nm
221instance is attached to.
222.It Va hint.ads111x.<unit>.<channel>.gain_index
223The 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
226The sample rate, as described above for the sysctl variable
227.Va dev.ads111x.<unit>.<channel>.rate_index .
228.El
229.Pp
230If no channels are configured, sysctl variables will be created
231for all possible channels supported by the device type, otherwise
232only the specified channels are created.
233.Sh SEE ALSO
234.Xr fdt 4 ,
235.Xr sysctl 4
236.Sh HISTORY
237The
238.Nm
239driver first appeared in
240.Fx 13.0 .
241