ichsmb.c revision 1.4.4.4 1 1.4.4.4 ad /* $NetBSD: ichsmb.c,v 1.4.4.4 2007/10/23 20:08:54 ad Exp $ */
2 1.4.4.2 ad /* $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */
3 1.4.4.2 ad
4 1.4.4.2 ad /*
5 1.4.4.2 ad * Copyright (c) 2005, 2006 Alexander Yurchenko <grange (at) openbsd.org>
6 1.4.4.2 ad *
7 1.4.4.2 ad * Permission to use, copy, modify, and distribute this software for any
8 1.4.4.2 ad * purpose with or without fee is hereby granted, provided that the above
9 1.4.4.2 ad * copyright notice and this permission notice appear in all copies.
10 1.4.4.2 ad *
11 1.4.4.2 ad * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.4.4.2 ad * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.4.4.2 ad * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.4.4.2 ad * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.4.4.2 ad * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.4.4.2 ad * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.4.4.2 ad * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.4.4.2 ad */
19 1.4.4.2 ad
20 1.4.4.2 ad /*
21 1.4.4.2 ad * Intel ICH SMBus controller driver.
22 1.4.4.2 ad */
23 1.4.4.2 ad
24 1.4.4.3 ad #include <sys/cdefs.h>
25 1.4.4.4 ad __KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.4.4.4 2007/10/23 20:08:54 ad Exp $");
26 1.4.4.3 ad
27 1.4.4.2 ad #include <sys/param.h>
28 1.4.4.2 ad #include <sys/device.h>
29 1.4.4.2 ad #include <sys/errno.h>
30 1.4.4.2 ad #include <sys/kernel.h>
31 1.4.4.3 ad #include <sys/rwlock.h>
32 1.4.4.2 ad #include <sys/proc.h>
33 1.4.4.2 ad
34 1.4.4.4 ad #include <sys/bus.h>
35 1.4.4.2 ad
36 1.4.4.2 ad #include <dev/pci/pcidevs.h>
37 1.4.4.2 ad #include <dev/pci/pcireg.h>
38 1.4.4.2 ad #include <dev/pci/pcivar.h>
39 1.4.4.2 ad
40 1.4.4.3 ad #include <dev/ic/i82801lpcreg.h>
41 1.4.4.2 ad
42 1.4.4.2 ad #include <dev/i2c/i2cvar.h>
43 1.4.4.2 ad
44 1.4.4.2 ad #ifdef ICHIIC_DEBUG
45 1.4.4.2 ad #define DPRINTF(x) printf x
46 1.4.4.2 ad #else
47 1.4.4.2 ad #define DPRINTF(x)
48 1.4.4.2 ad #endif
49 1.4.4.2 ad
50 1.4.4.2 ad #define ICHIIC_DELAY 100
51 1.4.4.2 ad #define ICHIIC_TIMEOUT 1
52 1.4.4.2 ad
53 1.4.4.2 ad struct ichsmb_softc {
54 1.4.4.2 ad struct device sc_dev;
55 1.4.4.2 ad
56 1.4.4.2 ad bus_space_tag_t sc_iot;
57 1.4.4.2 ad bus_space_handle_t sc_ioh;
58 1.4.4.2 ad void * sc_ih;
59 1.4.4.2 ad int sc_poll;
60 1.4.4.2 ad
61 1.4.4.2 ad struct i2c_controller sc_i2c_tag;
62 1.4.4.3 ad krwlock_t sc_i2c_rwlock;
63 1.4.4.2 ad struct {
64 1.4.4.2 ad i2c_op_t op;
65 1.4.4.2 ad void * buf;
66 1.4.4.2 ad size_t len;
67 1.4.4.2 ad int flags;
68 1.4.4.2 ad volatile int error;
69 1.4.4.2 ad } sc_i2c_xfer;
70 1.4.4.2 ad };
71 1.4.4.2 ad
72 1.4.4.2 ad static int ichsmb_match(struct device *, struct cfdata *, void *);
73 1.4.4.2 ad static void ichsmb_attach(struct device *, struct device *, void *);
74 1.4.4.2 ad
75 1.4.4.2 ad static int ichsmb_i2c_acquire_bus(void *, int);
76 1.4.4.2 ad static void ichsmb_i2c_release_bus(void *, int);
77 1.4.4.2 ad static int ichsmb_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *,
78 1.4.4.2 ad size_t, void *, size_t, int);
79 1.4.4.2 ad
80 1.4.4.2 ad static int ichsmb_intr(void *);
81 1.4.4.2 ad
82 1.4.4.2 ad
83 1.4.4.2 ad CFATTACH_DECL(ichsmb, sizeof(struct ichsmb_softc),
84 1.4.4.2 ad ichsmb_match, ichsmb_attach, NULL, NULL);
85 1.4.4.2 ad
86 1.4.4.2 ad
87 1.4.4.2 ad static int
88 1.4.4.2 ad ichsmb_match(struct device *parent, struct cfdata *match, void *aux)
89 1.4.4.2 ad {
90 1.4.4.2 ad struct pci_attach_args *pa = aux;
91 1.4.4.2 ad
92 1.4.4.2 ad if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL) {
93 1.4.4.2 ad switch (PCI_PRODUCT(pa->pa_id)) {
94 1.4.4.2 ad case PCI_PRODUCT_INTEL_6300ESB_SMB:
95 1.4.4.2 ad case PCI_PRODUCT_INTEL_63XXESB_SMB:
96 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801AA_SMB:
97 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801AB_SMB:
98 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801BA_SMB:
99 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801CA_SMB:
100 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801DB_SMB:
101 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801E_SMB:
102 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801EB_SMB:
103 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801FB_SMB:
104 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801G_SMB:
105 1.4.4.2 ad case PCI_PRODUCT_INTEL_82801H_SMB:
106 1.4.4.3 ad case PCI_PRODUCT_INTEL_82801I_SMB:
107 1.4.4.2 ad return 1;
108 1.4.4.2 ad }
109 1.4.4.2 ad }
110 1.4.4.2 ad return 0;
111 1.4.4.2 ad }
112 1.4.4.2 ad
113 1.4.4.2 ad static void
114 1.4.4.2 ad ichsmb_attach(struct device *parent, struct device *self, void *aux)
115 1.4.4.2 ad {
116 1.4.4.2 ad struct ichsmb_softc *sc = (struct ichsmb_softc *)self;
117 1.4.4.2 ad struct pci_attach_args *pa = aux;
118 1.4.4.2 ad struct i2cbus_attach_args iba;
119 1.4.4.2 ad pcireg_t conf;
120 1.4.4.2 ad bus_size_t iosize;
121 1.4.4.2 ad pci_intr_handle_t ih;
122 1.4.4.2 ad const char *intrstr = NULL;
123 1.4.4.2 ad char devinfo[256];
124 1.4.4.2 ad
125 1.4.4.2 ad aprint_naive("\n");
126 1.4.4.2 ad pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
127 1.4.4.2 ad aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
128 1.4.4.2 ad PCI_REVISION(pa->pa_class));
129 1.4.4.2 ad
130 1.4.4.2 ad /* Read configuration */
131 1.4.4.3 ad conf = pci_conf_read(pa->pa_pc, pa->pa_tag, LPCIB_SMB_HOSTC);
132 1.4.4.2 ad DPRINTF(("%s: conf 0x%08x", sc->sc_dev.dv_xname, conf));
133 1.4.4.2 ad
134 1.4.4.3 ad if ((conf & LPCIB_SMB_HOSTC_HSTEN) == 0) {
135 1.4.4.2 ad aprint_error("%s: SMBus disabled\n", sc->sc_dev.dv_xname);
136 1.4.4.2 ad return;
137 1.4.4.2 ad }
138 1.4.4.2 ad
139 1.4.4.2 ad /* Map I/O space */
140 1.4.4.3 ad if (pci_mapreg_map(pa, LPCIB_SMB_BASE, PCI_MAPREG_TYPE_IO, 0,
141 1.4.4.2 ad &sc->sc_iot, &sc->sc_ioh, NULL, &iosize)) {
142 1.4.4.2 ad aprint_error("%s: can't map I/O space\n", sc->sc_dev.dv_xname);
143 1.4.4.2 ad return;
144 1.4.4.2 ad }
145 1.4.4.2 ad
146 1.4.4.2 ad sc->sc_poll = 1;
147 1.4.4.3 ad if (conf & LPCIB_SMB_HOSTC_SMIEN) {
148 1.4.4.2 ad /* No PCI IRQ */
149 1.4.4.2 ad aprint_normal("%s: SMI\n", sc->sc_dev.dv_xname);
150 1.4.4.2 ad } else {
151 1.4.4.2 ad /* Install interrupt handler */
152 1.4.4.2 ad if (pci_intr_map(pa, &ih) == 0) {
153 1.4.4.2 ad intrstr = pci_intr_string(pa->pa_pc, ih);
154 1.4.4.2 ad sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
155 1.4.4.2 ad ichsmb_intr, sc);
156 1.4.4.2 ad if (sc->sc_ih != NULL) {
157 1.4.4.2 ad aprint_normal("%s: interrupting at %s\n",
158 1.4.4.2 ad sc->sc_dev.dv_xname, intrstr);
159 1.4.4.2 ad sc->sc_poll = 0;
160 1.4.4.2 ad }
161 1.4.4.2 ad }
162 1.4.4.2 ad if (sc->sc_poll)
163 1.4.4.2 ad aprint_normal("%s: polling\n", sc->sc_dev.dv_xname);
164 1.4.4.2 ad }
165 1.4.4.2 ad
166 1.4.4.2 ad /* Attach I2C bus */
167 1.4.4.3 ad rw_init(&sc->sc_i2c_rwlock);
168 1.4.4.2 ad sc->sc_i2c_tag.ic_cookie = sc;
169 1.4.4.2 ad sc->sc_i2c_tag.ic_acquire_bus = ichsmb_i2c_acquire_bus;
170 1.4.4.2 ad sc->sc_i2c_tag.ic_release_bus = ichsmb_i2c_release_bus;
171 1.4.4.2 ad sc->sc_i2c_tag.ic_exec = ichsmb_i2c_exec;
172 1.4.4.2 ad
173 1.4.4.2 ad bzero(&iba, sizeof(iba));
174 1.4.4.3 ad iba.iba_type = I2C_TYPE_SMBUS;
175 1.4.4.2 ad iba.iba_tag = &sc->sc_i2c_tag;
176 1.4.4.2 ad config_found(self, &iba, iicbus_print);
177 1.4.4.2 ad
178 1.4.4.2 ad return;
179 1.4.4.2 ad }
180 1.4.4.2 ad
181 1.4.4.2 ad static int
182 1.4.4.2 ad ichsmb_i2c_acquire_bus(void *cookie, int flags)
183 1.4.4.2 ad {
184 1.4.4.2 ad struct ichsmb_softc *sc = cookie;
185 1.4.4.2 ad
186 1.4.4.2 ad if (cold || sc->sc_poll || (flags & I2C_F_POLL))
187 1.4.4.3 ad return 0;
188 1.4.4.2 ad
189 1.4.4.3 ad rw_enter(&sc->sc_i2c_rwlock, RW_WRITER);
190 1.4.4.3 ad return 0;
191 1.4.4.2 ad }
192 1.4.4.2 ad
193 1.4.4.2 ad static void
194 1.4.4.2 ad ichsmb_i2c_release_bus(void *cookie, int flags)
195 1.4.4.2 ad {
196 1.4.4.2 ad struct ichsmb_softc *sc = cookie;
197 1.4.4.2 ad
198 1.4.4.2 ad if (cold || sc->sc_poll || (flags & I2C_F_POLL))
199 1.4.4.2 ad return;
200 1.4.4.2 ad
201 1.4.4.3 ad rw_exit(&sc->sc_i2c_rwlock);
202 1.4.4.2 ad }
203 1.4.4.2 ad
204 1.4.4.2 ad static int
205 1.4.4.2 ad ichsmb_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
206 1.4.4.2 ad const void *cmdbuf, size_t cmdlen, void *buf, size_t len, int flags)
207 1.4.4.2 ad {
208 1.4.4.2 ad struct ichsmb_softc *sc = cookie;
209 1.4.4.2 ad const uint8_t *b;
210 1.4.4.2 ad uint8_t ctl = 0, st;
211 1.4.4.2 ad int retries;
212 1.4.4.2 ad char fbuf[64];
213 1.4.4.2 ad
214 1.4.4.2 ad DPRINTF(("%s: exec: op %d, addr 0x%02x, cmdlen %zu, len %d, "
215 1.4.4.2 ad "flags 0x%02x\n", sc->sc_dev.dv_xname, op, addr, cmdlen,
216 1.4.4.2 ad len, flags));
217 1.4.4.2 ad
218 1.4.4.2 ad /* Wait for bus to be idle */
219 1.4.4.2 ad for (retries = 100; retries > 0; retries--) {
220 1.4.4.3 ad st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS);
221 1.4.4.3 ad if (!(st & LPCIB_SMB_HS_BUSY))
222 1.4.4.2 ad break;
223 1.4.4.2 ad DELAY(ICHIIC_DELAY);
224 1.4.4.2 ad }
225 1.4.4.2 ad #ifdef ICHIIC_DEBUG
226 1.4.4.3 ad bitmask_snprintf(st, LPCIB_SMB_HS_BITS, fbuf, sizeof(fbuf));
227 1.4.4.2 ad printf("%s: exec: st 0x%s\n", sc->sc_dev.dv_xname, fbuf);
228 1.4.4.2 ad #endif
229 1.4.4.3 ad if (st & LPCIB_SMB_HS_BUSY)
230 1.4.4.2 ad return (1);
231 1.4.4.2 ad
232 1.4.4.2 ad if (cold || sc->sc_poll)
233 1.4.4.2 ad flags |= I2C_F_POLL;
234 1.4.4.2 ad
235 1.4.4.2 ad if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2)
236 1.4.4.2 ad return (1);
237 1.4.4.2 ad
238 1.4.4.2 ad /* Setup transfer */
239 1.4.4.2 ad sc->sc_i2c_xfer.op = op;
240 1.4.4.2 ad sc->sc_i2c_xfer.buf = buf;
241 1.4.4.2 ad sc->sc_i2c_xfer.len = len;
242 1.4.4.2 ad sc->sc_i2c_xfer.flags = flags;
243 1.4.4.2 ad sc->sc_i2c_xfer.error = 0;
244 1.4.4.2 ad
245 1.4.4.2 ad /* Set slave address and transfer direction */
246 1.4.4.3 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_TXSLVA,
247 1.4.4.3 ad LPCIB_SMB_TXSLVA_ADDR(addr) |
248 1.4.4.3 ad (I2C_OP_READ_P(op) ? LPCIB_SMB_TXSLVA_READ : 0));
249 1.4.4.2 ad
250 1.4.4.2 ad b = (const uint8_t *)cmdbuf;
251 1.4.4.2 ad if (cmdlen > 0)
252 1.4.4.2 ad /* Set command byte */
253 1.4.4.3 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HCMD, b[0]);
254 1.4.4.2 ad
255 1.4.4.2 ad if (I2C_OP_WRITE_P(op)) {
256 1.4.4.2 ad /* Write data */
257 1.4.4.2 ad b = buf;
258 1.4.4.2 ad if (len > 0)
259 1.4.4.2 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh,
260 1.4.4.3 ad LPCIB_SMB_HD0, b[0]);
261 1.4.4.2 ad if (len > 1)
262 1.4.4.2 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh,
263 1.4.4.3 ad LPCIB_SMB_HD1, b[1]);
264 1.4.4.2 ad }
265 1.4.4.2 ad
266 1.4.4.2 ad /* Set SMBus command */
267 1.4.4.2 ad if (len == 0)
268 1.4.4.3 ad ctl = LPCIB_SMB_HC_CMD_BYTE;
269 1.4.4.2 ad else if (len == 1)
270 1.4.4.3 ad ctl = LPCIB_SMB_HC_CMD_BDATA;
271 1.4.4.2 ad else if (len == 2)
272 1.4.4.3 ad ctl = LPCIB_SMB_HC_CMD_WDATA;
273 1.4.4.2 ad
274 1.4.4.2 ad if ((flags & I2C_F_POLL) == 0)
275 1.4.4.3 ad ctl |= LPCIB_SMB_HC_INTREN;
276 1.4.4.2 ad
277 1.4.4.2 ad /* Start transaction */
278 1.4.4.3 ad ctl |= LPCIB_SMB_HC_START;
279 1.4.4.3 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HC, ctl);
280 1.4.4.2 ad
281 1.4.4.2 ad if (flags & I2C_F_POLL) {
282 1.4.4.2 ad /* Poll for completion */
283 1.4.4.2 ad DELAY(ICHIIC_DELAY);
284 1.4.4.2 ad for (retries = 1000; retries > 0; retries--) {
285 1.4.4.2 ad st = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
286 1.4.4.3 ad LPCIB_SMB_HS);
287 1.4.4.3 ad if ((st & LPCIB_SMB_HS_BUSY) == 0)
288 1.4.4.2 ad break;
289 1.4.4.2 ad DELAY(ICHIIC_DELAY);
290 1.4.4.2 ad }
291 1.4.4.3 ad if (st & LPCIB_SMB_HS_BUSY)
292 1.4.4.2 ad goto timeout;
293 1.4.4.2 ad ichsmb_intr(sc);
294 1.4.4.2 ad } else {
295 1.4.4.2 ad /* Wait for interrupt */
296 1.4.4.2 ad if (tsleep(sc, PRIBIO, "iicexec", ICHIIC_TIMEOUT * hz))
297 1.4.4.2 ad goto timeout;
298 1.4.4.2 ad }
299 1.4.4.2 ad
300 1.4.4.2 ad if (sc->sc_i2c_xfer.error)
301 1.4.4.2 ad return (1);
302 1.4.4.2 ad
303 1.4.4.2 ad return (0);
304 1.4.4.2 ad
305 1.4.4.2 ad timeout:
306 1.4.4.2 ad /*
307 1.4.4.2 ad * Transfer timeout. Kill the transaction and clear status bits.
308 1.4.4.2 ad */
309 1.4.4.3 ad bitmask_snprintf(st, LPCIB_SMB_HS_BITS, fbuf, sizeof(fbuf));
310 1.4.4.2 ad printf("%s: exec: op %d, addr 0x%02x, cmdlen %zd, len %zd, "
311 1.4.4.2 ad "flags 0x%02x: timeout, status 0x%s\n",
312 1.4.4.2 ad sc->sc_dev.dv_xname, op, addr, cmdlen, len, flags, fbuf);
313 1.4.4.3 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HC,
314 1.4.4.3 ad LPCIB_SMB_HC_KILL);
315 1.4.4.2 ad DELAY(ICHIIC_DELAY);
316 1.4.4.3 ad st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS);
317 1.4.4.3 ad if ((st & LPCIB_SMB_HS_FAILED) == 0) {
318 1.4.4.3 ad bitmask_snprintf(st, LPCIB_SMB_HS_BITS, fbuf, sizeof(fbuf));
319 1.4.4.2 ad printf("%s: abort failed, status 0x%s\n",
320 1.4.4.2 ad sc->sc_dev.dv_xname, fbuf);
321 1.4.4.2 ad }
322 1.4.4.3 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS, st);
323 1.4.4.2 ad return (1);
324 1.4.4.2 ad }
325 1.4.4.2 ad
326 1.4.4.2 ad static int
327 1.4.4.2 ad ichsmb_intr(void *arg)
328 1.4.4.2 ad {
329 1.4.4.2 ad struct ichsmb_softc *sc = arg;
330 1.4.4.2 ad uint8_t st;
331 1.4.4.2 ad uint8_t *b;
332 1.4.4.2 ad size_t len;
333 1.4.4.2 ad #ifdef ICHIIC_DEBUG
334 1.4.4.2 ad char fbuf[64];
335 1.4.4.2 ad #endif
336 1.4.4.2 ad
337 1.4.4.2 ad /* Read status */
338 1.4.4.3 ad st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS);
339 1.4.4.3 ad if ((st & LPCIB_SMB_HS_BUSY) != 0 || (st & (LPCIB_SMB_HS_INTR |
340 1.4.4.3 ad LPCIB_SMB_HS_DEVERR | LPCIB_SMB_HS_BUSERR | LPCIB_SMB_HS_FAILED |
341 1.4.4.3 ad LPCIB_SMB_HS_SMBAL | LPCIB_SMB_HS_BDONE)) == 0)
342 1.4.4.2 ad /* Interrupt was not for us */
343 1.4.4.2 ad return (0);
344 1.4.4.2 ad
345 1.4.4.2 ad #ifdef ICHIIC_DEBUG
346 1.4.4.3 ad bitmask_snprintf(st, LPCIB_SMB_HS_BITS, fbuf, sizeof(fbuf));
347 1.4.4.2 ad printf("%s: intr st 0x%s\n", sc->sc_dev.dv_xname, fbuf);
348 1.4.4.2 ad #endif
349 1.4.4.2 ad
350 1.4.4.2 ad /* Clear status bits */
351 1.4.4.3 ad bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS, st);
352 1.4.4.2 ad
353 1.4.4.2 ad /* Check for errors */
354 1.4.4.3 ad if (st & (LPCIB_SMB_HS_DEVERR | LPCIB_SMB_HS_BUSERR | LPCIB_SMB_HS_FAILED)) {
355 1.4.4.2 ad sc->sc_i2c_xfer.error = 1;
356 1.4.4.2 ad goto done;
357 1.4.4.2 ad }
358 1.4.4.2 ad
359 1.4.4.3 ad if (st & LPCIB_SMB_HS_INTR) {
360 1.4.4.2 ad if (I2C_OP_WRITE_P(sc->sc_i2c_xfer.op))
361 1.4.4.2 ad goto done;
362 1.4.4.2 ad
363 1.4.4.2 ad /* Read data */
364 1.4.4.2 ad b = sc->sc_i2c_xfer.buf;
365 1.4.4.2 ad len = sc->sc_i2c_xfer.len;
366 1.4.4.2 ad if (len > 0)
367 1.4.4.2 ad b[0] = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
368 1.4.4.3 ad LPCIB_SMB_HD0);
369 1.4.4.2 ad if (len > 1)
370 1.4.4.2 ad b[1] = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
371 1.4.4.3 ad LPCIB_SMB_HD1);
372 1.4.4.2 ad }
373 1.4.4.2 ad
374 1.4.4.2 ad done:
375 1.4.4.2 ad if ((sc->sc_i2c_xfer.flags & I2C_F_POLL) == 0)
376 1.4.4.2 ad wakeup(sc);
377 1.4.4.2 ad return (1);
378 1.4.4.2 ad }
379