fan: add event interface

Add the FanFailed and FanFailed events based on Redfish specification
for Fan events in Environmental namespace[1].

[1] https://github.com/DMTF/Redfish-Publications/blob/main/registries/Environmental.1.2.0.json#L635

Change-Id: I36a2153d61e38f859a2434953f745e306be291da
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/gen/xyz/openbmc_project/State/Fan/meson.build b/gen/xyz/openbmc_project/State/Fan/meson.build
new file mode 100644
index 0000000..7e10302
--- /dev/null
+++ b/gen/xyz/openbmc_project/State/Fan/meson.build
@@ -0,0 +1,26 @@
+# Generated file; do not modify.
+
+sdbusplus_current_path = 'xyz/openbmc_project/State/Fan'
+
+generated_sources += custom_target(
+    'xyz/openbmc_project/State/Fan__cpp'.underscorify(),
+    input: ['../../../../../yaml/xyz/openbmc_project/State/Fan.events.yaml'],
+    output: ['event.cpp', 'event.hpp'],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog,
+        '--command',
+        'cpp',
+        '--output',
+        meson.current_build_dir(),
+        '--tool',
+        sdbusplusplus_prog,
+        '--directory',
+        meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/State/Fan',
+    ],
+    install: should_generate_cpp,
+    install_dir: [false, get_option('includedir') / sdbusplus_current_path],
+    build_by_default: should_generate_cpp,
+)
+
diff --git a/gen/xyz/openbmc_project/State/meson.build b/gen/xyz/openbmc_project/State/meson.build
index f4fdfe7..1d3b4d4 100644
--- a/gen/xyz/openbmc_project/State/meson.build
+++ b/gen/xyz/openbmc_project/State/meson.build
@@ -6,6 +6,7 @@
 subdir('Chassis')
 subdir('Decorator')
 subdir('Drive')
+subdir('Fan')
 subdir('Filter')
 subdir('Host')
 subdir('Leak')
@@ -188,6 +189,50 @@
 )
 
 generated_markdown += custom_target(
+    'xyz/openbmc_project/State/Fan__markdown'.underscorify(),
+    input: ['../../../../yaml/xyz/openbmc_project/State/Fan.events.yaml'],
+    output: ['Fan.md'],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog,
+        '--command',
+        'markdown',
+        '--output',
+        meson.current_build_dir(),
+        '--tool',
+        sdbusplusplus_prog,
+        '--directory',
+        meson.current_source_dir() / '../../../../yaml',
+        'xyz/openbmc_project/State/Fan',
+    ],
+    install: should_generate_markdown,
+    install_dir: [inst_markdown_dir / sdbusplus_current_path],
+    build_by_default: should_generate_markdown,
+)
+
+generated_registry += custom_target(
+    'xyz/openbmc_project/State/Fan__registry'.underscorify(),
+    input: ['../../../../yaml/xyz/openbmc_project/State/Fan.events.yaml'],
+    output: ['Fan.json'],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog,
+        '--command',
+        'registry',
+        '--output',
+        meson.current_build_dir(),
+        '--tool',
+        sdbusplusplus_prog,
+        '--directory',
+        meson.current_source_dir() / '../../../../yaml',
+        'xyz/openbmc_project/State/Fan',
+    ],
+    install: should_generate_registry,
+    install_dir: [inst_registry_dir / sdbusplus_current_path],
+    build_by_default: should_generate_registry,
+)
+
+generated_markdown += custom_target(
     'xyz/openbmc_project/State/Filter__markdown'.underscorify(),
     input: ['../../../../yaml/xyz/openbmc_project/State/Filter.events.yaml'],
     output: ['Filter.md'],
diff --git a/yaml/xyz/openbmc_project/State/Fan.events.yaml b/yaml/xyz/openbmc_project/State/Fan.events.yaml
new file mode 100644
index 0000000..f9c6db4
--- /dev/null
+++ b/yaml/xyz/openbmc_project/State/Fan.events.yaml
@@ -0,0 +1,21 @@
+version: 1.0.0
+
+errors:
+    - name: FanFailed
+      severity: critical
+      metadata:
+          - name: FanName
+            description: The name or identifier of the fan.
+            type: object_path
+            primary: true
+      errno: EIO
+      redfish-mapping: Environmental.FanFailed
+
+events:
+    - name: FanRestored
+      metadata:
+          - name: FanName
+            description: The name or identifier of the fan.
+            type: object_path
+            primary: true
+      redfish-mapping: Environmental.FanRestored