xref: /freebsd/sys/arm/ti/cpsw/if_cpswreg.h (revision ae6aefaf57b554aa74764639426e68ecf7a32b37)
1e53470feSOleksandr Tymoshenko /*-
2e53470feSOleksandr Tymoshenko  * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org>
3e53470feSOleksandr Tymoshenko  * All rights reserved.
4e53470feSOleksandr Tymoshenko  *
5e53470feSOleksandr Tymoshenko  * Redistribution and use in source and binary forms, with or without
6e53470feSOleksandr Tymoshenko  * modification, are permitted provided that the following conditions
7e53470feSOleksandr Tymoshenko  * are met:
8e53470feSOleksandr Tymoshenko  * 1. Redistributions of source code must retain the above copyright
9e53470feSOleksandr Tymoshenko  *    notice, this list of conditions and the following disclaimer.
10e53470feSOleksandr Tymoshenko  * 2. Redistributions in binary form must reproduce the above copyright
11e53470feSOleksandr Tymoshenko  *    notice, this list of conditions and the following disclaimer in the
12e53470feSOleksandr Tymoshenko  *    documentation and/or other materials provided with the distribution.
13e53470feSOleksandr Tymoshenko  *
14e53470feSOleksandr Tymoshenko  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15e53470feSOleksandr Tymoshenko  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16e53470feSOleksandr Tymoshenko  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17e53470feSOleksandr Tymoshenko  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18e53470feSOleksandr Tymoshenko  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19e53470feSOleksandr Tymoshenko  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20e53470feSOleksandr Tymoshenko  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21e53470feSOleksandr Tymoshenko  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22e53470feSOleksandr Tymoshenko  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23e53470feSOleksandr Tymoshenko  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24e53470feSOleksandr Tymoshenko  * SUCH DAMAGE.
25e53470feSOleksandr Tymoshenko  *
26e53470feSOleksandr Tymoshenko  * $FreeBSD$
27e53470feSOleksandr Tymoshenko  */
28e53470feSOleksandr Tymoshenko 
29e53470feSOleksandr Tymoshenko #ifndef	_IF_CPSWREG_H
30e53470feSOleksandr Tymoshenko #define	_IF_CPSWREG_H
31e53470feSOleksandr Tymoshenko 
32e53470feSOleksandr Tymoshenko #define CPSW_SS_OFFSET			0x0000
33e53470feSOleksandr Tymoshenko #define CPSW_SS_IDVER			(CPSW_SS_OFFSET + 0x00)
34e53470feSOleksandr Tymoshenko #define CPSW_SS_SOFT_RESET		(CPSW_SS_OFFSET + 0x08)
35e53470feSOleksandr Tymoshenko #define CPSW_SS_STAT_PORT_EN		(CPSW_SS_OFFSET + 0x0C)
36e53470feSOleksandr Tymoshenko #define CPSW_SS_PTYPE			(CPSW_SS_OFFSET + 0x10)
37*ae6aefafSTim Kientzle #define	CPSW_SS_FLOW_CONTROL		(CPSW_SS_OFFSET + 0x24)
38e53470feSOleksandr Tymoshenko 
39e53470feSOleksandr Tymoshenko #define CPSW_PORT_OFFSET		0x0100
40*ae6aefafSTim Kientzle #define	CPSW_PORT_P_MAX_BLKS(p)		(CPSW_PORT_OFFSET + 0x08 + ((p) * 0x100))
41*ae6aefafSTim Kientzle #define	CPSW_PORT_P_BLK_CNT(p)		(CPSW_PORT_OFFSET + 0x0C + ((p) * 0x100))
42e53470feSOleksandr Tymoshenko #define CPSW_PORT_P_TX_PRI_MAP(p)	(CPSW_PORT_OFFSET + 0x118 + ((p-1) * 0x100))
43e53470feSOleksandr Tymoshenko #define CPSW_PORT_P0_CPDMA_TX_PRI_MAP	(CPSW_PORT_OFFSET + 0x01C)
44e53470feSOleksandr Tymoshenko #define CPSW_PORT_P0_CPDMA_RX_CH_MAP	(CPSW_PORT_OFFSET + 0x020)
45e53470feSOleksandr Tymoshenko #define CPSW_PORT_P_SA_LO(p)		(CPSW_PORT_OFFSET + 0x120 + ((p-1) * 0x100))
46e53470feSOleksandr Tymoshenko #define CPSW_PORT_P_SA_HI(p)		(CPSW_PORT_OFFSET + 0x124 + ((p-1) * 0x100))
47e53470feSOleksandr Tymoshenko 
48e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_OFFSET		0x0800
49e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_TX_CONTROL		(CPSW_CPDMA_OFFSET + 0x04)
505bf32555STim Kientzle #define CPSW_CPDMA_TX_TEARDOWN		(CPSW_CPDMA_OFFSET + 0x08)
51e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_CONTROL		(CPSW_CPDMA_OFFSET + 0x14)
525bf32555STim Kientzle #define CPSW_CPDMA_RX_TEARDOWN		(CPSW_CPDMA_OFFSET + 0x18)
53e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_SOFT_RESET		(CPSW_CPDMA_OFFSET + 0x1c)
54e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_DMACONTROL		(CPSW_CPDMA_OFFSET + 0x20)
55e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_DMASTATUS		(CPSW_CPDMA_OFFSET + 0x24)
56e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_BUFFER_OFFSET	(CPSW_CPDMA_OFFSET + 0x28)
57e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_TX_INTSTAT_RAW	(CPSW_CPDMA_OFFSET + 0x80)
58e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_TX_INTSTAT_MASKED	(CPSW_CPDMA_OFFSET + 0x84)
59e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_TX_INTMASK_SET	(CPSW_CPDMA_OFFSET + 0x88)
60e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_TX_INTMASK_CLEAR	(CPSW_CPDMA_OFFSET + 0x8C)
61e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_CPDMA_EOI_VECTOR	(CPSW_CPDMA_OFFSET + 0x94)
62e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_INTSTAT_RAW	(CPSW_CPDMA_OFFSET + 0xA0)
63e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_INTSTAT_MASKED	(CPSW_CPDMA_OFFSET + 0xA4)
64e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_INTMASK_SET	(CPSW_CPDMA_OFFSET + 0xA8)
65e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_INTMASK_CLEAR	(CPSW_CPDMA_OFFSET + 0xAc)
66e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_DMA_INTSTAT_RAW	(CPSW_CPDMA_OFFSET + 0xB0)
67e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_DMA_INTSTAT_MASKED	(CPSW_CPDMA_OFFSET + 0xB4)
68e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_DMA_INTMASK_SET	(CPSW_CPDMA_OFFSET + 0xB8)
69e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_DMA_INTMASK_CLEAR	(CPSW_CPDMA_OFFSET + 0xBC)
70e53470feSOleksandr Tymoshenko #define CPSW_CPDMA_RX_FREEBUFFER(p)	(CPSW_CPDMA_OFFSET + 0x0e0 + ((p) * 0x04))
715bf32555STim Kientzle 
725bf32555STim Kientzle #define CPSW_STATS_OFFSET		0x0900
735bf32555STim Kientzle 
745bf32555STim Kientzle #define CPSW_STATERAM_OFFSET		0x0A00
755bf32555STim Kientzle #define CPSW_CPDMA_TX_HDP(p)		(CPSW_STATERAM_OFFSET + 0x00 + ((p) * 0x04))
765bf32555STim Kientzle #define CPSW_CPDMA_RX_HDP(p)		(CPSW_STATERAM_OFFSET + 0x20 + ((p) * 0x04))
775bf32555STim Kientzle #define CPSW_CPDMA_TX_CP(p)		(CPSW_STATERAM_OFFSET + 0x40 + ((p) * 0x04))
785bf32555STim Kientzle #define CPSW_CPDMA_RX_CP(p)		(CPSW_STATERAM_OFFSET + 0x60 + ((p) * 0x04))
79e53470feSOleksandr Tymoshenko 
80e53470feSOleksandr Tymoshenko #define CPSW_CPTS_OFFSET		0x0C00
81e53470feSOleksandr Tymoshenko 
82e53470feSOleksandr Tymoshenko #define CPSW_ALE_OFFSET			0x0D00
83e53470feSOleksandr Tymoshenko #define CPSW_ALE_CONTROL		(CPSW_ALE_OFFSET + 0x08)
84e53470feSOleksandr Tymoshenko #define CPSW_ALE_TBLCTL			(CPSW_ALE_OFFSET + 0x20)
85e53470feSOleksandr Tymoshenko #define CPSW_ALE_TBLW2			(CPSW_ALE_OFFSET + 0x34)
86e53470feSOleksandr Tymoshenko #define CPSW_ALE_TBLW1			(CPSW_ALE_OFFSET + 0x38)
87e53470feSOleksandr Tymoshenko #define CPSW_ALE_TBLW0			(CPSW_ALE_OFFSET + 0x3C)
88e53470feSOleksandr Tymoshenko #define CPSW_ALE_PORTCTL(p)		(CPSW_ALE_OFFSET + 0x40 + ((p) * 0x04))
89e53470feSOleksandr Tymoshenko 
90*ae6aefafSTim Kientzle /* SL1 is at 0x0D80, SL2 is at 0x0DC0 */
91e53470feSOleksandr Tymoshenko #define CPSW_SL_OFFSET			0x0D80
92e53470feSOleksandr Tymoshenko #define CPSW_SL_MACCONTROL(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x04)
93*ae6aefafSTim Kientzle #define CPSW_SL_MACSTATUS(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x08)
94e53470feSOleksandr Tymoshenko #define CPSW_SL_SOFT_RESET(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x0C)
95e53470feSOleksandr Tymoshenko #define CPSW_SL_RX_MAXLEN(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x10)
96*ae6aefafSTim Kientzle #define CPSW_SL_RX_PAUSE(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x18)
97*ae6aefafSTim Kientzle #define CPSW_SL_TX_PAUSE(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x1C)
98e53470feSOleksandr Tymoshenko #define CPSW_SL_RX_PRI_MAP(p)		(CPSW_SL_OFFSET + (0x40 * (p)) + 0x24)
99e53470feSOleksandr Tymoshenko 
100e53470feSOleksandr Tymoshenko #define MDIO_OFFSET			0x1000
101e53470feSOleksandr Tymoshenko #define MDIOCONTROL			(MDIO_OFFSET + 0x04)
102e53470feSOleksandr Tymoshenko #define MDIOUSERACCESS0			(MDIO_OFFSET + 0x80)
103e53470feSOleksandr Tymoshenko #define MDIOUSERPHYSEL0			(MDIO_OFFSET + 0x84)
104e53470feSOleksandr Tymoshenko 
105e53470feSOleksandr Tymoshenko #define CPSW_WR_OFFSET			0x1200
106e53470feSOleksandr Tymoshenko #define CPSW_WR_SOFT_RESET		(CPSW_WR_OFFSET + 0x04)
107e53470feSOleksandr Tymoshenko #define CPSW_WR_CONTROL			(CPSW_WR_OFFSET + 0x08)
108e53470feSOleksandr Tymoshenko #define CPSW_WR_INT_CONTROL		(CPSW_WR_OFFSET + 0x0c)
109e53470feSOleksandr Tymoshenko #define CPSW_WR_C_RX_THRESH_EN(p)	(CPSW_WR_OFFSET + (0x10 * (p)) + 0x10)
110e53470feSOleksandr Tymoshenko #define CPSW_WR_C_RX_EN(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x14)
111e53470feSOleksandr Tymoshenko #define CPSW_WR_C_TX_EN(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x18)
112e53470feSOleksandr Tymoshenko #define CPSW_WR_C_MISC_EN(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x1C)
113e53470feSOleksandr Tymoshenko #define CPSW_WR_C_RX_THRESH_STAT(p)	(CPSW_WR_OFFSET + (0x10 * (p)) + 0x40)
114e53470feSOleksandr Tymoshenko #define CPSW_WR_C_RX_STAT(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x44)
115e53470feSOleksandr Tymoshenko #define CPSW_WR_C_TX_STAT(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x48)
116e53470feSOleksandr Tymoshenko #define CPSW_WR_C_MISC_STAT(p)		(CPSW_WR_OFFSET + (0x10 * (p)) + 0x4C)
117e53470feSOleksandr Tymoshenko 
118e53470feSOleksandr Tymoshenko #define CPSW_CPPI_RAM_OFFSET		0x2000
119*ae6aefafSTim Kientzle #define	CPSW_CPPI_RAM_SIZE		0x2000
120*ae6aefafSTim Kientzle 
121*ae6aefafSTim Kientzle #define CPDMA_BD_SOP		(1<<15)
122*ae6aefafSTim Kientzle #define CPDMA_BD_EOP		(1<<14)
123*ae6aefafSTim Kientzle #define CPDMA_BD_OWNER		(1<<13)
124*ae6aefafSTim Kientzle #define CPDMA_BD_EOQ		(1<<12)
125*ae6aefafSTim Kientzle #define CPDMA_BD_TDOWNCMPLT	(1<<11)
126*ae6aefafSTim Kientzle #define CPDMA_BD_PKT_ERR_MASK	(3<< 4)
127*ae6aefafSTim Kientzle 
128*ae6aefafSTim Kientzle struct cpsw_cpdma_bd {
129*ae6aefafSTim Kientzle 	volatile uint32_t next;
130*ae6aefafSTim Kientzle 	volatile uint32_t bufptr;
131*ae6aefafSTim Kientzle 	volatile uint16_t buflen;
132*ae6aefafSTim Kientzle 	volatile uint16_t bufoff;
133*ae6aefafSTim Kientzle 	volatile uint16_t pktlen;
134*ae6aefafSTim Kientzle 	volatile uint16_t flags;
135*ae6aefafSTim Kientzle };
136e53470feSOleksandr Tymoshenko 
137e53470feSOleksandr Tymoshenko #endif /*_IF_CPSWREG_H */
138