Merge tag 'ti-v2020.07-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-ti
[oweals/u-boot.git] / drivers / dma / ti / k3-udma.c
index a375854dcd3cd86fd3a0805d8ffe9cd59cf29b01..2ce16c8e27f16728a888ae7d1c2d087ee512742a 100644 (file)
@@ -7,12 +7,16 @@
 
 #include <common.h>
 #include <cpu_func.h>
+#include <log.h>
+#include <asm/cache.h>
 #include <asm/io.h>
 #include <asm/bitops.h>
 #include <malloc.h>
-#include <asm/dma-mapping.h>
+#include <linux/bitops.h>
+#include <linux/dma-mapping.h>
 #include <dm.h>
-#include <dm/device.h>
+#include <dm/device_compat.h>
+#include <dm/devres.h>
 #include <dm/read.h>
 #include <dm/of_access.h>
 #include <dma.h>
@@ -20,6 +24,7 @@
 #include <linux/delay.h>
 #include <dt-bindings/dma/k3-udma.h>
 #include <linux/bitmap.h>
+#include <linux/err.h>
 #include <linux/soc/ti/k3-navss-ringacc.h>
 #include <linux/soc/ti/cppi5.h>
 #include <linux/soc/ti/ti-udma.h>
@@ -936,7 +941,9 @@ static int udma_alloc_rchan_sci_req(struct udma_chan *uc)
 
        req.valid_params = TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID |
                        TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID |
-                       TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID;
+                       TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID |
+                       TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID |
+                       TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID;
        req.nav_id = tisci_rm->tisci_dev_id;
        req.index = uc->rchan->id;
        req.rx_chan_type = mode;
@@ -952,9 +959,6 @@ static int udma_alloc_rchan_sci_req(struct udma_chan *uc)
        if (uc->rflow->id != uc->rchan->id && uc->dir != DMA_MEM_TO_MEM) {
                req.flowid_start = uc->rflow->id;
                req.flowid_cnt = 1;
-               req.valid_params |=
-                       TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID |
-                       TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID;
        }
 
        ret = tisci_rm->tisci_udmap_ops->rx_ch_cfg(tisci_rm->tisci, &req);
@@ -1476,8 +1480,8 @@ static int *udma_prep_dma_memcpy(struct udma_chan *uc, dma_addr_t dest,
 
        cppi5_tr_csf_set(&tr_req[num_tr - 1].flags, CPPI5_TR_CSF_EOP);
 
-       flush_dcache_range((u64)tr_desc,
-                          ALIGN((u64)tr_desc + desc_size,
+       flush_dcache_range((unsigned long)tr_desc,
+                          ALIGN((unsigned long)tr_desc + desc_size,
                                 ARCH_DMA_MINALIGN));
 
        udma_push_to_ring(uc->tchan->t_ring, tr_desc);
@@ -1551,7 +1555,7 @@ static int udma_request(struct dma *dma)
        return 0;
 }
 
-static int udma_free(struct dma *dma)
+static int udma_rfree(struct dma *dma)
 {
        struct udma_dev *ud = dev_get_priv(dma->dev);
        struct udma_chan *uc;
@@ -1648,11 +1652,11 @@ static int udma_send(struct dma *dma, void *src, size_t len, void *metadata)
        cppi5_hdesc_set_pkttype(desc_tx, packet_data.pkt_type);
        cppi5_desc_set_tags_ids(&desc_tx->hdr, 0, packet_data.dest_tag);
 
-       flush_dcache_range((u64)dma_src,
-                          ALIGN((u64)dma_src + len,
+       flush_dcache_range((unsigned long)dma_src,
+                          ALIGN((unsigned long)dma_src + len,
                                 ARCH_DMA_MINALIGN));
-       flush_dcache_range((u64)desc_tx,
-                          ALIGN((u64)desc_tx + uc->hdesc_size,
+       flush_dcache_range((unsigned long)desc_tx,
+                          ALIGN((unsigned long)desc_tx + uc->hdesc_size,
                                 ARCH_DMA_MINALIGN));
 
        ret = udma_push_to_ring(uc->tchan->t_ring, uc->desc_tx);
@@ -1810,8 +1814,8 @@ int udma_prepare_rcv_buf(struct dma *dma, void *dst, size_t size)
        cppi5_hdesc_set_pktlen(desc_rx, size);
        cppi5_hdesc_attach_buf(desc_rx, dma_dst, size, dma_dst, size);
 
-       flush_dcache_range((u64)desc_rx,
-                          ALIGN((u64)desc_rx + uc->hdesc_size,
+       flush_dcache_range((unsigned long)desc_rx,
+                          ALIGN((unsigned long)desc_rx + uc->hdesc_size,
                                 ARCH_DMA_MINALIGN));
 
        udma_push_to_ring(uc->rchan->fd_ring, desc_rx);
@@ -1846,7 +1850,7 @@ static const struct dma_ops udma_ops = {
        .transfer       = udma_transfer,
        .of_xlate       = udma_of_xlate,
        .request        = udma_request,
-       .free           = udma_free,
+       .rfree          = udma_rfree,
        .enable         = udma_enable,
        .disable        = udma_disable,
        .send           = udma_send,