Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7854189rwb; Tue, 6 Dec 2022 10:38:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4kKbGtrY3xf51GWKlvzqCCH93I+nsHhwlcFMclVLPU7hMV2X7lGJty18cO8bJa5sVD/B4+ X-Received: by 2002:a17:90b:30cf:b0:219:fda3:3b28 with SMTP id hi15-20020a17090b30cf00b00219fda33b28mr4446237pjb.150.1670351926601; Tue, 06 Dec 2022 10:38:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670351926; cv=none; d=google.com; s=arc-20160816; b=HYcZ6L1t+yWX8eMAZovChoEVHN44JKgywjRhmu2x4m1hf+NZOZgR4tj2vqv5xadXRm XVjlJqCenq5J+1AJuXZQyxULJw1Qan5wZKil+xXSTt5i2lwxgonDgj5jtwaIP/DSFdAq 1TOvu/Y6c4ufBQPmvcBEf2SNLLFMtUVyQIx54MPtbIOOENzzdBjQhFnYcjQ+uG6BvpMw nVLoJEgKBnchjI9e9gHmlYmg2nq2+PtPuVXtHIEfE0j6FgUggX2eqB40a5lLQbZb6aun WJzUjp66KOZShH0ZRo5+zAY6H8Mu41f8+gZv1owbEo+EJSeJ/E63ViqCDeX26SLRf+cF Z4eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jtIWr9ch7YDQuR1NkAMllmQYeC+7Fh/NFmZpcbpce2c=; b=kJ+pudEReH8eaGvWPSQJRvFEN6Q9tuiAzcL6a9xWKXAnMc/kTUiPUx2QDX6wQ0oB99 0WGVKBq9CU2uEV+bD2SiMt7qRIA8zohF378qPIIlTJLoaH/1uHJOiASNqzm5I3+ZrM5g juFkeTYm3cdUWHLmdtZCOK6JgIm9suDnqZ3jtMocGkZtEpf7U6UVhmx+7Md7DMPxE1u6 0UpSyWYIAIcuB0oR6vK7C+ghsiqFHXmRLjep/rtb7Tuj880UIDOI0VoXUBKqJP48NY7b pv3vxkLe6fzNAR1q1LXdpQklWO4IMuBMhgJZzLNe2hriboFPeidSKiGxlmHdb0SmOoH+ xZbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DBa9yjWk; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw1-20020a17090b180100b001ed40b70436si19620831pjb.155.2022.12.06.10.38.36; Tue, 06 Dec 2022 10:38:46 -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=@gmail.com header.s=20210112 header.b=DBa9yjWk; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbiLFSH6 (ORCPT + 77 others); Tue, 6 Dec 2022 13:07:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbiLFSHs (ORCPT ); Tue, 6 Dec 2022 13:07:48 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D8DF013; Tue, 6 Dec 2022 10:07:47 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id vp12so8151776ejc.8; Tue, 06 Dec 2022 10:07:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jtIWr9ch7YDQuR1NkAMllmQYeC+7Fh/NFmZpcbpce2c=; b=DBa9yjWkmwV3z7XRAKL/zuLsHeVUJihbjUO3drpJlSPjw4rJEoYnOH58htDTTNpfpp Ojk4wffktsZ/F6KS8p785i2F658k40JRcYSyttdNVHJUw34c6kaS2m8ipzz/mYUo5YET L2wZlIEYOZmcSIvwvIqITXeEzGpGe52nAs/AgUDoxgL6joEZo6/nklEBqLVIwr/cEZkx +/U2lZ+mBqFymv0RZFOqsvaAfyn7o1kzdM113Tc1TAOGLo9oy2k8yuOBBmgFaVx/rafO P86J+OgWQXX08wv4OOk6Qhaj8/tuuLIZhoPSij/Oo6LGpbMpp3W2cpjVaPLwyuRb+b6u 8gDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jtIWr9ch7YDQuR1NkAMllmQYeC+7Fh/NFmZpcbpce2c=; b=d25hXdSbHMQeGPauDc3yDQhe6C1kiQ8I0cZIu8le0rSBVbaO+3miCtsVfD6pbd6+cd OKnJfSyhF9uwT/Ct0gY4KQvk9xSMgYUkHg9ktxMNPZ5rw2ekHGiJAm9fhaMENrtAJUdF NGInIvLf42Xof31s9sb+N+QG1oPiPZh/lLyFV26nuLFdsGrtCoV53j1sqE6vGsMpNbMt qgNj3I7/Mkyke43HPdOWApKG8kCGv3rRLtHaw80/8k3snKXaP1QCKs2gNtdHazHLFHPk j2FCSXDl+OzVZxwyMTbAyzFJDkwZc6YOraGo0nx2HSQGxjQEPm00/k5Bv2ojEX0Qeecz 6YcQ== X-Gm-Message-State: ANoB5pl/UZKEAB/DYPLF0rVpgBRKw7OHKLUnWq9JgmFMDKgI6/PsKqjU wiVA3o7jwosQWLlaLPycljo= X-Received: by 2002:a17:906:830f:b0:7c0:a3c6:e788 with SMTP id j15-20020a170906830f00b007c0a3c6e788mr11382813ejx.476.1670350066157; Tue, 06 Dec 2022 10:07:46 -0800 (PST) Received: from gvm01 (net-2-45-26-236.cust.vodafonedsl.it. [2.45.26.236]) by smtp.gmail.com with ESMTPSA id l12-20020aa7d94c000000b0046b1d63cfc1sm1233187eds.88.2022.12.06.10.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 10:07:45 -0800 (PST) Date: Tue, 6 Dec 2022 19:07:56 +0100 From: Piergiorgio Beruto To: Andrew Lunn Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: Re: [PATCH v4 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration Message-ID: References: <4c6bb420c2169edb31abd5c4d5fe04090ed329e4.1670329232.git.piergiorgio.beruto@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Tue, Dec 06, 2022 at 02:59:39PM +0100, Andrew Lunn wrote: > > +/* MDIO Manageable Devices (MMDs). */ > > +#define MDIO_MMD_OATC14 MDIO_MMD_VEND2 > > As i said in a comment somewhere, i would prefer you use > MDIO_MMD_VEND2, not MDIO_MMD_OATC14. We want the gentle reminder that > these registers can contain anything the vendor wants, including, but > not limited to, PLCA. Ok, I'll fix that. > > +/* Open Alliance TC14 PLCA CTRL0 register */ > > +#define MDIO_OATC14_PLCA_EN 0x8000 /* PLCA enable */ > > +#define MDIO_OATC14_PLCA_RST 0x4000 /* PLCA reset */ > > These are bits, so use the BIT macro. When this was part of mii.h, > that file used this hex format so it made sense to follow that > format. Now you are in a few file, you should use the macro. Sure, I just moved the code in the new file without thinking of changing this. Will do. > > +/* Open Alliance TC14 PLCA CTRL1 register */ > > +#define MDIO_OATC14_PLCA_NCNT 0xff00 /* PLCA node count */ > > +#define MDIO_OATC14_PLCA_ID 0x00ff /* PLCA local node ID */ > > + > > +/* Open Alliance TC14 PLCA STATUS register */ > > +#define MDIO_OATC14_PLCA_PST 0x8000 /* PLCA status indication */ > > + > > +/* Open Alliance TC14 PLCA TOTMR register */ > > +#define MDIO_OATC14_PLCA_TOT 0x00ff > > + > > +/* Open Alliance TC14 PLCA BURST register */ > > +#define MDIO_OATC14_PLCA_MAXBC 0xff00 > > +#define MDIO_OATC14_PLCA_BTMR 0x00ff > > + > > +#endif /* __MDIO_OPEN_ALLIANCE__ */ > > diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c > > index a87a4b3ffce4..dace5d3b29ad 100644 > > --- a/drivers/net/phy/phy-c45.c > > +++ b/drivers/net/phy/phy-c45.c > > @@ -8,6 +8,8 @@ > > #include > > #include > > > > +#include "mdio-open-alliance.h" > > + > > /** > > * genphy_c45_baset1_able - checks if the PMA has BASE-T1 extended abilities > > * @phydev: target phy_device struct > > @@ -931,6 +933,184 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable) > > } > > EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain); > > > > +/** > > + * genphy_c45_plca_get_cfg - get PLCA configuration from standard registers > > + * @phydev: target phy_device struct > > + * @plca_cfg: output structure to store the PLCA configuration > > + * > > + * Description: if the PHY complies to the Open Alliance TC14 10BASE-T1S PLCA > > + * Management Registers specifications, this function can be used to retrieve > > + * the current PLCA configuration from the standard registers in MMD 31. > > + */ > > +int genphy_c45_plca_get_cfg(struct phy_device *phydev, > > + struct phy_plca_cfg *plca_cfg) > > +{ > > + int ret; > > + > > + ret = phy_read_mmd(phydev, MDIO_MMD_OATC14, MDIO_OATC14_PLCA_IDVER); > > + if (ret < 0) > > + return ret; > > + > > + plca_cfg->version = ret; > > It would be good to verify this value, and return -ENODEV if it is not > valid. Got it, thanks. Piergiorgio