a0fc1e44ec068e17e208c64d32744f9a65041074
[openwrt/openwrt.git] / target / linux / adm5120-2.6 / files / include / asm-mips / mach-adm5120 / adm5120_switch.h
1 /*
2 * ADM5120 ethernet switch definitions
3 *
4 * This header file defines the hardware registers of the ADM5120 SoC
5 * built-in Ethernet switch.
6 *
7 * Copyright (C) 2007 OpenWrt.org
8 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 */
25
26 #ifndef _ADM5120_SWITCH_H
27 #define _ADM5120_SWITCH_H
28
29 #define BITMASK(len) ((1 << (len))-1)
30 #define ONEBIT(at) (1 << (at))
31
32 /* Switch register offsets */
33 #define SWITCH_REG_CODE 0x0000
34 #define SWITCH_REG_SOFT_RESET 0x0004
35 #define SWITCH_REG_MEMCTRL 0x001C
36 #define SWITCH_REG_CPUP_CONF 0x0024
37 #define SWITCH_REG_PORT_CONF0 0x0028
38 #define SWITCH_REG_PORT_CONF1 0x002C
39 #define SWITCH_REG_PORT_CONF2 0x0030
40 #define SWITCH_REG_VLAN_G1 0x0040
41 #define SWITCH_REG_VLAN_G2 0x0044
42 #define SWITCH_REG_SEND_TRIG 0x0048
43 #define SWITCH_REG_MAC_WT0 0x0058
44 #define SWITCH_REG_MAC_WT1 0x005C
45 #define SWITCH_REG_PHY_CNTL0 0x0068
46 #define SWITCH_REG_PHY_CNTL1 0x006C
47 #define SWITCH_REG_PHY_CNTL2 0x007C
48 #define SWITCH_REG_PHY_CNTL3 0x0080
49 #define SWITCH_REG_PRI_CNTL 0x0084
50 #define SWITCH_REG_INT_STATUS 0x00B0
51 #define SWITCH_REG_INT_MASK 0x00B4
52 #define SWITCH_REG_GPIO_CONF0 0x00B8
53 #define SWITCH_REG_GPIO_CONF2 0x00BC
54 #define SWITCH_REG_WDOG0 0x00C0
55 #define SWITCH_REG_WDOG1 0x00C4
56 #define SWITCH_REG_PHY_CNTL4 0x00A0
57
58 #define SWITCH_REG_SEND_HBADDR 0x00D0
59 #define SWITCH_REG_SEND_LBADDR 0x00D4
60 #define SWITCH_REG_RECV_HBADDR 0x00D8
61 #define SWITCH_REG_RECV_LBADDR 0x00DC
62
63 #define SWITCH_REG_TIMER_INT 0x00F0
64 #define SWITCH_REG_TIMER 0x00F4
65
66 #define SWITCH_REG_PORT0_LED 0x0100
67 #define SWITCH_REG_PORT1_LED 0x0104
68 #define SWITCH_REG_PORT2_LED 0x0108
69 #define SWITCH_REG_PORT3_LED 0x010C
70 #define SWITCH_REG_PORT4_LED 0x0110
71
72 /* CODE register bits */
73 #define CODE_PC_MASK BITMASK(16) /* Product Code */
74 #define CODE_REV_SHIFT 16
75 #define CODE_REV_MASK BITMASK(4) /* Product Revision */
76 #define CODE_CLKS_SHIFT 20
77 #define CODE_CLKS_MASK BITMASK(2) /* Clock Speed */
78 #define CODE_CLKS_175 0 /* 175 MHz */
79 #define CODE_CLKS_200 1 /* 200 MHz */
80 #define CODE_CLKS_225 2 /* 225 MHz */
81 #define CODE_CLKS_250 3 /* 250 MHz */
82 #define CODE_NAB ONEBIT(24) /* NAND boot */
83 #define CODE_PK_MASK BITMASK(1) /* Package type */
84 #define CODE_PK_SHIFT 29
85 #define CODE_PK_BGA 0 /* BGA package */
86 #define CODE_PK_PQFP 1 /* PQFP package */
87
88 /* GPIO_CONF0 register bits */
89 #define GPIO_CONF0_MASK BITMASK(8)
90 #define GPIO_CONF0_IM_SHIFT 0
91 #define GPIO_CONF0_IV_SHIFT 8
92 #define GPIO_CONF0_OE_SHIFT 16
93 #define GPIO_CONF0_OV_SHIFT 24
94 #define GPIO_CONF0_IM_MASK (0xFF << GPIO_CONF0_IM_SHIFT)
95 #define GPIO_CONF0_IV_MASK (0xFF << GPIO_CONF0_IV_SHIFT)
96 #define GPIO_CONF0_OE_MASK (0xFF << GPIO_CONF0_OE_SHIFT)
97 #define GPIO_CONF0_OV_MASK (0xFF << GPIO_CONF0_OV_SHIFT)
98
99 /* PORTx_LED register bits */
100 #define LED_MODE_MASK BITMASK(4)
101 #define LED_MODE_INPUT 0
102 #define LED_MODE_FLASH 1
103 #define LED_MODE_OUT_HIGH 2
104 #define LED_MODE_OUT_LOW 3
105 #define LED_MODE_LINK 4
106 #define LED_MODE_SPEED 5
107 #define LED_MODE_DUPLEX 6
108 #define LED_MODE_ACT 7
109 #define LED_MODE_COLL 8
110 #define LED_MODE_LINK_ACT 9
111 #define LED_MODE_DUPLEX_COLL 10
112 #define LED_MODE_10M_ACT 11
113 #define LED_MODE_100M_ACT 12
114 #define LED0_MODE_SHIFT 0 /* LED0 mode shift */
115 #define LED1_MODE_SHIFT 4 /* LED1 mode shift */
116 #define LED2_MODE_SHIFT 8 /* LED2 mode shift */
117 #define LED0_IV_SHIFT 12 /* LED0 input value shift */
118 #define LED1_IV_SHIFT 13 /* LED1 input value shift */
119 #define LED2_IV_SHIFT 14 /* LED2 input value shift */
120
121 #endif /* _ADM5120_SWITCH_H */