include/device/pci_def.h: Add PCIe SRIOV definitions
[coreboot2.git] / src / include / device / smbus.h
blob171e30447271e291423a133cf49f1ce00f638a3c
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef DEVICE_SMBUS_H
4 #define DEVICE_SMBUS_H
6 #include <stdint.h>
7 #include <device/device.h>
8 #include <device/i2c_bus.h>
10 /* Common SMBus bus operations */
11 struct smbus_bus_operations {
12 int (*recv_byte)(struct device *dev);
13 int (*send_byte)(struct device *dev, u8 value);
14 int (*read_byte)(struct device *dev, u8 addr);
15 int (*write_byte)(struct device *dev, u8 addr, u8 value);
16 int (*block_read)(struct device *dev, u8 cmd, u8 bytes, u8 *buffer);
17 int (*block_write)(struct device *dev, u8 cmd, u8 bytes,
18 const u8 *buffer);
21 static inline const struct smbus_bus_operations *ops_smbus_bus(struct bus *bus)
23 const struct smbus_bus_operations *bops;
25 bops = 0;
26 if (bus && bus->dev && bus->dev->ops)
27 bops = bus->dev->ops->ops_smbus_bus;
29 return bops;
32 struct bus *get_pbus_smbus(struct device *dev);
34 #if !DEVTREE_EARLY
35 static inline int smbus_recv_byte(struct device *const dev)
37 return i2c_dev_readb(dev);
40 static inline int smbus_send_byte(struct device *const dev, u8 byte)
42 return i2c_dev_writeb(dev, byte);
45 static inline int smbus_read_byte(struct device *const dev, u8 addr)
47 return i2c_dev_readb_at(dev, addr);
50 static inline int smbus_write_byte(struct device *const dev, u8 addr, u8 val)
52 return i2c_dev_writeb_at(dev, addr, val);
55 int smbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buffer);
56 int smbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buffer);
57 #endif
59 #endif /* DEVICE_SMBUS_H */