Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp298058lqb; Tue, 16 Apr 2024 16:49:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFaXqlA8n3xxTmq9sKWPau9V3eTVYytBbZQ+5WuuJJ2s8BkLtjp7uL/RUwDGzkiSvZ5+xrUcGxvn8Sgo2NyEoKb7QlArKUN64asCRZdg== X-Google-Smtp-Source: AGHT+IG3whyRpuWiYKGzzLM8vvhRZhP0XvVOooqsx+j0kw6p4UFDuf3HxZ4HCJu0ZFyiFF9e0IAB X-Received: by 2002:a05:620a:819:b0:78e:d2a8:b4de with SMTP id s25-20020a05620a081900b0078ed2a8b4demr11818475qks.20.1713311343761; Tue, 16 Apr 2024 16:49:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713311343; cv=pass; d=google.com; s=arc-20160816; b=R3zPdbHCjn0fpQIXcauT1nCMeqaTcW7EHXvbVVLxec7Kroj9gvm0Fv7RCKbQ0EJQYX lObvtxsXLoaBW+bOjBFjYpCNJI2wz9UGeCWYjjKTKVHm6oBkSnwj6ms4PEN+zzO808hi QyaD10+hi2M4QTf3mcoP8i/NLoetqYOrUczAQ0MNUkEKGmc13nr4QZ+rKgRvgy48b7x3 5PRN5jQHigallwy6jZYbLq47YAJXDZPrIUK/0ex0oIBvvnJdv+qu4nDB2m5WYp7T7cFP kRDGEYlOLIJHSZfcJsWbRQg53wqgTD0RhbfujFNWBXgkgLWJag0QSzb3+ZdO0BbtcNKG T6Qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:autocrypt:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=bA4y7B4vtX3cVTLrK0KhmofaBtcISyRZFye2zuFzoqY=; fh=6Y+7lxHziwiYYCUYwzTW/gsFO+YxGfuYejAAGKY4wBc=; b=jtgo0JbOhzpm9buIHF9Fb5S7dKRch8UFyD4qEhFHbZ4n9/FNxUaSRF9BCM+zbuCJ8n Y371uNvpboxf5G9TQrxRqJpUhtNOeFiSLC02wYIrd0e8qwWV4WWfLMVthSw541xdNjTb 9EhY7fg+QdlctOdNruEFreR1pURw1ONnAlwgxhjaJTNgyjBrBBsaUie3WzU9+w16xpD/ KkaKtCptb2pMOBlCAJGGPYUhLYEe3YcX4+w6T/1CHzzs3UiLKzfuQ23zQk2Dns5o3TGC W6JTUoTRh0HvzoAieHtQf3pCfQVlEtYOkub/SfUN9XxzurL+V+pcPNeeHyxbmgUSYuDD WINA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=DQsj77kK; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-147762-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vv3-20020a05620a562300b0078edfefdcb9si7096338qkn.368.2024.04.16.16.49.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 16:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147762-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=DQsj77kK; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-147762-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id ED1A41C21A3F for ; Tue, 16 Apr 2024 23:49:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD02C13AA48; Tue, 16 Apr 2024 23:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="DQsj77kK" Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F3D53B2A6 for ; Tue, 16 Apr 2024 23:48:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713311329; cv=none; b=jYN11K94xwMWw69WmEL4ENZ9nUdOLDMUEW2I5e2HFFuj0pnzjjBSwpnnXlimv5ue6Dr8J+/WGykX/SBHnJdZTZRGy/bT+kpjhRl/IbfMUqylIuhGnjMpqh17I87ztCPkEsCgQyA8FgzQIH9/dgbhx99svD/vnz/cdMFS7wBz55E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713311329; c=relaxed/simple; bh=/t2jaeTR1HEWQM7TECKiGQbkyE6b/hoJwZnjLhBOLpw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gxDqfGPjVdqVomIWD08dP3N3TuRJxB7wefUilFO6nYx/aJul+My9/EjA8PF9khALkoSwxDVUk2ZzQJdcP0oUh2re2IT6gGGmbKzNSer+s5suDftX5lvQkxkvXpxFbOqcL42WDQKt9YLvkzEZXFam95aO+HYR5f1tO2ST4lswe8w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=DQsj77kK; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4347e55066cso19567441cf.2 for ; Tue, 16 Apr 2024 16:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1713311326; x=1713916126; darn=vger.kernel.org; h=in-reply-to:autocrypt:from:references:cc:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=bA4y7B4vtX3cVTLrK0KhmofaBtcISyRZFye2zuFzoqY=; b=DQsj77kKX0VQwDNqt3hOUvZerw2Ar4ck9x+VQbf2XluJNM/mIoKAoL4OTtfdLzolac Wq+DCQ9O+tvESgwm7bkOEEpgJh79otQCJYLAl+reKSfgYwqZItkEyQ6aTO44Umj7yZVH l4nczNU5usOBe548K/0vxMxlZu+Z5ZmpMhZCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713311326; x=1713916126; h=in-reply-to:autocrypt:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=bA4y7B4vtX3cVTLrK0KhmofaBtcISyRZFye2zuFzoqY=; b=C/7aIc16CtPZ6jTJec1oRoUT253fqM8tZ3Rp1mbNNbBCWhaIFxQVAI3VufmbCQzcbI 3OYgAcZxbi9nwI4K9NJu1P6lEQoROyJnliLdZwSl6jj2XhkWjkxIbfxwbRrSR4xKpPsS ZhCi8mWwjsNVhV18zOcUiJASNHrnza+aa+Z5vYK6zmpBlN41ly183jOZE9/yY9swa3Mj x8rzI1kQELjUbXuaFAZhOHCAPKd5kSiInczYQVVIpamUIBv0M9Qx5IMm2/nJYMgmCvUf EkaM2r1JMepFptTK1Z3WXOyYENrBdePjSNipLlt7XCeG65P9N52la4JOTiUGW+NFDdTr U+Tw== X-Forwarded-Encrypted: i=1; AJvYcCXT9LPmcTmKwr3djEIfzSawrnKTWSH4DVmpxvcWADkKo0YcdSZ2z9mntLd3dYwMfpN2ETqpNhN3Qmt1GCZGvusAAJ/doknrbaz2rjrB X-Gm-Message-State: AOJu0YxrkCBh+Eje/Fa/0+9kJcX/q/OoIiZiEPYQ7OCef+3svmTwmMwK Or2HidovyWWxZ70Q0cV5NwMq+CIlQJBC+Ddp8YFXftsh7JjttWlxGtuWnxP73g== X-Received: by 2002:ac8:5f46:0:b0:437:a1e:5eb0 with SMTP id y6-20020ac85f46000000b004370a1e5eb0mr7569754qta.14.1713311326372; Tue, 16 Apr 2024 16:48:46 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 17-20020a05620a04d100b0078d693c0b4bsm7885379qks.135.2024.04.16.16.48.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Apr 2024 16:48:44 -0700 (PDT) Message-ID: <96dc827a-9f4b-4b9a-8577-170cb335bebf@broadcom.com> Date: Tue, 16 Apr 2024 16:48:39 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: phy: bcm54811: add support for BroadR-Reach mode To: =?UTF-8?Q?Kamil_Hor=C3=A1k_-_2N?= , florian.fainelli@broadcom.com, bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch, hkallweit1@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240416123811.1880177-1-kamilh@axis.com> From: Florian Fainelli Autocrypt: addr=florian.fainelli@broadcom.com; keydata= xsBNBFPAG8ABCAC3EO02urEwipgbUNJ1r6oI2Vr/+uE389lSEShN2PmL3MVnzhViSAtrYxeT M0Txqn1tOWoIc4QUl6Ggqf5KP6FoRkCrgMMTnUAINsINYXK+3OLe7HjP10h2jDRX4Ajs4Ghs JrZOBru6rH0YrgAhr6O5gG7NE1jhly+EsOa2MpwOiXO4DE/YKZGuVe6Bh87WqmILs9KvnNrQ PcycQnYKTVpqE95d4M824M5cuRB6D1GrYovCsjA9uxo22kPdOoQRAu5gBBn3AdtALFyQj9DQ KQuc39/i/Kt6XLZ/RsBc6qLs+p+JnEuPJngTSfWvzGjpx0nkwCMi4yBb+xk7Hki4kEslABEB AAHNMEZsb3JpYW4gRmFpbmVsbGkgPGZsb3JpYW4uZmFpbmVsbGlAYnJvYWRjb20uY29tPsLB IQQQAQgAywUCZWl41AUJI+Jo+hcKAAG/SMv+fS3xUQWa0NryPuoRGjsA3SAUAAAAAAAWAAFr ZXktdXNhZ2UtbWFza0BwZ3AuY29tjDAUgAAAAAAgAAdwcmVmZXJyZWQtZW1haWwtZW5jb2Rp bmdAcGdwLmNvbXBncG1pbWUICwkIBwMCAQoFF4AAAAAZGGxkYXA6Ly9rZXlzLmJyb2FkY29t Lm5ldAUbAwAAAAMWAgEFHgEAAAAEFQgJChYhBNXZKpfnkVze1+R8aIExtcQpvGagAAoJEIEx tcQpvGagWPEH/2l0DNr9QkTwJUxOoP9wgHfmVhqc0ZlDsBFv91I3BbhGKI5UATbipKNqG13Z TsBrJHcrnCqnTRS+8n9/myOF0ng2A4YT0EJnayzHugXm+hrkO5O9UEPJ8a+0553VqyoFhHqA zjxj8fUu1px5cbb4R9G4UAySqyeLLeq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xQSvJYj0GWpadrDJUvUu3LEsunDCxdWrmbmwGRKqZraV2oG7YEddmDqOe0Xm/NxeSobc MIlnaE6V0U8f5zNHB7Y46yJjjYT/Ds1TJo3pvwevDWPvv6rdBeV07D9s43frUS6xYd1uFxHC 7dZYWJjZmyUf5evr1W1gCgwLXG0PEi9n3qmz1lelQ8lSocmvxBKtMbX/OKhAfuP/iIwnTsww 95A2SaPiQZA51NywV8OFgsN0ITl2PlZ4Tp9hHERDe6nQCsNI/Us= In-Reply-To: <20240416123811.1880177-1-kamilh@axis.com> Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000061a1b06163f6121" --000000000000061a1b06163f6121 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/16/24 05:38, Kamil Horák - 2N wrote: > Enable the BroadR-Reach link modes for BCM54811 PHY by Broadcom. > This allows for two-wire Ethernet at 10 or 100MBit using BroadR-Reach > mode and also for other BroadR-Reach modes using more than one pair. In terms of organization, it seems like you could do at least 3 patches: - one patch that adds the new BroadR-Reach link modes and ethtool plumbing - one patch that adds all of the register definitions to brcmphy.h which can be easily skipped - one patch that updates broadcom.c and bcm-phy-lib.[ch] to implement BroadR-Reach I am happy that you introduced an ethtool tunable, rather than key it off Device Tree or module parameter, so kudos for doing that! Need to wrap my head a bit as to what to do with the overlapping register mapping, and whether it would not be simpler to do some sort of register level remapping of values, rather than provide different callbacks for read_status, config_aneg, etc. > > Signed-off-by: Kamil Horák - 2N > --- > drivers/net/phy/broadcom.c | 432 ++++++++++++++++++++++++++++++++++- > drivers/net/phy/phy-core.c | 13 +- > include/linux/brcmphy.h | 91 +++++++- > include/uapi/linux/ethtool.h | 13 +- > net/ethtool/common.c | 31 +++ > net/ethtool/ioctl.c | 1 + > net/ipv4/tcp.c | 2 +- This file should really not be modified, you must have made this temporary change to build test your changes, but this is now fixed in net-next as of a few days ago. > 7 files changed, 567 insertions(+), 16 deletions(-) > > diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c > index 370e4ed45098..aeb49b566aca 100644 > --- a/drivers/net/phy/broadcom.c > +++ b/drivers/net/phy/broadcom.c > @@ -553,18 +553,46 @@ static int bcm54810_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, > return -EOPNOTSUPP; > } > > -static int bcm54811_config_init(struct phy_device *phydev) > +static int bcm54811_get_brrmode(struct phy_device *phydev, u8 *data) > { > - int err, reg; > + int reg; > > - /* Disable BroadR-Reach function. */ > reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL); > - reg &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN; > - err = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL, > - reg); > - if (err < 0) > + > + *data = (reg & BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN) ? > + ETHTOOL_PHY_BRR_MODE_ON : ETHTOOL_PHY_BRR_MODE_OFF; > + > + return 0; > +} > + > +static int bcm54811_set_brrmode(struct phy_device *phydev, u8 on) > +{ > + int reg; > + int err; > + > + reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL); > + > + if (on) > + reg |= BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN; > + else > + reg &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN; > + > + err = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL, reg); > + if (err) > return err; > > + /* Ensure LRE or IEEE register set is accessed according to the brr on/off, > + * thus set the override > + */ > + return bcm_phy_write_exp(phydev, BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL, > + BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_EN | > + on ? 0 : BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_OVERRIDE_VAL); > +} > + > +static int bcm54811_config_init(struct phy_device *phydev) > +{ > + int err, reg; > + > err = bcm54xx_config_init(phydev); > > /* Enable CLK125 MUX on LED4 if ref clock is enabled. */ > @@ -576,16 +604,151 @@ static int bcm54811_config_init(struct phy_device *phydev) > return err; > } > > - return err; > + /* Configure BroadR-Reach function. */ > + return bcm54811_set_brrmode(phydev, ETHTOOL_PHY_BRR_MODE_OFF); > +} > + > +static int bcm_setup_master_slave(struct phy_device *phydev) The namespace in this driver is such that we prefix with bcm54xx_ or bcm, this is generic so this could go to bcm-phy-lib.[ch] as a matter of fact. > +{ > + u16 ctl = 0; > + > + switch (phydev->master_slave_set) { > + case MASTER_SLAVE_CFG_MASTER_PREFERRED: > + case MASTER_SLAVE_CFG_MASTER_FORCE: > + ctl = LRECR_MASTER; > + break; > + case MASTER_SLAVE_CFG_SLAVE_PREFERRED: > + break; > + case MASTER_SLAVE_CFG_SLAVE_FORCE: > + break; > + case MASTER_SLAVE_CFG_UNKNOWN: > + case MASTER_SLAVE_CFG_UNSUPPORTED: > + return 0; > + default: > + phydev_warn(phydev, "Unsupported Master/Slave mode\n"); > + return -EOPNOTSUPP; > + } > + > + return phy_modify_changed(phydev, MII_BCM54XX_LRECR, LRECR_MASTER, ctl); > +} > + > +static int bcm_setup_forced(struct phy_device *phydev) > +{ > + u16 ctl = 0; > + > + phydev->pause = 0; > + phydev->asym_pause = 0; > + > + if (phydev->speed == SPEED_100) > + ctl |= LRECR_SPEED100; > + > + if (phydev->duplex != DUPLEX_FULL) > + return -EOPNOTSUPP; > + > + return phy_modify(phydev, MII_BCM54XX_LRECR, LRECR_SPEED100, ctl); > +} > + > +/** > + * bcm_linkmode_adv_to_mii_adv_t > + * @advertising: the linkmode advertisement settings > + * > + * A small helper function that translates linkmode advertisement > + * settings to phy autonegotiation advertisements for the > + * MII_BCM54XX_LREANAA register. > + */ > +static inline u32 bcm_linkmode_adv_to_mii_adv_t(unsigned long *advertising) > +{ > + u32 result = 0; > + > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1BR10_BIT, advertising)) > + result |= LREANAA_10_1PAIR; > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2BR10_BIT, advertising)) > + result |= LREANAA_10_2PAIR; > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1BR100_BIT, advertising)) > + result |= LREANAA_100_1PAIR; > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2BR100_BIT, advertising)) > + result |= LREANAA_100_2PAIR; > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_4BR100_BIT, advertising)) > + result |= LREANAA_100_4PAIR; > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising)) > + result |= LRELPA_PAUSE; > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising)) > + result |= LRELPA_PAUSE_ASYM; > + > + return result; > +} > + > +/** > + * bcm_config_advert - sanitize and advertise auto-negotiation parameters > + * @phydev: target phy_device struct > + * > + * Description: Writes MII_BCM54XX_LREANAA with the appropriate values, > + * after sanitizing the values to make sure we only advertise > + * what is supported. Returns < 0 on error, 0 if the PHY's advertisement > + * hasn't changed, and > 0 if it has changed. > + */ > +static int bcm_config_advert(struct phy_device *phydev) > +{ > + int err; > + u32 adv; > + > + /* Only allow advertising what this PHY supports */ > + linkmode_and(phydev->advertising, phydev->advertising, > + phydev->supported); > + > + adv = bcm_linkmode_adv_to_mii_adv_t(phydev->advertising); > + > + /* Setup BroadR-Reach mode advertisement */ > + err = phy_modify_changed(phydev, MII_BCM54XX_LREANAA, > + LRE_ADVERTISE_ALL | LREANAA_PAUSE | > + LREANAA_PAUSE_ASYM, adv); > + > + if (err < 0) > + return err; > + > + return err > 0 ? 1 : 0; > +} > + > +static int bcm_config_aneg(struct phy_device *phydev, bool changed) > +{ > + int err; > + > + if (genphy_config_eee_advert(phydev)) > + changed = true; > + > + err = bcm_setup_master_slave(phydev); > + if (err < 0) > + return err; > + else if (err) > + changed = true; > + > + if (phydev->autoneg != AUTONEG_ENABLE) > + return bcm_setup_forced(phydev); > + > + err = bcm_config_advert(phydev); > + if (err < 0) /* error */ > + return err; > + else if (err) > + changed = true; > + > + return genphy_check_and_restart_aneg(phydev, changed); > } > > static int bcm5481_config_aneg(struct phy_device *phydev) > { I would create a bcm54811_config_aneg() function here which checks for the BRR mode. > struct device_node *np = phydev->mdio.dev.of_node; > int ret; > + u8 brr_mode; > > /* Aneg firstly. */ > - ret = genphy_config_aneg(phydev); > + ret = bcm54811_get_brrmode(phydev, &brr_mode); > + if (ret) > + return ret; > + > + if (brr_mode == ETHTOOL_PHY_BRR_MODE_ON) > + ret = bcm_config_aneg(phydev, false); > + else > + ret = genphy_config_aneg(phydev); > > /* Then we can set up the delay. */ > bcm54xx_config_clock_delay(phydev); > @@ -1062,6 +1225,253 @@ static void bcm54xx_link_change_notify(struct phy_device *phydev) > bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, ret); > } > > +static int bcm54811_read_abilities(struct phy_device *phydev) > +{ > + int val, err; > + int i; > + static const int modes_array[] = {ETHTOOL_LINK_MODE_1BR100_BIT, > + ETHTOOL_LINK_MODE_4BR100_BIT, > + ETHTOOL_LINK_MODE_2BR100_BIT, > + ETHTOOL_LINK_MODE_2BR10_BIT, > + ETHTOOL_LINK_MODE_1BR10_BIT, > + ETHTOOL_LINK_MODE_1000baseT_Full_BIT, > + ETHTOOL_LINK_MODE_1000baseX_Full_BIT, > + ETHTOOL_LINK_MODE_1000baseT_Half_BIT, > + ETHTOOL_LINK_MODE_100baseT_Full_BIT, > + ETHTOOL_LINK_MODE_100baseT_Half_BIT, > + ETHTOOL_LINK_MODE_10baseT_Full_BIT, > + ETHTOOL_LINK_MODE_10baseT_Half_BIT}; > + > + u8 brr_mode; > + > + for (i = 0; i < ARRAY_SIZE(modes_array); i++) > + linkmode_clear_bit(modes_array[i], phydev->supported); > + > + err = bcm54811_get_brrmode(phydev, &brr_mode); > + > + if (!err) { Please do an early return so you can reduce the indentation here, and elsewhere, too. -- Florian --000000000000061a1b06163f6121 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQeQYJKoZIhvcNAQcCoIIQajCCEGYCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3QMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a1e/czkALg3sgTcOOcFZTXk38e aqsXsipoX1vsNurqPtnC27TWsA7pk4uKXscFjkeUE8JZu9BDKaswZygxBOPBQBwrA5+20Wxlk6k1 e6EKaaNaNZUy30q3ArEf30ZDpXyfCtiXnupjSK8WU2cK4qsEtj09JS4+mhi0CTCrCnXAzum3tgcH cHRg0prcSzzEUDQWoFxyuqwiwhHu3sPQNmFOMwIDAQABo4IB2jCCAdYwDgYDVR0PAQH/BAQDAgGG MGAGA1UdJQRZMFcGCCsGAQUFBwMCBggrBgEFBQcDBAYKKwYBBAGCNxQCAgYKKwYBBAGCNwoDBAYJ KwYBBAGCNxUGBgorBgEEAYI3CgMMBggrBgEFBQcDBwYIKwYBBQUHAxEwEgYDVR0TAQH/BAgwBgEB /wIBADAdBgNVHQ4EFgQUljPR5lgXWzR1ioFWZNW+S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