diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/device/device.h | 2 | ||||
-rw-r--r-- | src/include/device/i2c.h | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h index 00ff3d9a07..95fabf42c8 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -20,6 +20,7 @@ struct device; typedef struct device * device_t; struct pci_operations; struct pci_bus_operations; +struct i2c_bus_operations; struct smbus_bus_operations; struct pnp_mode_ops; @@ -62,6 +63,7 @@ struct device_operations { const char *(*acpi_name)(device_t dev); #endif const struct pci_operations *ops_pci; + const struct i2c_bus_operations *ops_i2c_bus; const struct smbus_bus_operations *ops_smbus_bus; const struct pci_bus_operations * (*ops_pci_bus)(device_t dev); const struct pnp_mode_ops *ops_pnp_mode; diff --git a/src/include/device/i2c.h b/src/include/device/i2c.h index c8c7b2283d..d8a793c716 100644 --- a/src/include/device/i2c.h +++ b/src/include/device/i2c.h @@ -168,4 +168,26 @@ static inline int i2c_writeb(unsigned bus, uint8_t chip, uint8_t reg, return i2c_transfer(bus, &seg, 1); } +/* I2C bus operation for ramstage drivers */ +struct device; +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_seg *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_H_ */ |