1b5bd8853SPatrick Williams# GPIO Monitoring 2939a6431SVijay Khemka 3b5bd8853SPatrick Williams## Implemented Daemons 4939a6431SVijay Khemka 5b5bd8853SPatrick Williams### `phosphor-gpio-monitor` 6939a6431SVijay Khemka 7b5bd8853SPatrick WilliamsThis daemon accepts a command line parameter for monitoring single gpio line and 8b5bd8853SPatrick Williamstake action if requested. This implementation uses GPIO keys and only supports 9b5bd8853SPatrick Williamsmonitoring single GPIO line, for multiple lines, user has to run this daemon 10b5bd8853SPatrick Williamsseperately for each gpio line. 11939a6431SVijay Khemka 12b5bd8853SPatrick Williams### `phosphor-multi-gpio-monitor` 13b5bd8853SPatrick Williams 14b5bd8853SPatrick WilliamsThis daemon accepts command line parameter as a well-defined GPIO configuration 15b5bd8853SPatrick Williamsfile in json format to monitor list of gpios from config file and take action 16b5bd8853SPatrick Williamsdefined in config based on gpio state change. It uses libgpiod library. 17b5bd8853SPatrick Williams 18b5bd8853SPatrick Williams### Difference 19b5bd8853SPatrick Williams 20b5bd8853SPatrick WilliamsNew implementation (phosphor-multi-gpio-monitor) provides multiple gpio line 21b5bd8853SPatrick Williamsmonitoring in single instance of phosphor-multi-gpio-monitor running. It is very 22b5bd8853SPatrick Williamseasy to add list of gpios into JSON config file and it also supports of GPIO 23b5bd8853SPatrick Williamsline by name defined in kernel. 24939a6431SVijay Khemka 25939a6431SVijay Khemka## Configuration 26939a6431SVijay Khemka 27b5bd8853SPatrick WilliamsThere is a phosphor-multi-gpio-monitor.json file that defines details of GPIOs 28b5bd8853SPatrick Williamswhich is required to be monitored. This file can be replaced with a platform 29b5bd8853SPatrick Williamsspecific configuration file via bbappend. 30939a6431SVijay Khemka 31939a6431SVijay KhemkaFollowing are fields in json file 32b5bd8853SPatrick Williams 33939a6431SVijay Khemka1. Name: Name of gpio for reference. 34939a6431SVijay Khemka2. LineName: this is the line name defined in device tree for specific gpio 35939a6431SVijay Khemka3. GpioNum: GPIO offset, this field is optional if LineName is defined. 36939a6431SVijay Khemka4. ChipId: This is device name either offset ("0") or complete gpio device 37939a6431SVijay Khemka ("gpiochip0"). This field is not required if LineName is defined. 38b5bd8853SPatrick Williams5. EventMon: Event of gpio to be monitored. This can be "FALLING", "RISING" OR 39b5bd8853SPatrick Williams "BOTH". Default value for this is "BOTH". 40939a6431SVijay Khemka6. Target: This is an optional systemd service which will get started after 41b5bd8853SPatrick Williams triggering event. A journal entry will be added for every event occurs 42b5bd8853SPatrick Williams irrespective of this definition. 43*a66ac0fcSDelphine CC Chiu7. Targets: This is an optional systemd service which will get started after 44*a66ac0fcSDelphine CC Chiu triggering corresponding event(RASING or FALLING). A journal entry will be 45*a66ac0fcSDelphine CC Chiu added for every event occurs irrespective of this definition. 46*a66ac0fcSDelphine CC Chiu8. Continue: This is a optional flag and if it is defined as true then this gpio 47b5bd8853SPatrick Williams will be monitored continously. If not defined then monitoring of this gpio 48b5bd8853SPatrick Williams will stop after first event. 49939a6431SVijay Khemka 50939a6431SVijay Khemka## Sample config file 51939a6431SVijay Khemka 52b5bd8853SPatrick Williams```json 53939a6431SVijay Khemka[ 54939a6431SVijay Khemka { 55939a6431SVijay Khemka "Name": "PowerButton", 56939a6431SVijay Khemka "LineName": "POWER_BUTTON", 57939a6431SVijay Khemka "GpioNum": 34, 58939a6431SVijay Khemka "ChipId": "gpiochip0", 59*a66ac0fcSDelphine CC Chiu "EventMon": "FALLING", 60*a66ac0fcSDelphine CC Chiu "Target": "PowerButtonDown.service", 61939a6431SVijay Khemka "Continue": true 62939a6431SVijay Khemka }, 63939a6431SVijay Khemka { 64939a6431SVijay Khemka "Name": "PowerGood", 65939a6431SVijay Khemka "LineName": "PS_PWROK", 66*a66ac0fcSDelphine CC Chiu "EventMon": "BOTH", 67*a66ac0fcSDelphine CC Chiu "Targets": { 68*a66ac0fcSDelphine CC Chiu "FALLING": ["PowerGoodFalling.service", "PowerOff.service"], 69*a66ac0fcSDelphine CC Chiu "RISING": ["PowerGoodRising.service", "PowerOn.service"] 70*a66ac0fcSDelphine CC Chiu }, 71939a6431SVijay Khemka "Continue": false 72939a6431SVijay Khemka }, 73b5bd8853SPatrick Williams { "Name": "SystemReset", "GpioNum": 46, "ChipId": "0" } 74939a6431SVijay Khemka] 75b5bd8853SPatrick Williams``` 76