aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorAndreas Oetken <ennoerlangen@gmail.com>2015-04-25 12:07:52 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-26 16:07:14 -0400
commit7cdbc6f74f8e6c06304b69b4e944fbd669581c7c (patch)
treea58f1fe5a18ecf52b7395b4ad38c4ad6fd74661f /drivers/net
parent0e03fd3e335d272bee88fe733d5fd13f5c5b7140 (diff)
altera tse: add support for fixed-links.
Add support for fixed-links in configurations without PHY. (e.g. connection to a switch, SGMII point to point, SFPs) Check: Documentation/devicetree/bindings/net/fixed-link.txt. Signed-off-by: Andreas Oetken <ennoerlangen@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/altera/altera_tse_main.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 90a76306ad0f..0533c051a3e5 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -777,6 +777,8 @@ static int init_phy(struct net_device *dev)
777 struct altera_tse_private *priv = netdev_priv(dev); 777 struct altera_tse_private *priv = netdev_priv(dev);
778 struct phy_device *phydev; 778 struct phy_device *phydev;
779 struct device_node *phynode; 779 struct device_node *phynode;
780 bool fixed_link = false;
781 int rc = 0;
780 782
781 /* Avoid init phy in case of no phy present */ 783 /* Avoid init phy in case of no phy present */
782 if (!priv->phy_iface) 784 if (!priv->phy_iface)
@@ -789,13 +791,32 @@ static int init_phy(struct net_device *dev)
789 phynode = of_parse_phandle(priv->device->of_node, "phy-handle", 0); 791 phynode = of_parse_phandle(priv->device->of_node, "phy-handle", 0);
790 792
791 if (!phynode) { 793 if (!phynode) {
792 netdev_dbg(dev, "no phy-handle found\n"); 794 /* check if a fixed-link is defined in device-tree */
793 if (!priv->mdio) { 795 if (of_phy_is_fixed_link(priv->device->of_node)) {
794 netdev_err(dev, 796 rc = of_phy_register_fixed_link(priv->device->of_node);
795 "No phy-handle nor local mdio specified\n"); 797 if (rc < 0) {
796 return -ENODEV; 798 netdev_err(dev, "cannot register fixed PHY\n");
799 return rc;
800 }
801
802 /* In the case of a fixed PHY, the DT node associated
803 * to the PHY is the Ethernet MAC DT node.
804 */
805 phynode = of_node_get(priv->device->of_node);
806 fixed_link = true;
807
808 netdev_dbg(dev, "fixed-link detected\n");
809 phydev = of_phy_connect(dev, phynode,
810 &altera_tse_adjust_link,
811 0, priv->phy_iface);
812 } else {
813 netdev_dbg(dev, "no phy-handle found\n");
814 if (!priv->mdio) {
815 netdev_err(dev, "No phy-handle nor local mdio specified\n");
816 return -ENODEV;
817 }
818 phydev = connect_local_phy(dev);
797 } 819 }
798 phydev = connect_local_phy(dev);
799 } else { 820 } else {
800 netdev_dbg(dev, "phy-handle found\n"); 821 netdev_dbg(dev, "phy-handle found\n");
801 phydev = of_phy_connect(dev, phynode, 822 phydev = of_phy_connect(dev, phynode,
@@ -819,10 +840,10 @@ static int init_phy(struct net_device *dev)
819 /* Broken HW is sometimes missing the pull-up resistor on the 840 /* Broken HW is sometimes missing the pull-up resistor on the
820 * MDIO line, which results in reads to non-existent devices returning 841 * MDIO line, which results in reads to non-existent devices returning
821 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent 842 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
822 * device as well. 843 * device as well. If a fixed-link is used the phy_id is always 0.
823 * Note: phydev->phy_id is the result of reading the UID PHY registers. 844 * Note: phydev->phy_id is the result of reading the UID PHY registers.
824 */ 845 */
825 if (phydev->phy_id == 0) { 846 if ((phydev->phy_id == 0) && !fixed_link) {
826 netdev_err(dev, "Bad PHY UID 0x%08x\n", phydev->phy_id); 847 netdev_err(dev, "Bad PHY UID 0x%08x\n", phydev->phy_id);
827 phy_disconnect(phydev); 848 phy_disconnect(phydev);
828 return -ENODEV; 849 return -ENODEV;