From 069e4405a6926cdacc33c0826075356da2cd9dbd Mon Sep 17 00:00:00 2001 From: Lei YU Date: Wed, 31 Jan 2018 16:47:37 +0800 Subject: Add target interface for fan control Current fan control assumes the use of the FanSpeed interface for fan targets. For fans controlled by pwm, FanPwm interface is added. This commit adds "target_interface" config parameter, so that user can specify the interface for the fan targets. E.g. - inventory: /system/chassis/motherboard/fan0 cooling_zone: 0 cooling_profile: air sensors: - fan0 target_interface: xyz.openbmc_project.Control.FanPwm The config is optional and defaults to FanSpeed, so the current code will not be affected. Tested: Use this config on Romulus, ensures the fan control sets target on FanPwm interface and works fine. Change-Id: I73adccaa770d657b5d7aaeb307917f89588524de Signed-off-by: Lei YU --- control/example/fans.yaml | 6 +++++- control/fan.cpp | 10 +++++----- control/fan.hpp | 5 +++++ control/gen-fan-zone-defs.py | 6 +++++- control/types.hpp | 5 ++++- 5 files changed, 24 insertions(+), 8 deletions(-) (limited to 'control') diff --git a/control/example/fans.yaml b/control/example/fans.yaml index 629c502..2583256 100644 --- a/control/example/fans.yaml +++ b/control/example/fans.yaml @@ -9,12 +9,15 @@ # cooling_zone: [The cooling zone number for the fan] # cooling_profile: [The cooling profile for the fan] # sensors: [The list of sensors for this fan] +# target_interface: [The interface implemented by the fan target. +# Default is xyz.openbmc_project.Control.FanSpeed] #The cooling zone, a number, and the cooling profile, a string, #have to match the corresponding values in the fan zone yaml #so the fans can be merged into the zone definition. -#Example entries for 2 fan system: +#Example entries for 2 fan system where fan0 uses default FanSpeed and +#fan1 uses FanPwm: #fans: # - inventory: /system/chassis/motherboard/fan0 # cooling_zone: 0 @@ -26,3 +29,4 @@ # cooling_profile: air # sensors: # - fan1 +# target_interface: xyz.openbmc_project.Control.FanPwm diff --git a/control/fan.cpp b/control/fan.cpp index f11bf6f..b0881da 100644 --- a/control/fan.cpp +++ b/control/fan.cpp @@ -36,13 +36,13 @@ using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties"; constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/"; -constexpr auto FAN_SENSOR_CONTROL_INTF = "xyz.openbmc_project.Control.FanSpeed"; constexpr auto FAN_TARGET_PROPERTY = "Target"; Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def): _bus(bus), - _name(std::get(def)) + _name(std::get(def)), + _interface(std::get(def)) { std::string path; auto sensors = std::get(def); @@ -58,7 +58,7 @@ Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def): _targetSpeed = util::SDBusPlus::getProperty( bus, path, - FAN_SENSOR_CONTROL_INTF, + _interface, FAN_TARGET_PROPERTY); } } @@ -69,7 +69,7 @@ Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def): std::string Fan::getService(const std::string& sensor) { return phosphor::fan::util::getService(sensor, - FAN_SENSOR_CONTROL_INTF, + _interface, _bus); } @@ -87,7 +87,7 @@ void Fan::setSpeed(uint64_t speed) sensor.c_str(), PROPERTY_INTERFACE, "Set"); - method.append(FAN_SENSOR_CONTROL_INTF, property, value); + method.append(_interface, property, value); auto response = _bus.call(method); if (response.is_method_error()) diff --git a/control/fan.hpp b/control/fan.hpp index 6975248..e7f3067 100644 --- a/control/fan.hpp +++ b/control/fan.hpp @@ -82,6 +82,11 @@ class Fan */ std::vector _sensors; + /** + * The interface of the fan target + */ + const std::string _interface; + /** * Target speed for this fan */ diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py index 1568137..3ccab36 100755 --- a/control/gen-fan-zone-defs.py +++ b/control/gen-fan-zone-defs.py @@ -140,7 +140,8 @@ const std::vector Manager::_zoneLayouts %for sensor in fan['sensors']: "${sensor}", %endfor - } + }, + "${fan['target_interface']}" }, %endfor }, @@ -665,6 +666,9 @@ def getFansInZone(zone_num, profiles, fan_data): fan = {} fan['name'] = f['inventory'] fan['sensors'] = f['sensors'] + fan['target_interface'] = f.get( + 'target_interface', + 'xyz.openbmc_project.Control.FanSpeed') fans.append(fan) return fans diff --git a/control/types.hpp b/control/types.hpp index f7b75aa..bb9367b 100644 --- a/control/types.hpp +++ b/control/types.hpp @@ -36,7 +36,10 @@ using PropertyVariantType = sdbusplus::message::variant>; +constexpr auto targetInterfacePos = 2; +using FanDefinition = std::tuple, + std::string>; constexpr auto intfPos = 0; constexpr auto propPos = 1; -- cgit v1.2.1