blob: ffe619866f920e5e2f807e80321b9649f88a03e2 [file] [log] [blame]
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05001/*
2 * Copyright (c) 2013 Google Inc.
3 *
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05004 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but without any warranty; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050013 */
14
15/* This file is derived from the flashrom project. */
16#include <stdint.h>
17#include <stdlib.h>
18#include <string.h>
David Hendricksf2612a12014-04-13 16:27:02 -070019#include <bootstate.h>
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050020#include <delay.h>
21#include <arch/io.h>
22#include <console/console.h>
23#include <device/pci_ids.h>
24#include <spi_flash.h>
25
Julius Werner18ea2d32014-10-07 16:42:17 -070026#include <soc/lpc.h>
27#include <soc/pci_devs.h>
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050028
29#ifdef __SMM__
30#define pci_read_config_byte(dev, reg, targ)\
31 *(targ) = pci_read_config8(dev, reg)
32#define pci_read_config_word(dev, reg, targ)\
33 *(targ) = pci_read_config16(dev, reg)
34#define pci_read_config_dword(dev, reg, targ)\
35 *(targ) = pci_read_config32(dev, reg)
36#define pci_write_config_byte(dev, reg, val)\
37 pci_write_config8(dev, reg, val)
38#define pci_write_config_word(dev, reg, val)\
39 pci_write_config16(dev, reg, val)
40#define pci_write_config_dword(dev, reg, val)\
41 pci_write_config32(dev, reg, val)
42#else /* !__SMM__ */
43#include <device/device.h>
44#include <device/pci.h>
45#define pci_read_config_byte(dev, reg, targ)\
46 *(targ) = pci_read_config8(dev, reg)
47#define pci_read_config_word(dev, reg, targ)\
48 *(targ) = pci_read_config16(dev, reg)
49#define pci_read_config_dword(dev, reg, targ)\
50 *(targ) = pci_read_config32(dev, reg)
51#define pci_write_config_byte(dev, reg, val)\
52 pci_write_config8(dev, reg, val)
53#define pci_write_config_word(dev, reg, val)\
54 pci_write_config16(dev, reg, val)
55#define pci_write_config_dword(dev, reg, val)\
56 pci_write_config32(dev, reg, val)
57#endif /* !__SMM__ */
58
59typedef struct spi_slave ich_spi_slave;
60
61static int ichspi_lock = 0;
62
63typedef struct ich9_spi_regs {
64 uint32_t bfpr;
65 uint16_t hsfs;
66 uint16_t hsfc;
67 uint32_t faddr;
68 uint32_t _reserved0;
69 uint32_t fdata[16];
70 uint32_t frap;
71 uint32_t freg[5];
72 uint32_t _reserved1[3];
73 uint32_t pr[5];
74 uint32_t _reserved2[2];
75 uint8_t ssfs;
76 uint8_t ssfc[3];
77 uint16_t preop;
78 uint16_t optype;
79 uint8_t opmenu[8];
80 uint32_t bbar;
81 uint8_t _reserved3[12];
82 uint32_t fdoc;
83 uint32_t fdod;
84 uint8_t _reserved4[8];
85 uint32_t afc;
86 uint32_t lvscc;
87 uint32_t uvscc;
88 uint8_t _reserved5[4];
89 uint32_t fpb;
90 uint8_t _reserved6[28];
91 uint32_t srdl;
92 uint32_t srdc;
93 uint32_t srd;
94} __attribute__((packed)) ich9_spi_regs;
95
96typedef struct ich_spi_controller {
97 int locked;
98
99 uint8_t *opmenu;
100 int menubytes;
101 uint16_t *preop;
102 uint16_t *optype;
103 uint32_t *addr;
104 uint8_t *data;
105 unsigned databytes;
106 uint8_t *status;
107 uint16_t *control;
108 uint32_t *bbar;
109} ich_spi_controller;
110
111static ich_spi_controller cntlr;
112
113enum {
114 SPIS_SCIP = 0x0001,
115 SPIS_GRANT = 0x0002,
116 SPIS_CDS = 0x0004,
117 SPIS_FCERR = 0x0008,
118 SSFS_AEL = 0x0010,
119 SPIS_LOCK = 0x8000,
120 SPIS_RESERVED_MASK = 0x7ff0,
121 SSFS_RESERVED_MASK = 0x7fe2
122};
123
124enum {
125 SPIC_SCGO = 0x000002,
126 SPIC_ACS = 0x000004,
127 SPIC_SPOP = 0x000008,
128 SPIC_DBC = 0x003f00,
129 SPIC_DS = 0x004000,
130 SPIC_SME = 0x008000,
131 SSFC_SCF_MASK = 0x070000,
132 SSFC_RESERVED = 0xf80000
133};
134
135enum {
136 HSFS_FDONE = 0x0001,
137 HSFS_FCERR = 0x0002,
138 HSFS_AEL = 0x0004,
139 HSFS_BERASE_MASK = 0x0018,
140 HSFS_BERASE_SHIFT = 3,
141 HSFS_SCIP = 0x0020,
142 HSFS_FDOPSS = 0x2000,
143 HSFS_FDV = 0x4000,
144 HSFS_FLOCKDN = 0x8000
145};
146
147enum {
148 HSFC_FGO = 0x0001,
149 HSFC_FCYCLE_MASK = 0x0006,
150 HSFC_FCYCLE_SHIFT = 1,
151 HSFC_FDBC_MASK = 0x3f00,
152 HSFC_FDBC_SHIFT = 8,
153 HSFC_FSMIE = 0x8000
154};
155
156enum {
157 SPI_OPCODE_TYPE_READ_NO_ADDRESS = 0,
158 SPI_OPCODE_TYPE_WRITE_NO_ADDRESS = 1,
159 SPI_OPCODE_TYPE_READ_WITH_ADDRESS = 2,
160 SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS = 3
161};
162
163#if CONFIG_DEBUG_SPI_FLASH
164
165static u8 readb_(const void *addr)
166{
167 u8 v = read8((unsigned long)addr);
168 printk(BIOS_DEBUG, "read %2.2x from %4.4x\n",
169 v, ((unsigned) addr & 0xffff) - 0xf020);
170 return v;
171}
172
173static u16 readw_(const void *addr)
174{
175 u16 v = read16((unsigned long)addr);
176 printk(BIOS_DEBUG, "read %4.4x from %4.4x\n",
177 v, ((unsigned) addr & 0xffff) - 0xf020);
178 return v;
179}
180
181static u32 readl_(const void *addr)
182{
183 u32 v = read32((unsigned long)addr);
184 printk(BIOS_DEBUG, "read %8.8x from %4.4x\n",
185 v, ((unsigned) addr & 0xffff) - 0xf020);
186 return v;
187}
188
189static void writeb_(u8 b, const void *addr)
190{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800191 write8(addr, b);
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500192 printk(BIOS_DEBUG, "wrote %2.2x to %4.4x\n",
193 b, ((unsigned) addr & 0xffff) - 0xf020);
194}
195
196static void writew_(u16 b, const void *addr)
197{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800198 write16(addr, b);
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500199 printk(BIOS_DEBUG, "wrote %4.4x to %4.4x\n",
200 b, ((unsigned) addr & 0xffff) - 0xf020);
201}
202
203static void writel_(u32 b, const void *addr)
204{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800205 write32(addr, b);
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500206 printk(BIOS_DEBUG, "wrote %8.8x to %4.4x\n",
207 b, ((unsigned) addr & 0xffff) - 0xf020);
208}
209
210#else /* CONFIG_DEBUG_SPI_FLASH ^^^ enabled vvv NOT enabled */
211
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800212#define readb_(a) read8(a)
213#define readw_(a) read16(a)
214#define readl_(a) read32(a)
215#define writeb_(val, addr) write8(addr, val)
216#define writew_(val, addr) write16(addr, val)
217#define writel_(val, addr) write32(addr, val)
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500218
219#endif /* CONFIG_DEBUG_SPI_FLASH ^^^ NOT enabled */
220
221static void write_reg(const void *value, void *dest, uint32_t size)
222{
223 const uint8_t *bvalue = value;
224 uint8_t *bdest = dest;
225
226 while (size >= 4) {
227 writel_(*(const uint32_t *)bvalue, bdest);
228 bdest += 4; bvalue += 4; size -= 4;
229 }
230 while (size) {
231 writeb_(*bvalue, bdest);
232 bdest++; bvalue++; size--;
233 }
234}
235
236static void read_reg(const void *src, void *value, uint32_t size)
237{
238 const uint8_t *bsrc = src;
239 uint8_t *bvalue = value;
240
241 while (size >= 4) {
242 *(uint32_t *)bvalue = readl_(bsrc);
243 bsrc += 4; bvalue += 4; size -= 4;
244 }
245 while (size) {
246 *bvalue = readb_(bsrc);
247 bsrc++; bvalue++; size--;
248 }
249}
250
251static void ich_set_bbar(uint32_t minaddr)
252{
253 const uint32_t bbar_mask = 0x00ffff00;
254 uint32_t ichspi_bbar;
255
256 minaddr &= bbar_mask;
257 ichspi_bbar = readl_(cntlr.bbar) & ~bbar_mask;
258 ichspi_bbar |= minaddr;
259 writel_(ichspi_bbar, cntlr.bbar);
260}
261
Gabe Black1e187352014-03-27 20:37:03 -0700262struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500263{
264 ich_spi_slave *slave = malloc(sizeof(*slave));
265
266 if (!slave) {
267 printk(BIOS_DEBUG, "ICH SPI: Bad allocation\n");
268 return NULL;
269 }
270
271 memset(slave, 0, sizeof(*slave));
272
273 slave->bus = bus;
274 slave->cs = cs;
275 return slave;
276}
277
278static ich9_spi_regs *spi_regs(void)
279{
280 device_t dev;
281 uint32_t sbase;
282
283#ifdef __SMM__
284 dev = PCI_DEV(0, LPC_DEV, LPC_FUNC);
285#else
286 dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
287#endif
288 pci_read_config_dword(dev, SBASE, &sbase);
289 sbase &= ~0x1ff;
290
291 return (void *)sbase;
292}
293
294void spi_init(void)
295{
296 ich9_spi_regs *ich9_spi = spi_regs();
297
298 ichspi_lock = readw_(&ich9_spi->hsfs) & HSFS_FLOCKDN;
299 cntlr.opmenu = ich9_spi->opmenu;
300 cntlr.menubytes = sizeof(ich9_spi->opmenu);
301 cntlr.optype = &ich9_spi->optype;
302 cntlr.addr = &ich9_spi->faddr;
303 cntlr.data = (uint8_t *)ich9_spi->fdata;
304 cntlr.databytes = sizeof(ich9_spi->fdata);
305 cntlr.status = &ich9_spi->ssfs;
306 cntlr.control = (uint16_t *)ich9_spi->ssfc;
307 cntlr.bbar = &ich9_spi->bbar;
308 cntlr.preop = &ich9_spi->preop;
309 ich_set_bbar(0);
310}
311
David Hendricksf2612a12014-04-13 16:27:02 -0700312static void spi_init_cb(void *unused)
313{
314 spi_init();
315}
316
Aaron Durbin9ef9d852015-03-16 17:30:09 -0500317BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
David Hendricksf2612a12014-04-13 16:27:02 -0700318
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500319int spi_claim_bus(struct spi_slave *slave)
320{
321 /* Handled by ICH automatically. */
322 return 0;
323}
324
325void spi_release_bus(struct spi_slave *slave)
326{
327 /* Handled by ICH automatically. */
328}
329
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500330typedef struct spi_transaction {
331 const uint8_t *out;
332 uint32_t bytesout;
333 uint8_t *in;
334 uint32_t bytesin;
335 uint8_t type;
336 uint8_t opcode;
337 uint32_t offset;
338} spi_transaction;
339
340static inline void spi_use_out(spi_transaction *trans, unsigned bytes)
341{
342 trans->out += bytes;
343 trans->bytesout -= bytes;
344}
345
346static inline void spi_use_in(spi_transaction *trans, unsigned bytes)
347{
348 trans->in += bytes;
349 trans->bytesin -= bytes;
350}
351
352static void spi_setup_type(spi_transaction *trans)
353{
354 trans->type = 0xFF;
355
356 /* Try to guess spi type from read/write sizes. */
357 if (trans->bytesin == 0) {
358 if (trans->bytesout > 4)
359 /*
360 * If bytesin = 0 and bytesout > 4, we presume this is
361 * a write data operation, which is accompanied by an
362 * address.
363 */
364 trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS;
365 else
366 trans->type = SPI_OPCODE_TYPE_WRITE_NO_ADDRESS;
367 return;
368 }
369
370 if (trans->bytesout == 1) { /* and bytesin is > 0 */
371 trans->type = SPI_OPCODE_TYPE_READ_NO_ADDRESS;
372 return;
373 }
374
375 if (trans->bytesout == 4) { /* and bytesin is > 0 */
376 trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS;
377 }
378
379 /* Fast read command is called with 5 bytes instead of 4 */
380 if (trans->out[0] == SPI_OPCODE_FAST_READ && trans->bytesout == 5) {
381 trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS;
382 --trans->bytesout;
383 }
384}
385
386static int spi_setup_opcode(spi_transaction *trans)
387{
388 uint16_t optypes;
389 uint8_t opmenu[cntlr.menubytes];
390
391 trans->opcode = trans->out[0];
392 spi_use_out(trans, 1);
393 if (!ichspi_lock) {
394 /* The lock is off, so just use index 0. */
395 writeb_(trans->opcode, cntlr.opmenu);
396 optypes = readw_(cntlr.optype);
397 optypes = (optypes & 0xfffc) | (trans->type & 0x3);
398 writew_(optypes, cntlr.optype);
399 return 0;
400 } else {
401 /* The lock is on. See if what we need is on the menu. */
402 uint8_t optype;
403 uint16_t opcode_index;
404
405 /* Write Enable is handled as atomic prefix */
406 if (trans->opcode == SPI_OPCODE_WREN)
407 return 0;
408
409 read_reg(cntlr.opmenu, opmenu, sizeof(opmenu));
410 for (opcode_index = 0; opcode_index < cntlr.menubytes;
411 opcode_index++) {
412 if (opmenu[opcode_index] == trans->opcode)
413 break;
414 }
415
416 if (opcode_index == cntlr.menubytes) {
417 printk(BIOS_DEBUG, "ICH SPI: Opcode %x not found\n",
418 trans->opcode);
419 return -1;
420 }
421
422 optypes = readw_(cntlr.optype);
423 optype = (optypes >> (opcode_index * 2)) & 0x3;
424 if (trans->type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS &&
425 optype == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS &&
426 trans->bytesout >= 3) {
427 /* We guessed wrong earlier. Fix it up. */
428 trans->type = optype;
429 }
430 if (optype != trans->type) {
431 printk(BIOS_DEBUG, "ICH SPI: Transaction doesn't fit type %d\n",
432 optype);
433 return -1;
434 }
435 return opcode_index;
436 }
437}
438
439static int spi_setup_offset(spi_transaction *trans)
440{
441 /* Separate the SPI address and data. */
442 switch (trans->type) {
443 case SPI_OPCODE_TYPE_READ_NO_ADDRESS:
444 case SPI_OPCODE_TYPE_WRITE_NO_ADDRESS:
445 return 0;
446 case SPI_OPCODE_TYPE_READ_WITH_ADDRESS:
447 case SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS:
448 trans->offset = ((uint32_t)trans->out[0] << 16) |
449 ((uint32_t)trans->out[1] << 8) |
450 ((uint32_t)trans->out[2] << 0);
451 spi_use_out(trans, 3);
452 return 1;
453 default:
454 printk(BIOS_DEBUG, "Unrecognized SPI transaction type %#x\n", trans->type);
455 return -1;
456 }
457}
458
459/*
460 * Wait for up to 60ms til status register bit(s) turn 1 (in case wait_til_set
461 * below is True) or 0. In case the wait was for the bit(s) to set - write
462 * those bits back, which would cause resetting them.
463 *
464 * Return the last read status value on success or -1 on failure.
465 */
466static int ich_status_poll(u16 bitmask, int wait_til_set)
467{
Aaron Durbin4177db52014-02-05 14:55:26 -0600468 int timeout = 40000; /* This will result in 400 ms */
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500469 u16 status = 0;
470
471 while (timeout--) {
472 status = readw_(cntlr.status);
473 if (wait_til_set ^ ((status & bitmask) == 0)) {
474 if (wait_til_set)
475 writew_((status & bitmask), cntlr.status);
476 return status;
477 }
478 udelay(10);
479 }
480
481 printk(BIOS_DEBUG, "ICH SPI: SCIP timeout, read %x, expected %x\n",
482 status, bitmask);
483 return -1;
484}
485
Kyösti Mälkki11104952014-06-29 16:17:33 +0300486unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
487{
488 return min(cntlr.databytes, buf_len);
489}
490
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500491int spi_xfer(struct spi_slave *slave, const void *dout,
Gabe Black93d9f922014-03-27 21:52:43 -0700492 unsigned int bytesout, void *din, unsigned int bytesin)
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500493{
494 uint16_t control;
495 int16_t opcode_index;
496 int with_address;
497 int status;
498
499 spi_transaction trans = {
Gabe Black93d9f922014-03-27 21:52:43 -0700500 dout, bytesout,
501 din, bytesin,
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500502 0xff, 0xff, 0
503 };
504
505 /* There has to always at least be an opcode. */
Gabe Black93d9f922014-03-27 21:52:43 -0700506 if (!bytesout || !dout) {
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500507 printk(BIOS_DEBUG, "ICH SPI: No opcode for transfer\n");
508 return -1;
509 }
510 /* Make sure if we read something we have a place to put it. */
Gabe Black93d9f922014-03-27 21:52:43 -0700511 if (bytesin != 0 && !din) {
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500512 printk(BIOS_DEBUG, "ICH SPI: Read but no target buffer\n");
513 return -1;
514 }
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500515
516 if (ich_status_poll(SPIS_SCIP, 0) == -1)
517 return -1;
518
519 writew_(SPIS_CDS | SPIS_FCERR, cntlr.status);
520
521 spi_setup_type(&trans);
522 if ((opcode_index = spi_setup_opcode(&trans)) < 0)
523 return -1;
524 if ((with_address = spi_setup_offset(&trans)) < 0)
525 return -1;
526
527 if (trans.opcode == SPI_OPCODE_WREN) {
528 /*
529 * Treat Write Enable as Atomic Pre-Op if possible
530 * in order to prevent the Management Engine from
531 * issuing a transaction between WREN and DATA.
532 */
533 if (!ichspi_lock)
534 writew_(trans.opcode, cntlr.preop);
535 return 0;
536 }
537
538 /* Preset control fields */
539 control = SPIC_SCGO | ((opcode_index & 0x07) << 4);
540
541 /* Issue atomic preop cycle if needed */
542 if (readw_(cntlr.preop))
543 control |= SPIC_ACS;
544
545 if (!trans.bytesout && !trans.bytesin) {
546 /* SPI addresses are 24 bit only */
547 if (with_address)
548 writel_(trans.offset & 0x00FFFFFF, cntlr.addr);
549
550 /*
551 * This is a 'no data' command (like Write Enable), its
Martin Roth99a3bba2014-12-07 14:57:26 -0700552 * bytesout size was 1, decremented to zero while executing
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500553 * spi_setup_opcode() above. Tell the chip to send the
554 * command.
555 */
556 writew_(control, cntlr.control);
557
558 /* wait for the result */
559 status = ich_status_poll(SPIS_CDS | SPIS_FCERR, 1);
560 if (status == -1)
561 return -1;
562
563 if (status & SPIS_FCERR) {
564 printk(BIOS_DEBUG, "ICH SPI: Command transaction error\n");
565 return -1;
566 }
567
568 return 0;
569 }
570
571 /*
Martin Roth99a3bba2014-12-07 14:57:26 -0700572 * Check if this is a write command attempting to transfer more bytes
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500573 * than the controller can handle. Iterations for writes are not
574 * supported here because each SPI write command needs to be preceded
575 * and followed by other SPI commands, and this sequence is controlled
576 * by the SPI chip driver.
577 */
578 if (trans.bytesout > cntlr.databytes) {
579 printk(BIOS_DEBUG, "ICH SPI: Too much to write. Does your SPI chip driver use"
Kyösti Mälkki11104952014-06-29 16:17:33 +0300580 " spi_crop_chunk()?\n");
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -0500581 return -1;
582 }
583
584 /*
585 * Read or write up to databytes bytes at a time until everything has
586 * been sent.
587 */
588 while (trans.bytesout || trans.bytesin) {
589 uint32_t data_length;
590
591 /* SPI addresses are 24 bit only */
592 writel_(trans.offset & 0x00FFFFFF, cntlr.addr);
593
594 if (trans.bytesout)
595 data_length = min(trans.bytesout, cntlr.databytes);
596 else
597 data_length = min(trans.bytesin, cntlr.databytes);
598
599 /* Program data into FDATA0 to N */
600 if (trans.bytesout) {
601 write_reg(trans.out, cntlr.data, data_length);
602 spi_use_out(&trans, data_length);
603 if (with_address)
604 trans.offset += data_length;
605 }
606
607 /* Add proper control fields' values */
608 control &= ~((cntlr.databytes - 1) << 8);
609 control |= SPIC_DS;
610 control |= (data_length - 1) << 8;
611
612 /* write it */
613 writew_(control, cntlr.control);
614
615 /* Wait for Cycle Done Status or Flash Cycle Error. */
616 status = ich_status_poll(SPIS_CDS | SPIS_FCERR, 1);
617 if (status == -1)
618 return -1;
619
620 if (status & SPIS_FCERR) {
621 printk(BIOS_DEBUG, "ICH SPI: Data transaction error\n");
622 return -1;
623 }
624
625 if (trans.bytesin) {
626 read_reg(cntlr.data, trans.in, data_length);
627 spi_use_in(&trans, data_length);
628 if (with_address)
629 trans.offset += data_length;
630 }
631 }
632
633 /* Clear atomic preop now that xfer is done */
634 writew_(0, cntlr.preop);
635
636 return 0;
637}