Skip to content

Commit b92143d

Browse files
Russell King (Oracle)davem330
Russell King (Oracle)
authored andcommitted
net: dsa: mv88e6xxx: add infrastructure for phylink_pcs
Add infrastructure for phylink_pcs to the mv88e6xxx driver. This involves adding a mac_select_pcs() hook so we can pass the PCS to phylink at the appropriate time, and a PCS initialisation function. As the various chip implementations are converted to use phylink_pcs, they are no longer reliant on the legacy phylink behaviour. We detect this by the use of this infrastructure, or the lack of any serdes. Signed-off-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 40da0c3 commit b92143d

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,31 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,
844844
__set_bit(PHY_INTERFACE_MODE_GMII,
845845
config->supported_interfaces);
846846
}
847+
848+
/* If we have a .pcs_ops, or don't have a .serdes_pcs_get_state,
849+
* serdes_pcs_config, serdes_pcs_an_restart, or serdes_pcs_link_up,
850+
* we are not legacy.
851+
*/
852+
if (chip->info->ops->pcs_ops ||
853+
(!chip->info->ops->serdes_pcs_get_state &&
854+
!chip->info->ops->serdes_pcs_config &&
855+
!chip->info->ops->serdes_pcs_an_restart &&
856+
!chip->info->ops->serdes_pcs_link_up))
857+
config->legacy_pre_march2020 = false;
858+
}
859+
860+
static struct phylink_pcs *mv88e6xxx_mac_select_pcs(struct dsa_switch *ds,
861+
int port,
862+
phy_interface_t interface)
863+
{
864+
struct mv88e6xxx_chip *chip = ds->priv;
865+
struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
866+
867+
if (chip->info->ops->pcs_ops)
868+
pcs = chip->info->ops->pcs_ops->pcs_select(chip, port,
869+
interface);
870+
871+
return pcs;
847872
}
848873

849874
static int mv88e6xxx_mac_prepare(struct dsa_switch *ds, int port,
@@ -3582,6 +3607,10 @@ static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
35823607
struct mv88e6xxx_chip *chip = ds->priv;
35833608
int err;
35843609

3610+
/* Do not control power or request irqs if using PCS */
3611+
if (chip->info->ops->pcs_ops)
3612+
return 0;
3613+
35853614
mv88e6xxx_reg_lock(chip);
35863615
err = mv88e6xxx_serdes_power(chip, port, true);
35873616
mv88e6xxx_reg_unlock(chip);
@@ -3593,6 +3622,10 @@ static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
35933622
{
35943623
struct mv88e6xxx_chip *chip = ds->priv;
35953624

3625+
/* Do not control power or request irqs if using PCS */
3626+
if (chip->info->ops->pcs_ops)
3627+
return;
3628+
35963629
mv88e6xxx_reg_lock(chip);
35973630
if (mv88e6xxx_serdes_power(chip, port, false))
35983631
dev_err(chip->dev, "failed to power off SERDES\n");
@@ -4061,12 +4094,26 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
40614094

40624095
static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
40634096
{
4097+
struct mv88e6xxx_chip *chip = ds->priv;
4098+
int err;
4099+
4100+
if (chip->info->ops->pcs_ops->pcs_init) {
4101+
err = chip->info->ops->pcs_ops->pcs_init(chip, port);
4102+
if (err)
4103+
return err;
4104+
}
4105+
40644106
return mv88e6xxx_setup_devlink_regions_port(ds, port);
40654107
}
40664108

40674109
static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port)
40684110
{
4111+
struct mv88e6xxx_chip *chip = ds->priv;
4112+
40694113
mv88e6xxx_teardown_devlink_regions_port(ds, port);
4114+
4115+
if (chip->info->ops->pcs_ops->pcs_teardown)
4116+
chip->info->ops->pcs_ops->pcs_teardown(chip, port);
40704117
}
40714118

40724119
static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
@@ -7061,6 +7108,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
70617108
.port_setup = mv88e6xxx_port_setup,
70627109
.port_teardown = mv88e6xxx_port_teardown,
70637110
.phylink_get_caps = mv88e6xxx_get_caps,
7111+
.phylink_mac_select_pcs = mv88e6xxx_mac_select_pcs,
70647112
.phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
70657113
.phylink_mac_prepare = mv88e6xxx_mac_prepare,
70667114
.phylink_mac_config = mv88e6xxx_mac_config,

drivers/net/dsa/mv88e6xxx/chip.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ struct mv88e6xxx_irq_ops;
205205
struct mv88e6xxx_gpio_ops;
206206
struct mv88e6xxx_avb_ops;
207207
struct mv88e6xxx_ptp_ops;
208+
struct mv88e6xxx_pcs_ops;
208209

209210
struct mv88e6xxx_irq {
210211
u16 masked;
@@ -288,6 +289,7 @@ struct mv88e6xxx_port {
288289
unsigned int serdes_irq;
289290
char serdes_irq_name[64];
290291
struct devlink_region *region;
292+
void *pcs_private;
291293

292294
/* MacAuth Bypass control flag */
293295
bool mab;
@@ -664,6 +666,8 @@ struct mv88e6xxx_ops {
664666
void (*phylink_get_caps)(struct mv88e6xxx_chip *chip, int port,
665667
struct phylink_config *config);
666668

669+
const struct mv88e6xxx_pcs_ops *pcs_ops;
670+
667671
/* Max Frame Size */
668672
int (*set_max_frame_size)(struct mv88e6xxx_chip *chip, int mtu);
669673
};
@@ -736,6 +740,14 @@ struct mv88e6xxx_ptp_ops {
736740
u32 cc_mult_dem;
737741
};
738742

743+
struct mv88e6xxx_pcs_ops {
744+
int (*pcs_init)(struct mv88e6xxx_chip *chip, int port);
745+
void (*pcs_teardown)(struct mv88e6xxx_chip *chip, int port);
746+
struct phylink_pcs *(*pcs_select)(struct mv88e6xxx_chip *chip, int port,
747+
phy_interface_t mode);
748+
749+
};
750+
739751
#define STATS_TYPE_PORT BIT(0)
740752
#define STATS_TYPE_BANK0 BIT(1)
741753
#define STATS_TYPE_BANK1 BIT(2)

0 commit comments

Comments
 (0)