/* the qdma core needs scratch memory to be setup */
 static int mtk_init_fq_dma(struct mtk_eth *eth)
 {
+       const struct mtk_soc_data *soc = eth->soc;
        dma_addr_t phy_ring_tail;
        int cnt = MTK_DMA_SIZE;
        dma_addr_t dma_addr;
        int i;
 
        eth->scratch_ring = dma_alloc_coherent(eth->dma_dev,
-                                              cnt * sizeof(struct mtk_tx_dma),
+                                              cnt * soc->txrx.txd_size,
                                               ð->phy_scratch_ring,
                                               GFP_KERNEL);
        if (unlikely(!eth->scratch_ring))
                return -ENOMEM;
 
-       eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
-                                   GFP_KERNEL);
+       eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, GFP_KERNEL);
        if (unlikely(!eth->scratch_head))
                return -ENOMEM;
 
        if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
                return -ENOMEM;
 
-       phy_ring_tail = eth->phy_scratch_ring +
-                       (sizeof(struct mtk_tx_dma) * (cnt - 1));
+       phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt - 1);
 
        for (i = 0; i < cnt; i++) {
-               eth->scratch_ring[i].txd1 =
-                                       (dma_addr + (i * MTK_QDMA_PAGE_SIZE));
+               struct mtk_tx_dma *txd;
+
+               txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size;
+               txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE;
                if (i < cnt - 1)
-                       eth->scratch_ring[i].txd2 = (eth->phy_scratch_ring +
-                               ((i + 1) * sizeof(struct mtk_tx_dma)));
-               eth->scratch_ring[i].txd3 = TX_DMA_SDL(MTK_QDMA_PAGE_SIZE);
+                       txd->txd2 = eth->phy_scratch_ring +
+                                   (i + 1) * soc->txrx.txd_size;
+
+               txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE);
+               txd->txd4 = 0;
        }
 
        mtk_w32(eth, eth->phy_scratch_ring, MTK_QDMA_FQ_HEAD);
 
 static void mtk_dma_free(struct mtk_eth *eth)
 {
+       const struct mtk_soc_data *soc = eth->soc;
        int i;
 
        for (i = 0; i < MTK_MAC_COUNT; i++)
                        netdev_reset_queue(eth->netdev[i]);
        if (eth->scratch_ring) {
                dma_free_coherent(eth->dma_dev,
-                                 MTK_DMA_SIZE * sizeof(struct mtk_tx_dma),
-                                 eth->scratch_ring,
-                                 eth->phy_scratch_ring);
+                                 MTK_DMA_SIZE * soc->txrx.txd_size,
+                                 eth->scratch_ring, eth->phy_scratch_ring);
                eth->scratch_ring = NULL;
                eth->phy_scratch_ring = 0;
        }
        .hw_features = MTK_HW_FEATURES,
        .required_clks = MT7623_CLKS_BITMAP,
        .required_pctl = true,
+       .txrx = {
+               .txd_size = sizeof(struct mtk_tx_dma),
+       },
 };
 
 static const struct mtk_soc_data mt7621_data = {
        .required_clks = MT7621_CLKS_BITMAP,
        .required_pctl = false,
        .offload_version = 2,
+       .txrx = {
+               .txd_size = sizeof(struct mtk_tx_dma),
+       },
 };
 
 static const struct mtk_soc_data mt7622_data = {
        .required_clks = MT7622_CLKS_BITMAP,
        .required_pctl = false,
        .offload_version = 2,
+       .txrx = {
+               .txd_size = sizeof(struct mtk_tx_dma),
+       },
 };
 
 static const struct mtk_soc_data mt7623_data = {
        .required_clks = MT7623_CLKS_BITMAP,
        .required_pctl = true,
        .offload_version = 2,
+       .txrx = {
+               .txd_size = sizeof(struct mtk_tx_dma),
+       },
 };
 
 static const struct mtk_soc_data mt7629_data = {
        .hw_features = MTK_HW_FEATURES,
        .required_clks = MT7629_CLKS_BITMAP,
        .required_pctl = false,
+       .txrx = {
+               .txd_size = sizeof(struct mtk_tx_dma),
+       },
 };
 
 static const struct mtk_soc_data rt5350_data = {
        .hw_features = MTK_HW_FEATURES_MT7628,
        .required_clks = MT7628_CLKS_BITMAP,
        .required_pctl = false,
+       .txrx = {
+               .txd_size = sizeof(struct mtk_tx_dma),
+       },
 };
 
 const struct of_device_id of_mtk_match[] = {