Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 3 | #include "hwmonio.hpp" |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 4 | #include "interface.hpp" |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame] | 5 | #include "sysfs.hpp" |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 6 | |
| 7 | namespace hwmon |
| 8 | { |
| 9 | |
| 10 | /** |
| 11 | * @class FanSpeed |
| 12 | * @brief Target fan speed control implementation |
| 13 | * @details Derived FanSpeedObject type that writes the target value to sysfs |
| 14 | * which in turn sets the fan speed to that target value |
| 15 | */ |
| 16 | class FanSpeed : public FanSpeedObject |
| 17 | { |
| 18 | public: |
| 19 | |
| 20 | /** |
| 21 | * @brief Constructs FanSpeed Object |
| 22 | * |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame] | 23 | * @param[in] instancePath - The hwmon instance path |
| 24 | * (ex. /sys/class/hwmon/hwmon1) |
| 25 | * @param[in] devPath - The /sys/devices sysfs path |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 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 |
Matt Spinler | b4e6557 | 2017-10-17 10:09:18 -0500 | [diff] [blame] | 30 | * @param[in] target - initial target speed value |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 31 | */ |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame] | 32 | FanSpeed(const std::string& instancePath, |
| 33 | const std::string& devPath, |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 34 | const std::string& id, |
| 35 | sdbusplus::bus::bus& bus, |
| 36 | const char* objPath, |
Matt Spinler | b4e6557 | 2017-10-17 10:09:18 -0500 | [diff] [blame] | 37 | bool defer, |
| 38 | uint64_t target) : FanSpeedObject(bus, objPath, defer), |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame] | 39 | id(id), |
| 40 | ioAccess(instancePath), |
| 41 | devPath(devPath) |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 42 | { |
Matt Spinler | b4e6557 | 2017-10-17 10:09:18 -0500 | [diff] [blame] | 43 | FanSpeedObject::target(target); |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 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 | |
Matt Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 53 | /** |
Matt Spinler | b778df0 | 2017-10-16 13:15:18 -0500 | [diff] [blame] | 54 | * @brief Writes the pwm_enable sysfs entry if the |
| 55 | * env var with the value to write is present |
Matt Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 56 | */ |
| 57 | void enable(); |
| 58 | |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 59 | private: |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 60 | /** @brief hwmon type */ |
| 61 | static constexpr auto type = "fan"; |
| 62 | /** @brief hwmon id */ |
| 63 | std::string id; |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame] | 64 | /** @brief Hwmon sysfs access. */ |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 65 | hwmonio::HwmonIO ioAccess; |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame] | 66 | /** @brief Physical device path. */ |
| 67 | std::string devPath; |
| 68 | |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | } // namespace hwmon |