From patchwork Thu Feb 9 15:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 54995 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp392760wrn; Thu, 9 Feb 2023 07:17:01 -0800 (PST) X-Google-Smtp-Source: AK7set/Q+52ChYDECXk+0+3yGZ0WIAOOLAALCnaklMQNt0ZsgClAXHC4/+6sdUrj6wH4y0rKaS5V X-Received: by 2002:a05:6a20:8f06:b0:a3:8eb5:6869 with SMTP id b6-20020a056a208f0600b000a38eb56869mr15885386pzk.14.1675955821314; Thu, 09 Feb 2023 07:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675955821; cv=none; d=google.com; s=arc-20160816; b=DHkk1O10RicNqiFAqXwK8/b1RXP76fNOPJ0dUrjSm//JsME7sCgs/o2CT/X3d0wwe7 rIYV/6Tv7t33CyuCtG2GWp7F+0JlPxT06tpYL1M/3gWp38sBJy9fdYXo6SQA6Oejey8E sD6n+4YNgKZZStJ+sGQED2OdKuuqnRjlQ4khW/n0GBOzR5VK0EWltVm3eUWfArD2myRW g13I9qNXdNzssEUmqSkBA8yGkq0ZGeTRWgdlDF8ir00215K8hm0qYiiUWz6/VK1aHxBe lkBcMX2kZu+7ogYRhCEDCbVohJh3bcnsqsBG6tGaCAq00F2O2ZLhrIVDMUYBfi1z3Jks SsOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1zV1VFrWVhQ6vhXF/fCLwcz9IjHBuYzryMaqXBU05Vo=; b=mu7TroQdsoDGe1EtlIVS89GD9Tc8DkBMlQdOPg0cXvVLS81xTSl4g/B0ofLCrtCMIi j2eiL5KcdOWyOevPEMY17/9GyTgFH6w1aui9CXlsI5UHlNHM2/hA3n4Aik9GKvxcekAv b65eeA914zBNYsxDiihqGMUMyrsE0h/3Pa8wUWXHzaUGXwYjhTUTZSLK0Noe4yvolUmH MZoCU70AenHPZOnMTfwEQN1I9+y/CAxmBlOVuQ0h9zYLjKTcGW4kYyYO7PqNb7vLXzii ge9F15CPih4DhuoG5JEcoNAI76YmtGv3ZM2/v0n20WIOhgEGN7X0rT8HRUqZ5TY8eA2c EoNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mg31+fwm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l192-20020a6391c9000000b004f3884d5b04si2097557pge.779.2023.02.09.07.16.48; Thu, 09 Feb 2023 07:17:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mg31+fwm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbjBIPOd (ORCPT + 99 others); Thu, 9 Feb 2023 10:14:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbjBIPO2 (ORCPT ); Thu, 9 Feb 2023 10:14:28 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2199F60E60; Thu, 9 Feb 2023 07:14:21 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id C3FEA10000E; Thu, 9 Feb 2023 15:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675955660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1zV1VFrWVhQ6vhXF/fCLwcz9IjHBuYzryMaqXBU05Vo=; b=mg31+fwmnqE8u7cGEi/QGe/SMl4+BaYKkpQi1C+HTGPppCfF+Fha0WJeq4chwPPf2489cK 2zMxvzC6h+MfgiCzZEBddNfqlAo0C5/EcRXdb+fqm89SdLoxwZ0gFn1jHBP4/B5jBsApVK DokxQO5wmtMmkBJJ30Z4uZUnRmZmIP3opk9DRGl10MawKt37a4xL7RBgOqjOJPAqCoKChQ 1W2UE3sxFea/w39bZ5kTSPnoHicRv+Gei5bvsQKM+0pHu7d8EO2pcyPOUGTnd6WJNgTsrG msyjEBkI3aUeXQ9Z4S82IPRPmXfJgYlXJZbRVuKucSIFlptwK2SvpsWEJbuA1g== From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Sergey Shtylyov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Magnus Damm , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Russell King , Wong Vee Khee , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Kurt Kanzenbach , Revanth Kumar Uppala , Tan Tee Min Cc: Thomas Petazzoni , Herve Codina , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Milan Stevanovic , Jimmy Lalande , Pascal Eberhard , Mohammad Athari Bin Ismail , Jon Hunter , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next v3 1/6] net: pcs: rzn1-miic: add pcs_early_setup() function Date: Thu, 9 Feb 2023 16:16:27 +0100 Message-Id: <20230209151632.275883-2-clement.leger@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230209151632.275883-1-clement.leger@bootlin.com> References: <20230209151632.275883-1-clement.leger@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757367051392767147?= X-GMAIL-MSGID: =?utf-8?q?1757367051392767147?= When using this PCS with the stmmac IP, if the pcs is not configured and enabled before setting up stmmac hardware, driver setup will fail due to the lack of input RGMII RX clock. Add pcs_early_setup() function which allows to configure the MIIC converter based on the "phy-mode" that is described in the device-tree. Signed-off-by: Clément Léger --- drivers/net/pcs/pcs-rzn1-miic.c | 12 ++++++++++++ include/linux/pcs-rzn1-miic.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c index c1424119e821..e2eaf789c4d2 100644 --- a/drivers/net/pcs/pcs-rzn1-miic.c +++ b/drivers/net/pcs/pcs-rzn1-miic.c @@ -288,6 +288,18 @@ static const struct phylink_pcs_ops miic_phylink_ops = { .pcs_link_up = miic_link_up, }; +int miic_early_setup(struct phylink_pcs *pcs, struct device *dev) +{ + int interface; + + interface = device_get_phy_mode(dev); + if (interface < 0) + return interface; + + return miic_config(pcs, 0, interface, NULL, false); +} +EXPORT_SYMBOL(miic_early_setup); + struct phylink_pcs *miic_create(struct device *dev, struct device_node *np) { struct platform_device *pdev; diff --git a/include/linux/pcs-rzn1-miic.h b/include/linux/pcs-rzn1-miic.h index 56d12b21365d..84d7130b4b78 100644 --- a/include/linux/pcs-rzn1-miic.h +++ b/include/linux/pcs-rzn1-miic.h @@ -9,8 +9,11 @@ #define __LINUX_PCS_MIIC_H struct phylink; +struct phylink_pcs; struct device_node; +int miic_early_setup(struct phylink_pcs *pcs, struct device *dev); + struct phylink_pcs *miic_create(struct device *dev, struct device_node *np); void miic_destroy(struct phylink_pcs *pcs);