Commit 41f5fbff authored by Maxime Chevallier's avatar Maxime Chevallier Committed by David S. Miller

net: ethernet: fs_enet: phylink conversion

fs_enet is a quite old but still used Ethernet driver found on some NXP
devices. It has support for 10/100 Mbps ethernet, with half and full
duplex. Some variants of it can use RMII, while other integrations are
MII-only.

Add phylink support, thus removing custom fixed-link hanldling.

This also allows removing some internal flags such as the use_rmii flag.
Acked-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c614acf6
......@@ -3,7 +3,7 @@ config FS_ENET
tristate "Freescale Ethernet Driver"
depends on NET_VENDOR_FREESCALE && (CPM1 || CPM2 || PPC_MPC512x)
select MII
select PHYLIB
select PHYLINK
config FS_ENET_MPC5121_FEC
def_bool y if (FS_ENET && PPC_MPC512x)
......
......@@ -7,6 +7,7 @@
#include <linux/types.h>
#include <linux/list.h>
#include <linux/phy.h>
#include <linux/phylink.h>
#include <linux/dma-mapping.h>
#ifdef CONFIG_CPM1
......@@ -76,7 +77,8 @@ struct fs_ops {
void (*free_bd)(struct net_device *dev);
void (*cleanup_data)(struct net_device *dev);
void (*set_multicast_list)(struct net_device *dev);
void (*restart)(struct net_device *dev);
void (*restart)(struct net_device *dev, phy_interface_t interface,
int speed, int duplex);
void (*stop)(struct net_device *dev);
void (*napi_clear_event)(struct net_device *dev);
void (*napi_enable)(struct net_device *dev);
......@@ -112,13 +114,9 @@ struct fs_platform_info {
u32 dpram_offset;
struct device_node *phy_node;
int rx_ring, tx_ring; /* number of buffers on rx */
int rx_copybreak; /* limit we copy small frames */
int napi_weight; /* NAPI weight */
int use_rmii; /* use RMII mode */
};
struct fs_enet_private {
......@@ -143,10 +141,10 @@ struct fs_enet_private {
cbd_t __iomem *cur_tx;
int tx_free;
u32 msg_enable;
struct phylink *phylink;
struct phylink_config phylink_config;
int interrupt;
int oldduplex, oldspeed, oldlink; /* current settings */
/* event masks */
u32 ev_napi; /* mask of NAPI events */
u32 ev; /* event mask */
......
......@@ -235,7 +235,8 @@ static void set_multicast_list(struct net_device *dev)
set_promiscuous_mode(dev);
}
static void restart(struct net_device *dev)
static void restart(struct net_device *dev, phy_interface_t interface,
int speed, int duplex)
{
struct fs_enet_private *fep = netdev_priv(dev);
const struct fs_platform_info *fpi = fep->fpi;
......@@ -359,8 +360,8 @@ static void restart(struct net_device *dev)
fs_init_bds(dev);
/* adjust to speed (for RMII mode) */
if (fpi->use_rmii) {
if (dev->phydev->speed == SPEED_100)
if (interface == PHY_INTERFACE_MODE_RMII) {
if (speed == SPEED_100)
C8(fcccp, fcc_gfemr, 0x20);
else
S8(fcccp, fcc_gfemr, 0x20);
......@@ -382,11 +383,11 @@ static void restart(struct net_device *dev)
W32(fccp, fcc_fpsmr, FCC_PSMR_ENCRC);
if (fpi->use_rmii)
if (interface == PHY_INTERFACE_MODE_RMII)
S32(fccp, fcc_fpsmr, FCC_PSMR_RMII);
/* adjust to duplex mode */
if (dev->phydev->duplex == DUPLEX_FULL)
if (duplex == DUPLEX_FULL)
S32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB);
else
C32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB);
......
......@@ -220,7 +220,8 @@ static void set_multicast_list(struct net_device *dev)
set_promiscuous_mode(dev);
}
static void restart(struct net_device *dev)
static void restart(struct net_device *dev, phy_interface_t interface,
int speed, int duplex)
{
struct fs_enet_private *fep = netdev_priv(dev);
struct fec __iomem *fecp = fep->fec.fecp;
......@@ -302,13 +303,13 @@ static void restart(struct net_device *dev)
* Only set MII/RMII mode - do not touch maximum frame length
* configured before.
*/
FS(fecp, r_cntrl, fpi->use_rmii ?
FS(fecp, r_cntrl, interface == PHY_INTERFACE_MODE_RMII ?
FEC_RCNTRL_RMII_MODE : FEC_RCNTRL_MII_MODE);
#endif
/*
* adjust to duplex mode
*/
if (dev->phydev->duplex == DUPLEX_FULL) {
if (duplex == DUPLEX_FULL) {
FC(fecp, r_cntrl, FEC_RCNTRL_DRT);
FS(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD enable */
} else {
......
......@@ -226,7 +226,8 @@ static void set_multicast_list(struct net_device *dev)
* change. This only happens when switching between half and full
* duplex.
*/
static void restart(struct net_device *dev)
static void restart(struct net_device *dev, phy_interface_t interface,
int speed, int duplex)
{
struct fs_enet_private *fep = netdev_priv(dev);
scc_t __iomem *sccp = fep->scc.sccp;
......@@ -337,7 +338,7 @@ static void restart(struct net_device *dev)
W16(sccp, scc_psmr, SCC_PSMR_ENCRC | SCC_PSMR_NIB22);
/* Set full duplex mode if needed */
if (dev->phydev->duplex == DUPLEX_FULL)
if (duplex == DUPLEX_FULL)
S16(sccp, scc_psmr, SCC_PSMR_LPB | SCC_PSMR_FDE);
/* Restore multicast and promiscuous settings */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment