Commit 1af3cb37 authored by Roger Quadros's avatar Roger Quadros Committed by David S. Miller

net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume

On low power during system suspend the ALE table context is lost.
Save the ALE contect before suspend and restore it after resume.
Signed-off-by: default avatarRoger Quadros <rogerq@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 643cf0e3
...@@ -2715,6 +2715,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) ...@@ -2715,6 +2715,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
struct clk *clk; struct clk *clk;
u64 id_temp; u64 id_temp;
int ret, i; int ret, i;
int ale_entries;
common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL); common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL);
if (!common) if (!common)
...@@ -2809,6 +2810,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) ...@@ -2809,6 +2810,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
goto err_of_clear; goto err_of_clear;
} }
ale_entries = common->ale->params.ale_entries;
common->ale_context = devm_kzalloc(dev,
ale_entries * ALE_ENTRY_WORDS * sizeof(u32),
GFP_KERNEL);
ret = am65_cpsw_init_cpts(common); ret = am65_cpsw_init_cpts(common);
if (ret) if (ret)
goto err_of_clear; goto err_of_clear;
...@@ -2879,6 +2884,7 @@ static int am65_cpsw_nuss_suspend(struct device *dev) ...@@ -2879,6 +2884,7 @@ static int am65_cpsw_nuss_suspend(struct device *dev)
int i, ret; int i, ret;
struct am65_cpsw_host *host_p = am65_common_get_host(common); struct am65_cpsw_host *host_p = am65_common_get_host(common);
cpsw_ale_dump(common->ale, common->ale_context);
host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET);
for (i = 0; i < common->port_num; i++) { for (i = 0; i < common->port_num; i++) {
port = &common->ports[i]; port = &common->ports[i];
...@@ -2937,6 +2943,7 @@ static int am65_cpsw_nuss_resume(struct device *dev) ...@@ -2937,6 +2943,7 @@ static int am65_cpsw_nuss_resume(struct device *dev)
} }
writel(host_p->vid_context, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); writel(host_p->vid_context, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET);
cpsw_ale_restore(common->ale, common->ale_context);
return 0; return 0;
} }
......
...@@ -149,6 +149,8 @@ struct am65_cpsw_common { ...@@ -149,6 +149,8 @@ struct am65_cpsw_common {
struct net_device *hw_bridge_dev; struct net_device *hw_bridge_dev;
struct notifier_block am65_cpsw_netdevice_nb; struct notifier_block am65_cpsw_netdevice_nb;
unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN]; unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN];
/* only for suspend/resume context restore */
u32 *ale_context;
}; };
struct am65_cpsw_ndev_stats { struct am65_cpsw_ndev_stats {
......
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