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>
66 iowrite32(val, ctl->base + reg); in axi_iowrite()
72 return ioread32(ctl->base + reg); in axi_ioread()
77 * T = /raw * 509.3140064 / 65535) - 280.2308787
83 u32 temp = axi_ioread(attr->index, ctl); in axi_fan_control_show()
85 temp = DIV_ROUND_CLOSEST_ULL(temp * 509314ULL, 65535) - 280230; in axi_fan_control_show()
98 ret = kstrtou32(buf, 10, &temp); in axi_fan_control_store()
103 axi_iowrite(temp, attr->index, ctl); in axi_fan_control_store()
148 return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach); in axi_fan_control_get_fan_rpm()
161 * T = (ADC * 501.3743 / 2^bits) - 273.6777 in axi_fan_control_read_temp()
165 *val = ((raw_temp * 501374) >> 16) - 273677; in axi_fan_control_read_temp()
168 return -ENOTSUPP; in axi_fan_control_read_temp()
178 *val = ctl->fan_fault; in axi_fan_control_read_fan()
180 ctl->fan_fault = 0; in axi_fan_control_read_fan()
186 return -ENOTSUPP; in axi_fan_control_read_fan()
199 return -ENOTSUPP; in axi_fan_control_read_pwm()
211 return -ENOTSUPP; in axi_fan_control_write_pwm()
227 return -ENOTSUPP; in axi_fan_control_read_labels()
243 return -ENOTSUPP; in axi_fan_control_read()
255 return -ENOTSUPP; in axi_fan_control_write()
321 * already to the ney duty cycle) based on the %ctl->hw_pwm_req flag.
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()
357 ctl->update_tacho_params = false; in axi_fan_control_irq_handler()
362 ctl->fan_fault = 1; in axi_fan_control_irq_handler()
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()
383 return -EINVAL; in axi_fan_control_init()
456 id = device_get_match_data(&pdev->dev); in axi_fan_control_probe()
458 return -EINVAL; in axi_fan_control_probe()
460 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL); in axi_fan_control_probe()
462 return -ENOMEM; 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()
468 clk = devm_clk_get_enabled(&pdev->dev, NULL); in axi_fan_control_probe()
470 return dev_err_probe(&pdev->dev, PTR_ERR(clk), 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()
475 return -EINVAL; in axi_fan_control_probe()
480 return dev_err_probe(&pdev->dev, -ENODEV, in axi_fan_control_probe()
489 ret = axi_fan_control_init(ctl, &pdev->dev); in axi_fan_control_probe()
491 return dev_err_probe(&pdev->dev, ret, in axi_fan_control_probe()
494 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, 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()
512 return dev_err_probe(&pdev->dev, ret, in axi_fan_control_probe()
521 { .compatible = "adi,axi-fan-control-1.00.a",