xref: /openbmc/docs/designs/multihost-phosphor-buttons.md (revision fd9919434002585aaa9d2ddb0b4ed858c7900e3a)
15aa57db6SNaveen Moses# Multi-host front panel phosphor buttons interface
25aa57db6SNaveen Moses
35aa57db6SNaveen MosesAuthor:
45aa57db6SNaveen Moses  Velumani T(velu),  [velumanit@hcl](mailto:velumanit@hcl.com)
55aa57db6SNaveen Moses  Naveen Moses S(naveen.moses), [naveen.mosess@hcl.com](mailto:naveen.mosess@hcl.com)
65aa57db6SNaveen MosesPrimary assignee:
75aa57db6SNaveen Moses
85aa57db6SNaveen MosesOther contributors:
95aa57db6SNaveen Moses
105aa57db6SNaveen MosesCreated:
115aa57db6SNaveen Moses  August 3, 2021
125aa57db6SNaveen Moses
135aa57db6SNaveen Moses## Problem Description
145aa57db6SNaveen MosesPhosphor buttons module has currently option to monitor gpio events of power
155aa57db6SNaveen Mosesand reset buttons and trigger power event handlers.
165aa57db6SNaveen Moses
175aa57db6SNaveen Mosesphosphor-buttons currently only support push type buttons.support for
185aa57db6SNaveen Mosesdifferent form factor inputs such as switches/MUX other than push type
195aa57db6SNaveen Mosesbuttons are needed for some hardwares. It will be helpful if we could
205aa57db6SNaveen Mosesadd option to support additional input types in phosphor button interfaces
215aa57db6SNaveen Mosesand event handling.
225aa57db6SNaveen Moses
235aa57db6SNaveen MosesCurrently handler events are only based on monitoring gpio events
24*fd991943SGeorge Keishingas input (power and reset).There may be cases where we need to create
255aa57db6SNaveen Mosesbutton interface which monitors non gpio events
265aa57db6SNaveen Mosesand triggers button actions for example events based on dbus property changes.
275aa57db6SNaveen Moses
285aa57db6SNaveen Moses## Requirements
29*fd991943SGeorge KeishingThis feature is needed to support additional phosphor button interfaces
305aa57db6SNaveen Mosescorresponding to platform specific hardware buttons/MUX/Switches which are
315aa57db6SNaveen Mosesavailable in the front panel apart from existing power and reset button
325aa57db6SNaveen Mosesinterfaces.
335aa57db6SNaveen Moses
345aa57db6SNaveen Moses## Background and References
355aa57db6SNaveen MosesThe front panel of bmc has buttons like power button, reset button
365aa57db6SNaveen Mosesin general the code for monitoring these buttons and triggering actions are
375aa57db6SNaveen Mosessupported.
385aa57db6SNaveen Moses
395aa57db6SNaveen Moses```
405aa57db6SNaveen Moses   +----------------------------------------------+
415aa57db6SNaveen Moses   |                                              |
425aa57db6SNaveen Moses   |       Front panel                            |
435aa57db6SNaveen Moses   |                                              |
445aa57db6SNaveen Moses   |   +--------------+      +--------------+     |
455aa57db6SNaveen Moses   |   |              |      |              |     |
465aa57db6SNaveen Moses   |   | power button |      | reset button |     |
475aa57db6SNaveen Moses   |   |              |      |              |     |
485aa57db6SNaveen Moses   |   +--------------+      +--------------+     |
495aa57db6SNaveen Moses   |                                              |
505aa57db6SNaveen Moses   |                                              |
515aa57db6SNaveen Moses   |                                              |
525aa57db6SNaveen Moses   |                                              |
535aa57db6SNaveen Moses   +----------------------------------------------+
545aa57db6SNaveen Moses```
555aa57db6SNaveen Moses
565aa57db6SNaveen Mosesplatform specific front panel may contain additional hardware buttons or
575aa57db6SNaveen Mosesmux switch
585aa57db6SNaveen Moses
595aa57db6SNaveen Mosesexample for a multihost platform yosemite-V2 it has host selector switch mux
605aa57db6SNaveen Mosesas additional button in front panel.
615aa57db6SNaveen Moses
625aa57db6SNaveen Moses```
635aa57db6SNaveen Moses+---------------------------+                                      +------------+
645aa57db6SNaveen Moses|                           |                                      |            |
655aa57db6SNaveen Moses|       yv2 front panel     |           power/           ---------+|  host 1    |
665aa57db6SNaveen Moses|                           |           reset/serial mux |         |            |
675aa57db6SNaveen Moses|     +----------------+    |           control          |         +------------+
685aa57db6SNaveen Moses|     |                |    |                            |
695aa57db6SNaveen Moses|     |  power button  |-+  |                            |         +------------+
705aa57db6SNaveen Moses|     |                | |  |                            |         |            |
715aa57db6SNaveen Moses|     +----------------+ |  |                            |--------+|  host 2    |
725aa57db6SNaveen Moses|                        |  |                            |         |            |
735aa57db6SNaveen Moses|                        |  |                            |         +------------+
745aa57db6SNaveen Moses|                        |  |     +---------------+      |
755aa57db6SNaveen Moses|     +----------------+ |  |     |    host       |      |         +-------------+
765aa57db6SNaveen Moses|     |                | |  |     |  selector     |------+         |             |
775aa57db6SNaveen Moses|     |  reset button  --|--------+   switch      |      |---------+  host 3     |
785aa57db6SNaveen Moses|     |                |    |     +---------------+      |         |             |
795aa57db6SNaveen Moses|     +----------------+    |                            |         +-------------+
805aa57db6SNaveen Moses|                           |                            |
815aa57db6SNaveen Moses|                           |                            |          +------------+
825aa57db6SNaveen Moses|                           |                            |          |            |
835aa57db6SNaveen Moses|     +----------------+    |                            |----------+ host 4     |
845aa57db6SNaveen Moses|     | serial console +---------------------------------|          |            |
855aa57db6SNaveen Moses|     |    mux switch  |    |                            |          +------------+
865aa57db6SNaveen Moses|     |                |    |                            |
875aa57db6SNaveen Moses|     +----------------+    |                            |           +-----------+
885aa57db6SNaveen Moses|                           |                            +-----------|   BMC     |
895aa57db6SNaveen Moses|                           |                                        |           |
905aa57db6SNaveen Moses+---------------------------+                                        +-----------+
915aa57db6SNaveen Moses
925aa57db6SNaveen Moses```
935aa57db6SNaveen Moses
945aa57db6SNaveen MosesThere are two additional hardware buttons/switch available in the
955aa57db6SNaveen Mosesfrontpanel for yv2.
965aa57db6SNaveen Moses
975aa57db6SNaveen Moses## 1.Host selector switch (selector switch)
985aa57db6SNaveen MosesThis host selector switch/selector switch has 4 gpio connected as input and
995aa57db6SNaveen Mosesbased on the gpio state values the host selector switch value is derived.
1005aa57db6SNaveen MosesThe possible switch values can vary from 0 to 10.
1015aa57db6SNaveen MosesThe specific mapping between gpio values and host selector values
1025aa57db6SNaveen Mosescan be stored as part of gpio json config.
1035aa57db6SNaveen Moses
1045aa57db6SNaveen MosesyosemiteV2 platform has 1 bmc and 4 hosts and only one power button and
1055aa57db6SNaveen Mosesreset button.
1065aa57db6SNaveen Moses
1075aa57db6SNaveen MosesFor example, when the power button is pressed,
1085aa57db6SNaveen MosesThe value of the host selector switch position(1 to 10) decides whether the
1095aa57db6SNaveen Mosespower button action is needs to be triggered for bmc or any one of the
1105aa57db6SNaveen Moseshosts.
1115aa57db6SNaveen Moses
1125aa57db6SNaveen MosesThis option is to use same power button and reset button for multiple hosts.
1135aa57db6SNaveen Moses
1145aa57db6SNaveen MosesThe power/reset button press events are triggered based on the value of
1155aa57db6SNaveen Moseshost selector switch position.
1165aa57db6SNaveen Moses
1175aa57db6SNaveen Moses### Example :
1185aa57db6SNaveen Moseshost selector position value = 0,bmc is mapped to power and reset buttons
1195aa57db6SNaveen Moseshost selector position value = 1,host 1 is mapped to power and reset buttons
1205aa57db6SNaveen Moseshost selector position value = 2,host 2 is mapped to power and reset buttons
1215aa57db6SNaveen Moseshost selector position value = 3,host 3 is mapped to power and reset buttons
1225aa57db6SNaveen Moseshost selector position value = 4,host 4 is mapped to power and reset buttons
1235aa57db6SNaveen Moses
1245aa57db6SNaveen Moses## 2.Serial console MUX switch
1255aa57db6SNaveen Moses
1265aa57db6SNaveen MosesThere is also uart console for each host and bmc which is connected via a
1275aa57db6SNaveen MosesMUX switch.
1285aa57db6SNaveen Moses
1295aa57db6SNaveen MosesAt a time any one of the device (either bmc or any one host) can be accessed
1305aa57db6SNaveen Mosesvia the console which is based on the UART MUX switch configuration.
1315aa57db6SNaveen Moses
1325aa57db6SNaveen MosesBased on the position of the host selector switch, a separate handler interface
1335aa57db6SNaveen Mosescan configure the respective serial console device is selected.
1345aa57db6SNaveen Moses
1355aa57db6SNaveen Moses## 3.OCP debug card host selector button
1365aa57db6SNaveen Moses
1375aa57db6SNaveen MosesAn OCP debug card can be connected to yosemitev2 via usb for debugging purpose.
1385aa57db6SNaveen Moses
1395aa57db6SNaveen MosesThis is a extension which has three buttons :
1405aa57db6SNaveen Moses1.Power button
1415aa57db6SNaveen Moses2.reset button
1425aa57db6SNaveen Moses3.host selector button
1435aa57db6SNaveen Moses
1445aa57db6SNaveen MosesPower and reset buttons are mapped to the same gpio of frontpanel so no
1455aa57db6SNaveen Mosesseparate event handling is required.
1465aa57db6SNaveen Moses
1475aa57db6SNaveen MosesThe host selector button purpose is same as that of the front panel
1485aa57db6SNaveen Moseshost selector switch in yosemitev2 front panel. The debug card host selector
1495aa57db6SNaveen Mosesbutton (push button) has different gpio lines than that of front panel
1505aa57db6SNaveen Moseshost selector switch gpios.
1515aa57db6SNaveen MosesWhenever the debug host selector button is pressed the host
1525aa57db6SNaveen Mosesselector switch position value should be increased up to MaxPosition.
1535aa57db6SNaveen MosesIf the host selector switch value is more than MaxPosition then it
1545aa57db6SNaveen Mosesshould be reset to zero.
1555aa57db6SNaveen Moses
1565aa57db6SNaveen Moses# Proposed Design
1575aa57db6SNaveen MosesThree high level changes are required in the phosphor button interface class
1585aa57db6SNaveen Moses
1595aa57db6SNaveen Moses1. Add support for adding button interfaces which are monitoring more than
1605aa57db6SNaveen Moses one gpio event and process with single event handler.
1615aa57db6SNaveen Moses
1625aa57db6SNaveen Moses2. Add support to monitor button / switch interface event  based on dbus
1635aa57db6SNaveen Mosesproperty changes (needed for serial console MUX).
1645aa57db6SNaveen Moses
1655aa57db6SNaveen Moses3. Each button interface class can be extended with the following overridable
1665aa57db6SNaveen Mosesmethods to allow platform specific logic if needed in a derived class.
1675aa57db6SNaveen Moses
1685aa57db6SNaveen Moses- init() - This method may have gpio configuration and
1695aa57db6SNaveen Moses      event handler initialization.
1705aa57db6SNaveen Moses
1715aa57db6SNaveen Moses- handleEvent() - This method may have custom event handling
1725aa57db6SNaveen Moses    routines for the respective button interface.This should be
1735aa57db6SNaveen Moses    be called from the main even handler function.
1745aa57db6SNaveen Moses
1755aa57db6SNaveen Moses## The host selector switch interface
1765aa57db6SNaveen Moses
1775aa57db6SNaveen MosesThe host selector switch has 4 gpios associated with it. host selector
1785aa57db6SNaveen Mosesswitch button interface monitors these 4 gpio io events as sd-event
1795aa57db6SNaveen Mosesbased event loop and a single event handler function is called for
1805aa57db6SNaveen Mosesall 4 gpio events.
1815aa57db6SNaveen Moses
1825aa57db6SNaveen MosesBased on the 4 gpio state values, the host selector switch position value
1835aa57db6SNaveen Mosesis derived and stored as a dbus property with name "Position".
1845aa57db6SNaveen Moses
1855aa57db6SNaveen Moses### Host selector dbus interface details
1865aa57db6SNaveen Moses  1. Position(property) - This is the property which holds the current
1875aa57db6SNaveen Moses  value of the host selector switch based on the GPIO state.
1885aa57db6SNaveen Moses
1895aa57db6SNaveen Moses  2. MaxPosition(property) - This is the property which keeps the maximum
1905aa57db6SNaveen Moses  number of Position the Position property can hold.(This value is based
1915aa57db6SNaveen Moses  on the number of hosts available in the platform)
1925aa57db6SNaveen Moses
1935aa57db6SNaveen Moses## OCP Debug card  host selector button interface
1945aa57db6SNaveen MosesA separate interface for debug card host selector button is created.
1955aa57db6SNaveen Moses
1965aa57db6SNaveen MosesThis button interface monitors the corresponding gpio lines for debug card
197*fd991943SGeorge Keishinghost selection button press and release event via sd-event based loop.
1985aa57db6SNaveen Moses
199*fd991943SGeorge Keishing### OCP Debug card host selector button dbus interface details :
2005aa57db6SNaveen Moses  1. Released(signal) - This is signal is triggered in the ocp debug card event
2015aa57db6SNaveen Moses  handler when the ocp debug card button is pressed and released.
2025aa57db6SNaveen Moses
2035aa57db6SNaveen Moses When the event handler is called once the  button is released,
2045aa57db6SNaveen Mosesthen the host selector switch  dbus property "Position" is increased by 1.
2055aa57db6SNaveen MosesThe host selector switch dbus property value is rollover to zero after Position
2065aa57db6SNaveen Mosesvalue exceeds MaxPosition Value.
2075aa57db6SNaveen Moses
2085aa57db6SNaveen MosesThis way when power and reset button press events are handled,
209*fd991943SGeorge Keishingthe Host selector Position property is referred and based on the
2105aa57db6SNaveen MosesPosition respective power events are called.
2115aa57db6SNaveen Moses
2125aa57db6SNaveen Moses## serial console MUX  interface
2135aa57db6SNaveen MosesThis button interface monitors for change in host selector switch Position dbus
2145aa57db6SNaveen Mosesproperty and based on the dbus property value change, corresponding serial
2155aa57db6SNaveen Mosesconsole is selected.mux value can be  set as configuring 4 gpio lines dedicated
2165aa57db6SNaveen Mosesfor the serial console mux.
2175aa57db6SNaveen Moses### Example
2185aa57db6SNaveen Moses0 - bmc serial console
2195aa57db6SNaveen Moses1 - host 1 serial console
2205aa57db6SNaveen Moses2 - host 2 serial console
2215aa57db6SNaveen Moses3 - host 3 serial console
2225aa57db6SNaveen Moses4 - host 4 serial console
2235aa57db6SNaveen Moses
2245aa57db6SNaveen Moses### Change in power button and reset button interface event handler
2255aa57db6SNaveen MosesIf selector button instance is available,then the power button and reset
2265aa57db6SNaveen Mosesbutton pressed events must route to appropriate multihost dbus service name
2275aa57db6SNaveen Moses
2285aa57db6SNaveen Moses## Impacts
2295aa57db6SNaveen Moses The change impacts are under phosphor buttons repo,the existing power and
2305aa57db6SNaveen Moses reset button handlers are calling dbus calls for single host power events.
2315aa57db6SNaveen Moses This calls should be modified to adapt corresponding multi host power events
2325aa57db6SNaveen Moses and the respective host dbus object is based on host selector position.
2335aa57db6SNaveen Moses
2345aa57db6SNaveen Moses## Testing
2355aa57db6SNaveen MosesThe proposed design can be tested in a platform in which the multiple hosts
2365aa57db6SNaveen Mosesare connected.
237