Rename CONFIG_EHCI_IS_TDI to CONFIG_USB_EHCI_IS_TDI
[platform/kernel/u-boot.git] / include / phy.h
index 34c2af7..c66fd43 100644 (file)
@@ -9,14 +9,17 @@
 #ifndef _PHY_H
 #define _PHY_H
 
-#include <dm.h>
+#include <log.h>
+#include <phy_interface.h>
+#include <dm/ofnode.h>
+#include <dm/read.h>
 #include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/mdio.h>
-#include <log.h>
-#include <phy_interface.h>
+
+struct udevice;
 
 #define PHY_FIXED_ID           0xa5a55a5a
 #define PHY_NCSI_ID            0xbeefcafe
                                 PHY_100BT_FEATURES | \
                                 PHY_DEFAULT_FEATURES)
 
+#define PHY_100BT1_FEATURES    (SUPPORTED_TP | \
+                                SUPPORTED_MII | \
+                                SUPPORTED_100baseT_Full)
+
 #define PHY_GBIT_FEATURES      (PHY_BASIC_FEATURES | \
                                 PHY_1000BT_FEATURES)
 
@@ -202,7 +209,7 @@ static inline int phy_write(struct phy_device *phydev, int devad, int regnum,
 {
        struct mii_dev *bus = phydev->bus;
 
-       if (!bus || !bus->read) {
+       if (!bus || !bus->write) {
                debug("%s: No bus configured\n", __func__);
                return -1;
        }
@@ -296,6 +303,60 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
        return phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, val);
 }
 
+/**
+ * phy_set_bits_mmd - Convenience function for setting bits in a register
+ * on MMD
+ * @phydev: the phy_device struct
+ * @devad: the MMD containing register to modify
+ * @regnum: register number to modify
+ * @val: bits to set
+ * @return: 0 for success or negative errno for failure
+ */
+static inline int phy_set_bits_mmd(struct phy_device *phydev, int devad,
+                                  u32 regnum, u16 val)
+{
+       int value, ret;
+
+       value = phy_read_mmd(phydev, devad, regnum);
+       if (value < 0)
+               return value;
+
+       value |= val;
+
+       ret = phy_write_mmd(phydev, devad, regnum, value);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+/**
+ * phy_clear_bits_mmd - Convenience function for clearing bits in a register
+ * on MMD
+ * @phydev: the phy_device struct
+ * @devad: the MMD containing register to modify
+ * @regnum: register number to modify
+ * @val: bits to clear
+ * @return: 0 for success or negative errno for failure
+ */
+static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad,
+                                    u32 regnum, u16 val)
+{
+       int value, ret;
+
+       value = phy_read_mmd(phydev, devad, regnum);
+       if (value < 0)
+               return value;
+
+       value &= ~val;
+
+       ret = phy_write_mmd(phydev, devad, regnum, value);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
 #ifdef CONFIG_PHYLIB_10G
 extern struct phy_driver gen10g_driver;
 
@@ -307,7 +368,7 @@ static inline int is_10g_interface(phy_interface_t interface)
 {
        return interface == PHY_INTERFACE_MODE_XGMII ||
               interface == PHY_INTERFACE_MODE_USXGMII ||
-              interface == PHY_INTERFACE_MODE_XFI;
+              interface == PHY_INTERFACE_MODE_10GBASER;
 }
 
 #endif
@@ -345,6 +406,27 @@ int phy_reset(struct phy_device *phydev);
 struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
                phy_interface_t interface);
 
+#ifdef CONFIG_PHY_FIXED
+
+/**
+ * fixed_phy_create() - create an unconnected fixed-link pseudo-PHY device
+ * @node: OF node for the container of the fixed-link node
+ *
+ * Description: Creates a struct phy_device based on a fixed-link of_node
+ * description. Can be used without phy_connect by drivers which do not expose
+ * a UCLASS_ETH udevice.
+ */
+struct phy_device *fixed_phy_create(ofnode node);
+
+#else
+
+static inline struct phy_device *fixed_phy_create(ofnode node)
+{
+       return NULL;
+}
+
+#endif
+
 #ifdef CONFIG_DM_ETH
 
 /**
@@ -436,6 +518,7 @@ int phy_aquantia_init(void);
 int phy_atheros_init(void);
 int phy_broadcom_init(void);
 int phy_cortina_init(void);
+int phy_cortina_access_init(void);
 int phy_davicom_init(void);
 int phy_et1011c_init(void);
 int phy_lxt_init(void);
@@ -444,6 +527,7 @@ int phy_micrel_ksz8xxx_init(void);
 int phy_micrel_ksz90x1_init(void);
 int phy_meson_gxl_init(void);
 int phy_natsemi_init(void);
+int phy_nxp_tja11xx_init(void);
 int phy_realtek_init(void);
 int phy_smsc_init(void);
 int phy_teranetics_init(void);
@@ -491,8 +575,8 @@ static inline bool phy_interface_is_sgmii(struct phy_device *phydev)
 }
 
 /* PHY UIDs for various PHYs that are referenced in external code */
-#define PHY_UID_CS4340         0x13e51002
-#define PHY_UID_CS4223         0x03e57003
+#define PHY_UID_CS4340         0x13e51002
+#define PHY_UID_CS4223         0x03e57003
 #define PHY_UID_TN2020         0x00a19410
 #define PHY_UID_IN112525_S03   0x02107440