.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2016 Google, Inc |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 or later as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | 4 | */ |
---|
8 | 5 | |
---|
9 | 6 | #include <linux/clk.h> |
---|
.. | .. |
---|
570 | 567 | return (clk_source * 60) / (2 * raw_data * tach_div); |
---|
571 | 568 | } |
---|
572 | 569 | |
---|
573 | | -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
---|
574 | | - const char *buf, size_t count) |
---|
| 570 | +static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, |
---|
| 571 | + const char *buf, size_t count) |
---|
575 | 572 | { |
---|
576 | 573 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
---|
577 | 574 | int index = sensor_attr->index; |
---|
.. | .. |
---|
595 | 592 | return count; |
---|
596 | 593 | } |
---|
597 | 594 | |
---|
598 | | -static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
---|
| 595 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *attr, |
---|
599 | 596 | char *buf) |
---|
600 | 597 | { |
---|
601 | 598 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
---|
.. | .. |
---|
605 | 602 | return sprintf(buf, "%u\n", priv->pwm_port_fan_ctrl[index]); |
---|
606 | 603 | } |
---|
607 | 604 | |
---|
608 | | -static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, |
---|
| 605 | +static ssize_t rpm_show(struct device *dev, struct device_attribute *attr, |
---|
609 | 606 | char *buf) |
---|
610 | 607 | { |
---|
611 | 608 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
---|
.. | .. |
---|
642 | 639 | return a->mode; |
---|
643 | 640 | } |
---|
644 | 641 | |
---|
645 | | -static SENSOR_DEVICE_ATTR(pwm1, 0644, |
---|
646 | | - show_pwm, set_pwm, 0); |
---|
647 | | -static SENSOR_DEVICE_ATTR(pwm2, 0644, |
---|
648 | | - show_pwm, set_pwm, 1); |
---|
649 | | -static SENSOR_DEVICE_ATTR(pwm3, 0644, |
---|
650 | | - show_pwm, set_pwm, 2); |
---|
651 | | -static SENSOR_DEVICE_ATTR(pwm4, 0644, |
---|
652 | | - show_pwm, set_pwm, 3); |
---|
653 | | -static SENSOR_DEVICE_ATTR(pwm5, 0644, |
---|
654 | | - show_pwm, set_pwm, 4); |
---|
655 | | -static SENSOR_DEVICE_ATTR(pwm6, 0644, |
---|
656 | | - show_pwm, set_pwm, 5); |
---|
657 | | -static SENSOR_DEVICE_ATTR(pwm7, 0644, |
---|
658 | | - show_pwm, set_pwm, 6); |
---|
659 | | -static SENSOR_DEVICE_ATTR(pwm8, 0644, |
---|
660 | | - show_pwm, set_pwm, 7); |
---|
| 642 | +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); |
---|
| 643 | +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); |
---|
| 644 | +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); |
---|
| 645 | +static SENSOR_DEVICE_ATTR_RW(pwm4, pwm, 3); |
---|
| 646 | +static SENSOR_DEVICE_ATTR_RW(pwm5, pwm, 4); |
---|
| 647 | +static SENSOR_DEVICE_ATTR_RW(pwm6, pwm, 5); |
---|
| 648 | +static SENSOR_DEVICE_ATTR_RW(pwm7, pwm, 6); |
---|
| 649 | +static SENSOR_DEVICE_ATTR_RW(pwm8, pwm, 7); |
---|
661 | 650 | static struct attribute *pwm_dev_attrs[] = { |
---|
662 | 651 | &sensor_dev_attr_pwm1.dev_attr.attr, |
---|
663 | 652 | &sensor_dev_attr_pwm2.dev_attr.attr, |
---|
.. | .. |
---|
675 | 664 | .is_visible = pwm_is_visible, |
---|
676 | 665 | }; |
---|
677 | 666 | |
---|
678 | | -static SENSOR_DEVICE_ATTR(fan1_input, 0444, |
---|
679 | | - show_rpm, NULL, 0); |
---|
680 | | -static SENSOR_DEVICE_ATTR(fan2_input, 0444, |
---|
681 | | - show_rpm, NULL, 1); |
---|
682 | | -static SENSOR_DEVICE_ATTR(fan3_input, 0444, |
---|
683 | | - show_rpm, NULL, 2); |
---|
684 | | -static SENSOR_DEVICE_ATTR(fan4_input, 0444, |
---|
685 | | - show_rpm, NULL, 3); |
---|
686 | | -static SENSOR_DEVICE_ATTR(fan5_input, 0444, |
---|
687 | | - show_rpm, NULL, 4); |
---|
688 | | -static SENSOR_DEVICE_ATTR(fan6_input, 0444, |
---|
689 | | - show_rpm, NULL, 5); |
---|
690 | | -static SENSOR_DEVICE_ATTR(fan7_input, 0444, |
---|
691 | | - show_rpm, NULL, 6); |
---|
692 | | -static SENSOR_DEVICE_ATTR(fan8_input, 0444, |
---|
693 | | - show_rpm, NULL, 7); |
---|
694 | | -static SENSOR_DEVICE_ATTR(fan9_input, 0444, |
---|
695 | | - show_rpm, NULL, 8); |
---|
696 | | -static SENSOR_DEVICE_ATTR(fan10_input, 0444, |
---|
697 | | - show_rpm, NULL, 9); |
---|
698 | | -static SENSOR_DEVICE_ATTR(fan11_input, 0444, |
---|
699 | | - show_rpm, NULL, 10); |
---|
700 | | -static SENSOR_DEVICE_ATTR(fan12_input, 0444, |
---|
701 | | - show_rpm, NULL, 11); |
---|
702 | | -static SENSOR_DEVICE_ATTR(fan13_input, 0444, |
---|
703 | | - show_rpm, NULL, 12); |
---|
704 | | -static SENSOR_DEVICE_ATTR(fan14_input, 0444, |
---|
705 | | - show_rpm, NULL, 13); |
---|
706 | | -static SENSOR_DEVICE_ATTR(fan15_input, 0444, |
---|
707 | | - show_rpm, NULL, 14); |
---|
708 | | -static SENSOR_DEVICE_ATTR(fan16_input, 0444, |
---|
709 | | - show_rpm, NULL, 15); |
---|
| 667 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, rpm, 0); |
---|
| 668 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, rpm, 1); |
---|
| 669 | +static SENSOR_DEVICE_ATTR_RO(fan3_input, rpm, 2); |
---|
| 670 | +static SENSOR_DEVICE_ATTR_RO(fan4_input, rpm, 3); |
---|
| 671 | +static SENSOR_DEVICE_ATTR_RO(fan5_input, rpm, 4); |
---|
| 672 | +static SENSOR_DEVICE_ATTR_RO(fan6_input, rpm, 5); |
---|
| 673 | +static SENSOR_DEVICE_ATTR_RO(fan7_input, rpm, 6); |
---|
| 674 | +static SENSOR_DEVICE_ATTR_RO(fan8_input, rpm, 7); |
---|
| 675 | +static SENSOR_DEVICE_ATTR_RO(fan9_input, rpm, 8); |
---|
| 676 | +static SENSOR_DEVICE_ATTR_RO(fan10_input, rpm, 9); |
---|
| 677 | +static SENSOR_DEVICE_ATTR_RO(fan11_input, rpm, 10); |
---|
| 678 | +static SENSOR_DEVICE_ATTR_RO(fan12_input, rpm, 11); |
---|
| 679 | +static SENSOR_DEVICE_ATTR_RO(fan13_input, rpm, 12); |
---|
| 680 | +static SENSOR_DEVICE_ATTR_RO(fan14_input, rpm, 13); |
---|
| 681 | +static SENSOR_DEVICE_ATTR_RO(fan15_input, rpm, 14); |
---|
| 682 | +static SENSOR_DEVICE_ATTR_RO(fan16_input, rpm, 15); |
---|
710 | 683 | static struct attribute *fan_dev_attrs[] = { |
---|
711 | 684 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
---|
712 | 685 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
---|
.. | .. |
---|
852 | 825 | dev_err(dev, "Property 'cooling-levels' cannot be read.\n"); |
---|
853 | 826 | return ret; |
---|
854 | 827 | } |
---|
855 | | - snprintf(cdev->name, MAX_CDEV_NAME_LEN, "%s%d", child->name, pwm_port); |
---|
| 828 | + snprintf(cdev->name, MAX_CDEV_NAME_LEN, "%pOFn%d", child, pwm_port); |
---|
856 | 829 | |
---|
857 | | - cdev->tcdev = thermal_of_cooling_device_register(child, |
---|
858 | | - cdev->name, |
---|
859 | | - cdev, |
---|
860 | | - &aspeed_pwm_cool_ops); |
---|
| 830 | + cdev->tcdev = devm_thermal_of_cooling_device_register(dev, child, |
---|
| 831 | + cdev->name, cdev, &aspeed_pwm_cool_ops); |
---|
861 | 832 | if (IS_ERR(cdev->tcdev)) |
---|
862 | 833 | return PTR_ERR(cdev->tcdev); |
---|
863 | 834 | |
---|
.. | .. |
---|
922 | 893 | struct device_node *np, *child; |
---|
923 | 894 | struct aspeed_pwm_tacho_data *priv; |
---|
924 | 895 | void __iomem *regs; |
---|
925 | | - struct resource *res; |
---|
926 | 896 | struct device *hwmon; |
---|
927 | 897 | struct clk *clk; |
---|
928 | 898 | int ret; |
---|
929 | 899 | |
---|
930 | 900 | np = dev->of_node; |
---|
931 | | - |
---|
932 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
933 | | - if (!res) |
---|
934 | | - return -ENOENT; |
---|
935 | | - regs = devm_ioremap_resource(dev, res); |
---|
| 901 | + regs = devm_platform_ioremap_resource(pdev, 0); |
---|
936 | 902 | if (IS_ERR(regs)) |
---|
937 | 903 | return PTR_ERR(regs); |
---|
938 | 904 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
---|