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