From patchwork Wed Feb 8 16:41:58 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: 54494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3559541wrn; Wed, 8 Feb 2023 08:41:28 -0800 (PST) X-Google-Smtp-Source: AK7set8/1ppBCYxAzEx28If7S2pXgC6z+8i6VJUptgdngq748Sa7gSjtS+ohzxX487lS8Fevweyx X-Received: by 2002:a17:90a:4f0c:b0:230:be88:69a with SMTP id p12-20020a17090a4f0c00b00230be88069amr7069306pjh.3.1675874487815; Wed, 08 Feb 2023 08:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874487; cv=none; d=google.com; s=arc-20160816; b=aYJBfypbOuHwMRAXVfxp8/XSHajtcq6ljU/6OTB4u8lRO0S6NDeI+VhcpT4EcskyaQ dJW8kI07tuv3yvjSVFV3vTbxZ4QBRUh9Vm3Pk/jlj7HMH4YOtiUKxlPtD42oG08NZuYE 1op/5CwYicXYm0tRXodeP+9GO7EG2o/kGALbNqfqvq/7bnumnp/yy+4pYCFvA0ULA5CC J6zX5sztmnNYolbS9LsJ9PyLDtVPyjMEeVOOnaTqDTWmd3cqCCCk7S+yVt19Vig1XGqx 1WLTvvFxWLu1W6bRxPR61NpWxW1lkjCTQG6v6vd+vhCrXVUHSBQcI7c0l20erhkZBAgV MsDQ== 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=OR55iGtFPIOj2473uX69Y0IDdG0CoIDK9y/DVzYiLSD/nTzCcYrnCR+Yi4zvWzGvgN GtEOcCuQTjePH+sGlsu+lESs1rWqHOZh5v9/7Gm/09qulj0C4zKjaa3Use0TGf1p8/AV JdD3pnAhlpqdHkkjFfefLUEOUKoKqxNykmFuAAIL8wSmAcMvf5oMcqCv0APUPguB6MTX PryLvBsGSbe78xTQ/zzV/WUQJ2nWKR43Rom+Xa8dup489C2Z7Yewz4nk0NjbQgiqPfl2 aBQsG1Fvjm10xix3q67UiOalQIvJ2qSzBnVLsVjgOZkmP0iScGzG4zp5bxa1z6e7FG8r dzmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="bsr2kT8/"; 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 13-20020a17090a190d00b0022929341650si2685664pjg.15.2023.02.08.08.41.14; Wed, 08 Feb 2023 08:41:27 -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="bsr2kT8/"; 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 S231713AbjBHQkn (ORCPT + 99 others); Wed, 8 Feb 2023 11:40:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjBHQk2 (ORCPT ); Wed, 8 Feb 2023 11:40:28 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7740F4DBE8; Wed, 8 Feb 2023 08:40:22 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 36E231BF209; Wed, 8 Feb 2023 16:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675874421; 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=bsr2kT8/fs5ycb41yzV5D54Na9MB0RfaRaz/6VBRiG9lnEj506WDX5EFWJbhJ9f9+cc+se 2srr6LKvbSutYzurG4hnAQYFcFmaPaHNO6rikx9pRpXY2XUWqXiMpwjs/rtViOJzTFcQT6 fSuuM3Mu67AGYUDEMsDt+vSQG9R7u27Msf4jnskpsYrVrHPWGbQJ1wv0eyK1brGcrBwxz8 GoVuevDB6Ep2WV7zfFfJvtWZ+K0ONsjugPgnC//YBHlj9EcDmvqagdg/CITSnvNfHpjgEm Ey22ZDxQPP28DIXD11BR4m4IZLtAV8WneDCssRBhlFWDLBNk5QYmoEHr7miOYg== 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 v2 1/6] net: pcs: rzn1-miic: add pcs_early_setup() function Date: Wed, 8 Feb 2023 17:41:58 +0100 Message-Id: <20230208164203.378153-2-clement.leger@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230208164203.378153-1-clement.leger@bootlin.com> References: <20230208164203.378153-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?1757281766528504738?= X-GMAIL-MSGID: =?utf-8?q?1757281766528504738?= 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);