{"id":18368625,"url":"https://github.com/openbmc/phosphor-buttons","last_synced_at":"2025-04-06T17:31:45.923Z","repository":{"id":43699215,"uuid":"143338835","full_name":"openbmc/phosphor-buttons","owner":"openbmc","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-05T07:47:10.000Z","size":774,"stargazers_count":1,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T04:02:00.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openbmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-02T19:52:14.000Z","updated_at":"2025-03-05T07:47:14.000Z","dependencies_parsed_at":"2025-02-06T18:23:20.769Z","dependency_job_id":"6e6bec1b-7baa-4f35-b64a-862fe6da4be2","html_url":"https://github.com/openbmc/phosphor-buttons","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-buttons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-buttons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-buttons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-buttons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openbmc","download_url":"https://codeload.github.com/openbmc/phosphor-buttons/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247522376,"owners_count":20952535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T23:26:46.597Z","updated_at":"2025-04-06T17:31:45.916Z","avatar_url":"https://github.com/openbmc.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phosphor-buttons\n\nPhosphor-buttons has a collection of IO event handler interfaces for physical\ninputs which are typically part of some sort of panel.\n\nIt defines an individual dbus interface object for each physical button/switch\ninputs such as power button, reset button etc. Each button interface monitors\nits associated IO for event changes and emits signals that the button-handler\napplication listens for.\n\n## Button Behavior\n\n### Power Button\n\nAll events occur when the button is released.\n\nIf the power is off, power on the host.\n\nIf the power is on, it depends on how long the press was and which options are\nenabled:\n\n- Short press: Do a host power off\n- Long press, as determined by the 'long-press-time-ms' meson option: Do a\n  chassis (hard) power off.\n\n#### Custom Power Button Profiles\n\nThe 'power-button-profile' meson option can be used to select custom power\nbutton profiles that have different behaviors.\n\nAvailable profiles are:\n\n- host_then_chassis_poweroff: When power is on, short presses are ignored and a\n  long press issues a host power off first and then a chassis power off if held\n  past a certain time. [This class](inc/host_then_chassis_poweroff.hpp) has\n  additional details.\n\n### Multi-Host Buttons\n\nSee [this section below](#group-gpio-config).\n\n### Reset Button\n\nWhen released:\n\n- If 'reset-button-do-warm-reboot' meson option is set to enabled, does warm\n  reboot the host.\n- Otherwise, reboots the host (default behavior)\n\n### ID Button\n\nWhen released, toggles the 'enclosure_identify' LED group provided by the\nphosphor-led-manager repository. The group name can be changed using the\n'id-led-group' meson option.\n\n## Gpio defs config\n\nIn order to monitor a button/input interface the respective gpio config details\nshould be mentioned in the gpio defs json file -\n`/etc/default/obmc/gpio/gpio_defs.json`\n\n1. The button interface type name.\n2. An array consists of single or multiple gpio configs associated with the\n   specific button interface.\n\nA gpio can be mapped using the \"pin\" or \"num\" keyword. The \"pin\" key uses\nalphanumerical references while the \"num\" key supports the integer pin number.\n\n## example gpio def Json config\n\n```json\n{\n  \"gpio_definitions\": [\n    {\n      \"name\": \"POWER_BUTTON\",\n      \"pin\": \"D0\",\n      \"direction\": \"both\"\n    },\n    {\n      \"name\": \"RESET_BUTTON\",\n      \"pin\": \"AB0\",\n      \"direction\": \"both\"\n    },\n    {\n      \"name\": \"HOST_SELECTOR\",\n\n      \"group_gpio_config\": [\n        {\n          \"pin\": \"AA4\",\n          \"direction\": \"both\"\n        },\n        {\n          \"pin\": \"AA5\",\n          \"direction\": \"both\"\n        },\n        {\n          \"pin\": \"AA6\",\n          \"direction\": \"both\"\n        },\n        {\n          \"pin\": \"AA7\",\n          \"direction\": \"both\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n## Single gpio config\n\nThis config is original config which can be used for configs with only single\ngpio such as power button,reset button, OCP debug card host select button.\n\n```json\n{\n  \"name\": \"POWER_BUTTON\",\n  \"pin\": \"D0\",\n  \"direction\": \"both\"\n}\n```\n\n**Note:** this config is used by most of the other platforms so this format is\nkept as it is so that existing gpio configs do not get affected.\n\n## Group gpio config\n\nThe following configs are related to multi-host bmc systems more info explained\nin the design:\n\u003chttps://github.com/openbmc/docs/blob/master/designs/multihost-phosphor-buttons.md\u003e\n\n### Host selector gpio config example\n\nThe host selector has four gpios associated. So the related gpios are mentioned\nin a json array named group_gpio_config.\n\n- name - This is name of the specific gpio line\n- pin - This represents the pin number from linux dts file.\n- polarity - polarity type of the gpio\n- max_position - This represents the max number of hosts in the multi-host bmc\n  system.\n- host_selector_map - This map is oem specific host position map which has how\n  the value read from the host selector gpios is mapped to the respective host\n  number.\n\nExample : The value of \"7\" derived from the 4 host select gpio lines are mapped\nto host position 1.\n\n```json\n{\n  \"name\": \"HOST_SELECTOR\",\n\n  \"group_gpio_config\": [\n    {\n      \"name\": \"host_select_0\",\n      \"pin\": \"AA4\",\n      \"direction\": \"both\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"host_select_1\",\n      \"pin\": \"AA5\",\n      \"direction\": \"both\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"host_select_2\",\n      \"pin\": \"AA6\",\n      \"direction\": \"both\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"host_select_3\",\n      \"pin\": \"AA7\",\n      \"direction\": \"both\",\n      \"polarity\": \"active_high\"\n    }\n  ],\n  \"max_position\": 4,\n  \"host_selector_map\": {\n    \"6\": 0,\n    \"7\": 1,\n    \"8\": 2,\n    \"9\": 3,\n    \"10\": 4,\n    \"11\": 0,\n    \"12\": 1,\n    \"13\": 2,\n    \"14\": 3,\n    \"15\": 4\n  }\n}\n```\n\n### Host selector cpld config example\n\nThere are also some systems that get the host selector selection from the CPLD,\nthe configuration is provided below.\n\n- name - The button interface type name.\n- i2c_bus - The i2c bus of cpld\n- i2c_address - The i2c address of cpld\n- register_name - The register file name exported by CLD driver for IO event\n  listen\n- max_position - This represents the max number of hosts in the multi-host bmc\n  system.\n\n```json\n{\n  \"cpld_definitions\": [\n    {\n      \"name\": \"HOST_SELECTOR\",\n      \"i2c_bus\": 12,\n      \"i2c_address\": 15,\n      \"register_name\": \"uart-selection-debug-card\",\n      \"max_position\": 4\n    }\n  ]\n}\n```\n\n### Serial uart mux config\n\nSimilar to host selector there are multiple gpios associated with the serial\nuart mux. These gpio configs are specified as part of json array\n\"group_gpio_config\".\n\nHere the serial uart mux output is accessed via OCP debug card. SO the OCP debug\ncard present gpio is mentioned part of the group_gpio_config. The debug card\npresent gpio is identified by its name \"debug_card_present\".\n\nThe other gpios part of the group gpio config is serial uart MUX gpio select\nlines and serial_uart_rx line.\n\n- name - this is name of the specific gpio line\n- pin - this represents the pin number from linux dts file.\n- polarity - polarity type of the gpio\n- serial_uart_mux_map - This is the map for selected host position to the serial\n  uart mux select output value\n\n```json\n{\n  \"name\": \"SERIAL_UART_MUX\",\n\n  \"group_gpio_config\": [\n    {\n      \"name\": \"serial_uart_sel_0\",\n      \"pin\": \"E0\",\n      \"direction\": \"out\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"serial_uart_sel_1\",\n      \"pin\": \"E1\",\n      \"direction\": \"out\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"serial_uart_sel_2\",\n      \"pin\": \"E2\",\n      \"direction\": \"out\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"serial_uart_sel_3\",\n      \"pin\": \"E3\",\n      \"direction\": \"out\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"serial_uart_rx\",\n      \"pin\": \"E4\",\n      \"direction\": \"out\",\n      \"polarity\": \"active_high\"\n    },\n    {\n      \"name\": \"debug_card_present\",\n      \"pin\": \"R3\",\n      \"direction\": \"both\",\n      \"polarity\": \"active_high\"\n    }\n  ],\n  \"serial_uart_mux_map\": {\n    \"0\": 4,\n    \"1\": 0,\n    \"2\": 1,\n    \"3\": 2,\n    \"4\": 3\n  }\n}\n```\n\n## Multiple power gpio config example\n\nThis config is used for configs with multiple power buttons on each slots and\nwhole sled, or for which needs multi-level chassis power control behavior.\n\nname - this is name of the specific gpio line, \"POWER_BUTTON\" + the index of\nchassis instance\n\n- pin - this represents the pin number from linux dts file.\n- multi-action - default no action, set the corresponding behavior with\n  following format:\n- duration - activate when pulling gpio over this value (unit: millisecond)\n- action - chassis power control behavior\n\n```json\n{\n  \"gpio_definitions\": [\n    {\n      \"name\": \"POWER_BUTTON0\",\n      \"pin\": \"I6\",\n      \"direction\": \"both\",\n      \"multi-action\": [\n        {\n          \"duration\": 4000,\n          \"action\": \"chassis cycle\"\n        }\n      ]\n    },\n    {\n      \"name\": \"POWER_BUTTON1\",\n      \"pin\": \"V0\",\n      \"direction\": \"both\",\n      \"multi-action\": [\n        {\n          \"duration\": 0,\n          \"action\": \"chassis on\"\n        },\n        {\n          \"duration\": 4000,\n          \"action\": \"chassis cycle\"\n        },\n        {\n          \"duration\": 8000,\n          \"action\": \"chassis off\"\n        }\n      ]\n    }\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Fphosphor-buttons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenbmc%2Fphosphor-buttons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Fphosphor-buttons/lists"}