[qca-ssdk]: Improve phyinfo get funciton and dump it
The port id should be compared with the dts value of port id
instead of the array index.
Change-Id: I32ece7df9edeb45720e720295813e13578635659
Signed-off-by: Luo Jie <luoj@codeaurora.org>
diff --git a/include/init/ssdk_init.h b/include/init/ssdk_init.h
index 3e1bdbc..6365d6a 100755
--- a/include/init/ssdk_init.h
+++ b/include/init/ssdk_init.h
@@ -192,6 +192,7 @@
QCA_PHY_F_QGMAC_BIT,
QCA_PHY_F_XGMAC_BIT,
QCA_PHY_F_I2C_BIT,
+ QCA_PHY_F_INIT_BIT,
QCA_PHY_FEATURE_MAX
};
/*qca808x_start*/
@@ -204,6 +205,7 @@
#define PHY_F_QGMAC _PHY_F(QGMAC)
#define PHY_F_XGMAC _PHY_F(XGMAC)
#define PHY_F_I2C _PHY_F(I2C)
+#define PHY_F_INIT _PHY_F(INIT)
typedef struct
{
diff --git a/src/init/ssdk_dts.c b/src/init/ssdk_dts.c
index 2226c48..147e2bf 100755
--- a/src/init/ssdk_dts.c
+++ b/src/init/ssdk_dts.c
@@ -129,9 +129,21 @@
ssdk_port_phyinfo* ssdk_port_phyinfo_get(a_uint32_t dev_id, a_uint32_t port_id)
{
- ssdk_dt_cfg* cfg = ssdk_dt_global.ssdk_dt_switch_nodes[dev_id];
+ a_uint32_t i;
+ ssdk_port_phyinfo *phyinfo_tmp = NULL;
+ ssdk_dt_cfg *cfg = ssdk_dt_global.ssdk_dt_switch_nodes[dev_id];
- return &cfg->port_phyinfo[port_id-1];
+ for (i = 0; i < cfg->phyinfo_num; i++) {
+ if (port_id == cfg->port_phyinfo[i].port_id) {
+ phyinfo_tmp = &cfg->port_phyinfo[i];
+ break;
+ } else if (!(cfg->port_phyinfo[i].phy_features & PHY_F_INIT) &&
+ phyinfo_tmp == NULL) {
+ phyinfo_tmp = &cfg->port_phyinfo[i];
+ }
+ }
+
+ return phyinfo_tmp;
}
struct mii_bus *
@@ -575,6 +587,8 @@
}
}
+ port_phyinfo->phy_features |= PHY_F_INIT;
+
if (mdio_node)
port_phyinfo->miibus = of_mdio_find_bus(mdio_node);
}
@@ -623,6 +637,8 @@
if (c45_phy) {
port_phyinfo->phy_features |= PHY_F_CLAUSE45;
}
+
+ port_phyinfo->phy_features |= PHY_F_INIT;
}
i++;
diff --git a/src/init/ssdk_plat.c b/src/init/ssdk_plat.c
index 539994b..92021d0 100755
--- a/src/init/ssdk_plat.c
+++ b/src/init/ssdk_plat.c
@@ -918,6 +918,38 @@
}
}
+static const a_int8_t *qca_phy_feature_str[QCA_PHY_FEATURE_MAX] = {
+ "PHY_CLAUSE45",
+ "PHY_COMBO",
+ "PHY_QGMAC",
+ "PHY_XGMAC",
+ "PHY_I2C",
+ "PHY_INIT"
+};
+
+void ssdk_dts_phyinfo_dump(a_uint32_t dev_id)
+{
+ a_uint32_t i, j;
+ ssdk_port_phyinfo *port_phyinfo;
+
+ printk("=====================port phyinfo========================\n");
+ printk("portid phy_addr features\n");
+
+ for (i = 0; i <= SSDK_MAX_PORT_NUM; i++) {
+ port_phyinfo = ssdk_port_phyinfo_get(dev_id, i);
+ if (port_phyinfo) {
+ printk("%6d%13d%*s", port_phyinfo->port_id,
+ port_phyinfo->phy_addr, 5, "");
+ for (j = 0; j < QCA_PHY_FEATURE_MAX; j++) {
+ if (port_phyinfo->phy_features & BIT(j)) {
+ printk("%s ", qca_phy_feature_str[j]);
+ }
+ }
+ printk("\n");
+ }
+ }
+}
+
static ssize_t ssdk_dts_dump(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -981,6 +1013,8 @@
ssdk_dts_l0scheduler_dump(dev_id);
printk("\n");
ssdk_dts_l1scheduler_dump(dev_id);
+ printk("\n");
+ ssdk_dts_phyinfo_dump(dev_id);
}
return count;