|
18 | 18 | #include "../virt-dma.h"
|
19 | 19 |
|
20 | 20 | #define TRE_TYPE_DMA 0x10
|
| 21 | +#define TRE_TYPE_IMMEDIATE_DMA 0x11 |
21 | 22 | #define TRE_TYPE_GO 0x20
|
22 | 23 | #define TRE_TYPE_CONFIG0 0x22
|
23 | 24 |
|
|
64 | 65 |
|
65 | 66 | /* DMA TRE */
|
66 | 67 | #define TRE_DMA_LEN GENMASK(23, 0)
|
| 68 | +#define TRE_DMA_IMMEDIATE_LEN GENMASK(3, 0) |
67 | 69 |
|
68 | 70 | /* Register offsets from gpi-top */
|
69 | 71 | #define GPII_n_CH_k_CNTXT_0_OFFS(n, k) (0x20000 + (0x4000 * (n)) + (0x80 * (k)))
|
@@ -1711,6 +1713,7 @@ static int gpi_create_spi_tre(struct gchan *chan, struct gpi_desc *desc,
|
1711 | 1713 | dma_addr_t address;
|
1712 | 1714 | struct gpi_tre *tre;
|
1713 | 1715 | unsigned int i;
|
| 1716 | + int len; |
1714 | 1717 |
|
1715 | 1718 | /* first create config tre if applicable */
|
1716 | 1719 | if (direction == DMA_MEM_TO_DEV && spi->set_config) {
|
@@ -1763,14 +1766,30 @@ static int gpi_create_spi_tre(struct gchan *chan, struct gpi_desc *desc,
|
1763 | 1766 | tre_idx++;
|
1764 | 1767 |
|
1765 | 1768 | address = sg_dma_address(sgl);
|
1766 |
| - tre->dword[0] = lower_32_bits(address); |
1767 |
| - tre->dword[1] = upper_32_bits(address); |
| 1769 | + len = sg_dma_len(sgl); |
1768 | 1770 |
|
1769 |
| - tre->dword[2] = u32_encode_bits(sg_dma_len(sgl), TRE_DMA_LEN); |
| 1771 | + /* Support Immediate dma for write transfers for data length up to 8 bytes */ |
| 1772 | + if (direction == DMA_MEM_TO_DEV && len <= 2 * sizeof(tre->dword[0])) { |
| 1773 | + /* |
| 1774 | + * For Immediate dma, data length may not always be length of 8 bytes, |
| 1775 | + * it can be length less than 8, hence initialize both dword's with 0 |
| 1776 | + */ |
| 1777 | + tre->dword[0] = 0; |
| 1778 | + tre->dword[1] = 0; |
| 1779 | + memcpy(&tre->dword[0], sg_virt(sgl), len); |
1770 | 1780 |
|
1771 |
| - tre->dword[3] = u32_encode_bits(TRE_TYPE_DMA, TRE_FLAGS_TYPE); |
1772 |
| - if (direction == DMA_MEM_TO_DEV) |
1773 |
| - tre->dword[3] |= u32_encode_bits(1, TRE_FLAGS_IEOT); |
| 1781 | + tre->dword[2] = u32_encode_bits(len, TRE_DMA_IMMEDIATE_LEN); |
| 1782 | + tre->dword[3] = u32_encode_bits(TRE_TYPE_IMMEDIATE_DMA, TRE_FLAGS_TYPE); |
| 1783 | + } else { |
| 1784 | + tre->dword[0] = lower_32_bits(address); |
| 1785 | + tre->dword[1] = upper_32_bits(address); |
| 1786 | + |
| 1787 | + tre->dword[2] = u32_encode_bits(len, TRE_DMA_LEN); |
| 1788 | + tre->dword[3] = u32_encode_bits(TRE_TYPE_DMA, TRE_FLAGS_TYPE); |
| 1789 | + } |
| 1790 | + |
| 1791 | + tre->dword[3] |= u32_encode_bits(direction == DMA_MEM_TO_DEV, |
| 1792 | + TRE_FLAGS_IEOT); |
1774 | 1793 |
|
1775 | 1794 | for (i = 0; i < tre_idx; i++)
|
1776 | 1795 | dev_dbg(dev, "TRE:%d %x:%x:%x:%x\n", i, desc->tre[i].dword[0],
|
|
0 commit comments