summaryrefslogtreecommitdiff
path: root/drivers/dma/mediatek/mtk-uart-apdma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dma/mediatek/mtk-uart-apdma.c')
-rw-r--r--drivers/dma/mediatek/mtk-uart-apdma.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
index 08e15177427b..3b9761f4e8a1 100644
--- a/drivers/dma/mediatek/mtk-uart-apdma.c
+++ b/drivers/dma/mediatek/mtk-uart-apdma.c
@@ -41,7 +41,7 @@
#define VFF_STOP_CLR_B 0
#define VFF_EN_CLR_B 0
#define VFF_INT_EN_CLR_B 0
-#define VFF_4G_SUPPORT_CLR_B 0
+#define VFF_ADDR2_CLR_B 0
/*
* interrupt trigger level for tx
@@ -72,12 +72,12 @@
/* TX: the buffer size SW can write. RX: the buffer size HW can write. */
#define VFF_LEFT_SIZE 0x40
#define VFF_DEBUG_STATUS 0x50
-#define VFF_4G_SUPPORT 0x54
+#define VFF_ADDR2 0x54
struct mtk_uart_apdmadev {
struct dma_device ddev;
struct clk *clk;
- bool support_33bits;
+ bool support_ext_addr;
unsigned int dma_requests;
};
@@ -148,8 +148,8 @@ static void mtk_uart_apdma_start_tx(struct mtk_chan *c)
mtk_uart_apdma_write(c, VFF_WPT, 0);
mtk_uart_apdma_write(c, VFF_INT_FLAG, VFF_TX_INT_CLR_B);
- if (mtkd->support_33bits)
- mtk_uart_apdma_write(c, VFF_4G_SUPPORT, VFF_4G_EN_B);
+ if (mtkd->support_ext_addr)
+ mtk_uart_apdma_write(c, VFF_ADDR2, upper_32_bits(d->addr));
}
mtk_uart_apdma_write(c, VFF_EN, VFF_EN_B);
@@ -191,8 +191,8 @@ static void mtk_uart_apdma_start_rx(struct mtk_chan *c)
mtk_uart_apdma_write(c, VFF_RPT, 0);
mtk_uart_apdma_write(c, VFF_INT_FLAG, VFF_RX_INT_CLR_B);
- if (mtkd->support_33bits)
- mtk_uart_apdma_write(c, VFF_4G_SUPPORT, VFF_4G_EN_B);
+ if (mtkd->support_ext_addr)
+ mtk_uart_apdma_write(c, VFF_ADDR2, upper_32_bits(d->addr));
}
mtk_uart_apdma_write(c, VFF_INT_EN, VFF_RX_INT_EN_B);
@@ -297,8 +297,8 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan)
goto err_pm;
}
- if (mtkd->support_33bits)
- mtk_uart_apdma_write(c, VFF_4G_SUPPORT, VFF_4G_SUPPORT_CLR_B);
+ if (mtkd->support_ext_addr)
+ mtk_uart_apdma_write(c, VFF_ADDR2, VFF_ADDR2_CLR_B);
err_pm:
pm_runtime_put_noidle(mtkd->ddev.dev);
@@ -468,7 +468,10 @@ static void mtk_uart_apdma_free(struct mtk_uart_apdmadev *mtkd)
}
static const struct of_device_id mtk_uart_apdma_match[] = {
- { .compatible = "mediatek,mt6577-uart-dma", },
+ { .compatible = "mediatek,mt6577-uart-dma", .data = (void *)32 },
+ { .compatible = "mediatek,mt6795-uart-dma", .data = (void *)33 },
+ { .compatible = "mediatek,mt6835-uart-dma", .data = (void *)34 },
+ { .compatible = "mediatek,mt6985-uart-dma", .data = (void *)35 },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, mtk_uart_apdma_match);
@@ -477,9 +480,9 @@ static int mtk_uart_apdma_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct mtk_uart_apdmadev *mtkd;
- int bit_mask = 32, rc;
struct mtk_chan *c;
- unsigned int i;
+ unsigned int bit_mask, i;
+ int rc;
mtkd = devm_kzalloc(&pdev->dev, sizeof(*mtkd), GFP_KERNEL);
if (!mtkd)
@@ -492,11 +495,9 @@ static int mtk_uart_apdma_probe(struct platform_device *pdev)
return rc;
}
- if (of_property_read_bool(np, "mediatek,dma-33bits"))
- mtkd->support_33bits = true;
-
- if (mtkd->support_33bits)
- bit_mask = 33;
+ bit_mask = (unsigned int)(uintptr_t)of_device_get_match_data(&pdev->dev);
+ if (bit_mask > 32)
+ mtkd->support_ext_addr = true;
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(bit_mask));
if (rc)