Lines 83-124
Link Here
|
83 |
static int |
83 |
static int |
84 |
sy8106a_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) |
84 |
sy8106a_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) |
85 |
{ |
85 |
{ |
86 |
struct sy8106a_softc *sc; |
86 |
return (iicdev_readfrom(dev, reg, data, size, IIC_INTRWAIT)); |
87 |
struct iic_msg msg[2]; |
|
|
88 |
|
89 |
sc = device_get_softc(dev); |
90 |
|
91 |
msg[0].slave = sc->addr; |
92 |
msg[0].flags = IIC_M_WR; |
93 |
msg[0].len = 1; |
94 |
msg[0].buf = ® |
95 |
|
96 |
msg[1].slave = sc->addr; |
97 |
msg[1].flags = IIC_M_RD; |
98 |
msg[1].len = size; |
99 |
msg[1].buf = data; |
100 |
|
101 |
return (iicbus_transfer(dev, msg, 2)); |
102 |
} |
87 |
} |
103 |
|
88 |
|
104 |
static int |
89 |
static int |
105 |
sy8106a_write(device_t dev, uint8_t reg, uint8_t val) |
90 |
sy8106a_write(device_t dev, uint8_t reg, uint8_t val) |
106 |
{ |
91 |
{ |
107 |
struct sy8106a_softc *sc; |
92 |
return (iicdev_writeto(dev, reg, &val, sizeof(val), IIC_INTRWAIT)); |
108 |
struct iic_msg msg; |
|
|
109 |
uint8_t buffer[2]; |
110 |
|
111 |
sc = device_get_softc(dev); |
112 |
|
113 |
buffer[0] = reg; |
114 |
buffer[1] = val; |
115 |
|
116 |
msg.slave = sc->addr; |
117 |
msg.flags = IIC_M_WR; |
118 |
msg.len = 2; |
119 |
msg.buf = buffer; |
120 |
|
121 |
return (iicbus_transfer(dev, &msg, 1)); |
122 |
} |
93 |
} |
123 |
|
94 |
|
124 |
static int |
95 |
static int |