Lines Matching refs:ctl
54 const struct axi_fan_control_data *ctl) in axi_iowrite() argument
56 iowrite32(val, ctl->base + reg); in axi_iowrite()
60 const struct axi_fan_control_data *ctl) in axi_ioread() argument
62 return ioread32(ctl->base + reg); in axi_ioread()
65 static long axi_fan_control_get_pwm_duty(const struct axi_fan_control_data *ctl) in axi_fan_control_get_pwm_duty() argument
67 u32 pwm_width = axi_ioread(ADI_REG_PWM_WIDTH, ctl); in axi_fan_control_get_pwm_duty()
68 u32 pwm_period = axi_ioread(ADI_REG_PWM_PERIOD, ctl); in axi_fan_control_get_pwm_duty()
77 struct axi_fan_control_data *ctl) in axi_fan_control_set_pwm_duty() argument
79 u32 pwm_period = axi_ioread(ADI_REG_PWM_PERIOD, ctl); in axi_fan_control_set_pwm_duty()
85 axi_iowrite(new_width, ADI_REG_PWM_WIDTH, ctl); in axi_fan_control_set_pwm_duty()
90 static long axi_fan_control_get_fan_rpm(const struct axi_fan_control_data *ctl) in axi_fan_control_get_fan_rpm() argument
92 const u32 tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl); in axi_fan_control_get_fan_rpm()
105 return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach); in axi_fan_control_get_fan_rpm()
110 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_temp() local
115 raw_temp = axi_ioread(ADI_REG_TEMPERATURE, ctl); in axi_fan_control_read_temp()
131 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_fan() local
135 *val = ctl->fan_fault; in axi_fan_control_read_fan()
137 ctl->fan_fault = 0; in axi_fan_control_read_fan()
140 *val = axi_fan_control_get_fan_rpm(ctl); in axi_fan_control_read_fan()
149 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_pwm() local
153 *val = axi_fan_control_get_pwm_duty(ctl); in axi_fan_control_read_pwm()
162 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_write_pwm() local
166 return axi_fan_control_set_pwm_duty(val, ctl); in axi_fan_control_write_pwm()
282 struct axi_fan_control_data *ctl = (struct axi_fan_control_data *)data; in axi_fan_control_irq_handler() local
283 u32 irq_pending = axi_ioread(ADI_REG_IRQ_PENDING, ctl); in axi_fan_control_irq_handler()
287 if (ctl->update_tacho_params) { in axi_fan_control_irq_handler()
288 u32 new_tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl); in axi_fan_control_irq_handler()
293 axi_iowrite(new_tach, ADI_REG_TACH_PERIOD, ctl); in axi_fan_control_irq_handler()
294 axi_iowrite(tach_tol, ADI_REG_TACH_TOLERANCE, ctl); in axi_fan_control_irq_handler()
295 ctl->update_tacho_params = false; in axi_fan_control_irq_handler()
305 if (!ctl->hw_pwm_req) { in axi_fan_control_irq_handler()
306 ctl->update_tacho_params = true; in axi_fan_control_irq_handler()
308 ctl->hw_pwm_req = false; in axi_fan_control_irq_handler()
309 sysfs_notify(&ctl->hdev->kobj, NULL, "pwm1"); in axi_fan_control_irq_handler()
315 ctl->hw_pwm_req = true; in axi_fan_control_irq_handler()
318 ctl->fan_fault = 1; in axi_fan_control_irq_handler()
322 axi_iowrite(clear_mask, ADI_REG_IRQ_PENDING, ctl); in axi_fan_control_irq_handler()
327 static int axi_fan_control_init(struct axi_fan_control_data *ctl, in axi_fan_control_init() argument
333 ret = of_property_read_u32(np, "pulses-per-revolution", &ctl->ppr); in axi_fan_control_init()
338 if (ctl->ppr != 1 && ctl->ppr != 2 && ctl->ppr != 4) in axi_fan_control_init()
346 ADI_REG_IRQ_MASK, ctl); in axi_fan_control_init()
349 axi_iowrite(0x01, ADI_REG_RSTN, ctl); in axi_fan_control_init()
384 struct axi_fan_control_data *ctl; in axi_fan_control_probe() local
395 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL); in axi_fan_control_probe()
396 if (!ctl) in axi_fan_control_probe()
399 ctl->base = devm_platform_ioremap_resource(pdev, 0); in axi_fan_control_probe()
400 if (IS_ERR(ctl->base)) in axi_fan_control_probe()
401 return PTR_ERR(ctl->base); in axi_fan_control_probe()
409 ctl->clk_rate = clk_get_rate(clk); in axi_fan_control_probe()
410 if (!ctl->clk_rate) in axi_fan_control_probe()
413 version = axi_ioread(ADI_AXI_REG_VERSION, ctl); in axi_fan_control_probe()
426 ctl->irq = platform_get_irq(pdev, 0); in axi_fan_control_probe()
427 if (ctl->irq < 0) in axi_fan_control_probe()
428 return ctl->irq; in axi_fan_control_probe()
430 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL, in axi_fan_control_probe()
433 pdev->driver_override, ctl); in axi_fan_control_probe()
439 ret = axi_fan_control_init(ctl, pdev->dev.of_node); in axi_fan_control_probe()
445 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, in axi_fan_control_probe()
447 ctl, in axi_fan_control_probe()
451 return PTR_ERR_OR_ZERO(ctl->hdev); in axi_fan_control_probe()