]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
net: tsec: Use priv->tbiaddr to initialize TBI PHY address
authorBin Meng <bmeng.cn@gmail.com>
Tue, 12 Jan 2016 06:41:25 +0000 (22:41 -0800)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 28 Jan 2016 18:23:19 +0000 (12:23 -0600)
Add a new member 'tbiaddr' to tsec_private struct. For non-DM driver,
it is initialized as CONFIG_SYS_TBIPA_VALUE, but for DM driver, we
can get this from device tree. Update the bindings doc as well.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
doc/device-tree-bindings/net/fsl-tsec-phy.txt
drivers/net/tsec.c
include/tsec.h

index dbe91aa161bf8b17967f1d5a997d4988daa48ddd..c5bf48c3cb51a4307d506a870e053056bee95778 100644 (file)
@@ -41,3 +41,24 @@ Example:
                        reg = <0>;
                };
        };
+
+* TBI Internal MDIO bus
+
+As of this writing, every tsec is associated with an internal TBI PHY.
+This PHY is accessed through the local MDIO bus.  These buses are defined
+similarly to the mdio buses.  The TBI PHYs underneath them are similar to
+normal PHYs, but the reg property is considered instructive, rather than
+descriptive.  The reg property should be chosen so it doesn't interfere
+with other PHYs on the bus.  The TBI PHYs are referred to by a "tbi-handle"
+property under the tsec node, which has a similar meaning of "phy-handle".
+
+Example:
+       ethernet@24000 {
+               phy-handle = <&tbi1>;
+       };
+
+       mdio@24520 {
+               tbi1: tbi-phy@1f {
+                       reg = <0x1f>;
+               };
+       };
index 18b44f6542fd5e09e92331c289150bcee618bcff..025e7a76f1262876d8aec7819e6a62831a51f31c 100644 (file)
@@ -658,7 +658,7 @@ static int init_phy(struct tsec_private *priv)
                supported |= SUPPORTED_1000baseT_Full;
 
        /* Assign a Physical address to the TBI */
-       out_be32(&regs->tbipa, CONFIG_SYS_TBIPA_VALUE);
+       out_be32(&regs->tbipa, priv->tbiaddr);
 
        priv->interface = tsec_get_interface(priv);
 
@@ -707,6 +707,7 @@ static int tsec_initialize(bd_t *bis, struct tsec_info_struct *tsec_info)
        priv->phyregs_sgmii = tsec_info->miiregs_sgmii;
 
        priv->phyaddr = tsec_info->phyaddr;
+       priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE;
        priv->flags = tsec_info->flags;
 
        sprintf(dev->name, tsec_info->devname);
@@ -801,6 +802,16 @@ int tsec_probe(struct udevice *dev)
                return -ENOENT;
        }
 
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+                                      "tbi-handle");
+       if (offset > 0) {
+               reg = fdtdec_get_int(gd->fdt_blob, offset, "reg",
+                                    CONFIG_SYS_TBIPA_VALUE);
+               priv->tbiaddr = reg;
+       } else {
+               priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE;
+       }
+
        phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset,
                               "phy-connection-type", NULL);
        if (phy_mode)
index 88ce964fd910526d30049c3876fd5efdfdd8c5c1..fb27edf2250d5e40e402fbae58c9629f3fc776d5 100644 (file)
@@ -402,6 +402,7 @@ struct tsec_private {
        phy_interface_t interface;
        struct mii_dev *bus;
        uint phyaddr;
+       uint tbiaddr;
        char mii_devname[16];
        u32 flags;
        uint rx_idx;    /* index of the current RX buffer */