1*b5bd8853SPatrick Williams# GPIO Monitoring
2939a6431SVijay Khemka
3*b5bd8853SPatrick Williams## Implemented Daemons
4939a6431SVijay Khemka
5*b5bd8853SPatrick Williams### `phosphor-gpio-monitor`
6939a6431SVijay Khemka
7*b5bd8853SPatrick WilliamsThis daemon accepts a command line parameter for monitoring single gpio line and
8*b5bd8853SPatrick Williamstake action if requested. This implementation uses GPIO keys and only supports
9*b5bd8853SPatrick Williamsmonitoring single GPIO line, for multiple lines, user has to run this daemon
10*b5bd8853SPatrick Williamsseperately for each gpio line.
11939a6431SVijay Khemka
12*b5bd8853SPatrick Williams### `phosphor-multi-gpio-monitor`
13*b5bd8853SPatrick Williams
14*b5bd8853SPatrick WilliamsThis daemon accepts command line parameter as a well-defined GPIO configuration
15*b5bd8853SPatrick Williamsfile in json format to monitor list of gpios from config file and take action
16*b5bd8853SPatrick Williamsdefined in config based on gpio state change. It uses libgpiod library.
17*b5bd8853SPatrick Williams
18*b5bd8853SPatrick Williams### Difference
19*b5bd8853SPatrick Williams
20*b5bd8853SPatrick WilliamsNew implementation (phosphor-multi-gpio-monitor) provides multiple gpio line
21*b5bd8853SPatrick Williamsmonitoring in single instance of phosphor-multi-gpio-monitor running. It is very
22*b5bd8853SPatrick Williamseasy to add list of gpios into JSON config file and it also supports of GPIO
23*b5bd8853SPatrick Williamsline by name defined in kernel.
24939a6431SVijay Khemka
25939a6431SVijay Khemka## Configuration
26939a6431SVijay Khemka
27*b5bd8853SPatrick WilliamsThere is a phosphor-multi-gpio-monitor.json file that defines details of GPIOs
28*b5bd8853SPatrick Williamswhich is required to be monitored. This file can be replaced with a platform
29*b5bd8853SPatrick Williamsspecific configuration file via bbappend.
30939a6431SVijay Khemka
31939a6431SVijay KhemkaFollowing are fields in json file
32*b5bd8853SPatrick 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.
38*b5bd8853SPatrick Williams5. EventMon: Event of gpio to be monitored. This can be "FALLING", "RISING" OR
39*b5bd8853SPatrick Williams   "BOTH". Default value for this is "BOTH".
40939a6431SVijay Khemka6. Target: This is an optional systemd service which will get started after
41*b5bd8853SPatrick Williams   triggering event. A journal entry will be added for every event occurs
42*b5bd8853SPatrick Williams   irrespective of this definition.
43*b5bd8853SPatrick Williams7. Continue: This is a optional flag and if it is defined as true then this gpio
44*b5bd8853SPatrick Williams   will be monitored continously. If not defined then monitoring of this gpio
45*b5bd8853SPatrick Williams   will stop after first event.
46939a6431SVijay Khemka
47939a6431SVijay Khemka## Sample config file
48939a6431SVijay Khemka
49*b5bd8853SPatrick Williams```json
50939a6431SVijay Khemka[
51939a6431SVijay Khemka  {
52939a6431SVijay Khemka    "Name": "PowerButton",
53939a6431SVijay Khemka    "LineName": "POWER_BUTTON",
54939a6431SVijay Khemka    "GpioNum": 34,
55939a6431SVijay Khemka    "ChipId": "gpiochip0",
56939a6431SVijay Khemka    "EventMon": "BOTH",
57939a6431SVijay Khemka    "Continue": true
58939a6431SVijay Khemka  },
59939a6431SVijay Khemka  {
60939a6431SVijay Khemka    "Name": "PowerGood",
61939a6431SVijay Khemka    "LineName": "PS_PWROK",
62939a6431SVijay Khemka    "EventMon": "FALLING",
63939a6431SVijay Khemka    "Continue": false
64939a6431SVijay Khemka  },
65*b5bd8853SPatrick Williams  { "Name": "SystemReset", "GpioNum": 46, "ChipId": "0" }
66939a6431SVijay Khemka]
67*b5bd8853SPatrick Williams```
68