Lines Matching full:trans

175 static inline void spi_use_out(struct spi_trans *trans, unsigned bytes)  in spi_use_out()  argument
177 trans->out += bytes; in spi_use_out()
178 trans->bytesout -= bytes; in spi_use_out()
181 static inline void spi_use_in(struct spi_trans *trans, unsigned bytes) in spi_use_in() argument
183 trans->in += bytes; in spi_use_in()
184 trans->bytesin -= bytes; in spi_use_in()
217 static void spi_setup_type(struct spi_trans *trans, int data_bytes) in spi_setup_type() argument
219 trans->type = 0xFF; in spi_setup_type()
222 if (trans->bytesin == 0) { in spi_setup_type()
223 if (trans->bytesout + data_bytes > 4) in spi_setup_type()
229 trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS; in spi_setup_type()
231 trans->type = SPI_OPCODE_TYPE_WRITE_NO_ADDRESS; in spi_setup_type()
235 if (trans->bytesout == 1) { /* and bytesin is > 0 */ in spi_setup_type()
236 trans->type = SPI_OPCODE_TYPE_READ_NO_ADDRESS; in spi_setup_type()
240 if (trans->bytesout == 4) /* and bytesin is > 0 */ in spi_setup_type()
241 trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS; in spi_setup_type()
244 if (trans->out[0] == SPI_OPCODE_FAST_READ && trans->bytesout == 5) { in spi_setup_type()
245 trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS; in spi_setup_type()
246 --trans->bytesout; in spi_setup_type()
250 static int spi_setup_opcode(struct ich_spi_priv *ctlr, struct spi_trans *trans, in spi_setup_opcode() argument
256 trans->opcode = trans->out[0]; in spi_setup_opcode()
257 spi_use_out(trans, 1); in spi_setup_opcode()
260 ich_writeb(ctlr, trans->opcode, ctlr->opmenu); in spi_setup_opcode()
262 optypes = (optypes & 0xfffc) | (trans->type & 0x3); in spi_setup_opcode()
271 if (trans->opcode == SPI_OPCODE_WREN) in spi_setup_opcode()
277 if (opmenu[opcode_index] == trans->opcode) in spi_setup_opcode()
283 trans->opcode); in spi_setup_opcode()
289 if (trans->type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS && in spi_setup_opcode()
291 trans->bytesout >= 3) { in spi_setup_opcode()
293 trans->type = optype; in spi_setup_opcode()
295 if (optype != trans->type) { in spi_setup_opcode()
304 static int spi_setup_offset(struct spi_trans *trans) in spi_setup_offset() argument
307 switch (trans->type) { in spi_setup_offset()
313 trans->offset = ((uint32_t)trans->out[0] << 16) | in spi_setup_offset()
314 ((uint32_t)trans->out[1] << 8) | in spi_setup_offset()
315 ((uint32_t)trans->out[2] << 0); in spi_setup_offset()
316 spi_use_out(trans, 3); in spi_setup_offset()
319 printf("Unrecognized SPI transaction type %#x\n", trans->type); in spi_setup_offset()
380 struct spi_trans *trans = &ctlr->trans; in ich_spi_xfer() local
397 memset(trans, '\0', sizeof(*trans)); in ich_spi_xfer()
405 memcpy(trans->cmd, dout, bytes); in ich_spi_xfer()
406 trans->cmd_len = bytes; in ich_spi_xfer()
418 if (trans->cmd_len) { in ich_spi_xfer()
419 trans->out = trans->cmd; in ich_spi_xfer()
420 trans->bytesout = trans->cmd_len; in ich_spi_xfer()
422 debug_trace("ICH SPI: Using %d bytes\n", trans->cmd_len); in ich_spi_xfer()
424 trans->out = dout; in ich_spi_xfer()
425 trans->bytesout = dout ? bytes : 0; in ich_spi_xfer()
428 trans->in = din; in ich_spi_xfer()
429 trans->bytesin = din ? bytes : 0; in ich_spi_xfer()
432 if (!trans->bytesout) { in ich_spi_xfer()
446 spi_setup_type(trans, using_cmd ? bytes : 0); in ich_spi_xfer()
447 opcode_index = spi_setup_opcode(ctlr, trans, lock); in ich_spi_xfer()
450 with_address = spi_setup_offset(trans); in ich_spi_xfer()
454 if (trans->opcode == SPI_OPCODE_WREN) { in ich_spi_xfer()
461 ich_writew(ctlr, trans->opcode, ctlr->preop); in ich_spi_xfer()
478 trans->out = dout; in ich_spi_xfer()
479 trans->bytesout = bytes; in ich_spi_xfer()
490 if (!trans->bytesout && !trans->bytesin) { in ich_spi_xfer()
493 ich_writel(ctlr, trans->offset & 0x00FFFFFF, in ich_spi_xfer()
524 if (trans->bytesout > ctlr->databytes) { in ich_spi_xfer()
533 while (trans->bytesout || trans->bytesin) { in ich_spi_xfer()
537 ich_writel(ctlr, trans->offset & 0x00FFFFFF, ctlr->addr); in ich_spi_xfer()
539 if (trans->bytesout) in ich_spi_xfer()
540 data_length = min(trans->bytesout, ctlr->databytes); in ich_spi_xfer()
542 data_length = min(trans->bytesin, ctlr->databytes); in ich_spi_xfer()
545 if (trans->bytesout) { in ich_spi_xfer()
546 write_reg(ctlr, trans->out, ctlr->data, data_length); in ich_spi_xfer()
547 spi_use_out(trans, data_length); in ich_spi_xfer()
549 trans->offset += data_length; in ich_spi_xfer()
570 if (trans->bytesin) { in ich_spi_xfer()
571 read_reg(ctlr, ctlr->data, trans->in, data_length); in ich_spi_xfer()
572 spi_use_in(trans, data_length); in ich_spi_xfer()
574 trans->offset += data_length; in ich_spi_xfer()