blob: 61c0bf6876b7047977dcdc881a5e28ab480ba5b9 [file] [log] [blame]
Patrick Venture9331ab72018-01-29 09:48:47 -08001#pragma once
2
Patrick Venture50552372018-06-07 10:53:56 -07003#include <memory>
4
Patrick Venture75e56c62018-04-20 18:10:15 -07005#include "hwmonio.hpp"
Patrick Venture9331ab72018-01-29 09:48:47 -08006#include "interface.hpp"
7#include "sysfs.hpp"
8
9namespace hwmon
10{
11
12/**
13 * @class FanPwm
14 * @brief Target fan pwm control implementation
15 * @details Derived FanPwmObject type that writes the target value to sysfs
16 * which in turn sets the fan speed to that target value
17 */
18class FanPwm : public FanPwmObject
19{
20 public:
21
22 /**
23 * @brief Constructs FanPwm Object
24 *
Patrick Venture50552372018-06-07 10:53:56 -070025 * @param[in] io - HwmonIO
Patrick Venture9331ab72018-01-29 09:48:47 -080026 * @param[in] devPath - The /sys/devices sysfs path
27 * @param[in] id - The hwmon id
28 * @param[in] bus - Dbus bus object
29 * @param[in] objPath - Dbus object path
30 * @param[in] defer - Dbus object registration defer
31 */
Patrick Venture50552372018-06-07 10:53:56 -070032 FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io,
Patrick Venture9331ab72018-01-29 09:48:47 -080033 const std::string& devPath,
34 const std::string& id,
35 sdbusplus::bus::bus& bus,
36 const char* objPath,
37 bool defer,
38 uint64_t target) : FanPwmObject(bus, objPath, defer),
39 id(id),
Patrick Venture50552372018-06-07 10:53:56 -070040 ioAccess(std::move(io)),
Patrick Venture9331ab72018-01-29 09:48:47 -080041 devPath(devPath)
42 {
43 FanPwmObject::target(target);
44 }
45
46 /**
47 * @brief Set the value of target
48 *
49 * @return Value of target
50 */
51 uint64_t target(uint64_t value) override;
52
53 private:
54 /** @brief hwmon type */
55 static constexpr auto type = "pwm";
56 /** @brief hwmon id */
57 std::string id;
58 /** @brief Hwmon sysfs access. */
Patrick Venture50552372018-06-07 10:53:56 -070059 std::unique_ptr<hwmonio::HwmonIOInterface> ioAccess;
Patrick Venture9331ab72018-01-29 09:48:47 -080060 /** @brief Physical device path. */
61 std::string devPath;
62};
63
64} // namespace hwmon
65