blob: 32031780355c5a6e82394e8723505c2877e1b685 [file] [log] [blame]
Matthew Barth048ac872017-03-09 14:36:08 -06001#pragma once
2
3#include "interface.hpp"
Brad Bishop751043e2017-08-29 11:13:46 -04004#include "sysfs.hpp"
Matthew Barth048ac872017-03-09 14:36:08 -06005
6namespace hwmon
7{
8
9/**
10 * @class FanSpeed
11 * @brief Target fan speed control implementation
12 * @details Derived FanSpeedObject type that writes the target value to sysfs
13 * which in turn sets the fan speed to that target value
14 */
15class FanSpeed : public FanSpeedObject
16{
17 public:
18
19 /**
20 * @brief Constructs FanSpeed Object
21 *
Brad Bishop751043e2017-08-29 11:13:46 -040022 * @param[in] instancePath - The hwmon instance path
23 * (ex. /sys/class/hwmon/hwmon1)
24 * @param[in] devPath - The /sys/devices sysfs path
Matthew Barth048ac872017-03-09 14:36:08 -060025 * @param[in] id - The hwmon id
26 * @param[in] bus - Dbus bus object
27 * @param[in] objPath - Dbus object path
28 * @param[in] defer - Dbus object registration defer
29 */
Brad Bishop751043e2017-08-29 11:13:46 -040030 FanSpeed(const std::string& instancePath,
31 const std::string& devPath,
Matthew Barth048ac872017-03-09 14:36:08 -060032 const std::string& id,
33 sdbusplus::bus::bus& bus,
34 const char* objPath,
35 bool defer) : FanSpeedObject(bus, objPath, defer),
Brad Bishop751043e2017-08-29 11:13:46 -040036 id(id),
37 ioAccess(instancePath),
38 devPath(devPath)
Matthew Barth048ac872017-03-09 14:36:08 -060039 {
40 // Nothing to do here
41 }
42
43 /**
44 * @brief Set the value of target
45 *
46 * @return Value of target
47 */
48 uint64_t target(uint64_t value) override;
49
Matt Spinler0a8de642017-05-11 10:59:39 -050050 /**
Matt Spinlerb778df02017-10-16 13:15:18 -050051 * @brief Writes the pwm_enable sysfs entry if the
52 * env var with the value to write is present
Matt Spinler0a8de642017-05-11 10:59:39 -050053 */
54 void enable();
55
Matthew Barth048ac872017-03-09 14:36:08 -060056 private:
Matthew Barth048ac872017-03-09 14:36:08 -060057 /** @brief hwmon type */
58 static constexpr auto type = "fan";
59 /** @brief hwmon id */
60 std::string id;
Brad Bishop751043e2017-08-29 11:13:46 -040061 /** @brief Hwmon sysfs access. */
62 sysfs::hwmonio::HwmonIO ioAccess;
63 /** @brief Physical device path. */
64 std::string devPath;
65
Matthew Barth048ac872017-03-09 14:36:08 -060066};
67
68} // namespace hwmon