blob: e80dde034350447110a1e7425531f0a3ded5b2f6 [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
Patrick Venture043d3232018-08-31 10:10:53 -07007#include <memory>
8
Patrick Venture9331ab72018-01-29 09:48:47 -08009namespace 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{
Patrick Venture043d3232018-08-31 10:10:53 -070020 public:
21 /**
22 * @brief Constructs FanPwm Object
23 *
24 * @param[in] io - HwmonIO
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 */
Patrick Venture50552372018-06-07 10:53:56 -070031 FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io,
Patrick Venture043d3232018-08-31 10:10:53 -070032 const std::string& devPath, const std::string& id,
33 sdbusplus::bus::bus& bus, const char* objPath, bool defer,
34 uint64_t target) :
35 FanPwmObject(bus, objPath, defer),
36 id(id), ioAccess(std::move(io)), devPath(devPath)
37 {
38 FanPwmObject::target(target);
39 }
Patrick Venture9331ab72018-01-29 09:48:47 -080040
Patrick Venture043d3232018-08-31 10:10:53 -070041 /**
42 * @brief Set the value of target
43 *
44 * @return Value of target
45 */
46 uint64_t target(uint64_t value) override;
Patrick Venture9331ab72018-01-29 09:48:47 -080047
Patrick Venture043d3232018-08-31 10:10:53 -070048 private:
49 /** @brief hwmon type */
50 static constexpr auto type = "pwm";
51 /** @brief hwmon id */
52 std::string id;
53 /** @brief Hwmon sysfs access. */
54 std::unique_ptr<hwmonio::HwmonIOInterface> ioAccess;
55 /** @brief Physical device path. */
56 std::string devPath;
Patrick Venture9331ab72018-01-29 09:48:47 -080057};
58
59} // namespace hwmon