|
82 | 82 | #define GQSPI_GENFIFO_RX 0x00020000 |
83 | 83 | #define GQSPI_GENFIFO_STRIPE 0x00040000 |
84 | 84 | #define GQSPI_GENFIFO_POLL 0x00080000 |
85 | | -#define GQSPI_GENFIFO_EXP_START 0x00000100 |
86 | 85 | #define GQSPI_FIFO_CTRL_RST_RX_FIFO_MASK 0x00000004 |
87 | 86 | #define GQSPI_FIFO_CTRL_RST_TX_FIFO_MASK 0x00000002 |
88 | 87 | #define GQSPI_FIFO_CTRL_RST_GEN_FIFO_MASK 0x00000001 |
@@ -672,71 +671,50 @@ static void zynqmp_qspi_readrxfifo(struct zynqmp_qspi *xqspi, u32 size) |
672 | 671 | static void zynqmp_qspi_fillgenfifo(struct zynqmp_qspi *xqspi, u8 nbits, |
673 | 672 | u32 genfifoentry) |
674 | 673 | { |
675 | | - u32 transfer_len = 0; |
| 674 | + u32 transfer_len, tempcount, exponent; |
| 675 | + u8 imm_data; |
676 | 676 |
|
677 | | - if (xqspi->txbuf) { |
678 | | - genfifoentry &= ~GQSPI_GENFIFO_RX; |
679 | | - genfifoentry |= GQSPI_GENFIFO_DATA_XFER; |
680 | | - genfifoentry |= GQSPI_GENFIFO_TX; |
681 | | - transfer_len = xqspi->bytes_to_transfer; |
682 | | - } else if (xqspi->rxbuf) { |
683 | | - genfifoentry &= ~GQSPI_GENFIFO_TX; |
684 | | - genfifoentry |= GQSPI_GENFIFO_DATA_XFER; |
| 677 | + genfifoentry |= GQSPI_GENFIFO_DATA_XFER; |
| 678 | + if (xqspi->rxbuf) { |
685 | 679 | genfifoentry |= GQSPI_GENFIFO_RX; |
686 | 680 | if (xqspi->mode == GQSPI_MODE_DMA) |
687 | 681 | transfer_len = xqspi->dma_rx_bytes; |
688 | 682 | else |
689 | 683 | transfer_len = xqspi->bytes_to_receive; |
690 | 684 | } else { |
691 | | - /* Sending dummy circles here */ |
692 | | - genfifoentry &= ~(GQSPI_GENFIFO_TX | GQSPI_GENFIFO_RX); |
693 | | - genfifoentry |= GQSPI_GENFIFO_DATA_XFER; |
694 | 685 | transfer_len = xqspi->bytes_to_transfer; |
695 | 686 | } |
| 687 | + |
| 688 | + if (xqspi->txbuf) |
| 689 | + genfifoentry |= GQSPI_GENFIFO_TX; |
| 690 | + |
696 | 691 | genfifoentry |= zynqmp_qspi_selectspimode(xqspi, nbits); |
697 | 692 | xqspi->genfifoentry = genfifoentry; |
698 | 693 | dev_dbg(xqspi->dev, "genfifo %05x transfer_len %u\n", |
699 | 694 | genfifoentry, transfer_len); |
700 | 695 |
|
701 | | - if ((transfer_len) < GQSPI_GENFIFO_IMM_DATA_MASK) { |
702 | | - genfifoentry &= ~GQSPI_GENFIFO_IMM_DATA_MASK; |
703 | | - genfifoentry |= transfer_len; |
704 | | - zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, genfifoentry); |
705 | | - } else { |
706 | | - int tempcount = transfer_len; |
707 | | - u32 exponent = 8; /* 2^8 = 256 */ |
708 | | - u8 imm_data = tempcount & 0xFF; |
709 | | - |
710 | | - tempcount &= ~(tempcount & 0xFF); |
711 | | - /* Immediate entry */ |
712 | | - if (tempcount != 0) { |
713 | | - /* Exponent entries */ |
714 | | - genfifoentry |= GQSPI_GENFIFO_EXP; |
715 | | - while (tempcount != 0) { |
716 | | - if (tempcount & GQSPI_GENFIFO_EXP_START) { |
717 | | - genfifoentry &= |
718 | | - ~GQSPI_GENFIFO_IMM_DATA_MASK; |
719 | | - genfifoentry |= exponent; |
720 | | - zynqmp_gqspi_write(xqspi, |
721 | | - GQSPI_GEN_FIFO_OFST, |
722 | | - genfifoentry); |
723 | | - } |
724 | | - tempcount = tempcount >> 1; |
725 | | - exponent++; |
726 | | - } |
727 | | - } |
728 | | - if (imm_data != 0) { |
729 | | - genfifoentry &= ~GQSPI_GENFIFO_EXP; |
730 | | - genfifoentry &= ~GQSPI_GENFIFO_IMM_DATA_MASK; |
731 | | - genfifoentry |= (u8)(imm_data & 0xFF); |
| 696 | + /* Exponent entries */ |
| 697 | + imm_data = transfer_len; |
| 698 | + tempcount = transfer_len >> 8; |
| 699 | + exponent = 8; |
| 700 | + genfifoentry |= GQSPI_GENFIFO_EXP; |
| 701 | + while (tempcount) { |
| 702 | + if (tempcount & 1) |
732 | 703 | zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, |
733 | | - genfifoentry); |
734 | | - } |
735 | | - } |
736 | | - if (xqspi->mode == GQSPI_MODE_IO && xqspi->rxbuf) { |
737 | | - /* Dummy generic FIFO entry */ |
738 | | - zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, 0x0); |
| 704 | + genfifoentry | exponent); |
| 705 | + tempcount >>= 1; |
| 706 | + exponent++; |
739 | 707 | } |
| 708 | + |
| 709 | + /* Immediate entry */ |
| 710 | + genfifoentry &= ~GQSPI_GENFIFO_EXP; |
| 711 | + if (imm_data) |
| 712 | + zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, |
| 713 | + genfifoentry | imm_data); |
| 714 | + |
| 715 | + /* Dummy generic FIFO entry */ |
| 716 | + if (xqspi->mode == GQSPI_MODE_IO && xqspi->rxbuf) |
| 717 | + zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, 0); |
740 | 718 | } |
741 | 719 |
|
742 | 720 | /** |
|
0 commit comments