Lines Matching +full:in4 +full:- +full:in5
1 // SPDX-License-Identifier: GPL-2.0-or-later
12 #include <linux/hwmon-sysfs.h>
37 [DA9052_ADC_IN4] = "ADC IN4",
38 [DA9052_ADC_IN5] = "ADC IN5",
42 [DA9052_ADC_TSI_XN] = "ADC TS X-",
43 [DA9052_ADC_TSI_YN] = "ADC TS Y-",
45 [DA9052_ADC_VBBAT] = "BACK-UP BATTERY VOLTAGE",
68 return DIV_ROUND_CLOSEST(value * hwmon->tsiref_mv, 1023); in input_tsireg_to_mv()
90 mutex_lock(&hwmon->hwmon_lock); in da9052_vddout_show()
92 ret = da9052_enable_vddout_channel(hwmon->da9052); in da9052_vddout_show()
96 vdd = da9052_reg_read(hwmon->da9052, DA9052_VDD_RES_REG); in da9052_vddout_show()
102 ret = da9052_disable_vddout_channel(hwmon->da9052); in da9052_vddout_show()
106 mutex_unlock(&hwmon->hwmon_lock); in da9052_vddout_show()
110 da9052_disable_vddout_channel(hwmon->da9052); in da9052_vddout_show()
112 mutex_unlock(&hwmon->hwmon_lock); in da9052_vddout_show()
122 ret = da9052_reg_read(hwmon->da9052, DA9052_ICHG_AV_REG); in da9052_ich_show()
135 return sprintf(buf, "%d\n", da9052_adc_read_temp(hwmon->da9052)); in da9052_tbat_show()
144 ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBAT); in da9052_vbat_show()
156 int channel = to_sensor_dev_attr(devattr)->index; in da9052_misc_channel_show()
159 ret = da9052_adc_manual_read(hwmon->da9052, channel); in da9052_misc_channel_show()
185 return da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_B_REG, val); in da9052_request_tsi_read()
194 err = da9052_group_read(hwmon->da9052, DA9052_TSI_X_MSB_REG, in da9052_get_tsi_result()
213 return -EINVAL; in da9052_get_tsi_result()
225 reinit_completion(&hwmon->tsidone); in __da9052_read_tsi()
232 if (!wait_for_completion_timeout(&hwmon->tsidone, in __da9052_read_tsi()
234 return -ETIMEDOUT; in __da9052_read_tsi()
243 int channel = to_sensor_dev_attr(devattr)->index; in da9052_tsi_show()
246 mutex_lock(&hwmon->da9052->auxadc_lock); in da9052_tsi_show()
248 mutex_unlock(&hwmon->da9052->auxadc_lock); in da9052_tsi_show()
263 tjunc = da9052_reg_read(hwmon->da9052, DA9052_TJUNC_RES_REG); in da9052_tjunc_show()
267 toffset = da9052_reg_read(hwmon->da9052, DA9052_T_OFFSET_REG); in da9052_tjunc_show()
272 * Degrees celsius = 1.708 * (TJUNC_RES - T_OFFSET) - 108.8 in da9052_tjunc_show()
275 return sprintf(buf, "%d\n", 1708 * (tjunc - toffset) - 108800); in da9052_tjunc_show()
284 ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBBAT); in da9052_vbbat_show()
295 input_names[to_sensor_dev_attr(devattr)->index]); in label_show()
307 if (!hwmon->tsi_as_adc) { in da9052_channel_is_visible()
308 switch (sattr->index) { in da9052_channel_is_visible()
317 return attr->mode; in da9052_channel_is_visible()
390 complete(&hwmon->tsidone); in da9052_tsi_datardy_irq()
396 struct device *dev = &pdev->dev; in da9052_hwmon_probe()
403 return -ENOMEM; in da9052_hwmon_probe()
407 mutex_init(&hwmon->hwmon_lock); in da9052_hwmon_probe()
408 hwmon->da9052 = dev_get_drvdata(pdev->dev.parent); in da9052_hwmon_probe()
410 init_completion(&hwmon->tsidone); in da9052_hwmon_probe()
412 hwmon->tsi_as_adc = in da9052_hwmon_probe()
413 device_property_read_bool(pdev->dev.parent, "dlg,tsi-as-adc"); in da9052_hwmon_probe()
415 if (hwmon->tsi_as_adc) { in da9052_hwmon_probe()
416 tsiref_uv = devm_regulator_get_enable_read_voltage(dev->parent, in da9052_hwmon_probe()
423 hwmon->tsiref_mv = tsiref_uv / 1000; in da9052_hwmon_probe()
426 if (hwmon->tsiref_mv < 1800 || hwmon->tsiref_mv > 2600) { in da9052_hwmon_probe()
427 dev_err(hwmon->da9052->dev, "invalid TSIREF voltage: %d", in da9052_hwmon_probe()
428 hwmon->tsiref_mv); in da9052_hwmon_probe()
429 return -ENXIO; in da9052_hwmon_probe()
433 da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00); in da9052_hwmon_probe()
436 da9052_reg_update(hwmon->da9052, DA9052_ADC_CONT_REG, in da9052_hwmon_probe()
440 err = da9052_request_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, in da9052_hwmon_probe()
441 "tsiready-irq", da9052_tsi_datardy_irq, in da9052_hwmon_probe()
444 dev_err(&pdev->dev, "Failed to register TSIRDY IRQ: %d", in da9052_hwmon_probe()
460 if (hwmon->tsi_as_adc) in da9052_hwmon_probe()
461 da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); in da9052_hwmon_probe()
470 if (hwmon->tsi_as_adc) in da9052_hwmon_remove()
471 da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); in da9052_hwmon_remove()
478 .name = "da9052-hwmon",
487 MODULE_ALIAS("platform:da9052-hwmon");