From patchwork Fri Jun 11 20:05:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12316553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1FF5C48BE0 for ; Fri, 11 Jun 2021 20:42:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 89246613C6 for ; Fri, 11 Jun 2021 20:42:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89246613C6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yOVWNFEwAShfdUyu6C+iP6IsNMvOsZF6NxnjzXIrt4c=; b=v839le0VNeFHUI kPlL7qDGP+9MjVtkvr5F+9cZb7T/i9eH0joZfJb2Buw1tEUcmoN2zUz1OTjB1z9X5S92bx7sFagP+ R5FPNCbhzdLk0qTvWKLRPuy8zlpbj/EqjvR0FHEVHxmy2ojNknK+a8fSLqmp+6X3Oz5O3c4P8HWDz WgEWGKyHzKa18a1X58wedAT8FAUeW0SRVBYT9f3BZA+9s8Wg9MpFQep1/zE8XPX/SYDUqTxUAwp/e N7nwJzCQtBi4XRj0ZFu4e1pKpL8qguVGHgMh7c4/G66WORfk1OAWRftoUlwoDjyjI3Y3auYehs7SU ySmQOrjkjk31loQXGQPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrnx0-006xST-2L; Fri, 11 Jun 2021 20:40:23 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrnPr-006omA-LQ for linux-arm-kernel@lists.infradead.org; Fri, 11 Jun 2021 20:06:09 +0000 Received: by mail-ed1-x52b.google.com with SMTP id cb9so38485497edb.1 for ; Fri, 11 Jun 2021 13:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jcd9ZhW9isRv7J3YGglkgaUD0FaC/eFCh9HeonDJwkI=; b=GeGkcqQ3m8oGz+kkSTZkm4+J8ZGhht4JwymPdga8IkLF8wejrOp/Kvo1gwV8PYye6x D9DrfPXjqI7H4j23+oc5Z1fnxV+DGVIgtJ8gokOaKA6RYw2Q46ASdqak8lkSzwZVmXnF 4CRwKtMNzsvk7u5jlJzMaEepAIy89LJygOq1f+eDltQTOmOfpD7Yc1MZ/zqY5MlALysS TaVMtxvuW0X730Hj88A3QEgE2cJAvmplttBNua4YJNgibAi+OH0cduv5jy9eF0DGedUJ 7WeLiiJzoTKn3wMnfV3vA6d8K4vsRdcz4cjmDwGjjSFZRRUlPoa5mLsUkRArjfIn4H5n CVYw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jcd9ZhW9isRv7J3YGglkgaUD0FaC/eFCh9HeonDJwkI=; b=olxm8B7ihYk4OKIEtZL1uBeGhsgO8260tccnUnK///4L987kGEdnw5SVPV2gEaxifG bZgxq93SREwoNNS0+dmfSEhRnccxnK1F3ka2r8FaKLePf3puq9ONuJ+xaAmhNmSkEGxV i6AQTMCWDWRuY5YVCISz27DFs7yG16QyUK9PPsgH1ygS1sgsNcLf5tTr9xm8xJQej9nb w43Y6/jSkFUu71R1+xdIuJPdKwYhOronq7WkpGq4AimlDtyh03i5iHrQOwYKvRrgpZeW RHdOCcI14oTfG+Vd2zzdvWF0bBEUM1HnWDQFhSsp5wog1eI8K6sPKhx4YdsFB4y0xcZy aCog== X-Gm-Message-State: AOAM532HAm6HseqojTfgPr9LDEx4UjcY/juTesNcFPj25B6smyPHDFpp sVG+1r+AX6XfbDeWcCo4xdE= X-Google-Smtp-Source: ABdhPJx1/rRabPdbstjHAYqg48IU+u3vo7eAHsgteeQAf+c1GOG5Az+u6lVkkTNt8eHJsGb1ZBE3Ug== X-Received: by 2002:a05:6402:1e8b:: with SMTP id f11mr5520991edf.86.1623441965754; Fri, 11 Jun 2021 13:06:05 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id w2sm2392084ejn.118.2021.06.11.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:06:05 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Vladimir Oltean Subject: [PATCH v3 net-next 13/13] net: dsa: sja1105: plug in support for 2500base-x Date: Fri, 11 Jun 2021 23:05:31 +0300 Message-Id: <20210611200531.2384819-14-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611200531.2384819-1-olteanv@gmail.com> References: <20210611200531.2384819-1-olteanv@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210611_130607_758551_831F83A6 X-CRM114-Status: GOOD ( 17.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Vladimir Oltean The MAC treats 2500base-x same as SGMII (yay for that) except that it must be set to a different speed. Extend all places that check for SGMII to also check for 2500base-x. Also add the missing 2500base-x compatibility matrix entry for SJA1110D. Signed-off-by: Vladimir Oltean --- v2->v3: none v1->v2: - add the 2500base-x check in one place where it was missing (before mdio_device_create) - remove it from a few places where it is no longer necessary now that we check more generically for the presence of priv->xpcs[port] drivers/net/dsa/sja1105/sja1105_main.c | 13 ++++++++++++- drivers/net/dsa/sja1105/sja1105_mdio.c | 3 ++- drivers/net/dsa/sja1105/sja1105_spi.c | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 3e32b8676fa7..8e5cdf93c23b 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1056,6 +1056,9 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, case SPEED_1000: speed = priv->info->port_speed[SJA1105_SPEED_1000MBPS]; break; + case SPEED_2500: + speed = priv->info->port_speed[SJA1105_SPEED_2500MBPS]; + break; default: dev_err(dev, "Invalid speed %iMbps\n", speed_mbps); return -EINVAL; @@ -1070,6 +1073,8 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, */ if (priv->phy_mode[port] == PHY_INTERFACE_MODE_SGMII) mac[port].speed = priv->info->port_speed[SJA1105_SPEED_1000MBPS]; + else if (priv->phy_mode[port] == PHY_INTERFACE_MODE_2500BASEX) + mac[port].speed = priv->info->port_speed[SJA1105_SPEED_2500MBPS]; else mac[port].speed = speed; @@ -1182,6 +1187,10 @@ static void sja1105_phylink_validate(struct dsa_switch *ds, int port, if (mii->xmii_mode[port] == XMII_MODE_RGMII || mii->xmii_mode[port] == XMII_MODE_SGMII) phylink_set(mask, 1000baseT_Full); + if (priv->info->supports_2500basex[port]) { + phylink_set(mask, 2500baseT_Full); + phylink_set(mask, 2500baseX_Full); + } bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); bitmap_and(state->advertising, state->advertising, mask, @@ -1942,7 +1951,9 @@ int sja1105_static_config_reload(struct sja1105_private *priv, if (!phylink_autoneg_inband(mode)) { int speed = SPEED_UNKNOWN; - if (bmcr[i] & BMCR_SPEED1000) + if (priv->phy_mode[i] == PHY_INTERFACE_MODE_2500BASEX) + speed = SPEED_2500; + else if (bmcr[i] & BMCR_SPEED1000) speed = SPEED_1000; else if (bmcr[i] & BMCR_SPEED100) speed = SPEED_100; diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c index 41468e51a38e..19aea8fb76f6 100644 --- a/drivers/net/dsa/sja1105/sja1105_mdio.c +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c @@ -427,7 +427,8 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) if (dsa_is_unused_port(ds, port)) continue; - if (priv->phy_mode[port] != PHY_INTERFACE_MODE_SGMII) + if (priv->phy_mode[port] != PHY_INTERFACE_MODE_SGMII && + priv->phy_mode[port] != PHY_INTERFACE_MODE_2500BASEX) continue; mdiodev = mdio_device_create(bus, port); diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c index 96768af4c6a8..7c493c6a839d 100644 --- a/drivers/net/dsa/sja1105/sja1105_spi.c +++ b/drivers/net/dsa/sja1105/sja1105_spi.c @@ -967,6 +967,8 @@ const struct sja1105_info sja1110d_info = { false, false, false, false, false, false}, .supports_sgmii = {false, true, true, true, true, false, false, false, false, false, false}, + .supports_2500basex = {false, false, false, true, true, + false, false, false, false, false, false}, .internal_phy = {SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_PHY_BASE_T1,