Add basic function for phosphor-nvme.

Add basic function to monitor temperature of
NVMe drive for phosphor-nvme.

Change-Id: Iebe3c8bf4b5cb958defab5b24a88f4bce477ad5e
Signed-off-by: Tony Lee <tony.lee@quantatw.com>
diff --git a/i2c.h b/i2c.h
new file mode 100644
index 0000000..2b2984d
--- /dev/null
+++ b/i2c.h
@@ -0,0 +1,34 @@
+#include <linux/i2c-dev.h>
+#include <linux/i2c.h>
+#include <linux/types.h>
+#include <sys/ioctl.h>
+
+#define I2C_DATA_MAX 256
+
+static inline __s32 i2c_read_after_write(int file, __u8 slave_addr, __u8 tx_len,
+                                         __u8* tx_buf, int rx_len, __u8* rx_buf)
+{
+    struct i2c_rdwr_ioctl_data msgst;
+    struct i2c_msg msg[2];
+    int ret;
+
+    msg[0].addr = slave_addr & 0xFF;
+    msg[0].flags = 0;
+    msg[0].buf = (__u8*)tx_buf;
+    msg[0].len = tx_len;
+
+    msg[1].addr = slave_addr & 0xFF;
+    msg[1].flags = I2C_M_RD | I2C_M_RECV_LEN;
+    msg[1].buf = (__u8*)rx_buf;
+    msg[1].len = rx_len;
+
+    msgst.msgs = msg;
+    msgst.nmsgs = 2;
+
+    ret = ioctl(file, I2C_RDWR, &msgst);
+
+    if (ret < 0)
+        return ret;
+
+    return ret;
+}