Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp272695imu; Fri, 14 Dec 2018 19:21:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/UVkU0XHXu3kVoSdDZah9yVG9/7zFue7KjkApAvHiitnfKtwwlmZSeQ+rOLGDixZdzLmBLu X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr4955919plh.302.1544844112566; Fri, 14 Dec 2018 19:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544844112; cv=none; d=google.com; s=arc-20160816; b=Zhm+AVkYl80nos56/mmJ+6lK4W1Dpck2K0UgnO2J0FILiwunuiU6Rtkues9aFtmMPJ yg/9HrhI+dGjWDXe/3R26HOlC/XlWmTjWuxGKlKwShboDxu8feDOppZp/rC0ENSv36az y/sYXhdZzAi9daP87cxDwt+UqufIO/kBgQZ8piXC6K7FR1Yh5QlIGzazoyRWPklFXq9r byRLjFNSFhkUzQka46UOQveg1Uk6xuF76QBbCUgThTtrvDIWFhyxabg1ORxbZLx6Dk98 FByTCWehtWc6UdEguSW32fPMnlwPb6GlkMOvasEKPRus797EZKvtrYQeWFdNugYOb2/i CxBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=u9WJOauFZ71rtp/6WevB+9pxLY5DpLehI2CZkzksOuo=; b=pbbqRxfkzRAUucdkILAog9+l1JeaS75LIN8a/CvktRwV/z0CwQFNtBwSmc9COnIZ0N B21D55jaYvY4rieuLhRiMlpGiWIu+3VegqYPTnKRX7trbFohrhxm92pMeiuFjNOwSuYu Le0ZAnEndhRYo1kM20FLrcBZVateyAurbotmGQvFWA5UUVrYv8Pjsa7ZUc381+Df1oXE 6Zwzxl9KUdZ/jsaCmKZPpRU5R0GsnmyI8+la5BZ3ThMHXBXEGNDGwdTaTsR+em8oYiiX DEE1kc+Q34TPqw9YnyNxSVlx2LcSIZJx3y1FQgWvj0P0wb+3idwPiDMMeHYlLF9JJzus 0ZtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si5677111pgl.108.2018.12.14.19.21.38; Fri, 14 Dec 2018 19:21:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729974AbeLODRd (ORCPT + 99 others); Fri, 14 Dec 2018 22:17:33 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16129 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727965AbeLODRc (ORCPT ); Fri, 14 Dec 2018 22:17:32 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E49BE4566C05C; Sat, 15 Dec 2018 11:17:29 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Sat, 15 Dec 2018 11:17:24 +0800 From: Peng Li To: CC: , , , , , Subject: [Patch net 09/10] net: hns: Add mac pcs config when enable|disable mac Date: Sat, 15 Dec 2018 11:53:28 +0800 Message-ID: <1544846009-50276-10-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> References: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonglong Liu In some case, when mac enable|disable and adjust link, may cause hard to link(or abnormal) between mac and phy. This patch adds the code for rx PCS to avoid this bug. Disable the rx PCS when driver disable the gmac, and enable the rx PCS when driver enable the mac. Signed-off-by: Yonglong Liu Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 14 ++++++++++---- drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c index aaf72c0..1790cda 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c @@ -67,11 +67,14 @@ static void hns_gmac_enable(void *mac_drv, enum mac_commom_mode mode) struct mac_driver *drv = (struct mac_driver *)mac_drv; /*enable GE rX/tX */ - if ((mode == MAC_COMM_MODE_TX) || (mode == MAC_COMM_MODE_RX_AND_TX)) + if (mode == MAC_COMM_MODE_TX || mode == MAC_COMM_MODE_RX_AND_TX) dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_TX_EN_B, 1); - if ((mode == MAC_COMM_MODE_RX) || (mode == MAC_COMM_MODE_RX_AND_TX)) + if (mode == MAC_COMM_MODE_RX || mode == MAC_COMM_MODE_RX_AND_TX) { + /* enable rx pcs */ + dsaf_set_dev_bit(drv, GMAC_PCS_RX_EN_REG, 0, 0); dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_RX_EN_B, 1); + } } static void hns_gmac_disable(void *mac_drv, enum mac_commom_mode mode) @@ -79,11 +82,14 @@ static void hns_gmac_disable(void *mac_drv, enum mac_commom_mode mode) struct mac_driver *drv = (struct mac_driver *)mac_drv; /*disable GE rX/tX */ - if ((mode == MAC_COMM_MODE_TX) || (mode == MAC_COMM_MODE_RX_AND_TX)) + if (mode == MAC_COMM_MODE_TX || mode == MAC_COMM_MODE_RX_AND_TX) dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_TX_EN_B, 0); - if ((mode == MAC_COMM_MODE_RX) || (mode == MAC_COMM_MODE_RX_AND_TX)) + if (mode == MAC_COMM_MODE_RX || mode == MAC_COMM_MODE_RX_AND_TX) { + /* disable rx pcs */ + dsaf_set_dev_bit(drv, GMAC_PCS_RX_EN_REG, 0, 1); dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_RX_EN_B, 0); + } } /* hns_gmac_get_en - get port enable diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h index f171d11..b9733b0 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h @@ -534,6 +534,7 @@ #define GMAC_LD_LINK_COUNTER_REG 0x01D0UL #define GMAC_LOOP_REG 0x01DCUL #define GMAC_RECV_CONTROL_REG 0x01E0UL +#define GMAC_PCS_RX_EN_REG 0x01E4UL #define GMAC_VLAN_CODE_REG 0x01E8UL #define GMAC_RX_OVERRUN_CNT_REG 0x01ECUL #define GMAC_RX_LENGTHFIELD_ERR_CNT_REG 0x01F4UL -- 1.9.1