2 * Copyright (C) 2013 Realtek Semiconductor Corp.
5 * Unless you and Realtek execute a separate written software license
6 * agreement governing use of this software, this software is licensed
7 * to you under the terms of the GNU General Public License version 2,
8 * available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
11 * $Date: 2017-03-08 15:13:58 +0800 (週三, 08 三月 2017) $
13 * Purpose : RTL8367C switch high-level API for RTL8367C
14 * Feature : Interrupt related functions
17 #include <rtl8367c_asicdrv_interrupt.h>
19 * rtl8367c_setAsicInterruptPolarity
21 * Set interrupt trigger polarity
23 * polarity - 0:pull high 1: pull low
28 * RT_ERR_SMI - SMI access error
32 ret_t
rtl8367c_setAsicInterruptPolarity(rtk_uint32 polarity
)
34 return rtl8367c_setAsicRegBit(RTL8367C_REG_INTR_CTRL
, RTL8367C_INTR_CTRL_OFFSET
, polarity
);
37 * rtl8367c_getAsicInterruptPolarity
39 * Get interrupt trigger polarity
41 * pPolarity - 0:pull high 1: pull low
46 * RT_ERR_SMI - SMI access error
50 ret_t
rtl8367c_getAsicInterruptPolarity(rtk_uint32
* pPolarity
)
52 return rtl8367c_getAsicRegBit(RTL8367C_REG_INTR_CTRL
, RTL8367C_INTR_CTRL_OFFSET
, pPolarity
);
55 * rtl8367c_setAsicInterruptMask
57 * Set interrupt enable mask
59 * imr - Interrupt mask
64 * RT_ERR_SMI - SMI access error
68 ret_t
rtl8367c_setAsicInterruptMask(rtk_uint32 imr
)
70 return rtl8367c_setAsicReg(RTL8367C_REG_INTR_IMR
, imr
);
73 * rtl8367c_getAsicInterruptMask
75 * Get interrupt enable mask
77 * pImr - Interrupt mask
82 * RT_ERR_SMI - SMI access error
86 ret_t
rtl8367c_getAsicInterruptMask(rtk_uint32
* pImr
)
88 return rtl8367c_getAsicReg(RTL8367C_REG_INTR_IMR
, pImr
);
91 * rtl8367c_setAsicInterruptMask
93 * Clear interrupt enable mask
95 * ims - Interrupt status mask
100 * RT_ERR_SMI - SMI access error
102 * This API can be used to clear ASIC interrupt status and register will be cleared by writing 1.
104 * [1]:Share meter exceed,
105 * [2]:Learn number over,
107 * [4]:Tx special congestion
108 * [5]:1 second green feature
110 * [7]:interrupt from 8051
111 * [8]:Cable diagnostic finish
112 * [9]:ACL action interrupt trigger
115 ret_t
rtl8367c_setAsicInterruptStatus(rtk_uint32 ims
)
117 return rtl8367c_setAsicReg(RTL8367C_REG_INTR_IMS
, ims
);
120 * rtl8367c_getAsicInterruptStatus
122 * Get interrupt enable mask
124 * pIms - Interrupt status mask
128 * RT_ERR_OK - Success
129 * RT_ERR_SMI - SMI access error
133 ret_t
rtl8367c_getAsicInterruptStatus(rtk_uint32
* pIms
)
135 return rtl8367c_getAsicReg(RTL8367C_REG_INTR_IMS
, pIms
);
138 * rtl8367c_setAsicInterruptRelatedStatus
140 * Clear interrupt status
142 * type - per port Learn over, per-port speed change, per-port special congest, share meter exceed status
143 * status - exceed status, write 1 to clear
147 * RT_ERR_OK - Success
148 * RT_ERR_SMI - SMI access error
149 * RT_ERR_OUT_OF_RANGE - input parameter out of range
153 ret_t
rtl8367c_setAsicInterruptRelatedStatus(rtk_uint32 type
, rtk_uint32 status
)
155 CONST rtk_uint32 indicatorAddress
[INTRST_END
] = {RTL8367C_REG_LEARN_OVER_INDICATOR
,
156 RTL8367C_REG_SPEED_CHANGE_INDICATOR
,
157 RTL8367C_REG_SPECIAL_CONGEST_INDICATOR
,
158 RTL8367C_REG_PORT_LINKDOWN_INDICATOR
,
159 RTL8367C_REG_PORT_LINKUP_INDICATOR
,
160 RTL8367C_REG_METER_OVERRATE_INDICATOR0
,
161 RTL8367C_REG_METER_OVERRATE_INDICATOR1
,
162 RTL8367C_REG_RLDP_LOOPED_INDICATOR
,
163 RTL8367C_REG_RLDP_RELEASED_INDICATOR
,
164 RTL8367C_REG_SYSTEM_LEARN_OVER_INDICATOR
};
166 if(type
>= INTRST_END
)
167 return RT_ERR_OUT_OF_RANGE
;
169 return rtl8367c_setAsicReg(indicatorAddress
[type
], status
);
172 * rtl8367c_getAsicInterruptRelatedStatus
174 * Get interrupt status
176 * type - per port Learn over, per-port speed change, per-port special congest, share meter exceed status
177 * pStatus - exceed status, write 1 to clear
181 * RT_ERR_OK - Success
182 * RT_ERR_SMI - SMI access error
183 * RT_ERR_OUT_OF_RANGE - input parameter out of range
187 ret_t
rtl8367c_getAsicInterruptRelatedStatus(rtk_uint32 type
, rtk_uint32
* pStatus
)
189 CONST rtk_uint32 indicatorAddress
[INTRST_END
] = {RTL8367C_REG_LEARN_OVER_INDICATOR
,
190 RTL8367C_REG_SPEED_CHANGE_INDICATOR
,
191 RTL8367C_REG_SPECIAL_CONGEST_INDICATOR
,
192 RTL8367C_REG_PORT_LINKDOWN_INDICATOR
,
193 RTL8367C_REG_PORT_LINKUP_INDICATOR
,
194 RTL8367C_REG_METER_OVERRATE_INDICATOR0
,
195 RTL8367C_REG_METER_OVERRATE_INDICATOR1
,
196 RTL8367C_REG_RLDP_LOOPED_INDICATOR
,
197 RTL8367C_REG_RLDP_RELEASED_INDICATOR
,
198 RTL8367C_REG_SYSTEM_LEARN_OVER_INDICATOR
};
200 if(type
>= INTRST_END
)
201 return RT_ERR_OUT_OF_RANGE
;
203 return rtl8367c_getAsicReg(indicatorAddress
[type
], pStatus
);