Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dwmac1000.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2007-2009 STMicroelectronics Ltd
3 
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  You should have received a copy of the GNU General Public License along with
14  this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 
17  The full GNU General Public License is included in this distribution in
18  the file called "COPYING".
19 
20  Author: Giuseppe Cavallaro <[email protected]>
21 *******************************************************************************/
22 #ifndef __DWMAC1000_H__
23 #define __DWMAC1000_H__
24 
25 #include <linux/phy.h>
26 #include "common.h"
27 
28 #define GMAC_CONTROL 0x00000000 /* Configuration */
29 #define GMAC_FRAME_FILTER 0x00000004 /* Frame Filter */
30 #define GMAC_HASH_HIGH 0x00000008 /* Multicast Hash Table High */
31 #define GMAC_HASH_LOW 0x0000000c /* Multicast Hash Table Low */
32 #define GMAC_MII_ADDR 0x00000010 /* MII Address */
33 #define GMAC_MII_DATA 0x00000014 /* MII Data */
34 #define GMAC_FLOW_CTRL 0x00000018 /* Flow Control */
35 #define GMAC_VLAN_TAG 0x0000001c /* VLAN Tag */
36 #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */
37 #define GMAC_WAKEUP_FILTER 0x00000028 /* Wake-up Frame Filter */
38 
39 #define GMAC_INT_STATUS 0x00000038 /* interrupt status register */
41  lpiis_irq = 0x400,
42  time_stamp_irq = 0x0200,
44  mmc_tx_irq = 0x0040,
45  mmc_rx_irq = 0x0020,
46  mmc_irq = 0x0010,
47  pmt_irq = 0x0008,
48  pcs_ane_irq = 0x0004,
49  pcs_link_irq = 0x0002,
50  rgmii_irq = 0x0001,
51 };
52 #define GMAC_INT_MASK 0x0000003c /* interrupt mask register */
53 
54 /* PMT Control and Status */
55 #define GMAC_PMT 0x0000002c
57  pointer_reset = 0x80000000,
58  global_unicast = 0x00000200,
59  wake_up_rx_frame = 0x00000040,
60  magic_frame = 0x00000020,
61  wake_up_frame_en = 0x00000004,
62  magic_pkt_en = 0x00000002,
63  power_down = 0x00000001,
64 };
65 
66 /* Energy Efficient Ethernet (EEE)
67  *
68  * LPI status, timer and control register offset
69  */
70 #define LPI_CTRL_STATUS 0x0030
71 #define LPI_TIMER_CTRL 0x0034
72 
73 /* LPI control and status defines */
74 #define LPI_CTRL_STATUS_LPITXA 0x00080000 /* Enable LPI TX Automate */
75 #define LPI_CTRL_STATUS_PLSEN 0x00040000 /* Enable PHY Link Status */
76 #define LPI_CTRL_STATUS_PLS 0x00020000 /* PHY Link Status */
77 #define LPI_CTRL_STATUS_LPIEN 0x00010000 /* LPI Enable */
78 #define LPI_CTRL_STATUS_RLPIST 0x00000200 /* Receive LPI state */
79 #define LPI_CTRL_STATUS_TLPIST 0x00000100 /* Transmit LPI state */
80 #define LPI_CTRL_STATUS_RLPIEX 0x00000008 /* Receive LPI Exit */
81 #define LPI_CTRL_STATUS_RLPIEN 0x00000004 /* Receive LPI Entry */
82 #define LPI_CTRL_STATUS_TLPIEX 0x00000002 /* Transmit LPI Exit */
83 #define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */
84 
85 /* GMAC HW ADDR regs */
86 #define GMAC_ADDR_HIGH(reg) (((reg > 15) ? 0x00000800 : 0x00000040) + \
87  (reg * 8))
88 #define GMAC_ADDR_LOW(reg) (((reg > 15) ? 0x00000804 : 0x00000044) + \
89  (reg * 8))
90 #define GMAC_MAX_PERFECT_ADDRESSES 32
91 
92 #define GMAC_AN_CTRL 0x000000c0 /* AN control */
93 #define GMAC_AN_STATUS 0x000000c4 /* AN status */
94 #define GMAC_ANE_ADV 0x000000c8 /* Auto-Neg. Advertisement */
95 #define GMAC_ANE_LINK 0x000000cc /* Auto-Neg. link partener ability */
96 #define GMAC_ANE_EXP 0x000000d0 /* ANE expansion */
97 #define GMAC_TBI 0x000000d4 /* TBI extend status */
98 #define GMAC_GMII_STATUS 0x000000d8 /* S/R-GMII status */
99 
100 /* GMAC Configuration defines */
101 #define GMAC_CONTROL_TC 0x01000000 /* Transmit Conf. in RGMII/SGMII */
102 #define GMAC_CONTROL_WD 0x00800000 /* Disable Watchdog on receive */
103 #define GMAC_CONTROL_JD 0x00400000 /* Jabber disable */
104 #define GMAC_CONTROL_BE 0x00200000 /* Frame Burst Enable */
105 #define GMAC_CONTROL_JE 0x00100000 /* Jumbo frame */
107  GMAC_CONTROL_IFG_88 = 0x00040000,
108  GMAC_CONTROL_IFG_80 = 0x00020000,
109  GMAC_CONTROL_IFG_40 = 0x000e0000,
110 };
111 #define GMAC_CONTROL_DCRS 0x00010000 /* Disable carrier sense during tx */
112 #define GMAC_CONTROL_PS 0x00008000 /* Port Select 0:GMI 1:MII */
113 #define GMAC_CONTROL_FES 0x00004000 /* Speed 0:10 1:100 */
114 #define GMAC_CONTROL_DO 0x00002000 /* Disable Rx Own */
115 #define GMAC_CONTROL_LM 0x00001000 /* Loop-back mode */
116 #define GMAC_CONTROL_DM 0x00000800 /* Duplex Mode */
117 #define GMAC_CONTROL_IPC 0x00000400 /* Checksum Offload */
118 #define GMAC_CONTROL_DR 0x00000200 /* Disable Retry */
119 #define GMAC_CONTROL_LUD 0x00000100 /* Link up/down */
120 #define GMAC_CONTROL_ACS 0x00000080 /* Automatic Pad/FCS Stripping */
121 #define GMAC_CONTROL_DC 0x00000010 /* Deferral Check */
122 #define GMAC_CONTROL_TE 0x00000008 /* Transmitter Enable */
123 #define GMAC_CONTROL_RE 0x00000004 /* Receiver Enable */
124 
125 #define GMAC_CORE_INIT (GMAC_CONTROL_JD | GMAC_CONTROL_PS | GMAC_CONTROL_ACS | \
126  GMAC_CONTROL_JE | GMAC_CONTROL_BE)
127 
128 /* GMAC Frame Filter defines */
129 #define GMAC_FRAME_FILTER_PR 0x00000001 /* Promiscuous Mode */
130 #define GMAC_FRAME_FILTER_HUC 0x00000002 /* Hash Unicast */
131 #define GMAC_FRAME_FILTER_HMC 0x00000004 /* Hash Multicast */
132 #define GMAC_FRAME_FILTER_DAIF 0x00000008 /* DA Inverse Filtering */
133 #define GMAC_FRAME_FILTER_PM 0x00000010 /* Pass all multicast */
134 #define GMAC_FRAME_FILTER_DBF 0x00000020 /* Disable Broadcast frames */
135 #define GMAC_FRAME_FILTER_SAIF 0x00000100 /* Inverse Filtering */
136 #define GMAC_FRAME_FILTER_SAF 0x00000200 /* Source Address Filter */
137 #define GMAC_FRAME_FILTER_HPF 0x00000400 /* Hash or perfect Filter */
138 #define GMAC_FRAME_FILTER_RA 0x80000000 /* Receive all mode */
139 /* GMII ADDR defines */
140 #define GMAC_MII_ADDR_WRITE 0x00000002 /* MII Write */
141 #define GMAC_MII_ADDR_BUSY 0x00000001 /* MII Busy */
142 /* GMAC FLOW CTRL defines */
143 #define GMAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */
144 #define GMAC_FLOW_CTRL_PT_SHIFT 16
145 #define GMAC_FLOW_CTRL_RFE 0x00000004 /* Rx Flow Control Enable */
146 #define GMAC_FLOW_CTRL_TFE 0x00000002 /* Tx Flow Control Enable */
147 #define GMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */
148 
149 /*--- DMA BLOCK defines ---*/
150 /* DMA Bus Mode register defines */
151 #define DMA_BUS_MODE_SFT_RESET 0x00000001 /* Software Reset */
152 #define DMA_BUS_MODE_DA 0x00000002 /* Arbitration scheme */
153 #define DMA_BUS_MODE_DSL_MASK 0x0000007c /* Descriptor Skip Length */
154 #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */
155 /* Programmable burst length (passed thorugh platform)*/
156 #define DMA_BUS_MODE_PBL_MASK 0x00003f00 /* Programmable Burst Len */
157 #define DMA_BUS_MODE_PBL_SHIFT 8
158 
160  double_ratio = 0x00004000, /*2:1 */
161  triple_ratio = 0x00008000, /*3:1 */
162  quadruple_ratio = 0x0000c000, /*4:1 */
163 };
164 
165 #define DMA_BUS_MODE_FB 0x00010000 /* Fixed burst */
166 #define DMA_BUS_MODE_MB 0x04000000 /* Mixed burst */
167 #define DMA_BUS_MODE_RPBL_MASK 0x003e0000 /* Rx-Programmable Burst Len */
168 #define DMA_BUS_MODE_RPBL_SHIFT 17
169 #define DMA_BUS_MODE_USP 0x00800000
170 #define DMA_BUS_MODE_PBL 0x01000000
171 #define DMA_BUS_MODE_AAL 0x02000000
172 
173 /* DMA CRS Control and Status Register Mapping */
174 #define DMA_HOST_TX_DESC 0x00001048 /* Current Host Tx descriptor */
175 #define DMA_HOST_RX_DESC 0x0000104c /* Current Host Rx descriptor */
176 /* DMA Bus Mode register defines */
177 #define DMA_BUS_PR_RATIO_MASK 0x0000c000 /* Rx/Tx priority ratio */
178 #define DMA_BUS_PR_RATIO_SHIFT 14
179 #define DMA_BUS_FB 0x00010000 /* Fixed Burst */
180 
181 /* DMA operation mode defines (start/stop tx/rx are placed in common header)*/
182 #define DMA_CONTROL_DT 0x04000000 /* Disable Drop TCP/IP csum error */
183 #define DMA_CONTROL_RSF 0x02000000 /* Receive Store and Forward */
184 #define DMA_CONTROL_DFF 0x01000000 /* Disaable flushing */
185 /* Threshold for Activating the FC */
186 enum rfa {
187  act_full_minus_1 = 0x00800000,
188  act_full_minus_2 = 0x00800200,
189  act_full_minus_3 = 0x00800400,
190  act_full_minus_4 = 0x00800600,
191 };
192 /* Threshold for Deactivating the FC */
193 enum rfd {
194  deac_full_minus_1 = 0x00400000,
195  deac_full_minus_2 = 0x00400800,
196  deac_full_minus_3 = 0x00401000,
197  deac_full_minus_4 = 0x00401800,
198 };
199 #define DMA_CONTROL_TSF 0x00200000 /* Transmit Store and Forward */
200 
202  DMA_CONTROL_TTC_64 = 0x00000000,
203  DMA_CONTROL_TTC_128 = 0x00004000,
204  DMA_CONTROL_TTC_192 = 0x00008000,
205  DMA_CONTROL_TTC_256 = 0x0000c000,
206  DMA_CONTROL_TTC_40 = 0x00010000,
207  DMA_CONTROL_TTC_32 = 0x00014000,
208  DMA_CONTROL_TTC_24 = 0x00018000,
209  DMA_CONTROL_TTC_16 = 0x0001c000,
210 };
211 #define DMA_CONTROL_TC_TX_MASK 0xfffe3fff
212 
213 #define DMA_CONTROL_EFC 0x00000100
214 #define DMA_CONTROL_FEF 0x00000080
215 #define DMA_CONTROL_FUF 0x00000040
216 
218  DMA_CONTROL_RTC_64 = 0x00000000,
219  DMA_CONTROL_RTC_32 = 0x00000008,
220  DMA_CONTROL_RTC_96 = 0x00000010,
221  DMA_CONTROL_RTC_128 = 0x00000018,
222 };
223 #define DMA_CONTROL_TC_RX_MASK 0xffffffe7
224 
225 #define DMA_CONTROL_OSF 0x00000004 /* Operate on second frame */
226 
227 /* MMC registers offset */
228 #define GMAC_MMC_CTRL 0x100
229 #define GMAC_MMC_RX_INTR 0x104
230 #define GMAC_MMC_TX_INTR 0x108
231 #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208
232 
233 /* Synopsys Core versions */
234 #define DWMAC_CORE_3_40 0x34
235 
236 extern const struct stmmac_dma_ops dwmac1000_dma_ops;
237 #endif /* __DWMAC1000_H__ */