PEL: devcallouts: Determine access type

Add a function to determine if the device path represents an I2C, FSI,
FSI-I2C, or FSI-SPI attached device.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ie58452e7988938e9b701357bbb96252be971902f
diff --git a/test/openpower-pels/device_callouts_test.cpp b/test/openpower-pels/device_callouts_test.cpp
index d2947a1..fd5213d 100644
--- a/test/openpower-pels/device_callouts_test.cpp
+++ b/test/openpower-pels/device_callouts_test.cpp
@@ -240,3 +240,51 @@
         EXPECT_THROW(util::getJSONFilename(compatibles), std::invalid_argument);
     }
 }
+
+// Test determining the callout type from the device path
+TEST_F(DeviceCalloutsTest, getCalloutTypeTest)
+{
+
+    // Invalid
+    {
+        EXPECT_EQ(util::getCalloutType("/some/bad/device/path"),
+                  util::CalloutType::unknown);
+    }
+
+    // I2C
+    {
+        EXPECT_EQ(util::getCalloutType(
+                      "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/"
+                      "1e78a340.i2c-bus/i2c-10/10-0022"),
+                  util::CalloutType::i2c);
+    }
+
+    // FSI
+    {
+        EXPECT_EQ(util::getCalloutType(
+                      "/sys/devices/platform/ahb/ahb:apb/1e79b000.fsi/"
+                      "fsi-master/fsi0/slave@00:00/00:00:00:0a/fsi-master/fsi1/"
+                      "slave@01:00/01:01:00:06/sbefifo2-dev0/occ-hwmon.2"),
+                  util::CalloutType::fsi);
+    }
+
+    // FSI-I2C
+    {
+        EXPECT_EQ(util::getCalloutType(
+                      "/sys/devices/platform/ahb/ahb:apb/1e79b000.fsi/"
+                      "fsi-master/fsi0/slave@00:00/00:00:00:0a/fsi-master/fsi1/"
+                      "slave@01:00/01:01:00:03/i2c-211/211-0055"),
+                  util::CalloutType::fsii2c);
+    }
+
+    // FSI-SPI
+    {
+
+        EXPECT_EQ(
+            util::getCalloutType(
+                "/sys/devices/platform/ahb/ahb:apb/1e79b000.fsi/fsi-master/"
+                "fsi0/slave@00:00/00:00:00:0a/fsi-master/fsi1/slave@08:00/"
+                "01:03:00:04/spi_master/spi9/spi9.0/spi9.00/nvmem"),
+            util::CalloutType::fsispi);
+    }
+}