Skip to content

Commit

Permalink
net: fman: Don't pass comm_mode to enable/disable
Browse files Browse the repository at this point in the history
mac_priv_s->enable() and ->disable() are always called with
a comm_mode of COMM_MODE_RX_AND_TX. Remove this parameter, and refactor
the macs appropriately.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
Tested-by: Camelia Groza <camelia.groza@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Sean Anderson authored and Jakub Kicinski committed Aug 19, 2022
1 parent 8585bda commit b7d8525
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 46 deletions.
20 changes: 6 additions & 14 deletions drivers/net/ethernet/freescale/fman/fman_dtsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ static void graceful_stop(struct fman_mac *dtsec, enum comm_mode mode)
}
}

int dtsec_enable(struct fman_mac *dtsec, enum comm_mode mode)
int dtsec_enable(struct fman_mac *dtsec)
{
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
Expand All @@ -889,20 +889,16 @@ int dtsec_enable(struct fman_mac *dtsec, enum comm_mode mode)

/* Enable */
tmp = ioread32be(&regs->maccfg1);
if (mode & COMM_MODE_RX)
tmp |= MACCFG1_RX_EN;
if (mode & COMM_MODE_TX)
tmp |= MACCFG1_TX_EN;

tmp |= MACCFG1_RX_EN | MACCFG1_TX_EN;
iowrite32be(tmp, &regs->maccfg1);

/* Graceful start - clear the graceful Rx/Tx stop bit */
graceful_start(dtsec, mode);
graceful_start(dtsec, COMM_MODE_RX_AND_TX);

return 0;
}

int dtsec_disable(struct fman_mac *dtsec, enum comm_mode mode)
int dtsec_disable(struct fman_mac *dtsec)
{
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
Expand All @@ -911,14 +907,10 @@ int dtsec_disable(struct fman_mac *dtsec, enum comm_mode mode)
return -EINVAL;

/* Graceful stop - Assert the graceful Rx/Tx stop bit */
graceful_stop(dtsec, mode);
graceful_stop(dtsec, COMM_MODE_RX_AND_TX);

tmp = ioread32be(&regs->maccfg1);
if (mode & COMM_MODE_RX)
tmp &= ~MACCFG1_RX_EN;
if (mode & COMM_MODE_TX)
tmp &= ~MACCFG1_TX_EN;

tmp &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN);
iowrite32be(tmp, &regs->maccfg1);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/freescale/fman/fman_dtsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ int dtsec_adjust_link(struct fman_mac *dtsec,
int dtsec_restart_autoneg(struct fman_mac *dtsec);
int dtsec_cfg_max_frame_len(struct fman_mac *dtsec, u16 new_val);
int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool new_val);
int dtsec_enable(struct fman_mac *dtsec, enum comm_mode mode);
int dtsec_disable(struct fman_mac *dtsec, enum comm_mode mode);
int dtsec_enable(struct fman_mac *dtsec);
int dtsec_disable(struct fman_mac *dtsec);
int dtsec_init(struct fman_mac *dtsec);
int dtsec_free(struct fman_mac *dtsec);
int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, bool en);
Expand Down
16 changes: 4 additions & 12 deletions drivers/net/ethernet/freescale/fman/fman_memac.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ static bool is_init_done(struct memac_cfg *memac_drv_params)
return false;
}

int memac_enable(struct fman_mac *memac, enum comm_mode mode)
int memac_enable(struct fman_mac *memac)
{
struct memac_regs __iomem *regs = memac->regs;
u32 tmp;
Expand All @@ -694,17 +694,13 @@ int memac_enable(struct fman_mac *memac, enum comm_mode mode)
return -EINVAL;

tmp = ioread32be(&regs->command_config);
if (mode & COMM_MODE_RX)
tmp |= CMD_CFG_RX_EN;
if (mode & COMM_MODE_TX)
tmp |= CMD_CFG_TX_EN;

tmp |= CMD_CFG_RX_EN | CMD_CFG_TX_EN;
iowrite32be(tmp, &regs->command_config);

return 0;
}

int memac_disable(struct fman_mac *memac, enum comm_mode mode)
int memac_disable(struct fman_mac *memac)
{
struct memac_regs __iomem *regs = memac->regs;
u32 tmp;
Expand All @@ -713,11 +709,7 @@ int memac_disable(struct fman_mac *memac, enum comm_mode mode)
return -EINVAL;

tmp = ioread32be(&regs->command_config);
if (mode & COMM_MODE_RX)
tmp &= ~CMD_CFG_RX_EN;
if (mode & COMM_MODE_TX)
tmp &= ~CMD_CFG_TX_EN;

tmp &= ~(CMD_CFG_RX_EN | CMD_CFG_TX_EN);
iowrite32be(tmp, &regs->command_config);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/freescale/fman/fman_memac.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ int memac_cfg_max_frame_len(struct fman_mac *memac, u16 new_val);
int memac_cfg_reset_on_init(struct fman_mac *memac, bool enable);
int memac_cfg_fixed_link(struct fman_mac *memac,
struct fixed_phy_status *fixed_link);
int memac_enable(struct fman_mac *memac, enum comm_mode mode);
int memac_disable(struct fman_mac *memac, enum comm_mode mode);
int memac_enable(struct fman_mac *memac);
int memac_disable(struct fman_mac *memac);
int memac_init(struct fman_mac *memac);
int memac_free(struct fman_mac *memac);
int memac_accept_rx_pause_frames(struct fman_mac *memac, bool en);
Expand Down
14 changes: 4 additions & 10 deletions drivers/net/ethernet/freescale/fman/fman_tgec.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static bool is_init_done(struct tgec_cfg *cfg)
return false;
}

int tgec_enable(struct fman_mac *tgec, enum comm_mode mode)
int tgec_enable(struct fman_mac *tgec)
{
struct tgec_regs __iomem *regs = tgec->regs;
u32 tmp;
Expand All @@ -401,16 +401,13 @@ int tgec_enable(struct fman_mac *tgec, enum comm_mode mode)
return -EINVAL;

tmp = ioread32be(&regs->command_config);
if (mode & COMM_MODE_RX)
tmp |= CMD_CFG_RX_EN;
if (mode & COMM_MODE_TX)
tmp |= CMD_CFG_TX_EN;
tmp |= CMD_CFG_RX_EN | CMD_CFG_TX_EN;
iowrite32be(tmp, &regs->command_config);

return 0;
}

int tgec_disable(struct fman_mac *tgec, enum comm_mode mode)
int tgec_disable(struct fman_mac *tgec)
{
struct tgec_regs __iomem *regs = tgec->regs;
u32 tmp;
Expand All @@ -419,10 +416,7 @@ int tgec_disable(struct fman_mac *tgec, enum comm_mode mode)
return -EINVAL;

tmp = ioread32be(&regs->command_config);
if (mode & COMM_MODE_RX)
tmp &= ~CMD_CFG_RX_EN;
if (mode & COMM_MODE_TX)
tmp &= ~CMD_CFG_TX_EN;
tmp &= ~(CMD_CFG_RX_EN | CMD_CFG_TX_EN);
iowrite32be(tmp, &regs->command_config);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/freescale/fman/fman_tgec.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ struct fman_mac *tgec_config(struct fman_mac_params *params);
int tgec_set_promiscuous(struct fman_mac *tgec, bool new_val);
int tgec_modify_mac_address(struct fman_mac *tgec, const enet_addr_t *enet_addr);
int tgec_cfg_max_frame_len(struct fman_mac *tgec, u16 new_val);
int tgec_enable(struct fman_mac *tgec, enum comm_mode mode);
int tgec_disable(struct fman_mac *tgec, enum comm_mode mode);
int tgec_enable(struct fman_mac *tgec);
int tgec_disable(struct fman_mac *tgec);
int tgec_init(struct fman_mac *tgec);
int tgec_free(struct fman_mac *tgec);
int tgec_accept_rx_pause_frames(struct fman_mac *tgec, bool en);
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/ethernet/freescale/fman/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct mac_priv_s {
u16 speed;
u16 max_speed;

int (*enable)(struct fman_mac *mac_dev, enum comm_mode mode);
int (*disable)(struct fman_mac *mac_dev, enum comm_mode mode);
int (*enable)(struct fman_mac *mac_dev);
int (*disable)(struct fman_mac *mac_dev);
};

struct mac_address {
Expand Down Expand Up @@ -247,7 +247,7 @@ static int start(struct mac_device *mac_dev)
struct phy_device *phy_dev = mac_dev->phy_dev;
struct mac_priv_s *priv = mac_dev->priv;

err = priv->enable(mac_dev->fman_mac, COMM_MODE_RX_AND_TX);
err = priv->enable(mac_dev->fman_mac);
if (!err && phy_dev)
phy_start(phy_dev);

Expand All @@ -261,7 +261,7 @@ static int stop(struct mac_device *mac_dev)
if (mac_dev->phy_dev)
phy_stop(mac_dev->phy_dev);

return priv->disable(mac_dev->fman_mac, COMM_MODE_RX_AND_TX);
return priv->disable(mac_dev->fman_mac);
}

static int set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
Expand Down

0 comments on commit b7d8525

Please sign in to comment.