Lines Matching refs:ctl

63 			       const struct axi_fan_control_data *ctl)  in axi_iowrite()  argument
65 iowrite32(val, ctl->base + reg); in axi_iowrite()
69 const struct axi_fan_control_data *ctl) in axi_ioread() argument
71 return ioread32(ctl->base + reg); in axi_ioread()
80 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_show() local
82 u32 temp = axi_ioread(attr->index, ctl); in axi_fan_control_show()
92 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_store() local
102 axi_iowrite(temp, attr->index, ctl); in axi_fan_control_store()
107 static long axi_fan_control_get_pwm_duty(const struct axi_fan_control_data *ctl) in axi_fan_control_get_pwm_duty() argument
109 u32 pwm_width = axi_ioread(ADI_REG_PWM_WIDTH, ctl); in axi_fan_control_get_pwm_duty()
110 u32 pwm_period = axi_ioread(ADI_REG_PWM_PERIOD, ctl); in axi_fan_control_get_pwm_duty()
119 struct axi_fan_control_data *ctl) in axi_fan_control_set_pwm_duty() argument
121 u32 pwm_period = axi_ioread(ADI_REG_PWM_PERIOD, ctl); in axi_fan_control_set_pwm_duty()
127 axi_iowrite(new_width, ADI_REG_PWM_WIDTH, ctl); in axi_fan_control_set_pwm_duty()
132 static long axi_fan_control_get_fan_rpm(const struct axi_fan_control_data *ctl) in axi_fan_control_get_fan_rpm() argument
134 const u32 tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl); in axi_fan_control_get_fan_rpm()
147 return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach); in axi_fan_control_get_fan_rpm()
152 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_temp() local
157 raw_temp = axi_ioread(ADI_REG_TEMPERATURE, ctl); in axi_fan_control_read_temp()
173 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_fan() local
177 *val = ctl->fan_fault; in axi_fan_control_read_fan()
179 ctl->fan_fault = 0; in axi_fan_control_read_fan()
182 *val = axi_fan_control_get_fan_rpm(ctl); in axi_fan_control_read_fan()
191 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_read_pwm() local
195 *val = axi_fan_control_get_pwm_duty(ctl); in axi_fan_control_read_pwm()
204 struct axi_fan_control_data *ctl = dev_get_drvdata(dev); in axi_fan_control_write_pwm() local
208 return axi_fan_control_set_pwm_duty(val, ctl); in axi_fan_control_write_pwm()
324 struct axi_fan_control_data *ctl = (struct axi_fan_control_data *)data; in axi_fan_control_irq_handler() local
325 u32 irq_pending = axi_ioread(ADI_REG_IRQ_PENDING, ctl); in axi_fan_control_irq_handler()
330 ctl->hw_pwm_req = true; in axi_fan_control_irq_handler()
338 if (!ctl->hw_pwm_req) { in axi_fan_control_irq_handler()
339 ctl->update_tacho_params = true; in axi_fan_control_irq_handler()
341 ctl->hw_pwm_req = false; in axi_fan_control_irq_handler()
342 sysfs_notify(&ctl->hdev->kobj, NULL, "pwm1"); in axi_fan_control_irq_handler()
347 if (ctl->update_tacho_params) { in axi_fan_control_irq_handler()
348 u32 new_tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl); in axi_fan_control_irq_handler()
353 axi_iowrite(new_tach, ADI_REG_TACH_PERIOD, ctl); in axi_fan_control_irq_handler()
354 axi_iowrite(tach_tol, ADI_REG_TACH_TOLERANCE, ctl); in axi_fan_control_irq_handler()
355 ctl->update_tacho_params = false; in axi_fan_control_irq_handler()
360 ctl->fan_fault = 1; in axi_fan_control_irq_handler()
364 axi_iowrite(clear_mask, ADI_REG_IRQ_PENDING, ctl); in axi_fan_control_irq_handler()
369 static int axi_fan_control_init(struct axi_fan_control_data *ctl, in axi_fan_control_init() argument
375 ret = of_property_read_u32(np, "pulses-per-revolution", &ctl->ppr); in axi_fan_control_init()
380 if (ctl->ppr != 1 && ctl->ppr != 2 && ctl->ppr != 4) in axi_fan_control_init()
388 ADI_REG_IRQ_MASK, ctl); in axi_fan_control_init()
391 axi_iowrite(0x01, ADI_REG_RSTN, ctl); in axi_fan_control_init()
461 struct axi_fan_control_data *ctl; in axi_fan_control_probe() local
472 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL); in axi_fan_control_probe()
473 if (!ctl) in axi_fan_control_probe()
476 ctl->base = devm_platform_ioremap_resource(pdev, 0); in axi_fan_control_probe()
477 if (IS_ERR(ctl->base)) in axi_fan_control_probe()
478 return PTR_ERR(ctl->base); in axi_fan_control_probe()
494 ctl->clk_rate = clk_get_rate(clk); in axi_fan_control_probe()
495 if (!ctl->clk_rate) in axi_fan_control_probe()
498 version = axi_ioread(ADI_AXI_REG_VERSION, ctl); in axi_fan_control_probe()
511 ctl->irq = platform_get_irq(pdev, 0); in axi_fan_control_probe()
512 if (ctl->irq < 0) in axi_fan_control_probe()
513 return ctl->irq; in axi_fan_control_probe()
515 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL, in axi_fan_control_probe()
518 pdev->driver_override, ctl); in axi_fan_control_probe()
524 ret = axi_fan_control_init(ctl, pdev->dev.of_node); in axi_fan_control_probe()
530 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, in axi_fan_control_probe()
532 ctl, in axi_fan_control_probe()
536 return PTR_ERR_OR_ZERO(ctl->hdev); in axi_fan_control_probe()