aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMugunthan V N <mugunthanvnm@ti.com>2013-12-11 23:09:05 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-12 13:46:57 -0500
commitf280e89ad6a29d9969cb6b216123c798e1689bc4 (patch)
tree484f1d67dffdf05e99663930f634160ce7b98f5d
parentd9601a36ffdb5c142697bef1228afb5ba4ee4003 (diff)
drivers: net: cpsw: fix for cpsw crash when build as modules
When CPSW and Davinci MDIO are build as modules, CPSW crashes when accessing CPSW registers in CPSW probe. The same is working in built-in as the CPSW clocks are enabled in Davindi MDIO probe, SO Enabling the clocks before accessing the version register and moving out the other register access to cpsw device open. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/ti/cpsw.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index a91f0c9d4511..5120d9ce1dd4 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1151,6 +1151,12 @@ static int cpsw_ndo_open(struct net_device *ndev)
1151 * receive descs 1151 * receive descs
1152 */ 1152 */
1153 cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); 1153 cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i);
1154
1155 if (cpts_register(&priv->pdev->dev, priv->cpts,
1156 priv->data.cpts_clock_mult,
1157 priv->data.cpts_clock_shift))
1158 dev_err(priv->dev, "error registering cpts device\n");
1159
1154 } 1160 }
1155 1161
1156 /* Enable Interrupt pacing if configured */ 1162 /* Enable Interrupt pacing if configured */
@@ -1197,6 +1203,7 @@ static int cpsw_ndo_stop(struct net_device *ndev)
1197 netif_carrier_off(priv->ndev); 1203 netif_carrier_off(priv->ndev);
1198 1204
1199 if (cpsw_common_res_usage_state(priv) <= 1) { 1205 if (cpsw_common_res_usage_state(priv) <= 1) {
1206 cpts_unregister(priv->cpts);
1200 cpsw_intr_disable(priv); 1207 cpsw_intr_disable(priv);
1201 cpdma_ctlr_int_ctrl(priv->dma, false); 1208 cpdma_ctlr_int_ctrl(priv->dma, false);
1202 cpdma_ctlr_stop(priv->dma); 1209 cpdma_ctlr_stop(priv->dma);
@@ -1985,9 +1992,15 @@ static int cpsw_probe(struct platform_device *pdev)
1985 goto clean_runtime_disable_ret; 1992 goto clean_runtime_disable_ret;
1986 } 1993 }
1987 priv->regs = ss_regs; 1994 priv->regs = ss_regs;
1988 priv->version = __raw_readl(&priv->regs->id_ver);
1989 priv->host_port = HOST_PORT_NUM; 1995 priv->host_port = HOST_PORT_NUM;
1990 1996
1997 /* Need to enable clocks with runtime PM api to access module
1998 * registers
1999 */
2000 pm_runtime_get_sync(&pdev->dev);
2001 priv->version = readl(&priv->regs->id_ver);
2002 pm_runtime_put_sync(&pdev->dev);
2003
1991 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2004 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1992 priv->wr_regs = devm_ioremap_resource(&pdev->dev, res); 2005 priv->wr_regs = devm_ioremap_resource(&pdev->dev, res);
1993 if (IS_ERR(priv->wr_regs)) { 2006 if (IS_ERR(priv->wr_regs)) {
@@ -2157,8 +2170,6 @@ static int cpsw_remove(struct platform_device *pdev)
2157 unregister_netdev(cpsw_get_slave_ndev(priv, 1)); 2170 unregister_netdev(cpsw_get_slave_ndev(priv, 1));
2158 unregister_netdev(ndev); 2171 unregister_netdev(ndev);
2159 2172
2160 cpts_unregister(priv->cpts);
2161
2162 cpsw_ale_destroy(priv->ale); 2173 cpsw_ale_destroy(priv->ale);
2163 cpdma_chan_destroy(priv->txch); 2174 cpdma_chan_destroy(priv->txch);
2164 cpdma_chan_destroy(priv->rxch); 2175 cpdma_chan_destroy(priv->rxch);