Lines Matching full:adc_tm

201 	unsigned int		decimation;	/* For Gen2 ADC_TM */
202 unsigned int avg_samples; /* For Gen2 ADC_TM */
203 bool high_thr_en; /* For Gen2 ADC_TM */
204 bool low_thr_en; /* For Gen2 ADC_TM */
205 bool meas_en; /* For Gen2 ADC_TM */
219 * Applies to all channels, used only on Gen1 ADC_TM.
222 * channels, used only on Gen1 ADC_TM.
224 * @adc_mutex_lock: ADC_TM mutex lock, used only on Gen2 ADC_TM.
241 static int adc_tm5_read(struct adc_tm5_chip *adc_tm, u16 offset, u8 *data, int len) in adc_tm5_read() argument
243 return regmap_bulk_read(adc_tm->regmap, adc_tm->base + offset, data, len); in adc_tm5_read()
246 static int adc_tm5_write(struct adc_tm5_chip *adc_tm, u16 offset, u8 *data, int len) in adc_tm5_write() argument
248 return regmap_bulk_write(adc_tm->regmap, adc_tm->base + offset, data, len); in adc_tm5_write()
251 static int adc_tm5_reg_update(struct adc_tm5_chip *adc_tm, u16 offset, u8 mask, u8 val) in adc_tm5_reg_update() argument
253 return regmap_write_bits(adc_tm->regmap, adc_tm->base + offset, mask, val); in adc_tm5_reg_update()
668 static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm) in adc_tm5_register_tzd() argument
673 for (i = 0; i < adc_tm->nchannels; i++) { in adc_tm5_register_tzd()
674 adc_tm->channels[i].chip = adc_tm; in adc_tm5_register_tzd()
675 tzd = devm_thermal_of_zone_register(adc_tm->dev, in adc_tm5_register_tzd()
676 adc_tm->channels[i].channel, in adc_tm5_register_tzd()
677 &adc_tm->channels[i], in adc_tm5_register_tzd()
681 dev_dbg(adc_tm->dev, "thermal sensor on channel %d is not used\n", in adc_tm5_register_tzd()
682 adc_tm->channels[i].channel); in adc_tm5_register_tzd()
686 dev_err(adc_tm->dev, "Error registering TZ zone for channel %d: %ld\n", in adc_tm5_register_tzd()
687 adc_tm->channels[i].channel, PTR_ERR(tzd)); in adc_tm5_register_tzd()
690 adc_tm->channels[i].tzd = tzd; in adc_tm5_register_tzd()
691 devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd); in adc_tm5_register_tzd()
780 static int adc_tm5_get_dt_channel_data(struct adc_tm5_chip *adc_tm, in adc_tm5_get_dt_channel_data() argument
787 struct device *dev = adc_tm->dev; in adc_tm5_get_dt_channel_data()
821 if (adc_tm->data->gen == ADC_TM5_GEN2) in adc_tm5_get_dt_channel_data()
830 channel->iio = devm_fwnode_iio_channel_get_by_name(adc_tm->dev, in adc_tm5_get_dt_channel_data()
852 ret = qcom_adc5_hw_settle_time_from_dt(value, adc_tm->data->hw_settle); in adc_tm5_get_dt_channel_data()
868 if (adc_tm->data->gen == ADC_TM5_GEN2) { in adc_tm5_get_dt_channel_data()
871 ret = qcom_adc5_decimation_from_dt(value, adc_tm->data->decimation); in adc_tm5_get_dt_channel_data()
938 static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node *node) in adc_tm5_get_dt_data() argument
944 struct device *dev = adc_tm->dev; in adc_tm5_get_dt_data()
946 adc_tm->nchannels = of_get_available_child_count(node); in adc_tm5_get_dt_data()
947 if (!adc_tm->nchannels) in adc_tm5_get_dt_data()
950 adc_tm->channels = devm_kcalloc(dev, adc_tm->nchannels, in adc_tm5_get_dt_data()
951 sizeof(*adc_tm->channels), GFP_KERNEL); in adc_tm5_get_dt_data()
952 if (!adc_tm->channels) in adc_tm5_get_dt_data()
955 channels = adc_tm->channels; in adc_tm5_get_dt_data()
957 adc_tm->data = of_device_get_match_data(dev); in adc_tm5_get_dt_data()
958 if (!adc_tm->data) in adc_tm5_get_dt_data()
959 adc_tm->data = &adc_tm5_data_pmic; in adc_tm5_get_dt_data()
963 ret = qcom_adc5_decimation_from_dt(value, adc_tm->data->decimation); in adc_tm5_get_dt_data()
968 adc_tm->decimation = ret; in adc_tm5_get_dt_data()
970 adc_tm->decimation = ADC5_DECIMATION_DEFAULT; in adc_tm5_get_dt_data()
980 adc_tm->avg_samples = ret; in adc_tm5_get_dt_data()
982 adc_tm->avg_samples = VADC_DEF_AVG_SAMPLES; in adc_tm5_get_dt_data()
986 ret = adc_tm5_get_dt_channel_data(adc_tm, channels, child); in adc_tm5_get_dt_data()
1002 struct adc_tm5_chip *adc_tm; in adc_tm5_probe() local
1015 adc_tm = devm_kzalloc(&pdev->dev, sizeof(*adc_tm), GFP_KERNEL); in adc_tm5_probe()
1016 if (!adc_tm) in adc_tm5_probe()
1019 adc_tm->regmap = regmap; in adc_tm5_probe()
1020 adc_tm->dev = dev; in adc_tm5_probe()
1021 adc_tm->base = reg; in adc_tm5_probe()
1027 ret = adc_tm5_get_dt_data(adc_tm, node); in adc_tm5_probe()
1031 ret = adc_tm->data->init(adc_tm); in adc_tm5_probe()
1037 ret = adc_tm5_register_tzd(adc_tm); in adc_tm5_probe()
1043 return devm_request_threaded_irq(dev, irq, NULL, adc_tm->data->isr, in adc_tm5_probe()
1044 IRQF_ONESHOT, adc_tm->data->irq_name, adc_tm); in adc_tm5_probe()