forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*******************************************************************************
23 Copyright (C) 2007-2009 STMicroelectronics Ltd
34
4
- This program is free software; you can redistribute it and/or modify it
5
- under the terms and conditions of the GNU General Public License,
6
- version 2, as published by the Free Software Foundation.
7
-
8
- This program is distributed in the hope it will be useful, but WITHOUT
9
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- more details.
12
-
13
- The full GNU General Public License is included in this distribution in
14
- the file called "COPYING".
155
166 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
177 *******************************************************************************/
....@@ -26,19 +16,14 @@
2616 int dwmac_dma_reset(void __iomem *ioaddr)
2717 {
2818 u32 value = readl(ioaddr + DMA_BUS_MODE);
29
- int err;
3019
3120 /* DMA SW reset */
3221 value |= DMA_BUS_MODE_SFT_RESET;
3322 writel(value, ioaddr + DMA_BUS_MODE);
3423
35
- err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
24
+ return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
3625 !(value & DMA_BUS_MODE_SFT_RESET),
37
- 10000, 100000);
38
- if (err)
39
- return -EBUSY;
40
-
41
- return 0;
26
+ 10000, 200000);
4227 }
4328
4429 /* CSR1 enables the transmit DMA to check for new descriptor */
....@@ -47,14 +32,28 @@
4732 writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
4833 }
4934
50
-void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan)
35
+void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan, bool rx, bool tx)
5136 {
52
- writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA);
37
+ u32 value = readl(ioaddr + DMA_INTR_ENA);
38
+
39
+ if (rx)
40
+ value |= DMA_INTR_DEFAULT_RX;
41
+ if (tx)
42
+ value |= DMA_INTR_DEFAULT_TX;
43
+
44
+ writel(value, ioaddr + DMA_INTR_ENA);
5345 }
5446
55
-void dwmac_disable_dma_irq(void __iomem *ioaddr, u32 chan)
47
+void dwmac_disable_dma_irq(void __iomem *ioaddr, u32 chan, bool rx, bool tx)
5648 {
57
- writel(0, ioaddr + DMA_INTR_ENA);
49
+ u32 value = readl(ioaddr + DMA_INTR_ENA);
50
+
51
+ if (rx)
52
+ value &= ~DMA_INTR_DEFAULT_RX;
53
+ if (tx)
54
+ value &= ~DMA_INTR_DEFAULT_TX;
55
+
56
+ writel(value, ioaddr + DMA_INTR_ENA);
5857 }
5958
6059 void dwmac_dma_start_tx(void __iomem *ioaddr, u32 chan)