• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/char/rtl8365mb/
1/*
2 * Copyright (C) 2013 Realtek Semiconductor Corp.
3 * All Rights Reserved.
4 *
5 * This program is the proprietary software of Realtek Semiconductor
6 * Corporation and/or its licensors, and only be used, duplicated,
7 * modified or distributed under the authorized license from Realtek.
8 *
9 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
10 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
11 *
12 * $Revision: 39814 $
13 * $Date: 2013-05-29 13:49:22 +0800 (������, 29 ������ 2013) $
14 *
15 * Purpose : RTL8367C switch high-level API for RTL8367C
16 * Feature : Interrupt related functions
17 *
18 */
19#include <rtl8367c_asicdrv_interrupt.h>
20/* Function Name:
21 *      rtl8367c_setAsicInterruptPolarity
22 * Description:
23 *      Set interrupt trigger polarity
24 * Input:
25 *      polarity 	- 0:pull high 1: pull low
26 * Output:
27 *      None
28 * Return:
29 *      RT_ERR_OK 	- Success
30 *      RT_ERR_SMI  - SMI access error
31 * Note:
32 *      None
33 */
34ret_t rtl8367c_setAsicInterruptPolarity(rtk_uint32 polarity)
35{
36    return rtl8367c_setAsicRegBit(RTL8367C_REG_INTR_CTRL, RTL8367C_INTR_CTRL_OFFSET, polarity);
37}
38/* Function Name:
39 *      rtl8367c_getAsicInterruptPolarity
40 * Description:
41 *      Get interrupt trigger polarity
42 * Input:
43 *      pPolarity 	- 0:pull high 1: pull low
44 * Output:
45 *      None
46 * Return:
47 *      RT_ERR_OK 	- Success
48 *      RT_ERR_SMI  - SMI access error
49 * Note:
50 *      None
51 */
52ret_t rtl8367c_getAsicInterruptPolarity(rtk_uint32* pPolarity)
53{
54    return rtl8367c_getAsicRegBit(RTL8367C_REG_INTR_CTRL, RTL8367C_INTR_CTRL_OFFSET, pPolarity);
55}
56/* Function Name:
57 *      rtl8367c_setAsicInterruptMask
58 * Description:
59 *      Set interrupt enable mask
60 * Input:
61 *      imr 	- Interrupt mask
62 * Output:
63 *      None
64 * Return:
65 *      RT_ERR_OK 	- Success
66 *      RT_ERR_SMI  - SMI access error
67 * Note:
68 *      None
69 */
70ret_t rtl8367c_setAsicInterruptMask(rtk_uint32 imr)
71{
72    return rtl8367c_setAsicReg(RTL8367C_REG_INTR_IMR, imr);
73}
74/* Function Name:
75 *      rtl8367c_getAsicInterruptMask
76 * Description:
77 *      Get interrupt enable mask
78 * Input:
79 *      pImr 	- Interrupt mask
80 * Output:
81 *      None
82 * Return:
83 *      RT_ERR_OK 	- Success
84 *      RT_ERR_SMI  - SMI access error
85 * Note:
86 *      None
87 */
88ret_t rtl8367c_getAsicInterruptMask(rtk_uint32* pImr)
89{
90    return rtl8367c_getAsicReg(RTL8367C_REG_INTR_IMR, pImr);
91}
92/* Function Name:
93 *      rtl8367c_setAsicInterruptMask
94 * Description:
95 *      Clear interrupt enable mask
96 * Input:
97 *      ims 	- Interrupt status mask
98 * Output:
99 *      None
100 * Return:
101 *      RT_ERR_OK 	- Success
102 *      RT_ERR_SMI  - SMI access error
103 * Note:
104 *   	This API can be used to clear ASIC interrupt status and register will be cleared by writting 1.
105 *    	[0]:Link change,
106 *    	[1]:Share meter exceed,
107 *    	[2]:Learn number overed,
108 *    	[3]:Speed Change,
109 *    	[4]:Tx special congestion
110 *    	[5]:1 second green feature
111 *    	[6]:loop detection
112 *    	[7]:interrupt from 8051
113 *    	[8]:Cable diagnostic finish
114 *    	[9]:ACL action interrupt trigger
115 *      [11]: Silent Start
116 */
117ret_t rtl8367c_setAsicInterruptStatus(rtk_uint32 ims)
118{
119    return rtl8367c_setAsicReg(RTL8367C_REG_INTR_IMS, ims);
120}
121/* Function Name:
122 *      rtl8367c_getAsicInterruptStatus
123 * Description:
124 *      Get interrupt enable mask
125 * Input:
126 *      pIms 	- Interrupt status mask
127 * Output:
128 *      None
129 * Return:
130 *      RT_ERR_OK 	- Success
131 *      RT_ERR_SMI  - SMI access error
132 * Note:
133 *   	None
134 */
135ret_t rtl8367c_getAsicInterruptStatus(rtk_uint32* pIms)
136{
137    return rtl8367c_getAsicReg(RTL8367C_REG_INTR_IMS, pIms);
138}
139/* Function Name:
140 *      rtl8367c_setAsicInterruptRelatedStatus
141 * Description:
142 *      Clear interrupt status
143 * Input:
144 *      type 	- per port Learn over, per-port speed change, per-port special congest, share meter exceed status
145 *      status 	- exceed status, write 1 to clear
146 * Output:
147 *      None
148 * Return:
149 *      RT_ERR_OK 			- Success
150 *      RT_ERR_SMI  		- SMI access error
151 *      RT_ERR_OUT_OF_RANGE - input parameter out of range
152 * Note:
153 *   	None
154 */
155ret_t rtl8367c_setAsicInterruptRelatedStatus(rtk_uint32 type, rtk_uint32 status)
156{
157    CONST rtk_uint32 indicatorAddress[INTRST_END] = {RTL8367C_REG_LEARN_OVER_INDICATOR,
158													RTL8367C_REG_SPEED_CHANGE_INDICATOR,
159													RTL8367C_REG_SPECIAL_CONGEST_INDICATOR,
160													RTL8367C_REG_PORT_LINKDOWN_INDICATOR,
161													RTL8367C_REG_PORT_LINKUP_INDICATOR,
162													RTL8367C_REG_METER_OVERRATE_INDICATOR0,
163													RTL8367C_REG_METER_OVERRATE_INDICATOR1,
164													RTL8367C_REG_RLDP_LOOPED_INDICATOR,
165													RTL8367C_REG_RLDP_RELEASED_INDICATOR,
166                                                    RTL8367C_REG_SYSTEM_LEARN_OVER_INDICATOR};
167
168    if(type >= INTRST_END )
169        return RT_ERR_OUT_OF_RANGE;
170
171    return rtl8367c_setAsicReg(indicatorAddress[type], status);
172}
173/* Function Name:
174 *      rtl8367c_getAsicInterruptRelatedStatus
175 * Description:
176 *      Get interrupt status
177 * Input:
178 *      type 	- per port Learn over, per-port speed change, per-port special congest, share meter exceed status
179 *      pStatus 	- exceed status, write 1 to clear
180 * Output:
181 *      None
182 * Return:
183 *      RT_ERR_OK 			- Success
184 *      RT_ERR_SMI  		- SMI access error
185 *      RT_ERR_OUT_OF_RANGE - input parameter out of range
186 * Note:
187 *   	None
188 */
189ret_t rtl8367c_getAsicInterruptRelatedStatus(rtk_uint32 type, rtk_uint32* pStatus)
190{
191    CONST rtk_uint32 indicatorAddress[INTRST_END] = {RTL8367C_REG_LEARN_OVER_INDICATOR,
192													RTL8367C_REG_SPEED_CHANGE_INDICATOR,
193													RTL8367C_REG_SPECIAL_CONGEST_INDICATOR,
194													RTL8367C_REG_PORT_LINKDOWN_INDICATOR,
195													RTL8367C_REG_PORT_LINKUP_INDICATOR,
196													RTL8367C_REG_METER_OVERRATE_INDICATOR0,
197													RTL8367C_REG_METER_OVERRATE_INDICATOR1,
198													RTL8367C_REG_RLDP_LOOPED_INDICATOR,
199													RTL8367C_REG_RLDP_RELEASED_INDICATOR,
200                                                    RTL8367C_REG_SYSTEM_LEARN_OVER_INDICATOR};
201
202    if(type >= INTRST_END )
203        return RT_ERR_OUT_OF_RANGE;
204
205    return rtl8367c_getAsicReg(indicatorAddress[type], pStatus);
206}
207
208