Lines Matching +full:adc +full:- +full:chan
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Nano River Technologies viperboard IIO ADC driver
27 u8 chan; member
50 struct iio_chan_spec const *chan, in vprbrd_iio_read_raw() argument
56 struct vprbrd_adc *adc = iio_priv(iio_dev); in vprbrd_iio_read_raw() local
57 struct vprbrd *vb = adc->vb; in vprbrd_iio_read_raw()
58 struct vprbrd_adc_msg *admsg = (struct vprbrd_adc_msg *)vb->buf; in vprbrd_iio_read_raw()
62 mutex_lock(&vb->lock); in vprbrd_iio_read_raw()
64 admsg->cmd = VPRBRD_ADC_CMD_GET; in vprbrd_iio_read_raw()
65 admsg->chan = chan->channel; in vprbrd_iio_read_raw()
66 admsg->val = 0x00; in vprbrd_iio_read_raw()
68 ret = usb_control_msg(vb->usb_dev, in vprbrd_iio_read_raw()
69 usb_sndctrlpipe(vb->usb_dev, 0), VPRBRD_USB_REQUEST_ADC, in vprbrd_iio_read_raw()
73 dev_err(&iio_dev->dev, "usb send error on adc read\n"); in vprbrd_iio_read_raw()
74 error = -EREMOTEIO; in vprbrd_iio_read_raw()
77 ret = usb_control_msg(vb->usb_dev, in vprbrd_iio_read_raw()
78 usb_rcvctrlpipe(vb->usb_dev, 0), VPRBRD_USB_REQUEST_ADC, in vprbrd_iio_read_raw()
82 *val = admsg->val; in vprbrd_iio_read_raw()
84 mutex_unlock(&vb->lock); in vprbrd_iio_read_raw()
87 dev_err(&iio_dev->dev, "usb recv error on adc read\n"); in vprbrd_iio_read_raw()
88 error = -EREMOTEIO; in vprbrd_iio_read_raw()
96 error = -EINVAL; in vprbrd_iio_read_raw()
109 struct vprbrd *vb = dev_get_drvdata(pdev->dev.parent); in vprbrd_adc_probe()
110 struct vprbrd_adc *adc; in vprbrd_adc_probe() local
115 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); in vprbrd_adc_probe()
117 dev_err(&pdev->dev, "failed allocating iio device\n"); in vprbrd_adc_probe()
118 return -ENOMEM; in vprbrd_adc_probe()
121 adc = iio_priv(indio_dev); in vprbrd_adc_probe()
122 adc->vb = vb; in vprbrd_adc_probe()
123 indio_dev->name = "viperboard adc"; in vprbrd_adc_probe()
124 indio_dev->info = &vprbrd_adc_iio_info; in vprbrd_adc_probe()
125 indio_dev->modes = INDIO_DIRECT_MODE; in vprbrd_adc_probe()
126 indio_dev->channels = vprbrd_adc_iio_channels; in vprbrd_adc_probe()
127 indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels); in vprbrd_adc_probe()
129 ret = devm_iio_device_register(&pdev->dev, indio_dev); in vprbrd_adc_probe()
131 dev_err(&pdev->dev, "could not register iio (adc)"); in vprbrd_adc_probe()
140 .name = "viperboard-adc",
148 MODULE_DESCRIPTION("IIO ADC driver for Nano River Techs Viperboard");
150 MODULE_ALIAS("platform:viperboard-adc");