regulators: Add configure support to Device class

Implemented the configure() method in the Device class.  This method
applies any configuration changes that are defined for the device.  Also
configures all rails within the device.

Also added a missing #include to rail_tests.cpp.

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I2faceb7d968b6bb01ee7e1116367afee5864ca28
diff --git a/phosphor-regulators/src/device.cpp b/phosphor-regulators/src/device.cpp
index 3e7d5a4..dd662c9 100644
--- a/phosphor-regulators/src/device.cpp
+++ b/phosphor-regulators/src/device.cpp
@@ -16,6 +16,9 @@
 
 #include "device.hpp"
 
+#include "chassis.hpp"
+#include "system.hpp"
+
 namespace phosphor::power::regulators
 {
 
@@ -31,4 +34,19 @@
     }
 }
 
+void Device::configure(System& system, Chassis& chassis)
+{
+    // If configuration changes are defined for this device, apply them
+    if (configuration)
+    {
+        configuration->execute(system, chassis, *this);
+    }
+
+    // Configure rails
+    for (std::unique_ptr<Rail>& rail : rails)
+    {
+        rail->configure(system, chassis, *this);
+    }
+}
+
 } // namespace phosphor::power::regulators
diff --git a/phosphor-regulators/src/device.hpp b/phosphor-regulators/src/device.hpp
index 919899a..e9369fc 100644
--- a/phosphor-regulators/src/device.hpp
+++ b/phosphor-regulators/src/device.hpp
@@ -29,6 +29,10 @@
 namespace phosphor::power::regulators
 {
 
+// Forward declarations to avoid circular dependencies
+class Chassis;
+class System;
+
 /**
  * @class Device
  *
@@ -82,6 +86,22 @@
     void addToIDMap(IDMap& idMap);
 
     /**
+     * Configure this device.
+     *
+     * Applies the configuration changes that are defined for this device, if
+     * any.
+     *
+     * Also configures the voltage rails produced by this device, if any.
+     *
+     * This method should be called during the boot before regulators are
+     * enabled.
+     *
+     * @param system system that contains the chassis
+     * @param chassis chassis that contains this device
+     */
+    void configure(System& system, Chassis& chassis);
+
+    /**
      * Returns the configuration changes to apply to this device, if any.
      *
      * @return Pointer to Configuration object.  Will equal nullptr if no