xref: /freebsd/sys/arm/ti/cpsw/if_cpswreg.h (revision d9f0ce31900a48d1a2bfc1c8c86f79d1e831451a)
1 /*-
2  * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 
29 #ifndef	_IF_CPSWREG_H
30 #define	_IF_CPSWREG_H
31 
32 #define	CPSW_SS_OFFSET			0x0000
33 #define	CPSW_SS_IDVER			(CPSW_SS_OFFSET + 0x00)
34 #define	CPSW_SS_SOFT_RESET		(CPSW_SS_OFFSET + 0x08)
35 #define	CPSW_SS_STAT_PORT_EN		(CPSW_SS_OFFSET + 0x0C)
36 #define	CPSW_SS_PTYPE			(CPSW_SS_OFFSET + 0x10)
37 #define	CPSW_SS_FLOW_CONTROL		(CPSW_SS_OFFSET + 0x24)
38 
39 #define	CPSW_PORT_OFFSET		0x0100
40 #define	CPSW_PORT_P_MAX_BLKS(p)		(CPSW_PORT_OFFSET + 0x08 + ((p) * 0x100))
41 #define	CPSW_PORT_P_BLK_CNT(p)		(CPSW_PORT_OFFSET + 0x0C + ((p) * 0x100))
42 #define	CPSW_PORT_P_VLAN(p)		(CPSW_PORT_OFFSET + 0x14 + ((p) * 0x100))
43 #define	CPSW_PORT_P_TX_PRI_MAP(p)	(CPSW_PORT_OFFSET + 0x118 + ((p-1) * 0x100))
44 #define	CPSW_PORT_P0_CPDMA_TX_PRI_MAP	(CPSW_PORT_OFFSET + 0x01C)
45 #define	CPSW_PORT_P0_CPDMA_RX_CH_MAP	(CPSW_PORT_OFFSET + 0x020)
46 #define	CPSW_PORT_P_SA_LO(p)		(CPSW_PORT_OFFSET + 0x120 + ((p-1) * 0x100))
47 #define	CPSW_PORT_P_SA_HI(p)		(CPSW_PORT_OFFSET + 0x124 + ((p-1) * 0x100))
48 
49 #define	CPSW_CPDMA_OFFSET		0x0800
50 #define	CPSW_CPDMA_TX_CONTROL		(CPSW_CPDMA_OFFSET + 0x04)
51 #define	CPSW_CPDMA_TX_TEARDOWN		(CPSW_CPDMA_OFFSET + 0x08)
52 #define	CPSW_CPDMA_RX_CONTROL		(CPSW_CPDMA_OFFSET + 0x14)
53 #define	CPSW_CPDMA_RX_TEARDOWN		(CPSW_CPDMA_OFFSET + 0x18)
54 #define	CPSW_CPDMA_SOFT_RESET		(CPSW_CPDMA_OFFSET + 0x1c)
55 #define	CPSW_CPDMA_DMACONTROL		(CPSW_CPDMA_OFFSET + 0x20)
56 #define	CPSW_CPDMA_DMASTATUS		(CPSW_CPDMA_OFFSET + 0x24)
57 #define	CPSW_CPDMA_RX_BUFFER_OFFSET	(CPSW_CPDMA_OFFSET + 0x28)
58 #define	CPSW_CPDMA_TX_INTSTAT_RAW	(CPSW_CPDMA_OFFSET + 0x80)
59 #define	CPSW_CPDMA_TX_INTSTAT_MASKED	(CPSW_CPDMA_OFFSET + 0x84)
60 #define	CPSW_CPDMA_TX_INTMASK_SET	(CPSW_CPDMA_OFFSET + 0x88)
61 #define	CPSW_CPDMA_TX_INTMASK_CLEAR	(CPSW_CPDMA_OFFSET + 0x8C)
62 #define	CPSW_CPDMA_CPDMA_EOI_VECTOR	(CPSW_CPDMA_OFFSET + 0x94)
63 #define	CPSW_CPDMA_RX_INTSTAT_RAW	(CPSW_CPDMA_OFFSET + 0xA0)
64 #define	CPSW_CPDMA_RX_INTSTAT_MASKED	(CPSW_CPDMA_OFFSET + 0xA4)
65 #define	CPSW_CPDMA_RX_INTMASK_SET	(CPSW_CPDMA_OFFSET + 0xA8)
66 #define	CPSW_CPDMA_RX_INTMASK_CLEAR	(CPSW_CPDMA_OFFSET + 0xAc)
67 #define	CPSW_CPDMA_DMA_INTSTAT_RAW	(CPSW_CPDMA_OFFSET + 0xB0)
68 #define	CPSW_CPDMA_DMA_INTSTAT_MASKED	(CPSW_CPDMA_OFFSET + 0xB4)
69 #define	CPSW_CPDMA_DMA_INTMASK_SET	(CPSW_CPDMA_OFFSET + 0xB8)
70 #define	CPSW_CPDMA_DMA_INTMASK_CLEAR	(CPSW_CPDMA_OFFSET + 0xBC)
71 #define	CPSW_CPDMA_RX_FREEBUFFER(p)	(CPSW_CPDMA_OFFSET + 0x0e0 + ((p) * 0x04))
72 
73 #define	CPSW_STATS_OFFSET		0x0900
74 
75 #define	CPSW_STATERAM_OFFSET		0x0A00
76 #define	CPSW_CPDMA_TX_HDP(p)		(CPSW_STATERAM_OFFSET + 0x00 + ((p) * 0x04))
77 #define	CPSW_CPDMA_RX_HDP(p)		(CPSW_STATERAM_OFFSET + 0x20 + ((p) * 0x04))
78 #define	CPSW_CPDMA_TX_CP(p)		(CPSW_STATERAM_OFFSET + 0x40 + ((p) * 0x04))
79 #define	CPSW_CPDMA_RX_CP(p)		(CPSW_STATERAM_OFFSET + 0x60 + ((p) * 0x04))
80 
81 #define	CPSW_CPTS_OFFSET		0x0C00
82 
83 #define	CPSW_ALE_OFFSET			0x0D00
84 #define	CPSW_ALE_CONTROL		(CPSW_ALE_OFFSET + 0x08)
85 #define	 CPSW_ALE_CTL_ENABLE		(1U << 31)
86 #define	 CPSW_ALE_CTL_CLEAR_TBL		(1 << 30)
87 #define	 CPSW_ALE_CTL_BYPASS		(1 << 4)
88 #define	 CPSW_ALE_CTL_VLAN_AWARE	(1 << 2)
89 #define	CPSW_ALE_TBLCTL			(CPSW_ALE_OFFSET + 0x20)
90 #define	CPSW_ALE_TBLW2			(CPSW_ALE_OFFSET + 0x34)
91 #define	CPSW_ALE_TBLW1			(CPSW_ALE_OFFSET + 0x38)
92 #define	CPSW_ALE_TBLW0			(CPSW_ALE_OFFSET + 0x3C)
93 #define	 ALE_MCAST(_a)			((_a[1] >> 8) & 1)
94 #define	 ALE_MCAST_FWD			(3 << 30)
95 #define	 ALE_PORTS(_a)			((_a[2] >> 2) & 7)
96 #define	 ALE_TYPE(_a)			((_a[1] >> 28) & 3)
97 #define	 ALE_TYPE_ADDR			1
98 #define	 ALE_TYPE_VLAN			2
99 #define	 ALE_TYPE_VLAN_ADDR		3
100 #define	 ALE_VLAN(_a)			((_a[1] >> 16) & 0xfff)
101 #define	 ALE_VLAN_UNREGFLOOD(_a)	((_a[0] >> 8) & 7)
102 #define	 ALE_VLAN_REGFLOOD(_a)		((_a[0] >> 16) & 7)
103 #define	 ALE_VLAN_UNTAG(_a)		((_a[0] >> 24) & 7)
104 #define	 ALE_VLAN_MEMBERS(_a)		(_a[0] & 7)
105 #define	CPSW_ALE_PORTCTL(p)		(CPSW_ALE_OFFSET + 0x40 + ((p) * 0x04))
106 
107 /* SL1 is at 0x0D80, SL2 is at 0x0DC0 */
108 #define	CPSW_SL_OFFSET			0x0D80
109 #define	CPSW_SL_MACCONTROL(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x04)
110 #define	 CPSW_SL_MACTL_IFCTL_B		(1 << 16)
111 #define	 CPSW_SL_MACTL_IFCTL_A		(1 << 15)
112 #define	 CPSW_SL_MACTL_GIG		(1 << 7)
113 #define	 CPSW_SL_MACTL_GMII_ENABLE	(1 << 5)
114 #define	 CPSW_SL_MACTL_FULLDUPLEX	(1 << 0)
115 #define	CPSW_SL_MACSTATUS(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x08)
116 #define	CPSW_SL_SOFT_RESET(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x0C)
117 #define	CPSW_SL_RX_MAXLEN(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x10)
118 #define	CPSW_SL_RX_PAUSE(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x18)
119 #define	CPSW_SL_TX_PAUSE(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x1C)
120 #define	CPSW_SL_RX_PRI_MAP(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x24)
121 
122 #define	MDIO_OFFSET			0x1000
123 #define	MDIOCONTROL			(MDIO_OFFSET + 0x04)
124 #define	 MDIOCTL_ENABLE			(1 << 30)
125 #define	 MDIOCTL_FAULTENB		(1 << 18)
126 #define	MDIOLINKINTRAW			(MDIO_OFFSET + 0x10)
127 #define	MDIOLINKINTMASKED		(MDIO_OFFSET + 0x14)
128 #define	MDIOUSERACCESS0			(MDIO_OFFSET + 0x80)
129 #define	MDIOUSERPHYSEL0			(MDIO_OFFSET + 0x84)
130 #define	MDIOUSERACCESS1			(MDIO_OFFSET + 0x88)
131 #define	MDIOUSERPHYSEL1			(MDIO_OFFSET + 0x8C)
132 #define	 MDIO_PHYSEL_LINKINTENB		(1 << 6)
133 #define	 MDIO_PHYACCESS_GO		(1U << 31)
134 #define	 MDIO_PHYACCESS_WRITE		(1 << 30)
135 #define	 MDIO_PHYACCESS_ACK		(1 << 29)
136 
137 #define	CPSW_WR_OFFSET			0x1200
138 #define	CPSW_WR_SOFT_RESET		(CPSW_WR_OFFSET + 0x04)
139 #define	CPSW_WR_CONTROL			(CPSW_WR_OFFSET + 0x08)
140 #define	CPSW_WR_INT_CONTROL		(CPSW_WR_OFFSET + 0x0c)
141 #define	CPSW_WR_C_RX_THRESH_EN(p)	(CPSW_WR_OFFSET + (0x10 * (p)) + 0x10)
142 #define	CPSW_WR_C_RX_EN(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x14)
143 #define	CPSW_WR_C_TX_EN(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x18)
144 #define	CPSW_WR_C_MISC_EN(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x1C)
145 #define	CPSW_WR_C_RX_THRESH_STAT(p)	(CPSW_WR_OFFSET + (0x10 * (p)) + 0x40)
146 #define	CPSW_WR_C_RX_STAT(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x44)
147 #define	CPSW_WR_C_TX_STAT(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x48)
148 #define	CPSW_WR_C_MISC_STAT(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x4C)
149 #define	 CPSW_WR_C_MISC_EVNT_PEND	(1 << 4)
150 #define	 CPSW_WR_C_MISC_STAT_PEND	(1 << 3)
151 #define	 CPSW_WR_C_MISC_HOST_PEND	(1 << 2)
152 #define	 CPSW_WR_C_MISC_MDIOLINK	(1 << 1)
153 #define	 CPSW_WR_C_MISC_MDIOUSER	(1 << 0)
154 
155 #define	CPSW_CPPI_RAM_OFFSET		0x2000
156 #define	CPSW_CPPI_RAM_SIZE		0x2000
157 
158 #define	CPSW_MEMWINDOW_SIZE		0x4000
159 
160 #define	 CPDMA_BD_SOP			(1 << 15)
161 #define	 CPDMA_BD_EOP			(1 << 14)
162 #define	 CPDMA_BD_OWNER			(1 << 13)
163 #define	 CPDMA_BD_EOQ			(1 << 12)
164 #define	 CPDMA_BD_TDOWNCMPLT		(1 << 11)
165 #define	 CPDMA_BD_PKT_ERR_MASK		(3 << 4)
166 #define	 CPDMA_BD_TO_PORT		(1 << 4)
167 #define	 CPDMA_BD_PORT_MASK		3
168 
169 struct cpsw_cpdma_bd {
170 	volatile uint32_t next;
171 	volatile uint32_t bufptr;
172 	volatile uint16_t buflen;
173 	volatile uint16_t bufoff;
174 	volatile uint16_t pktlen;
175 	volatile uint16_t flags;
176 };
177 
178 #endif /*_IF_CPSWREG_H */
179