blob: 20baf3838ac5bfa704d74e6acbb4f3b06f192fbc [file] [log] [blame]
Patrick Venture9331ab72018-01-29 09:48:47 -08001#pragma once
2
Patrick Venture75e56c62018-04-20 18:10:15 -07003#include "hwmonio.hpp"
Patrick Venture9331ab72018-01-29 09:48:47 -08004#include "interface.hpp"
5#include "sysfs.hpp"
6
7namespace hwmon
8{
9
10/**
11 * @class FanPwm
12 * @brief Target fan pwm control implementation
13 * @details Derived FanPwmObject type that writes the target value to sysfs
14 * which in turn sets the fan speed to that target value
15 */
16class FanPwm : public FanPwmObject
17{
18 public:
19
20 /**
21 * @brief Constructs FanPwm Object
22 *
23 * @param[in] instancePath - The hwmon instance path
24 * (ex. /sys/class/hwmon/hwmon1)
25 * @param[in] devPath - The /sys/devices sysfs path
26 * @param[in] id - The hwmon id
27 * @param[in] bus - Dbus bus object
28 * @param[in] objPath - Dbus object path
29 * @param[in] defer - Dbus object registration defer
30 */
31 FanPwm(const std::string& instancePath,
32 const std::string& devPath,
33 const std::string& id,
34 sdbusplus::bus::bus& bus,
35 const char* objPath,
36 bool defer,
37 uint64_t target) : FanPwmObject(bus, objPath, defer),
38 id(id),
39 ioAccess(instancePath),
40 devPath(devPath)
41 {
42 FanPwmObject::target(target);
43 }
44
45 /**
46 * @brief Set the value of target
47 *
48 * @return Value of target
49 */
50 uint64_t target(uint64_t value) override;
51
52 private:
53 /** @brief hwmon type */
54 static constexpr auto type = "pwm";
55 /** @brief hwmon id */
56 std::string id;
57 /** @brief Hwmon sysfs access. */
Patrick Venture75e56c62018-04-20 18:10:15 -070058 hwmonio::HwmonIO ioAccess;
Patrick Venture9331ab72018-01-29 09:48:47 -080059 /** @brief Physical device path. */
60 std::string devPath;
61};
62
63} // namespace hwmon
64