forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*******************************************************************************
23 This is the driver for the GMAC on-chip Ethernet controller for ST SoCs.
34 DWC Ether MAC 10/100/1000 Universal version 3.41a has been used for
....@@ -7,17 +8,6 @@
78
89 Copyright (C) 2007-2009 STMicroelectronics Ltd
910
10
- This program is free software; you can redistribute it and/or modify it
11
- under the terms and conditions of the GNU General Public License,
12
- version 2, as published by the Free Software Foundation.
13
-
14
- This program is distributed in the hope it will be useful, but WITHOUT
15
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17
- more details.
18
-
19
- The full GNU General Public License is included in this distribution in
20
- the file called "COPYING".
2111
2212 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
2313 *******************************************************************************/
....@@ -122,18 +112,18 @@
122112
123113 static void dwmac1000_dma_init_rx(void __iomem *ioaddr,
124114 struct stmmac_dma_cfg *dma_cfg,
125
- u32 dma_rx_phy, u32 chan)
115
+ dma_addr_t dma_rx_phy, u32 chan)
126116 {
127117 /* RX descriptor base address list must be written into DMA CSR3 */
128
- writel(dma_rx_phy, ioaddr + DMA_RCV_BASE_ADDR);
118
+ writel(lower_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR);
129119 }
130120
131121 static void dwmac1000_dma_init_tx(void __iomem *ioaddr,
132122 struct stmmac_dma_cfg *dma_cfg,
133
- u32 dma_tx_phy, u32 chan)
123
+ dma_addr_t dma_tx_phy, u32 chan)
134124 {
135125 /* TX descriptor base address list must be written into DMA CSR4 */
136
- writel(dma_tx_phy, ioaddr + DMA_TX_BASE_ADDR);
126
+ writel(lower_32_bits(dma_tx_phy), ioaddr + DMA_TX_BASE_ADDR);
137127 }
138128
139129 static u32 dwmac1000_configure_fc(u32 csr6, int rxfifosz)
....@@ -228,10 +218,17 @@
228218 readl(ioaddr + DMA_BUS_MODE + i * 4);
229219 }
230220
231
-static void dwmac1000_get_hw_feature(void __iomem *ioaddr,
232
- struct dma_features *dma_cap)
221
+static int dwmac1000_get_hw_feature(void __iomem *ioaddr,
222
+ struct dma_features *dma_cap)
233223 {
234224 u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
225
+
226
+ if (!hw_cap) {
227
+ /* 0x00000000 is the value read on old hardware that does not
228
+ * implement this register
229
+ */
230
+ return -EOPNOTSUPP;
231
+ }
235232
236233 dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
237234 dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
....@@ -262,6 +259,8 @@
262259 dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
263260 /* Alternate (enhanced) DESC mode */
264261 dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
262
+
263
+ return 0;
265264 }
266265
267266 static void dwmac1000_rx_watchdog(void __iomem *ioaddr, u32 riwt,