Add wistron oem command to detect riser-f

PNOR needs to know whether riser-f is present when poweron, so we add
an oem command to detect whether riser-f is present.
The result will return two bytes of data, the first byte is bus9 and
the second byte is bus10.

Return data will have 0x00 or 0x01.
0x00 means riser-f not present
0x01 means riser-f present

Change-Id: I7d932b8e69b820b67466b83998d5bd3b8c472720
Signed-off-by: Ben Pai <Ben_Pai@wistron.com>
diff --git a/i2c.h b/i2c.h
new file mode 100644
index 0000000..55dc23c
--- /dev/null
+++ b/i2c.h
@@ -0,0 +1,57 @@
+#include <linux/i2c-dev.h>
+#include <linux/i2c.h>
+#include <linux/types.h>
+#include <stddef.h>
+#include <sys/ioctl.h>
+
+/*
+ * Data for SMBus Messages
+ */
+#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
+#define I2C_DATA_MAX 256
+
+/* smbus_access read or write markers */
+#define I2C_SMBUS_READ 1
+#define I2C_SMBUS_WRITE 0
+
+/* SMBus transaction types (size parameter in the above functions)
+   Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
+#define I2C_SMBUS_BYTE_DATA 2
+
+/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
+ * are NOT supported! (due to code brokenness)
+ */
+#define I2C_SLAVE 0x0703 /* Use this slave address */
+#define I2C_SLAVE_FORCE 0x0706
+#define I2C_SMBUS 0x0720 /* SMBus transfer */
+
+static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
+                                     int size, union i2c_smbus_data* data)
+{
+    struct i2c_smbus_ioctl_data args;
+
+    args.read_write = read_write;
+    args.command = command;
+    args.size = size;
+    args.data = data;
+    return ioctl(file, I2C_SMBUS, &args);
+}
+
+static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
+                                              __u8 value)
+{
+    union i2c_smbus_data data;
+    data.byte = value;
+    return i2c_smbus_access(file, I2C_SMBUS_WRITE, command, I2C_SMBUS_BYTE_DATA,
+                            &data);
+}
+
+static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
+{
+    union i2c_smbus_data data;
+    if (i2c_smbus_access(file, I2C_SMBUS_READ, command, I2C_SMBUS_BYTE_DATA,
+                         &data))
+        return -1;
+    else
+        return 0x0FF & data.byte;
+}