summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c/test
diff options
context:
space:
mode:
authorTerry J. Opie <opiet@us.ibm.com>2011-08-05 08:51:38 -0500
committerTerry J. Opie <opiet@us.ibm.com>2011-08-15 13:57:29 -0500
commitfa0113e4599fcca0c2d4c938c88d445d288a952a (patch)
treeca797228d6c31b9dcd3ed617f7a82e77d9e27138 /src/usr/i2c/test
parentb0ceda93e7d5b6b06465a5fcc0b261a52dad987d (diff)
downloadtalos-hostboot-fa0113e4599fcca0c2d4c938c88d445d288a952a.tar.gz
talos-hostboot-fa0113e4599fcca0c2d4c938c88d445d288a952a.zip
I2C Device Driver Skeleton
Change-Id: I0b092ea67e5bb8789378041c8c3a6a3f5cf3025e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/242 Reviewed-by: Terry J. Opie <opiet@us.ibm.com> Tested-by: Jenkins Server
Diffstat (limited to 'src/usr/i2c/test')
-rwxr-xr-xsrc/usr/i2c/test/i2ctest.H113
-rw-r--r--src/usr/i2c/test/makefile6
2 files changed, 119 insertions, 0 deletions
diff --git a/src/usr/i2c/test/i2ctest.H b/src/usr/i2c/test/i2ctest.H
new file mode 100755
index 000000000..3828cf889
--- /dev/null
+++ b/src/usr/i2c/test/i2ctest.H
@@ -0,0 +1,113 @@
+#ifndef __I2CTEST_H
+#define __I2CTEST_H
+
+/**
+ * @file i2ctest.H
+ *
+ * @brief Test case for I2C code
+*/
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <errl/errltypes.H>
+#include <devicefw/driverif.H>
+#include <i2c/i2creasoncodes.H>
+
+extern trace_desc_t* g_trac_i2c;
+
+using namespace TARGETING;
+
+// Address and data to read/write
+struct testI2CAddrData
+{
+ uint32_t addr;
+ uint64_t data;
+};
+
+// Test table values
+const testI2CAddrData g_i2cAddrTable[] =
+{
+ // Write data to be ORed with read value
+ {0x13030007, 0x0000040000000000},
+ {0x13010002, 0x00000C0000000000},
+};
+
+const uint32_t g_i2cmAddrTableSz =
+ sizeof(g_i2cAddrTable)/sizeof(testI2CAddrData);
+
+
+class I2CTest: public CxxTest::TestSuite
+{
+public:
+
+ /**
+ * @brief I2C test #1
+ * Write value and read back to verify
+ */
+ void testI2C1(void)
+ {
+ errlHndl_t l_err = NULL;
+ TS_TRACE( "I2C Test 1: its running!" );
+
+ do
+ {
+ TARGETING::TargetService& targetService = TARGETING::targetService();
+ TARGETING::Target* l_testTarget = NULL;
+ targetService.masterProcChipTargetHandle( l_testTarget );
+
+ if( NULL == l_testTarget )
+ {
+ TS_TRACE( "I2C Test - PROC test target is NULL!" );
+ break;
+ }
+
+ size_t l_size = sizeof(uint64_t);
+ testI2CAddrData l_testEntry = g_i2cAddrTable[0];
+
+ // --------------------------------------------
+ // NOTE: The following doesn't actually read
+ // or write any data, it is strictly there to
+ // prove that the interfaces are working. The
+ // real tests will be added at a later time.
+ // --------------------------------------------
+
+ // Perform I2C write
+ uint64_t l_data = 0;
+
+ l_err = deviceOp( DeviceFW::WRITE,
+ l_testTarget,
+ &l_data,
+ l_size,
+ DEVICE_I2C_ADDRESS(l_testEntry.addr) );
+
+ if( l_err )
+ {
+ break;
+ }
+
+ // Perform I2C read
+ l_err = deviceOp( DeviceFW::READ,
+ l_testTarget,
+ &l_data,
+ l_size,
+ DEVICE_I2C_ADDRESS(l_testEntry.addr) );
+
+
+ } while( 0 );
+
+ if (l_err)
+ {
+ TS_FAIL("testI2C1 failed! Error committed.");
+ errlCommit(l_err);
+ }
+ else
+ {
+ TS_TRACE("testI2C1 runs successfully!");
+ }
+
+ return;
+ }
+};
+
+#endif
diff --git a/src/usr/i2c/test/makefile b/src/usr/i2c/test/makefile
new file mode 100644
index 000000000..6e8623758
--- /dev/null
+++ b/src/usr/i2c/test/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../../..
+
+MODULE = testi2c
+TESTS = *.H
+
+include ${ROOTPATH}/config.mk
OpenPOWER on IntegriCloud