Add sensor entry for power supply redundancy enabled.

IPMI to dbus lookup contained only mapping for PS
redundancy disabled, adding the mapping for enabled.
Changing the PS redundancy sensor type from D8 to CA.

Resolves openbmc/openbmc#2810

Change-Id: I2399ce76a168f63f6a4528cff8aa397ef12d5e1e
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/ipmisensor.cpp b/ipmisensor.cpp
index eb70a7d..3bca4e7 100644
--- a/ipmisensor.cpp
+++ b/ipmisensor.cpp
@@ -204,7 +204,8 @@
 	{0x12, 0x02, set_sensor_dbus_state_system_event, "setValue", "", ""},
 	{0x12, 0x03, set_sensor_dbus_state_system_event, "setValue", "", ""},
 	{0x12, 0x04, set_sensor_dbus_state_system_event, "setValue", "", ""},
-	{0xD8, 0x00, set_sensor_dbus_state_simple,       "setValue", "Disabled", ""},
+	{0xCA, 0x00, set_sensor_dbus_state_simple,       "setValue", "Disabled", ""},
+	{0xCA, 0x01, set_sensor_dbus_state_simple,       "setValue", "Enabled", ""},
 	{0xFF, 0xFF, NULL, "", "", ""}
 };
 
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 3358b83..9064ecc 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -488,6 +488,7 @@
     sd_bus *bus = ipmid_get_sd_bus_connection();
     sd_bus_message *reply = NULL;
     int reading = 0;
+    char* assertion = NULL;
 
     printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum);
 
@@ -542,6 +543,39 @@
             resp->indication[1] = 0;
             break;
 
+        //TODO openbmc/openbmc#2154 Move this sensor to right place.
+        case 0xCA:
+            r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "s");
+            if (r < 0) {
+                fprintf(stderr, "Failed to call sd_bus_get_property:%d,  %s\n", r, strerror(-r));
+                fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n",
+                        a.bus, a.path, a.interface);
+                break;
+            }
+
+            r = sd_bus_message_read(reply, "s", &assertion);
+            if (r < 0) {
+                fprintf(stderr, "Failed to read sensor: %s\n", strerror(-r));
+                break;
+            }
+
+            rc = IPMI_CC_OK;
+            *data_len=sizeof(sensorreadingresp_t);
+
+            resp->value         = 0;
+            resp->operation     = 0;
+            if (strcmp(assertion,"Enabled") == 0)
+            {
+                resp->indication[0] = 0x02;
+            }
+            else
+            {
+                resp->indication[0] = 0x1;
+            }
+            resp->indication[1] = 0;
+            free(assertion);
+            break;
+
         case IPMI_SENSOR_TEMP:
         case IPMI_SENSOR_VOLTAGE:
         case IPMI_SENSOR_CURRENT: