Lines Matching +full:gxp +full:- +full:fan +full:- +full:ctrl

1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (C) 2022 Hewlett-Packard Enterprise Development Company, L.P. */
23 static bool fan_installed(struct device *dev, int fan) in fan_installed() argument
28 val = readb(drvdata->plreg + OFS_FAN_INST); in fan_installed()
30 return !!(val & BIT(fan)); in fan_installed()
33 static long fan_failed(struct device *dev, int fan) in fan_failed() argument
38 val = readb(drvdata->plreg + OFS_FAN_FAIL); in fan_failed()
40 return !!(val & BIT(fan)); in fan_failed()
43 static long fan_enabled(struct device *dev, int fan) in fan_enabled() argument
50 * reported for the PWM will be incorrect. Report fan as in fan_enabled()
53 val = readl(drvdata->fn2 + OFS_SEVSTAT); in fan_enabled()
55 return !!((val & BIT(POWER_BIT)) && fan_installed(dev, fan)); in fan_enabled()
65 return -EINVAL; in gxp_pwm_write()
66 writeb(val, drvdata->base + channel); in gxp_pwm_write()
69 return -EOPNOTSUPP; in gxp_pwm_write()
80 return -EOPNOTSUPP; in gxp_fan_ctrl_write()
94 return -EOPNOTSUPP; in gxp_fan_read()
109 reg = readl(drvdata->fn2 + OFS_SEVSTAT); in gxp_pwm_read()
112 *val = fan_installed(dev, channel) ? readb(drvdata->base + channel) : 0; in gxp_pwm_read()
128 return -EOPNOTSUPP; in gxp_fan_ctrl_read()
172 HWMON_CHANNEL_INFO(fan,
202 struct device *dev = &pdev->dev; in gxp_fan_ctrl_probe()
208 return -ENOMEM; in gxp_fan_ctrl_probe()
210 drvdata->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in gxp_fan_ctrl_probe()
211 if (IS_ERR(drvdata->base)) in gxp_fan_ctrl_probe()
212 return dev_err_probe(dev, PTR_ERR(drvdata->base), in gxp_fan_ctrl_probe()
215 drvdata->plreg = devm_platform_ioremap_resource_byname(pdev, in gxp_fan_ctrl_probe()
217 if (IS_ERR(drvdata->plreg)) in gxp_fan_ctrl_probe()
218 return dev_err_probe(dev, PTR_ERR(drvdata->plreg), in gxp_fan_ctrl_probe()
221 drvdata->fn2 = devm_platform_ioremap_resource_byname(pdev, in gxp_fan_ctrl_probe()
223 if (IS_ERR(drvdata->fn2)) in gxp_fan_ctrl_probe()
224 return dev_err_probe(dev, PTR_ERR(drvdata->fn2), in gxp_fan_ctrl_probe()
227 hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, in gxp_fan_ctrl_probe()
237 { .compatible = "hpe,gxp-fan-ctrl", },
245 .name = "gxp-fan-ctrl",
252 MODULE_DESCRIPTION("HPE GXP fan controller");