[qca-ssdk]: fix cdt issue of aq109.
use mode0 for aq107 and use aq109 for mode2.
Change-Id: Ie564525af4043604ac29a0dfaf227fb01274d061
Signed-off-by: Liu Zhongjian <zhongjia@codeaurora.org>
diff --git a/include/hsl/phy/aquantia_phy.h b/include/hsl/phy/aquantia_phy.h
index 79bf612..0a03918 100755
--- a/include/hsl/phy/aquantia_phy.h
+++ b/include/hsl/phy/aquantia_phy.h
@@ -59,7 +59,9 @@
#define AQUANTIA_AUTONEG_LINK_PARTNER_10G_ABILITY 0x21
#define AQUANTIA_GLOBAL_CDT_CONTROL 0xC470
+#define AQUANTIA_GLOBAL_GENERAL_STATUS 0xC831
#define AQUANTIA_NORMAL_CABLE_DIAGNOSTICS 0x10
+#define AQUANTIA_CABLE_DIAGNOSTICS_STATUS 0x8000
/*AQUANTIA PHY LINE SIDE PACKETS COUNTER REGISTER*/
#define AQUANTIA_LINE_SIDE_TRANSMIT_GOOD_FRAME_COUNTER2 0xc821
#define AQUANTIA_LINE_SIDE_TRANSMIT_GOOD_FRAME_COUNTER1 0xc820
@@ -299,6 +301,9 @@
#define RUN_CDT 0x8000
#define CABLE_LENGTH_UNIT 0x0400
+#define AQUANTIA_PHY_CDT_MODE0 0
+#define AQUANTIA_PHY_CDT_MODE1 1
+#define AQUANTIA_PHY_CDT_MODE2 2
/** Phy pages */
typedef enum
diff --git a/src/hsl/phy/aquantia_phy.c b/src/hsl/phy/aquantia_phy.c
index 494313d..e28af01 100755
--- a/src/hsl/phy/aquantia_phy.c
+++ b/src/hsl/phy/aquantia_phy.c
@@ -59,6 +59,26 @@
return rv;
}
+/******************************************************************************
+*
+* aquantia_phy_get_phy_id - get the phy id
+*
+*/
+sw_error_t
+aquantia_phy_get_phy_id(a_uint32_t dev_id, a_uint32_t phy_id,
+ a_uint16_t * org_id, a_uint16_t * rev_id)
+{
+ sw_error_t rv;
+
+ rv = aquantia_phy_reg_read(dev_id, phy_id, AQUANTIA_MMD_PHY_XS_REGISTERS,
+ AQUANTIA_PHY_ID1, org_id);
+ SW_RTN_ON_ERROR(rv);
+ rv = aquantia_phy_reg_read(dev_id, phy_id, AQUANTIA_MMD_PHY_XS_REGISTERS,
+ AQUANTIA_PHY_ID2, rev_id);
+
+ return rv;
+}
+
sw_error_t
aquantia_phy_get_speed(a_uint32_t dev_id, a_uint32_t phy_id,
fal_port_speed_t * speed)
@@ -581,20 +601,38 @@
sw_error_t aquatia_phy_cdt_start(a_uint32_t dev_id, a_uint32_t phy_id)
{
- a_uint16_t status = 0;
+ a_uint16_t status = 0, phy_data = 0, org_id, rev_id;
+ a_uint32_t aq_phy_id;
a_uint16_t ii = 300;
sw_error_t rv = SW_OK;
- /* RUN CDT */
+ /*select mode0 if aq107, and select mode2 if aq109*/
+ rv = aquantia_phy_get_phy_id(dev_id, phy_id, &org_id, &rev_id);
+ SW_RTN_ON_ERROR(rv);
+ aq_phy_id = (org_id << 16) | rev_id;
+ rv = aquantia_phy_reg_read(dev_id, phy_id, AQUANTIA_MMD_GLOBAL_REGISTERS,
+ AQUANTIA_GLOBAL_CDT_CONTROL, &phy_data);
+ SW_RTN_ON_ERROR(rv);
+ if(aq_phy_id == AQUANTIA_PHY_109)
+ {
+ phy_data |= AQUANTIA_PHY_CDT_MODE2;
+ }
+ else
+ {
+ phy_data |= AQUANTIA_PHY_CDT_MODE0;
+ }
+
+ phy_data |= AQUANTIA_NORMAL_CABLE_DIAGNOSTICS;
rv = aquantia_phy_reg_write(dev_id, phy_id, AQUANTIA_MMD_GLOBAL_REGISTERS,
- AQUANTIA_GLOBAL_CDT_CONTROL, AQUANTIA_NORMAL_CABLE_DIAGNOSTICS);
+ AQUANTIA_GLOBAL_CDT_CONTROL, phy_data);
+ SW_RTN_ON_ERROR(rv);
do {
aos_mdelay(30);
rv = aquantia_phy_reg_read(dev_id, phy_id, AQUANTIA_MMD_GLOBAL_REGISTERS,
- AQUANTIA_GLOBAL_CDT_CONTROL, &status);
+ AQUANTIA_GLOBAL_GENERAL_STATUS, &status);
SW_RTN_ON_ERROR(rv);
}
- while ((status & AQUANTIA_NORMAL_CABLE_DIAGNOSTICS) && (--ii));
+ while ((status & AQUANTIA_CABLE_DIAGNOSTICS_STATUS) && (--ii));
return rv;
}
@@ -1559,26 +1597,6 @@
return rv;
}
-/******************************************************************************
-*
-* aquantia_phy_get_phy_id - get the phy id
-*
-*/
-sw_error_t
-aquantia_phy_get_phy_id(a_uint32_t dev_id, a_uint32_t phy_id,
- a_uint16_t * org_id, a_uint16_t * rev_id)
-{
- sw_error_t rv;
-
- rv = aquantia_phy_reg_read(dev_id, phy_id, AQUANTIA_MMD_PHY_XS_REGISTERS,
- AQUANTIA_PHY_ID1, org_id);
- SW_RTN_ON_ERROR(rv);
- rv = aquantia_phy_reg_read(dev_id, phy_id, AQUANTIA_MMD_PHY_XS_REGISTERS,
- AQUANTIA_PHY_ID2, rev_id);
-
- return rv;
-}
-
static sw_error_t
_aquantia_phy_line_side_counter_get(a_uint32_t dev_id, a_uint32_t phy_id,
fal_port_counter_info_t * counter_infor)