Lines Matching full:ctl
64 const struct axi_fan_control_data *ctl) in axi_iowrite() argument
66 iowrite32(val, ctl->base + reg); in axi_iowrite()
70 const struct axi_fan_control_data *ctl) in axi_ioread() argument
72 return ioread32(ctl->base + reg); in axi_ioread()
81 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_show() local
83 u32 temp = axi_ioread(attr->index, ctl); in axi_fan_control_show()
93 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_store() local
103 axi_iowrite(temp, attr->index, ctl); in axi_fan_control_store()
108 static long axi_fan_control_get_pwm_duty(const struct axi_fan_control_data *ctl) in axi_fan_control_get_pwm_duty() argument
110 u32 pwm_width = axi_ioread(ADI_REG_PWM_WIDTH, ctl); in axi_fan_control_get_pwm_duty()
111 u32 pwm_period = axi_ioread(ADI_REG_PWM_PERIOD, ctl); in axi_fan_control_get_pwm_duty()
120 struct axi_fan_control_data *ctl) in axi_fan_control_set_pwm_duty() argument
122 u32 pwm_period = axi_ioread(ADI_REG_PWM_PERIOD, ctl); in axi_fan_control_set_pwm_duty()
128 axi_iowrite(new_width, ADI_REG_PWM_WIDTH, ctl); in axi_fan_control_set_pwm_duty()
133 static long axi_fan_control_get_fan_rpm(const struct axi_fan_control_data *ctl) in axi_fan_control_get_fan_rpm() argument
135 const u32 tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl); in axi_fan_control_get_fan_rpm()
148 return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach); in axi_fan_control_get_fan_rpm()
153 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_temp() local
158 raw_temp = axi_ioread(ADI_REG_TEMPERATURE, ctl); in axi_fan_control_read_temp()
174 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_fan() local
178 *val = ctl->fan_fault; in axi_fan_control_read_fan()
180 ctl->fan_fault = 0; in axi_fan_control_read_fan()
183 *val = axi_fan_control_get_fan_rpm(ctl); in axi_fan_control_read_fan()
192 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_pwm() local
196 *val = axi_fan_control_get_pwm_duty(ctl); in axi_fan_control_read_pwm()
205 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_write_pwm() local
209 return axi_fan_control_set_pwm_duty(val, ctl); in axi_fan_control_write_pwm()
321 * already to the ney duty cycle) based on the %ctl->hw_pwm_req flag.
325 struct axi_fan_control_data *ctl = (struct axi_fan_control_data *)data; in axi_fan_control_irq_handler() local
326 u32 irq_pending = axi_ioread(ADI_REG_IRQ_PENDING, ctl); in axi_fan_control_irq_handler()
331 ctl->hw_pwm_req = true; in axi_fan_control_irq_handler()
339 if (!ctl->hw_pwm_req) { in axi_fan_control_irq_handler()
340 ctl->update_tacho_params = true; in axi_fan_control_irq_handler()
342 ctl->hw_pwm_req = false; in axi_fan_control_irq_handler()
343 hwmon_notify_event(ctl->hdev, hwmon_pwm, in axi_fan_control_irq_handler()
349 if (ctl->update_tacho_params) { in axi_fan_control_irq_handler()
350 u32 new_tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl); in axi_fan_control_irq_handler()
355 axi_iowrite(new_tach, ADI_REG_TACH_PERIOD, ctl); in axi_fan_control_irq_handler()
356 axi_iowrite(tach_tol, ADI_REG_TACH_TOLERANCE, ctl); in axi_fan_control_irq_handler()
357 ctl->update_tacho_params = false; in axi_fan_control_irq_handler()
362 ctl->fan_fault = 1; in axi_fan_control_irq_handler()
366 axi_iowrite(clear_mask, ADI_REG_IRQ_PENDING, ctl); in axi_fan_control_irq_handler()
371 static int axi_fan_control_init(struct axi_fan_control_data *ctl, in axi_fan_control_init() argument
377 ret = device_property_read_u32(dev, "pulses-per-revolution", &ctl->ppr); in axi_fan_control_init()
382 if (ctl->ppr != 1 && ctl->ppr != 2 && ctl->ppr != 4) in axi_fan_control_init()
390 ADI_REG_IRQ_MASK, ctl); in axi_fan_control_init()
393 axi_iowrite(0x01, ADI_REG_RSTN, ctl); in axi_fan_control_init()
449 struct axi_fan_control_data *ctl; in axi_fan_control_probe() local
460 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL); in axi_fan_control_probe()
461 if (!ctl) in axi_fan_control_probe()
464 ctl->base = devm_platform_ioremap_resource(pdev, 0); in axi_fan_control_probe()
465 if (IS_ERR(ctl->base)) in axi_fan_control_probe()
466 return PTR_ERR(ctl->base); in axi_fan_control_probe()
473 ctl->clk_rate = clk_get_rate(clk); in axi_fan_control_probe()
474 if (!ctl->clk_rate) in axi_fan_control_probe()
477 version = axi_ioread(ADI_AXI_REG_VERSION, ctl); in axi_fan_control_probe()
489 ret = axi_fan_control_init(ctl, &pdev->dev); in axi_fan_control_probe()
494 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, in axi_fan_control_probe()
496 ctl, in axi_fan_control_probe()
500 if (IS_ERR(ctl->hdev)) in axi_fan_control_probe()
501 return PTR_ERR(ctl->hdev); in axi_fan_control_probe()
503 ctl->irq = platform_get_irq(pdev, 0); in axi_fan_control_probe()
504 if (ctl->irq < 0) in axi_fan_control_probe()
505 return ctl->irq; in axi_fan_control_probe()
507 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL, in axi_fan_control_probe()
510 pdev->driver_override, ctl); in axi_fan_control_probe()