From patchwork Fri Aug 12 11:21:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9276813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50B77600CB for ; Fri, 12 Aug 2016 11:33:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40D542899D for ; Fri, 12 Aug 2016 11:33:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35AC12899F; Fri, 12 Aug 2016 11:33:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 97CC82899D for ; Fri, 12 Aug 2016 11:33:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bYAgc-0004vr-5C; Fri, 12 Aug 2016 11:31:38 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bYAYJ-0004CO-Di for linux-arm-kernel@lists.infradead.org; Fri, 12 Aug 2016 11:23:07 +0000 Received: by mail-pf0-x242.google.com with SMTP id g202so1426134pfb.1 for ; Fri, 12 Aug 2016 04:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3st1+KsrfRsKwbGLtVyWdWPiXo2tm2y0Ul01BneOkwY=; b=f8TgJLWR9J6ITHQ7qYMLQfnfjCV2VmhibFsoPpNPIGhliYc+v+VqfwkpeGsmW9/GdW 8xJVMQUedKOAGyn8MzKTHZ/DOKVJarViV3udW5Ra1jSyq4ykx5NIt3Pbfo3YrK5j+MVh X6umnOb3jSDIk8dF0N2EYWsLgzxPOInPYQ8chqS12ETn0LcfN35fNYQurD/kxXTdBOi0 nLY9fwPSnCDAqbCBjiJO2aYPSKAxGefEpkm4eHVAmXM0hONEHnxKqFudNMwNsCmLXprd dOudNil/K+6Uf6QHGQ2rig1WTY5BVJifWzScpcsIZnj+fQ5OgV3P0VN1mAqhWq61834w bRTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3st1+KsrfRsKwbGLtVyWdWPiXo2tm2y0Ul01BneOkwY=; b=kvnMJvXh2NraiI7HAGlsURQarYYK0OaaWcuPpQBppxkc8mIm/1gZsd3ACzMw0mFJb0 irFJ7lpFjHF4iFX3FwVkJ50drAc+FFpRf/qXOKKM1YVXwEAbk9ZWahqjb8hFrjEZZG8f jtEmWrhVRMQi59X47YfixRJb2In/VZPlYtGF13YJci1YE/QtTmr9mUgD3nvVjx/BkVIN yAlXJNgqhU7fH31IlbNUsIHvwMY7Uoa7NBgUEbwtIhpfDQY0+47P7/vLf2m8rujREYqg L3sRo8Le5PkxuTEtxWF5cMZUr8rhGV1KvgvUYHOaP441jPUrqUUSJm42+KaIG/sUa4az G1CQ== X-Gm-Message-State: AEkooutmX8xdl7gvDNt1cwIMxmeMcNdTYylUbJSTe0J9kFsD2+QMF6jK2P63DUbHcJBkMQ== X-Received: by 10.98.65.81 with SMTP id o78mr26302221pfa.48.1471000962156; Fri, 12 Aug 2016 04:22:42 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id ww14sm12306817pac.34.2016.08.12.04.22.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Aug 2016 04:22:41 -0700 (PDT) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH v2 09/21] net: thunderx: Add QSGMII interface type support Date: Fri, 12 Aug 2016 16:51:32 +0530 Message-Id: <1471000904-21715-10-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471000904-21715-1-git-send-email-sunil.kovvuri@gmail.com> References: <1471000904-21715-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160812_042303_736464_6D26C67D X-CRM114-Status: GOOD ( 17.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sunil Goutham , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sunil Goutham This patch adds support for QSGMII interface type to the BGX driver. This type of interface is supported by 81xx SOC. Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 65 ++++++++++++++++++----- drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 1 + 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 9c3c273..0bf8d24 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -379,8 +379,9 @@ void bgx_lmac_internal_loopback(int node, int bgx_idx, } EXPORT_SYMBOL(bgx_lmac_internal_loopback); -static int bgx_lmac_sgmii_init(struct bgx *bgx, int lmacid) +static int bgx_lmac_sgmii_init(struct bgx *bgx, struct lmac *lmac) { + int lmacid = lmac->lmacid; u64 cfg; bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_THRESH, 0x30); @@ -409,6 +410,14 @@ static int bgx_lmac_sgmii_init(struct bgx *bgx, int lmacid) cfg |= (PCS_MRX_CTL_RST_AN | PCS_MRX_CTL_AN_EN); bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, cfg); + if (lmac->lmac_type == BGX_MODE_QSGMII) { + /* Disable disparity check for QSGMII */ + cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MISCX_CTL); + cfg &= ~PCS_MISC_CTL_DISP_EN; + bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MISCX_CTL, cfg); + return 0; + } + if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_STATUS, PCS_MRX_STATUS_AN_CPT, false)) { dev_err(&bgx->pdev->dev, "BGX AN_CPT not completed\n"); @@ -650,6 +659,14 @@ static void bgx_poll_for_link(struct work_struct *work) queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2); } +static int phy_interface_mode(u8 lmac_type) +{ + if (lmac_type == BGX_MODE_QSGMII) + return PHY_INTERFACE_MODE_QSGMII; + + return PHY_INTERFACE_MODE_SGMII; +} + static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) { struct lmac *lmac; @@ -658,9 +675,10 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) lmac = &bgx->lmac[lmacid]; lmac->bgx = bgx; - if (lmac->lmac_type == BGX_MODE_SGMII) { + if ((lmac->lmac_type == BGX_MODE_SGMII) || + (lmac->lmac_type == BGX_MODE_QSGMII)) { lmac->is_sgmii = 1; - if (bgx_lmac_sgmii_init(bgx, lmacid)) + if (bgx_lmac_sgmii_init(bgx, lmac)) return -1; } else { lmac->is_sgmii = 0; @@ -697,7 +715,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) if (phy_connect_direct(&lmac->netdev, lmac->phydev, bgx_lmac_handler, - PHY_INTERFACE_MODE_SGMII)) + phy_interface_mode(lmac->lmac_type))) return -ENODEV; phy_start_aneg(lmac->phydev); @@ -799,6 +817,11 @@ static void bgx_init_hw(struct bgx *bgx) bgx_reg_write(bgx, 0, BGX_CMR_RX_STREERING + (i * 8), 0x00); } +static u8 bgx_get_lane2sds_cfg(struct bgx *bgx, struct lmac *lmac) +{ + return (u8)(bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG) & 0xFF); +} + static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid) { struct device *dev = &bgx->pdev->dev; @@ -838,12 +861,22 @@ static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid) else dev_info(dev, "%s: 40G_KR4\n", (char *)str); break; - default: - dev_info(dev, "%s: INVALID\n", (char *)str); + case BGX_MODE_QSGMII: + if ((lmacid == 0) && + (bgx_get_lane2sds_cfg(bgx, lmac) != lmacid)) + return; + if ((lmacid == 2) && + (bgx_get_lane2sds_cfg(bgx, lmac) == lmacid)) + return; + dev_info(dev, "%s: QSGMII\n", (char *)str); + break; + case BGX_MODE_INVALID: + /* Nothing to do */ + break; } } -static void lmac_set_lane2sds(struct lmac *lmac) +static void lmac_set_lane2sds(struct bgx *bgx, struct lmac *lmac) { switch (lmac->lmac_type) { case BGX_MODE_SGMII: @@ -857,6 +890,14 @@ static void lmac_set_lane2sds(struct lmac *lmac) case BGX_MODE_RXAUI: lmac->lane_to_sds = (lmac->lmacid) ? 0xE : 0x4; break; + case BGX_MODE_QSGMII: + /* There is no way to determine if DLM0/2 is QSGMII or + * DLM1/3 is configured to QSGMII as bootloader will + * configure all LMACs, so take whatever is configured + * by low level firmware. + */ + lmac->lane_to_sds = bgx_get_lane2sds_cfg(bgx, lmac); + break; default: lmac->lane_to_sds = 0; break; @@ -882,7 +923,7 @@ static void bgx_set_lmac_config(struct bgx *bgx, u8 idx) lmac->use_training = bgx_reg_read(bgx, 0, BGX_SPUX_BR_PMD_CRTL) & SPU_PMD_CRTL_TRAIN_EN; - lmac_set_lane2sds(lmac); + lmac_set_lane2sds(bgx, lmac); return; } @@ -901,7 +942,7 @@ static void bgx_set_lmac_config(struct bgx *bgx, u8 idx) lmac->use_training = bgx_reg_read(bgx, idx, BGX_SPUX_BR_PMD_CRTL) & SPU_PMD_CRTL_TRAIN_EN; - lmac_set_lane2sds(lmac); + lmac_set_lane2sds(bgx, lmac); /* Set LMAC type of other lmac on same DLM i.e LMAC 1/3 */ olmac = &bgx->lmac[idx + 1]; @@ -909,7 +950,7 @@ static void bgx_set_lmac_config(struct bgx *bgx, u8 idx) olmac->use_training = bgx_reg_read(bgx, idx + 1, BGX_SPUX_BR_PMD_CRTL) & SPU_PMD_CRTL_TRAIN_EN; - lmac_set_lane2sds(olmac); + lmac_set_lane2sds(bgx, olmac); } } @@ -920,7 +961,7 @@ static bool is_dlm0_in_bgx_mode(struct bgx *bgx) if (!bgx->is_81xx) return true; - lmac = &bgx->lmac[1]; + lmac = &bgx->lmac[0]; if (lmac->lmac_type == BGX_MODE_INVALID) return false; @@ -946,7 +987,7 @@ static void bgx_get_qlm_mode(struct bgx *bgx) if (bgx->lmac_count > MAX_LMAC_PER_BGX) bgx->lmac_count = MAX_LMAC_PER_BGX; - for (idx = 0; idx < bgx->lmac_count; idx++) + for (idx = 0; idx < MAX_LMAC_PER_BGX; idx++) bgx_set_lmac_config(bgx, idx); if (!bgx->is_81xx) { diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h index 38e9fb4..0705863 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h @@ -146,6 +146,7 @@ #define BGX_GMP_PCS_ANX_AN_RESULTS 0x30020 #define BGX_GMP_PCS_SGM_AN_ADV 0x30068 #define BGX_GMP_PCS_MISCX_CTL 0x30078 +#define PCS_MISC_CTL_DISP_EN BIT_ULL(13) #define PCS_MISC_CTL_GMX_ENO BIT_ULL(11) #define PCS_MISC_CTL_SAMP_PT_MASK 0x7Full #define BGX_GMP_GMI_PRTX_CFG 0x38020