swift: Add fan control for bring-up

To support the swift system bring-up, install the cooling type and fan
control application with minimal configuration to run fans at full
speed(9500 RPMs).

Tested:
    Cooling type included in image and configured correctly
    Fan control included in image and configured correctly

Change-Id: Ide1ade5bcf892daa416c5b6253e7b6aa33042f2e
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/meta-witherspoon/recipes-phosphor/fans/phosphor-fan_%.bbappend b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan_%.bbappend
index e28bcb1..5a24fa7 100644
--- a/meta-witherspoon/recipes-phosphor/fans/phosphor-fan_%.bbappend
+++ b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan_%.bbappend
@@ -22,12 +22,16 @@
 
 SYSTEMD_ENVIRONMENT_FILE_phosphor-cooling-type += "${@compose_list(d, 'COOLING_ENV_FMT', 'OBMC_CHASSIS_INSTANCES')}"
 
+# Do not install presence and monitor applications for Swift bring-up
+FAN_PACKAGES_remove_swift = "${PN}-presence-tach ${PN}-monitor"
+PACKAGECONFIG_remove_swift = "presence monitor"
+
 #These services are protected by the watchdog
-SYSTEMD_OVERRIDE_phosphor-fan-control += "fan-watchdog-monitor.conf:phosphor-fan-control-init@0.service.d/fan-watchdog-monitor.conf"
-SYSTEMD_OVERRIDE_phosphor-fan-control += "fan-watchdog-monitor.conf:phosphor-fan-control@0.service.d/fan-watchdog-monitor.conf"
-SYSTEMD_OVERRIDE_phosphor-fan-monitor += "fan-watchdog-monitor.conf:phosphor-fan-monitor-init@0.service.d/fan-watchdog-monitor.conf"
-SYSTEMD_OVERRIDE_phosphor-fan-monitor += "fan-watchdog-monitor.conf:phosphor-fan-monitor@0.service.d/fan-watchdog-monitor.conf"
+SYSTEMD_OVERRIDE_phosphor-fan-control_witherspoon += "fan-watchdog-monitor.conf:phosphor-fan-control-init@0.service.d/fan-watchdog-monitor.conf"
+SYSTEMD_OVERRIDE_phosphor-fan-control_witherspoon += "fan-watchdog-monitor.conf:phosphor-fan-control@0.service.d/fan-watchdog-monitor.conf"
+SYSTEMD_OVERRIDE_phosphor-fan-monitor_witherspoon += "fan-watchdog-monitor.conf:phosphor-fan-monitor-init@0.service.d/fan-watchdog-monitor.conf"
+SYSTEMD_OVERRIDE_phosphor-fan-monitor_witherspoon += "fan-watchdog-monitor.conf:phosphor-fan-monitor@0.service.d/fan-watchdog-monitor.conf"
 
 #These services need to be stopped when watchdog expires
-SYSTEMD_OVERRIDE_phosphor-fan-control += "fan-watchdog-conflicts.conf:phosphor-fan-control@0.service.d/fan-watchdog-conflicts.conf"
-SYSTEMD_OVERRIDE_phosphor-fan-monitor += "fan-watchdog-conflicts.conf:phosphor-fan-monitor@0.service.d/fan-watchdog-conflicts.conf"
+SYSTEMD_OVERRIDE_phosphor-fan-control_witherspoon += "fan-watchdog-conflicts.conf:phosphor-fan-control@0.service.d/fan-watchdog-conflicts.conf"
+SYSTEMD_OVERRIDE_phosphor-fan-monitor_witherspoon += "fan-watchdog-conflicts.conf:phosphor-fan-monitor@0.service.d/fan-watchdog-conflicts.conf"
diff --git a/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-fan-config-native/fans.yaml b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-fan-config-native/fans.yaml
new file mode 100644
index 0000000..a70ac85
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-fan-config-native/fans.yaml
@@ -0,0 +1,21 @@
+fans:
+  - inventory: /system/chassis/motherboard/fan2
+    cooling_zone: 0
+    cooling_profile: all
+    sensors:
+      - fan2_0
+  - inventory: /system/chassis/motherboard/fan0
+    cooling_zone: 0
+    cooling_profile: all
+    sensors:
+      - fan0_0
+  - inventory: /system/chassis/motherboard/fan1
+    cooling_zone: 0
+    cooling_profile: air
+    sensors:
+      - fan1_0
+  - inventory: /system/chassis/motherboard/fan3
+    cooling_zone: 0
+    cooling_profile: all
+    sensors:
+      - fan3_0
diff --git a/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-zone-conditions-config-native/zone_conditions.yaml b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-zone-conditions-config-native/zone_conditions.yaml
new file mode 100644
index 0000000..0c8b3c5
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-zone-conditions-config-native/zone_conditions.yaml
@@ -0,0 +1,18 @@
+conditions:
+  - name: air_cooled_chassis
+    type: getProperty
+    properties:
+      - property: WaterCooled
+        interface: xyz.openbmc_project.Inventory.Decorator.CoolingType
+        path: /xyz/openbmc_project/inventory/system/chassis
+        type: bool
+        value: false
+
+  - name: water_and_air_cooled_chassis
+    type: getProperty
+    properties:
+      - property: WaterCooled
+        interface: xyz.openbmc_project.Inventory.Decorator.CoolingType
+        path: /xyz/openbmc_project/inventory/system/chassis
+        type: bool
+        value: true
diff --git a/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-zone-config-native/zones.yaml b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-zone-config-native/zones.yaml
new file mode 100644
index 0000000..c10c6c1
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan-control-zone-config-native/zones.yaml
@@ -0,0 +1,68 @@
+manager_configuration:
+  power_on_delay: 20
+
+zone_configuration:
+
+#Air cooled zones
+- zone_conditions:
+  - name: air_cooled_chassis
+
+  zones:
+    - zone: 0
+      cooling_profiles:
+      - air
+      - all
+      full_speed: 9500
+      default_floor: 8000
+      increase_delay: 5
+      decrease_interval: 30
+      interfaces:
+          - name: xyz.openbmc_project.Control.ThermalMode
+            properties:
+                - name: Supported
+                  type: array[string]
+                  values:
+                      - value: DEFAULT
+                        description: >
+                            Default thermal control mode
+                - name: Current
+                  type: string
+                  persist: true
+                  values:
+                      - value: DEFAULT
+                        description: >
+                            Set current thermal control mode to the
+                            default which will be replaced on startup if
+                            another supported mode was selected & persisted.
+
+#Water cooled zones
+- zone_conditions:
+  - name: water_and_air_cooled_chassis
+
+  zones:
+    - zone: 0
+      cooling_profiles:
+      - water
+      - all
+      full_speed: 9500
+      default_floor: 8000
+      increase_delay: 5
+      decrease_interval: 30
+      interfaces:
+          - name: xyz.openbmc_project.Control.ThermalMode
+            properties:
+                - name: Supported
+                  type: array[string]
+                  values:
+                      - value: DEFAULT
+                        description: >
+                            Default thermal control mode
+                - name: Current
+                  type: string
+                  persist: true
+                  values:
+                      - value: DEFAULT
+                        description: >
+                            Set current thermal control mode to the
+                            default which will be replaced on startup if
+                            another supported mode was selected & persisted.
diff --git a/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan/obmc/phosphor-fan/phosphor-cooling-type-0.conf b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan/obmc/phosphor-fan/phosphor-cooling-type-0.conf
new file mode 100644
index 0000000..e5e8f43
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan/obmc/phosphor-fan/phosphor-cooling-type-0.conf
@@ -0,0 +1,6 @@
+OBJPATH="--path=/system/chassis"
+AIR="--air"
+WATER=""
+DEVICE="--dev=/dev/input/by-path/platform-gpio-keys-event"
+CODE="--event=13"
+
diff --git a/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan/phosphor-cooling-type@.service b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan/phosphor-cooling-type@.service
new file mode 100644
index 0000000..c1f5ae2
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/swift-phosphor-fan/phosphor-cooling-type@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Phosphor Cooling Type
+Wants=mapper-wait@-xyz-openbmc_project-inventory.service
+After=mapper-wait@-xyz-openbmc_project-inventory.service
+ConditionPathExists={envfiledir}/obmc/phosphor-fan/phosphor-cooling-type-%i.conf
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+EnvironmentFile={envfiledir}/obmc/phosphor-fan/phosphor-cooling-type-%i.conf
+ExecStart=/usr/bin/env phosphor-cooling-type ${{OBJPATH}} ${{AIR}} ${{WATER}} ${{DEVICE}} ${{CODE}}
+SyslogIdentifier=phosphor-cooling-type
+
+[Install]
+RequiredBy=multi-user.target