xref: /freebsd/share/man/man4/ads111x.4 (revision ffc4f93e960d38b6f70d59409127f7562e40f916)
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.\"
25385a0efeSIan Lepore.Dd September 2, 2019
26649e7627SIan Lepore.Dt ADS111x 4
275177d294SIan Lepore.Os
285177d294SIan Lepore.Sh NAME
29649e7627SIan Lepore.Nm ads111x
305177d294SIan Lepore.Nd driver for ADS101x and ADS111x i2c analog to digital converters
315177d294SIan Lepore.Sh SYNOPSIS
325177d294SIan LeporeTo compile this driver into the kernel,
335177d294SIan Leporeplace the following line in your
345177d294SIan Leporekernel configuration file:
355177d294SIan Lepore.Bd -ragged -offset indent
36649e7627SIan Lepore.Cd "device ads111x"
375177d294SIan Lepore.Ed
385177d294SIan Lepore.Pp
395177d294SIan LeporeAlternatively, to load the driver as a
405177d294SIan Leporemodule at boot time, place the following line in
415177d294SIan Lepore.Xr loader.conf 5 :
425177d294SIan Lepore.Bd -literal -offset indent
43649e7627SIan Leporeads111x_load="YES"
445177d294SIan Lepore.Ed
455177d294SIan Lepore.Sh DESCRIPTION
465177d294SIan LeporeThe
475177d294SIan Lepore.Nm
485177d294SIan Leporedriver provides support for the ADS101x/ADS111x family of analog
495177d294SIan Leporeto digital converter (ADC) devices.
505177d294SIan LeporeThe supported devices are all similar to each other, varying in
515177d294SIan Leporefeatures such as resolution and number of input channels.
525177d294SIan LeporeThe devices offer a number of configuration options which can be
535177d294SIan Leporeset via hints, FDT data, and
545177d294SIan Lepore.Xr sysctl 8 .
555177d294SIan Lepore.Pp
5614e3d324SJens SchweikhardtThe
5714e3d324SJens Schweikhardt.Xr sysctl 8
5814e3d324SJens Schweikhardtutility provides access to the voltage measurements made by the device.
595177d294SIan LeporeEach time the
60649e7627SIan Lepore.Va dev.ads111x.<unit>.<channel>.voltage
615177d294SIan Leporevariable is accessed for a given channel, the driver switches the
625177d294SIan Leporechip's internal mux to choose the right input pins for that channel,
635177d294SIan Leporedirects it to make a single measurement, and returns the measured value
645177d294SIan Leporein microvolts.
655177d294SIan LeporeThe amount of time required to make the measurement is a function
665177d294SIan Leporeof the sampling rate configured for the device.
675177d294SIan LeporeWhile device is directed to make a single measurement, it still averages
685177d294SIan Leporethe input values for the same amount of time as it would to emit one
695177d294SIan Leporesample if it were in continuous mode.
705177d294SIan LeporeFor example, if the sample rate were configured as 125 samples per
715177d294SIan Leporesecond, a single measurement would require 8 milliseconds.
725177d294SIan Lepore.Pp
735177d294SIan LeporeFor devices that support multiple input pins, the device datasheet
74*ffc4f93eSBenedict Reuschlingdescribes mux settings to control how those pins are interpreted when
755177d294SIan Leporemaking either single-ended or differential measurements.
765177d294SIan LeporeThere are eight possible ways to combine the inputs from the four pins.
775177d294SIan LeporeThe
785177d294SIan Lepore.Nm
795177d294SIan Leporedriver models that by creating a separate output channel for each of
805177d294SIan Leporethe eight combinations.
815177d294SIan LeporeTo make a measurement on a given pin or pair of pins, you simply access
825177d294SIan Leporethe voltage variable for the channel number that corresponds the mux
835177d294SIan Leporesetting number (0 through 7) shown in the datasheet.
845177d294SIan LeporeWhen the driver is configured with hints or FDT data, it creates
855177d294SIan Leporesysctl variables for just the channels specified in the config data.
865177d294SIan LeporeWhen there is no channel config data, it creates all eight possible
875177d294SIan Leporechannels so that you can access whichever one(s) you need.
885177d294SIan Lepore.Pp
895177d294SIan LeporeFor devices that include an
905177d294SIan Lepore.Va alert
915177d294SIan Leporeoutput pin, the
925177d294SIan Lepore.Nm
935177d294SIan Leporedriver does not directly support the pin in terms of sensing or
945177d294SIan Leporeacting on changes in the pin state.
955177d294SIan LeporeHowever, you may connect the pin to a gpio input or fan controller
965177d294SIan Leporeor other external device, and use the driver's sysctl variables to
975177d294SIan Leporeconfigure behavior and threshold values for the pin.
985177d294SIan LeporeThe driver avoids perturbing your settings as it does other
995177d294SIan Leporemanipulations to the config register.
1005177d294SIan Lepore.Sh SYSCTL VARIABLES
1015177d294SIan LeporeSysctl variables are used to access the voltage measurements, and to
1025177d294SIan Leporechange the configuration of the channels.
1035177d294SIan LeporeAll writeable variables may also be set as
1045177d294SIan Lepore.Xr loader 8
1055177d294SIan Leporetunables.
1065177d294SIan LeporeChannel numbers in these sysctl variables range from 0 through 7.
1075177d294SIan Lepore.Bl -tag -width indent
108649e7627SIan Lepore.It Va dev.ads111x.<unit>.config
1095177d294SIan LeporeProvides access to the configuration register bits that control the
1105177d294SIan Leporealert pin configuration.
1115177d294SIan LeporeOther bits which are controlled by the driver are masked out, and
1125177d294SIan Leporecannot be viewed or changed using this variable.
113649e7627SIan Lepore.It Va dev.ads111x.<unit>.lo_thresh
1145177d294SIan LeporeSets the low threshold for activating the alert pin.
115649e7627SIan Lepore.It Va dev.ads111x.<unit>.hi_thresh
1165177d294SIan LeporeSets the high threshold for activating the alert pin.
117649e7627SIan Lepore.It Va dev.ads111x.<unit>.<channel>.rate_index
1185177d294SIan LeporeSets the sample rate for the channel.
1195177d294SIan LeporeThe device datasheet documents eight available sample rates, chosen
1205177d294SIan Leporeby setting a value of 0 through 7 into the corresponding control
1215177d294SIan Leporeregister bits.
1225177d294SIan LeporeThis variable sets the value used for those bits when making a
1235177d294SIan Leporemeasurement on the given channel.
1245177d294SIan Lepore.Pp
1255177d294SIan LeporeBecause measurements are always made in single-shot mode, think of
1265177d294SIan Leporethis variable as controlling the averaging time for a single sample;
1275177d294SIan Leporethe time to make a measurement is 1 / samplerate.
128649e7627SIan Lepore.It Va dev.ads111x.<unit>.<channel>.gain_index
1295177d294SIan LeporeSets the programmable gain amplifier for the channel on devices
1305177d294SIan Leporewhich have an internal amplifier.
1315177d294SIan LeporeThe device datasheet documents eight available gain values, chosen
1325177d294SIan Leporeby setting a value of 0 through 7 into the corresponding control
1335177d294SIan Leporeregister bits.
1345177d294SIan LeporeThis variable sets the value used for those bits when making a
1355177d294SIan Leporemeasurement on the given channel.
136649e7627SIan Lepore.It Va dev.ads111x.<unit>.<channel>.voltage
1375177d294SIan LeporeReading this variable causes the device to make a measurement on
1385177d294SIan Leporethe corresponding input pin(s) and return the voltage in microvolts.
1395177d294SIan Lepore.Pp
1405177d294SIan LeporeNote that this variable does not appear when you list multiple
1415177d294SIan Leporesysctl variables -- you must access it specifically by name, because
1425177d294SIan Leporeaccessing it triggers device I/O.
1435177d294SIan Lepore.El
1445177d294SIan Lepore.Sh HARDWARE
1455177d294SIan LeporeThe
1465177d294SIan Lepore.Nm
1475177d294SIan Leporedriver provides support for the following devices:
1485177d294SIan Lepore.Pp
1495177d294SIan Lepore.Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
1505177d294SIan Lepore.It ADS1013 Ta ADS1113
1515177d294SIan Lepore.It ADS1014 Ta ADS1114
1525177d294SIan Lepore.It ADS1015 Ta ADS1115
1535177d294SIan Lepore.El
1545177d294SIan Lepore.Sh FDT CONFIGURATION
1555177d294SIan LeporeOn an
1565177d294SIan Lepore.Xr fdt 4
1575177d294SIan Leporebased system, the
1585177d294SIan Lepore.Nm
1595177d294SIan Leporedevice is defined as a slave device subnode
1605177d294SIan Leporeof the i2c bus controller node.
1615177d294SIan LeporeAll properties documented in the
162385a0efeSIan Lepore.Va ads1015.txt
1635177d294SIan Leporebindings document can be used with the
1645177d294SIan Lepore.Nm
1655177d294SIan Leporedevice.
1665177d294SIan Lepore.Pp
1675177d294SIan LeporeThe following properties are required in the
1685177d294SIan Lepore.Nm
1695177d294SIan Leporedevice subnode:
1705177d294SIan Lepore.Bl -tag -width indent
1715177d294SIan Lepore.It Va compatible
1725177d294SIan LeporeOne of the following:
1735177d294SIan Lepore.Bl -column -compact -offset indent ".Dq ti,ads1013" ".Dq ti,ads1113"
1745177d294SIan Lepore.It Dq ti,ads1013 Ta Dq ti,ads1113
1755177d294SIan Lepore.It Dq ti,ads1014 Ta Dq ti,ads1114
1765177d294SIan Lepore.It Dq ti,ads1015 Ta Dq ti,ads1115
1775177d294SIan Lepore.El
1785177d294SIan Lepore.It Va reg
1795177d294SIan LeporeI2c slave address of device.
1805177d294SIan Lepore.El
1815177d294SIan Lepore.Pp
1825177d294SIan LeporeSpecific channels can be configured by adding child nodes to the
1835177d294SIan Lepore.Nm
184385a0efeSIan Leporenode, as described in the standard ads1015.txt bindings document.
1855177d294SIan LeporeIf no channels are configured, sysctl variables will be created
1865177d294SIan Leporefor all possible channels supported by the device type, otherwise
1875177d294SIan Leporeonly the specified channels are created.
1885177d294SIan Lepore.Ss Example including channel configuration
1895177d294SIan Lepore.Bd -unfilled -offset indent
1905177d294SIan Leporeadc@48 {
1915177d294SIan Lepore    compatible = "ti,ads1115";
1925177d294SIan Lepore    reg = <0x48>;
1935177d294SIan Lepore    status = "okay";
1945177d294SIan Lepore    #address-cells = <1>;
1955177d294SIan Lepore    #size-cells = <0>;
1965177d294SIan Lepore
1975177d294SIan Lepore    channel@6 {
1985177d294SIan Lepore        reg = <6>;
1995177d294SIan Lepore        ti,gain = <3>;
2005177d294SIan Lepore        ti,datarate = <4>;
2015177d294SIan Lepore    };
2025177d294SIan Lepore    channel@7 {
2035177d294SIan Lepore        reg = <7>;
2045177d294SIan Lepore        ti,gain = <1>;
2055177d294SIan Lepore        ti,datarate = <7>;
2065177d294SIan Lepore    };
2075177d294SIan Lepore};
2085177d294SIan Lepore.Ed
2095177d294SIan Lepore.Sh HINTS CONFIGURATION
2105177d294SIan LeporeOn a
2115177d294SIan Lepore.Xr device.hints 5
2125177d294SIan Leporebased system, such as
2135177d294SIan Lepore.Li MIPS ,
2145177d294SIan Leporethese values are configurable for
2155177d294SIan Lepore.Nm :
2165177d294SIan Lepore.Bl -tag -width indent
217649e7627SIan Lepore.It Va hint.ads111x.<unit>.at
2185177d294SIan LeporeThe iicbus instance the
2195177d294SIan Lepore.Nm
2205177d294SIan Leporeinstance is attached to.
221649e7627SIan Lepore.It Va hint.ads111x.<unit>.<channel>.gain_index
2225177d294SIan LeporeThe amplifier gain, as described above for the sysctl variable
223649e7627SIan Lepore.Va dev.ads111x.<unit>.<channel>.gain_index .
224649e7627SIan Lepore.It Va hint.ads111x.<unit>.<channel>.rate_index
2255177d294SIan LeporeThe sample rate, as described above for the sysctl variable
226649e7627SIan Lepore.Va dev.ads111x.<unit>.<channel>.rate_index .
2275177d294SIan Lepore.El
2285177d294SIan Lepore.Pp
2295177d294SIan LeporeIf no channels are configured, sysctl variables will be created
2305177d294SIan Leporefor all possible channels supported by the device type, otherwise
2315177d294SIan Leporeonly the specified channels are created.
2325177d294SIan Lepore.Sh SEE ALSO
2335177d294SIan Lepore.Xr fdt 4 ,
234acd8b8a1SIan Lepore.Xr sysctl 8
2355177d294SIan Lepore.Sh HISTORY
2365177d294SIan LeporeThe
2375177d294SIan Lepore.Nm
2385177d294SIan Leporedriver first appeared in
2395177d294SIan Lepore.Fx 13.0 .
240