Commit c3f4465d authored by Iyappan Subramanian's avatar Iyappan Subramanian Committed by David S. Miller

drivers: net: xgene: Backward compatibility with older firmware

This patch adds support when used with older firmware (<= 1.13.28).

- Added xgene_ring_mgr_init() to check whether ring manager is initialized
- Calling xgene_ring_mgr_init() from xgene_port_ops.reset()
- To handle errors, changed the return type of xgene_port_ops.reset()
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarKeyur Chudgar <kchudgar@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 09c9e059
...@@ -575,10 +575,24 @@ static void xgene_gmac_tx_disable(struct xgene_enet_pdata *pdata) ...@@ -575,10 +575,24 @@ static void xgene_gmac_tx_disable(struct xgene_enet_pdata *pdata)
xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN); xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN);
} }
static void xgene_enet_reset(struct xgene_enet_pdata *pdata) bool xgene_ring_mgr_init(struct xgene_enet_pdata *p)
{
if (!ioread32(p->ring_csr_addr + CLKEN_ADDR))
return false;
if (ioread32(p->ring_csr_addr + SRST_ADDR))
return false;
return true;
}
static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
{ {
u32 val; u32 val;
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
...@@ -590,6 +604,8 @@ static void xgene_enet_reset(struct xgene_enet_pdata *pdata) ...@@ -590,6 +604,8 @@ static void xgene_enet_reset(struct xgene_enet_pdata *pdata)
val |= SCAN_AUTO_INCR; val |= SCAN_AUTO_INCR;
MGMT_CLOCK_SEL_SET(&val, 1); MGMT_CLOCK_SEL_SET(&val, 1);
xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val); xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val);
return 0;
} }
static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata) static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
......
...@@ -104,6 +104,9 @@ enum xgene_enet_rm { ...@@ -104,6 +104,9 @@ enum xgene_enet_rm {
#define BLOCK_ETH_MAC_OFFSET 0x0000 #define BLOCK_ETH_MAC_OFFSET 0x0000
#define BLOCK_ETH_MAC_CSR_OFFSET 0x2800 #define BLOCK_ETH_MAC_CSR_OFFSET 0x2800
#define CLKEN_ADDR 0xc208
#define SRST_ADDR 0xc200
#define MAC_ADDR_REG_OFFSET 0x00 #define MAC_ADDR_REG_OFFSET 0x00
#define MAC_COMMAND_REG_OFFSET 0x04 #define MAC_COMMAND_REG_OFFSET 0x04
#define MAC_WRITE_REG_OFFSET 0x08 #define MAC_WRITE_REG_OFFSET 0x08
...@@ -318,6 +321,7 @@ void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring, ...@@ -318,6 +321,7 @@ void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata); int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata);
void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata); void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata);
bool xgene_ring_mgr_init(struct xgene_enet_pdata *p);
extern struct xgene_mac_ops xgene_gmac_ops; extern struct xgene_mac_ops xgene_gmac_ops;
extern struct xgene_port_ops xgene_gport_ops; extern struct xgene_port_ops xgene_gport_ops;
......
...@@ -852,7 +852,9 @@ static int xgene_enet_init_hw(struct xgene_enet_pdata *pdata) ...@@ -852,7 +852,9 @@ static int xgene_enet_init_hw(struct xgene_enet_pdata *pdata)
u16 dst_ring_num; u16 dst_ring_num;
int ret; int ret;
pdata->port_ops->reset(pdata); ret = pdata->port_ops->reset(pdata);
if (ret)
return ret;
ret = xgene_enet_create_desc_rings(ndev); ret = xgene_enet_create_desc_rings(ndev);
if (ret) { if (ret) {
...@@ -954,6 +956,7 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -954,6 +956,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
return ret; return ret;
err: err:
unregister_netdev(ndev);
free_netdev(ndev); free_netdev(ndev);
return ret; return ret;
} }
......
...@@ -83,7 +83,7 @@ struct xgene_mac_ops { ...@@ -83,7 +83,7 @@ struct xgene_mac_ops {
}; };
struct xgene_port_ops { struct xgene_port_ops {
void (*reset)(struct xgene_enet_pdata *pdata); int (*reset)(struct xgene_enet_pdata *pdata);
void (*cle_bypass)(struct xgene_enet_pdata *pdata, void (*cle_bypass)(struct xgene_enet_pdata *pdata,
u32 dst_ring_num, u16 bufpool_id); u32 dst_ring_num, u16 bufpool_id);
void (*shutdown)(struct xgene_enet_pdata *pdata); void (*shutdown)(struct xgene_enet_pdata *pdata);
......
...@@ -311,14 +311,19 @@ static void xgene_sgmac_tx_disable(struct xgene_enet_pdata *p) ...@@ -311,14 +311,19 @@ static void xgene_sgmac_tx_disable(struct xgene_enet_pdata *p)
xgene_sgmac_rxtx(p, TX_EN, false); xgene_sgmac_rxtx(p, TX_EN, false);
} }
static void xgene_enet_reset(struct xgene_enet_pdata *p) static int xgene_enet_reset(struct xgene_enet_pdata *p)
{ {
if (!xgene_ring_mgr_init(p))
return -ENODEV;
clk_prepare_enable(p->clk); clk_prepare_enable(p->clk);
clk_disable_unprepare(p->clk); clk_disable_unprepare(p->clk);
clk_prepare_enable(p->clk); clk_prepare_enable(p->clk);
xgene_enet_ecc_init(p); xgene_enet_ecc_init(p);
xgene_enet_config_ring_if_assoc(p); xgene_enet_config_ring_if_assoc(p);
return 0;
} }
static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p, static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p,
......
...@@ -252,14 +252,19 @@ static void xgene_xgmac_tx_disable(struct xgene_enet_pdata *pdata) ...@@ -252,14 +252,19 @@ static void xgene_xgmac_tx_disable(struct xgene_enet_pdata *pdata)
xgene_enet_wr_mac(pdata, AXGMAC_CONFIG_1, data & ~HSTTFEN); xgene_enet_wr_mac(pdata, AXGMAC_CONFIG_1, data & ~HSTTFEN);
} }
static void xgene_enet_reset(struct xgene_enet_pdata *pdata) static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
{ {
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
xgene_enet_ecc_init(pdata); xgene_enet_ecc_init(pdata);
xgene_enet_config_ring_if_assoc(pdata); xgene_enet_config_ring_if_assoc(pdata);
return 0;
} }
static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata, static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata,
......
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