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: 2014-05-29 16:39:06 +0800 (ι±ε, 29 δΊζ 2014) $
13 * Purpose : RTK switch high-level API for RTL8367/RTL8367C
14 * Feature : Here is a list of all functions and variables in EEE module.
18 #include <rtk_switch.h>
19 #include <rtk_error.h>
23 #include <rtl8367c_asicdrv.h>
24 #include <rtl8367c_asicdrv_eee.h>
25 #include <rtl8367c_asicdrv_phy.h>
30 * EEE function initialization.
37 * RT_ERR_FAILED - Failed
38 * RT_ERR_SMI - SMI access error
40 * This API is used to initialize EEE status.
42 rtk_api_ret_t
rtk_eee_init(void)
46 /* Check initialization state */
49 if((retVal
= rtl8367c_setAsicRegBit(0x0018, 10, 1)) != RT_ERR_OK
)
52 if((retVal
= rtl8367c_setAsicRegBit(0x0018, 11, 1)) != RT_ERR_OK
)
59 * rtk_eee_portEnable_set
61 * Set enable status of EEE function.
64 * enable - enable EEE status.
69 * RT_ERR_FAILED - Failed
70 * RT_ERR_SMI - SMI access error
71 * RT_ERR_PORT_ID - Invalid port number.
72 * RT_ERR_ENABLE - Invalid enable input.
74 * This API can set EEE function to the specific port.
75 * The configuration of the port is as following:
79 rtk_api_ret_t
rtk_eee_portEnable_set(rtk_port_t port
, rtk_enable_t enable
)
85 /* Check initialization state */
88 /* Check port is UTP port */
89 RTK_CHK_PORT_IS_UTP(port
);
91 if (enable
>=RTK_ENABLE_END
)
94 phy_port
= rtk_switch_port_L2P_get(port
);
96 if ((retVal
= rtl8367c_setAsicEee100M(phy_port
,enable
))!=RT_ERR_OK
)
98 if ((retVal
= rtl8367c_setAsicEeeGiga(phy_port
,enable
))!=RT_ERR_OK
)
101 if ((retVal
= rtl8367c_setAsicPHYReg(phy_port
, RTL8367C_PHY_PAGE_ADDRESS
, 0))!=RT_ERR_OK
)
103 if ((retVal
= rtl8367c_getAsicPHYReg(phy_port
, 0, ®Data
))!=RT_ERR_OK
)
106 if ((retVal
= rtl8367c_setAsicPHYReg(phy_port
, 0, regData
))!=RT_ERR_OK
)
113 * rtk_eee_portEnable_get
115 * Get enable status of EEE function
119 * pEnable - Back pressure status.
122 * RT_ERR_FAILED - Failed
123 * RT_ERR_SMI - SMI access error
124 * RT_ERR_PORT_ID - Invalid port number.
126 * This API can get EEE function to the specific port.
127 * The configuration of the port is as following:
132 rtk_api_ret_t
rtk_eee_portEnable_get(rtk_port_t port
, rtk_enable_t
*pEnable
)
134 rtk_api_ret_t retVal
;
135 rtk_uint32 regData1
, regData2
;
138 /* Check initialization state */
139 RTK_CHK_INIT_STATE();
141 /* Check port is UTP port */
142 RTK_CHK_PORT_IS_UTP(port
);
145 return RT_ERR_NULL_POINTER
;
147 phy_port
= rtk_switch_port_L2P_get(port
);
149 if ((retVal
= rtl8367c_getAsicEee100M(phy_port
,®Data1
))!=RT_ERR_OK
)
151 if ((retVal
= rtl8367c_getAsicEeeGiga(phy_port
,®Data2
))!=RT_ERR_OK
)
154 if (regData1
==1&®Data2
==1)