[qca-ssdk] update two ports phy's first phy address
Change-Id: I1e5b7f92c41941f3676a52eb65bb2ced91189bbc
Signed-off-by: esong <song@codeaurora.org>
diff --git a/include/hsl/phy/hsl_phy.h b/include/hsl/phy/hsl_phy.h
index 1cf083a..797099f 100755
--- a/include/hsl/phy/hsl_phy.h
+++ b/include/hsl/phy/hsl_phy.h
@@ -565,6 +565,7 @@
#define INVALID_PHY_ADDR 0xff
#define MAX_PHY_ADDR 0x1f
+#define QCA8072_PHY_NUM 0x2
sw_error_t
hsl_phy_api_ops_register(phy_type_t phy_type, hsl_phy_ops_t * phy_api_ops);
diff --git a/src/hsl/phy/malibu_phy.c b/src/hsl/phy/malibu_phy.c
index b604ecf..498c32d 100755
--- a/src/hsl/phy/malibu_phy.c
+++ b/src/hsl/phy/malibu_phy.c
@@ -2698,14 +2698,15 @@
sw_error_t
malibu_phy_hw_init(a_uint32_t dev_id, a_uint32_t port_bmp)
{
- a_uint32_t port_id = 0, phy_addr = 0;
+ a_uint32_t port_id = 0, phy_addr = 0, phy_cnt = 0;
a_uint16_t dac_value,led_status, phy_data;
- a_uint32_t phy_id = 0, mode;
+ a_uint32_t mode;
for (port_id = 0; port_id < SW_MAX_NR_PORT; port_id ++)
{
if (port_bmp & (0x1 << port_id))
{
+ phy_cnt ++;
phy_addr = qca_ssdk_port_to_phy_addr(dev_id, port_id);
if (phy_addr < first_phy_addr)
{
@@ -2732,11 +2733,10 @@
MALIBU_PHY_MMD7_LED_1000_CTRL1, led_status);
}
}
-
- malibu_phy_get_phy_id(dev_id, first_phy_addr, &phy_id);
- /* software get 8072 phy chip's firstly address to init phy chip */
- if ((phy_id == MALIBU_1_1_2PORT) && (first_phy_addr >= 0x3))
+ /* qca 8072 two ports phy chip's firstly address to init phy chip */
+ if ((phy_cnt == QCA8072_PHY_NUM) && (first_phy_addr >= 0x3)) {
first_phy_addr = first_phy_addr - 0x3;
+ }
/*workaround to enable AZ transmitting ability*/
malibu_phy_mmd_write(dev_id, first_phy_addr + 5, MALIBU_PHY_MMD1_NUM,
diff --git a/src/init/ssdk_init.c b/src/init/ssdk_init.c
index 0a713d0..05c355e 100755
--- a/src/init/ssdk_init.c
+++ b/src/init/ssdk_init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012, 2014-2019, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -2156,13 +2156,12 @@
SSDK_INFO("PHY final test result: 0x%x \r\n",phy_t_status);
}
-void ssdk_psgmii_self_test(a_uint32_t dev_id, a_bool_t enable, a_uint32_t times,
- a_uint32_t *result)
+
+void ssdk_psgmii_get_first_phy_address(a_uint32_t dev_id,
+ a_uint32_t *first_phy_addr)
{
- int i = 0;
- u32 value = 0;
+ a_uint32_t port_id = 0, phy_addr = 0, phy_cnt = 0;
a_uint32_t port_bmp[SW_MAX_NR_DEV] = {0};
- a_uint32_t port_id = 0, first_phy_addr = 0, phy = 0;
port_bmp[dev_id] = qca_ssdk_phy_type_port_bmp_get(dev_id, MALIBU_PHY_CHIP);
@@ -2170,10 +2169,29 @@
{
if (port_bmp[dev_id] & (0x1 << port_id))
{
- first_phy_addr = qca_ssdk_port_to_phy_addr(dev_id, port_id);
- break;
+ phy_cnt ++;
+ phy_addr = qca_ssdk_port_to_phy_addr(dev_id, port_id);
+ if (phy_addr < *first_phy_addr) {
+ *first_phy_addr = phy_addr;
+ }
}
}
+ if ((phy_cnt == QCA8072_PHY_NUM) && (*first_phy_addr >= 0x3)) {
+ *first_phy_addr = *first_phy_addr - 3;
+ }
+}
+
+void ssdk_psgmii_self_test(a_uint32_t dev_id, a_bool_t enable, a_uint32_t times,
+ a_uint32_t *result)
+{
+ int i = 0;
+ u32 value = 0;
+ a_uint32_t first_phy_addr = MAX_PHY_ADDR + 1, phy = 0;
+
+ ssdk_psgmii_get_first_phy_address(dev_id, &first_phy_addr);
+ if ((first_phy_addr < 0) || (first_phy_addr > MAX_PHY_ADDR)) {
+ return;
+ }
if (enable == A_FALSE) {
ssdk_malibu_psgmii_and_dakota_dess_reset(dev_id, first_phy_addr);
@@ -2239,19 +2257,11 @@
void clear_self_test_config(a_uint32_t dev_id)
{
u32 value = 0;
- a_uint32_t port_bmp[SW_MAX_NR_DEV] = {0};
- a_uint32_t port_id = 0, first_phy_addr = 0, phy = 0;
+ a_uint32_t first_phy_addr = MAX_PHY_ADDR + 1, phy = 0;
-
- port_bmp[dev_id] = qca_ssdk_phy_type_port_bmp_get(dev_id, MALIBU_PHY_CHIP);
-
- for (port_id = 0; port_id < SW_MAX_NR_PORT; port_id ++)
- {
- if (port_bmp[dev_id] & (0x1 << port_id))
- {
- first_phy_addr = qca_ssdk_port_to_phy_addr(dev_id, port_id);
- break;
- }
+ ssdk_psgmii_get_first_phy_address(dev_id, &first_phy_addr);
+ if ((first_phy_addr < 0) || (first_phy_addr > MAX_PHY_ADDR)) {
+ return;
}
/* disable EEE */