1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef DEVICE_SMBUS_H
19#define DEVICE_SMBUS_H
20
21#include <device/device.h>
22#include <device/path.h>
23#include <device/smbus_def.h>
24
25
26struct smbus_bus_operations {
27 int (*quick_read) (struct device *dev);
28 int (*quick_write) (struct device *dev);
29 int (*recv_byte) (struct device *dev);
30 int (*send_byte) (struct device *dev, u8 value);
31 int (*read_byte) (struct device *dev, u8 addr);
32 int (*write_byte) (struct device *dev, u8 addr, u8 value);
33 int (*read_word) (struct device *dev, u8 addr);
34 int (*write_word) (struct device *dev, u8 addr, u16 value);
35 int (*process_call)(struct device *dev, u8 cmd, u16 data);
36 int (*block_read) (struct device *dev, u8 cmd, u8 bytes, u8 *buffer);
37 int (*block_write) (struct device *dev, u8 cmd, u8 bytes, const u8 *buffer);
38};
39
40static inline const struct smbus_bus_operations *ops_smbus_bus(struct bus *bus)
41{
42 const struct smbus_bus_operations *bops;
43 bops = 0;
44 if (bus && bus->dev && bus->dev->ops) {
45 bops = bus->dev->ops->ops_smbus_bus;
46 }
47 return bops;
48}
49struct bus *get_pbus_smbus(struct device *dev);
50int smbus_set_link(struct device *dev);
51
52int smbus_quick_read(struct device *dev);
53int smbus_quick_write(struct device *dev);
54int smbus_recv_byte(struct device *dev);
55int smbus_send_byte(struct device *dev, u8 byte);
56int smbus_read_byte(struct device *dev, u8 addr);
57int smbus_write_byte(struct device *dev, u8 addr, u8 val);
58int smbus_read_word(struct device *dev, u8 addr);
59int smbus_write_word(struct device *dev, u8 addr, u16 val);
60int smbus_process_call(struct device *dev, u8 cmd, u16 data);
61int smbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buffer);
62int smbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buffer);
63
64#endif
65