• Home
  • Raw
  • Download

Lines Matching +full:axi +full:- +full:fan +full:- +full:control +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
3 * Fan Control HDL CORE driver
9 #include <linux/fpga/adi-axi-common.h>
33 #define ADI_IRQ_SRC_TACH_ERR BIT(1)
56 iowrite32(val, ctl->base + reg); in axi_iowrite()
62 return ioread32(ctl->base + reg); in axi_ioread()
105 return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach); in axi_fan_control_get_fan_rpm()
118 * T = (ADC * 501.3743 / 2^bits) - 273.6777 in axi_fan_control_read_temp()
122 *val = ((raw_temp * 501374) >> 16) - 273677; in axi_fan_control_read_temp()
125 return -ENOTSUPP; in axi_fan_control_read_temp()
135 *val = ctl->fan_fault; in axi_fan_control_read_fan()
137 ctl->fan_fault = 0; in axi_fan_control_read_fan()
143 return -ENOTSUPP; in axi_fan_control_read_fan()
156 return -ENOTSUPP; in axi_fan_control_read_pwm()
168 return -ENOTSUPP; in axi_fan_control_write_pwm()
178 *str = "FAN"; in axi_fan_control_read_labels()
184 return -ENOTSUPP; in axi_fan_control_read_labels()
200 return -ENOTSUPP; in axi_fan_control_read()
212 return -ENOTSUPP; in axi_fan_control_write()
275 * on which the core waits for the fan rotation speed to stabilize. After this
278 * already to the ney duty cycle) based on the %ctl->hw_pwm_req flag.
287 if (ctl->update_tacho_params) { 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()
332 /* get fan pulses per revolution */ in axi_fan_control_init()
333 ret = of_property_read_u32(np, "pulses-per-revolution", &ctl->ppr); in axi_fan_control_init()
337 /* 1, 2 and 4 are the typical and accepted values */ in axi_fan_control_init()
338 if (ctl->ppr != 1 && ctl->ppr != 2 && ctl->ppr != 4) in axi_fan_control_init()
339 return -EINVAL; in axi_fan_control_init()
356 HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_LABEL),
373 static const u32 version_1_0_0 = ADI_AXI_PCORE_VER(1, 0, 'a');
376 { .compatible = "adi,axi-fan-control-1.00.a",
391 id = of_match_node(axi_fan_control_of_match, pdev->dev.of_node); in axi_fan_control_probe()
393 return -EINVAL; in axi_fan_control_probe()
395 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL); in axi_fan_control_probe()
397 return -ENOMEM; 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()
403 clk = devm_clk_get(&pdev->dev, NULL); in axi_fan_control_probe()
405 dev_err(&pdev->dev, "clk_get failed with %ld\n", PTR_ERR(clk)); 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()
411 return -EINVAL; in axi_fan_control_probe()
415 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data))) { in axi_fan_control_probe()
416 dev_err(&pdev->dev, "Major version mismatch. Expected %d.%.2d.%c, Reported %d.%.2d.%c\n", in axi_fan_control_probe()
417 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data)), in axi_fan_control_probe()
418 ADI_AXI_PCORE_VER_MINOR((*(u32 *)id->data)), in axi_fan_control_probe()
419 ADI_AXI_PCORE_VER_PATCH((*(u32 *)id->data)), in axi_fan_control_probe()
423 return -ENODEV; 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()
435 dev_err(&pdev->dev, "failed to request an irq, %d", ret); in axi_fan_control_probe()
439 ret = axi_fan_control_init(ctl, pdev->dev.of_node); in axi_fan_control_probe()
441 dev_err(&pdev->dev, "Failed to initialize device\n"); in axi_fan_control_probe()
445 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, in axi_fan_control_probe()
451 return PTR_ERR_OR_ZERO(ctl->hdev); in axi_fan_control_probe()
464 MODULE_DESCRIPTION("Analog Devices Fan Control HDL CORE driver");