From patchwork Sun May 22 13:41:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1981 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 CEB683F05D for ; Sun, 22 May 2022 15:41:49 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id w5-20020a056402128500b0042aa2647eb6sf8942786edv.12 for ; Sun, 22 May 2022 06:41:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653226909; cv=pass; d=google.com; s=arc-20160816; b=rXgIn+/tW/lBLx6NneY4U2yjOK1758yesa8iUVcHfKUd303lok98ggoLUGP0OAyEn/ Y+izoVIcG+BtE3CNfIj4shmmWQLQ7oSukgOkoyDuOIfP7Op2ecD59dVhvS2kC63cVLEJ uk6KSA4buTn4Ubz9skfLzxzc5KD/NGEtmhV/gScPELUHG4MXtRCHaPXWMjr8UHG6HSFQ 3nN19QmWtsLdS5hnlPhm2qB/Mo2IkjIxVGd629K2CE9BkWws0paIQmt8JJ08T/eT+ATf v87CfiOx4pZvo7wFk381KSpYLSDCI7pmhLPuCzrrGmU2kXdgPfH83Q9Q8S+1BDmv51KC Isdw== 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=hpvX5i9e+YNBC/MH1+Iz349Yi7ArNcrMpr7TeGBX1Vry1JNIpB9mvBqXgA5vrSiLUj mi7syIqBQ/6UAWuEntnf3Eb3FC7ITbDbUjEkUjr83CPzYbEDEWMJdrtmBYjBSELwK0lM 2DDXdfY+H/T/4Yqb5e44Hr8voPGrVvWF6NKy6NpLe89kxEMPR0h3jlh2uAKRHolsrbjg hLtygw5JHjqdvlrPw15QZaMZSNnwdU/QX1XeFoC0tciaeb4GD/pgmHa63NyM6qUCNOrH J+ImYTbvBFVWsssfWbWAq6QP11WZLpWh+s6DPSMRlAnHHnqtNkrpeXCm4ZlVX/PGPldA /M7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GryjDlxH; 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=aifzHIcBzrr/OuutvGMCMlO9Jo0JwZROeRmYs2x+Azf2jScFlPl6piZiI151Ifw9DB JYkycnO9q4zBTG2MbrWEh0sbMHO4lBENEPkUeaTjYw5u/8YwTOSC6Ki3IOXjRbQXiThC nrZVKRU8luILVCKKOLHpiK800Ii2uo+on5vlI= 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=wPMRTwpJBFXBaBEGNdU5VNUBSY3qQZqtydShJ8bZsHvIzdOepLqJChEgcxsMtLhfLS mm5XkPphz9St/Pwg84ekMe/Z0ZX41VQ7yo43+8l8373WZ70acphM4BEvkzz1/CIwLcUQ qnKPo20YXmATWknHGmoYjnKem6v4T0dghdoy3fWtC6Lb0kBWyOl/IiqJ6lQvlAJuvMw5 qnT5FKAYwVMwY4jQvKVq5+TbM7owl5C5HdCsjN1iJcai0B5NWT7V2Z9oB8AW60xr6ZFb mvWEQ3z3ecnwjhdlKssT6/EmUHf0vVQRtrk6+Cs8RnJTYiWa5pwTF5ZP+lQWjBgQC4rH WUiw== X-Gm-Message-State: AOAM5323m9o1ao9ctT6z3pYNK4Biudyc1kBL3lzUv52X7sKWQsZn5DGl NNtLnwzeEb0yDX7WWMHOEyzWgX0k X-Google-Smtp-Source: ABdhPJxc4h4A0Jxbc2jmFIKX1sRCaYsbKNdykRkPxR1TsSRGzGij284fTi+yJ1AToUuV7JJxcVGQSg== X-Received: by 2002:aa7:c595:0:b0:42a:b571:2726 with SMTP id g21-20020aa7c595000000b0042ab5712726mr19981626edq.48.1653226909613; Sun, 22 May 2022 06:41:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:9910:b0:6fe:c0cb:366b with SMTP id zl16-20020a170906991000b006fec0cb366bls1058621ejb.11.gmail; Sun, 22 May 2022 06:41:48 -0700 (PDT) X-Received: by 2002:a17:907:7baa:b0:6fe:b3dc:2378 with SMTP id ne42-20020a1709077baa00b006feb3dc2378mr9025349ejc.266.1653226908179; Sun, 22 May 2022 06:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653226908; cv=none; d=google.com; s=arc-20160816; b=wle9rTSknqW1OJYEXfc9QV1PTFnFXyDf/0BoJgUtxhjOLqGNE7UKxwkic3HHQY0tZG bwRAU8kUj+CLEa24LabMROQxt3wqC/1OwWmDjKsRB1qhUPZ8+LmTiUtYwSDYXMX6xj90 vNmFQEp7OkMk2vYDAF0Js4lQMnTOFGhnDayrrTZDWeHXjegP9+dJzd/mqPpyAcikW56L kf+t/aUYabhxun6xTaJ8A6tOvjIith3Q5DoeHkD3AzII9ZSOOPu7OzRPPgO/NGYOPgAi A2rkmWVsqEG8JRXhOPMaZSmU62GgUliqyZYbNB7vCCr8dlirrErH2Om2OB4RD7kghS+T VzYw== 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=NM0PHebwwWxtNzCU+G+f3MrcygQdKbP7eQ9DtxiRUul+PM/N5RNtPjsFbyLTenWmza VHluoaLsNBOlqhpjawtCF/euRKlIDLzEkJfmNfcOnno3QVpwzwtrraf9UmnJw+1ib6sJ VmuNl6yLqe92ElavaUfopYiEZvjZm+Ddnp2Y9KdF9/wU2v3rxLDiasM+d+BN0H5drwKZ 29nPfaw68Hw5W2dagCdZT90G/uxb7OMkGFReY+J3MgVq7CJI4+TxLNn85IZFzVqqKhI9 eGmCKogNiAwYXWyOGOvpuZkAdGE/DzBxVMoMYOSejbsYKHYE7rUqPHfxh88LopqtBcVC M5/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GryjDlxH; 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 jv21-20020a170907769500b006febde6d776sor1156409ejc.30.2022.05.22.06.41.48 for (Google Transport Security); Sun, 22 May 2022 06:41:48 -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:c149:b0:6f9:2a43:ef37 with SMTP id dp9-20020a170906c14900b006f92a43ef37mr16008816ejc.17.1653226907887; Sun, 22 May 2022 06:41:47 -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 h22-20020aa7cdd6000000b0042abb914d6asm6772383edw.69.2022.05.22.06.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 06:41:47 -0700 (PDT) From: Michael Trimarchi To: Tommaso Merciai Cc: linux-amarula@amarulasolutions.com Subject: [PATCH V2 1/3] net: phy: DP83822: Clean up config_init code Date: Sun, 22 May 2022 15:41:44 +0200 Message-Id: <20220522134146.120312-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=GryjDlxH; 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:41:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1982 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B18513F05D for ; Sun, 22 May 2022 15:41:50 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id s9-20020aa7d789000000b0042ab9d77febsf8898068edq.16 for ; Sun, 22 May 2022 06:41:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653226910; cv=pass; d=google.com; s=arc-20160816; b=cPe12LpbRHgneOC1WBNailLz1qcnta14MP1zw/1Rbq5iEQF5NQ8J8Srya8lCMw6Dx9 +GEl+n45wFrpVAhQxOjIsCsVzVSszqJe4e0zsEXwNJe00y4AwgW50JW20MXKR6WYCTI/ v9Vyhg9sXEcasxOT4xf6RvNLYAcMLIWfTNEyib/5PDyOFak3a08Neyv3dfK1cysgH6T4 N6khv7A76U4LqIOqAwjsCMsKikAj9Wv3nCMCawlDn0cyEkWJQLVlSHgDfGuXXhrNG/uS 1wvlYQBmnpTJcEaNCEc05/rfF6XtZwBiNCwVnQ6VY3Ap49xxh2/XYbOSycCC9qULDMEn rlDQ== 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=ohLrwPmHO+/h/Uq8V4cDAN3JaCnzlRvPB7hGsnhfiCs=; b=DoimLFLxCl+j/8AJBOtaK1FGpg7Ci13wfDsj/DTDWJH2D+mLE7eMg5ONq7XN+nO1mN 6NmqIVB9qk9XsCzBxtDG9a+QGEaUtVb/QRci/pL9rJsVvS5xGa0NtTrM5oVPvk+Cm1MT gT8EmudsylYeDp89wpnCMBwnX/sEQuv+TdyaOJPQzplVrqDV8I8OGq8i5ClTMr7k/aou 5egwYAkGX20FK2Ilxnr9bOggVJbtRkJ9kQaob4bUPVnRSLhMQ2NKjfJ4mOPNEjlw2pIS 7NZ7L8T8aUYgbA6KAKBmsJpQGxtAYqm/x4S8bXwqoFDnVWj2DHcfQDxn+YFzuTjhD9B3 igbg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=X5k+KiG3; 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=ohLrwPmHO+/h/Uq8V4cDAN3JaCnzlRvPB7hGsnhfiCs=; b=j8BAQH/7rFJdSQE7xacj4xyXK5K2339t8YJHWlqAsBWquzwxT53MRJ4sO7Eyx5fFv6 EEuqny2stQ+4N6+6SRcZFZ4Y6QLAtvn6/SszPv15Sy0HaymRnW6nVaGYbP56D7RLOb6P 9cWKzVjp3hI9xLygUyi/IsGzCgPLgz4h8KgEo= 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=ohLrwPmHO+/h/Uq8V4cDAN3JaCnzlRvPB7hGsnhfiCs=; b=d8lKezbjMt0ZFwsqpmyPx83g3TrJwUnq479MJgUDaz0Vr3VOK7y7+6W7FS3r9TLDca i15Gb80qVC+5RBLsT/swGVQjeo7BStgJTQ4uSbQvSWwxunb/fX025PdPOtx+Mevv8DyA FMXX6Y94glBI+wZSN2aVl3pqESPudFK+ql91A6fdcNEMJWZLn8LVVP5UC2bLUifRY0/O w7288DVCIYTH8FxVL7ke4tuh2XnJ13uWUeMEblEXsgrM47McEXuVURahXJyAo5+B2QM8 P6Y8xo1JC2RhMOk0mR665f9snCUy1DHWwEeu3Z1i5JT8EseX3Rd0waUyZp0Kx1kbQ/cE EHcA== X-Gm-Message-State: AOAM533ACD5WuitVTIqamVu+jfIeGfvPTwN7hqnM7arxQRNT3OoPNqob J+wT3YAoMlVOVj/O+znVYqnOU0q7 X-Google-Smtp-Source: ABdhPJwWecfabdRKTyVvXkAkDCf1bDbpje54wvOyxKrWrquOrknv3HBR4A4i4VSjDZSkSa9GI2cGBA== X-Received: by 2002:aa7:d898:0:b0:42a:af71:dc24 with SMTP id u24-20020aa7d898000000b0042aaf71dc24mr19827345edq.162.1653226910556; Sun, 22 May 2022 06:41:50 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2741:b0:41f:7eee:e393 with SMTP id z1-20020a056402274100b0041f7eeee393ls870790edd.3.gmail; Sun, 22 May 2022 06:41:49 -0700 (PDT) X-Received: by 2002:a05:6402:42d4:b0:412:c26b:789 with SMTP id i20-20020a05640242d400b00412c26b0789mr19348641edc.232.1653226909338; Sun, 22 May 2022 06:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653226909; cv=none; d=google.com; s=arc-20160816; b=V6P7RGM0BcHY4AZZxEN5I+/fBBH4xh3cWh6HvxYnhpSdON+dPkbP3T65PdmIzQPREA Fsfelq/HyELfFhs48V4R8mN2ZWi84jfAgzfltRSxvB+I1YUx/R/6yDTVDE497/2VUitb tOUcJR79HMwD443PjAQCklxqO9x+dnb2r1cmhLgt4ELMvrgLVZDr1MwOLOrG39KR8C8S 3cmd3fQ4TfCksJl3j+U3dUOILjmpSTT4P5NJIlBAwnOtdQMGISVoP5V63TteuQWafLhR eBtSS3tmMqhAw+yK6LNYAuGhFIWwkwxChO5yA6WSexFqckwKBzvLDRtuyTuj0zmT5gUg Ohwg== 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=5NXbmyJMpYVQ+QWiWJG7pL4OHe0VXmf42B1KgTipLig=; b=bOfrXPZCFRZBuiN6+7W3IyqnV/uo/k5jM+Wn9yYZnoOoENkwbhrEkZnSBUPP9TEKcc BpiG/vhwjobg/mXL5dUzR48Wl0wbvJYIOCmj2WsVSgmrFLrbIolYqZW0wg+OgN7truc/ 92fQSAKJa8DqiTRTqm7SvDRG2Ik0NT5sKCctahaiDYfeG1CbHqMcihc5ddFC1q4pNTpy dCb578EWtxfkEDXcNzkxpAWTYQn1Qw1Xog+BcLyLqcquy3ALkWM2TrC9ADbIi8k6ClvO BYeN61hxqR1898p72aiviIegdJif0/jZG3lLTZ+/cTBOOEsh5KkPAjvXKjn1XKHOtwvL sCNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=X5k+KiG3; 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 p25-20020a17090664d900b006f44ffc4ba5sor5618404ejn.133.2022.05.22.06.41.49 for (Google Transport Security); Sun, 22 May 2022 06:41:49 -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:65c4:b0:6fe:8829:b8e4 with SMTP id z4-20020a17090665c400b006fe8829b8e4mr16189710ejn.291.1653226909041; Sun, 22 May 2022 06:41:49 -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 h22-20020aa7cdd6000000b0042abb914d6asm6772383edw.69.2022.05.22.06.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 06:41:48 -0700 (PDT) From: Michael Trimarchi To: Tommaso Merciai Cc: linux-amarula@amarulasolutions.com, Alberto Bianchi Subject: [PATCH V2 2/3] net: phy: DP83822: enable rgmii/rmmi mode according to phy interface mode Date: Sun, 22 May 2022 15:41:45 +0200 Message-Id: <20220522134146.120312-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220522134146.120312-1-michael@amarulasolutions.com> References: <20220522134146.120312-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=X5k+KiG3; 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index c344b8ffaf3c..0b35f6d1a08e 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,15 @@ 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 { + 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:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1983 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0DE2A3F05D for ; Sun, 22 May 2022 15:41:52 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id gh15-20020a170906e08f00b006fea2a22319sf2531494ejb.20 for ; Sun, 22 May 2022 06:41:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653226911; cv=pass; d=google.com; s=arc-20160816; b=w6lqFM2yYm+o4YdbNaY/O/899yv2+PLhgYdrr+5zCTANvRchNqYTvizm6DKt5laBgl jP0UlIsVrQH8ss7Y2aDdTFVhYb78ByQELNoYX7jI9NazR4uHPnbRUF/0JVpXYc4q7wbi 9YUyYHdY53vMho9DFGq1C8FMNsEVTO0nVINIqqVUa20sMQXL2V8h+mRbJusaVjgDkk3a gF8c0f9OES4CUObL5VoU825zPhGHVbasFtpURwYPiDx1X6gkDPONAYw/qVo0V2/eYjhu oj3T4C2mWtWTT5uOjOQ8IAe1Js1cso/b6CXR1axX5YHVGdV2T1p8VdZcSre222fNtDjZ Q5cQ== 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=eLwlmmADiyjXQavaxCgs9hHzrz6hzJFkRaGiqqpJxJ0=; b=0kmgm4kqLlKoqNZ9Mw305MHGzOtBVXdhnVeVEaJgi7+XQYr9whF3zBxu/Ivlg9+dqt mjMjWsHcNVKBuTPrWDC5rHn/4oXowlWKGrSfNn5HZHADz57/N4oVtVYU+YmXSGSz9rWL 6t4A9iSCNN6BsO5ZbPnuy4nLF1H4XmeJVBEQISpi4QwLsKtG2Qxqtx7e8azPjqq3ULtM wC9Ugkfv6Xzu3hIQrY7AuRWAv0nMgfhFPKt+CCG6biNexvvQNLnBWs3wfV3O2w6oRkXE 2ViO67N+cdZs3vTqXUf6K8YvnKKM5Cx9GthRGQHaiStpvbcuE5+6qjc9aIx+SUdz4ICl Vong== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="U/DCGPp0"; 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=eLwlmmADiyjXQavaxCgs9hHzrz6hzJFkRaGiqqpJxJ0=; b=kQmxg4IjrAEKCbRdmh0gSbql3wFBJq0kVgNjSIMCAsRQmyBCN0bYIp51DLIt0TaC/s ek17ZyY+8Mnve/u29vB4qN1z1ljQSR1KTIwNqnfFBCPuuZeEdO9sW3FpC6T7IvnlC6Qg kM2EGr4Pm8W4mCii1Y7/q6IB9x5wOCl1sPBC4= 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=eLwlmmADiyjXQavaxCgs9hHzrz6hzJFkRaGiqqpJxJ0=; b=VQ1LYILjLIsYildHJYlKovhR6v31JYB+z2NtZ2G0Ozg6tVUxqsoZo/o/wNq2j4OGTF tguHl4EX3d0NS+jawU9sbtLG6Y4I0PrrDicA+PUykS/mELSHz28cMkKq8sGEcEfrhnFl v3U26hwIhAm84XPHnTcTqIcsJFhVlbMMcm83sK7LKT1n03R9HuSF4nH2wX6KA00C2WWx 7/x8dI+gCFU0rcPRH2II2vJJ7vvR6aFSo5dDmdU0KoAPSnj4CclHeU4iO+sKsX8NeUGA ykPPrUmh5mn7O9UXUOreHwwiJxHrWLCpsTKrLJcj12y5WT4EmpIeB5L18Mo/nqjTXpu2 iQAg== X-Gm-Message-State: AOAM531z/etCNWKOFQ6ojt3UGKenBc5v46P3onvqSM2r5QlboJwbpWVV qIvtHAXN/B2V+QsL3EAojnN+FkxP X-Google-Smtp-Source: ABdhPJwO1FG6nVUEZ9rb0rUSMY0KZhc20+LXGF2HexH5y/gI5hC2JgrMdhzWX1xrqV8T6EzoP6dyUg== X-Received: by 2002:a17:907:3e92:b0:6f4:7ab4:20a5 with SMTP id hs18-20020a1709073e9200b006f47ab420a5mr16565110ejc.620.1653226911863; Sun, 22 May 2022 06:41:51 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5415:b0:42b:305b:5501 with SMTP id ev21-20020a056402541500b0042b305b5501ls871444edb.0.gmail; Sun, 22 May 2022 06:41:50 -0700 (PDT) X-Received: by 2002:aa7:df86:0:b0:42a:ba05:3ee7 with SMTP id b6-20020aa7df86000000b0042aba053ee7mr19521849edy.141.1653226910507; Sun, 22 May 2022 06:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653226910; cv=none; d=google.com; s=arc-20160816; b=Kbz4EoQWyEjlE+TmZo2nxPmgrxMUrbIYQu06vp7/J5FwniXeytNgvOVQ7r1clvBE5W Gk167wXiVxN6cWJch+05tSMf/mmMBhjaNuqq7ZRDCa1LAvqHu8eQr11xi9clYJPCe2gg M0BAJzLkSufN8jeikVdDwRyXm0IJiN901AWvPIWQ5l8PDKm5djbcB1OEZCxHXhYsaFRB fV5PjaTj6cWCWXa8rtNdMrouCUS+9V/sUQM5joYBWrsuOIjHL50Ll6obmoy3QmVO4r0O dbV2WgqJJDCLuf4wqFbHx2RKJbU0FnYqo/ZHKbPawuHff98fHth50jsWtaLZDe9qjP5k RYyg== 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=wwCzHLqAYP1e3pWxNFSfQy0wYVL2yigOJdfonllZrJs=; b=YDr22v+/nNqTGDVa9lRetsN4gcERjM5EAEZ+iQQb76D7w2VugaD6KNSdZRHeJlKOpi uCO6xHPUds01EHB/BFCwBd4Rj8WOu1hU6qy3iIBVqc/0V8GyOEd/g8VB1nZWrzk4jV0D 8ARx+kynbOOLnY0PypQ0xyJwuD6/onC7T3FR76yB1yMB3bNV63ofOaIAdwFUaRzhqntX 8HxwSUbqEwPberbuBFzT4bHpVXNZZnpaGk4vMjbzgw/f3FIZtkA+2YLTcTyCLY3oM2+S d1oI76MqEYIPmYzWfWXIaa5Mi8rm3Dkne+echTR/0iciTRJBJlca8DZ/LWZXCZBiwovZ uxKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="U/DCGPp0"; 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 j3-20020a170906534300b006fe88301d74sor5370649ejo.110.2022.05.22.06.41.50 for (Google Transport Security); Sun, 22 May 2022 06:41:50 -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:907:9615:b0:6f4:92ab:4fce with SMTP id gb21-20020a170907961500b006f492ab4fcemr16188565ejc.95.1653226910196; Sun, 22 May 2022 06:41:50 -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 h22-20020aa7cdd6000000b0042abb914d6asm6772383edw.69.2022.05.22.06.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 06:41:49 -0700 (PDT) From: Michael Trimarchi To: Tommaso Merciai Cc: linux-amarula@amarulasolutions.com Subject: [PATCH V2 3/3] net: phy: DP83822: check for supported interface modes in config_init Date: Sun, 22 May 2022 15:41:46 +0200 Message-Id: <20220522134146.120312-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220522134146.120312-1-michael@amarulasolutions.com> References: <20220522134146.120312-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="U/DCGPp0"; 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 0b35f6d1a08e..beb3203aaf9f 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);