strip the kernel version suffix from target directories, except for brcm-2.4 (the...
[15.05/openwrt.git] / target / linux / amazon / files / include / asm-mips / amazon / adm6996.h
1 /******************************************************************************
2      Copyright (c) 2004, Infineon Technologies.  All rights reserved.
3
4                                No Warranty
5    Because the program is licensed free of charge, there is no warranty for
6    the program, to the extent permitted by applicable law.  Except when
7    otherwise stated in writing the copyright holders and/or other parties
8    provide the program "as is" without warranty of any kind, either
9    expressed or implied, including, but not limited to, the implied
10    warranties of merchantability and fitness for a particular purpose. The
11    entire risk as to the quality and performance of the program is with
12    you.  should the program prove defective, you assume the cost of all
13    necessary servicing, repair or correction.
14
15    In no event unless required by applicable law or agreed to in writing
16    will any copyright holder, or any other party who may modify and/or
17    redistribute the program as permitted above, be liable to you for
18    damages, including any general, special, incidental or consequential
19    damages arising out of the use or inability to use the program
20    (including but not limited to loss of data or data being rendered
21    inaccurate or losses sustained by you or third parties or a failure of
22    the program to operate with any other programs), even if such holder or
23    other party has been advised of the possibility of such damages.
24  ******************************************************************************
25    Module      : ifx_swdrv.h
26    Date        : 2004-09-01
27    Description : JoeLin
28    Remarks:
29
30  *****************************************************************************/
31
32 #ifndef _ADM_6996_MODULE_H_
33 #define _ADM_6996_MODULE_H_
34
35 #include <asm/amazon/amazon.h>
36
37 #define ifx_printf(x)       printk x
38
39 /* command codes */
40 #define ADM_SW_SMI_READ     0x02
41 #define ADM_SW_SMI_WRITE    0x01
42 #define ADM_SW_SMI_START    0x01
43
44 #define ADM_SW_EEPROM_WRITE     0x01
45 #define ADM_SW_EEPROM_WRITE_ENABLE  0x03
46 #define ADM_SW_EEPROM_WRITE_DISABLE 0x00
47 #define EEPROM_TYPE     8   /* for 93C66 */
48
49 /* bit masks */
50 #define ADM_SW_BIT_MASK_1   0x00000001
51 #define ADM_SW_BIT_MASK_2   0x00000002
52 #define ADM_SW_BIT_MASK_4   0x00000008
53 #define ADM_SW_BIT_MASK_10  0x00000200
54 #define ADM_SW_BIT_MASK_16  0x00008000
55 #define ADM_SW_BIT_MASK_32  0x80000000
56
57 /* delay timers */
58 #define ADM_SW_MDC_DOWN_DELAY   5
59 #define ADM_SW_MDC_UP_DELAY 5
60 #define ADM_SW_CS_DELAY     5
61
62 /* MDIO modes */
63 #define ADM_SW_MDIO_OUTPUT  1
64 #define ADM_SW_MDIO_INPUT   0
65
66 #define ADM_SW_MAX_PORT_NUM 5
67 #define ADM_SW_MAX_VLAN_NUM 15
68
69 /* registers */
70 #define ADM_SW_PORT0_CONF   0x1
71 #define ADM_SW_PORT1_CONF   0x3
72 #define ADM_SW_PORT2_CONF   0x5
73 #define ADM_SW_PORT3_CONF   0x7
74 #define ADM_SW_PORT4_CONF   0x8
75 #define ADM_SW_PORT5_CONF   0x9
76 #define ADM_SW_VLAN_MODE    0x11
77 #define ADM_SW_MAC_LOCK     0x12
78 #define ADM_SW_VLAN0_CONF   0x13
79 #define ADM_SW_PORT0_PVID   0x28
80 #define ADM_SW_PORT1_PVID   0x29
81 #define ADM_SW_PORT2_PVID   0x2a
82 #define ADM_SW_PORT34_PVID  0x2b
83 #define ADM_SW_PORT5_PVID   0x2c
84 #define ADM_SW_PHY_RESET    0x2f
85 #define ADM_SW_MISC_CONF    0x30
86 #define ADM_SW_BNDWDH_CTL0  0x31
87 #define ADM_SW_BNDWDH_CTL1  0x32
88 #define ADM_SW_BNDWDH_CTL_ENA   0x33
89
90 /* port modes */
91 #define ADM_SW_PORT_FLOWCTL 0x1 /* 802.3x flow control */
92 #define ADM_SW_PORT_AN      0x2 /* auto negotiation */
93 #define ADM_SW_PORT_100M    0x4 /* 100M */
94 #define ADM_SW_PORT_FULL    0x8 /* full duplex */
95 #define ADM_SW_PORT_TAG     0x10    /* output tag on */
96 #define ADM_SW_PORT_DISABLE 0x20    /* disable port */
97 #define ADM_SW_PORT_TOS     0x40    /* TOS first */
98 #define ADM_SW_PORT_PPRI    0x80    /* port based priority first */
99 #define ADM_SW_PORT_MDIX    0x8000  /* auto MDIX on */
100 #define ADM_SW_PORT_PVID_SHIFT  10
101 #define ADM_SW_PORT_PVID_BITS   4
102
103 /* VLAN */
104 #define ADM_SW_VLAN_PORT0   0x1
105 #define ADM_SW_VLAN_PORT1   0x2
106 #define ADM_SW_VLAN_PORT2   0x10
107 #define ADM_SW_VLAN_PORT3   0x40
108 #define ADM_SW_VLAN_PORT4   0x80
109 #define ADM_SW_VLAN_PORT5   0x100
110
111
112 /* GPIO 012 enabled, output mode */
113 #define GPIO_ENABLEBITS 0x000700f8
114
115 /*
116   define AMAZON GPIO port to ADM6996 EEPROM interface
117   MDIO ->   EEDI        GPIO 16, AMAZON GPIO P1.0, bi-direction
118   MDC ->    EESK        GPIO 17, AMAZON GPIO P1.1, output only
119   MDCS ->   EECS        GPIO 18, AMAZON GPIO P1.2, output only
120             EEDO        GPIO 15, AMAZON GPIO P0.15, do not need this one! */
121
122 #define GPIO_MDIO   1           //P1.0
123 #define GPIO_MDC    2           //P1.1
124 #define GPIO_MDCS   4           //P1.2
125
126 //joelin #define GPIO_MDIO   0
127 //joelin #define GPIO_MDC    5   /* PORT 0 GPIO5 */
128 //joelin #define GPIO_MDCS   6   /* PORT 0 GPIO6 */
129
130
131 #define MDIO_INPUT  0x00000001
132 #define MDIO_OUTPUT_EN  0x00010000
133
134
135 /* type definitions */
136 typedef unsigned char U8;
137 typedef unsigned short U16;
138 typedef unsigned int U32;
139
140 typedef struct _REGRW_
141 {
142   unsigned int addr;
143   unsigned int value;
144   unsigned int mode;
145 }REGRW, *PREGRW;
146
147 //joelin adm6996i
148 typedef struct _MACENTRY_
149 {
150         unsigned char mac_addr[6];
151         unsigned long fid:4;
152             unsigned long portmap:6;
153         union  {
154                 unsigned long age_timer:9;
155                 unsigned long info_ctrl:9;
156         } ctrl;
157         unsigned long occupy:1;
158         unsigned long info_type:1;
159         unsigned long bad:1;
160         unsigned long result:3;//000:command ok ,001:all entry used,010:Entry Not found  ,011:try next entry ,101:command error
161         
162  }MACENTRY, *PMACENTRY;
163 typedef struct _PROTOCOLFILTER_
164 {
165         int protocol_filter_num;//[0~7]
166         int ip_p; //Value Compared with Protocol in IP Heade[7:0]
167         char action:2;//Action for protocol Filter .
168 //00 = Protocol Portmap is Default Output Ports.
169 //01 = Protocol Portmap is 6'b0.
170 //10 = Protocol Portmap is the CPU port if the incoming port 
171 //is not the CPU port. But if the incoming port is the CPU port, then Type Portmap contains Default Output Ports, excluding the CPU port.
172  }PROTOCOLFILTER, *PPROTOCOLFILTER;
173
174 //joelin adm6996i
175
176 /* Santosh: for IGMP proxy/snooping */
177
178 //050614:fchang int adm_process_mac_table_request (unsigned int cmd, struct _MACENTRY_ *mac);
179 //050614:fchang int adm_process_protocol_filter_request (unsigned int cmd, struct _PROTOCOLFILTER_ *filter);
180
181
182 /* IOCTL keys */
183 #define KEY_IOCTL_ADM_REGRW             0x01
184 #define KEY_IOCTL_ADM_SW_REGRW          0x02
185 #define KEY_IOCTL_ADM_SW_PORTSTS        0x03
186 #define KEY_IOCTL_ADM_SW_INIT           0x04
187 //for adm6996i-start
188 #define KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_ADD             0x05
189 #define KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_DEL             0x06
190 #define KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_GET_INIT        0x07
191 #define KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_GET_MORE        0x08
192 #define KEY_IOCTL_ADM_SW_IOCTL_FILTER_ADD               0x09
193 #define KEY_IOCTL_ADM_SW_IOCTL_FILTER_DEL               0x0a
194 #define KEY_IOCTL_ADM_SW_IOCTL_FILTER_GET               0x0b
195  
196 //adm6996i #define KEY_IOCTL_MAX_KEY       0x05
197 #define KEY_IOCTL_MAX_KEY       0x0c
198 //for adm6996i-end
199 /* IOCTL MAGIC */
200 #define ADM_MAGIC  ('a'|'d'|'m'|'t'|'e'|'k')
201
202 /* IOCTL parameters */
203 #define ADM_IOCTL_REGRW         _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_REGRW, REGRW)
204 #define ADM_SW_IOCTL_REGRW      _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_REGRW, REGRW)
205 #define ADM_SW_IOCTL_PORTSTS    _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_PORTSTS, NULL)
206 #define ADM_SW_IOCTL_INIT       _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_INIT, NULL)
207
208
209 //6996i-stat
210 #define ADM_SW_IOCTL_MACENTRY_ADD           _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_ADD,MACENTRY)
211 #define ADM_SW_IOCTL_MACENTRY_DEL           _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_DEL,MACENTRY)
212 #define ADM_SW_IOCTL_MACENTRY_GET_INIT      _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_GET_INIT,MACENTRY)
213 #define ADM_SW_IOCTL_MACENTRY_GET_MORE      _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_MACENTRY_GET_MORE,MACENTRY)
214 #define ADM_SW_IOCTL_FILTER_ADD             _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_FILTER_ADD,PROTOCOLFILTER)  
215 #define ADM_SW_IOCTL_FILTER_DEL             _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_FILTER_DEL,PROTOCOLFILTER)
216 #define ADM_SW_IOCTL_FILTER_GET             _IOWR(ADM_MAGIC, KEY_IOCTL_ADM_SW_IOCTL_FILTER_GET,PROTOCOLFILTER)  
217  
218 //6996i-end
219
220
221 #define REG_READ    0x0
222 #define REG_WRITE   0x1
223
224 /* undefine symbol */
225 #define AMAZON_SW_REG(reg)  *((volatile U32*)(reg))
226 //#define GPIO0_INPUT_MASK    0
227 //#define GPIO_conf0_REG      0x12345678
228 //#define GPIO_SET_HI
229 //#define GPIO_SET_LOW
230
231 #endif
232 /* _ADM_6996_MODULE_H_ */