pseq: Add named GPIO properties
Add the new named GPIO properties from the JSON config file to the
power sequencer device class hierarchy.
New JSON GPIO properties:
* power_control_gpio_name
* power_good_gpio_name
Power sequencer device class hierarchy:
* PowerSequencerDevice (power_sequencer_device.*)
* StandardDevice (standard_device.*)
* PMBusDriverDevice (pmbus_driver_device.*)
* UCD90xDevice (ucd90x_device.*)
* UCD90160Device (ucd90160_device.*)
* UCD90320Device (ucd90320_device.*)
Tested:
* Ran automated tests. All ran successfully.
Change-Id: Idcccee89eb09cb7d135f45aeb4f6dfe8299adf43
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/pmbus_driver_device.hpp b/phosphor-power-sequencer/src/pmbus_driver_device.hpp
index 9e77626..c6b6369 100644
--- a/phosphor-power-sequencer/src/pmbus_driver_device.hpp
+++ b/phosphor-power-sequencer/src/pmbus_driver_device.hpp
@@ -56,6 +56,10 @@
* @param name Device name
* @param bus I2C bus for the device
* @param address I2C address for the device
+ * @param powerControlGPIOName Name of the GPIO that turns this device on
+ * and off
+ * @param powerGoodGPIOName Name of the GPIO that reads the power good
+ * signal from this device
* @param rails Voltage rails that are enabled and monitored by this device
* @param services System services like hardware presence and the journal
* @param driverName Device driver name
@@ -63,9 +67,12 @@
*/
explicit PMBusDriverDevice(
const std::string& name, uint8_t bus, uint16_t address,
+ const std::string& powerControlGPIOName,
+ const std::string& powerGoodGPIOName,
std::vector<std::unique_ptr<Rail>> rails, Services& services,
const std::string& driverName = "", size_t instance = 0) :
- StandardDevice(name, bus, address, std::move(rails)),
+ StandardDevice(name, bus, address, powerControlGPIOName,
+ powerGoodGPIOName, std::move(rails)),
driverName{driverName}, instance{instance}
{
pmbusInterface =
diff --git a/phosphor-power-sequencer/src/power_control.cpp b/phosphor-power-sequencer/src/power_control.cpp
index fbf2d5f..fa43ff9 100644
--- a/phosphor-power-sequencer/src/power_control.cpp
+++ b/phosphor-power-sequencer/src/power_control.cpp
@@ -399,12 +399,14 @@
{
device = std::make_unique<UCD90160Device>(
deviceProperties->bus, deviceProperties->address,
+ "power-chassis-control", "power-chassis-good",
std::move(rails), services);
}
else if (deviceProperties->type == UCD90320Device::deviceName)
{
device = std::make_unique<UCD90320Device>(
deviceProperties->bus, deviceProperties->address,
+ "power-chassis-control", "power-chassis-good",
std::move(rails), services);
}
else
diff --git a/phosphor-power-sequencer/src/power_sequencer_device.hpp b/phosphor-power-sequencer/src/power_sequencer_device.hpp
index b7907c0..7597595 100644
--- a/phosphor-power-sequencer/src/power_sequencer_device.hpp
+++ b/phosphor-power-sequencer/src/power_sequencer_device.hpp
@@ -66,6 +66,21 @@
virtual uint16_t getAddress() const = 0;
/**
+ * Returns the name of the GPIO that turns this device on and off.
+ *
+ * @return GPIO name
+ */
+ virtual const std::string& getPowerControlGPIOName() const = 0;
+
+ /**
+ * Returns the name of the GPIO that reads the power good signal from this
+ * device.
+ *
+ * @return GPIO name
+ */
+ virtual const std::string& getPowerGoodGPIOName() const = 0;
+
+ /**
* Returns the voltage rails that are enabled and monitored by this device.
*
* @return voltage rails
diff --git a/phosphor-power-sequencer/src/standard_device.hpp b/phosphor-power-sequencer/src/standard_device.hpp
index 03a6bf0..54c3a01 100644
--- a/phosphor-power-sequencer/src/standard_device.hpp
+++ b/phosphor-power-sequencer/src/standard_device.hpp
@@ -56,12 +56,20 @@
* @param name device name
* @param bus I2C bus for the device
* @param address I2C address for the device
+ * @param powerControlGPIOName name of the GPIO that turns this device on
+ * and off
+ * @param powerGoodGPIOName name of the GPIO that reads the power good
+ * signal from this device
* @param rails voltage rails that are enabled and monitored by this device
*/
explicit StandardDevice(const std::string& name, uint8_t bus,
uint16_t address,
+ const std::string& powerControlGPIOName,
+ const std::string& powerGoodGPIOName,
std::vector<std::unique_ptr<Rail>> rails) :
- name{name}, bus{bus}, address{address}, rails{std::move(rails)}
+ name{name}, bus{bus}, address{address},
+ powerControlGPIOName{powerControlGPIOName},
+ powerGoodGPIOName{powerGoodGPIOName}, rails{std::move(rails)}
{}
/** @copydoc PowerSequencerDevice::getName() */
@@ -82,6 +90,18 @@
return address;
}
+ /** @copydoc PowerSequencerDevice::getPowerControlGPIOName() */
+ virtual const std::string& getPowerControlGPIOName() const override
+ {
+ return powerControlGPIOName;
+ }
+
+ /** @copydoc PowerSequencerDevice::getPowerGoodGPIOName() */
+ virtual const std::string& getPowerGoodGPIOName() const override
+ {
+ return powerGoodGPIOName;
+ }
+
/** @copydoc PowerSequencerDevice::getRails() */
virtual const std::vector<std::unique_ptr<Rail>>& getRails() const override
{
@@ -199,6 +219,16 @@
uint16_t address;
/**
+ * Name of the GPIO that turns this device on and off.
+ */
+ std::string powerControlGPIOName{};
+
+ /**
+ * Name of the GPIO that reads the power good signal from this device.
+ */
+ std::string powerGoodGPIOName{};
+
+ /**
* Voltage rails that are enabled and monitored by this device.
*/
std::vector<std::unique_ptr<Rail>> rails{};
diff --git a/phosphor-power-sequencer/src/ucd90160_device.hpp b/phosphor-power-sequencer/src/ucd90160_device.hpp
index fa7c5e9..73f9df2 100644
--- a/phosphor-power-sequencer/src/ucd90160_device.hpp
+++ b/phosphor-power-sequencer/src/ucd90160_device.hpp
@@ -50,13 +50,19 @@
*
* @param bus I2C bus for the device
* @param address I2C address for the device
+ * @param powerControlGPIOName Name of the GPIO that turns this device on
+ * and off
+ * @param powerGoodGPIOName Name of the GPIO that reads the power good
+ * signal from this device
* @param rails Voltage rails that are enabled and monitored by this device
* @param services System services like hardware presence and the journal
*/
- explicit UCD90160Device(uint8_t bus, uint16_t address,
- std::vector<std::unique_ptr<Rail>> rails,
- Services& services) :
- UCD90xDevice(deviceName, bus, address, std::move(rails), services)
+ explicit UCD90160Device(
+ uint8_t bus, uint16_t address, const std::string& powerControlGPIOName,
+ const std::string& powerGoodGPIOName,
+ std::vector<std::unique_ptr<Rail>> rails, Services& services) :
+ UCD90xDevice(deviceName, bus, address, powerControlGPIOName,
+ powerGoodGPIOName, std::move(rails), services)
{}
constexpr static std::string deviceName{"UCD90160"};
diff --git a/phosphor-power-sequencer/src/ucd90320_device.hpp b/phosphor-power-sequencer/src/ucd90320_device.hpp
index cadcbf6..87a5cc7 100644
--- a/phosphor-power-sequencer/src/ucd90320_device.hpp
+++ b/phosphor-power-sequencer/src/ucd90320_device.hpp
@@ -50,13 +50,19 @@
*
* @param bus I2C bus for the device
* @param address I2C address for the device
+ * @param powerControlGPIOName Name of the GPIO that turns this device on
+ * and off
+ * @param powerGoodGPIOName Name of the GPIO that reads the power good
+ * signal from this device
* @param rails Voltage rails that are enabled and monitored by this device
* @param services System services like hardware presence and the journal
*/
- explicit UCD90320Device(uint8_t bus, uint16_t address,
- std::vector<std::unique_ptr<Rail>> rails,
- Services& services) :
- UCD90xDevice(deviceName, bus, address, std::move(rails), services)
+ explicit UCD90320Device(
+ uint8_t bus, uint16_t address, const std::string& powerControlGPIOName,
+ const std::string& powerGoodGPIOName,
+ std::vector<std::unique_ptr<Rail>> rails, Services& services) :
+ UCD90xDevice(deviceName, bus, address, powerControlGPIOName,
+ powerGoodGPIOName, std::move(rails), services)
{}
constexpr static std::string deviceName{"UCD90320"};
diff --git a/phosphor-power-sequencer/src/ucd90x_device.hpp b/phosphor-power-sequencer/src/ucd90x_device.hpp
index 45dd774..e19c1b6 100644
--- a/phosphor-power-sequencer/src/ucd90x_device.hpp
+++ b/phosphor-power-sequencer/src/ucd90x_device.hpp
@@ -53,14 +53,20 @@
* @param name Device name
* @param bus I2C bus for the device
* @param address I2C address for the device
+ * @param powerControlGPIOName Name of the GPIO that turns this device on
+ * and off
+ * @param powerGoodGPIOName Name of the GPIO that reads the power good
+ * signal from this device
* @param rails Voltage rails that are enabled and monitored by this device
* @param services System services like hardware presence and the journal
*/
- explicit UCD90xDevice(const std::string& name, uint8_t bus,
- uint16_t address,
- std::vector<std::unique_ptr<Rail>> rails,
- Services& services) :
- PMBusDriverDevice(name, bus, address, std::move(rails), services,
+ explicit UCD90xDevice(
+ const std::string& name, uint8_t bus, uint16_t address,
+ const std::string& powerControlGPIOName,
+ const std::string& powerGoodGPIOName,
+ std::vector<std::unique_ptr<Rail>> rails, Services& services) :
+ PMBusDriverDevice(name, bus, address, powerControlGPIOName,
+ powerGoodGPIOName, std::move(rails), services,
driverName)
{}