From patchwork Wed May 17 20:05:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 9731829 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 3E60C600CC for ; Wed, 17 May 2017 20:03:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CD922621D for ; Wed, 17 May 2017 20:03:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01156287D2; Wed, 17 May 2017 20:03:22 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A0092621D for ; Wed, 17 May 2017 20:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=8gJxIEJlKVAW0HiFtTLKsXodMwhLXndFCaRa3CUwfiU=; b=Ges Mt3cAoT9G0udHeuxShaCFq95GV5+dCg0CbW+Eoo+I35yjfXNT9ijaC4mrYuHLNYBpvG0Th0kEdq/0 M13EF1hfu2bTDaXe4ycay++SqzNZHsuoRiV7lg/umgQCDKjyaf4pdHyu3FXa5COUG0mlYmtUkUdXA vDp/81wQN9/KhLMoKGLYoha39oQMg6FZ0NhH4YENGF2FHa7rVDMAkhR/QYry6yw994OSUDNzNx3gm IDYwxo58HqozWBEE+EVgRYb+1jhGZ5W9KzYJQgMqjJAt1dER0JSkmLf1dw5e6EFQniIWeS3bF+dPA 4sxEJ2LjmP30HMLwBHygAe3TbYwtIdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dB5AF-0003U0-M2; Wed, 17 May 2017 20:03:19 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dB5AB-0003PT-UH for linux-arm-kernel@lists.infradead.org; Wed, 17 May 2017 20:03:17 +0000 Received: by mail-pf0-x234.google.com with SMTP id m17so12414826pfg.3 for ; Wed, 17 May 2017 13:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=p7RMQkQZA7pOZK1l5h7SV8ciCujTxKYXXYwAzAnfNM4=; b=ajpaddecap4DIfUFhohjp/RtLw+FbPtvGuKzyjiyNhnoaEkz8BFQGwCl5iSu3V3eKO VEDFDxB+iRigWfASDmwiSya0Zu3jN28bJE4Nzu7+aNeUbcQtg+AcIpKG8HzXdrD1viZ1 SL1qKbHEE+a9CLgl6XDEU9ttX8mNSK1pO/gUg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=p7RMQkQZA7pOZK1l5h7SV8ciCujTxKYXXYwAzAnfNM4=; b=ijLbD2QOMUo4uiqqjOGn6TBnxpGyBD1jMykCjQz4YtHwOmJjmWAhl36T3RYyxmaCR9 nIDQmwo5eHOSKatCgjO22AJcocAl9NakfUzyLtP+u4wDDuF5hhQT2ONIt6YhnZlOIjVb Fr67wy60k95xr+4XuAuuOSJeNROITpsfgSXSAnCcGQZrETETgZy9aMogXhX3NCtrtmKa Z2n+tFtwy/qalh9uJ8IMBgYcxruqXYmmAjl3729o/aJi75DZA2l012WtWnfvsWgSAEFO LpEwXgOHuKTjP2nifyuWwxEakQ46EsjF0JraSmlaS+2Xp/VuhmozHHYUKpNMKWCClVLG 7L1Q== X-Gm-Message-State: AODbwcAkS1TCUOOmrRKornLg2sROp7cyGTDVPat8IsFvZaV9PXJG2GJv rqM4yQ0VP6Br7YL+ X-Received: by 10.84.238.9 with SMTP id u9mr575252plk.126.1495051374677; Wed, 17 May 2017 13:02:54 -0700 (PDT) Received: from isubrama-dev.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id e16sm5202589pfk.100.2017.05.17.13.02.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 May 2017 13:02:54 -0700 (PDT) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH net-next] drivers: net: xgene: Check all RGMII phy mode variants Date: Wed, 17 May 2017 13:05:50 -0700 Message-Id: <1495051550-28961-1-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170517_130316_012200_8D35042D X-CRM114-Status: GOOD ( 15.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Quan Nguyen , f.fainelli@gmail.com, patches@apm.com, linux-arm-kernel@lists.infradead.org, Iyappan Subramanian 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 This patch addresses the review comment from the previous patch set, by adding a helper function to address all RGMII phy mode variants. Signed-off-by: Iyappan Subramanian Signed-off-by: Quan Nguyen --- Review comment reference: http://www.spinics.net/lists/netdev/msg434649.html --- .../net/ethernet/apm/xgene/xgene_enet_ethtool.c | 6 ++--- drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 26 +++++++++++++++++----- drivers/net/ethernet/apm/xgene/xgene_enet_hw.h | 1 + drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 15 ++++++++----- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c index 0fdec78..a0c9ddc 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c @@ -127,7 +127,7 @@ static int xgene_get_link_ksettings(struct net_device *ndev, struct phy_device *phydev = ndev->phydev; u32 supported; - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { + if (is_xgene_enet_phy_mode_rgmii(ndev)) { if (phydev == NULL) return -ENODEV; @@ -177,7 +177,7 @@ static int xgene_set_link_ksettings(struct net_device *ndev, struct xgene_enet_pdata *pdata = netdev_priv(ndev); struct phy_device *phydev = ndev->phydev; - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { + if (is_xgene_enet_phy_mode_rgmii(ndev)) { if (!phydev) return -ENODEV; @@ -304,7 +304,7 @@ static int xgene_set_pauseparam(struct net_device *ndev, struct phy_device *phydev = ndev->phydev; u32 oldadv, newadv; - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII || + if (is_xgene_enet_phy_mode_rgmii(ndev) || pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) { if (!phydev) return -EINVAL; diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c index 6ac27c7..00f313d 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c @@ -264,6 +264,20 @@ static void xgene_enet_wr_mcx_csr(struct xgene_enet_pdata *pdata, iowrite32(val, addr); } +bool is_xgene_enet_phy_mode_rgmii(struct net_device *ndev) +{ + struct xgene_enet_pdata *pdata = netdev_priv(ndev); + int phy_mode = pdata->phy_mode; + bool ret; + + ret = phy_mode == PHY_INTERFACE_MODE_RGMII || + phy_mode == PHY_INTERFACE_MODE_RGMII_ID || + phy_mode == PHY_INTERFACE_MODE_RGMII_RXID || + phy_mode == PHY_INTERFACE_MODE_RGMII_TXID; + + return ret; +} + void xgene_enet_wr_mac(struct xgene_enet_pdata *pdata, u32 wr_addr, u32 wr_data) { void __iomem *addr, *wr, *cmd, *cmd_done; @@ -272,7 +286,7 @@ void xgene_enet_wr_mac(struct xgene_enet_pdata *pdata, u32 wr_addr, u32 wr_data) u32 done; if (pdata->mdio_driver && ndev->phydev && - pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { + is_xgene_enet_phy_mode_rgmii(ndev)) { struct mii_bus *bus = ndev->phydev->mdio.bus; return xgene_mdio_wr_mac(bus->priv, wr_addr, wr_data); @@ -326,12 +340,13 @@ static void xgene_enet_rd_mcx_csr(struct xgene_enet_pdata *pdata, u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr) { void __iomem *addr, *rd, *cmd, *cmd_done; + struct net_device *ndev = pdata->ndev; u32 done, rd_data; u8 wait = 10; - if (pdata->mdio_driver && pdata->ndev->phydev && - pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { - struct mii_bus *bus = pdata->ndev->phydev->mdio.bus; + if (pdata->mdio_driver && ndev->phydev && + is_xgene_enet_phy_mode_rgmii(ndev)) { + struct mii_bus *bus = ndev->phydev->mdio.bus; return xgene_mdio_rd_mac(bus->priv, rd_addr); } @@ -349,8 +364,7 @@ u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr) udelay(1); if (!done) - netdev_err(pdata->ndev, "mac read failed, addr: %04x\n", - rd_addr); + netdev_err(ndev, "mac read failed, addr: %04x\n", rd_addr); rd_data = ioread32(rd); iowrite32(0, cmd); diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h index 5d3e18d..5c54f65 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h @@ -431,6 +431,7 @@ static inline u16 xgene_enet_get_numslots(u16 id, u32 size) size / WORK_DESC_SIZE; } +bool is_xgene_enet_phy_mode_rgmii(struct net_device *ndev); void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring, enum xgene_enet_err_code status); int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata); diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index 21cd4ef..6e0028f 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -1634,7 +1634,7 @@ static int xgene_enet_get_irqs(struct xgene_enet_pdata *pdata) struct device *dev = &pdev->dev; int i, ret, max_irqs; - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) + if (is_xgene_enet_phy_mode_rgmii(pdata->ndev)) max_irqs = 1; else if (pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) max_irqs = 2; @@ -1760,7 +1760,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) dev_err(dev, "Unable to get phy-connection-type\n"); return pdata->phy_mode; } - if (pdata->phy_mode != PHY_INTERFACE_MODE_RGMII && + if (!is_xgene_enet_phy_mode_rgmii(ndev) && pdata->phy_mode != PHY_INTERFACE_MODE_SGMII && pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) { dev_err(dev, "Incorrect phy-connection-type specified\n"); @@ -1805,7 +1805,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) pdata->cle.base = base_addr + BLOCK_ETH_CLE_CSR_OFFSET; pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET; pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET; - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII || + if (is_xgene_enet_phy_mode_rgmii(ndev) || pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) { pdata->mcx_mac_addr = pdata->base_addr + BLOCK_ETH_MAC_OFFSET; pdata->mcx_stats_addr = @@ -1904,6 +1904,9 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata) { switch (pdata->phy_mode) { case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: pdata->mac_ops = &xgene_gmac_ops; pdata->port_ops = &xgene_gport_ops; pdata->rm = RM3; @@ -2100,7 +2103,7 @@ static int xgene_enet_probe(struct platform_device *pdev) if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) { INIT_DELAYED_WORK(&pdata->link_work, link_state); } else if (!pdata->mdio_driver) { - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) + if (is_xgene_enet_phy_mode_rgmii(ndev)) ret = xgene_enet_mdio_config(pdata); else INIT_DELAYED_WORK(&pdata->link_work, link_state); @@ -2131,7 +2134,7 @@ static int xgene_enet_probe(struct platform_device *pdev) if (pdata->mdio_driver) xgene_enet_phy_disconnect(pdata); - else if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) + else if (is_xgene_enet_phy_mode_rgmii(ndev)) xgene_enet_mdio_remove(pdata); err1: xgene_enet_delete_desc_rings(pdata); @@ -2155,7 +2158,7 @@ static int xgene_enet_remove(struct platform_device *pdev) if (pdata->mdio_driver) xgene_enet_phy_disconnect(pdata); - else if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) + else if (is_xgene_enet_phy_mode_rgmii(ndev)) xgene_enet_mdio_remove(pdata); unregister_netdev(ndev);