148c4d7785d9ce1ab05448c36dfadddfa360cabd
[coreboot.git] / src / include / device / smbus.h
1 #ifndef DEVICE_SMBUS_H
2 #define DEVICE_SMBUS_H
3
4 #include <stdint.h>
5 #include <device/device.h>
6 #include <device/path.h>
7 #include <device/smbus_def.h>
8
9 /* Common smbus bus operations */
10 struct smbus_bus_operations {
11         int (*quick_read)  (device_t dev);
12         int (*quick_write) (device_t dev);
13         int (*recv_byte)   (device_t dev);
14         int (*send_byte)   (device_t dev, uint8_t value);
15         int (*read_byte)   (device_t dev, uint8_t addr);
16         int (*write_byte)  (device_t dev, uint8_t addr, uint8_t value);
17         int (*read_word)   (device_t dev, uint8_t addr);
18         int (*write_word)  (device_t dev, uint8_t addr, uint16_t value);
19         int (*process_call)(device_t dev, uint8_t cmd, uint16_t data);
20         int (*block_read)  (device_t dev, uint8_t cmd, uint8_t bytes, uint8_t *buffer);
21         int (*block_write) (device_t dev, uint8_t cmd, uint8_t bytes, const uint8_t *buffer);
22 };
23
24 static inline const struct smbus_bus_operations *ops_smbus_bus(struct bus *bus)
25 {
26         const struct smbus_bus_operations *bops;
27         bops = 0;
28         if (bus && bus->dev && bus->dev->ops) {
29                 bops = bus->dev->ops->ops_smbus_bus;
30         }
31         return bops;
32 }
33 struct bus *get_pbus_smbus(device_t dev);
34 int smbus_set_link(device_t dev);
35
36 int smbus_quick_read(device_t dev);
37 int smbus_quick_write(device_t dev);
38 int smbus_recv_byte(device_t dev);
39 int smbus_send_byte(device_t dev, uint8_t byte);
40 int smbus_read_byte(device_t dev, uint8_t addr);
41 int smbus_write_byte(device_t dev, uint8_t addr, uint8_t val);
42 int smbus_read_word(device_t dev, uint8_t addr);
43 int smbus_write_word(device_t dev, uint8_t addr, uint16_t val);
44 int smbus_process_call(device_t dev, uint8_t cmd, uint16_t data);
45 int smbus_block_read(device_t dev, uint8_t cmd, uint8_t bytes, uint8_t *buffer);
46 int smbus_block_write(device_t dev, uint8_t cmd, uint8_t bytes, const uint8_t *buffer);
47
48
49 #endif /* DEVICE_SMBUS_H */