Lines Matching +full:mt6370 +full:- +full:adc
1 // SPDX-License-Identifier: GPL-2.0-only
20 #include <dt-bindings/iio/adc/mediatek,mt6370_adc.h>
60 * This mutex lock is for preventing the different ADC channels
74 mutex_lock(&priv->adc_lock); in mt6370_adc_read_channel()
78 ret = regmap_write(priv->regmap, MT6370_REG_CHG_ADC, reg_val); in mt6370_adc_read_channel()
84 ret = regmap_read_poll_timeout(priv->regmap, in mt6370_adc_read_channel()
90 dev_err(priv->dev, "Failed to read ADC register (%d)\n", ret); in mt6370_adc_read_channel()
94 ret = regmap_raw_read(priv->regmap, MT6370_REG_ADC_DATA_H, in mt6370_adc_read_channel()
103 mutex_unlock(&priv->adc_lock); in mt6370_adc_read_channel()
110 switch (priv->vid) { in mt6370_adc_get_ibus_scale()
122 switch (priv->vid) { in mt6370_adc_get_ibat_scale()
145 ret = regmap_read(priv->regmap, MT6370_REG_CHG_CTRL3, ®_val); in mt6370_adc_read_scale()
168 ret = regmap_read(priv->regmap, MT6370_REG_CHG_CTRL7, ®_val); in mt6370_adc_read_scale()
208 return -EINVAL; in mt6370_adc_read_scale()
215 *val = -20; in mt6370_adc_read_offset()
228 return mt6370_adc_read_channel(priv, chan->channel, in mt6370_adc_read_raw()
229 chan->address, val); in mt6370_adc_read_raw()
231 return mt6370_adc_read_scale(priv, chan->channel, val, val2); in mt6370_adc_read_raw()
233 return mt6370_adc_read_offset(priv, chan->channel, val); in mt6370_adc_read_raw()
235 return -EINVAL; in mt6370_adc_read_raw()
254 return sysfs_emit(label, "%s\n", mt6370_channel_labels[chan->channel]); in mt6370_adc_read_label()
290 ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, &dev_info); in mt6370_get_vendor_info()
294 priv->vid = FIELD_GET(MT6370_VENID_MASK, dev_info); in mt6370_get_vendor_info()
301 struct device *dev = &pdev->dev; in mt6370_adc_probe()
307 regmap = dev_get_regmap(pdev->dev.parent, NULL); in mt6370_adc_probe()
309 return dev_err_probe(dev, -ENODEV, "Failed to get regmap\n"); in mt6370_adc_probe()
313 return -ENOMEM; in mt6370_adc_probe()
316 priv->dev = dev; in mt6370_adc_probe()
317 priv->regmap = regmap; in mt6370_adc_probe()
318 mutex_init(&priv->adc_lock); in mt6370_adc_probe()
324 ret = regmap_write(priv->regmap, MT6370_REG_CHG_ADC, 0); in mt6370_adc_probe()
326 return dev_err_probe(dev, ret, "Failed to reset ADC\n"); in mt6370_adc_probe()
328 indio_dev->name = "mt6370-adc"; in mt6370_adc_probe()
329 indio_dev->info = &mt6370_adc_iio_info; in mt6370_adc_probe()
330 indio_dev->modes = INDIO_DIRECT_MODE; in mt6370_adc_probe()
331 indio_dev->channels = mt6370_adc_channels; in mt6370_adc_probe()
332 indio_dev->num_channels = ARRAY_SIZE(mt6370_adc_channels); in mt6370_adc_probe()
338 { .compatible = "mediatek,mt6370-adc", },
345 .name = "mt6370-adc",
353 MODULE_DESCRIPTION("MT6370 ADC Driver");