From patchwork Tue Nov 20 01:24:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 151542 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2021ljp; Mon, 19 Nov 2018 17:25:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/XHC0qGEDUlkHx6aoWumqAHHBpMbqonTXN+e3sc1UttsONA9M5GILueSRj1cPMyoZnVGwFx X-Received: by 2002:a63:a84a:: with SMTP id i10mr16401pgp.263.1542677157018; Mon, 19 Nov 2018 17:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542677157; cv=none; d=google.com; s=arc-20160816; b=DpcbTM0TNtQCW2UI0sub3S5YGe1Xrd5bjAbUqIAbW6cIcQ4xMkriw6BX2qtvhUy3pa TwtILDOLfw/vrhRBda2cgZGxROeCBscyXmONXabDQ4Fj6HEjLUaE97bXwO6W3eo1Ki7a 5IZpTobEU3cU5hxFbLOtzQK5GOVHlGwNThAkspQyfoAb4dXhsUvkz7ZxAiqJgP8raRxB Vh57SVGAyrgG9uM9phN6PKWwLP1jkdD1GucW6mDBm4viHUXpFv6llY4RF/T7L7r8Qp/u rQgDCNwmCyHd/NnuPF2oJohobj0uR3mHjsh+pVkjgO/Zsl9uGxzuzHcIjibwTHU2+svq 5cUw== 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:dkim-signature; bh=2VDfed9KY4h+R8FdQ2P0e/jfTBo+1N6PWOIRZasAyXU=; b=EyI7RY6kWjSgE28hCybfARe0pzEybnqn14tm3OgbX7d/bKwuKT1Ub7UjgUoJV/6W1A +XTDBa45bFmtvSmoW8rregVMZtLENFkostjKawLDL+TpKSQ5Q3mfKFDqdSLmLXDglnHz 9uxujWUEpw3oqQ5/9iWxhl2U+YKRjw0D8EyZAJwd1aF1iV/RXVANTcEbqG8rgvYi3H37 MOSfQuVH67XcFJ4A/Y18HmenLp5/m9j5SAi2osNkThQXs+e9IXIL+x2aLqRshVhNTFdG 4nPwASNcTD/E0K3kZZ68ypHU/7dOztSirXz2gHmUGlWQUEWkFR8CjCcGGBhnHEOEGr9y t1qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wh1pept9; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si40381970plk.360.2018.11.19.17.25.56; Mon, 19 Nov 2018 17:25:57 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wh1pept9; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732470AbeKTLwD (ORCPT + 32 others); Tue, 20 Nov 2018 06:52:03 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:60198 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbeKTLwC (ORCPT ); Tue, 20 Nov 2018 06:52:02 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAK1OR7c084589; Mon, 19 Nov 2018 19:24:27 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1542677067; bh=2VDfed9KY4h+R8FdQ2P0e/jfTBo+1N6PWOIRZasAyXU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wh1pept97PZpKSdXXCfCaRCZQpm2SQ3gW5MEg8Z8VFEixRNiEdGMn/6b2zu98ui60 0pqe5sgaKK6xbF4PjpFsd3tt20s9KuoYpoJzQYdmp/UjKQ56kKssN+gEDKV3PU3zW5 bMP1e0yJLOsygg8CrVC8Nk37mzZHpLcFmM1Jn7hQ= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAK1OR4h128541 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 Nov 2018 19:24:27 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 19 Nov 2018 19:24:27 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 19 Nov 2018 19:24:27 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAK1ORQ7001274; Mon, 19 Nov 2018 19:24:27 -0600 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id wAK1OQx26497; Mon, 19 Nov 2018 19:24:26 -0600 (CST) From: Grygorii Strashko To: "David S. Miller" , Kishon Vijay Abraham I , Antoine Tenart , Quentin Schulz , Russell King - ARM Linux , Maxime Chevallier CC: , Sekhar Nori , , , Tony Lindgren , , , Alexandre Belloni , Vivek Gautam , Maxime Ripard , Chen-Yu Tsai , Carlo Caione , Chunfeng Yun , Matthias Brugger , Manu Gautam , Grygorii Strashko Subject: [PATCH v3 3/5] phy: ocelot-serdes: convert to use eth phy mode and submode Date: Mon, 19 Nov 2018 19:24:22 -0600 Message-ID: <20181120012424.11802-4-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.5 In-Reply-To: <20181120012424.11802-1-grygorii.strashko@ti.com> References: <20181120012424.11802-1-grygorii.strashko@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert ocelot-serdes PHY driver to use recently introduced PHY_MODE_ETHERNET and phy_set_mode_ext(). Cc: Quentin Schulz Signed-off-by: Grygorii Strashko --- drivers/net/ethernet/mscc/ocelot.c | 9 ++------- drivers/phy/mscc/phy-ocelot-serdes.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) -- 2.10.5 Reviewed-by: Quentin Schulz Tested-by: Quentin Schulz diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 3238b9e..3edb608 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -472,7 +472,6 @@ static int ocelot_port_open(struct net_device *dev) { struct ocelot_port *port = netdev_priv(dev); struct ocelot *ocelot = port->ocelot; - enum phy_mode phy_mode; int err; /* Enable receiving frames on the port, and activate auto-learning of @@ -484,12 +483,8 @@ static int ocelot_port_open(struct net_device *dev) ANA_PORT_PORT_CFG, port->chip_port); if (port->serdes) { - if (port->phy_mode == PHY_INTERFACE_MODE_SGMII) - phy_mode = PHY_MODE_SGMII; - else - phy_mode = PHY_MODE_QSGMII; - - err = phy_set_mode(port->serdes, phy_mode); + err = phy_set_mode_ext(port->serdes, PHY_MODE_ETHERNET, + port->phy_mode); if (err) { netdev_err(dev, "Could not set mode of SerDes\n"); return err; diff --git a/drivers/phy/mscc/phy-ocelot-serdes.c b/drivers/phy/mscc/phy-ocelot-serdes.c index c61a9890..77c46f6 100644 --- a/drivers/phy/mscc/phy-ocelot-serdes.c +++ b/drivers/phy/mscc/phy-ocelot-serdes.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -104,20 +105,24 @@ struct serdes_mux { u8 idx; u8 port; enum phy_mode mode; + int submode; u32 mask; u32 mux; }; -#define SERDES_MUX(_idx, _port, _mode, _mask, _mux) { \ +#define SERDES_MUX(_idx, _port, _mode, _submode, _mask, _mux) { \ .idx = _idx, \ .port = _port, \ .mode = _mode, \ + .submode = _submode, \ .mask = _mask, \ .mux = _mux, \ } -#define SERDES_MUX_SGMII(i, p, m, c) SERDES_MUX(i, p, PHY_MODE_SGMII, m, c) -#define SERDES_MUX_QSGMII(i, p, m, c) SERDES_MUX(i, p, PHY_MODE_QSGMII, m, c) +#define SERDES_MUX_SGMII(i, p, m, c) \ + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_SGMII, m, c) +#define SERDES_MUX_QSGMII(i, p, m, c) \ + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_QSGMII, m, c) static const struct serdes_mux ocelot_serdes_muxes[] = { SERDES_MUX_SGMII(SERDES1G(0), 0, 0, 0), @@ -154,7 +159,7 @@ static const struct serdes_mux ocelot_serdes_muxes[] = { SERDES_MUX_SGMII(SERDES6G(1), 8, 0, 0), SERDES_MUX_SGMII(SERDES6G(2), 10, HSIO_HW_CFG_PCIE_ENA | HSIO_HW_CFG_DEV2G5_10_MODE, 0), - SERDES_MUX(SERDES6G(2), 10, PHY_MODE_PCIE, HSIO_HW_CFG_PCIE_ENA, + SERDES_MUX(SERDES6G(2), 10, PHY_MODE_PCIE, 0, HSIO_HW_CFG_PCIE_ENA, HSIO_HW_CFG_PCIE_ENA), }; @@ -164,12 +169,17 @@ static int serdes_set_mode(struct phy *phy, enum phy_mode mode, int submode) unsigned int i; int ret; + /* As of now only PHY_MODE_ETHERNET is supported */ + if (mode != PHY_MODE_ETHERNET) + return -EOPNOTSUPP; + for (i = 0; i < ARRAY_SIZE(ocelot_serdes_muxes); i++) { if (macro->idx != ocelot_serdes_muxes[i].idx || - mode != ocelot_serdes_muxes[i].mode) + mode != ocelot_serdes_muxes[i].mode || + submode != ocelot_serdes_muxes[i].submode) continue; - if (mode != PHY_MODE_QSGMII && + if (submode != PHY_INTERFACE_MODE_QSGMII && macro->port != ocelot_serdes_muxes[i].port) continue;