Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "interface.hpp" |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame^] | 4 | #include "sysfs.hpp" |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 5 | |
| 6 | namespace 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 | */ |
| 15 | class FanSpeed : public FanSpeedObject |
| 16 | { |
| 17 | public: |
| 18 | |
| 19 | /** |
| 20 | * @brief Constructs FanSpeed Object |
| 21 | * |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame^] | 22 | * @param[in] instancePath - The hwmon instance path |
| 23 | * (ex. /sys/class/hwmon/hwmon1) |
| 24 | * @param[in] devPath - The /sys/devices sysfs path |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 25 | * @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 Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame^] | 30 | FanSpeed(const std::string& instancePath, |
| 31 | const std::string& devPath, |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 32 | const std::string& id, |
| 33 | sdbusplus::bus::bus& bus, |
| 34 | const char* objPath, |
| 35 | bool defer) : FanSpeedObject(bus, objPath, defer), |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame^] | 36 | id(id), |
| 37 | ioAccess(instancePath), |
| 38 | devPath(devPath) |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 39 | { |
| 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 Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 50 | /** |
| 51 | * @brief Writes the pwm_enable sysfs entry. |
| 52 | */ |
| 53 | void enable(); |
| 54 | |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 55 | private: |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 56 | /** @brief hwmon type */ |
| 57 | static constexpr auto type = "fan"; |
| 58 | /** @brief hwmon id */ |
| 59 | std::string id; |
Brad Bishop | 751043e | 2017-08-29 11:13:46 -0400 | [diff] [blame^] | 60 | /** @brief Hwmon sysfs access. */ |
| 61 | sysfs::hwmonio::HwmonIO ioAccess; |
| 62 | /** @brief Physical device path. */ |
| 63 | std::string devPath; |
| 64 | |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace hwmon |