README.md
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(RISING or FALLING). A journal entry will be
45 added for every event occurs irrespective of this definition. Upon start up,
46 depending on the current GPIO value, the systemd services for INIT_HIGH and
47 INIT_LOW will be called (if defined).
488. Continue: This is a optional flag and if it is defined as true then this gpio
49 will be monitored continuously. If not defined then monitoring of this gpio
50 will stop after first event.
51
52#### Sample config file
53
54```json
55[
56 {
57 "Name": "PowerButton",
58 "LineName": "POWER_BUTTON",
59 "GpioNum": 34,
60 "ChipId": "gpiochip0",
61 "EventMon": "FALLING",
62 "Target": "PowerButtonDown.service",
63 "Continue": true
64 },
65 {
66 "Name": "PowerGood",
67 "LineName": "PS_PWROK",
68 "EventMon": "BOTH",
69 "Targets": {
70 "FALLING": ["PowerGoodFalling.service", "PowerOff.service"],
71 "RISING": ["PowerGoodRising.service", "PowerOn.service"]
72 },
73 "Continue": false
74 },
75 { "Name": "SystemReset", "GpioNum": 46, "ChipId": "0" }
76]
77```
78
79### `phosphor-multi-gpio-presence`
80
81This daemon accepts command line parameter as a well-defined GPIO configuration
82file in json format to monitor list of gpios from config file and sets inventory
83presence as defined in config based on gpio state change. It uses libgpiod
84library.
85
86#### Difference
87
88New implementation (phosphor-multi-gpio-presence) provides multiple gpio line
89monitoring in single instance of phosphor-multi-gpio-presence running. It is
90very easy to add list of gpios into JSON config file and it also supports of
91GPIO line by name defined in kernel.
92
93#### Configuration
94
95There is a phosphor-multi-gpio-presence.json file that defines details of GPIOs
96which is required to be monitored. This file can be replaced with a platform
97specific configuration file via bbappend.
98
99Following are fields in json file
100
1011. Name: PrettyName of inventory item
1022. LineName: this is the line name defined in device tree for specific gpio
1033. GpioNum: GPIO offset, this field is optional if LineName is defined.
1044. ChipId: This is device name either offset ("0") or complete gpio device
105 ("gpiochip0"). This field is not required if LineName is defined.
1065. Inventory: Object path under inventory that will be created
1076. ExtraInterfaces: [Optional] List of interfaces to associate to inventory item
1087. ActiveLow: [Optional] Object is present on LOW level
1098. Bias: [Optional] Configure a BIAS on the GPIO line, for example PULL_UP
110
111#### Sample config file
112
113```json
114[
115 {
116 "Name": "DIMM A0",
117 "LineName": "POWER_BUTTON",
118 "Inventory": "/system/chassis/motherboard/dimm_a0"
119 },
120 {
121 "Name": "Powersupply 0",
122 "ChipId": "0",
123 "GpioNum": 14,
124 "Inventory": "/system/chassis/motherboard/powersupply0",
125 "ActiveLow": true,
126 "Bias": "PULL_UP",
127 "ExtraInterfaces": ["xyz.openbmc_project.Inventory.Item.PowerSupply"]
128 }
129]
130```
131