mirror of https://gitee.com/openkylin/linux.git
greybus: spi: add inprogress bit to xfer_flags
When a SPI transfer needs to be split by more than one greybus spi transfer operation, we need to indicate it so the controller can handle the chip select lines correctly. Add a new bit to indicate it, GB_SPI_XFER_INPROGRESS, and create an helper function to calculate when the transfer is done. As we need this information also in other places. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
22e26a3a13
commit
3a238fc784
|
@ -879,6 +879,7 @@ struct gb_spi_transfer {
|
|||
__u8 xfer_flags;
|
||||
#define GB_SPI_XFER_READ 0x01
|
||||
#define GB_SPI_XFER_WRITE 0x02
|
||||
#define GB_SPI_XFER_INPROGRESS 0x04
|
||||
} __packed;
|
||||
|
||||
struct gb_spi_transfer_request {
|
||||
|
|
|
@ -102,6 +102,17 @@ static void clean_xfer_state(struct gb_spilib *spi)
|
|||
spi->op_timeout = 0;
|
||||
}
|
||||
|
||||
static bool is_last_xfer_done(struct gb_spilib *spi)
|
||||
{
|
||||
struct spi_transfer *last_xfer = spi->last_xfer;
|
||||
|
||||
if ((spi->tx_xfer_offset + spi->last_xfer_size == last_xfer->len) ||
|
||||
(spi->rx_xfer_offset + spi->last_xfer_size == last_xfer->len))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int setup_next_xfer(struct gb_spilib *spi, struct spi_message *msg)
|
||||
{
|
||||
struct spi_transfer *last_xfer = spi->last_xfer;
|
||||
|
@ -113,8 +124,7 @@ static int setup_next_xfer(struct gb_spilib *spi, struct spi_message *msg)
|
|||
* if we transferred all content of the last transfer, reset values and
|
||||
* check if this was the last transfer in the message
|
||||
*/
|
||||
if ((spi->tx_xfer_offset + spi->last_xfer_size == last_xfer->len) ||
|
||||
(spi->rx_xfer_offset + spi->last_xfer_size == last_xfer->len)) {
|
||||
if (is_last_xfer_done(spi)) {
|
||||
spi->tx_xfer_offset = 0;
|
||||
spi->rx_xfer_offset = 0;
|
||||
spi->op_timeout = 0;
|
||||
|
@ -265,6 +275,8 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,
|
|||
gb_xfer->xfer_flags |= GB_SPI_XFER_READ;
|
||||
|
||||
if (xfer == spi->last_xfer) {
|
||||
if (!is_last_xfer_done(spi))
|
||||
gb_xfer->xfer_flags |= GB_SPI_XFER_INPROGRESS;
|
||||
msg->state = GB_SPI_STATE_OP_DONE;
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue