From patchwork Sun May 22 13:38:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1978 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5E32A3F05D for ; Sun, 22 May 2022 15:38:17 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id q12-20020a056402040c00b0042a84f9939dsf8934617edv.7 for ; Sun, 22 May 2022 06:38:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653226697; cv=pass; d=google.com; s=arc-20160816; b=nbOxL3Na17k/sRMbiYA3ZH6PURBRZ5C3dvZFeWZ9MOotBnE4Gt7koSiZ/flOskIFNt 5J879Zge3tsjhvqs+jEyTgXjY+PgKs1H50crTgN96NyFmBI3Ku4uZdoJVNioP+jpMdQS c7XWGJzt6Qm2b4sJIt+3p7UnkEwuY0e5VAQyTQKCzORwWMJ+F6Dj26FiYcqmK6xVhoZt vNqGwJY2xRDbAaDtnz2zTXxokX9a3ZrK9bqxOw1VmpOscaN+L/aeUdFiNIyCeM9pL2IS JbYYFPPuFduENb1e2YbOhXHDhBcPCc13lQxuxLrjgwtl2QHcGrHrYC5Q4MV4sHAkMRJs xAKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=1XNvf+1fKMVQbUUaydO3aKIe1Po6v4alzNFPb2SimIQ=; b=FWSZA9yxZwzIvW/D8kKJpixbDOwBJbEOVs+IL+Nzj9ttprGtKeJeuIcAYSD1pXHmkR 2EAVDF0qr0/U6eexrXmzXtXngruCnhAKzW7whJMOjLDgo81t/kksAH+0d6gBLDxnILUW AFuQp0o0otvSXzRbprmICwVS6fyg0p/kuxi8NeYHPR4OG/OM8cmJH4JGjmKhqf06412z x77W2BBLnfl+ADpDj6MuHl2h0HBPCAGykmIYMxXX09KJwKFCeTgkskBAE4OZQvVlPcsy fqVwMoWdOyiWFYyuEN5C967nvqsMZ7UihSVuVB5aVJk4YFUdplmAwJx304HSsjbam1id 7MYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BvCCJBHQ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=1XNvf+1fKMVQbUUaydO3aKIe1Po6v4alzNFPb2SimIQ=; b=Ch777+qk0QCUJVfPU5LZ2aWlISXu+iB5HCGoLt83+lfqaCIP+Z4be+024TsJf9EoRx DWv2KRlo1V4SIcvJAgGKp6tgV2rxLBQkEN1OnoeW4ebjXmM71j3zKCa88o33KPsKzR5Y AnW1pHfIpnlprmEdYenyAAN8X2dztezzLh204= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-unsubscribe; bh=1XNvf+1fKMVQbUUaydO3aKIe1Po6v4alzNFPb2SimIQ=; b=qHD26tVrtIyJEv8prvnQUgMKEyzHXflekx7WO/EbkPR48xWSGAbwru4zENaTZhisp2 5MO13d5ZMyk7hxeqT8oDOC45QqXNu2DldZV3fFGKFFlnTSolpAdFrtSPZqHthAfmlDUg OE/43Vkm+ZOyLuYFOJ73iYxyfqtEnyHHjrxZ6eJ9tv+P9CrJhA8u5KIfJcBmrb1cMJAb gRJISjXEFZYS04WFPqfJ9Zy/NwQQcHKlCVYrgiWht7QpuOt3iB7zBr5Ncop3lLntGdnS NWrrrpDteIxz3yqfN0p/XwsoCcD0A8SmYSPXcwcO5/TYf7bF1DZxpAacko8Bjn27cCrC W19g== X-Gm-Message-State: AOAM5324zzUz6P4UYQCZJvMY9NM4CKwY6nkB12LyuXtHICbhGVJs4lKr OstFU7RTMXrKUYfP9qYVVXlEyEbL X-Google-Smtp-Source: ABdhPJw4Y55NNlIQBr57ETTIZNrFJL9wtrDOue05jMX3WCnhFmN2MZP3JUQIPi+Qcj4U1w4mHBtr5g== X-Received: by 2002:a17:907:7d92:b0:6fd:bd33:f00f with SMTP id oz18-20020a1709077d9200b006fdbd33f00fmr15841041ejc.467.1653226696988; Sun, 22 May 2022 06:38:16 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2741:b0:41f:7eee:e393 with SMTP id z1-20020a056402274100b0041f7eeee393ls867799edd.3.gmail; Sun, 22 May 2022 06:38:15 -0700 (PDT) X-Received: by 2002:a05:6402:2750:b0:42b:2616:7cdb with SMTP id z16-20020a056402275000b0042b26167cdbmr13009429edd.306.1653226695593; Sun, 22 May 2022 06:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653226695; cv=none; d=google.com; s=arc-20160816; b=RhQlhYERq1UWdm8T3xlukFJUQylY9y3YWG0z9Z6bjWEwbH95XIOvXtk+JkuWoyh4A5 1uX5Y1CgOj4xVy7Alg2uXD5dBKNYaUq7Ph2cs8W33hiITfcojEc7Eumz42qZ13ltiaNi +WnJ97o7lfI2kXwT5PlqV7wr7c1LVDiPlmt+cijP8NozBastOZSNoTdTGOScBdiaRZQz OZ5tn/dbJwyZASbVxtKEkt3QFAVRGI/Qdiv0L4JZUpCh5odILQzxdLvGo2Qf4Z6OEFTi XiPjOpo6c9n/roOlxTgsiX9NLxSy5fKYrAy6UNRfsJxEwvSTuC/uDY5rNK8V8nyM5Omp umzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=Dqmu0Iahg3CS/5jd7u9PaALU1v41yhVtsfvP9I5+8DY=; b=WuBN7t9QG+qzalS5EgfARzFhQNPpMTkYUk3bHWaEMBGaFaNqdKX6xwxr6JSNng8nM+ KaLwQxnwL3A9fojdwCJ+lFu2cHs1eZHWsN25cW0O28dtxPg2xjrPpRHxfWVTM0SAKFBh JgzC3euw5E7BUwk1HZcq+g8xuWtKxDdShzgx2Ob79MFpL0ndHE55/rDVpTf/Lav9kXZV n9LZMnVv2oVa/kOmHukMt5GaVXppdfz6S10SP4BZfJBHEZFCrmuZEoXxjBYoLRWYJuNK nRDtWa/aH84H6jYKP/ouuywwm8bYeW7LGs4l56Ayck2ZiOSJ+IUHTJ1G5dRaMyW4A0+m 3iVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BvCCJBHQ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id j38-20020a05640223a600b00429e2f78c66sor7080738eda.4.2022.05.22.06.38.15 for (Google Transport Security); Sun, 22 May 2022 06:38:15 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:5193:b0:428:414d:e20d with SMTP id q19-20020a056402519300b00428414de20dmr19416172edd.173.1653226695286; Sun, 22 May 2022 06:38:15 -0700 (PDT) Received: from panicking.amarulasolutions.com (host-80-21-24-253.business.telecomitalia.it. [80.21.24.253]) by smtp.gmail.com with ESMTPSA id md17-20020a170906ae9100b006feaf472637sm2696906ejb.53.2022.05.22.06.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 06:38:14 -0700 (PDT) From: Michael Trimarchi To: Tommaso Merciai Cc: linux-amarula@amarulasolutions.com Subject: [PATCH 1/3] net: phy: DP83822: Clean up config_init code Date: Sun, 22 May 2022 15:38:11 +0200 Message-Id: <20220522133813.119729-1-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BvCCJBHQ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Rename some variables and reduce a bit code complexity. No functional changes Signed-off-by: Michael Trimarchi --- drivers/net/phy/dp83822.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index ce17b2af3218..c344b8ffaf3c 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -380,31 +380,26 @@ static int dp83822_config_init(struct phy_device *phydev) { struct dp83822_private *dp83822 = phydev->priv; struct device *dev = &phydev->mdio.dev; - int rgmii_delay; - s32 rx_int_delay; - s32 tx_int_delay; + int value = 0; + s32 trx_int_delay; int err = 0; int bmcr; if (phy_interface_is_rgmii(phydev)) { - rx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, + trx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, true); - if (rx_int_delay <= 0) - rgmii_delay = 0; - else - rgmii_delay = DP83822_RX_CLK_SHIFT; + if (trx_int_delay > 0) + value = DP83822_RX_CLK_SHIFT; - tx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, + trx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, false); - if (tx_int_delay <= 0) - rgmii_delay &= ~DP83822_TX_CLK_SHIFT; - else - rgmii_delay |= DP83822_TX_CLK_SHIFT; + if (trx_int_delay > 0) + value |= DP83822_TX_CLK_SHIFT; - if (rgmii_delay) { + if (value) { err = phy_set_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, rgmii_delay); + MII_DP83822_RCSR, value); if (err) return err; } From patchwork Sun May 22 13:38:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1979 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2D1AF3F05D for ; Sun, 22 May 2022 15:38:18 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id v1-20020a056402348100b0042b4442b954sf2622996edc.22 for ; Sun, 22 May 2022 06:38:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653226698; cv=pass; d=google.com; s=arc-20160816; b=xvJ+7hkoCmg13shxWyhj0iOfom6i6F2RJ8m0/RBukaavILcCKBbMGBizzAW6tQsHe0 ZK7OXZj0GWi9w1+/jo7poDNQkkcn+DMNzVhQ4esGyWsbRtzte5LuXKbB1gqwppxKY+ul sOdOgYIGQwQg1OmBFLZ0IYMhrjqAWcaUgt1BM9hRWJe9G46z248lt8H+6uQGz452mxiy bi/bqxhsVlO4ipRTTAfwfPq0dW/Kp9CGuF8OU2zf086U71w3CRhPtdI6UDbklwrh6xA3 bEMTGiXC5agQl1w6BDjihNxqvE5z/awTg4LXYQiJWmdLtsWn6UAzd69A/o7j5+mLUJ7k KKLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=UamjYqGMyMeqth+iaNne0gu/O+pnqWGxn7SpZk7tTtY=; b=Q1kq7YFe9oqbpyLTqFflGaTot/4soojUS5pNO9bFM3K/HXC/OGB2+WJXbx9SHmFSuD AKAiG5ccucp5vW7bx58mVWSpcSZP4dT5KADk/KfMEcDuq13+R4q92lQ1engTkuVOihJv CHZmj5aaggbPV5LHXChnkVu2pctheIuY/rPheVegBKcQ8/R+7LnhqimqsezvsR8brHck 7pjXoHX2ICiOP6kcDPFtws8Pvh/2qI+C9GM8kuASHs77cjahSqlJfO2UX47KTLxVMw4p O6N5Nm0UrpPrbiK8JiHs+kHWLUv75yAUAYYm4WbH0Ll36sOKU8Ri43Q21P9KmfG8MiEx R2hw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PDCJN7Ak; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=UamjYqGMyMeqth+iaNne0gu/O+pnqWGxn7SpZk7tTtY=; b=k7dMnzidoLBVSYefrsMwdArvG+r7/wm/e9renz9Vdj9Zy5M3lGD8O0TyqTmK81x0+w uAd3uTKeQcFmvpEiMQfTgZD0aRqEMR2zuyvX3MkHoOORLF2m3aaxi+cJL3kGE7QoD6X0 aN9vBixF6McPlzfE89X1OeR+qLKgx3033fc58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=UamjYqGMyMeqth+iaNne0gu/O+pnqWGxn7SpZk7tTtY=; b=2zCsvWNhB/CiusHwMKv0neMqQOMTaRZ6Vf1UDWlxPlAy9IxPMCQ2SVCL2KdghSvIQO 0nL1ew0czXQIXz3qteeTz5XN6QmxkXTj0Ymk6mnCAvCFrXm+vG61iMYV4471EJsVWi19 T+lgWB5Iy6Vz+iyBAM1+H5XvIsSJspkkR7OJUFTPfmf3Fu/agL/yGoqBqPS4mt2dxzvV MV9TTTT8F9ccwFJhILJb5b5qGgMBbKnI6/gZy6zinLywXFUWGWyA8gARoH2o0vFBxno8 hzU8J0deMHKwOptNjUGgF5+RCFD+YQMowuNDz0r3123FdYEUJAr+d0QuzBPOIp0Z0TOP dawg== X-Gm-Message-State: AOAM533Mxqj9rSUZVYfitkwHsoUGUelOHQky6iIobXZKH5BXAqOFpi4/ gaSTAoCZQJdmjtJ6KY6VlXyMESWT X-Google-Smtp-Source: ABdhPJxJ/ukf/Qu5qO6cUZBPsGaoW4+P7H9BeaLEBINjJp1b+o+MTh9LCLYrJQGCypCSjdb9yjymBA== X-Received: by 2002:a17:906:58c9:b0:6fd:f4fe:800a with SMTP id e9-20020a17090658c900b006fdf4fe800amr15596450ejs.285.1653226697915; Sun, 22 May 2022 06:38:17 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2741:b0:41f:7eee:e393 with SMTP id z1-20020a056402274100b0041f7eeee393ls867809edd.3.gmail; Sun, 22 May 2022 06:38:16 -0700 (PDT) X-Received: by 2002:a05:6402:5205:b0:42b:2678:998a with SMTP id s5-20020a056402520500b0042b2678998amr12750923edd.250.1653226696655; Sun, 22 May 2022 06:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653226696; cv=none; d=google.com; s=arc-20160816; b=wPlEQzK6RArBK27nNT8Yy5xwOZj6dq63qKc9a0n4Zljv8LmuCR9KTCBibfwx/bGVpq ylOeGgZmCjCx3mH0icpkQUx6n7Eeq9V9s/utACUsiQcc30BedGOyve6X3BEF9PJYOF7J 2mUimFlU3tI8sKeKDqKOK7YoVgZSNSvwyUks683KhPNNMoSZqwycGJ4TEmdg3trxxNuo puo2DT+mbHtXL5mdKTeNunUgUW19i98v0XG0tR6Dw7Ejte1FiiTWIWFz1G1cWFE4E2+O uzBa10cTFG+7aEpaKWViCy/zCXtOBhKyXqmX8SYYi13chfMb2JruzauZ2gjJxi8a58mm uLXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=W7dWwUxUlimu0TIAMmn2GLJbuH1VGuNPXRNJig9fkcw=; b=UINi0NzKDFJcEOeN3pIKI1//ObAy/D1u4DsHTdWOxI0bli/Dm2yHgmd7o1Q20QZTwM F8eSTTxxpDB2GWw2o4kvaLGBz+aDUHZvQ+dmDXXRJNz1FybcLKPtskKgxLkm36LUWaQ4 sY2Epn+CcNo2dTq/ddPEiu4OeqyNX+l8caLrGXUdq9xi0bqk+qmZKnpMXIjx3lpv5hN0 PVqKyIeokI8LsC+ebN7RFH19+erYVY61zHk40vIldcSouJU+W3LHRAxjVzUaBYrYBs0F X75RiUE2cofLRcuVEAl6jnuGz4cnh5XiT5DDTm0fP2406wjvHjLM3pj37m9GBX9UT0TY aU5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PDCJN7Ak; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id e1-20020a170906648100b006e08aeba14esor5797290ejm.31.2022.05.22.06.38.16 for (Google Transport Security); Sun, 22 May 2022 06:38:16 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:9b96:b0:6f5:cdd:9bf2 with SMTP id dd22-20020a1709069b9600b006f50cdd9bf2mr16130334ejc.364.1653226696365; Sun, 22 May 2022 06:38:16 -0700 (PDT) Received: from panicking.amarulasolutions.com (host-80-21-24-253.business.telecomitalia.it. [80.21.24.253]) by smtp.gmail.com with ESMTPSA id md17-20020a170906ae9100b006feaf472637sm2696906ejb.53.2022.05.22.06.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 06:38:15 -0700 (PDT) From: Michael Trimarchi To: Tommaso Merciai Cc: linux-amarula@amarulasolutions.com, Alberto Bianchi Subject: [PATCH 2/3] net: phy: DP83822: enable rgmii/rmmi mode according to phy interface mode Date: Sun, 22 May 2022 15:38:12 +0200 Message-Id: <20220522133813.119729-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220522133813.119729-1-michael@amarulasolutions.com> References: <20220522133813.119729-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PDCJN7Ak; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , RMII/RGMII mode can be enable from dp83822 straps, and also writing bit 9 and bit 5 of register 0x17 - RMII and Status Register (RCSR). When phy_interface_is_rgmii rgmii mode must be enabled, same for contrary, this prevents malconfigurations of hw straps. If bit 9 is 0 the RMII/MII mode is determinated by bit 5. References: - https://www.ti.com/lit/gpn/dp83822i p66 Signed-off-by: Tommaso Merciai Co-developed-by: Michael Trimarchi Suggested-by: Alberto Bianchi Tested-by: Tommaso Merciai --- drivers/net/phy/dp83822.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index c344b8ffaf3c..89887a05f23d 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -94,7 +94,9 @@ #define DP83822_WOL_INDICATION_SEL BIT(8) #define DP83822_WOL_CLR_INDICATION BIT(11) -/* RSCR bits */ +/* RCSR bits */ +#define DP83822_RMII_MODE_EN BIT(5) +#define DP83822_RGMII_MODE_EN BIT(9) #define DP83822_RX_CLK_SHIFT BIT(12) #define DP83822_TX_CLK_SHIFT BIT(11) @@ -403,6 +405,17 @@ static int dp83822_config_init(struct phy_device *phydev) if (err) return err; } + + phy_set_bits_mmd(phydev, DP83822_DEVADDR, + MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); + } else { + value = DP83822_RGMII_MODE_EN; + + if (phydev->interface == PHY_INTERFACE_MODE_RMII) + value != DP83822_RMII_MODE_EN; + + phy_modify_mmd(phydev, DP83822_DEVADDR, MII_DP83822_RCSR, + DP83822_RGMII_MODE_EN | DP83822_RMII_MODE_EN, value); } if (dp83822->fx_enabled) { From patchwork Sun May 22 13:38:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1980 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 555983F05D for ; Sun, 22 May 2022 15:38:19 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id v1-20020a056402348100b0042b4442b954sf2622996edc.22 for ; Sun, 22 May 2022 06:38:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653226699; cv=pass; d=google.com; s=arc-20160816; b=ueFQR/9OcRcga9Y+PZrSKaew+8ilZsdkSpiWLZ2eNun+A0qmvcHNzozbYiJBvgygMG VrU/ll8Uw92t2Ahwq18dc8JEFoFWn7IYihGi2UDRoSrwMj+OgG8XdmcJFzYF9DC1+wJu IEYDgoy5gcjYPALsjGi7t4fOE9NYg2BTTuwfyPQV2Ozcpzynnb2c8r3yqoPWaDVcDZOK xchldTvsYrIGyV5LXf2wRRR0cdPwOOPiHx8rcAK7eql99C9wcGgH144Lge/WbcyEvca9 3EckJCSrCeqjOzy717WMIBLcvb83nYkMax5xcRw6I67+y/YWxYDL0q0Q/eEs2fKXLlFm +x3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hy0zCqDGoNPCR7akjiSI5c1LEY0KvhtZOaHBsauY0No=; b=a5vSheE0NtQob399EzWKqE5mAvpr6cY2V2jDERczIlI1DTXH2CVFhtM8/jhEW0rw07 Y7pfozM4lo88GambR7/12sx7iNIK/7rCpPjzt+bG33TQBKWrgS4sug4Pr+DT1sE316bw TZYwdv0rEcga32P8ezrBEJ4AjZJEaT+a0+mantH8pfJIjhyu9nFw4RRj/rIemYg1rntG w0T7TjWdMfCE97/92pGUySVwMtmjGNVEspbFzHDO2E+uIUqy4UFx4ObnKK/Lvg/4Qry4 0Kw7odBwknodUnbDogFP2X5gA7BdWgZoAxGt+HnhUTkYBO7OIznA0iH7rWocd5pA2PcG +NmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=qD+w4MC7; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=hy0zCqDGoNPCR7akjiSI5c1LEY0KvhtZOaHBsauY0No=; b=KB1xcclSrSEKLZw/yY4ZZoCN7sMxKk3/oX32V0RmrD3q+bO5nmdRj13a9C1Bek5S+5 nXKFHOJvzHe3FV9VkHMWldUQXnJcAC5k9RvYP+7WBFiDxyywM0jLRgBHauRTBaZS0QEP bLYC/ZAJZYlozUBMyfUFbF0f/ds+ED/c5DFxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=hy0zCqDGoNPCR7akjiSI5c1LEY0KvhtZOaHBsauY0No=; b=qMjeliJWssGHrhPGooTPhZTZZ+KUWjpvCxM+we5UlouX7iG/q/abUy3nqR6Bg6WviO QoszgAck4Wk+R+nQGSxsUYLdASArr/0+9DVABiMKdJ4GRvToBdzea5v5A7WUo78yrTor YOuxlY+yhiDh4VZjMK33XU3LE/FtPN/0Tdj2DNtjXjyJ25yEMDuHC+5eWscZADZCZuVA UXsPQXT32P+x+zerwzjurmO/sm9lb7bl5hiGvEX8VXdTgdKQWTacKvZv/fCy7Cvw0Gsu zwVIiZQkF7+v/4Zecv4S3f+Trpgpmm9jNC59YrIcEBZOCvBaaiMauIo8d9HhcpNznkUq GaQg== X-Gm-Message-State: AOAM531DdcHUYdiVtjObrAjgHksU9lBLL68zxbL/o+RYpm0Tk+1fW8dv VzzSK8SP1u5Wz3VDf7T8qsB7vgQ7 X-Google-Smtp-Source: ABdhPJyRYVUQ6xKnt4cTa66bVSqeM6FJcwbA1v8Iwn8jPWfWBZSrFWPlH/HXkpziVgRkakW9MMvTFA== X-Received: by 2002:a05:6402:274c:b0:42b:394e:c7b2 with SMTP id z12-20020a056402274c00b0042b394ec7b2mr8875792edd.338.1653226699257; Sun, 22 May 2022 06:38:19 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:70cf:b0:6fe:d027:3c1f with SMTP id g15-20020a17090670cf00b006fed0273c1fls440498ejk.2.gmail; Sun, 22 May 2022 06:38:18 -0700 (PDT) X-Received: by 2002:a17:906:e202:b0:6fe:478b:7c1 with SMTP id gf2-20020a170906e20200b006fe478b07c1mr15746627ejb.419.1653226697879; Sun, 22 May 2022 06:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653226697; cv=none; d=google.com; s=arc-20160816; b=KENi0lYQt03SExZPm1tbsMsRRYuuSzpjjHb6mcad1mwFPCkKldvVbFVBVr6JwPLXDH 8sktVHXGNMa+2AzMGenTpYGChTcabhTKdKLaqSw+anQUmYJYoBnaIDtOX1enDJr6CjoA 4//LbpyTIvmniHYdvlHofeWcbAc9hvlPaL0//zJYM9WeGc/YGsrW0BYfUXBqiTYhPvie Lidlu6e9q289aD/or2ZqT7HPyRwz20csfQ1p1aUMvr4lm66MpQJq9WUcRDBm04OCoi1s X6h6B9cwNsACXpeKj/S81t/OVbKDPwhJSZptHGcz2vQWjt9x6w51uuh3G9l3Nyy4uc/F hqcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=R3n9Nsmy/N48v4Cd5t4AJgEfSEvDIjuBATI3Pkj/ifM=; b=qdIymRCmZh8ErSG0OQoopGvWlRFvFOYDb/pbxKpyBgEYXhmTaGwMSVO6l5437gMjCU gs71wOkbK59DMF2FAtkzS91Hb9ZuSpzUZITC88TjfMD25KKZtwp+bQnT8EWskVJuBPjw zlVxD3WW6e9vkaLsoE+p6W+BKbPZt9BX0I82G8ETyRBpVSsGnbfVN4XYL3AZr2FRebfs UP4vBTXkpOO5FkJk/ORNym/uso8mkUwa1xGugPtUUlFpTSCGqDxwAGcR5CTZh2UY1asI SepR22UiMMk0uLNrYyxKakqxa4t2L/glc8XBnNJDLkYPub7uISzJaLqbVxazzuI7OHeM WcRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=qD+w4MC7; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id h41-20020a0564020ea900b0042aa06922f4sor6881504eda.32.2022.05.22.06.38.17 for (Google Transport Security); Sun, 22 May 2022 06:38:17 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:40ce:b0:42b:9d1:96e6 with SMTP id z14-20020a05640240ce00b0042b09d196e6mr16386132edb.262.1653226697560; Sun, 22 May 2022 06:38:17 -0700 (PDT) Received: from panicking.amarulasolutions.com (host-80-21-24-253.business.telecomitalia.it. [80.21.24.253]) by smtp.gmail.com with ESMTPSA id md17-20020a170906ae9100b006feaf472637sm2696906ejb.53.2022.05.22.06.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 06:38:16 -0700 (PDT) From: Michael Trimarchi To: Tommaso Merciai Cc: linux-amarula@amarulasolutions.com Subject: [PATCH 3/3] net: phy: DP83822: check for supported interface modes in config_init Date: Sun, 22 May 2022 15:38:13 +0200 Message-Id: <20220522133813.119729-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220522133813.119729-1-michael@amarulasolutions.com> References: <20220522133813.119729-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=qD+w4MC7; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Let config_init check for unsupported interface modes Signed-off-by: Michael Trimarchi --- drivers/net/phy/dp83822.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index 89887a05f23d..2741081d6988 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -387,6 +387,11 @@ static int dp83822_config_init(struct phy_device *phydev) int err = 0; int bmcr; + if (!phy_interface_is_rgmii(phydev) && + phy->interface != PHY_INTERFACE_MODE_RMII && + phy->interface != PHY_INTERFACE_MODE_MII) + return -ENODEV; + if (phy_interface_is_rgmii(phydev)) { trx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, true);