71e1a398aec94b6bc9d08c909a7d5cc2fc345f37
[openwrt.git] / target / linux / kirkwood / patches-3.10 / 0023-net-mv643xx_eth-use-of_phy_connect-if-phy_node-prese.patch
1 From db22a1196162f981444d241f92d02e2e50d12ed7 Mon Sep 17 00:00:00 2001
2 From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
3 Date: Wed, 29 May 2013 09:32:46 +0000
4 Subject: [PATCH 23/29] net: mv643xx_eth: use of_phy_connect if phy_node
5  present
6
7 This connects to a phy node passed to the port device instead of probing
8 the phy by phy_addr.
9
10 Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13  drivers/net/ethernet/marvell/mv643xx_eth.c | 25 ++++++++++++++++++-------
14  1 file changed, 18 insertions(+), 7 deletions(-)
15
16 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
17 +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
18 @@ -60,6 +60,7 @@
19  #include <linux/types.h>
20  #include <linux/slab.h>
21  #include <linux/clk.h>
22 +#include <linux/of_mdio.h>
23  
24  static char mv643xx_eth_driver_name[] = "mv643xx_eth";
25  static char mv643xx_eth_driver_version[] = "1.4";
26 @@ -2715,17 +2716,27 @@ static int mv643xx_eth_probe(struct plat
27         netif_set_real_num_tx_queues(dev, mp->txq_count);
28         netif_set_real_num_rx_queues(dev, mp->rxq_count);
29  
30 -       if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
31 +       err = 0;
32 +       if (pd->phy_node) {
33 +               mp->phy = of_phy_connect(mp->dev, pd->phy_node,
34 +                                        mv643xx_eth_adjust_link, 0,
35 +                                        PHY_INTERFACE_MODE_GMII);
36 +               if (!mp->phy)
37 +                       err = -ENODEV;
38 +       } else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
39                 mp->phy = phy_scan(mp, pd->phy_addr);
40  
41 -               if (IS_ERR(mp->phy)) {
42 +               if (IS_ERR(mp->phy))
43                         err = PTR_ERR(mp->phy);
44 -                       if (err == -ENODEV)
45 -                               err = -EPROBE_DEFER;
46 -                       goto out;
47 -               }
48 -               phy_init(mp, pd->speed, pd->duplex);
49 +               else
50 +                       phy_init(mp, pd->speed, pd->duplex);
51         }
52 +       if (err == -ENODEV) {
53 +               err = -EPROBE_DEFER;
54 +               goto out;
55 +       }
56 +       if (err)
57 +               goto out;
58  
59         SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops);
60