cpu/x86/smm/pci_resource_store: Store DEV/VEN ID
[coreboot2.git] / src / device / smbus_ops.c
blobd08965c7e0b1660ad4d64ec9d1a5b07f56b9ea84
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <stdint.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/smbus.h>
8 struct bus *get_pbus_smbus(struct device *dev)
10 struct bus *const pbus = i2c_link(dev);
11 if (!pbus->dev->ops->ops_smbus_bus)
12 die("%s Cannot find SMBus bus operations", dev_path(dev));
13 return pbus;
16 #define CHECK_PRESENCE(x) \
17 if (!ops_smbus_bus(get_pbus_smbus(dev))->x) { \
18 printk(BIOS_ERR, "%s missing " #x "\n", \
19 dev_path(dev)); \
20 return -1; \
23 int smbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buffer)
25 CHECK_PRESENCE(block_read);
27 return ops_smbus_bus(get_pbus_smbus(dev))->block_read(dev, cmd,
28 bytes, buffer);
31 int smbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buffer)
33 CHECK_PRESENCE(block_write);
35 return ops_smbus_bus(get_pbus_smbus(dev))->block_write(dev, cmd,
36 bytes, buffer);