liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /** |
| 2 | * @file ql_sgmii.h |
| 3 | * @brief Quectel Openlinux SGMII public function declarations. |
| 4 | * |
| 5 | * @note |
| 6 | * |
| 7 | * @copyright Copyright (c) 2009-2017 @ Quectel Wireless Solutions Co., Ltd. |
| 8 | */ |
| 9 | |
| 10 | #ifndef __QL_SGMII_H__ |
| 11 | #define __QL_SGMII_H__ |
| 12 | #include "mbtk_type.h" |
| 13 | |
| 14 | |
| 15 | typedef enum { |
| 16 | QL_SGMII_AUTONEG_OFF = 0, |
| 17 | QL_SGMII_AUTONEG_ON |
| 18 | } ql_sgmii_autoneg_e; |
| 19 | |
| 20 | typedef enum { |
| 21 | QL_SGMII_SPEED_10MHZ = 0, |
| 22 | QL_SGMII_SPEED_100MHZ, |
| 23 | QL_SGMII_SPEED_1000MHZ /* this speed can not support */ |
| 24 | } ql_sgmii_speed_e; |
| 25 | |
| 26 | typedef enum { |
| 27 | QL_SGMII_DUPLEX_FULL = 0, |
| 28 | QL_SGMII_DUPLEX_HALF |
| 29 | } ql_sgmii_duplex_e; |
| 30 | |
| 31 | struct ql_sgmii_info { |
| 32 | ql_sgmii_autoneg_e autoneg; |
| 33 | ql_sgmii_speed_e speed; |
| 34 | ql_sgmii_duplex_e duplex; |
| 35 | unsigned long tx_bytes; |
| 36 | unsigned long rx_bytes; |
| 37 | unsigned long tx_pkts; |
| 38 | unsigned long rx_pkts; |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * Enables the SGMII ethernet module. |
| 43 | * |
| 44 | * @param None |
| 45 | * |
| 46 | * @return |
| 47 | * On success, 0 is returned. On error, -1 is returned. |
| 48 | * |
| 49 | */ |
| 50 | extern int ql_sgmii_enable(void); |
| 51 | |
| 52 | /** |
| 53 | * Disable the SGMII ethernet module. |
| 54 | * |
| 55 | * @param None |
| 56 | * |
| 57 | * @return |
| 58 | * On success, 0 is returned. On error, -1 is returned. |
| 59 | * |
| 60 | */ |
| 61 | extern int ql_sgmii_disable(void); |
| 62 | |
| 63 | /** |
| 64 | * Set the SGMII ethernet configuration: the ethernet auto negotiation configuration. |
| 65 | * |
| 66 | * @param [in] auto negotiation |
| 67 | * |
| 68 | * @return |
| 69 | * On success, 0 is returned. On error, -1 is returned. |
| 70 | * |
| 71 | * @dependencies |
| 72 | * the ql_sgmii_enable must be set enable |
| 73 | * |
| 74 | */ |
| 75 | extern int ql_sgmii_autoneg_set(ql_sgmii_autoneg_e autoneg); |
| 76 | |
| 77 | /** |
| 78 | * Get the SGMII ethernet configuration: the ethernet auto negotiation configuration. |
| 79 | * |
| 80 | * @param [out] auto negotiation |
| 81 | * |
| 82 | * @return |
| 83 | * On success, 0 is returned. On error, -1 is returned. |
| 84 | * |
| 85 | * @dependencies |
| 86 | * the ql_sgmii_enable must be set enable |
| 87 | * |
| 88 | */ |
| 89 | extern int ql_sgmii_autoneg_get(ql_sgmii_autoneg_e *autoneg); |
| 90 | |
| 91 | /** |
| 92 | * Set the SGMII ethernet configuration: the ethernet speed configuration. |
| 93 | * |
| 94 | * @param [in] ethernet speed |
| 95 | * |
| 96 | * @return |
| 97 | * On success, 0 is returned. On error, -1 is returned. |
| 98 | * |
| 99 | * @dependencies |
| 100 | * the ql_sgmii_enable must be set enable |
| 101 | * |
| 102 | */ |
| 103 | extern int ql_sgmii_speed_set(ql_sgmii_speed_e speed); |
| 104 | |
| 105 | /** |
| 106 | * Get the SGMII ethernet configuration: the ethernet speed configuration. |
| 107 | * |
| 108 | * @param [out] the ethernet current speed |
| 109 | * |
| 110 | * @return |
| 111 | * On success, 0 is returned. On error, -1 is returned. |
| 112 | * |
| 113 | * @dependencies |
| 114 | * the ql_sgmii_enable must be set enable |
| 115 | * |
| 116 | */ |
| 117 | extern int ql_sgmii_speed_get(ql_sgmii_speed_e *speed); |
| 118 | |
| 119 | /** |
| 120 | * Set the SGMII ethernet configuration: the ethernet duplex configuration. |
| 121 | * |
| 122 | * @param [in] ethernet duplex |
| 123 | * |
| 124 | * @return |
| 125 | * On success, 0 is returned. On error, -1 is returned. |
| 126 | * |
| 127 | * @dependencies |
| 128 | * the ql_sgmii_enable must be set enable |
| 129 | * |
| 130 | */ |
| 131 | extern int ql_sgmii_duplex_set(ql_sgmii_duplex_e duplex); |
| 132 | |
| 133 | /** |
| 134 | * Get the SGMII ethernet configuration: the ethernet duplex configuration. |
| 135 | * |
| 136 | * @param [out] the ethernet current duplex |
| 137 | * |
| 138 | * @return |
| 139 | * On success, 0 is returned. On error, -1 is returned. |
| 140 | * |
| 141 | * @dependencies |
| 142 | * the ql_sgmii_enable must be set enable |
| 143 | * |
| 144 | */ |
| 145 | extern int ql_sgmii_duplex_get(ql_sgmii_duplex_e *duplex); |
| 146 | |
| 147 | /** |
| 148 | * Get the sgmii ethernet information: transmit and receive bytes, transmit and receive packets, speed, duplex. |
| 149 | * |
| 150 | * @param [out] the ethernet information |
| 151 | * |
| 152 | * @return |
| 153 | * On success, 0 is returned. On error, -1 is returned. |
| 154 | * |
| 155 | * @dependencies |
| 156 | * the ql_sgmii_enable must be set enable |
| 157 | * |
| 158 | */ |
| 159 | extern int ql_smgii_info_get(struct ql_sgmii_info *info); |
| 160 | |
| 161 | |
| 162 | #endif /* end of __QL_SGMII_H__ */ |