Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6553747rwi; Mon, 24 Oct 2022 03:03:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EVfAGwf7H/SVlftCnPb/XI5dkXeiU4WdQiPIxU4qW9CelU89w/qCsK+IcFJwqTXQZqf2b X-Received: by 2002:a65:6e0e:0:b0:434:59e0:27d3 with SMTP id bd14-20020a656e0e000000b0043459e027d3mr26720855pgb.185.1666605802607; Mon, 24 Oct 2022 03:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666605802; cv=none; d=google.com; s=arc-20160816; b=WQ5iS3OOHdx+ow8cwS6rJhWRNRgldjxWQZ66zFqA36FeF7N/HHcVOyyT7b5z1i6idk 2o+4InXW5z6fNfExWINhgkFT9iN69zEJo6/XPMO2QACk3MWBfSny+ARx53cxi5oJRQY2 qxhjCx7lm5v3EaCKpm7kVy7MhNMLvi2v2HAVei2DBtl9lkVImmS7uPxWZT+4JkpwAQWm l5rDQzxPB3ddapshvyV1pNu8mbpVAs0/ly1m1f6iQWUbK+l08bTlazbq48a6OXFecxs3 cl2XIlcLrPLlDhus1llnilnZB8PSre3/axbIUfBC81xREnWMPInwWNZbWX+5JDs9QV1q Vs0g== 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=zVcWy0O+1OS4uchmB17Fzty+Ou9Hxm0cCjuj0rbjdBc=; b=WrYr0DRjjnfJ+3/Gk3eEJSfU0f6jpVhw9GRw8e5Tpe5TaiWdosg9/2oEi/wj91KGcP O8m+vpA6rBW2uSJ/gIJnWiy5uO8+2HDaiFlpMJ3CQpzTXTAYNVeQ9WQC8AZd3UBrlF/4 3HRs6Wcngp3D4mE2gRt/pANw6rnXXZVa66DZBVvEWWxWUWp4+hIiIlSlPCWIzHO6OdS7 mzbiEm35bujQxMN2kdZSNiUw7/UMLAEGAj0fQbioUR8yz+005mmSnCqAj3M9Im4n29WT K9chYyMhgQyg5ji+GP7zapbFqwtG2W3wFMQyxUQ2FD1M29oCReZ5XbzZcwjS3ruAZLZ5 wFNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="adNPW/Db"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020a056a00188200b00535fa14ffaasi39982314pfh.116.2022.10.24.03.03.09; Mon, 24 Oct 2022 03:03:22 -0700 (PDT) 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=@microchip.com header.s=mchp header.b="adNPW/Db"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbiJXJwX (ORCPT + 99 others); Mon, 24 Oct 2022 05:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJXJwW (ORCPT ); Mon, 24 Oct 2022 05:52:22 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 241A9BF4B; Mon, 24 Oct 2022 02:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666605142; x=1698141142; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=VKA0TLvqW6SrGdoMkbABZt9c/Z5KNe1Vij6Iqbim3mM=; b=adNPW/Db61VCESgQ/vYJZRYnljKZYekUj9pFDi5I2gdDKsW60bHmLEay pspHF8z7sIUIPFLaOrRROL4a++sk24K1JJkA5sPyu6E9wgOhsNg5EIrGf Obb7J6l2on9AyBEm3JZeldx585lS54a8RcPdWME7YQPqVTuZfUFdSQyDs g7P6ac02bBVQJJhfl0svmFj1pZPm8SttpTWrHTG+tql3LyUOrhPp5OnSA DCq6v2oWvzHcfeSDfOBYumsMk1Zv0kVAgxnNwoxBEq3j2eBN2/kLJ6C8Y rAIYpiGQT8gYcUQyxIjOAGO2q/0FB9YX9PzfJBRxGoeWHfmJQxIvNhiwa Q==; X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="180209758" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Oct 2022 02:52:21 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 24 Oct 2022 02:52:20 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 24 Oct 2022 02:52:19 -0700 Date: Mon, 24 Oct 2022 11:56:59 +0200 From: Horatiu Vultur To: Raju Lakkaraju CC: , , , , , , , , , , , Subject: Re: [PATCH net-next V1 2/2] net: phy: micrel: Add PHY Auto/MDI/MDI-X set driver for KSZ9131 Message-ID: <20221024095659.aurdnuurytjzgav5@soft-dev3-1> References: <20221024082516.661199-1-Raju.Lakkaraju@microchip.com> <20221024082516.661199-3-Raju.Lakkaraju@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20221024082516.661199-3-Raju.Lakkaraju@microchip.com> X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,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 The 10/24/2022 13:55, Raju Lakkaraju wrote: > Add support for MDI-X status and configuration for KSZ9131 chips Reviewed-by: Horatiu Vultur > > Signed-off-by: Raju Lakkaraju > --- > Change List: > ============ > V0 -> V1: > - Drop the "_" from the end of the macros > - Add KSZ9131 MDI-X specific register contain 9131 in macro names > > drivers/net/phy/micrel.c | 77 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 77 insertions(+) > > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c > index 54a17b576eac..26ce0c5defcd 100644 > --- a/drivers/net/phy/micrel.c > +++ b/drivers/net/phy/micrel.c > @@ -1295,6 +1295,81 @@ static int ksz9131_config_init(struct phy_device *phydev) > return 0; > } > > +#define MII_KSZ9131_AUTO_MDIX 0x1C > +#define MII_KSZ9131_AUTO_MDI_SET BIT(7) > +#define MII_KSZ9131_AUTO_MDIX_SWAP_OFF BIT(6) > + > +static int ksz9131_mdix_update(struct phy_device *phydev) > +{ > + int ret; > + > + ret = phy_read(phydev, MII_KSZ9131_AUTO_MDIX); > + if (ret < 0) > + return ret; > + > + if (ret & MII_KSZ9131_AUTO_MDIX_SWAP_OFF) { > + if (ret & MII_KSZ9131_AUTO_MDI_SET) > + phydev->mdix_ctrl = ETH_TP_MDI; > + else > + phydev->mdix_ctrl = ETH_TP_MDI_X; > + } else { > + phydev->mdix_ctrl = ETH_TP_MDI_AUTO; > + } > + > + if (ret & MII_KSZ9131_AUTO_MDI_SET) > + phydev->mdix = ETH_TP_MDI; > + else > + phydev->mdix = ETH_TP_MDI_X; > + > + return 0; > +} > + > +static int ksz9131_config_mdix(struct phy_device *phydev, u8 ctrl) > +{ > + u16 val; > + > + switch (ctrl) { > + case ETH_TP_MDI: > + val = MII_KSZ9131_AUTO_MDIX_SWAP_OFF | > + MII_KSZ9131_AUTO_MDI_SET; > + break; > + case ETH_TP_MDI_X: > + val = MII_KSZ9131_AUTO_MDIX_SWAP_OFF; > + break; > + case ETH_TP_MDI_AUTO: > + val = 0; > + break; > + default: > + return 0; > + } > + > + return phy_modify(phydev, MII_KSZ9131_AUTO_MDIX, > + MII_KSZ9131_AUTO_MDIX_SWAP_OFF | > + MII_KSZ9131_AUTO_MDI_SET, val); > +} > + > +static int ksz9131_read_status(struct phy_device *phydev) > +{ > + int ret; > + > + ret = ksz9131_mdix_update(phydev); > + if (ret < 0) > + return ret; > + > + return genphy_read_status(phydev); > +} > + > +static int ksz9131_config_aneg(struct phy_device *phydev) > +{ > + int ret; > + > + ret = ksz9131_config_mdix(phydev, phydev->mdix_ctrl); > + if (ret) > + return ret; > + > + return genphy_config_aneg(phydev); > +} > + > #define KSZ8873MLL_GLOBAL_CONTROL_4 0x06 > #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX BIT(6) > #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED BIT(4) > @@ -3304,6 +3379,8 @@ static struct phy_driver ksphy_driver[] = { > .probe = kszphy_probe, > .config_init = ksz9131_config_init, > .config_intr = kszphy_config_intr, > + .config_aneg = ksz9131_config_aneg, > + .read_status = ksz9131_read_status, > .handle_interrupt = kszphy_handle_interrupt, > .get_sset_count = kszphy_get_sset_count, > .get_strings = kszphy_get_strings, > -- > 2.25.1 > -- /Horatiu