1 /** 2 * aQuantia Corporation Network Driver 3 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * (1) Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer. 12 * 13 * (2) Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * (3) The name of the author may not be used to endorse or promote 19 * products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 23 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 28 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 #ifndef AQ_FW_H 35 #define AQ_FW_H 36 37 struct aq_hw; 38 39 enum aq_fw_link_speed 40 { 41 aq_fw_none = 0, 42 aq_fw_10M = (1 << 0), /* Atlantic 2 only */ 43 aq_fw_100M = (1 << 1), 44 aq_fw_1G = (1 << 2), 45 aq_fw_2G5 = (1 << 3), 46 aq_fw_5G = (1 << 4), 47 aq_fw_10G = (1 << 5), 48 }; 49 50 enum aq_fw_link_fc 51 { 52 aq_fw_fc_none = 0, 53 aq_fw_fc_ENABLE_RX = BIT(0), 54 aq_fw_fc_ENABLE_TX = BIT(1), 55 aq_fw_fc_ENABLE_ALL = aq_fw_fc_ENABLE_RX | aq_fw_fc_ENABLE_TX, 56 }; 57 58 #define aq_fw_speed_auto \ 59 (aq_fw_10M | aq_fw_100M | aq_fw_1G | aq_fw_2G5 | aq_fw_5G | aq_fw_10G) 60 61 struct aq_firmware_ops 62 { 63 int (*reset)(struct aq_hw* hw); 64 65 int (*set_mode)(struct aq_hw* hw, enum aq_hw_fw_mpi_state mode, enum aq_fw_link_speed speed); 66 int (*get_mode)(struct aq_hw* hw, enum aq_hw_fw_mpi_state* mode, enum aq_fw_link_speed* speed, enum aq_fw_link_fc* fc); 67 68 /* Reports duplex, EEE and the firmware link state beyond the rate. */ 69 int (*get_link_info)(struct aq_hw* hw, struct aq_hw_link_info* info); 70 71 int (*get_mac_addr)(struct aq_hw* hw, uint8_t* mac_addr); 72 int (*get_stats)(struct aq_hw* hw, struct aq_hw_stats* stats); 73 74 /* Reports the firmware's own link transition counters. */ 75 int (*get_link_counters)(struct aq_hw* hw, uint32_t* up, uint32_t* down); 76 77 /* Reports millidegrees Celsius. */ 78 int (*get_temp)(struct aq_hw* hw, int* temp_mc); 79 80 /* Reports the PHY global fault code; zero means no fault. */ 81 int (*get_phy_fault)(struct aq_hw* hw, uint16_t* fault); 82 83 /* Reports the pre-shutdown PHY over-temperature warning. */ 84 int (*get_phy_hot_warning)(struct aq_hw* hw, bool* hot); 85 86 /* Resets the PHY (clears a latched thermal shutdown). */ 87 int (*phy_reset)(struct aq_hw* hw); 88 89 /* Arms or disarms the firmware autonomous thermal shutdown. */ 90 int (*thermal_arm)(struct aq_hw* hw, bool enable); 91 92 /* Reports the PHY high-temperature shutdown threshold (millidegrees C). */ 93 int (*get_thermal_limit)(struct aq_hw* hw, int* limit_mc); 94 95 int (*led_control)(struct aq_hw* hw, uint32_t mode); 96 }; 97 98 /* PHY global fault codes, register 1E.C850. */ 99 #define AQ_PHY_FAULT_THERMAL_SHUTDOWN 0x8007 100 101 /* aq_fw1x/aq_fw2x: Atlantic 1 firmware ABIs; aq2_fw: Atlantic 2 (AQC11x). */ 102 extern const struct aq_firmware_ops aq_fw1x_ops; 103 extern const struct aq_firmware_ops aq_fw2x_ops; 104 extern const struct aq_firmware_ops aq2_fw_ops; 105 106 int aq_fw_reset(struct aq_hw* hw); 107 int aq_fw_ops_init(struct aq_hw* hw); 108 int aq2_fw_reboot(struct aq_hw* hw); 109 110 #endif // AQ_FW_H 111