Skip to content

Commit b9274ab

Browse files
committed
Merge branch 'net-phy-bcm54811-phy-initialization'
says: ==================== net: phy: bcm54811: PHY initialization Proper bcm54811 PHY driver initialization for MII-Lite. The bcm54811 PHY in MLP package must be setup for MII-Lite interface mode by software. Normally, the PHY to MAC interface is selected in hardware by setting the bootstrap pins of the PHY. However, MII and MII-Lite share the same hardware setup and must be distinguished by software, setting appropriate bit in a configuration register. The MII-Lite interface mode is non-standard one, defined by Broadcom for some of their PHYs. The MII-Lite lightness consist in omitting RXER, TXER, CRS and COL signals of the standard MII interface. Absence of COL them makes half-duplex links modes impossible but does not interfere with Broadcom's BroadR-Reach link modes, because they are full-duplex only. To do it in a clean way, MII-Lite must be introduced first, including its limitation to link modes (no half-duplex), because it is a prerequisite for the patch kernel-patches#3 of this series. The patch kernel-patches#4 does not depend on MII-Lite directly but both kernel-patches#3 and kernel-patches#4 are necessary for bcm54811 to work properly without additional configuration steps to be done - for example in the bootloader, before the kernel starts. PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.). PATCH 2 - Add MII-Lite PHY interface type PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x PHYs PATCH 4 - Initialize the BCM54811 PHY properly so that it conforms to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Ignore the LDS capability bit in LRE Status register on bcm54811. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6dfcbd7 + 3117a11 commit b9274ab

File tree

8 files changed

+58
-5
lines changed

8 files changed

+58
-5
lines changed

Documentation/devicetree/bindings/net/ethernet-controller.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ properties:
3939
# MAC.
4040
- internal
4141
- mii
42+
- mii-lite
4243
- gmii
4344
- sgmii
4445
- psgmii

Documentation/networking/phy.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ Some of the interface modes are described below:
333333
SerDes lane, each port having speeds of 2.5G / 1G / 100M / 10M achieved
334334
through symbol replication. The PCS expects the standard USXGMII code word.
335335

336+
``PHY_INTERFACE_MODE_MIILITE``
337+
Non-standard, simplified MII mode, without TXER, RXER, CRS and COL signals
338+
as defined for the MII. The absence of COL signal makes half-duplex link
339+
modes impossible but does not interfere with BroadR-Reach link modes on
340+
Broadcom (and other two-wire Ethernet) PHYs, because they are full-duplex
341+
only.
342+
336343
Pause frames / flow control
337344
===========================
338345

drivers/net/phy/broadcom.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static int bcm5481x_set_brrmode(struct phy_device *phydev, bool on)
407407
static int bcm54811_config_init(struct phy_device *phydev)
408408
{
409409
struct bcm54xx_phy_priv *priv = phydev->priv;
410-
int err, reg;
410+
int err, reg, exp_sync_ethernet;
411411

412412
/* Enable CLK125 MUX on LED4 if ref clock is enabled. */
413413
if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) {
@@ -424,6 +424,18 @@ static int bcm54811_config_init(struct phy_device *phydev)
424424
if (priv->brr_mode)
425425
phydev->autoneg = 0;
426426

427+
/* Enable MII Lite (No TXER, RXER, CRS, COL) if configured */
428+
if (phydev->interface == PHY_INTERFACE_MODE_MIILITE)
429+
exp_sync_ethernet = BCM_EXP_SYNC_ETHERNET_MII_LITE;
430+
else
431+
exp_sync_ethernet = 0;
432+
433+
err = bcm_phy_modify_exp(phydev, BCM_EXP_SYNC_ETHERNET,
434+
BCM_EXP_SYNC_ETHERNET_MII_LITE,
435+
exp_sync_ethernet);
436+
if (err < 0)
437+
return err;
438+
427439
return bcm5481x_set_brrmode(phydev, priv->brr_mode);
428440
}
429441

@@ -655,7 +667,7 @@ static int bcm5481x_read_abilities(struct phy_device *phydev)
655667
{
656668
struct device_node *np = phydev->mdio.dev.of_node;
657669
struct bcm54xx_phy_priv *priv = phydev->priv;
658-
int i, val, err;
670+
int i, val, err, aneg;
659671

660672
for (i = 0; i < ARRAY_SIZE(bcm54811_linkmodes); i++)
661673
linkmode_clear_bit(bcm54811_linkmodes[i], phydev->supported);
@@ -676,9 +688,19 @@ static int bcm5481x_read_abilities(struct phy_device *phydev)
676688
if (val < 0)
677689
return val;
678690

691+
/* BCM54811 is not capable of LDS but the corresponding bit
692+
* in LRESR is set to 1 and marked "Ignore" in the datasheet.
693+
* So we must read the bcm54811 as unable to auto-negotiate
694+
* in BroadR-Reach mode.
695+
*/
696+
if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
697+
aneg = 0;
698+
else
699+
aneg = val & LRESR_LDSABILITY;
700+
679701
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
680702
phydev->supported,
681-
val & LRESR_LDSABILITY);
703+
aneg);
682704
linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
683705
phydev->supported,
684706
val & LRESR_100_1PAIR);
@@ -735,8 +757,15 @@ static int bcm54811_config_aneg(struct phy_device *phydev)
735757

736758
/* Aneg firstly. */
737759
if (priv->brr_mode) {
738-
/* BCM54811 is only capable of autonegotiation in IEEE mode */
739-
phydev->autoneg = 0;
760+
/* BCM54811 is only capable of autonegotiation in IEEE mode.
761+
* In BroadR-Reach mode, disable the Long Distance Signaling,
762+
* the BRR mode autoneg as supported in other Broadcom PHYs.
763+
* This bit is marked as "Reserved" and "Default 1, must be
764+
* written to 0 after every device reset" in the datasheet.
765+
*/
766+
ret = phy_modify(phydev, MII_BCM54XX_LRECR, LRECR_LDSEN, 0);
767+
if (ret < 0)
768+
return ret;
740769
ret = bcm_config_lre_aneg(phydev, false);
741770
} else {
742771
ret = genphy_config_aneg(phydev);

drivers/net/phy/phy-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ int phy_interface_num_ports(phy_interface_t interface)
115115
return 0;
116116
case PHY_INTERFACE_MODE_INTERNAL:
117117
case PHY_INTERFACE_MODE_MII:
118+
case PHY_INTERFACE_MODE_MIILITE:
118119
case PHY_INTERFACE_MODE_GMII:
119120
case PHY_INTERFACE_MODE_TBI:
120121
case PHY_INTERFACE_MODE_REVMII:

drivers/net/phy/phy_caps.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ unsigned long phy_caps_from_interface(phy_interface_t interface)
316316
link_caps |= BIT(LINK_CAPA_100HD) | BIT(LINK_CAPA_100FD);
317317
break;
318318

319+
case PHY_INTERFACE_MODE_MIILITE:
320+
link_caps |= BIT(LINK_CAPA_10FD) | BIT(LINK_CAPA_100FD);
321+
break;
322+
319323
case PHY_INTERFACE_MODE_TBI:
320324
case PHY_INTERFACE_MODE_MOCA:
321325
case PHY_INTERFACE_MODE_RTBI:

drivers/net/phy/phylink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ static int phylink_interface_max_speed(phy_interface_t interface)
237237
case PHY_INTERFACE_MODE_SMII:
238238
case PHY_INTERFACE_MODE_REVMII:
239239
case PHY_INTERFACE_MODE_MII:
240+
case PHY_INTERFACE_MODE_MIILITE:
240241
return SPEED_100;
241242

242243
case PHY_INTERFACE_MODE_TBI:

include/linux/brcmphy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@
182182
#define BCM_LED_MULTICOLOR_ACT 0x9
183183
#define BCM_LED_MULTICOLOR_PROGRAM 0xa
184184

185+
/*
186+
* Broadcom Synchronous Ethernet Controls (expansion register 0x0E)
187+
*/
188+
#define BCM_EXP_SYNC_ETHERNET (MII_BCM54XX_EXP_SEL_ER + 0x0E)
189+
#define BCM_EXP_SYNC_ETHERNET_MII_LITE BIT(11)
190+
185191
/*
186192
* BCM5482: Shadow registers
187193
* Shadow values go into bits [14:10] of register 0x1c to select a shadow

include/linux/phy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern const int phy_basic_ports_array[3];
106106
* @PHY_INTERFACE_MODE_50GBASER: 50GBase-R - with Clause 134 FEC
107107
* @PHY_INTERFACE_MODE_LAUI: 50 Gigabit Attachment Unit Interface
108108
* @PHY_INTERFACE_MODE_100GBASEP: 100GBase-P - with Clause 134 FEC
109+
* @PHY_INTERFACE_MODE_MIILITE: MII-Lite - MII without RXER TXER CRS COL
109110
* @PHY_INTERFACE_MODE_MAX: Book keeping
110111
*
111112
* Describes the interface between the MAC and PHY.
@@ -150,6 +151,7 @@ typedef enum {
150151
PHY_INTERFACE_MODE_50GBASER,
151152
PHY_INTERFACE_MODE_LAUI,
152153
PHY_INTERFACE_MODE_100GBASEP,
154+
PHY_INTERFACE_MODE_MIILITE,
153155
PHY_INTERFACE_MODE_MAX,
154156
} phy_interface_t;
155157

@@ -272,6 +274,8 @@ static inline const char *phy_modes(phy_interface_t interface)
272274
return "laui";
273275
case PHY_INTERFACE_MODE_100GBASEP:
274276
return "100gbase-p";
277+
case PHY_INTERFACE_MODE_MIILITE:
278+
return "mii-lite";
275279
default:
276280
return "unknown";
277281
}

0 commit comments

Comments
 (0)