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
77### `phosphor-multi-gpio-presence`
78
79This daemon accepts command line parameter as a well-defined GPIO configuration
80file in json format to monitor list of gpios from config file and sets inventory
81presence as defined in config based on gpio state change. It uses libgpiod
82library.
83
84### Difference
85
86New implementation (phosphor-multi-gpio-presence) provides multiple gpio line
87monitoring in single instance of phosphor-multi-gpio-presence running. It is
88very easy to add list of gpios into JSON config file and it also supports of
89GPIO line by name defined in kernel.
90
91## Configuration
92
93There is a phosphor-multi-gpio-presence.json file that defines details of GPIOs
94which is required to be monitored. This file can be replaced with a platform
95specific configuration file via bbappend.
96
97Following are fields in json file
98
991. Name: PrettyName of inventory item
1002. LineName: this is the line name defined in device tree for specific gpio
1013. GpioNum: GPIO offset, this field is optional if LineName is defined.
1024. ChipId: This is device name either offset ("0") or complete gpio device
103   ("gpiochip0"). This field is not required if LineName is defined.
1045. Inventory: Object path under inventory that will be created
1056. ExtraInterfaces: [Optional] List of interfaces to associate to inventory item
1067. ActiveLow: [Optional] Object is present on LOW level
1078. Bias: [Optional] Configure a BIAS on the GPIO line, for example PULL_UP
108
109## Sample config file
110
111```json
112[
113  {
114    "Name": "DIMM A0",
115    "LineName": "POWER_BUTTON",
116    "Inventory": "/system/chassis/motherboard/dimm_a0"
117  },
118  {
119    "Name": "Powersupply 0",
120    "ChipId": "0",
121    "GpioNum": 14,
122    "Inventory": "/system/chassis/motherboard/powersupply0",
123    "ActiveLow": true,
124    "Bias": "PULL_UP",
125    "ExtraInterfaces": ["xyz.openbmc_project.Inventory.Item.PowerSupply"]
126  }
127]
128```
129