Lines Matching +full:axi +full:- +full:adc +full:- +full:10
1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/fpga/adi-axi-common.h>
11 #include <linux/hwmon-sysfs.h>
65 iowrite32(val, ctl->base + reg); in axi_iowrite()
71 return ioread32(ctl->base + reg); in axi_ioread()
76 * T = /raw * 509.3140064 / 65535) - 280.2308787
82 u32 temp = axi_ioread(attr->index, ctl); in axi_fan_control_show()
84 temp = DIV_ROUND_CLOSEST_ULL(temp * 509314ULL, 65535) - 280230; in axi_fan_control_show()
97 ret = kstrtou32(buf, 10, &temp); in axi_fan_control_store()
102 axi_iowrite(temp, attr->index, ctl); in axi_fan_control_store()
147 return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach); in axi_fan_control_get_fan_rpm()
160 * T = (ADC * 501.3743 / 2^bits) - 273.6777 in axi_fan_control_read_temp()
164 *val = ((raw_temp * 501374) >> 16) - 273677; in axi_fan_control_read_temp()
167 return -ENOTSUPP; in axi_fan_control_read_temp()
177 *val = ctl->fan_fault; in axi_fan_control_read_fan()
179 ctl->fan_fault = 0; in axi_fan_control_read_fan()
185 return -ENOTSUPP; in axi_fan_control_read_fan()
198 return -ENOTSUPP; in axi_fan_control_read_pwm()
210 return -ENOTSUPP; in axi_fan_control_write_pwm()
226 return -ENOTSUPP; in axi_fan_control_read_labels()
242 return -ENOTSUPP; in axi_fan_control_read()
254 return -ENOTSUPP; in axi_fan_control_write()
320 * already to the ney duty cycle) based on the %ctl->hw_pwm_req flag.
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 hwmon_notify_event(ctl->hdev, hwmon_pwm, in axi_fan_control_irq_handler()
348 if (ctl->update_tacho_params) { in axi_fan_control_irq_handler()
356 ctl->update_tacho_params = false; in axi_fan_control_irq_handler()
361 ctl->fan_fault = 1; in axi_fan_control_irq_handler()
376 ret = of_property_read_u32(np, "pulses-per-revolution", &ctl->ppr); in axi_fan_control_init()
381 if (ctl->ppr != 1 && ctl->ppr != 2 && ctl->ppr != 4) in axi_fan_control_init()
382 return -EINVAL; in axi_fan_control_init()
449 { .compatible = "adi,axi-fan-control-1.00.a",
464 id = of_match_node(axi_fan_control_of_match, pdev->dev.of_node); in axi_fan_control_probe()
466 return -EINVAL; in axi_fan_control_probe()
468 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL); in axi_fan_control_probe()
470 return -ENOMEM; in axi_fan_control_probe()
472 ctl->base = devm_platform_ioremap_resource(pdev, 0); in axi_fan_control_probe()
473 if (IS_ERR(ctl->base)) in axi_fan_control_probe()
474 return PTR_ERR(ctl->base); in axi_fan_control_probe()
476 clk = devm_clk_get_enabled(&pdev->dev, NULL); in axi_fan_control_probe()
478 dev_err(&pdev->dev, "clk_get failed with %ld\n", PTR_ERR(clk)); in axi_fan_control_probe()
482 ctl->clk_rate = clk_get_rate(clk); in axi_fan_control_probe()
483 if (!ctl->clk_rate) in axi_fan_control_probe()
484 return -EINVAL; in axi_fan_control_probe()
488 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data))) { in axi_fan_control_probe()
489 dev_err(&pdev->dev, "Major version mismatch. Expected %d.%.2d.%c, Reported %d.%.2d.%c\n", in axi_fan_control_probe()
490 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data)), in axi_fan_control_probe()
491 ADI_AXI_PCORE_VER_MINOR((*(u32 *)id->data)), in axi_fan_control_probe()
492 ADI_AXI_PCORE_VER_PATCH((*(u32 *)id->data)), in axi_fan_control_probe()
496 return -ENODEV; in axi_fan_control_probe()
499 ctl->irq = platform_get_irq(pdev, 0); in axi_fan_control_probe()
500 if (ctl->irq < 0) in axi_fan_control_probe()
501 return ctl->irq; in axi_fan_control_probe()
503 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL, in axi_fan_control_probe()
506 pdev->driver_override, ctl); in axi_fan_control_probe()
508 dev_err(&pdev->dev, "failed to request an irq, %d", ret); in axi_fan_control_probe()
512 ret = axi_fan_control_init(ctl, pdev->dev.of_node); in axi_fan_control_probe()
514 dev_err(&pdev->dev, "Failed to initialize device\n"); in axi_fan_control_probe()
518 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, in axi_fan_control_probe()
524 return PTR_ERR_OR_ZERO(ctl->hdev); in axi_fan_control_probe()