summaryrefslogtreecommitdiffstats
path: root/src/include/device/i2c_bus.h
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2017-08-01 14:02:40 +0200
committerMartin Roth <martinroth@google.com>2017-08-18 15:33:29 +0000
commit0f2dd1eff9930e30dddd9aabceb5d85ee3b4e980 (patch)
tree50de642731203f720012db6bd2829d8dada2be40 /src/include/device/i2c_bus.h
parent457fba6be5c2b31f6fc50a5e6feabf73a2663330 (diff)
downloadcoreboot-0f2dd1eff9930e30dddd9aabceb5d85ee3b4e980.tar.gz
coreboot-0f2dd1eff9930e30dddd9aabceb5d85ee3b4e980.tar.bz2
coreboot-0f2dd1eff9930e30dddd9aabceb5d85ee3b4e980.zip
include/device: Split i2c.h into three
Split `i2c.h` into three pieces to ease reuse of the generic defi- nitions. No code is changed. * `i2c.h` - keeps the generic definitions * `i2c_simple.h` - holds the current, limited to one controller driver per board, devicetree independent I2C interface * `i2c_bus.h` - will become the devicetree compatible interface for native I2C (e.g. non-SMBus) controllers Change-Id: I382d45c70f9314588663e1284f264f877469c74d Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/20845 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include/device/i2c_bus.h')
-rw-r--r--src/include/device/i2c_bus.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/include/device/i2c_bus.h b/src/include/device/i2c_bus.h
new file mode 100644
index 000000000000..474d9e5b2c06
--- /dev/null
+++ b/src/include/device/i2c_bus.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DEVICE_I2C_BUS_H_
+#define _DEVICE_I2C_BUS_H_
+
+#include <stdint.h>
+#include <device/i2c.h>
+#include <device/device.h>
+
+/* I2C bus operation for ramstage drivers */
+struct i2c_bus_operations {
+ /*
+ * This is an SOC specific method that can be provided to translate the
+ * 'struct device' for an I2C controller into a unique I2C bus number.
+ * Returns -1 if the bus number for this device cannot be determined.
+ */
+ int (*dev_to_bus)(struct device *dev);
+};
+
+/* Return I2C bus number for provided device, -1 if not found */
+int i2c_dev_find_bus(struct device *dev);
+
+/* Variants of I2C helper functions that take a device instead of bus number */
+int i2c_dev_transfer(struct device *dev, struct i2c_msg *segments, int count);
+int i2c_dev_readb(struct device *dev, uint8_t reg, uint8_t *data);
+int i2c_dev_writeb(struct device *dev, uint8_t reg, uint8_t data);
+int i2c_dev_read_bytes(struct device *dev, uint8_t reg, uint8_t *data, int len);
+int i2c_dev_read_raw(struct device *dev, uint8_t *data, int len);
+int i2c_dev_write_raw(struct device *dev, uint8_t *data, int len);
+
+#endif /* _DEVICE_I2C_BUS_H_ */