-
Notifications
You must be signed in to change notification settings - Fork 1
/
rtl8367c_asicdrv_eee.c
165 lines (134 loc) · 4.55 KB
/
rtl8367c_asicdrv_eee.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* Copyright (C) 2013 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision: 80668 $
* $Date: 2017-07-19 14:21:43 +0800 (週三, 19 七月 2017) $
*
* Purpose : RTL8370 switch high-level API for RTL8367C
* Feature :
*
*/
#include "rtl8367c_asicdrv_eee.h"
#include "rtl8367c_asicdrv_phy.h"
/*
@func ret_t | rtl8367c_setAsicEee100M | Set eee force mode function enable/disable.
@parm rtk_uint32 | port | The port number.
@parm rtk_uint32 | enabled | 1: enabled, 0: disabled.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
This API set the 100M EEE enable function.
*/
ret_t rtl8367c_setAsicEee100M(rtk_uint32 port, rtk_uint32 enable)
{
rtk_api_ret_t retVal;
rtk_uint32 regData;
if (port >= RTL8367C_PORTNO)
return RT_ERR_PORT_ID;
if (enable > 1)
return RT_ERR_INPUT;
if ((retVal = rtl8367c_getAsicPHYOCPReg(port, EEE_OCP_PHY_ADDR, ®Data)) != RT_ERR_OK)
return retVal;
if (enable)
regData |= (0x0001 << 1);
else
regData &= ~(0x0001 << 1);
if ((retVal = rtl8367c_setAsicPHYOCPReg(port, EEE_OCP_PHY_ADDR, regData)) != RT_ERR_OK)
return retVal;
if ((retVal = rtl8367c_getAsicReg(RTL8367C_PORT_EEE_CFG_REG(port), ®Data)) != RT_ERR_OK)
return retVal;
if (enable)
regData |= (0x0001 << 11);
else
regData &= ~(0x0001 << 11);
if ((retVal = rtl8367c_setAsicReg(RTL8367C_PORT_EEE_CFG_REG(port), regData)) != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_getAsicEee100M | Get 100M eee enable/disable.
@parm rtk_uint32 | port | The port number.
@parm rtk_uint32* | enabled | 1: enabled, 0: disabled.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
This API get the 100M EEE function.
*/
ret_t rtl8367c_getAsicEee100M(rtk_uint32 port, rtk_uint32 *enable)
{
rtk_api_ret_t retVal;
rtk_uint32 regData;
if (port >= RTL8367C_PORTNO)
return RT_ERR_PORT_ID;
if ((retVal = rtl8367c_getAsicPHYOCPReg(port, EEE_OCP_PHY_ADDR, ®Data)) != RT_ERR_OK)
return retVal;
*enable = (regData & (0x0001 << 1)) ? RTK_ENABLED : RTK_DISABLED;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_setAsicEeeGiga | Set eee force mode function enable/disable.
@parm rtk_uint32 | port | The port number.
@parm rtk_uint32 | enabled | 1: enabled, 0: disabled.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
This API set the 100M EEE enable function.
*/
ret_t rtl8367c_setAsicEeeGiga(rtk_uint32 port, rtk_uint32 enable)
{
rtk_api_ret_t retVal;
rtk_uint32 regData;
if (port >= RTL8367C_PORTNO)
return RT_ERR_PORT_ID;
if (enable > 1)
return RT_ERR_INPUT;
if ((retVal = rtl8367c_getAsicPHYOCPReg(port, EEE_OCP_PHY_ADDR, ®Data)) != RT_ERR_OK)
return retVal;
if (enable)
regData |= (0x0001 << 2);
else
regData &= ~(0x0001 << 2);
if ((retVal = rtl8367c_setAsicPHYOCPReg(port, EEE_OCP_PHY_ADDR, regData)) != RT_ERR_OK)
return retVal;
if ((retVal = rtl8367c_getAsicReg(RTL8367C_PORT_EEE_CFG_REG(port), ®Data)) != RT_ERR_OK)
return retVal;
if (enable)
regData |= (0x0001 << 10);
else
regData &= ~(0x0001 << 10);
if ((retVal = rtl8367c_setAsicReg(RTL8367C_PORT_EEE_CFG_REG(port), regData)) != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_getAsicEeeGiga | Get 100M eee enable/disable.
@parm rtk_uint32 | port | The port number.
@parm rtk_uint32* | enabled | 1: enabled, 0: disabled.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
This API get the 100M EEE function.
*/
ret_t rtl8367c_getAsicEeeGiga(rtk_uint32 port, rtk_uint32 *enable)
{
rtk_api_ret_t retVal;
rtk_uint32 regData;
if (port >= RTL8367C_PORTNO)
return RT_ERR_PORT_ID;
if ((retVal = rtl8367c_getAsicPHYOCPReg(port, EEE_OCP_PHY_ADDR, ®Data)) != RT_ERR_OK)
return retVal;
*enable = (regData & (0x0001 << 2)) ? RTK_ENABLED : RTK_DISABLED;
return RT_ERR_OK;
}