Lines Matching refs:hwmon

67 static inline int input_tsireg_to_mv(struct da9052_hwmon *hwmon, int value)  in input_tsireg_to_mv()  argument
69 return DIV_ROUND_CLOSEST(value * hwmon->tsiref_mv, 1023); in input_tsireg_to_mv()
88 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_vddout_show() local
91 mutex_lock(&hwmon->hwmon_lock); in da9052_vddout_show()
93 ret = da9052_enable_vddout_channel(hwmon->da9052); in da9052_vddout_show()
97 vdd = da9052_reg_read(hwmon->da9052, DA9052_VDD_RES_REG); in da9052_vddout_show()
103 ret = da9052_disable_vddout_channel(hwmon->da9052); in da9052_vddout_show()
107 mutex_unlock(&hwmon->hwmon_lock); in da9052_vddout_show()
111 da9052_disable_vddout_channel(hwmon->da9052); in da9052_vddout_show()
113 mutex_unlock(&hwmon->hwmon_lock); in da9052_vddout_show()
120 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_ich_show() local
123 ret = da9052_reg_read(hwmon->da9052, DA9052_ICHG_AV_REG); in da9052_ich_show()
134 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_tbat_show() local
136 return sprintf(buf, "%d\n", da9052_adc_read_temp(hwmon->da9052)); in da9052_tbat_show()
142 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_vbat_show() local
145 ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBAT); in da9052_vbat_show()
156 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_misc_channel_show() local
160 ret = da9052_adc_manual_read(hwmon->da9052, channel); in da9052_misc_channel_show()
167 static int da9052_request_tsi_read(struct da9052_hwmon *hwmon, int channel) in da9052_request_tsi_read() argument
186 return da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_B_REG, val); in da9052_request_tsi_read()
189 static int da9052_get_tsi_result(struct da9052_hwmon *hwmon, int channel) in da9052_get_tsi_result() argument
195 err = da9052_group_read(hwmon->da9052, DA9052_TSI_X_MSB_REG, in da9052_get_tsi_result()
223 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in __da9052_read_tsi() local
226 reinit_completion(&hwmon->tsidone); in __da9052_read_tsi()
228 ret = da9052_request_tsi_read(hwmon, channel); in __da9052_read_tsi()
233 if (!wait_for_completion_timeout(&hwmon->tsidone, in __da9052_read_tsi()
237 return da9052_get_tsi_result(hwmon, channel); in __da9052_read_tsi()
243 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_tsi_show() local
247 mutex_lock(&hwmon->da9052->auxadc_lock); in da9052_tsi_show()
249 mutex_unlock(&hwmon->da9052->auxadc_lock); in da9052_tsi_show()
254 return sprintf(buf, "%d\n", input_tsireg_to_mv(hwmon, ret)); in da9052_tsi_show()
260 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_tjunc_show() local
264 tjunc = da9052_reg_read(hwmon->da9052, DA9052_TJUNC_RES_REG); in da9052_tjunc_show()
268 toffset = da9052_reg_read(hwmon->da9052, DA9052_T_OFFSET_REG); in da9052_tjunc_show()
282 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_vbbat_show() local
285 ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBBAT); in da9052_vbbat_show()
303 struct da9052_hwmon *hwmon = dev_get_drvdata(dev); in da9052_channel_is_visible() local
308 if (!hwmon->tsi_as_adc) { in da9052_channel_is_visible()
389 struct da9052_hwmon *hwmon = data; in da9052_tsi_datardy_irq() local
391 complete(&hwmon->tsidone); in da9052_tsi_datardy_irq()
398 struct da9052_hwmon *hwmon; in da9052_hwmon_probe() local
402 hwmon = devm_kzalloc(dev, sizeof(struct da9052_hwmon), GFP_KERNEL); in da9052_hwmon_probe()
403 if (!hwmon) in da9052_hwmon_probe()
406 platform_set_drvdata(pdev, hwmon); in da9052_hwmon_probe()
408 mutex_init(&hwmon->hwmon_lock); in da9052_hwmon_probe()
409 hwmon->da9052 = dev_get_drvdata(pdev->dev.parent); in da9052_hwmon_probe()
411 init_completion(&hwmon->tsidone); in da9052_hwmon_probe()
413 hwmon->tsi_as_adc = in da9052_hwmon_probe()
416 if (hwmon->tsi_as_adc) { in da9052_hwmon_probe()
417 hwmon->tsiref = devm_regulator_get(pdev->dev.parent, "tsiref"); in da9052_hwmon_probe()
418 if (IS_ERR(hwmon->tsiref)) { in da9052_hwmon_probe()
419 err = PTR_ERR(hwmon->tsiref); in da9052_hwmon_probe()
424 err = regulator_enable(hwmon->tsiref); in da9052_hwmon_probe()
428 hwmon->tsiref_mv = regulator_get_voltage(hwmon->tsiref); in da9052_hwmon_probe()
429 if (hwmon->tsiref_mv < 0) { in da9052_hwmon_probe()
430 err = hwmon->tsiref_mv; in da9052_hwmon_probe()
435 hwmon->tsiref_mv /= 1000; in da9052_hwmon_probe()
438 if (hwmon->tsiref_mv < 1800 || hwmon->tsiref_mv > 2600) { in da9052_hwmon_probe()
439 dev_err(hwmon->da9052->dev, "invalid TSIREF voltage: %d", in da9052_hwmon_probe()
440 hwmon->tsiref_mv); in da9052_hwmon_probe()
446 da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00); in da9052_hwmon_probe()
449 da9052_reg_update(hwmon->da9052, DA9052_ADC_CONT_REG, in da9052_hwmon_probe()
453 err = da9052_request_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, in da9052_hwmon_probe()
455 hwmon); in da9052_hwmon_probe()
464 hwmon, in da9052_hwmon_probe()
473 if (hwmon->tsi_as_adc) in da9052_hwmon_probe()
474 da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); in da9052_hwmon_probe()
476 if (hwmon->tsiref) in da9052_hwmon_probe()
477 regulator_disable(hwmon->tsiref); in da9052_hwmon_probe()
484 struct da9052_hwmon *hwmon = platform_get_drvdata(pdev); in da9052_hwmon_remove() local
486 if (hwmon->tsi_as_adc) { in da9052_hwmon_remove()
487 da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); in da9052_hwmon_remove()
488 regulator_disable(hwmon->tsiref); in da9052_hwmon_remove()