Lines Matching full:hwmon
3 * HWMON Driver for Dialog DA9052
11 #include <linux/hwmon.h>
12 #include <linux/hwmon-sysfs.h>
66 static inline int input_tsireg_to_mv(struct da9052_hwmon *hwmon, int value) in input_tsireg_to_mv() argument
68 return DIV_ROUND_CLOSEST(value * hwmon->tsiref_mv, 1023); in input_tsireg_to_mv()
87 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_vddout_show() local
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()
119 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_ich_show() local
122 ret = da9052_reg_read(hwmon->da9052, DA9052_ICHG_AV_REG); in da9052_ich_show()
133 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_tbat_show() local
135 return sprintf(buf, "%d\n", da9052_adc_read_temp(hwmon->da9052)); in da9052_tbat_show()
141 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_vbat_show() local
144 ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBAT); in da9052_vbat_show()
155 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_misc_channel_show() local
159 ret = da9052_adc_manual_read(hwmon->da9052, channel); in da9052_misc_channel_show()
166 static int da9052_request_tsi_read(struct da9052_hwmon *hwmon, int channel) in da9052_request_tsi_read() argument
185 return da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_B_REG, val); in da9052_request_tsi_read()
188 static int da9052_get_tsi_result(struct da9052_hwmon *hwmon, int channel) in da9052_get_tsi_result() argument
194 err = da9052_group_read(hwmon->da9052, DA9052_TSI_X_MSB_REG, in da9052_get_tsi_result()
222 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in __da9052_read_tsi() local
225 reinit_completion(&hwmon->tsidone); in __da9052_read_tsi()
227 ret = da9052_request_tsi_read(hwmon, channel); in __da9052_read_tsi()
232 if (!wait_for_completion_timeout(&hwmon->tsidone, in __da9052_read_tsi()
236 return da9052_get_tsi_result(hwmon, channel); in __da9052_read_tsi()
242 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_tsi_show() local
246 mutex_lock(&hwmon->da9052->auxadc_lock); in da9052_tsi_show()
248 mutex_unlock(&hwmon->da9052->auxadc_lock); in da9052_tsi_show()
253 return sprintf(buf, "%d\n", input_tsireg_to_mv(hwmon, ret)); in da9052_tsi_show()
259 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_tjunc_show() local
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()
281 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_vbbat_show() local
284 ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBBAT); in da9052_vbbat_show()
302 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_channel_is_visible() local
307 if (!hwmon->tsi_as_adc) { in da9052_channel_is_visible()
388 struct da9052_hwmon *hwmon = data; in da9052_tsi_datardy_irq() local
390 complete(&hwmon->tsidone); in da9052_tsi_datardy_irq()
397 struct da9052_hwmon *hwmon; in da9052_hwmon_probe() local
401 hwmon = devm_kzalloc(dev, sizeof(struct da9052_hwmon), GFP_KERNEL); in da9052_hwmon_probe()
402 if (!hwmon) in da9052_hwmon_probe()
405 platform_set_drvdata(pdev, hwmon); 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()
415 if (hwmon->tsi_as_adc) { in da9052_hwmon_probe()
422 /* convert from microvolt (DT) to millivolt (hwmon) */ 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()
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()
442 hwmon); in da9052_hwmon_probe()
451 hwmon, 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()
468 struct da9052_hwmon *hwmon = platform_get_drvdata(pdev); in da9052_hwmon_remove() local
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",
485 MODULE_DESCRIPTION("DA9052 HWMON driver");
487 MODULE_ALIAS("platform:da9052-hwmon");