Name Date Size #Lines LOC

..--

inc/H--1,359778

service_files/H--2720

src/H--1,8591,426

subprojects/H--4230

.clang-formatH A D01-Feb-20253.7 KiB137135

.gitignoreH A D20-Jun-202241 33

LICENSEH A D02-Aug-201811.1 KiB202169

OWNERSH A D24-Feb-20251.7 KiB5348

README.mdH A D28-Feb-20258.1 KiB343288

meson.buildH A D03-Mar-20252.6 KiB10088

meson.optionsH A D03-Mar-2025946 4337

meson_config.hpp.inH A D08-Nov-20241.4 KiB3629

README.md

1# phosphor-buttons
2
3Phosphor-buttons has a collection of IO event handler interfaces for physical
4inputs which are typically part of some sort of panel.
5
6It defines an individual dbus interface object for each physical button/switch
7inputs such as power button, reset button etc. Each button interface monitors
8its associated IO for event changes and emits signals that the button-handler
9application listens for.
10
11## Button Behavior
12
13### Power Button
14
15All events occur when the button is released.
16
17If the power is off, power on the host.
18
19If the power is on, it depends on how long the press was and which options are
20enabled:
21
22- Short press: Do a host power off
23- Long press, as determined by the 'long-press-time-ms' meson option: Do a
24  chassis (hard) power off.
25
26#### Custom Power Button Profiles
27
28The 'power-button-profile' meson option can be used to select custom power
29button profiles that have different behaviors.
30
31Available profiles are:
32
33- host_then_chassis_poweroff: When power is on, short presses are ignored and a
34  long press issues a host power off first and then a chassis power off if held
35  past a certain time. [This class](inc/host_then_chassis_poweroff.hpp) has
36  additional details.
37
38### Multi-Host Buttons
39
40See [this section below](#group-gpio-config).
41
42### Reset Button
43
44When released:
45
46- If 'reset-button-do-warm-reboot' meson option is set to enabled, does warm
47  reboot the host.
48- Otherwise, reboots the host (default behavior)
49
50### ID Button
51
52When released, toggles the 'enclosure_identify' LED group provided by the
53phosphor-led-manager repository. The group name can be changed using the
54'id-led-group' meson option.
55
56## Gpio defs config
57
58In order to monitor a button/input interface the respective gpio config details
59should be mentioned in the gpio defs json file -
60`/etc/default/obmc/gpio/gpio_defs.json`
61
621. The button interface type name.
632. An array consists of single or multiple gpio configs associated with the
64   specific button interface.
65
66A gpio can be mapped using the "pin" or "num" keyword. The "pin" key uses
67alphanumerical references while the "num" key supports the integer pin number.
68
69## example gpio def Json config
70
71```json
72{
73  "gpio_definitions": [
74    {
75      "name": "POWER_BUTTON",
76      "pin": "D0",
77      "direction": "both"
78    },
79    {
80      "name": "RESET_BUTTON",
81      "pin": "AB0",
82      "direction": "both"
83    },
84    {
85      "name": "HOST_SELECTOR",
86
87      "group_gpio_config": [
88        {
89          "pin": "AA4",
90          "direction": "both"
91        },
92        {
93          "pin": "AA5",
94          "direction": "both"
95        },
96        {
97          "pin": "AA6",
98          "direction": "both"
99        },
100        {
101          "pin": "AA7",
102          "direction": "both"
103        }
104      ]
105    }
106  ]
107}
108```
109
110## Single gpio config
111
112This config is original config which can be used for configs with only single
113gpio such as power button,reset button, OCP debug card host select button.
114
115```json
116{
117  "name": "POWER_BUTTON",
118  "pin": "D0",
119  "direction": "both"
120}
121```
122
123**Note:** this config is used by most of the other platforms so this format is
124kept as it is so that existing gpio configs do not get affected.
125
126## Group gpio config
127
128The following configs are related to multi-host bmc systems more info explained
129in the design:
130<https://github.com/openbmc/docs/blob/master/designs/multihost-phosphor-buttons.md>
131
132### Host selector gpio config example
133
134The host selector has four gpios associated. So the related gpios are mentioned
135in a json array named group_gpio_config.
136
137- name - This is name of the specific gpio line
138- pin - This represents the pin number from linux dts file.
139- polarity - polarity type of the gpio
140- max_position - This represents the max number of hosts in the multi-host bmc
141  system.
142- host_selector_map - This map is oem specific host position map which has how
143  the value read from the host selector gpios is mapped to the respective host
144  number.
145
146Example : The value of "7" derived from the 4 host select gpio lines are mapped
147to host position 1.
148
149```json
150{
151  "name": "HOST_SELECTOR",
152
153  "group_gpio_config": [
154    {
155      "name": "host_select_0",
156      "pin": "AA4",
157      "direction": "both",
158      "polarity": "active_high"
159    },
160    {
161      "name": "host_select_1",
162      "pin": "AA5",
163      "direction": "both",
164      "polarity": "active_high"
165    },
166    {
167      "name": "host_select_2",
168      "pin": "AA6",
169      "direction": "both",
170      "polarity": "active_high"
171    },
172    {
173      "name": "host_select_3",
174      "pin": "AA7",
175      "direction": "both",
176      "polarity": "active_high"
177    }
178  ],
179  "max_position": 4,
180  "host_selector_map": {
181    "6": 0,
182    "7": 1,
183    "8": 2,
184    "9": 3,
185    "10": 4,
186    "11": 0,
187    "12": 1,
188    "13": 2,
189    "14": 3,
190    "15": 4
191  }
192}
193```
194
195### Host selector cpld config example
196
197There are also some systems that get the host selector selection from the CPLD,
198the configuration is provided below.
199
200- name - The button interface type name.
201- i2c_bus - The i2c bus of cpld
202- i2c_address - The i2c address of cpld
203- register_name - The register file name exported by CLD driver for IO event
204  listen
205- max_position - This represents the max number of hosts in the multi-host bmc
206  system.
207
208```json
209{
210  "cpld_definitions": [
211    {
212      "name": "HOST_SELECTOR",
213      "i2c_bus": 12,
214      "i2c_address": 15,
215      "register_name": "uart-selection-debug-card",
216      "max_position": 4
217    }
218  ]
219}
220```
221
222### Serial uart mux config
223
224Similar to host selector there are multiple gpios associated with the serial
225uart mux. These gpio configs are specified as part of json array
226"group_gpio_config".
227
228Here the serial uart mux output is accessed via OCP debug card. SO the OCP debug
229card present gpio is mentioned part of the group_gpio_config. The debug card
230present gpio is identified by its name "debug_card_present".
231
232The other gpios part of the group gpio config is serial uart MUX gpio select
233lines and serial_uart_rx line.
234
235- name - this is name of the specific gpio line
236- pin - this represents the pin number from linux dts file.
237- polarity - polarity type of the gpio
238- serial_uart_mux_map - This is the map for selected host position to the serial
239  uart mux select output value
240
241```json
242{
243  "name": "SERIAL_UART_MUX",
244
245  "group_gpio_config": [
246    {
247      "name": "serial_uart_sel_0",
248      "pin": "E0",
249      "direction": "out",
250      "polarity": "active_high"
251    },
252    {
253      "name": "serial_uart_sel_1",
254      "pin": "E1",
255      "direction": "out",
256      "polarity": "active_high"
257    },
258    {
259      "name": "serial_uart_sel_2",
260      "pin": "E2",
261      "direction": "out",
262      "polarity": "active_high"
263    },
264    {
265      "name": "serial_uart_sel_3",
266      "pin": "E3",
267      "direction": "out",
268      "polarity": "active_high"
269    },
270    {
271      "name": "serial_uart_rx",
272      "pin": "E4",
273      "direction": "out",
274      "polarity": "active_high"
275    },
276    {
277      "name": "debug_card_present",
278      "pin": "R3",
279      "direction": "both",
280      "polarity": "active_high"
281    }
282  ],
283  "serial_uart_mux_map": {
284    "0": 4,
285    "1": 0,
286    "2": 1,
287    "3": 2,
288    "4": 3
289  }
290}
291```
292
293## Multiple power gpio config example
294
295This config is used for configs with multiple power buttons on each slots and
296whole sled, or for which needs multi-level chassis power control behavior.
297
298name - this is name of the specific gpio line, "POWER_BUTTON" + the index of
299chassis instance
300
301- pin - this represents the pin number from linux dts file.
302- multi-action - default no action, set the corresponding behavior with
303  following format:
304- duration - activate when pulling gpio over this value (unit: millisecond)
305- action - chassis power control behavior
306
307```json
308{
309  "gpio_definitions": [
310    {
311      "name": "POWER_BUTTON0",
312      "pin": "I6",
313      "direction": "both",
314      "multi-action": [
315        {
316          "duration": 4000,
317          "action": "chassis cycle"
318        }
319      ]
320    },
321    {
322      "name": "POWER_BUTTON1",
323      "pin": "V0",
324      "direction": "both",
325      "multi-action": [
326        {
327          "duration": 0,
328          "action": "chassis on"
329        },
330        {
331          "duration": 4000,
332          "action": "chassis cycle"
333        },
334        {
335          "duration": 8000,
336          "action": "chassis off"
337        }
338      ]
339    }
340  ]
341}
342```
343