]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/net/dsa/mv88e6xxx/phy.c
net: dsa: mv88e6xxx: prefix PHY macros
[mirror_ubuntu-bionic-kernel.git] / drivers / net / dsa / mv88e6xxx / phy.c
index 0d3e8aaedf506eaad01813103e81419ac0dc1a77..3500ac0ea8489e3659dbe4eed36123de735bbd1e 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/module.h>
 #include <net/dsa.h>
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 #include "phy.h"
 
 int mv88e6165_phy_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
@@ -62,7 +62,7 @@ int mv88e6xxx_phy_write(struct mv88e6xxx_chip *chip, int phy, int reg, u16 val)
 
 static int mv88e6xxx_phy_page_get(struct mv88e6xxx_chip *chip, int phy, u8 page)
 {
-       return mv88e6xxx_phy_write(chip, phy, PHY_PAGE, page);
+       return mv88e6xxx_phy_write(chip, phy, MV88E6XXX_PHY_PAGE, page);
 }
 
 static void mv88e6xxx_phy_page_put(struct mv88e6xxx_chip *chip, int phy)
@@ -72,7 +72,8 @@ static void mv88e6xxx_phy_page_put(struct mv88e6xxx_chip *chip, int phy)
        /* Restore PHY page Copper 0x0 for access via the registered
         * MDIO bus
         */
-       err = mv88e6xxx_phy_write(chip, phy, PHY_PAGE, PHY_PAGE_COPPER);
+       err = mv88e6xxx_phy_write(chip, phy, MV88E6XXX_PHY_PAGE,
+                                 MV88E6XXX_PHY_PAGE_COPPER);
        if (unlikely(err)) {
                dev_err(chip->dev,
                        "failed to restore PHY %d page Copper (%d)\n",
@@ -86,7 +87,7 @@ int mv88e6xxx_phy_page_read(struct mv88e6xxx_chip *chip, int phy,
        int err;
 
        /* There is no paging for registers 22 */
-       if (reg == PHY_PAGE)
+       if (reg == MV88E6XXX_PHY_PAGE)
                return -EINVAL;
 
        err = mv88e6xxx_phy_page_get(chip, phy, page);
@@ -104,19 +105,19 @@ int mv88e6xxx_phy_page_write(struct mv88e6xxx_chip *chip, int phy,
        int err;
 
        /* There is no paging for registers 22 */
-       if (reg == PHY_PAGE)
+       if (reg == MV88E6XXX_PHY_PAGE)
                return -EINVAL;
 
        err = mv88e6xxx_phy_page_get(chip, phy, page);
        if (!err) {
-               err = mv88e6xxx_phy_write(chip, phy, PHY_PAGE, page);
+               err = mv88e6xxx_phy_write(chip, phy, MV88E6XXX_PHY_PAGE, page);
                mv88e6xxx_phy_page_put(chip, phy);
        }
 
        return err;
 }
 
-static int mv88e6xxx_ppu_disable(struct mv88e6xxx_chip *chip)
+static int mv88e6xxx_phy_ppu_disable(struct mv88e6xxx_chip *chip)
 {
        if (!chip->info->ops->ppu_disable)
                return 0;
@@ -124,7 +125,7 @@ static int mv88e6xxx_ppu_disable(struct mv88e6xxx_chip *chip)
        return chip->info->ops->ppu_disable(chip);
 }
 
-int mv88e6xxx_ppu_enable(struct mv88e6xxx_chip *chip)
+static int mv88e6xxx_phy_ppu_enable(struct mv88e6xxx_chip *chip)
 {
        if (!chip->info->ops->ppu_enable)
                return 0;
@@ -132,7 +133,7 @@ int mv88e6xxx_ppu_enable(struct mv88e6xxx_chip *chip)
        return chip->info->ops->ppu_enable(chip);
 }
 
-static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly)
+static void mv88e6xxx_phy_ppu_reenable_work(struct work_struct *ugly)
 {
        struct mv88e6xxx_chip *chip;
 
@@ -141,7 +142,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly)
        mutex_lock(&chip->reg_lock);
 
        if (mutex_trylock(&chip->ppu_mutex)) {
-               if (mv88e6xxx_ppu_enable(chip) == 0)
+               if (mv88e6xxx_phy_ppu_enable(chip) == 0)
                        chip->ppu_disabled = 0;
                mutex_unlock(&chip->ppu_mutex);
        }
@@ -149,14 +150,14 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly)
        mutex_unlock(&chip->reg_lock);
 }
 
-static void mv88e6xxx_ppu_reenable_timer(unsigned long _ps)
+static void mv88e6xxx_phy_ppu_reenable_timer(unsigned long _ps)
 {
        struct mv88e6xxx_chip *chip = (void *)_ps;
 
        schedule_work(&chip->ppu_work);
 }
 
-static int mv88e6xxx_ppu_access_get(struct mv88e6xxx_chip *chip)
+static int mv88e6xxx_phy_ppu_access_get(struct mv88e6xxx_chip *chip)
 {
        int ret;
 
@@ -168,7 +169,7 @@ static int mv88e6xxx_ppu_access_get(struct mv88e6xxx_chip *chip)
         * it.
         */
        if (!chip->ppu_disabled) {
-               ret = mv88e6xxx_ppu_disable(chip);
+               ret = mv88e6xxx_phy_ppu_disable(chip);
                if (ret < 0) {
                        mutex_unlock(&chip->ppu_mutex);
                        return ret;
@@ -182,49 +183,49 @@ static int mv88e6xxx_ppu_access_get(struct mv88e6xxx_chip *chip)
        return ret;
 }
 
-static void mv88e6xxx_ppu_access_put(struct mv88e6xxx_chip *chip)
+static void mv88e6xxx_phy_ppu_access_put(struct mv88e6xxx_chip *chip)
 {
        /* Schedule a timer to re-enable the PHY polling unit. */
        mod_timer(&chip->ppu_timer, jiffies + msecs_to_jiffies(10));
        mutex_unlock(&chip->ppu_mutex);
 }
 
-static void mv88e6xxx_ppu_state_init(struct mv88e6xxx_chip *chip)
+static void mv88e6xxx_phy_ppu_state_init(struct mv88e6xxx_chip *chip)
 {
        mutex_init(&chip->ppu_mutex);
-       INIT_WORK(&chip->ppu_work, mv88e6xxx_ppu_reenable_work);
-       setup_timer(&chip->ppu_timer, mv88e6xxx_ppu_reenable_timer,
+       INIT_WORK(&chip->ppu_work, mv88e6xxx_phy_ppu_reenable_work);
+       setup_timer(&chip->ppu_timer, mv88e6xxx_phy_ppu_reenable_timer,
                    (unsigned long)chip);
 }
 
-static void mv88e6xxx_ppu_state_destroy(struct mv88e6xxx_chip *chip)
+static void mv88e6xxx_phy_ppu_state_destroy(struct mv88e6xxx_chip *chip)
 {
        del_timer_sync(&chip->ppu_timer);
 }
 
-int mv88e6xxx_phy_ppu_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
+int mv88e6185_phy_ppu_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
                           int addr, int reg, u16 *val)
 {
        int err;
 
-       err = mv88e6xxx_ppu_access_get(chip);
+       err = mv88e6xxx_phy_ppu_access_get(chip);
        if (!err) {
                err = mv88e6xxx_read(chip, addr, reg, val);
-               mv88e6xxx_ppu_access_put(chip);
+               mv88e6xxx_phy_ppu_access_put(chip);
        }
 
        return err;
 }
 
-int mv88e6xxx_phy_ppu_write(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
+int mv88e6185_phy_ppu_write(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
                            int addr, int reg, u16 val)
 {
        int err;
 
-       err = mv88e6xxx_ppu_access_get(chip);
+       err = mv88e6xxx_phy_ppu_access_get(chip);
        if (!err) {
                err = mv88e6xxx_write(chip, addr, reg, val);
-               mv88e6xxx_ppu_access_put(chip);
+               mv88e6xxx_phy_ppu_access_put(chip);
        }
 
        return err;
@@ -233,11 +234,16 @@ int mv88e6xxx_phy_ppu_write(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
 void mv88e6xxx_phy_init(struct mv88e6xxx_chip *chip)
 {
        if (chip->info->ops->ppu_enable && chip->info->ops->ppu_disable)
-               mv88e6xxx_ppu_state_init(chip);
+               mv88e6xxx_phy_ppu_state_init(chip);
 }
 
 void mv88e6xxx_phy_destroy(struct mv88e6xxx_chip *chip)
 {
        if (chip->info->ops->ppu_enable && chip->info->ops->ppu_disable)
-               mv88e6xxx_ppu_state_destroy(chip);
+               mv88e6xxx_phy_ppu_state_destroy(chip);
+}
+
+int mv88e6xxx_phy_setup(struct mv88e6xxx_chip *chip)
+{
+       return mv88e6xxx_phy_ppu_enable(chip);
 }