1# GPIO Monitoring
2
3## Implemented Daemons
4
5### `phosphor-gpio-monitor`
6
7This daemon accepts a command line parameter for monitoring single gpio line and
8take action if requested. This implementation uses GPIO keys and only supports
9monitoring single GPIO line, for multiple lines, user has to run this daemon
10seperately for each gpio line.
11
12### `phosphor-multi-gpio-monitor`
13
14This daemon accepts command line parameter as a well-defined GPIO configuration
15file in json format to monitor list of gpios from config file and take action
16defined in config based on gpio state change. It uses libgpiod library.
17
18### Difference
19
20New implementation (phosphor-multi-gpio-monitor) provides multiple gpio line
21monitoring in single instance of phosphor-multi-gpio-monitor running. It is very
22easy to add list of gpios into JSON config file and it also supports of GPIO
23line by name defined in kernel.
24
25## Configuration
26
27There is a phosphor-multi-gpio-monitor.json file that defines details of GPIOs
28which is required to be monitored. This file can be replaced with a platform
29specific configuration file via bbappend.
30
31Following are fields in json file
32
331. Name: Name of gpio for reference.
342. LineName: this is the line name defined in device tree for specific gpio
353. GpioNum: GPIO offset, this field is optional if LineName is defined.
364. ChipId: This is device name either offset ("0") or complete gpio device
37   ("gpiochip0"). This field is not required if LineName is defined.
385. EventMon: Event of gpio to be monitored. This can be "FALLING", "RISING" OR
39   "BOTH". Default value for this is "BOTH".
406. Target: This is an optional systemd service which will get started after
41   triggering event. A journal entry will be added for every event occurs
42   irrespective of this definition.
437. Targets: This is an optional systemd service which will get started after
44   triggering corresponding event(RASING or FALLING). A journal entry will be
45   added for every event occurs irrespective of this definition.
468. Continue: This is a optional flag and if it is defined as true then this gpio
47   will be monitored continously. If not defined then monitoring of this gpio
48   will stop after first event.
49
50## Sample config file
51
52```json
53[
54  {
55    "Name": "PowerButton",
56    "LineName": "POWER_BUTTON",
57    "GpioNum": 34,
58    "ChipId": "gpiochip0",
59    "EventMon": "FALLING",
60    "Target": "PowerButtonDown.service",
61    "Continue": true
62  },
63  {
64    "Name": "PowerGood",
65    "LineName": "PS_PWROK",
66    "EventMon": "BOTH",
67    "Targets": {
68      "FALLING": ["PowerGoodFalling.service", "PowerOff.service"],
69      "RISING": ["PowerGoodRising.service", "PowerOn.service"]
70    },
71    "Continue": false
72  },
73  { "Name": "SystemReset", "GpioNum": 46, "ChipId": "0" }
74]
75```
76