Commit 0d13a1a4 authored by Biju Das's avatar Biju Das Committed by David S. Miller

ravb: Add reset support

Reset support is present on R-Car. Let's support it, if it is
available.
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 511d74d9
...@@ -1057,6 +1057,7 @@ struct ravb_private { ...@@ -1057,6 +1057,7 @@ struct ravb_private {
unsigned int num_tx_desc; /* TX descriptors per packet */ unsigned int num_tx_desc; /* TX descriptors per packet */
const struct ravb_hw_info *info; const struct ravb_hw_info *info;
struct reset_control *rstc;
}; };
static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg) static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg)
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/sys_soc.h> #include <linux/sys_soc.h>
#include <linux/reset.h>
#include <asm/div64.h> #include <asm/div64.h>
...@@ -2140,6 +2141,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -2140,6 +2141,7 @@ static int ravb_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const struct ravb_hw_info *info; const struct ravb_hw_info *info;
struct reset_control *rstc;
struct ravb_private *priv; struct ravb_private *priv;
struct net_device *ndev; struct net_device *ndev;
int error, irq, q; int error, irq, q;
...@@ -2152,6 +2154,11 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -2152,6 +2154,11 @@ static int ravb_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
if (IS_ERR(rstc))
return dev_err_probe(&pdev->dev, PTR_ERR(rstc),
"failed to get cpg reset\n");
ndev = alloc_etherdev_mqs(sizeof(struct ravb_private), ndev = alloc_etherdev_mqs(sizeof(struct ravb_private),
NUM_TX_QUEUE, NUM_RX_QUEUE); NUM_TX_QUEUE, NUM_RX_QUEUE);
if (!ndev) if (!ndev)
...@@ -2162,6 +2169,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -2162,6 +2169,7 @@ static int ravb_probe(struct platform_device *pdev)
ndev->features = info->net_features; ndev->features = info->net_features;
ndev->hw_features = info->net_hw_features; ndev->hw_features = info->net_hw_features;
reset_control_deassert(rstc);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev); pm_runtime_get_sync(&pdev->dev);
...@@ -2179,6 +2187,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -2179,6 +2187,7 @@ static int ravb_probe(struct platform_device *pdev)
priv = netdev_priv(ndev); priv = netdev_priv(ndev);
priv->info = info; priv->info = info;
priv->rstc = rstc;
priv->ndev = ndev; priv->ndev = ndev;
priv->pdev = pdev; priv->pdev = pdev;
priv->num_tx_ring[RAVB_BE] = BE_TX_RING_SIZE; priv->num_tx_ring[RAVB_BE] = BE_TX_RING_SIZE;
...@@ -2349,6 +2358,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -2349,6 +2358,7 @@ static int ravb_probe(struct platform_device *pdev)
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
reset_control_assert(rstc);
return error; return error;
} }
...@@ -2374,6 +2384,7 @@ static int ravb_remove(struct platform_device *pdev) ...@@ -2374,6 +2384,7 @@ static int ravb_remove(struct platform_device *pdev)
netif_napi_del(&priv->napi[RAVB_BE]); netif_napi_del(&priv->napi[RAVB_BE]);
ravb_mdio_release(priv); ravb_mdio_release(priv);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
reset_control_assert(priv->rstc);
free_netdev(ndev); free_netdev(ndev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
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