@@ -1886,6 +1886,58 @@ static int ftgmac100_probe_ncsi(struct net_device *netdev,
18861886 return err ;
18871887}
18881888
1889+ static int ftgmac100_probe_dt (struct net_device * netdev ,
1890+ struct platform_device * pdev ,
1891+ struct ftgmac100 * priv ,
1892+ struct device_node * np )
1893+ {
1894+ struct phy_device * phy ;
1895+ int err ;
1896+
1897+ if (of_get_property (np , "use-ncsi" , NULL ))
1898+ return ftgmac100_probe_ncsi (netdev , priv , pdev );
1899+
1900+ if (of_phy_is_fixed_link (np ) ||
1901+ of_get_property (np , "phy-handle" , NULL )) {
1902+ /* Support "mdio"/"phy" child nodes for ast2400/2500
1903+ * with an embedded MDIO controller. Automatically
1904+ * scan the DTS for available PHYs and register
1905+ * them. 2600 has an independent MDIO controller, not
1906+ * part of the MAC.
1907+ */
1908+ phy = of_phy_get_and_connect (priv -> netdev , np ,
1909+ & ftgmac100_adjust_link );
1910+ if (!phy ) {
1911+ dev_err (& pdev -> dev , "Failed to connect to phy\n" );
1912+ return - EINVAL ;
1913+ }
1914+
1915+ /* Indicate that we support PAUSE frames (see comment in
1916+ * Documentation/networking/phy.rst)
1917+ */
1918+ phy_support_asym_pause (phy );
1919+
1920+ /* Display what we found */
1921+ phy_attached_info (phy );
1922+ return 0 ;
1923+ }
1924+
1925+ if (!ftgmac100_has_child_node (np , "mdio" )) {
1926+ /* Support legacy ASPEED devicetree descriptions that
1927+ * decribe a MAC with an embedded MDIO controller but
1928+ * have no "mdio" child node. Automatically scan the
1929+ * MDIO bus for available PHYs.
1930+ */
1931+ err = ftgmac100_mii_probe (netdev );
1932+ if (err ) {
1933+ dev_err (priv -> dev , "MII probe failed!\n" );
1934+ return err ;
1935+ }
1936+ }
1937+
1938+ return 0 ;
1939+ }
1940+
18891941static int ftgmac100_probe (struct platform_device * pdev )
18901942{
18911943 const struct ftgmac100_match_data * match_data ;
@@ -1981,41 +2033,10 @@ static int ftgmac100_probe(struct platform_device *pdev)
19812033 return err ;
19822034 }
19832035
1984- if (np && of_get_property ( np , "use-ncsi" , NULL ) ) {
1985- err = ftgmac100_probe_ncsi (netdev , priv , pdev );
2036+ if (np ) {
2037+ err = ftgmac100_probe_dt (netdev , pdev , priv , np );
19862038 if (err )
19872039 goto err ;
1988- } else if (np && (of_phy_is_fixed_link (np ) ||
1989- of_get_property (np , "phy-handle" , NULL ))) {
1990- struct phy_device * phy ;
1991-
1992- phy = of_phy_get_and_connect (priv -> netdev , np ,
1993- & ftgmac100_adjust_link );
1994- if (!phy ) {
1995- dev_err (& pdev -> dev , "Failed to connect to phy\n" );
1996- err = - EINVAL ;
1997- goto err ;
1998- }
1999-
2000- /* Indicate that we support PAUSE frames (see comment in
2001- * Documentation/networking/phy.rst)
2002- */
2003- phy_support_asym_pause (phy );
2004-
2005- /* Display what we found */
2006- phy_attached_info (phy );
2007- } else if (np && !ftgmac100_has_child_node (np , "mdio" )) {
2008- /* Support legacy ASPEED devicetree descriptions that decribe a
2009- * MAC with an embedded MDIO controller but have no "mdio"
2010- * child node. Automatically scan the MDIO bus for available
2011- * PHYs.
2012- */
2013- err = ftgmac100_mii_probe (netdev );
2014- if (err ) {
2015- dev_err (priv -> dev , "MII probe failed!\n" );
2016- goto err ;
2017- }
2018-
20192040 }
20202041
20212042 priv -> rst = devm_reset_control_get_optional_exclusive (priv -> dev , NULL );
0 commit comments