perf tools: Don't clone maps from parent when synthesizing forks
[linux/fpc-iii.git] / drivers / net / ethernet / stmicro / stmmac / dwmac4_dma.h
blob22a4a6dbb1a4af42d3d7467e3ebca50efef57986
1 /*
2 * DWMAC4 DMA Header file.
5 * Copyright (C) 2007-2015 STMicroelectronics Ltd
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * Author: Alexandre Torgue <alexandre.torgue@st.com>
14 #ifndef __DWMAC4_DMA_H__
15 #define __DWMAC4_DMA_H__
17 /* Define the max channel number used for tx (also rx).
18 * dwmac4 accepts up to 8 channels for TX (and also 8 channels for RX
20 #define DMA_CHANNEL_NB_MAX 1
22 #define DMA_BUS_MODE 0x00001000
23 #define DMA_SYS_BUS_MODE 0x00001004
24 #define DMA_STATUS 0x00001008
25 #define DMA_DEBUG_STATUS_0 0x0000100c
26 #define DMA_DEBUG_STATUS_1 0x00001010
27 #define DMA_DEBUG_STATUS_2 0x00001014
28 #define DMA_AXI_BUS_MODE 0x00001028
30 /* DMA Bus Mode bitmap */
31 #define DMA_BUS_MODE_SFT_RESET BIT(0)
33 /* DMA SYS Bus Mode bitmap */
34 #define DMA_BUS_MODE_SPH BIT(24)
35 #define DMA_BUS_MODE_PBL BIT(16)
36 #define DMA_BUS_MODE_PBL_SHIFT 16
37 #define DMA_BUS_MODE_RPBL_SHIFT 16
38 #define DMA_BUS_MODE_MB BIT(14)
39 #define DMA_BUS_MODE_FB BIT(0)
41 /* DMA Interrupt top status */
42 #define DMA_STATUS_MAC BIT(17)
43 #define DMA_STATUS_MTL BIT(16)
44 #define DMA_STATUS_CHAN7 BIT(7)
45 #define DMA_STATUS_CHAN6 BIT(6)
46 #define DMA_STATUS_CHAN5 BIT(5)
47 #define DMA_STATUS_CHAN4 BIT(4)
48 #define DMA_STATUS_CHAN3 BIT(3)
49 #define DMA_STATUS_CHAN2 BIT(2)
50 #define DMA_STATUS_CHAN1 BIT(1)
51 #define DMA_STATUS_CHAN0 BIT(0)
53 /* DMA debug status bitmap */
54 #define DMA_DEBUG_STATUS_TS_MASK 0xf
55 #define DMA_DEBUG_STATUS_RS_MASK 0xf
57 /* DMA AXI bitmap */
58 #define DMA_AXI_EN_LPI BIT(31)
59 #define DMA_AXI_LPI_XIT_FRM BIT(30)
60 #define DMA_AXI_WR_OSR_LMT GENMASK(27, 24)
61 #define DMA_AXI_WR_OSR_LMT_SHIFT 24
62 #define DMA_AXI_RD_OSR_LMT GENMASK(19, 16)
63 #define DMA_AXI_RD_OSR_LMT_SHIFT 16
65 #define DMA_AXI_OSR_MAX 0xf
66 #define DMA_AXI_MAX_OSR_LIMIT ((DMA_AXI_OSR_MAX << DMA_AXI_WR_OSR_LMT_SHIFT) | \
67 (DMA_AXI_OSR_MAX << DMA_AXI_RD_OSR_LMT_SHIFT))
69 #define DMA_SYS_BUS_MB BIT(14)
70 #define DMA_AXI_1KBBE BIT(13)
71 #define DMA_SYS_BUS_AAL BIT(12)
72 #define DMA_AXI_BLEN256 BIT(7)
73 #define DMA_AXI_BLEN128 BIT(6)
74 #define DMA_AXI_BLEN64 BIT(5)
75 #define DMA_AXI_BLEN32 BIT(4)
76 #define DMA_AXI_BLEN16 BIT(3)
77 #define DMA_AXI_BLEN8 BIT(2)
78 #define DMA_AXI_BLEN4 BIT(1)
79 #define DMA_SYS_BUS_FB BIT(0)
81 #define DMA_BURST_LEN_DEFAULT (DMA_AXI_BLEN256 | DMA_AXI_BLEN128 | \
82 DMA_AXI_BLEN64 | DMA_AXI_BLEN32 | \
83 DMA_AXI_BLEN16 | DMA_AXI_BLEN8 | \
84 DMA_AXI_BLEN4)
86 #define DMA_AXI_BURST_LEN_MASK 0x000000FE
88 /* Following DMA defines are chanels oriented */
89 #define DMA_CHAN_BASE_ADDR 0x00001100
90 #define DMA_CHAN_BASE_OFFSET 0x80
91 #define DMA_CHANX_BASE_ADDR(x) (DMA_CHAN_BASE_ADDR + \
92 (x * DMA_CHAN_BASE_OFFSET))
93 #define DMA_CHAN_REG_NUMBER 17
95 #define DMA_CHAN_CONTROL(x) DMA_CHANX_BASE_ADDR(x)
96 #define DMA_CHAN_TX_CONTROL(x) (DMA_CHANX_BASE_ADDR(x) + 0x4)
97 #define DMA_CHAN_RX_CONTROL(x) (DMA_CHANX_BASE_ADDR(x) + 0x8)
98 #define DMA_CHAN_TX_BASE_ADDR(x) (DMA_CHANX_BASE_ADDR(x) + 0x14)
99 #define DMA_CHAN_RX_BASE_ADDR(x) (DMA_CHANX_BASE_ADDR(x) + 0x1c)
100 #define DMA_CHAN_TX_END_ADDR(x) (DMA_CHANX_BASE_ADDR(x) + 0x20)
101 #define DMA_CHAN_RX_END_ADDR(x) (DMA_CHANX_BASE_ADDR(x) + 0x28)
102 #define DMA_CHAN_TX_RING_LEN(x) (DMA_CHANX_BASE_ADDR(x) + 0x2c)
103 #define DMA_CHAN_RX_RING_LEN(x) (DMA_CHANX_BASE_ADDR(x) + 0x30)
104 #define DMA_CHAN_INTR_ENA(x) (DMA_CHANX_BASE_ADDR(x) + 0x34)
105 #define DMA_CHAN_RX_WATCHDOG(x) (DMA_CHANX_BASE_ADDR(x) + 0x38)
106 #define DMA_CHAN_SLOT_CTRL_STATUS(x) (DMA_CHANX_BASE_ADDR(x) + 0x3c)
107 #define DMA_CHAN_CUR_TX_DESC(x) (DMA_CHANX_BASE_ADDR(x) + 0x44)
108 #define DMA_CHAN_CUR_RX_DESC(x) (DMA_CHANX_BASE_ADDR(x) + 0x4c)
109 #define DMA_CHAN_CUR_TX_BUF_ADDR(x) (DMA_CHANX_BASE_ADDR(x) + 0x54)
110 #define DMA_CHAN_CUR_RX_BUF_ADDR(x) (DMA_CHANX_BASE_ADDR(x) + 0x5c)
111 #define DMA_CHAN_STATUS(x) (DMA_CHANX_BASE_ADDR(x) + 0x60)
113 /* DMA Control X */
114 #define DMA_CONTROL_MSS_MASK GENMASK(13, 0)
116 /* DMA Tx Channel X Control register defines */
117 #define DMA_CONTROL_TSE BIT(12)
118 #define DMA_CONTROL_OSP BIT(4)
119 #define DMA_CONTROL_ST BIT(0)
121 /* DMA Rx Channel X Control register defines */
122 #define DMA_CONTROL_SR BIT(0)
123 #define DMA_RBSZ_MASK GENMASK(14, 1)
124 #define DMA_RBSZ_SHIFT 1
126 /* Interrupt status per channel */
127 #define DMA_CHAN_STATUS_REB GENMASK(21, 19)
128 #define DMA_CHAN_STATUS_REB_SHIFT 19
129 #define DMA_CHAN_STATUS_TEB GENMASK(18, 16)
130 #define DMA_CHAN_STATUS_TEB_SHIFT 16
131 #define DMA_CHAN_STATUS_NIS BIT(15)
132 #define DMA_CHAN_STATUS_AIS BIT(14)
133 #define DMA_CHAN_STATUS_CDE BIT(13)
134 #define DMA_CHAN_STATUS_FBE BIT(12)
135 #define DMA_CHAN_STATUS_ERI BIT(11)
136 #define DMA_CHAN_STATUS_ETI BIT(10)
137 #define DMA_CHAN_STATUS_RWT BIT(9)
138 #define DMA_CHAN_STATUS_RPS BIT(8)
139 #define DMA_CHAN_STATUS_RBU BIT(7)
140 #define DMA_CHAN_STATUS_RI BIT(6)
141 #define DMA_CHAN_STATUS_TBU BIT(2)
142 #define DMA_CHAN_STATUS_TPS BIT(1)
143 #define DMA_CHAN_STATUS_TI BIT(0)
145 /* Interrupt enable bits per channel */
146 #define DMA_CHAN_INTR_ENA_NIE BIT(16)
147 #define DMA_CHAN_INTR_ENA_AIE BIT(15)
148 #define DMA_CHAN_INTR_ENA_NIE_4_10 BIT(15)
149 #define DMA_CHAN_INTR_ENA_AIE_4_10 BIT(14)
150 #define DMA_CHAN_INTR_ENA_CDE BIT(13)
151 #define DMA_CHAN_INTR_ENA_FBE BIT(12)
152 #define DMA_CHAN_INTR_ENA_ERE BIT(11)
153 #define DMA_CHAN_INTR_ENA_ETE BIT(10)
154 #define DMA_CHAN_INTR_ENA_RWE BIT(9)
155 #define DMA_CHAN_INTR_ENA_RSE BIT(8)
156 #define DMA_CHAN_INTR_ENA_RBUE BIT(7)
157 #define DMA_CHAN_INTR_ENA_RIE BIT(6)
158 #define DMA_CHAN_INTR_ENA_TBUE BIT(2)
159 #define DMA_CHAN_INTR_ENA_TSE BIT(1)
160 #define DMA_CHAN_INTR_ENA_TIE BIT(0)
162 #define DMA_CHAN_INTR_NORMAL (DMA_CHAN_INTR_ENA_NIE | \
163 DMA_CHAN_INTR_ENA_RIE | \
164 DMA_CHAN_INTR_ENA_TIE)
166 #define DMA_CHAN_INTR_ABNORMAL (DMA_CHAN_INTR_ENA_AIE | \
167 DMA_CHAN_INTR_ENA_FBE)
168 /* DMA default interrupt mask for 4.00 */
169 #define DMA_CHAN_INTR_DEFAULT_MASK (DMA_CHAN_INTR_NORMAL | \
170 DMA_CHAN_INTR_ABNORMAL)
172 #define DMA_CHAN_INTR_NORMAL_4_10 (DMA_CHAN_INTR_ENA_NIE_4_10 | \
173 DMA_CHAN_INTR_ENA_RIE | \
174 DMA_CHAN_INTR_ENA_TIE)
176 #define DMA_CHAN_INTR_ABNORMAL_4_10 (DMA_CHAN_INTR_ENA_AIE_4_10 | \
177 DMA_CHAN_INTR_ENA_FBE)
178 /* DMA default interrupt mask for 4.10a */
179 #define DMA_CHAN_INTR_DEFAULT_MASK_4_10 (DMA_CHAN_INTR_NORMAL_4_10 | \
180 DMA_CHAN_INTR_ABNORMAL_4_10)
182 /* channel 0 specific fields */
183 #define DMA_CHAN0_DBG_STAT_TPS GENMASK(15, 12)
184 #define DMA_CHAN0_DBG_STAT_TPS_SHIFT 12
185 #define DMA_CHAN0_DBG_STAT_RPS GENMASK(11, 8)
186 #define DMA_CHAN0_DBG_STAT_RPS_SHIFT 8
188 int dwmac4_dma_reset(void __iomem *ioaddr);
189 void dwmac4_enable_dma_irq(void __iomem *ioaddr, u32 chan);
190 void dwmac410_enable_dma_irq(void __iomem *ioaddr, u32 chan);
191 void dwmac4_disable_dma_irq(void __iomem *ioaddr, u32 chan);
192 void dwmac4_dma_start_tx(void __iomem *ioaddr, u32 chan);
193 void dwmac4_dma_stop_tx(void __iomem *ioaddr, u32 chan);
194 void dwmac4_dma_start_rx(void __iomem *ioaddr, u32 chan);
195 void dwmac4_dma_stop_rx(void __iomem *ioaddr, u32 chan);
196 int dwmac4_dma_interrupt(void __iomem *ioaddr,
197 struct stmmac_extra_stats *x, u32 chan);
198 void dwmac4_set_rx_ring_len(void __iomem *ioaddr, u32 len, u32 chan);
199 void dwmac4_set_tx_ring_len(void __iomem *ioaddr, u32 len, u32 chan);
200 void dwmac4_set_rx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
201 void dwmac4_set_tx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
203 #endif /* __DWMAC4_DMA_H__ */