Lines Matching +full:adc +full:- +full:dev

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
41 #include <dev/iicbus/iicbus.h>
42 #include <dev/iicbus/iiconf.h>
45 #include <dev/ofw/ofw_bus.h>
46 #include <dev/ofw/ofw_bus_subr.h>
50 * Driver for PCF8591 I2C 8-bit ADC and DAC.
77 pcf8591_set_config(device_t dev) in pcf8591_set_config() argument
85 sc = device_get_softc(dev); in pcf8591_set_config()
86 data[0] = sc->sc_cfg; in pcf8591_set_config()
87 data[1] = sc->sc_output; in pcf8591_set_config()
88 msg.slave = sc->sc_addr; in pcf8591_set_config()
93 error = iicbus_transfer_excl(dev, &msg, 1, IIC_INTRWAIT); in pcf8591_set_config()
98 pcf8591_get_reading(device_t dev, uint8_t *reading) in pcf8591_get_reading() argument
104 sc = device_get_softc(dev); in pcf8591_get_reading()
106 msg.slave = sc->sc_addr; in pcf8591_get_reading()
111 error = iicbus_transfer_excl(dev, &msg, 1, IIC_INTRWAIT); in pcf8591_get_reading()
116 pcf8591_select_channel(device_t dev, int channel) in pcf8591_select_channel() argument
122 sc = device_get_softc(dev); in pcf8591_select_channel()
123 if (channel >= sc->sc_ch_count) in pcf8591_select_channel()
125 sc->sc_cfg &= ~CTRL_CH_SELECT_MASK; in pcf8591_select_channel()
126 sc->sc_cfg += channel; in pcf8591_select_channel()
127 error = pcf8591_set_config(dev); in pcf8591_select_channel()
135 error = pcf8591_get_reading(dev, &unused); in pcf8591_select_channel()
142 device_t dev; in pcf8591_channel_sysctl() local
146 dev = arg1; in pcf8591_channel_sysctl()
149 if (req->oldptr != NULL) { in pcf8591_channel_sysctl()
150 error = pcf8591_select_channel(dev, channel); in pcf8591_channel_sysctl()
153 error = pcf8591_get_reading(dev, &reading); in pcf8591_channel_sysctl()
165 device_t dev; in pcf8591_start() local
174 dev = sc->sc_dev; in pcf8591_start()
177 * Set initial -- and, for the time being, fixed -- configuration. in pcf8591_start()
178 * Channel auto-incrementi is disabled, although it could be more in pcf8591_start()
183 sc->sc_cfg = 0; in pcf8591_start()
184 sc->sc_output = 0; in pcf8591_start()
185 sc->sc_ch_count = 4; in pcf8591_start()
186 (void)pcf8591_set_config(dev); in pcf8591_start()
188 ctx = device_get_sysctl_ctx(dev); in pcf8591_start()
189 tree_node = device_get_sysctl_tree(dev); in pcf8591_start()
195 for (int i = 0; i < sc->sc_ch_count; i++) { in pcf8591_start()
200 CTLTYPE_INT | CTLFLAG_RD, dev, i, in pcf8591_start()
207 pcf8591_probe(device_t dev) in pcf8591_probe() argument
210 if (!ofw_bus_status_okay(dev)) in pcf8591_probe()
213 device_set_desc(dev, "PCF8591 8-bit ADC / DAC"); in pcf8591_probe()
215 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data) in pcf8591_probe()
222 pcf8591_attach(device_t dev) in pcf8591_attach() argument
226 sc = device_get_softc(dev); in pcf8591_attach()
227 sc->sc_dev = dev; in pcf8591_attach()
228 sc->sc_addr = iicbus_get_addr(dev); in pcf8591_attach()
239 pcf8591_detach(device_t dev) in pcf8591_detach() argument