aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/networking/stmmac.txt24
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/common.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000.h2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c42
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c4
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c3
-rw-r--r--include/linux/stmmac.h20
9 files changed, 89 insertions, 16 deletions
diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index 61f40a3fa7ea..eacb640286b1 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -111,7 +111,7 @@ and detailed below as well:
111 int phy_addr; 111 int phy_addr;
112 int interface; 112 int interface;
113 struct stmmac_mdio_bus_data *mdio_bus_data; 113 struct stmmac_mdio_bus_data *mdio_bus_data;
114 int pbl; 114 struct stmmac_dma_cfg *dma_cfg;
115 int clk_csr; 115 int clk_csr;
116 int has_gmac; 116 int has_gmac;
117 int enh_desc; 117 int enh_desc;
@@ -163,7 +163,7 @@ Where:
163 o custom_cfg: this is a custom configuration that can be passed while 163 o custom_cfg: this is a custom configuration that can be passed while
164 initialising the resources. 164 initialising the resources.
165 165
166The we have: 166For MDIO bus The we have:
167 167
168 struct stmmac_mdio_bus_data { 168 struct stmmac_mdio_bus_data {
169 int bus_id; 169 int bus_id;
@@ -180,10 +180,28 @@ Where:
180 o irqs: list of IRQs, one per PHY. 180 o irqs: list of IRQs, one per PHY.
181 o probed_phy_irq: if irqs is NULL, use this for probed PHY. 181 o probed_phy_irq: if irqs is NULL, use this for probed PHY.
182 182
183
184For DMA engine we have the following internal fields that should be
185tuned according to the HW capabilities.
186
187struct stmmac_dma_cfg {
188 int pbl;
189 int fixed_burst;
190 int burst_len_supported;
191};
192
193Where:
194 o pbl: Programmable Burst Length
195 o fixed_burst: program the DMA to use the fixed burst mode
196 o burst_len: this is the value we put in the register
197 supported values are provided as macros in
198 linux/stmmac.h header file.
199
200---
201
183Below an example how the structures above are using on ST platforms. 202Below an example how the structures above are using on ST platforms.
184 203
185 static struct plat_stmmacenet_data stxYYY_ethernet_platform_data = { 204 static struct plat_stmmacenet_data stxYYY_ethernet_platform_data = {
186 .pbl = 32,
187 .has_gmac = 0, 205 .has_gmac = 0,
188 .enh_desc = 0, 206 .enh_desc = 0,
189 .fix_mac_speed = stxYYY_ethernet_fix_mac_speed, 207 .fix_mac_speed = stxYYY_ethernet_fix_mac_speed,
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index eec8d34b6c88..b14829f8085d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -236,7 +236,8 @@ struct stmmac_desc_ops {
236 236
237struct stmmac_dma_ops { 237struct stmmac_dma_ops {
238 /* DMA core initialization */ 238 /* DMA core initialization */
239 int (*init) (void __iomem *ioaddr, int pbl, u32 dma_tx, u32 dma_rx); 239 int (*init) (void __iomem *ioaddr, int pbl, int fb, int burst_len,
240 u32 dma_tx, u32 dma_rx);
240 /* Dump DMA registers */ 241 /* Dump DMA registers */
241 void (*dump_regs) (void __iomem *ioaddr); 242 void (*dump_regs) (void __iomem *ioaddr);
242 /* Set tx/rx threshold in the csr6 register 243 /* Set tx/rx threshold in the csr6 register
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
index cfcef0ea0fa5..54339a78e358 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
@@ -142,7 +142,7 @@ enum rx_tx_priority_ratio {
142#define DMA_BUS_MODE_RPBL_MASK 0x003e0000 /* Rx-Programmable Burst Len */ 142#define DMA_BUS_MODE_RPBL_MASK 0x003e0000 /* Rx-Programmable Burst Len */
143#define DMA_BUS_MODE_RPBL_SHIFT 17 143#define DMA_BUS_MODE_RPBL_SHIFT 17
144#define DMA_BUS_MODE_USP 0x00800000 144#define DMA_BUS_MODE_USP 0x00800000
145#define DMA_BUS_MODE_4PBL 0x01000000 145#define DMA_BUS_MODE_PBL 0x01000000
146#define DMA_BUS_MODE_AAL 0x02000000 146#define DMA_BUS_MODE_AAL 0x02000000
147 147
148/* DMA CRS Control and Status Register Mapping */ 148/* DMA CRS Control and Status Register Mapping */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
index 4d5402a1d262..3675c5731565 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
@@ -30,8 +30,8 @@
30#include "dwmac1000.h" 30#include "dwmac1000.h"
31#include "dwmac_dma.h" 31#include "dwmac_dma.h"
32 32
33static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx, 33static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, int fb,
34 u32 dma_rx) 34 int burst_len, u32 dma_tx, u32 dma_rx)
35{ 35{
36 u32 value = readl(ioaddr + DMA_BUS_MODE); 36 u32 value = readl(ioaddr + DMA_BUS_MODE);
37 int limit; 37 int limit;
@@ -48,15 +48,47 @@ static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx,
48 if (limit < 0) 48 if (limit < 0)
49 return -EBUSY; 49 return -EBUSY;
50 50
51 value = /* DMA_BUS_MODE_FB | */ DMA_BUS_MODE_4PBL | 51 /*
52 ((pbl << DMA_BUS_MODE_PBL_SHIFT) | 52 * Set the DMA PBL (Programmable Burst Length) mode
53 (pbl << DMA_BUS_MODE_RPBL_SHIFT)); 53 * Before stmmac core 3.50 this mode bit was 4xPBL, and
54 * post 3.5 mode bit acts as 8*PBL.
55 * For core rev < 3.5, when the core is set for 4xPBL mode, the
56 * DMA transfers the data in 4, 8, 16, 32, 64 & 128 beats
57 * depending on pbl value.
58 * For core rev > 3.5, when the core is set for 8xPBL mode, the
59 * DMA transfers the data in 8, 16, 32, 64, 128 & 256 beats
60 * depending on pbl value.
61 */
62 value = DMA_BUS_MODE_PBL | ((pbl << DMA_BUS_MODE_PBL_SHIFT) |
63 (pbl << DMA_BUS_MODE_RPBL_SHIFT));
64
65 /* Set the Fixed burst mode */
66 if (fb)
67 value |= DMA_BUS_MODE_FB;
54 68
55#ifdef CONFIG_STMMAC_DA 69#ifdef CONFIG_STMMAC_DA
56 value |= DMA_BUS_MODE_DA; /* Rx has priority over tx */ 70 value |= DMA_BUS_MODE_DA; /* Rx has priority over tx */
57#endif 71#endif
58 writel(value, ioaddr + DMA_BUS_MODE); 72 writel(value, ioaddr + DMA_BUS_MODE);
59 73
74 /* In case of GMAC AXI configuration, program the DMA_AXI_BUS_MODE
75 * for supported bursts.
76 *
77 * Note: This is applicable only for revision GMACv3.61a. For
78 * older version this register is reserved and shall have no
79 * effect.
80 *
81 * Note:
82 * For Fixed Burst Mode: if we directly write 0xFF to this
83 * register using the configurations pass from platform code,
84 * this would ensure that all bursts supported by core are set
85 * and those which are not supported would remain ineffective.
86 *
87 * For Non Fixed Burst Mode: provide the maximum value of the
88 * burst length. Any burst equal or below the provided burst
89 * length would be allowed to perform. */
90 writel(burst_len, ioaddr + DMA_AXI_BUS_MODE);
91
60 /* Mask interrupts by writing to CSR7 */ 92 /* Mask interrupts by writing to CSR7 */
61 writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA); 93 writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA);
62 94
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
index bc17fd08b55d..92ed2e07609e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
@@ -32,8 +32,8 @@
32#include "dwmac100.h" 32#include "dwmac100.h"
33#include "dwmac_dma.h" 33#include "dwmac_dma.h"
34 34
35static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx, 35static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, int fb,
36 u32 dma_rx) 36 int burst_len, u32 dma_tx, u32 dma_rx)
37{ 37{
38 u32 value = readl(ioaddr + DMA_BUS_MODE); 38 u32 value = readl(ioaddr + DMA_BUS_MODE);
39 int limit; 39 int limit;
@@ -52,7 +52,7 @@ static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx,
52 52
53 /* Enable Application Access by writing to DMA CSR0 */ 53 /* Enable Application Access by writing to DMA CSR0 */
54 writel(DMA_BUS_MODE_DEFAULT | (pbl << DMA_BUS_MODE_PBL_SHIFT), 54 writel(DMA_BUS_MODE_DEFAULT | (pbl << DMA_BUS_MODE_PBL_SHIFT),
55 ioaddr + DMA_BUS_MODE); 55 ioaddr + DMA_BUS_MODE);
56 56
57 /* Mask interrupts by writing to CSR7 */ 57 /* Mask interrupts by writing to CSR7 */
58 writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA); 58 writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
index 437edacd602e..6e0360f9cfde 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
@@ -32,6 +32,7 @@
32#define DMA_CONTROL 0x00001018 /* Ctrl (Operational Mode) */ 32#define DMA_CONTROL 0x00001018 /* Ctrl (Operational Mode) */
33#define DMA_INTR_ENA 0x0000101c /* Interrupt Enable */ 33#define DMA_INTR_ENA 0x0000101c /* Interrupt Enable */
34#define DMA_MISSED_FRAME_CTR 0x00001020 /* Missed Frame Counter */ 34#define DMA_MISSED_FRAME_CTR 0x00001020 /* Missed Frame Counter */
35#define DMA_AXI_BUS_MODE 0x00001028 /* AXI Bus Mode */
35#define DMA_CUR_TX_BUF_ADDR 0x00001050 /* Current Host Tx Buffer */ 36#define DMA_CUR_TX_BUF_ADDR 0x00001050 /* Current Host Tx Buffer */
36#define DMA_CUR_RX_BUF_ADDR 0x00001054 /* Current Host Rx Buffer */ 37#define DMA_CUR_RX_BUF_ADDR 0x00001054 /* Current Host Rx Buffer */
37#define DMA_HW_FEATURE 0x00001058 /* HW Feature Register */ 38#define DMA_HW_FEATURE 0x00001058 /* HW Feature Register */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 84f6b348ec70..933f63c4b2f3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -944,7 +944,9 @@ static int stmmac_open(struct net_device *dev)
944 init_dma_desc_rings(dev); 944 init_dma_desc_rings(dev);
945 945
946 /* DMA initialization and SW reset */ 946 /* DMA initialization and SW reset */
947 ret = priv->hw->dma->init(priv->ioaddr, priv->plat->pbl, 947 ret = priv->hw->dma->init(priv->ioaddr, priv->plat->dma_cfg->pbl,
948 priv->plat->dma_cfg->fixed_burst,
949 priv->plat->dma_cfg->burst_len,
948 priv->dma_tx_phy, priv->dma_rx_phy); 950 priv->dma_tx_phy, priv->dma_rx_phy);
949 if (ret < 0) { 951 if (ret < 0) {
950 pr_err("%s: DMA initialization failed\n", __func__); 952 pr_err("%s: DMA initialization failed\n", __func__);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index da66ed7c3c5d..65e0f98520d6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -35,7 +35,8 @@ static void stmmac_default_data(void)
35 plat_dat.bus_id = 1; 35 plat_dat.bus_id = 1;
36 plat_dat.phy_addr = 0; 36 plat_dat.phy_addr = 0;
37 plat_dat.interface = PHY_INTERFACE_MODE_GMII; 37 plat_dat.interface = PHY_INTERFACE_MODE_GMII;
38 plat_dat.pbl = 32; 38 plat_dat.dma_cfg->pbl = 32;
39 plat_dat.dma_cfg->burst_len = DMA_AXI_BLEN_256;
39 plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ 40 plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
40 plat_dat.has_gmac = 1; 41 plat_dat.has_gmac = 1;
41 plat_dat.force_sf_dma_mode = 1; 42 plat_dat.force_sf_dma_mode = 1;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index e5292828b684..4aef9baff12b 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -60,6 +60,18 @@
60 * 1110 clk_csr_i/16 60 * 1110 clk_csr_i/16
61 * 1111 clk_csr_i/18 */ 61 * 1111 clk_csr_i/18 */
62 62
63/* AXI DMA Burst length suported */
64#define DMA_AXI_BLEN_4 (1 << 1)
65#define DMA_AXI_BLEN_8 (1 << 2)
66#define DMA_AXI_BLEN_16 (1 << 3)
67#define DMA_AXI_BLEN_32 (1 << 4)
68#define DMA_AXI_BLEN_64 (1 << 5)
69#define DMA_AXI_BLEN_128 (1 << 6)
70#define DMA_AXI_BLEN_256 (1 << 7)
71#define DMA_AXI_BLEN_ALL (DMA_AXI_BLEN_4 | DMA_AXI_BLEN_8 | DMA_AXI_BLEN_16 \
72 | DMA_AXI_BLEN_32 | DMA_AXI_BLEN_64 \
73 | DMA_AXI_BLEN_128 | DMA_AXI_BLEN_256)
74
63/* Platfrom data for platform device structure's platform_data field */ 75/* Platfrom data for platform device structure's platform_data field */
64 76
65struct stmmac_mdio_bus_data { 77struct stmmac_mdio_bus_data {
@@ -70,13 +82,19 @@ struct stmmac_mdio_bus_data {
70 int probed_phy_irq; 82 int probed_phy_irq;
71}; 83};
72 84
85struct stmmac_dma_cfg {
86 int pbl;
87 int fixed_burst;
88 int burst_len;
89};
90
73struct plat_stmmacenet_data { 91struct plat_stmmacenet_data {
74 char *phy_bus_name; 92 char *phy_bus_name;
75 int bus_id; 93 int bus_id;
76 int phy_addr; 94 int phy_addr;
77 int interface; 95 int interface;
78 struct stmmac_mdio_bus_data *mdio_bus_data; 96 struct stmmac_mdio_bus_data *mdio_bus_data;
79 int pbl; 97 struct stmmac_dma_cfg *dma_cfg;
80 int clk_csr; 98 int clk_csr;
81 int has_gmac; 99 int has_gmac;
82 int enh_desc; 100 int enh_desc;