1*dd6c3661SShawn McCarney## Overview 2*dd6c3661SShawn McCarney 3*dd6c3661SShawn McCarneyThe phosphor-power-sequencer application powers the chassis on/off and monitors 4*dd6c3661SShawn McCarneythe power sequencer device. 5*dd6c3661SShawn McCarney 6*dd6c3661SShawn McCarneyIf the chassis power good (pgood) status changes to false unexpectedly, the 7*dd6c3661SShawn McCarneyapplication uses information from the power sequencer device to determine the 8*dd6c3661SShawn McCarneycause. Typically this is a voltage rail that shut down due to a fault. 9*dd6c3661SShawn McCarney 10*dd6c3661SShawn McCarney## Application 11*dd6c3661SShawn McCarney 12*dd6c3661SShawn McCarneyThe application is a single-threaded C++ executable. It is a 'daemon' process 13*dd6c3661SShawn McCarneythat runs continually. The application is launched by systemd when the BMC 14*dd6c3661SShawn McCarneyreaches the Ready state and before the chassis is powered on. 15*dd6c3661SShawn McCarney 16*dd6c3661SShawn McCarneyThe application is driven by an optional, system-specific JSON configuration 17*dd6c3661SShawn McCarneyfile. The config file is found and parsed at runtime. The parsing process 18*dd6c3661SShawn McCarneycreates a collection of C++ objects. These objects represent the power sequencer 19*dd6c3661SShawn McCarneydevice, voltage rails, GPIOs, and fault checks to perform. 20*dd6c3661SShawn McCarney 21*dd6c3661SShawn McCarney## Power sequencer device 22*dd6c3661SShawn McCarney 23*dd6c3661SShawn McCarneyA power sequencer device enables (turns on) the voltage rails in the correct 24*dd6c3661SShawn McCarneyorder and monitors them for pgood faults. 25*dd6c3661SShawn McCarney 26*dd6c3661SShawn McCarneyThis application currently supports the following power sequencer device types: 27*dd6c3661SShawn McCarney 28*dd6c3661SShawn McCarney- UCD90160 29*dd6c3661SShawn McCarney- UCD90320 30*dd6c3661SShawn McCarney 31*dd6c3661SShawn McCarneyAdditional device types can be supported by creating a new sub-class within the 32*dd6c3661SShawn McCarneyPowerSequencerDevice class hierarchy. 33*dd6c3661SShawn McCarney 34*dd6c3661SShawn McCarney## Powering on the chassis 35*dd6c3661SShawn McCarney 36*dd6c3661SShawn McCarney- A BMC application or script sets the `state` property to 1 on the 37*dd6c3661SShawn McCarney `org.openbmc.control.Power` D-Bus interface. 38*dd6c3661SShawn McCarney- The phosphor-power-sequencer application writes the value 1 to the named GPIO 39*dd6c3661SShawn McCarney `power-chassis-control`. 40*dd6c3661SShawn McCarney - This GPIO is defined in the device tree. The GPIO name is defined in the 41*dd6c3661SShawn McCarney [Device Tree GPIO Naming in OpenBMC document](https://github.com/openbmc/docs/blob/master/designs/device-tree-gpio-naming.md) 42*dd6c3661SShawn McCarney- The power sequencer device powers on all the voltage rails in the correct 43*dd6c3661SShawn McCarney order. 44*dd6c3661SShawn McCarney- When all rails have been successfully powered on, the power sequencer device 45*dd6c3661SShawn McCarney sets the named `power-chassis-good` GPIO to the value 1. 46*dd6c3661SShawn McCarney - This GPIO is defined in the device tree. The GPIO name is defined in the 47*dd6c3661SShawn McCarney [Device Tree GPIO Naming in OpenBMC document](https://github.com/openbmc/docs/blob/master/designs/device-tree-gpio-naming.md) 48*dd6c3661SShawn McCarney- The phosphor-power-sequencer application sets the `pgood` property to 1 on the 49*dd6c3661SShawn McCarney `org.openbmc.control.Power` D-Bus interface. 50*dd6c3661SShawn McCarney- The rest of the boot continues 51*dd6c3661SShawn McCarney 52*dd6c3661SShawn McCarney## Powering off the chassis 53*dd6c3661SShawn McCarney 54*dd6c3661SShawn McCarney- A BMC application or script sets the `state` property to 0 on the 55*dd6c3661SShawn McCarney `org.openbmc.control.Power` D-Bus interface. 56*dd6c3661SShawn McCarney- The phosphor-power-sequencer application writes the value 0 to the named GPIO 57*dd6c3661SShawn McCarney `power-chassis-control`. 58*dd6c3661SShawn McCarney- The power sequencer device powers off all the voltage rails in the correct 59*dd6c3661SShawn McCarney order. 60*dd6c3661SShawn McCarney- When all rails have been successfully powered off, the power sequencer device 61*dd6c3661SShawn McCarney sets the named `power-chassis-good` GPIO to the value 0. 62*dd6c3661SShawn McCarney- The phosphor-power-sequencer application sets the `pgood` property to 0 on the 63*dd6c3661SShawn McCarney `org.openbmc.control.Power` D-Bus interface. 64*dd6c3661SShawn McCarney 65*dd6c3661SShawn McCarney## Pgood fault 66*dd6c3661SShawn McCarney 67*dd6c3661SShawn McCarneyA power good (pgood) fault occurs in two scenarios: 68*dd6c3661SShawn McCarney 69*dd6c3661SShawn McCarney- When attempting to power on the chassis: 70*dd6c3661SShawn McCarney - The power sequencer device is powering on all voltage rails in order, and 71*dd6c3661SShawn McCarney one of the rails does not turn on. 72*dd6c3661SShawn McCarney- After the chassis was successfully powered on: 73*dd6c3661SShawn McCarney - A voltage rail suddenly turns off or stops providing the expected level of 74*dd6c3661SShawn McCarney voltage. This could occur if the voltage regulator stops working or if it 75*dd6c3661SShawn McCarney shuts itself off due to exceeding a temperature/voltage/current limit. 76*dd6c3661SShawn McCarney 77*dd6c3661SShawn McCarneyIf the pgood fault occurs when attempting to power on the chassis, the chassis 78*dd6c3661SShawn McCarneypgood signal never changes to true. 79*dd6c3661SShawn McCarney 80*dd6c3661SShawn McCarneyIf the pgood fault occurs after the chassis was successfully powered on, the 81*dd6c3661SShawn McCarneychassis pgood signal changes from true to false. This application monitors the 82*dd6c3661SShawn McCarneychassis power good status by reading the named GPIO `power-chassis-good`. 83*dd6c3661SShawn McCarney 84*dd6c3661SShawn McCarney## Identifying the cause of a pgood fault 85*dd6c3661SShawn McCarney 86*dd6c3661SShawn McCarneyIt is very helpful to identify which voltage rail caused the pgood fault. That 87*dd6c3661SShawn McCarneydetermines what hardware potentially needs to be replaced. 88*dd6c3661SShawn McCarney 89*dd6c3661SShawn McCarneyDetermining the correct rail requires the following: 90*dd6c3661SShawn McCarney 91*dd6c3661SShawn McCarney- The power sequencer device type is supported by this application 92*dd6c3661SShawn McCarney- A JSON config file is defined for the current system 93*dd6c3661SShawn McCarney 94*dd6c3661SShawn McCarneyIf those requirements are met, the application will attempt to determine which 95*dd6c3661SShawn McCarneyvoltage rail caused the chassis pgood fault. If found, an error is logged 96*dd6c3661SShawn McCarneyagainst that specific rail. 97*dd6c3661SShawn McCarney 98*dd6c3661SShawn McCarneyIf those requirements are not met, a general pgood fault error is logged. 99*dd6c3661SShawn McCarney 100*dd6c3661SShawn McCarney## JSON configuration file 101*dd6c3661SShawn McCarney 102*dd6c3661SShawn McCarneyThis application is configured by an optional JSON configuration file. The 103*dd6c3661SShawn McCarneyconfiguration file defines the voltage rails in the system and how they should 104*dd6c3661SShawn McCarneybe monitored. 105*dd6c3661SShawn McCarney 106*dd6c3661SShawn McCarneyJSON configuration files are system-specific and are stored in the 107*dd6c3661SShawn McCarney[config_files](../config_files/) sub-directory. 108*dd6c3661SShawn McCarney 109*dd6c3661SShawn McCarney[Documentation](config_file/README.md) is available on the configuration file 110*dd6c3661SShawn McCarneyformat. 111*dd6c3661SShawn McCarney 112*dd6c3661SShawn McCarneyIf no configuration file is found for the current system, this application can 113*dd6c3661SShawn McCarneystill power the chassis on/off and detect chassis pgood faults. However, it will 114*dd6c3661SShawn McCarneynot be able to determine which voltage rail caused a pgood fault. 115*dd6c3661SShawn McCarney 116*dd6c3661SShawn McCarney## Key Classes 117*dd6c3661SShawn McCarney 118*dd6c3661SShawn McCarney- PowerInterface 119*dd6c3661SShawn McCarney - Defines the `org.openbmc.control.Power` D-Bus interface. 120*dd6c3661SShawn McCarney - The `state` property is set to power the chassis on or off. This contains 121*dd6c3661SShawn McCarney the desired power state. 122*dd6c3661SShawn McCarney - The `pgood` property contains the actual power state of the chassis. 123*dd6c3661SShawn McCarney- PowerControl 124*dd6c3661SShawn McCarney - Created in `main()`. Handles the event loop. 125*dd6c3661SShawn McCarney - Sub-class of PowerInterface that provides a concrete implementation of the 126*dd6c3661SShawn McCarney `org.openbmc.control.Power` D-Bus interface. 127*dd6c3661SShawn McCarney - Finds and loads the JSON configuration file. 128*dd6c3661SShawn McCarney - Finds power sequencer device information. 129*dd6c3661SShawn McCarney - Creates a sub-class of PowerSequencerDevice that matches power sequencer 130*dd6c3661SShawn McCarney device information. 131*dd6c3661SShawn McCarney - Powers the chassis on and off using the `power-chassis-control` named GPIO. 132*dd6c3661SShawn McCarney - Monitors the chassis pgood status every 3 seconds using the 133*dd6c3661SShawn McCarney `power-chassis-good` named GPIO. 134*dd6c3661SShawn McCarney - Enforces a minimum power off time of 15 seconds from cold start and 25 135*dd6c3661SShawn McCarney seconds from power off. 136*dd6c3661SShawn McCarney- DeviceFinder 137*dd6c3661SShawn McCarney - Finds power sequencer device information on D-Bus published by 138*dd6c3661SShawn McCarney EntityManager. 139*dd6c3661SShawn McCarney- Rail 140*dd6c3661SShawn McCarney - A voltage rail that is enabled or monitored by the power sequencer device. 141*dd6c3661SShawn McCarney- PowerSequencerDevice 142*dd6c3661SShawn McCarney - Abstract base class for a power sequencer device. 143*dd6c3661SShawn McCarney - Defines virtual methods that must be implemented by all child classes. 144*dd6c3661SShawn McCarney- StandardDevice 145*dd6c3661SShawn McCarney - Sub-class of PowerSequencerDevice that implements the standard pgood fault 146*dd6c3661SShawn McCarney detection algorithm. 147*dd6c3661SShawn McCarney- PMBusDriverDevice 148*dd6c3661SShawn McCarney - Sub-class of StandardDevice for power sequencer devices that are bound to a 149*dd6c3661SShawn McCarney PMBus device driver. 150*dd6c3661SShawn McCarney- UCD90xDevice 151*dd6c3661SShawn McCarney - Sub-class of PMBusDriverDevice for the UCD90X family of power sequencer 152*dd6c3661SShawn McCarney devices. 153*dd6c3661SShawn McCarney- UCD90160Device 154*dd6c3661SShawn McCarney - Sub-class of UCD90xDevice representing a UCD90160 power sequencer device. 155*dd6c3661SShawn McCarney- UCD90320Device 156*dd6c3661SShawn McCarney - Sub-class of UCD90xDevice representing a UCD90320 power sequencer device. 157*dd6c3661SShawn McCarney- Services 158*dd6c3661SShawn McCarney - Abstract base class that provides an interface to system services like error 159*dd6c3661SShawn McCarney logging and the journal. 160*dd6c3661SShawn McCarney- BMCServices 161*dd6c3661SShawn McCarney - Sub-class of Services with real implementation of methods. 162*dd6c3661SShawn McCarney- MockServices 163*dd6c3661SShawn McCarney - Sub-class of Services with mock implementation of methods for automated 164*dd6c3661SShawn McCarney testing. 165*dd6c3661SShawn McCarney 166*dd6c3661SShawn McCarney## Testing 167*dd6c3661SShawn McCarney 168*dd6c3661SShawn McCarneyAutomated test cases exist for most of the code in this application. See 169*dd6c3661SShawn McCarney[testing.md](testing.md) for more information. 170