Lines Matching full:hwmon

5 #include <linux/hwmon.h>
80 struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); in lan966x_hwmon_read_temp() local
84 ret = regmap_read(hwmon->regmap_pvt, PVT_SENSOR_STAT, &data); in lan966x_hwmon_read_temp()
99 struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); in lan966x_hwmon_read_fan() local
103 ret = regmap_read(hwmon->regmap_fan, FAN_CNT, &data); in lan966x_hwmon_read_fan()
118 struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); in lan966x_hwmon_read_pwm() local
122 ret = regmap_read(hwmon->regmap_fan, FAN_CFG, &data); in lan966x_hwmon_read_pwm()
133 struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); in lan966x_hwmon_read_pwm_freq() local
138 ret = regmap_read(hwmon->regmap_fan, FAN_PWM_FREQ, &data); in lan966x_hwmon_read_pwm_freq()
147 tmp = DIV_ROUND_CLOSEST(hwmon->clk_rate, 256); in lan966x_hwmon_read_pwm_freq()
177 struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); in lan966x_hwmon_write_pwm() local
182 return regmap_update_bits(hwmon->regmap_fan, FAN_CFG, in lan966x_hwmon_write_pwm()
189 struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); in lan966x_hwmon_write_pwm_freq() local
194 val = DIV_ROUND_CLOSEST(hwmon->clk_rate, val); in lan966x_hwmon_write_pwm_freq()
198 return regmap_update_bits(hwmon->regmap_fan, FAN_PWM_FREQ, in lan966x_hwmon_write_pwm_freq()
284 struct lan966x_hwmon *hwmon = data; in lan966x_hwmon_disable() local
286 regmap_update_bits(hwmon->regmap_pvt, PVT_SENSOR_CFG, in lan966x_hwmon_disable()
292 struct lan966x_hwmon *hwmon) in lan966x_hwmon_enable() argument
307 div = DIV_ROUND_CLOSEST(hwmon->clk_rate, LAN966X_PVT_CLK); in lan966x_hwmon_enable()
310 ret = regmap_update_bits(hwmon->regmap_pvt, PVT_SENSOR_CFG, in lan966x_hwmon_enable()
315 return devm_add_action_or_reset(dev, lan966x_hwmon_disable, hwmon); in lan966x_hwmon_enable()
339 struct lan966x_hwmon *hwmon = data; in lan966x_clk_disable() local
341 clk_disable_unprepare(hwmon->clk); in lan966x_clk_disable()
344 static int lan966x_clk_enable(struct device *dev, struct lan966x_hwmon *hwmon) in lan966x_clk_enable() argument
348 ret = clk_prepare_enable(hwmon->clk); in lan966x_clk_enable()
352 return devm_add_action_or_reset(dev, lan966x_clk_disable, hwmon); in lan966x_clk_enable()
358 struct lan966x_hwmon *hwmon; in lan966x_hwmon_probe() local
362 hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL); in lan966x_hwmon_probe()
363 if (!hwmon) in lan966x_hwmon_probe()
366 hwmon->clk = devm_clk_get(dev, NULL); in lan966x_hwmon_probe()
367 if (IS_ERR(hwmon->clk)) in lan966x_hwmon_probe()
368 return dev_err_probe(dev, PTR_ERR(hwmon->clk), in lan966x_hwmon_probe()
371 ret = lan966x_clk_enable(dev, hwmon); in lan966x_hwmon_probe()
375 hwmon->clk_rate = clk_get_rate(hwmon->clk); in lan966x_hwmon_probe()
377 hwmon->regmap_pvt = lan966x_init_regmap(pdev, "pvt"); in lan966x_hwmon_probe()
378 if (IS_ERR(hwmon->regmap_pvt)) in lan966x_hwmon_probe()
379 return dev_err_probe(dev, PTR_ERR(hwmon->regmap_pvt), in lan966x_hwmon_probe()
382 hwmon->regmap_fan = lan966x_init_regmap(pdev, "fan"); in lan966x_hwmon_probe()
383 if (IS_ERR(hwmon->regmap_fan)) in lan966x_hwmon_probe()
384 return dev_err_probe(dev, PTR_ERR(hwmon->regmap_fan), in lan966x_hwmon_probe()
387 ret = lan966x_hwmon_enable(dev, hwmon); in lan966x_hwmon_probe()
392 "lan966x_hwmon", hwmon, in lan966x_hwmon_probe()
396 "failed to register hwmon device\n"); in lan966x_hwmon_probe()
402 { .compatible = "microchip,lan9668-hwmon" },
410 .name = "lan966x-hwmon",