ramips: ethernet: ralink: add fe_reset_fe() to reset fe via reset controller

The dts defines the reset fe for all architectures. However
the soc code used direct register access of the reset controller.
Replace the custom soc reset with a generic fe_reset_fe().

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
This commit is contained in:
Alexander Couzens 2021-06-09 23:08:07 +02:00
parent d50e129399
commit 3fa01db479
5 changed files with 23 additions and 25 deletions

View File

@ -141,6 +141,17 @@ void fe_reset(u32 reset_bits)
usleep_range(10, 20);
}
void fe_reset_fe(struct fe_priv *priv)
{
if (!priv->rst_fe)
return;
reset_control_assert(priv->rst_fe);
usleep_range(60, 120);
reset_control_deassert(priv->rst_fe);
usleep_range(60, 120);
}
static inline void fe_int_disable(u32 mask)
{
fe_reg_w32(fe_reg_r32(FE_REG_FE_INT_ENABLE) & ~mask,
@ -1360,7 +1371,10 @@ static int __init fe_init(struct net_device *dev)
const char *mac_addr;
int err;
priv->soc->reset_fe(priv);
if (priv->soc->reset_fe)
priv->soc->reset_fe(priv);
else
fe_reset_fe(priv);
if (priv->soc->switch_init)
if (priv->soc->switch_init(priv)) {
@ -1579,6 +1593,12 @@ static int fe_probe(struct platform_device *pdev)
goto err_free_dev;
}
priv = netdev_priv(netdev);
spin_lock_init(&priv->page_lock);
priv->rst_fe = devm_reset_control_get(&pdev->dev, "fe");
if (IS_ERR(priv->rst_fe))
priv->rst_fe = NULL;
if (soc->init_data)
soc->init_data(soc, netdev);
netdev->vlan_features = netdev->hw_features &
@ -1593,8 +1613,6 @@ static int fe_probe(struct platform_device *pdev)
if (fe_reg_table[FE_REG_FE_DMA_VID_BASE])
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
priv = netdev_priv(netdev);
spin_lock_init(&priv->page_lock);
if (fe_reg_table[FE_REG_FE_COUNTER_BASE]) {
priv->hw_stats = kzalloc(sizeof(*priv->hw_stats), GFP_KERNEL);
if (!priv->hw_stats) {

View File

@ -498,6 +498,7 @@ struct fe_priv {
DECLARE_BITMAP(pending_flags, FE_FLAG_MAX);
struct reset_control *rst_ppe;
struct reset_control *rst_fe;
struct mtk_foe_entry *foe_table;
dma_addr_t foe_table_phys;
struct flow_offload __rcu **foe_flow_table;
@ -517,6 +518,7 @@ void fe_reg_w32(u32 val, enum fe_reg reg);
u32 fe_reg_r32(enum fe_reg reg);
void fe_reset(u32 reset_bits);
void fe_reset_fe(struct fe_priv *priv);
static inline void *priv_netdev(struct fe_priv *priv)
{

View File

@ -19,8 +19,6 @@
#include "mtk_eth_soc.h"
#include "mdio_rt2880.h"
#define RT2880_RESET_FE BIT(18)
static void rt2880_init_data(struct fe_soc_data *data,
struct net_device *netdev)
{
@ -33,11 +31,6 @@ static void rt2880_init_data(struct fe_soc_data *data,
/* netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; */
}
void rt2880_fe_reset(struct fe_priv *priv)
{
fe_reset(RT2880_RESET_FE);
}
static int rt2880_fwd_config(struct fe_priv *priv)
{
int ret;
@ -55,7 +48,6 @@ static int rt2880_fwd_config(struct fe_priv *priv)
struct fe_soc_data rt2880_data = {
.init_data = rt2880_init_data,
.reset_fe = rt2880_fe_reset,
.fwd_config = rt2880_fwd_config,
.pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS,
.checksum_bit = RX_DMA_L4VALID,

View File

@ -69,11 +69,6 @@ static int rt3050_fwd_config(struct fe_priv *priv)
return 0;
}
static void rt305x_fe_reset(struct fe_priv *priv)
{
fe_reset(RT305X_RESET_FE);
}
static void rt5350_init_data(struct fe_soc_data *data,
struct net_device *netdev)
{
@ -127,7 +122,6 @@ static void rt5350_fe_reset(struct fe_priv *priv)
static struct fe_soc_data rt3050_data = {
.init_data = rt305x_init_data,
.reset_fe = rt305x_fe_reset,
.fwd_config = rt3050_fwd_config,
.pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS,
.checksum_bit = RX_DMA_L4VALID,

View File

@ -19,13 +19,6 @@
#include "mtk_eth_soc.h"
#include "mdio_rt2880.h"
#define RT3883_RSTCTRL_FE BIT(21)
static void rt3883_fe_reset(struct fe_priv *priv)
{
fe_reset(RT3883_RSTCTRL_FE);
}
static int rt3883_fwd_config(struct fe_priv *priv)
{
int ret;
@ -54,7 +47,6 @@ static void rt3883_init_data(struct fe_soc_data *data,
static struct fe_soc_data rt3883_data = {
.init_data = rt3883_init_data,
.reset_fe = rt3883_fe_reset,
.fwd_config = rt3883_fwd_config,
.pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS,
.rx_int = FE_RX_DONE_INT,