aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/freescale/fec_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/freescale/fec_main.c')
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index aff0310a778b..a667015be22a 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -87,6 +87,8 @@
87#define FEC_QUIRK_HAS_GBIT (1 << 3) 87#define FEC_QUIRK_HAS_GBIT (1 << 3)
88/* Controller has extend desc buffer */ 88/* Controller has extend desc buffer */
89#define FEC_QUIRK_HAS_BUFDESC_EX (1 << 4) 89#define FEC_QUIRK_HAS_BUFDESC_EX (1 << 4)
90/* Controller has hardware checksum support */
91#define FEC_QUIRK_HAS_CSUM (1 << 5)
90 92
91static struct platform_device_id fec_devtype[] = { 93static struct platform_device_id fec_devtype[] = {
92 { 94 {
@@ -105,9 +107,9 @@ static struct platform_device_id fec_devtype[] = {
105 }, { 107 }, {
106 .name = "imx6q-fec", 108 .name = "imx6q-fec",
107 .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT | 109 .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
108 FEC_QUIRK_HAS_BUFDESC_EX, 110 FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM,
109 }, { 111 }, {
110 .name = "mvf-fec", 112 .name = "mvf600-fec",
111 .driver_data = FEC_QUIRK_ENET_MAC, 113 .driver_data = FEC_QUIRK_ENET_MAC,
112 }, { 114 }, {
113 /* sentinel */ 115 /* sentinel */
@@ -120,7 +122,7 @@ enum imx_fec_type {
120 IMX27_FEC, /* runs on i.mx27/35/51 */ 122 IMX27_FEC, /* runs on i.mx27/35/51 */
121 IMX28_FEC, 123 IMX28_FEC,
122 IMX6Q_FEC, 124 IMX6Q_FEC,
123 MVF_FEC, 125 MVF600_FEC,
124}; 126};
125 127
126static const struct of_device_id fec_dt_ids[] = { 128static const struct of_device_id fec_dt_ids[] = {
@@ -128,7 +130,7 @@ static const struct of_device_id fec_dt_ids[] = {
128 { .compatible = "fsl,imx27-fec", .data = &fec_devtype[IMX27_FEC], }, 130 { .compatible = "fsl,imx27-fec", .data = &fec_devtype[IMX27_FEC], },
129 { .compatible = "fsl,imx28-fec", .data = &fec_devtype[IMX28_FEC], }, 131 { .compatible = "fsl,imx28-fec", .data = &fec_devtype[IMX28_FEC], },
130 { .compatible = "fsl,imx6q-fec", .data = &fec_devtype[IMX6Q_FEC], }, 132 { .compatible = "fsl,imx6q-fec", .data = &fec_devtype[IMX6Q_FEC], },
131 { .compatible = "fsl,mvf-fec", .data = &fec_devtype[MVF_FEC], }, 133 { .compatible = "fsl,mvf600-fec", .data = &fec_devtype[MVF600_FEC], },
132 { /* sentinel */ } 134 { /* sentinel */ }
133}; 135};
134MODULE_DEVICE_TABLE(of, fec_dt_ids); 136MODULE_DEVICE_TABLE(of, fec_dt_ids);
@@ -449,7 +451,7 @@ fec_restart(struct net_device *ndev, int duplex)
449 netif_device_detach(ndev); 451 netif_device_detach(ndev);
450 napi_disable(&fep->napi); 452 napi_disable(&fep->napi);
451 netif_stop_queue(ndev); 453 netif_stop_queue(ndev);
452 netif_tx_lock(ndev); 454 netif_tx_lock_bh(ndev);
453 } 455 }
454 456
455 /* Whack a reset. We should wait for this. */ 457 /* Whack a reset. We should wait for this. */
@@ -614,10 +616,10 @@ fec_restart(struct net_device *ndev, int duplex)
614 writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); 616 writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
615 617
616 if (netif_running(ndev)) { 618 if (netif_running(ndev)) {
617 netif_device_attach(ndev); 619 netif_tx_unlock_bh(ndev);
618 napi_enable(&fep->napi);
619 netif_wake_queue(ndev); 620 netif_wake_queue(ndev);
620 netif_tx_unlock(ndev); 621 napi_enable(&fep->napi);
622 netif_device_attach(ndev);
621 } 623 }
622} 624}
623 625
@@ -1036,6 +1038,18 @@ static void fec_get_mac(struct net_device *ndev)
1036 iap = &tmpaddr[0]; 1038 iap = &tmpaddr[0];
1037 } 1039 }
1038 1040
1041 /*
1042 * 5) random mac address
1043 */
1044 if (!is_valid_ether_addr(iap)) {
1045 /* Report it and use a random ethernet address instead */
1046 netdev_err(ndev, "Invalid MAC address: %pM\n", iap);
1047 eth_hw_addr_random(ndev);
1048 netdev_info(ndev, "Using random MAC address: %pM\n",
1049 ndev->dev_addr);
1050 return;
1051 }
1052
1039 memcpy(ndev->dev_addr, iap, ETH_ALEN); 1053 memcpy(ndev->dev_addr, iap, ETH_ALEN);
1040 1054
1041 /* Adjust MAC if using macaddr */ 1055 /* Adjust MAC if using macaddr */
@@ -1744,6 +1758,8 @@ static const struct net_device_ops fec_netdev_ops = {
1744static int fec_enet_init(struct net_device *ndev) 1758static int fec_enet_init(struct net_device *ndev)
1745{ 1759{
1746 struct fec_enet_private *fep = netdev_priv(ndev); 1760 struct fec_enet_private *fep = netdev_priv(ndev);
1761 const struct platform_device_id *id_entry =
1762 platform_get_device_id(fep->pdev);
1747 struct bufdesc *cbd_base; 1763 struct bufdesc *cbd_base;
1748 1764
1749 /* Allocate memory for buffer descriptors. */ 1765 /* Allocate memory for buffer descriptors. */
@@ -1775,12 +1791,14 @@ static int fec_enet_init(struct net_device *ndev)
1775 writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK); 1791 writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK);
1776 netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, FEC_NAPI_WEIGHT); 1792 netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, FEC_NAPI_WEIGHT);
1777 1793
1778 /* enable hw accelerator */ 1794 if (id_entry->driver_data & FEC_QUIRK_HAS_CSUM) {
1779 ndev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM 1795 /* enable hw accelerator */
1780 | NETIF_F_RXCSUM); 1796 ndev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM
1781 ndev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM 1797 | NETIF_F_RXCSUM);
1782 | NETIF_F_RXCSUM); 1798 ndev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM
1783 fep->csum_flags |= FLAG_RX_CSUM_ENABLED; 1799 | NETIF_F_RXCSUM);
1800 fep->csum_flags |= FLAG_RX_CSUM_ENABLED;
1801 }
1784 1802
1785 fec_restart(ndev, 0); 1803 fec_restart(ndev, 0);
1786 1804