diff options
author | Yisen.Zhuang\(Zhuangyuzeng\) <Yisen.Zhuang@huawei.com> | 2016-04-23 17:05:14 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-26 01:09:18 -0400 |
commit | 0d768fc62def08628affa4a2abe4f319926027a9 (patch) | |
tree | 04b9e8c24ce0a2869238c9aaa31a09fe805505bd /drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | |
parent | 850bfa3b78ea8849fef78ed74f5f2ccf947db0ca (diff) | |
download | linux-0d768fc62def08628affa4a2abe4f319926027a9.tar.gz linux-0d768fc62def08628affa4a2abe4f319926027a9.tar.bz2 linux-0d768fc62def08628affa4a2abe4f319926027a9.zip |
net: hns: add attribute port-mode-offset for dsaf port node
Port mode offset for each dsaf port is different. The current code is not
so readability. This patch adds configuration named port-mode-offset to
make the code simple and more readability. If port-mode-offset isn't
exists, default value 0 will be used.
Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
Signed-off-by: Yisen Zhuang <Yisen.Zhuang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c')
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c index e549a11420b4..a837bb9e3839 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c @@ -265,37 +265,31 @@ phy_interface_t hns_mac_get_phy_if(struct hns_mac_cb *mac_cb) { u32 mode; u32 reg; - u32 shift; - u32 phy_offset; bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver); int mac_id = mac_cb->mac_id; - phy_interface_t phy_if = PHY_INTERFACE_MODE_NA; + phy_interface_t phy_if; - if (is_ver1 && HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev)) { - phy_if = PHY_INTERFACE_MODE_SGMII; - } else if (mac_id >= 0 && mac_id <= 3 && - !HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev)) { - reg = is_ver1 ? HNS_MAC_HILINK4_REG : HNS_MAC_HILINK4V2_REG; - mode = dsaf_read_sub(mac_cb->dsaf_dev, reg); - /* mac_id 0, 1, 2, 3 ---> hilink4 lane 0, 1, 2, 3 */ - shift = is_ver1 ? 0 : mac_id; - if (dsaf_get_bit(mode, shift)) - phy_if = PHY_INTERFACE_MODE_XGMII; + if (is_ver1) { + if (HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev)) + return PHY_INTERFACE_MODE_SGMII; + + if (mac_id >= 0 && mac_id <= 3) + reg = HNS_MAC_HILINK4_REG; else - phy_if = PHY_INTERFACE_MODE_SGMII; - } else { - reg = is_ver1 ? HNS_MAC_HILINK3_REG : HNS_MAC_HILINK3V2_REG; - mode = dsaf_read_sub(mac_cb->dsaf_dev, reg); - /* mac_id 4, 5,---> hilink3 lane 2, 3 - * debug port 0(6), 1(7) ---> hilink3 lane 0, 1 - */ - phy_offset = mac_cb->dsaf_dev->reset_offset - 1; - shift = is_ver1 ? 0 : mac_id >= 4 ? mac_id - 2 : phy_offset; - if (dsaf_get_bit(mode, shift)) - phy_if = PHY_INTERFACE_MODE_XGMII; + reg = HNS_MAC_HILINK3_REG; + } else{ + if (!HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev) && mac_id <= 3) + reg = HNS_MAC_HILINK4V2_REG; else - phy_if = PHY_INTERFACE_MODE_SGMII; + reg = HNS_MAC_HILINK3V2_REG; } + + mode = dsaf_read_sub(mac_cb->dsaf_dev, reg); + if (dsaf_get_bit(mode, mac_cb->port_mode_off)) + phy_if = PHY_INTERFACE_MODE_XGMII; + else + phy_if = PHY_INTERFACE_MODE_SGMII; + return phy_if; } |