Skip to content

Commit dda1c25

Browse files
Russell King (Oracle)davem330
authored andcommitted
net: dsa: b53: populate supported_interfaces and mac_capabilities
Populate the supported interfaces and MAC capabilities for the Broadcom B53 DSA switches in preparation to using these for the generic validation functionality. The interface modes are derived from: - b53_serdes_phylink_validate() - SRAB mux configuration Signed-off-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 341b672 commit dda1c25

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,33 @@ void b53_phylink_validate(struct dsa_switch *ds, int port,
13531353
}
13541354
EXPORT_SYMBOL(b53_phylink_validate);
13551355

1356+
static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
1357+
struct phylink_config *config)
1358+
{
1359+
struct b53_device *dev = ds->priv;
1360+
1361+
/* Internal ports need GMII for PHYLIB */
1362+
__set_bit(PHY_INTERFACE_MODE_GMII, config->supported_interfaces);
1363+
1364+
/* These switches appear to support MII and RevMII too, but beyond
1365+
* this, the code gives very few clues. FIXME: We probably need more
1366+
* interface modes here.
1367+
*/
1368+
__set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces);
1369+
__set_bit(PHY_INTERFACE_MODE_REVMII, config->supported_interfaces);
1370+
1371+
config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1372+
MAC_10 | MAC_100;
1373+
1374+
/* 5325/5365 are not capable of gigabit speeds, everything else is */
1375+
if (!(is5325(dev) || is5365(dev)))
1376+
config->mac_capabilities |= MAC_1000;
1377+
1378+
/* Get the implementation specific capabilities */
1379+
if (dev->ops->phylink_get_caps)
1380+
dev->ops->phylink_get_caps(dev, port, config);
1381+
}
1382+
13561383
int b53_phylink_mac_link_state(struct dsa_switch *ds, int port,
13571384
struct phylink_link_state *state)
13581385
{
@@ -2262,6 +2289,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
22622289
.phy_read = b53_phy_read16,
22632290
.phy_write = b53_phy_write16,
22642291
.adjust_link = b53_adjust_link,
2292+
.phylink_get_caps = b53_phylink_get_caps,
22652293
.phylink_validate = b53_phylink_validate,
22662294
.phylink_mac_link_state = b53_phylink_mac_link_state,
22672295
.phylink_mac_config = b53_phylink_mac_config,

drivers/net/dsa/b53/b53_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct b53_io_ops {
4646
int (*phy_write16)(struct b53_device *dev, int addr, int reg, u16 value);
4747
int (*irq_enable)(struct b53_device *dev, int port);
4848
void (*irq_disable)(struct b53_device *dev, int port);
49+
void (*phylink_get_caps)(struct b53_device *dev, int port,
50+
struct phylink_config *config);
4951
u8 (*serdes_map_lane)(struct b53_device *dev, int port);
5052
int (*serdes_link_state)(struct b53_device *dev, int port,
5153
struct phylink_link_state *state);

drivers/net/dsa/b53/b53_serdes.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,35 @@ void b53_serdes_phylink_validate(struct b53_device *dev, int port,
180180
}
181181
EXPORT_SYMBOL(b53_serdes_phylink_validate);
182182

183+
void b53_serdes_phylink_get_caps(struct b53_device *dev, int port,
184+
struct phylink_config *config)
185+
{
186+
u8 lane = b53_serdes_map_lane(dev, port);
187+
188+
if (lane == B53_INVALID_LANE)
189+
return;
190+
191+
switch (lane) {
192+
case 0:
193+
/* It appears lane 0 supports 2500base-X and 1000base-X */
194+
__set_bit(PHY_INTERFACE_MODE_2500BASEX,
195+
config->supported_interfaces);
196+
config->mac_capabilities |= MAC_2500FD;
197+
fallthrough;
198+
case 1:
199+
/* It appears lane 1 only supports 1000base-X and SGMII */
200+
__set_bit(PHY_INTERFACE_MODE_1000BASEX,
201+
config->supported_interfaces);
202+
__set_bit(PHY_INTERFACE_MODE_SGMII,
203+
config->supported_interfaces);
204+
config->mac_capabilities |= MAC_1000FD;
205+
break;
206+
default:
207+
break;
208+
}
209+
}
210+
EXPORT_SYMBOL(b53_serdes_phylink_get_caps);
211+
183212
int b53_serdes_init(struct b53_device *dev, int port)
184213
{
185214
u8 lane = b53_serdes_map_lane(dev, port);

drivers/net/dsa/b53/b53_serdes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ void b53_serdes_config(struct b53_device *dev, int port, unsigned int mode,
115115
void b53_serdes_an_restart(struct b53_device *dev, int port);
116116
void b53_serdes_link_set(struct b53_device *dev, int port, unsigned int mode,
117117
phy_interface_t interface, bool link_up);
118+
void b53_serdes_phylink_get_caps(struct b53_device *dev, int port,
119+
struct phylink_config *config);
118120
void b53_serdes_phylink_validate(struct b53_device *dev, int port,
119121
unsigned long *supported,
120122
struct phylink_link_state *state);

drivers/net/dsa/b53/b53_srab.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,39 @@ static void b53_srab_irq_disable(struct b53_device *dev, int port)
443443
}
444444
}
445445

446+
static void b53_srab_phylink_get_caps(struct b53_device *dev, int port,
447+
struct phylink_config *config)
448+
{
449+
struct b53_srab_priv *priv = dev->priv;
450+
struct b53_srab_port_priv *p = &priv->port_intrs[port];
451+
452+
switch (p->mode) {
453+
case PHY_INTERFACE_MODE_SGMII:
454+
#if IS_ENABLED(CONFIG_B53_SERDES)
455+
/* If p->mode indicates SGMII mode, that essentially means we
456+
* are using a serdes. As the serdes for the capabilities.
457+
*/
458+
b53_serdes_phylink_get_caps(dev, port, config);
459+
#endif
460+
break;
461+
462+
case PHY_INTERFACE_MODE_NA:
463+
break;
464+
465+
case PHY_INTERFACE_MODE_RGMII:
466+
/* If we support RGMII, support all RGMII modes, since
467+
* that dictates the PHY delay settings.
468+
*/
469+
phy_interface_set_rgmii(config->supported_interfaces);
470+
break;
471+
472+
default:
473+
/* Some other mode (e.g. MII, GMII etc) */
474+
__set_bit(p->mode, config->supported_interfaces);
475+
break;
476+
}
477+
}
478+
446479
static const struct b53_io_ops b53_srab_ops = {
447480
.read8 = b53_srab_read8,
448481
.read16 = b53_srab_read16,
@@ -456,6 +489,7 @@ static const struct b53_io_ops b53_srab_ops = {
456489
.write64 = b53_srab_write64,
457490
.irq_enable = b53_srab_irq_enable,
458491
.irq_disable = b53_srab_irq_disable,
492+
.phylink_get_caps = b53_srab_phylink_get_caps,
459493
#if IS_ENABLED(CONFIG_B53_SERDES)
460494
.serdes_map_lane = b53_srab_serdes_map_lane,
461495
.serdes_link_state = b53_serdes_link_state,

0 commit comments

Comments
 (0)