xref: /freebsd/share/man/man4/ads111x.4 (revision 385a0efed3266d089c38cea99ee2733fef1fdedb)
15177d294SIan Lepore.\"
25177d294SIan Lepore.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
35177d294SIan Lepore.\"
45177d294SIan Lepore.\" Redistribution and use in source and binary forms, with or without
55177d294SIan Lepore.\" modification, are permitted provided that the following conditions
65177d294SIan Lepore.\" are met:
75177d294SIan Lepore.\"
85177d294SIan Lepore.\" 1. Redistributions of source code must retain the above copyright
95177d294SIan Lepore.\"    notice, this list of conditions and the following disclaimer.
105177d294SIan Lepore.\" 2. Redistributions in binary form must reproduce the above copyright
115177d294SIan Lepore.\"    notice, this list of conditions and the following disclaimer in the
125177d294SIan Lepore.\"    documentation and/or other materials provided with the distribution.
135177d294SIan Lepore.\"
145177d294SIan Lepore.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
155177d294SIan Lepore.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
165177d294SIan Lepore.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
175177d294SIan Lepore.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
185177d294SIan Lepore.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
195177d294SIan Lepore.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
205177d294SIan Lepore.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
215177d294SIan Lepore.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
225177d294SIan Lepore.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
235177d294SIan Lepore.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
245177d294SIan Lepore.\"
255177d294SIan Lepore.\" $FreeBSD$
265177d294SIan Lepore.\"
27*385a0efeSIan Lepore.Dd September 2, 2019
28649e7627SIan Lepore.Dt ADS111x 4
295177d294SIan Lepore.Os
305177d294SIan Lepore.Sh NAME
31649e7627SIan Lepore.Nm ads111x
325177d294SIan Lepore.Nd driver for ADS101x and ADS111x i2c analog to digital converters
335177d294SIan Lepore.Sh SYNOPSIS
345177d294SIan LeporeTo compile this driver into the kernel,
355177d294SIan Leporeplace the following line in your
365177d294SIan Leporekernel configuration file:
375177d294SIan Lepore.Bd -ragged -offset indent
38649e7627SIan Lepore.Cd "device ads111x"
395177d294SIan Lepore.Ed
405177d294SIan Lepore.Pp
415177d294SIan LeporeAlternatively, to load the driver as a
425177d294SIan Leporemodule at boot time, place the following line in
435177d294SIan Lepore.Xr loader.conf 5 :
445177d294SIan Lepore.Bd -literal -offset indent
45649e7627SIan Leporeads111x_load="YES"
465177d294SIan Lepore.Ed
475177d294SIan Lepore.Sh DESCRIPTION
485177d294SIan LeporeThe
495177d294SIan Lepore.Nm
505177d294SIan Leporedriver provides support for the ADS101x/ADS111x family of analog
515177d294SIan Leporeto digital converter (ADC) devices.
525177d294SIan LeporeThe supported devices are all similar to each other, varying in
535177d294SIan Leporefeatures such as resolution and number of input channels.
545177d294SIan LeporeThe devices offer a number of configuration options which can be
555177d294SIan Leporeset via hints, FDT data, and
565177d294SIan Lepore.Xr sysctl 8 .
575177d294SIan Lepore.Pp
585177d294SIan Lepore.Xr Sysctl 8
595177d294SIan Leporeprovides access to the voltage measurements made by the device.
605177d294SIan LeporeEach time the
61649e7627SIan Lepore.Va dev.ads111x.<unit>.<channel>.voltage
625177d294SIan Leporevariable is accessed for a given channel, the driver switches the
635177d294SIan Leporechip's internal mux to choose the right input pins for that channel,
645177d294SIan Leporedirects it to make a single measurement, and returns the measured value
655177d294SIan Leporein microvolts.
665177d294SIan LeporeThe amount of time required to make the measurement is a function
675177d294SIan Leporeof the sampling rate configured for the device.
685177d294SIan LeporeWhile device is directed to make a single measurement, it still averages
695177d294SIan Leporethe input values for the same amount of time as it would to emit one
705177d294SIan Leporesample if it were in continuous mode.
715177d294SIan LeporeFor example, if the sample rate were configured as 125 samples per
725177d294SIan Leporesecond, a single measurement would require 8 milliseconds.
735177d294SIan Lepore.Pp
745177d294SIan LeporeFor devices that support multiple input pins, the device datasheet
755177d294SIan Leporedescribes mux settings to control how those pins are interpeted when
765177d294SIan Leporemaking either single-ended or differential measurements.
775177d294SIan LeporeThere are eight possible ways to combine the inputs from the four pins.
785177d294SIan LeporeThe
795177d294SIan Lepore.Nm
805177d294SIan Leporedriver models that by creating a separate output channel for each of
815177d294SIan Leporethe eight combinations.
825177d294SIan LeporeTo make a measurement on a given pin or pair of pins, you simply access
835177d294SIan Leporethe voltage variable for the channel number that corresponds the mux
845177d294SIan Leporesetting number (0 through 7) shown in the datasheet.
855177d294SIan LeporeWhen the driver is configured with hints or FDT data, it creates
865177d294SIan Leporesysctl variables for just the channels specified in the config data.
875177d294SIan LeporeWhen there is no channel config data, it creates all eight possible
885177d294SIan Leporechannels so that you can access whichever one(s) you need.
895177d294SIan Lepore.Pp
905177d294SIan LeporeFor devices that include an
915177d294SIan Lepore.Va alert
925177d294SIan Leporeoutput pin, the
935177d294SIan Lepore.Nm
945177d294SIan Leporedriver does not directly support the pin in terms of sensing or
955177d294SIan Leporeacting on changes in the pin state.
965177d294SIan LeporeHowever, you may connect the pin to a gpio input or fan controller
975177d294SIan Leporeor other external device, and use the driver's sysctl variables to
985177d294SIan Leporeconfigure behavior and threshold values for the pin.
995177d294SIan LeporeThe driver avoids perturbing your settings as it does other
1005177d294SIan Leporemanipulations to the config register.
1015177d294SIan Lepore.Sh SYSCTL VARIABLES
1025177d294SIan LeporeSysctl variables are used to access the voltage measurements, and to
1035177d294SIan Leporechange the configuration of the channels.
1045177d294SIan LeporeAll writeable variables may also be set as
1055177d294SIan Lepore.Xr loader 8
1065177d294SIan Leporetunables.
1075177d294SIan LeporeChannel numbers in these sysctl variables range from 0 through 7.
1085177d294SIan Lepore.Bl -tag -width indent
109649e7627SIan Lepore.It Va dev.ads111x.<unit>.config
1105177d294SIan LeporeProvides access to the configuration register bits that control the
1115177d294SIan Leporealert pin configuration.
1125177d294SIan LeporeOther bits which are controlled by the driver are masked out, and
1135177d294SIan Leporecannot be viewed or changed using this variable.
114649e7627SIan Lepore.It Va dev.ads111x.<unit>.lo_thresh
1155177d294SIan LeporeSets the low threshold for activating the alert pin.
116649e7627SIan Lepore.It Va dev.ads111x.<unit>.hi_thresh
1175177d294SIan LeporeSets the high threshold for activating the alert pin.
118649e7627SIan Lepore.It Va dev.ads111x.<unit>.<channel>.rate_index
1195177d294SIan LeporeSets the sample rate for the channel.
1205177d294SIan LeporeThe device datasheet documents eight available sample rates, chosen
1215177d294SIan Leporeby setting a value of 0 through 7 into the corresponding control
1225177d294SIan Leporeregister bits.
1235177d294SIan LeporeThis variable sets the value used for those bits when making a
1245177d294SIan Leporemeasurement on the given channel.
1255177d294SIan Lepore.Pp
1265177d294SIan LeporeBecause measurements are always made in single-shot mode, think of
1275177d294SIan Leporethis variable as controlling the averaging time for a single sample;
1285177d294SIan Leporethe time to make a measurement is 1 / samplerate.
129649e7627SIan Lepore.It Va dev.ads111x.<unit>.<channel>.gain_index
1305177d294SIan LeporeSets the programmable gain amplifier for the channel on devices
1315177d294SIan Leporewhich have an internal amplifier.
1325177d294SIan LeporeThe device datasheet documents eight available gain values, chosen
1335177d294SIan Leporeby setting a value of 0 through 7 into the corresponding control
1345177d294SIan Leporeregister bits.
1355177d294SIan LeporeThis variable sets the value used for those bits when making a
1365177d294SIan Leporemeasurement on the given channel.
137649e7627SIan Lepore.It Va dev.ads111x.<unit>.<channel>.voltage
1385177d294SIan LeporeReading this variable causes the device to make a measurement on
1395177d294SIan Leporethe corresponding input pin(s) and return the voltage in microvolts.
1405177d294SIan Lepore.Pp
1415177d294SIan LeporeNote that this variable does not appear when you list multiple
1425177d294SIan Leporesysctl variables -- you must access it specifically by name, because
1435177d294SIan Leporeaccessing it triggers device I/O.
1445177d294SIan Lepore.El
1455177d294SIan Lepore.Sh HARDWARE
1465177d294SIan LeporeThe
1475177d294SIan Lepore.Nm
1485177d294SIan Leporedriver provides support for the following devices:
1495177d294SIan Lepore.Pp
1505177d294SIan Lepore.Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
1515177d294SIan Lepore.It ADS1013 Ta ADS1113
1525177d294SIan Lepore.It ADS1014 Ta ADS1114
1535177d294SIan Lepore.It ADS1015 Ta ADS1115
1545177d294SIan Lepore.El
1555177d294SIan Lepore.Sh FDT CONFIGURATION
1565177d294SIan LeporeOn an
1575177d294SIan Lepore.Xr fdt 4
1585177d294SIan Leporebased system, the
1595177d294SIan Lepore.Nm
1605177d294SIan Leporedevice is defined as a slave device subnode
1615177d294SIan Leporeof the i2c bus controller node.
1625177d294SIan LeporeAll properties documented in the
163*385a0efeSIan Lepore.Va ads1015.txt
1645177d294SIan Leporebindings document can be used with the
1655177d294SIan Lepore.Nm
1665177d294SIan Leporedevice.
1675177d294SIan Lepore.Pp
1685177d294SIan LeporeThe following properties are required in the
1695177d294SIan Lepore.Nm
1705177d294SIan Leporedevice subnode:
1715177d294SIan Lepore.Bl -tag -width indent
1725177d294SIan Lepore.It Va compatible
1735177d294SIan LeporeOne of the following:
1745177d294SIan Lepore.Bl -column -compact -offset indent ".Dq ti,ads1013" ".Dq ti,ads1113"
1755177d294SIan Lepore.It Dq ti,ads1013 Ta Dq ti,ads1113
1765177d294SIan Lepore.It Dq ti,ads1014 Ta Dq ti,ads1114
1775177d294SIan Lepore.It Dq ti,ads1015 Ta Dq ti,ads1115
1785177d294SIan Lepore.El
1795177d294SIan Lepore.It Va reg
1805177d294SIan LeporeI2c slave address of device.
1815177d294SIan Lepore.El
1825177d294SIan Lepore.Pp
1835177d294SIan LeporeSpecific channels can be configured by adding child nodes to the
1845177d294SIan Lepore.Nm
185*385a0efeSIan Leporenode, as described in the standard ads1015.txt bindings document.
1865177d294SIan LeporeIf no channels are configured, sysctl variables will be created
1875177d294SIan Leporefor all possible channels supported by the device type, otherwise
1885177d294SIan Leporeonly the specified channels are created.
1895177d294SIan Lepore.Ss Example including channel configuration
1905177d294SIan Lepore.Bd -unfilled -offset indent
1915177d294SIan Leporeadc@48 {
1925177d294SIan Lepore    compatible = "ti,ads1115";
1935177d294SIan Lepore    reg = <0x48>;
1945177d294SIan Lepore    status = "okay";
1955177d294SIan Lepore    #address-cells = <1>;
1965177d294SIan Lepore    #size-cells = <0>;
1975177d294SIan Lepore
1985177d294SIan Lepore    channel@6 {
1995177d294SIan Lepore        reg = <6>;
2005177d294SIan Lepore        ti,gain = <3>;
2015177d294SIan Lepore        ti,datarate = <4>;
2025177d294SIan Lepore    };
2035177d294SIan Lepore    channel@7 {
2045177d294SIan Lepore        reg = <7>;
2055177d294SIan Lepore        ti,gain = <1>;
2065177d294SIan Lepore        ti,datarate = <7>;
2075177d294SIan Lepore    };
2085177d294SIan Lepore};
2095177d294SIan Lepore.Ed
2105177d294SIan Lepore.Sh HINTS CONFIGURATION
2115177d294SIan LeporeOn a
2125177d294SIan Lepore.Xr device.hints 5
2135177d294SIan Leporebased system, such as
2145177d294SIan Lepore.Li MIPS ,
2155177d294SIan Leporethese values are configurable for
2165177d294SIan Lepore.Nm :
2175177d294SIan Lepore.Bl -tag -width indent
218649e7627SIan Lepore.It Va hint.ads111x.<unit>.at
2195177d294SIan LeporeThe iicbus instance the
2205177d294SIan Lepore.Nm
2215177d294SIan Leporeinstance is attached to.
222649e7627SIan Lepore.It Va hint.ads111x.<unit>.<channel>.gain_index
2235177d294SIan LeporeThe amplifier gain, as described above for the sysctl variable
224649e7627SIan Lepore.Va dev.ads111x.<unit>.<channel>.gain_index .
225649e7627SIan Lepore.It Va hint.ads111x.<unit>.<channel>.rate_index
2265177d294SIan LeporeThe sample rate, as described above for the sysctl variable
227649e7627SIan Lepore.Va dev.ads111x.<unit>.<channel>.rate_index .
2285177d294SIan Lepore.El
2295177d294SIan Lepore.Pp
2305177d294SIan LeporeIf no channels are configured, sysctl variables will be created
2315177d294SIan Leporefor all possible channels supported by the device type, otherwise
2325177d294SIan Leporeonly the specified channels are created.
2335177d294SIan Lepore.Sh SEE ALSO
2345177d294SIan Lepore.Xr fdt 4 ,
2355177d294SIan Lepore.Xr sysctl 4
2365177d294SIan Lepore.Sh HISTORY
2375177d294SIan LeporeThe
2385177d294SIan Lepore.Nm
2395177d294SIan Leporedriver first appeared in
2405177d294SIan Lepore.Fx 13.0 .
241