xref: /openbmc/docs/designs/multihost-phosphor-buttons.md (revision 5aa57db6be083531d74ff2480b975476d0192995)
1*5aa57db6SNaveen Moses# Multi-host front panel phosphor buttons interface
2*5aa57db6SNaveen Moses
3*5aa57db6SNaveen MosesAuthor:
4*5aa57db6SNaveen Moses  Velumani T(velu),  [velumanit@hcl](mailto:velumanit@hcl.com)
5*5aa57db6SNaveen Moses  Naveen Moses S(naveen.moses), [naveen.mosess@hcl.com](mailto:naveen.mosess@hcl.com)
6*5aa57db6SNaveen MosesPrimary assignee:
7*5aa57db6SNaveen Moses
8*5aa57db6SNaveen MosesOther contributors:
9*5aa57db6SNaveen Moses
10*5aa57db6SNaveen MosesCreated:
11*5aa57db6SNaveen Moses  August 3, 2021
12*5aa57db6SNaveen Moses
13*5aa57db6SNaveen Moses## Problem Description
14*5aa57db6SNaveen MosesPhosphor buttons module has currently option to monitor gpio events of power
15*5aa57db6SNaveen Mosesand reset buttons and trigger power event handlers.
16*5aa57db6SNaveen Moses
17*5aa57db6SNaveen Mosesphosphor-buttons currently only support push type buttons.support for
18*5aa57db6SNaveen Mosesdifferent form factor inputs such as switches/MUX other than push type
19*5aa57db6SNaveen Mosesbuttons are needed for some hardwares. It will be helpful if we could
20*5aa57db6SNaveen Mosesadd option to support additional input types in phosphor button interfaces
21*5aa57db6SNaveen Mosesand event handling.
22*5aa57db6SNaveen Moses
23*5aa57db6SNaveen MosesCurrently handler events are only based on monitoring gpio events
24*5aa57db6SNaveen Mosesas input (power and reset).There may be cases where whe need to create
25*5aa57db6SNaveen Mosesbutton interface which monitors non gpio events
26*5aa57db6SNaveen Mosesand triggers button actions for example events based on dbus property changes.
27*5aa57db6SNaveen Moses
28*5aa57db6SNaveen Moses## Requirements
29*5aa57db6SNaveen MosesThis feature is needed to support additonal phosphor button interfaces
30*5aa57db6SNaveen Mosescorresponding to platform specific hardware buttons/MUX/Switches which are
31*5aa57db6SNaveen Mosesavailable in the front panel apart from existing power and reset button
32*5aa57db6SNaveen Mosesinterfaces.
33*5aa57db6SNaveen Moses
34*5aa57db6SNaveen Moses## Background and References
35*5aa57db6SNaveen MosesThe front panel of bmc has buttons like power button, reset button
36*5aa57db6SNaveen Mosesin general the code for monitoring these buttons and triggering actions are
37*5aa57db6SNaveen Mosessupported.
38*5aa57db6SNaveen Moses
39*5aa57db6SNaveen Moses```
40*5aa57db6SNaveen Moses   +----------------------------------------------+
41*5aa57db6SNaveen Moses   |                                              |
42*5aa57db6SNaveen Moses   |       Front panel                            |
43*5aa57db6SNaveen Moses   |                                              |
44*5aa57db6SNaveen Moses   |   +--------------+      +--------------+     |
45*5aa57db6SNaveen Moses   |   |              |      |              |     |
46*5aa57db6SNaveen Moses   |   | power button |      | reset button |     |
47*5aa57db6SNaveen Moses   |   |              |      |              |     |
48*5aa57db6SNaveen Moses   |   +--------------+      +--------------+     |
49*5aa57db6SNaveen Moses   |                                              |
50*5aa57db6SNaveen Moses   |                                              |
51*5aa57db6SNaveen Moses   |                                              |
52*5aa57db6SNaveen Moses   |                                              |
53*5aa57db6SNaveen Moses   +----------------------------------------------+
54*5aa57db6SNaveen Moses```
55*5aa57db6SNaveen Moses
56*5aa57db6SNaveen Mosesplatform specific front panel may contain additional hardware buttons or
57*5aa57db6SNaveen Mosesmux switch
58*5aa57db6SNaveen Moses
59*5aa57db6SNaveen Mosesexample for a multihost platform yosemite-V2 it has host selector switch mux
60*5aa57db6SNaveen Mosesas additional button in front panel.
61*5aa57db6SNaveen Moses
62*5aa57db6SNaveen Moses```
63*5aa57db6SNaveen Moses+---------------------------+                                      +------------+
64*5aa57db6SNaveen Moses|                           |                                      |            |
65*5aa57db6SNaveen Moses|       yv2 front panel     |           power/           ---------+|  host 1    |
66*5aa57db6SNaveen Moses|                           |           reset/serial mux |         |            |
67*5aa57db6SNaveen Moses|     +----------------+    |           control          |         +------------+
68*5aa57db6SNaveen Moses|     |                |    |                            |
69*5aa57db6SNaveen Moses|     |  power button  |-+  |                            |         +------------+
70*5aa57db6SNaveen Moses|     |                | |  |                            |         |            |
71*5aa57db6SNaveen Moses|     +----------------+ |  |                            |--------+|  host 2    |
72*5aa57db6SNaveen Moses|                        |  |                            |         |            |
73*5aa57db6SNaveen Moses|                        |  |                            |         +------------+
74*5aa57db6SNaveen Moses|                        |  |     +---------------+      |
75*5aa57db6SNaveen Moses|     +----------------+ |  |     |    host       |      |         +-------------+
76*5aa57db6SNaveen Moses|     |                | |  |     |  selector     |------+         |             |
77*5aa57db6SNaveen Moses|     |  reset button  --|--------+   switch      |      |---------+  host 3     |
78*5aa57db6SNaveen Moses|     |                |    |     +---------------+      |         |             |
79*5aa57db6SNaveen Moses|     +----------------+    |                            |         +-------------+
80*5aa57db6SNaveen Moses|                           |                            |
81*5aa57db6SNaveen Moses|                           |                            |          +------------+
82*5aa57db6SNaveen Moses|                           |                            |          |            |
83*5aa57db6SNaveen Moses|     +----------------+    |                            |----------+ host 4     |
84*5aa57db6SNaveen Moses|     | serial console +---------------------------------|          |            |
85*5aa57db6SNaveen Moses|     |    mux switch  |    |                            |          +------------+
86*5aa57db6SNaveen Moses|     |                |    |                            |
87*5aa57db6SNaveen Moses|     +----------------+    |                            |           +-----------+
88*5aa57db6SNaveen Moses|                           |                            +-----------|   BMC     |
89*5aa57db6SNaveen Moses|                           |                                        |           |
90*5aa57db6SNaveen Moses+---------------------------+                                        +-----------+
91*5aa57db6SNaveen Moses
92*5aa57db6SNaveen Moses```
93*5aa57db6SNaveen Moses
94*5aa57db6SNaveen MosesThere are two additional hardware buttons/switch available in the
95*5aa57db6SNaveen Mosesfrontpanel for yv2.
96*5aa57db6SNaveen Moses
97*5aa57db6SNaveen Moses## 1.Host selector switch (selector switch)
98*5aa57db6SNaveen MosesThis host selector switch/selector switch has 4 gpio connected as input and
99*5aa57db6SNaveen Mosesbased on the gpio state values the host selector switch value is derived.
100*5aa57db6SNaveen MosesThe possible switch values can vary from 0 to 10.
101*5aa57db6SNaveen MosesThe specific mapping between gpio values and host selector values
102*5aa57db6SNaveen Mosescan be stored as part of gpio json config.
103*5aa57db6SNaveen Moses
104*5aa57db6SNaveen MosesyosemiteV2 platform has 1 bmc and 4 hosts and only one power button and
105*5aa57db6SNaveen Mosesreset button.
106*5aa57db6SNaveen Moses
107*5aa57db6SNaveen MosesFor example, when the power button is pressed,
108*5aa57db6SNaveen MosesThe value of the host selector switch position(1 to 10) decides whether the
109*5aa57db6SNaveen Mosespower button action is needs to be triggered for bmc or any one of the
110*5aa57db6SNaveen Moseshosts.
111*5aa57db6SNaveen Moses
112*5aa57db6SNaveen MosesThis option is to use same power button and reset button for multiple hosts.
113*5aa57db6SNaveen Moses
114*5aa57db6SNaveen MosesThe power/reset button press events are triggered based on the value of
115*5aa57db6SNaveen Moseshost selector switch position.
116*5aa57db6SNaveen Moses
117*5aa57db6SNaveen Moses### Example :
118*5aa57db6SNaveen Moseshost selector position value = 0,bmc is mapped to power and reset buttons
119*5aa57db6SNaveen Moseshost selector position value = 1,host 1 is mapped to power and reset buttons
120*5aa57db6SNaveen Moseshost selector position value = 2,host 2 is mapped to power and reset buttons
121*5aa57db6SNaveen Moseshost selector position value = 3,host 3 is mapped to power and reset buttons
122*5aa57db6SNaveen Moseshost selector position value = 4,host 4 is mapped to power and reset buttons
123*5aa57db6SNaveen Moses
124*5aa57db6SNaveen Moses## 2.Serial console MUX switch
125*5aa57db6SNaveen Moses
126*5aa57db6SNaveen MosesThere is also uart console for each host and bmc which is connected via a
127*5aa57db6SNaveen MosesMUX switch.
128*5aa57db6SNaveen Moses
129*5aa57db6SNaveen MosesAt a time any one of the device (either bmc or any one host) can be accessed
130*5aa57db6SNaveen Mosesvia the console which is based on the UART MUX switch configuration.
131*5aa57db6SNaveen Moses
132*5aa57db6SNaveen MosesBased on the position of the host selector switch, a separate handler interface
133*5aa57db6SNaveen Mosescan configure the respective serial console device is selected.
134*5aa57db6SNaveen Moses
135*5aa57db6SNaveen Moses## 3.OCP debug card host selector button
136*5aa57db6SNaveen Moses
137*5aa57db6SNaveen MosesAn OCP debug card can be connected to yosemitev2 via usb for debugging purpose.
138*5aa57db6SNaveen Moses
139*5aa57db6SNaveen MosesThis is a extension which has three buttons :
140*5aa57db6SNaveen Moses1.Power button
141*5aa57db6SNaveen Moses2.reset button
142*5aa57db6SNaveen Moses3.host selector button
143*5aa57db6SNaveen Moses
144*5aa57db6SNaveen MosesPower and reset buttons are mapped to the same gpio of frontpanel so no
145*5aa57db6SNaveen Mosesseparate event handling is required.
146*5aa57db6SNaveen Moses
147*5aa57db6SNaveen MosesThe host selector button purpose is same as that of the front panel
148*5aa57db6SNaveen Moseshost selector switch in yosemitev2 front panel. The debug card host selector
149*5aa57db6SNaveen Mosesbutton (push button) has different gpio lines than that of front panel
150*5aa57db6SNaveen Moseshost selector switch gpios.
151*5aa57db6SNaveen MosesWhenever the debug host selector button is pressed the host
152*5aa57db6SNaveen Mosesselector switch position value should be increased up to MaxPosition.
153*5aa57db6SNaveen MosesIf the host selector switch value is more than MaxPosition then it
154*5aa57db6SNaveen Mosesshould be reset to zero.
155*5aa57db6SNaveen Moses
156*5aa57db6SNaveen Moses# Proposed Design
157*5aa57db6SNaveen MosesThree high level changes are required in the phosphor button interface class
158*5aa57db6SNaveen Moses
159*5aa57db6SNaveen Moses1. Add support for adding button interfaces which are monitoring more than
160*5aa57db6SNaveen Moses one gpio event and process with single event handler.
161*5aa57db6SNaveen Moses
162*5aa57db6SNaveen Moses2. Add support to monitor button / switch interface event  based on dbus
163*5aa57db6SNaveen Mosesproperty changes (needed for serial console MUX).
164*5aa57db6SNaveen Moses
165*5aa57db6SNaveen Moses3. Each button interface class can be extended with the following overridable
166*5aa57db6SNaveen Mosesmethods to allow platform specific logic if needed in a derived class.
167*5aa57db6SNaveen Moses
168*5aa57db6SNaveen Moses- init() - This method may have gpio configuration and
169*5aa57db6SNaveen Moses      event handler initialization.
170*5aa57db6SNaveen Moses
171*5aa57db6SNaveen Moses- handleEvent() - This method may have custom event handling
172*5aa57db6SNaveen Moses    routines for the respective button interface.This should be
173*5aa57db6SNaveen Moses    be called from the main even handler function.
174*5aa57db6SNaveen Moses
175*5aa57db6SNaveen Moses## The host selector switch interface
176*5aa57db6SNaveen Moses
177*5aa57db6SNaveen MosesThe host selector switch has 4 gpios associated with it. host selector
178*5aa57db6SNaveen Mosesswitch button interface monitors these 4 gpio io events as sd-event
179*5aa57db6SNaveen Mosesbased event loop and a single event handler function is called for
180*5aa57db6SNaveen Mosesall 4 gpio events.
181*5aa57db6SNaveen Moses
182*5aa57db6SNaveen MosesBased on the 4 gpio state values, the host selector switch position value
183*5aa57db6SNaveen Mosesis derived and stored as a dbus property with name "Position".
184*5aa57db6SNaveen Moses
185*5aa57db6SNaveen Moses### Host selector dbus interface details
186*5aa57db6SNaveen Moses  1. Position(property) - This is the property which holds the current
187*5aa57db6SNaveen Moses  value of the host selector switch based on the GPIO state.
188*5aa57db6SNaveen Moses
189*5aa57db6SNaveen Moses  2. MaxPosition(property) - This is the property which keeps the maximum
190*5aa57db6SNaveen Moses  number of Position the Position property can hold.(This value is based
191*5aa57db6SNaveen Moses  on the number of hosts available in the platform)
192*5aa57db6SNaveen Moses
193*5aa57db6SNaveen Moses## OCP Debug card  host selector button interface
194*5aa57db6SNaveen MosesA separate interface for debug card host selector button is created.
195*5aa57db6SNaveen Moses
196*5aa57db6SNaveen MosesThis button interface monitors the corresponding gpio lines for debug card
197*5aa57db6SNaveen Moseshost selecton button press and release event via sd-event based loop.
198*5aa57db6SNaveen Moses
199*5aa57db6SNaveen Moses### OCP Debug card host selector buton dbus interface details :
200*5aa57db6SNaveen Moses  1. Released(signal) - This is signal is triggered in the ocp debug card event
201*5aa57db6SNaveen Moses  handler when the ocp debug card button is pressed and released.
202*5aa57db6SNaveen Moses
203*5aa57db6SNaveen Moses When the event handler is called once the  button is released,
204*5aa57db6SNaveen Mosesthen the host selector switch  dbus property "Position" is increased by 1.
205*5aa57db6SNaveen MosesThe host selector switch dbus property value is rollover to zero after Position
206*5aa57db6SNaveen Mosesvalue exceeds MaxPosition Value.
207*5aa57db6SNaveen Moses
208*5aa57db6SNaveen MosesThis way when power and reset button press events are handled,
209*5aa57db6SNaveen Mosesthe Host selector Position property is refered and based on the
210*5aa57db6SNaveen MosesPosition respective power events are called.
211*5aa57db6SNaveen Moses
212*5aa57db6SNaveen Moses## serial console MUX  interface
213*5aa57db6SNaveen MosesThis button interface monitors for change in host selector switch Position dbus
214*5aa57db6SNaveen Mosesproperty and based on the dbus property value change, corresponding serial
215*5aa57db6SNaveen Mosesconsole is selected.mux value can be  set as configuring 4 gpio lines dedicated
216*5aa57db6SNaveen Mosesfor the serial console mux.
217*5aa57db6SNaveen Moses### Example
218*5aa57db6SNaveen Moses0 - bmc serial console
219*5aa57db6SNaveen Moses1 - host 1 serial console
220*5aa57db6SNaveen Moses2 - host 2 serial console
221*5aa57db6SNaveen Moses3 - host 3 serial console
222*5aa57db6SNaveen Moses4 - host 4 serial console
223*5aa57db6SNaveen Moses
224*5aa57db6SNaveen Moses### Change in power button and reset button interface event handler
225*5aa57db6SNaveen MosesIf selector button instance is available,then the power button and reset
226*5aa57db6SNaveen Mosesbutton pressed events must route to appropriate multihost dbus service name
227*5aa57db6SNaveen Moses
228*5aa57db6SNaveen Moses## Impacts
229*5aa57db6SNaveen Moses The change impacts are under phosphor buttons repo,the existing power and
230*5aa57db6SNaveen Moses reset button handlers are calling dbus calls for single host power events.
231*5aa57db6SNaveen Moses This calls should be modified to adapt corresponding multi host power events
232*5aa57db6SNaveen Moses and the respective host dbus object is based on host selector position.
233*5aa57db6SNaveen Moses
234*5aa57db6SNaveen Moses## Testing
235*5aa57db6SNaveen MosesThe proposed design can be tested in a platform in which the multiple hosts
236*5aa57db6SNaveen Mosesare connected.