ath79: ag71xx: Split gmac config into separated file and add support for ar934x/qca955x.
[openwrt/staging/ynezz.git] / target / linux / ath79 / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_main.c
index 4a966fce9e125a38269daad5ed308f29e05b2aec..acc0f089d033be8b7b06cb709800142101bcf6c5 100644 (file)
@@ -618,16 +618,15 @@ __ag71xx_link_adjust(struct ag71xx *ag, bool update)
        ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, ag->fifodata[2]);
 
        if (update) {
-               if (of_device_is_compatible(np, "qca,ar7100-eth")) {
+               if (of_device_is_compatible(np, "qca,ar7100-eth") ||
+                   of_device_is_compatible(np, "qca,ar9130-eth")) {
                        ath79_set_pll(ag);
                        ath79_mii_ctrl_set_speed(ag);
-               } else if (of_device_is_compatible(np, "qca,ar7242-eth")) {
-                       ath79_set_pll(ag);
-               } else if (of_device_is_compatible(np, "qca,ar9130-eth")) {
-               } else if (of_device_is_compatible(np, "qca,ar9340-eth")) {
-                       ath79_set_pll(ag);
-               } else if (of_device_is_compatible(np, "qca,qca9550-eth")) {
-               } else if (of_device_is_compatible(np, "qca,qca9560-eth")) {
+               } else if (of_device_is_compatible(np, "qca,ar7242-eth") ||
+                          of_device_is_compatible(np, "qca,ar9340-eth") ||
+                          of_device_is_compatible(np, "qca,qca9550-eth") ||
+                          of_device_is_compatible(np, "qca,qca9560-eth")) {
+                       ath79_set_pllval(ag);
                }
        }
 
@@ -635,7 +634,8 @@ __ag71xx_link_adjust(struct ag71xx *ag, bool update)
        ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
        ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
 
-       if (of_device_is_compatible(np, "qca,qca9530-eth")) {
+       if (of_device_is_compatible(np, "qca,qca9530-eth") ||
+           of_device_is_compatible(np, "qca,qca9560-eth")) {
                /*
                 * The rx ring buffer can stall on small packets on QCA953x and
                 * QCA956x. Disabling the inline checksum engine fixes the stall.
@@ -1271,64 +1271,6 @@ static const char *ag71xx_get_phy_if_mode_name(phy_interface_t mode)
        return "unknown";
 }
 
-static void ag71xx_of_bit(struct device_node *np, const char *prop,
-                         u32 *reg, u32 mask)
-{
-       u32 val;
-
-       if (of_property_read_u32(np, prop, &val))
-               return;
-
-       if (val)
-               *reg |= mask;
-       else
-               *reg &= ~mask;
-}
-
-static void ag71xx_setup_gmac_933x(struct device_node *np, void __iomem *base)
-{
-       u32 val = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
-
-       ag71xx_of_bit(np, "switch-phy-swap", &val, AR933X_ETH_CFG_SW_PHY_SWAP);
-       ag71xx_of_bit(np, "switch-phy-addr-swap", &val,
-                     AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
-
-       __raw_writel(val, base + AR933X_GMAC_REG_ETH_CFG);
-}
-
-static int ag71xx_setup_gmac(struct device_node *np)
-{
-       struct device_node *np_dev;
-       void __iomem *base;
-       int err = 0;
-
-       np = of_get_child_by_name(np, "gmac-config");
-       if (!np)
-               return 0;
-
-       np_dev = of_parse_phandle(np, "device", 0);
-       if (!np_dev)
-               goto out;
-
-       base = of_iomap(np_dev, 0);
-       if (!base) {
-               pr_err("%pOF: can't map GMAC registers\n", np_dev);
-               err = -ENOMEM;
-               goto err_iomap;
-       }
-
-       if (of_device_is_compatible(np_dev, "qca,ar9330-gmac"))
-               ag71xx_setup_gmac_933x(np, base);
-
-       iounmap(base);
-
-err_iomap:
-       of_node_put(np_dev);
-out:
-       of_node_put(np);
-       return err;
-}
-
 static int ag71xx_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;