ar71xx: add kernel support for the TP-Link TL-WDR4900 v2.0 board
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / dev-eth.c
index 4a2b1db..21feeb9 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
 #include <linux/clk.h>
+#include <linux/sizes.h>
 
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
@@ -39,7 +40,7 @@ static struct resource ath79_mdio0_resources[] = {
        }
 };
 
-static struct ag71xx_mdio_platform_data ath79_mdio0_data;
+struct ag71xx_mdio_platform_data ath79_mdio0_data;
 
 struct platform_device ath79_mdio0_device = {
        .name           = "ag71xx-mdio",
@@ -60,7 +61,7 @@ static struct resource ath79_mdio1_resources[] = {
        }
 };
 
-static struct ag71xx_mdio_platform_data ath79_mdio1_data;
+struct ag71xx_mdio_platform_data ath79_mdio1_data;
 
 struct platform_device ath79_mdio1_device = {
        .name           = "ag71xx-mdio",
@@ -253,13 +254,8 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
                mdio_data->is_ar934x = 1;
                break;
 
-       case ATH79_SOC_QCA9558:
-               if (id == 1)
-                       mdio_data->builtin_switch = 1;
-               mdio_data->is_ar934x = 1;
-               break;
-
        case ATH79_SOC_QCA9556:
+       case ATH79_SOC_QCA9558:
                mdio_data->is_ar934x = 1;
                break;
 
@@ -786,6 +782,9 @@ void __init ath79_register_eth(unsigned int id)
 
        pdata = pdev->dev.platform_data;
 
+       pdata->max_frame_len = 1540;
+       pdata->desc_pktlen_mask = 0xfff;
+
        err = ath79_setup_phy_if_mode(id, pdata);
        if (err) {
                printk(KERN_ERR
@@ -955,6 +954,9 @@ void __init ath79_register_eth(unsigned int id)
                pdata->has_gbit = 1;
                pdata->is_ar724x = 1;
 
+               pdata->max_frame_len = SZ_16K - 1;
+               pdata->desc_pktlen_mask = SZ_16K - 1;
+
                if (!pdata->fifo_cfg1)
                        pdata->fifo_cfg1 = 0x0010ffff;
                if (!pdata->fifo_cfg2)
@@ -979,6 +981,17 @@ void __init ath79_register_eth(unsigned int id)
                pdata->has_gbit = 1;
                pdata->is_ar724x = 1;
 
+               /*
+                * Limit the maximum frame length to 4095 bytes.
+                * Although the documentation says that the hardware
+                * limit is 16383 bytes but that does not work in
+                * practice. It seems that the hardware only updates
+                * the lowest 12 bits of the packet length field
+                * in the RX descriptor.
+                */
+               pdata->max_frame_len = SZ_4K - 1;
+               pdata->desc_pktlen_mask = SZ_16K - 1;
+
                if (!pdata->fifo_cfg1)
                        pdata->fifo_cfg1 = 0x0010ffff;
                if (!pdata->fifo_cfg2)