Received: by 10.192.165.148 with SMTP id m20csp79300imm; Fri, 4 May 2018 07:01:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZofjFzJYb98WSWJFfkt/OQCw9tEvUGsAcTtWvGG1yUtvtQ5UH/8XTH89esZvlG9PdDEpWV2 X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr2810111plg.229.1525442486736; Fri, 04 May 2018 07:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525442486; cv=none; d=google.com; s=arc-20160816; b=JKxtFWHNp7Rzki5myFdJbnbdQWgZYb+Ly2K8Ofxnr3LyHgioTfSI7SZlKKCLhhtvBD BglIm1XoVQmxEagFLmCdQSG7bAWKlDOGkhUgWsmK4f8L+WLrNkT0G3c2sxzBQoUHxB6o QSmrJ1XQbh2XCTpO+84GZtGh7BEFAYZoC7/31Pbw7PG1HpdKipaRVfj/XgJz2rd26tGi QBR5PELPs7h0811rzoC/RN9J4sL3ZtvDAsMkkvN/bXuTjeHaczLAguenswYpsEkOyyfG fKufPPHvTBaVdz89f6/krcaqYeV8GBqpZ/Q2n2xBeXAyUUPFTMrVeF9Ly8mI4adbnWla hLjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=L7d/H6545C086JbK2SEcOuJePYM/t8eEZwuI+MwcQ1I=; b=H1ksCSW2P+I4aWlP7vLYlQjs2GJnMGvkCBk0k2jItM4RZk0G3k79hVG7VXFapzWU/x BrwdqNrDt6eudlo+HY/7kWzntDZtSsIyJV0Ic+XqC/aCWXjiESiaZCBOPTdZDxz48P7B CF4QBeqctsN2CJRPCXlxx/3cZQxP/Sln9yAfNDAlgnRVZbcbSUcb9dmZ0Bmg6r/NRNh9 trWgHB9dlxVSkDOB7S9sfDgPVrWI0t5Pz+G5qHRpgHY56xAPCdpaReQQFJnj2rAQNKce 1A4lDkwcB37RV4yQ6Jvv/2YXAY+843FvWoNK8TyAMCPb4bcWqCAySw/UF4BatUatx6Ln BwkQ== 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 t27si16530079pfm.150.2018.05.04.07.01.12; Fri, 04 May 2018 07:01:26 -0700 (PDT) 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 S1752064AbeEDOAV (ORCPT + 99 others); Fri, 4 May 2018 10:00:21 -0400 Received: from mail.bootlin.com ([62.4.15.54]:60392 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751572AbeEDOAN (ORCPT ); Fri, 4 May 2018 10:00:13 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id A422820A36; Fri, 4 May 2018 16:00:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 73ECD207D4; Fri, 4 May 2018 16:00:01 +0200 (CEST) From: Antoine Tenart To: davem@davemloft.net, kishon@ti.com, linux@armlinux.org.uk, gregory.clement@bootlin.com, andrew@lunn.ch, jason@lakedaemon.net, sebastian.hesselbarth@gmail.com Cc: Antoine Tenart , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, maxime.chevallier@bootlin.com, miquel.raynal@bootlin.com, nadavh@marvell.com, stefanc@marvell.com, ymarkman@marvell.com, mw@semihalf.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next v2 02/13] net: phy: sfp: handle non-wired SFP connectors Date: Fri, 4 May 2018 15:56:32 +0200 Message-Id: <20180504135643.23466-3-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504135643.23466-1-antoine.tenart@bootlin.com> References: <20180504135643.23466-1-antoine.tenart@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SFP connectors can be solder on a board without having any of their pins (LOS, i2c...) wired. In such cases the SFP link state cannot be guessed, and the overall link status reporting is left to other layers. In order to achieve this, a new SFP_DEV status is added, named UNKNOWN. This mode is set when it is not possible for the SFP code to get the link status and as a result the link status is reported to be always UP from the SFP point of view. Signed-off-by: Antoine Tenart --- drivers/net/phy/sfp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 4686c443fc22..8e323a4b70da 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -48,6 +48,7 @@ enum { SFP_DEV_DOWN = 0, SFP_DEV_UP, + SFP_DEV_UNKNOWN, SFP_S_DOWN = 0, SFP_S_INIT, @@ -737,6 +738,15 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event) sfp->sm_dev_state = SFP_DEV_DOWN; } break; + + case SFP_DEV_UNKNOWN: + /* We can't know the state of the SFP link. Report the + * link as being up as its status has to be guessed by + * other layers. + */ + if (event != SFP_E_DEV_UP) + sfp_link_up(sfp->sfp_bus); + break; } /* Some events are global */ @@ -1077,6 +1087,12 @@ static int sfp_probe(struct platform_device *pdev) if (poll) mod_delayed_work(system_wq, &sfp->poll, poll_jiffies); + /* We won't be able to know the state of the SFP link, report it as + * unknown. + */ + if (!sfp->gpio[GPIO_MODDEF0] && !sfp->gpio[GPIO_LOS]) + sfp->sm_dev_state = SFP_DEV_UNKNOWN; + return 0; } -- 2.17.0