aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ti
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2016-08-09 19:22:41 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-10 20:27:40 -0400
commite38b5a3db84c75c418d8c08863e005bda077f382 (patch)
tree09108c15e1002e12003e520e6e267da062f7cebe /drivers/net/ethernet/ti
parent2c836bd9a247132ff478857ec7b41a740df5ab64 (diff)
net; ethernet: ti: cpsw: move irq stuff under cpsw_common
The irq data are common for net devs in dual_emac mode. So no need to hold these data in every priv struct, move them under cpsw_common. Also delete irq_num var, as after optimization it's not needed. Correct number of irqs to 2, as anyway, driver is using only 2, at least for now. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r--drivers/net/ethernet/ti/cpsw.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 6d99d1e614f5..b2482b668044 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -143,6 +143,7 @@ do { \
143#define cpsw_slave_index(priv) \ 143#define cpsw_slave_index(priv) \
144 ((priv->data.dual_emac) ? priv->emac_port : \ 144 ((priv->data.dual_emac) ? priv->emac_port : \
145 priv->data.active_slave) 145 priv->data.active_slave)
146#define IRQ_NUM 2
146 147
147static int debug_level; 148static int debug_level;
148module_param(debug_level, int, 0); 149module_param(debug_level, int, 0);
@@ -371,6 +372,10 @@ struct cpsw_common {
371 struct cpsw_host_regs __iomem *host_port_regs; 372 struct cpsw_host_regs __iomem *host_port_regs;
372 struct cpdma_ctlr *dma; 373 struct cpdma_ctlr *dma;
373 struct cpdma_chan *txch, *rxch; 374 struct cpdma_chan *txch, *rxch;
375 bool quirk_irq;
376 bool rx_irq_disabled;
377 bool tx_irq_disabled;
378 u32 irqs_table[IRQ_NUM];
374}; 379};
375 380
376struct cpsw_priv { 381struct cpsw_priv {
@@ -389,12 +394,6 @@ struct cpsw_priv {
389 struct cpsw_ale *ale; 394 struct cpsw_ale *ale;
390 bool rx_pause; 395 bool rx_pause;
391 bool tx_pause; 396 bool tx_pause;
392 bool quirk_irq;
393 bool rx_irq_disabled;
394 bool tx_irq_disabled;
395 /* snapshot of IRQ numbers */
396 u32 irqs_table[4];
397 u32 num_irqs;
398 struct cpts *cpts; 397 struct cpts *cpts;
399 u32 emac_port; 398 u32 emac_port;
400 struct cpsw_common *cpsw; 399 struct cpsw_common *cpsw;
@@ -756,9 +755,9 @@ static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
756 writel(0, &cpsw->wr_regs->tx_en); 755 writel(0, &cpsw->wr_regs->tx_en);
757 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_TX); 756 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_TX);
758 757
759 if (priv->quirk_irq) { 758 if (cpsw->quirk_irq) {
760 disable_irq_nosync(priv->irqs_table[1]); 759 disable_irq_nosync(cpsw->irqs_table[1]);
761 priv->tx_irq_disabled = true; 760 cpsw->tx_irq_disabled = true;
762 } 761 }
763 762
764 napi_schedule(&priv->napi_tx); 763 napi_schedule(&priv->napi_tx);
@@ -773,9 +772,9 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
773 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_RX); 772 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_RX);
774 writel(0, &cpsw->wr_regs->rx_en); 773 writel(0, &cpsw->wr_regs->rx_en);
775 774
776 if (priv->quirk_irq) { 775 if (cpsw->quirk_irq) {
777 disable_irq_nosync(priv->irqs_table[0]); 776 disable_irq_nosync(cpsw->irqs_table[0]);
778 priv->rx_irq_disabled = true; 777 cpsw->rx_irq_disabled = true;
779 } 778 }
780 779
781 napi_schedule(&priv->napi_rx); 780 napi_schedule(&priv->napi_rx);
@@ -792,9 +791,9 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget)
792 if (num_tx < budget) { 791 if (num_tx < budget) {
793 napi_complete(napi_tx); 792 napi_complete(napi_tx);
794 writel(0xff, &cpsw->wr_regs->tx_en); 793 writel(0xff, &cpsw->wr_regs->tx_en);
795 if (priv->quirk_irq && priv->tx_irq_disabled) { 794 if (cpsw->quirk_irq && cpsw->tx_irq_disabled) {
796 priv->tx_irq_disabled = false; 795 cpsw->tx_irq_disabled = false;
797 enable_irq(priv->irqs_table[1]); 796 enable_irq(cpsw->irqs_table[1]);
798 } 797 }
799 } 798 }
800 799
@@ -811,9 +810,9 @@ static int cpsw_rx_poll(struct napi_struct *napi_rx, int budget)
811 if (num_rx < budget) { 810 if (num_rx < budget) {
812 napi_complete(napi_rx); 811 napi_complete(napi_rx);
813 writel(0xff, &cpsw->wr_regs->rx_en); 812 writel(0xff, &cpsw->wr_regs->rx_en);
814 if (priv->quirk_irq && priv->rx_irq_disabled) { 813 if (cpsw->quirk_irq && cpsw->rx_irq_disabled) {
815 priv->rx_irq_disabled = false; 814 cpsw->rx_irq_disabled = false;
816 enable_irq(priv->irqs_table[0]); 815 enable_irq(cpsw->irqs_table[0]);
817 } 816 }
818 } 817 }
819 818
@@ -1299,14 +1298,14 @@ static int cpsw_ndo_open(struct net_device *ndev)
1299 napi_enable(&priv_sl0->napi_rx); 1298 napi_enable(&priv_sl0->napi_rx);
1300 napi_enable(&priv_sl0->napi_tx); 1299 napi_enable(&priv_sl0->napi_tx);
1301 1300
1302 if (priv_sl0->tx_irq_disabled) { 1301 if (cpsw->tx_irq_disabled) {
1303 priv_sl0->tx_irq_disabled = false; 1302 cpsw->tx_irq_disabled = false;
1304 enable_irq(priv->irqs_table[1]); 1303 enable_irq(cpsw->irqs_table[1]);
1305 } 1304 }
1306 1305
1307 if (priv_sl0->rx_irq_disabled) { 1306 if (cpsw->rx_irq_disabled) {
1308 priv_sl0->rx_irq_disabled = false; 1307 cpsw->rx_irq_disabled = false;
1309 enable_irq(priv->irqs_table[0]); 1308 enable_irq(cpsw->irqs_table[0]);
1310 } 1309 }
1311 1310
1312 buf_num = cpdma_chan_get_rx_buf_num(cpsw->dma); 1311 buf_num = cpdma_chan_get_rx_buf_num(cpsw->dma);
@@ -1655,8 +1654,8 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
1655 struct cpsw_common *cpsw = priv->cpsw; 1654 struct cpsw_common *cpsw = priv->cpsw;
1656 1655
1657 cpsw_intr_disable(priv->cpsw); 1656 cpsw_intr_disable(priv->cpsw);
1658 cpsw_rx_interrupt(priv->irqs_table[0], priv); 1657 cpsw_rx_interrupt(cpsw->irqs_table[0], priv);
1659 cpsw_tx_interrupt(priv->irqs_table[1], priv); 1658 cpsw_tx_interrupt(cpsw->irqs_table[1], priv);
1660 cpsw_intr_enable(priv->cpsw); 1659 cpsw_intr_enable(priv->cpsw);
1661} 1660}
1662#endif 1661#endif
@@ -2173,7 +2172,7 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv)
2173 struct cpsw_platform_data *data = &priv->data; 2172 struct cpsw_platform_data *data = &priv->data;
2174 struct net_device *ndev; 2173 struct net_device *ndev;
2175 struct cpsw_priv *priv_sl2; 2174 struct cpsw_priv *priv_sl2;
2176 int ret = 0, i; 2175 int ret = 0;
2177 struct cpsw_common *cpsw = priv->cpsw; 2176 struct cpsw_common *cpsw = priv->cpsw;
2178 2177
2179 ndev = alloc_etherdev(sizeof(struct cpsw_priv)); 2178 ndev = alloc_etherdev(sizeof(struct cpsw_priv));
@@ -2210,11 +2209,6 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv)
2210 priv->slaves[1].ndev = ndev; 2209 priv->slaves[1].ndev = ndev;
2211 priv_sl2->cpts = priv->cpts; 2210 priv_sl2->cpts = priv->cpts;
2212 priv_sl2->version = priv->version; 2211 priv_sl2->version = priv->version;
2213
2214 for (i = 0; i < priv->num_irqs; i++) {
2215 priv_sl2->irqs_table[i] = priv->irqs_table[i];
2216 priv_sl2->num_irqs = priv->num_irqs;
2217 }
2218 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 2212 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
2219 2213
2220 ndev->netdev_ops = &cpsw_netdev_ops; 2214 ndev->netdev_ops = &cpsw_netdev_ops;
@@ -2489,7 +2483,7 @@ static int cpsw_probe(struct platform_device *pdev)
2489 if (of_id) { 2483 if (of_id) {
2490 pdev->id_entry = of_id->data; 2484 pdev->id_entry = of_id->data;
2491 if (pdev->id_entry->driver_data) 2485 if (pdev->id_entry->driver_data)
2492 priv->quirk_irq = true; 2486 cpsw->quirk_irq = true;
2493 } 2487 }
2494 2488
2495 /* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and 2489 /* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and
@@ -2507,7 +2501,7 @@ static int cpsw_probe(struct platform_device *pdev)
2507 goto clean_ale_ret; 2501 goto clean_ale_ret;
2508 } 2502 }
2509 2503
2510 priv->irqs_table[0] = irq; 2504 cpsw->irqs_table[0] = irq;
2511 ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt, 2505 ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt,
2512 0, dev_name(&pdev->dev), priv); 2506 0, dev_name(&pdev->dev), priv);
2513 if (ret < 0) { 2507 if (ret < 0) {
@@ -2522,14 +2516,13 @@ static int cpsw_probe(struct platform_device *pdev)
2522 goto clean_ale_ret; 2516 goto clean_ale_ret;
2523 } 2517 }
2524 2518
2525 priv->irqs_table[1] = irq; 2519 cpsw->irqs_table[1] = irq;
2526 ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt, 2520 ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt,
2527 0, dev_name(&pdev->dev), priv); 2521 0, dev_name(&pdev->dev), priv);
2528 if (ret < 0) { 2522 if (ret < 0) {
2529 dev_err(priv->dev, "error attaching irq (%d)\n", ret); 2523 dev_err(priv->dev, "error attaching irq (%d)\n", ret);
2530 goto clean_ale_ret; 2524 goto clean_ale_ret;
2531 } 2525 }
2532 priv->num_irqs = 2;
2533 2526
2534 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 2527 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
2535 2528