From: Alexandru Tachici <redacted>
The ADIN1100 is a low power single port 10BASE-T1L transceiver designed for
industrial Ethernet applications and is compliant with the IEEE 802.3cg
Ethernet standard for long reach 10 Mb/s Single Pair Ethernet.
The ADIN1100 uses Auto-Negotiation capability in accordance
with IEEE 802.3 Clause 98, providing a mechanism for
exchanging information between PHYs to allow link partners to
agree to a common mode of operation.
The concluded operating mode is the transmit amplitude mode and
master/slave preference common across the two devices.
Both device and LP advertise their ability and request for
increased transmit at:
- BASE-T1 autonegotiation advertisement register [47:32]\
Clause 45.2.7.21 of Standard 802.3
- BIT(13) - 10BASE-T1L High Level Transmit Operating Mode Ability
- BIT(12) - 10BASE-T1L High Level Transmit Operating Mode Request
For 2.4 Vpp (high level transmit) operation, both devices need
to have the High Level Transmit Operating Mode Ability bit set,
and only one of them needs to have the High Level Transmit
Operating Mode Request bit set. Otherwise 1.0 Vpp transmit level
will be used.
Ethtool output:
Settings for eth1:
Supported ports: [ TP MII ]
Supported link modes: 10baseT1L/Full
Supported pause frame use: Transmit-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT1L/Full
Advertised pause frame use: Transmit-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT1L/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 10Mb/s
Duplex: Full
Auto-negotiation: on
master-slave cfg: preferred master
master-slave status: master
Port: MII
PHYAD: 0
Transceiver: external
Link detected: yes
SQI: 7/7
1. Add basic support for ADIN1100.
Alexandru Ardelean (1):
net: phy: adin1100: Add initial support for ADIN1100 industrial PHY
1. Added 10baset-T1L link modes.
2. Added 10-BasetT1L registers that are used in ADIN1100 driver.
3. Added BaseT1 auto-negotiation registers. For ADIN1100 these
registers decide master/slave status and TX voltage of the
device and link partner.
4. Allow user to set the master-slave configuration of ADIN1100.
5. Convert MSE to SQI using a predefined table and allow user access
through ethtool.
6. DT bindings for the 2.4 Vpp transmit mode.
7. DT bindings for ADIN1100.
Alexandru Tachici (7):
ethtool: Add 10base-T1L link mode entry
net: phy: Add 10-BaseT1L registers
net: phy: Add BaseT1 auto-negotiation registers
net: phy: adin1100: Add ethtool master-slave support
net: phy: adin1100: Add SQI support
dt-bindings: net: phy: Add 10-baseT1L 2.4 Vpp
dt-bindings: adin1100: Add binding for ADIN1100 Ethernet PHY
Changelog V2 -> V3:
- removed unused defines
- dropped 1 V 2.4 V voltage link entries (will add these features in a separate patch)
- dropped extra PHY stats, will add them in a separate patch
(adin1200/1300 will need rework too as it implements same stats)
- added PMA status register and PCS control register in mdio.h (registers specified in 802.3gc)
- added auto-negotiation advertisement and link partner registers in mdio.h
(Registers specified in 802.3 2018)
- added 10base-t1l-2.4vpp tristate property to ethernet-phy yaml
- replaced standard registers defines in adin1100.c with the ones added to mdio.h
.../devicetree/bindings/net/adi,adin1100.yaml | 30 ++
.../devicetree/bindings/net/ethernet-phy.yaml | 9 +
drivers/net/phy/Kconfig | 7 +
drivers/net/phy/Makefile | 1 +
drivers/net/phy/adin1100.c | 403 ++++++++++++++++++
drivers/net/phy/phy-core.c | 3 +-
include/uapi/linux/ethtool.h | 1 +
include/uapi/linux/mdio.h | 56 +++
net/ethtool/common.c | 3 +
9 files changed, 512 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/adi,adin1100.yaml
create mode 100644 drivers/net/phy/adin1100.c
--
2.25.1
From: Alexandru Tachici <redacted>
The 802.3gc specification defines the 10-BaseT1L link
mode for ethernet trafic on twisted wire pair.
PMA status register can be used to detect if the phy supports
2.4 V TX level and PCS control register can be used to
enable/disable PCS level loopback.
Signed-off-by: Alexandru Tachici <redacted>
---
include/uapi/linux/mdio.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
From: Alexandru Tachici <redacted>
Add a tristate property to advertise desired transmit level.
If the device supports the 2.4 Vpp operating mode for 10BASE-T1L,
as defined in 802.3gc, and the 2.4 Vpp transmit voltage operation
is desired, property should be set to 1. This property is used
to select whether Auto-Negotiation advertises a request to
operate the 10BASE-T1L PHY in increased transmit level mode.
If property is set to 1, the PHY shall advertise a request
to operate the 10BASE-T1L PHY in increased transmit level mode.
If property is set to zero, the PHY shall not advertise
a request to operate the 10BASE-T1L PHY in increased transmit level mode.
Signed-off-by: Alexandru Tachici <redacted>
---
Documentation/devicetree/bindings/net/ethernet-phy.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -77,6 +77,15 @@ properties:description:Maximum PHY supported speed in Mbits / seconds.+an-10base-t1l-2.4vpp:+description:|+tristate, request/disable 2.4 Vpp operating mode. The values are:+0:Disable 2.4 Vpp operating mode.+1:Request 2.4 Vpp operating mode from link partner.+Absence of this property will leave configuration to default values.+$ref:"/schemas/types.yaml#/definitions/uint32"+enum:[0,1]+broken-turn-around:$ref:/schemas/types.yaml#/definitions/flagdescription:
From: Alexandru Tachici <redacted>
Determine the SQI from MSE using a predefined table
for the 10BASE-T1L.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Alexandru Tachici <redacted>
---
drivers/net/phy/adin1100.c | 52 ++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
From: Alexandru Tachici <redacted>
Allow user to select the advertised master-slave
configuration through ethtool.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Alexandru Tachici <redacted>
---
drivers/net/phy/adin1100.c | 74 +++++++++++++++++++++++++++++++++++++-
1 file changed, 73 insertions(+), 1 deletion(-)
From: Alexandru Ardelean <redacted>
The ADIN1100 is a low power single port 10BASE-T1L transceiver designed for
industrial Ethernet applications and is compliant with the IEEE 802.3cg
Ethernet standard for long reach 10 Mb/s Single Pair Ethernet.
Signed-off-by: Alexandru Ardelean <redacted>
Signed-off-by: Alexandru Tachici <redacted>
---
drivers/net/phy/Kconfig | 7 +
drivers/net/phy/Makefile | 1 +
drivers/net/phy/adin1100.c | 279 +++++++++++++++++++++++++++++++++++++
3 files changed, 287 insertions(+)
create mode 100644 drivers/net/phy/adin1100.c
@@ -0,0 +1,279 @@+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)+/*+*DriverforAnalogDevicesIndustrialEthernetT1LPHYs+*+*Copyright2020AnalogDevicesInc.+*/+#include<linux/kernel.h>+#include<linux/bitfield.h>+#include<linux/delay.h>+#include<linux/errno.h>+#include<linux/init.h>+#include<linux/module.h>+#include<linux/mii.h>+#include<linux/phy.h>+#include<linux/property.h>++#define PHY_ID_ADIN1100 0x0283bc81++staticconstintphy_10_features_array[]={+ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,+};++#define ADIN_CRSM_SFT_RST 0x8810+#define ADIN_CRSM_SFT_RST_EN BIT(0)++#define ADIN_CRSM_SFT_PD_CNTRL 0x8812+#define ADIN_CRSM_SFT_PD_CNTRL_EN BIT(0)++#define ADIN_CRSM_STAT 0x8818+#define ADIN_CRSM_SFT_PD_RDY BIT(1)+#define ADIN_CRSM_SYS_RDY BIT(0)++/**+*structadin_priv-ADINPHYdriverprivatedata+*tx_level_2v4_ablesetifthePHYsupports2.4VTXlevels(10BASE-T1L)+*tx_level_2v4setifthePHYrequests2.4VTXlevels(10BASE-T1L)+*tx_level_prop_presentsetiftheTXlevelisspecifiedinDT+*/+structadin_priv{+unsignedinttx_level_2v4_able:1;+unsignedinttx_level_2v4:1;+unsignedinttx_level_prop_present:1;+};++staticvoidadin_mii_adv_m_to_ethtool_adv_t(unsignedlong*advertising,u32adv)+{+if(adv&MDIO_AN_T1_ADV_M_B10L)+linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,advertising);+}++staticintadin_read_lpa(structphy_device*phydev)+{+intval;++linkmode_zero(phydev->lp_advertising);++val=phy_read_mmd(phydev,MDIO_MMD_AN,MDIO_AN_T1_STAT);+if(val<0)+returnval;++if(!(val&MDIO_AN_STAT1_COMPLETE)){+phydev->pause=0;+phydev->asym_pause=0;++return0;+}++linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,+phydev->lp_advertising);++/* Read the link partner's base page advertisement */+val=phy_read_mmd(phydev,MDIO_MMD_AN,MDIO_AN_T1_LP_L);+if(val<0)+returnval;++phydev->pause=val&MDIO_AN_T1_LP_L_PAUSE_CAP?1:0;+phydev->asym_pause=val&MDIO_AN_T1_LP_L_PAUSE_ASYM?1:0;++val=phy_read_mmd(phydev,MDIO_MMD_AN,MDIO_AN_T1_LP_M);+if(val<0)+returnval;++adin_mii_adv_m_to_ethtool_adv_t(phydev->lp_advertising,val);++return0;+}++staticintadin_read_status(structphy_device*phydev)+{+intret;++ret=genphy_c45_read_link(phydev);+if(ret)+returnret;++phydev->speed=SPEED_UNKNOWN;+phydev->duplex=DUPLEX_UNKNOWN;+phydev->pause=0;+phydev->asym_pause=0;++if(phydev->autoneg==AUTONEG_ENABLE){+ret=adin_read_lpa(phydev);+if(ret)+returnret;++phy_resolve_aneg_linkmode(phydev);+}else{+/* Only one mode & duplex supported */+linkmode_zero(phydev->lp_advertising);+phydev->speed=SPEED_10;+phydev->duplex=DUPLEX_FULL;+}++returnret;+}++staticintadin_config_aneg(structphy_device*phydev)+{+structadin_priv*priv=phydev->priv;+intret;++/* No sense to continue if auto-neg is disabled,+*onlyonelink-modesupported.+*/+if(phydev->autoneg==AUTONEG_DISABLE)+return0;++/* Request increased transmit level from LP. */+if(priv->tx_level_prop_present&&priv->tx_level_2v4){+ret=phy_set_bits_mmd(phydev,MDIO_MMD_AN,MDIO_AN_T1_ADV_H,+MDIO_AN_T1_ADV_H_10L_TX_HI|+MDIO_AN_T1_ADV_H_10L_TX_HI_REQ);+if(ret<0)+returnret;+}++/* Disable 2.4 Vpp transmit level. */+if((priv->tx_level_prop_present&&!priv->tx_level_2v4)||!priv->tx_level_2v4_able){+ret=phy_clear_bits_mmd(phydev,MDIO_MMD_AN,MDIO_AN_T1_ADV_H,+MDIO_AN_T1_ADV_H_10L_TX_HI|+MDIO_AN_T1_ADV_H_10L_TX_HI_REQ);+if(ret<0)+returnret;+}++returnphy_set_bits_mmd(phydev,MDIO_MMD_AN,MDIO_AN_T1_CTRL,BMCR_ANRESTART);+}++staticintadin_set_powerdown_mode(structphy_device*phydev,boolen)+{+intret;+intval;++if(en)+val=ADIN_CRSM_SFT_PD_CNTRL_EN;+else+val=0;++ret=phy_write_mmd(phydev,MDIO_MMD_VEND1,+ADIN_CRSM_SFT_PD_CNTRL,val);+if(ret<0)+returnret;++returnphy_read_mmd_poll_timeout(phydev,MDIO_MMD_VEND1,ADIN_CRSM_STAT,ret,+(ret&ADIN_CRSM_SFT_PD_RDY)==val,+1000,30000,true);+}++staticintadin_suspend(structphy_device*phydev)+{+returnadin_set_powerdown_mode(phydev,true);+}++staticintadin_resume(structphy_device*phydev)+{+returnadin_set_powerdown_mode(phydev,false);+}++staticintadin_set_loopback(structphy_device*phydev,boolenable)+{+if(enable)+returnphy_set_bits_mmd(phydev,MDIO_MMD_PCS,MDIO_PCS_10T1L_CTRL,+BMCR_LOOPBACK);++/* PCS loopback (according to 10BASE-T1L spec) */+returnphy_clear_bits_mmd(phydev,MDIO_MMD_PCS,MDIO_PCS_10T1L_CTRL,+BMCR_LOOPBACK);+}++staticintadin_soft_reset(structphy_device*phydev)+{+intret;++ret=phy_set_bits_mmd(phydev,MDIO_MMD_VEND1,ADIN_CRSM_SFT_RST,ADIN_CRSM_SFT_RST_EN);+if(ret<0)+returnret;++returnphy_read_mmd_poll_timeout(phydev,MDIO_MMD_VEND1,ADIN_CRSM_STAT,ret,+(ret&ADIN_CRSM_SYS_RDY),+10000,30000,true);+}++staticintadin_get_features(structphy_device*phydev)+{+structadin_priv*priv=phydev->priv;+structdevice*dev=&phydev->mdio.dev;+intret;+u8val;++ret=phy_read_mmd(phydev,MDIO_MMD_PMAPMD,MDIO_PMA_10T1L_STAT);+if(ret<0)+returnret;++/* This depends on the voltage level from the power source */+priv->tx_level_2v4_able=!!(ret&MDIO_PMA_10T1L_STAT_2V4_ABLE);++phydev_dbg(phydev,"PHY supports 2.4V TX level: %s\n",+priv->tx_level_2v4_able?"yes":"no");++priv->tx_level_prop_present=device_property_present(dev,"10base-t1l-2.4vpp");+if(priv->tx_level_prop_present){+ret=device_property_read_u8(dev,"10base-t1l-2.4vpp",&val);+if(ret<0)+returnret;++priv->tx_level_2v4=val;+if(!priv->tx_level_2v4&&priv->tx_level_2v4_able)+phydev_info(phydev,+"PHY supports 2.4V TX level, but disabled via config\n");+}++linkmode_set_bit_array(phy_basic_ports_array,ARRAY_SIZE(phy_basic_ports_array),+phydev->supported);++linkmode_set_bit_array(phy_10_features_array,ARRAY_SIZE(phy_10_features_array),+phydev->supported);++return0;+}++staticintadin_probe(structphy_device*phydev)+{+structdevice*dev=&phydev->mdio.dev;+structadin_priv*priv;++priv=devm_kzalloc(dev,sizeof(*priv),GFP_KERNEL);+if(!priv)+return-ENOMEM;++phydev->priv=priv;++return0;+}++staticstructphy_driveradin_driver[]={+{+PHY_ID_MATCH_MODEL(PHY_ID_ADIN1100),+.name="ADIN1100",+.get_features=adin_get_features,+.soft_reset=adin_soft_reset,+.probe=adin_probe,+.config_aneg=adin_config_aneg,+.read_status=adin_read_status,+.set_loopback=adin_set_loopback,+.suspend=adin_suspend,+.resume=adin_resume,+},+};++module_phy_driver(adin_driver);++staticstructmdio_device_id__maybe_unusedadin_tbl[]={+{PHY_ID_MATCH_MODEL(PHY_ID_ADIN1100)},+{}+};++MODULE_DEVICE_TABLE(mdio,adin_tbl);+MODULE_DESCRIPTION("Analog Devices Industrial Ethernet T1L PHY driver");+MODULE_LICENSE("Dual BSD/GPL");
@@ -13,7 +13,7 @@*/constchar*phy_speed_to_str(intspeed){-BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS!=92,+BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS!=93,"Enum ethtool_link_mode_bit_indices and phylib are out of sync. ""If a speed or mode has been added please update phy_speed_to_str ""and the PHY settings array.\n");
@@ -1661,6 +1661,7 @@ enum ethtool_link_mode_bit_indices {ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT=89,ETHTOOL_LINK_MODE_100baseFX_Half_BIT=90,ETHTOOL_LINK_MODE_100baseFX_Full_BIT=91,+ETHTOOL_LINK_MODE_10baseT1L_Full_BIT=92,/* must be last entry */__ETHTOOL_LINK_MODE_MASK_NBITS};
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-11 15:25:03
On Mon, 11 Oct 2021 17:22:11 +0300 alexandru.tachici@analog.com wrote:
+/**
+ * struct adin_priv - ADIN PHY driver private data
+ * tx_level_2v4_able set if the PHY supports 2.4V TX levels (10BASE-T1L)
+ * tx_level_2v4 set if the PHY requests 2.4V TX levels (10BASE-T1L)
+ * tx_level_prop_present set if the TX level is specified in DT
+ */
This is not correct kdoc format. Should be
* @member: description
scripts/kernel-doc -none is your friend:
drivers/net/phy/adin1100.c:44: warning: Function parameter or member 'tx_level_2v4_able' not described in 'adin_priv'
drivers/net/phy/adin1100.c:44: warning: Function parameter or member 'tx_level_2v4' not described in 'adin_priv'
drivers/net/phy/adin1100.c:44: warning: Function parameter or member 'tx_level_prop_present' not described in 'adin_priv'
From: Rob Herring <robh@kernel.org> Date: 2021-10-11 23:13:48
On Mon, 11 Oct 2021 17:22:15 +0300, alexandru.tachici@analog.com wrote:
From: Alexandru Tachici <redacted>
DT bindings for the ADIN1100 10BASE-T1L Ethernet PHY.
Signed-off-by: Alexandru Tachici <redacted>
---
.../devicetree/bindings/net/adi,adin1100.yaml | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/adi,adin1100.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/adi,adin1100.yaml: 'oneOf' conditional failed, one must be fixed:
'unevaluatedProperties' is a required property
'additionalProperties' is a required property
hint: A schema with a "$ref" to another schema either can define all properties used and use "additionalProperties" or can use "unevaluatedProperties"
from schema $id: http://devicetree.org/meta-schemas/base.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/adi,adin1100.yaml: 'anyOf' conditional failed, one must be fixed:
'properties' is a required property
'patternProperties' is a required property
hint: Metaschema for devicetree binding documentation
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/adi,adin1100.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/net/adi,adin1100.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/adi,adin1100.example.dt.yaml: ethernet: '10base-t1l-2.4vpp' does not match any of the regexes: '.*-names$', '.*-supply$', '^#.*-cells$', '^#[a-zA-Z0-9,+\\-._]{0,63}$', '^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}$', '^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}@[0-9a-fA-F]+(,[0-9a-fA-F]+)*$', '^__.*__$', 'pinctrl-[0-9]+'
From schema: /usr/local/lib/python3.8/dist-packages/dtschema/schemas/dt-core.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1539350
This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit.
On Mon, Oct 11, 2021 at 05:22:09PM +0300, alexandru.tachici@analog.com wrote:
From: Alexandru Tachici <redacted>
The 802.3gc specification defines the 10-BaseT1L link
mode for ethernet trafic on twisted wire pair.
PMA status register can be used to detect if the phy supports
2.4 V TX level and PCS control register can be used to
enable/disable PCS level loopback.
Signed-off-by: Alexandru Tachici <redacted>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Thank you!
Question on maintainers: IEEE 802.3 spec, documents register bits in the
little-endian order. In the mdio.h we use big-endian, it makes
comparison with the spec a bit more challenging. May be we should fix
it?
Regards,
Oleksij
Hm.. MDIO_AN_T1_ADV_M_MST is T4 of Link codeword Base Page. The spec says:
"Transmitted Nonce Field (T[4:0]) is a 5-bit wide field whose lower 4
bits contains a random or pseudorandom number. A new value shall be
generated for each entry to the Ability Detect state"
Should we actually do it?
@@ -13,7 +13,7 @@*/constchar*phy_speed_to_str(intspeed){-BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS!=92,+BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS!=93,"Enum ethtool_link_mode_bit_indices and phylib are out of sync. ""If a speed or mode has been added please update phy_speed_to_str ""and the PHY settings array.\n");
@@ -1661,6 +1661,7 @@ enum ethtool_link_mode_bit_indices {ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT=89,ETHTOOL_LINK_MODE_100baseFX_Half_BIT=90,ETHTOOL_LINK_MODE_100baseFX_Full_BIT=91,+ETHTOOL_LINK_MODE_10baseT1L_Full_BIT=92,/* must be last entry */__ETHTOOL_LINK_MODE_MASK_NBITS};
On Mon, Oct 11, 2021 at 05:22:11PM +0300, alexandru.tachici@analog.com wrote:
quoted hunk
From: Alexandru Ardelean <redacted>
The ADIN1100 is a low power single port 10BASE-T1L transceiver designed for
industrial Ethernet applications and is compliant with the IEEE 802.3cg
Ethernet standard for long reach 10 Mb/s Single Pair Ethernet.
Signed-off-by: Alexandru Ardelean <redacted>
Signed-off-by: Alexandru Tachici <redacted>
---
drivers/net/phy/Kconfig | 7 +
drivers/net/phy/Makefile | 1 +
drivers/net/phy/adin1100.c | 279 +++++++++++++++++++++++++++++++++++++
3 files changed, 287 insertions(+)
create mode 100644 drivers/net/phy/adin1100.c
Please extend genphy_c45_pma_read_abilities() to set 10baseT1L_Full_BIT.
It is already doing most of needed work:
..
if (val & MDIO_PMA_STAT2_EXTABLE) {
val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
// This is 45.2.1.10 PMA/PMD extended ability register (Register 1.11)
// You should test for bit 1.11.11 and read register register 1.18
// to set missing abilities.
+static int adin_read_lpa(struct phy_device *phydev)
+{
+ int val;
+
+ linkmode_zero(phydev->lp_advertising);
+
+ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT);
+ if (val < 0)
+ return val;
+
+ if (!(val & MDIO_AN_STAT1_COMPLETE)) {
+ phydev->pause = 0;
+ phydev->asym_pause = 0;
+
+ return 0;
+ }
+
+ linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+ phydev->lp_advertising);
+
+ /* Read the link partner's base page advertisement */
+ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_LP_L);
+ if (val < 0)
+ return val;
+
+ phydev->pause = val & MDIO_AN_T1_LP_L_PAUSE_CAP ? 1 : 0;
+ phydev->asym_pause = val & MDIO_AN_T1_LP_L_PAUSE_ASYM ? 1 : 0;
+
+ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_LP_M);
+ if (val < 0)
+ return val;
+
+ adin_mii_adv_m_to_ethtool_adv_t(phydev->lp_advertising, val);
+
+ return 0;
+}
+
+static int adin_read_status(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = genphy_c45_read_link(phydev);
+ if (ret)
+ return ret;
+
+ phydev->speed = SPEED_UNKNOWN;
+ phydev->duplex = DUPLEX_UNKNOWN;
+ phydev->pause = 0;
+ phydev->asym_pause = 0;
+
+ if (phydev->autoneg == AUTONEG_ENABLE) {
+ ret = adin_read_lpa(phydev);
+ if (ret)
+ return ret;
+
+ phy_resolve_aneg_linkmode(phydev);
+ } else {
+ /* Only one mode & duplex supported */
+ linkmode_zero(phydev->lp_advertising);
+ phydev->speed = SPEED_10;
+ phydev->duplex = DUPLEX_FULL;
+ }
+
+ return ret;
+}
+
+static int adin_config_aneg(struct phy_device *phydev)
+{
+ struct adin_priv *priv = phydev->priv;
+ int ret;
+
+ /* No sense to continue if auto-neg is disabled,
+ * only one link-mode supported.
+ */
+ if (phydev->autoneg == AUTONEG_DISABLE)
+ return 0;
+
+ /* Request increased transmit level from LP. */
+ if (priv->tx_level_prop_present && priv->tx_level_2v4) {
+ ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_ADV_H,
+ MDIO_AN_T1_ADV_H_10L_TX_HI |
+ MDIO_AN_T1_ADV_H_10L_TX_HI_REQ);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Disable 2.4 Vpp transmit level. */
+ if ((priv->tx_level_prop_present && !priv->tx_level_2v4) || !priv->tx_level_2v4_able) {
+ ret = phy_clear_bits_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_ADV_H,
+ MDIO_AN_T1_ADV_H_10L_TX_HI |
+ MDIO_AN_T1_ADV_H_10L_TX_HI_REQ);
+ if (ret < 0)
+ return ret;
+ }
+
+ return phy_set_bits_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_CTRL, BMCR_ANRESTART);
+}
+static int adin_set_powerdown_mode(struct phy_device *phydev, bool en)
+{
+ int ret;
+ int val;
+
+ if (en)
+ val = ADIN_CRSM_SFT_PD_CNTRL_EN;
+ else
+ val = 0;
+
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1,
+ ADIN_CRSM_SFT_PD_CNTRL, val);
+ if (ret < 0)
+ return ret;
+
+ return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ADIN_CRSM_STAT, ret,
+ (ret & ADIN_CRSM_SFT_PD_RDY) == val,
+ 1000, 30000, true);
+}
+
+static int adin_suspend(struct phy_device *phydev)
+{
+ return adin_set_powerdown_mode(phydev, true);
+}
+
+static int adin_resume(struct phy_device *phydev)
+{
+ return adin_set_powerdown_mode(phydev, false);
+}
+
+static int adin_set_loopback(struct phy_device *phydev, bool enable)
+{
+ if (enable)
+ return phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_10T1L_CTRL,
+ BMCR_LOOPBACK);
+
+ /* PCS loopback (according to 10BASE-T1L spec) */
+ return phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_10T1L_CTRL,
+ BMCR_LOOPBACK);
+}
+
+static int adin_soft_reset(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, ADIN_CRSM_SFT_RST, ADIN_CRSM_SFT_RST_EN);
+ if (ret < 0)
+ return ret;
+
+ return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ADIN_CRSM_STAT, ret,
+ (ret & ADIN_CRSM_SYS_RDY),
+ 10000, 30000, true);
+}
+
+static int adin_get_features(struct phy_device *phydev)
+{
+ struct adin_priv *priv = phydev->priv;
+ struct device *dev = &phydev->mdio.dev;
+ int ret;
+ u8 val;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10T1L_STAT);
+ if (ret < 0)
+ return ret;
+
+ /* This depends on the voltage level from the power source */
+ priv->tx_level_2v4_able = !!(ret & MDIO_PMA_10T1L_STAT_2V4_ABLE);
+
+ phydev_dbg(phydev, "PHY supports 2.4V TX level: %s\n",
+ priv->tx_level_2v4_able ? "yes" : "no");
+
+ priv->tx_level_prop_present = device_property_present(dev, "10base-t1l-2.4vpp");
+ if (priv->tx_level_prop_present) {
+ ret = device_property_read_u8(dev, "10base-t1l-2.4vpp", &val);
+ if (ret < 0)
+ return ret;
+
+ priv->tx_level_2v4 = val;
+ if (!priv->tx_level_2v4 && priv->tx_level_2v4_able)
+ phydev_info(phydev,
+ "PHY supports 2.4V TX level, but disabled via config\n");
+ }
+
+ linkmode_set_bit_array(phy_basic_ports_array, ARRAY_SIZE(phy_basic_ports_array),
+ phydev->supported);
+
+ linkmode_set_bit_array(phy_10_features_array, ARRAY_SIZE(phy_10_features_array),
+ phydev->supported);
+
+ return 0;
+}
+
+static int adin_probe(struct phy_device *phydev)
+{
+ struct device *dev = &phydev->mdio.dev;
+ struct adin_priv *priv;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ phydev->priv = priv;
+
+ return 0;
+}
+
Without spending too much time on review right now, I would expect that
most of this code should got to the drivers/net/phy/phy-c45.c
From: Rob Herring <robh@kernel.org> Date: 2021-10-18 19:06:31
On Mon, Oct 11, 2021 at 05:22:14PM +0300, alexandru.tachici@analog.com wrote:
quoted hunk
From: Alexandru Tachici <redacted>
Add a tristate property to advertise desired transmit level.
If the device supports the 2.4 Vpp operating mode for 10BASE-T1L,
as defined in 802.3gc, and the 2.4 Vpp transmit voltage operation
is desired, property should be set to 1. This property is used
to select whether Auto-Negotiation advertises a request to
operate the 10BASE-T1L PHY in increased transmit level mode.
If property is set to 1, the PHY shall advertise a request
to operate the 10BASE-T1L PHY in increased transmit level mode.
If property is set to zero, the PHY shall not advertise
a request to operate the 10BASE-T1L PHY in increased transmit level mode.
Signed-off-by: Alexandru Tachici <redacted>
---
Documentation/devicetree/bindings/net/ethernet-phy.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
On Mon, Oct 18, 2021 at 02:06:19PM -0500, Rob Herring wrote:
On Mon, Oct 11, 2021 at 05:22:14PM +0300, alexandru.tachici@analog.com wrote:
quoted
From: Alexandru Tachici <redacted>
Add a tristate property to advertise desired transmit level.
If the device supports the 2.4 Vpp operating mode for 10BASE-T1L,
as defined in 802.3gc, and the 2.4 Vpp transmit voltage operation
is desired, property should be set to 1. This property is used
to select whether Auto-Negotiation advertises a request to
operate the 10BASE-T1L PHY in increased transmit level mode.
If property is set to 1, the PHY shall advertise a request
to operate the 10BASE-T1L PHY in increased transmit level mode.
If property is set to zero, the PHY shall not advertise
a request to operate the 10BASE-T1L PHY in increased transmit level mode.
Signed-off-by: Alexandru Tachici <redacted>
---
Documentation/devicetree/bindings/net/ethernet-phy.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
This one was not really synced with the IEEE 802.3 standard. According
to the standard, there is optional 10base-t1l specific 2.4 Vpp operating mode.
To be able to operate in this mode, HW should be designed to do so.
And other way around, if HW is designed for explosive environment, it
should never operate in 2.4 Vpp mode.
So, depending on this property, the ability of the link-partner and user
space configuration, we may allow to auto negotiate this mode.
The question is, should it actually be called "an-", since this property
should limit automatic and manual link configuration
Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hm.. MDIO_AN_T1_ADV_M_MST is T4 of Link codeword Base Page. The spec says:
"Transmitted Nonce Field (T[4:0]) is a 5-bit wide field whose lower 4
bits contains a random or pseudorandom number. A new value shall be
generated for each entry to the Ability Detect state"
Should we actually do it?
Managed to get some answears from the HW team:
Bits 7.515.3:0 correspond to the lower 4 bits of the Transmitted Nonce Field. We do not allow users to write these bits as they need to be controlled by the auto-negotiation (AN) sequencers in order to ensure that AN remains robust and reliable. However, the Transmitted Nonce value is readable via register 7.515. So we could call these bits out in the documentation and indicate that they are readonly.
Bottom line is that the driver cannot and should not do anything with the lower 4 Transmitted Nonce bits. The PHY controls them.
Also from 802.3 98.2.1.2.3 Transmitted Nonce Field:
If the device has received a DME page with good CRC16 and the link partner has a Transmitted Nonce Field
(T[4:0]) that matches the devices generated T[4:0], the device shall invert its T[0] bit and regenerate a new
random value for T[3:1] and use that as its new T[4:0] value. Since the DME pages are exchanged in a halfduplex manner, it is possible to swap to a new T[4:0] value prior to transmitting the DME page. One device
will always see a DME page with good CRC16 before the other device hence this swapping will guarantee
that nonce_match will never be true.
Seems that there must be hardware to deal with nonce collisions.
Regards,
Alexandru