95461dc90398b0a0c9fc1b14d1eb1de6a5df5769
[openwrt.git] / target / linux / ixp4xx / patches-3.10 / 207-npe_driver_multiphy_support.patch
1 TODO: take care of additional PHYs through the PHY abstraction layer
2
3 --- a/arch/arm/mach-ixp4xx/include/mach/platform.h
4 +++ b/arch/arm/mach-ixp4xx/include/mach/platform.h
5 @@ -72,7 +72,7 @@ extern unsigned long ixp4xx_exp_bus_size
6  /*
7   * Clock Speed Definitions.
8   */
9 -#define IXP4XX_PERIPHERAL_BUS_CLOCK    (66) /* 66Mhzi APB BUS   */ 
10 +#define IXP4XX_PERIPHERAL_BUS_CLOCK    (66) /* 66Mhzi APB BUS   */
11  #define IXP4XX_UART_XTAL               14745600
12  
13  /*
14 @@ -93,12 +93,23 @@ struct ixp4xx_pata_data {
15  #define IXP4XX_ETH_NPEB                0x10
16  #define IXP4XX_ETH_NPEC                0x20
17  
18 +#define IXP4XX_ETH_PHY_MAX_ADDR        32
19 +
20  /* Information about built-in Ethernet MAC interfaces */
21  struct eth_plat_info {
22         u8 phy;         /* MII PHY ID, 0 - 31 */
23         u8 rxq;         /* configurable, currently 0 - 31 only */
24         u8 txreadyq;
25         u8 hwaddr[6];
26 +
27 +       u32 phy_mask;
28 +#if 0
29 +       int speed;
30 +       int duplex;
31 +#else
32 +       int speed_10;
33 +       int half_duplex;
34 +#endif
35  };
36  
37  /* Information about built-in HSS (synchronous serial) interfaces */
38 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
39 +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
40 @@ -594,6 +594,37 @@ static int ixp4xx_phy_connect(struct net
41         struct eth_plat_info *plat = port->plat;
42         char phy_id[MII_BUS_ID_SIZE + 3];
43  
44 +       if (plat->phy == IXP4XX_ETH_PHY_MAX_ADDR) {
45 +#if 0
46 +               switch (plat->speed) {
47 +               case SPEED_10:
48 +               case SPEED_100:
49 +                       break;
50 +               default:
51 +                       printk(KERN_ERR "%s: invalid speed (%d)\n",
52 +                                       dev->name, plat->speed);
53 +                       return -EINVAL;
54 +               }
55 +
56 +               switch (plat->duplex) {
57 +               case DUPLEX_HALF:
58 +               case DUPLEX_FULL:
59 +                       break;
60 +               default:
61 +                       printk(KERN_ERR "%s: invalid duplex mode (%d)\n",
62 +                                       dev->name, plat->duplex);
63 +                       return -EINVAL;
64 +               }
65 +               port->speed = plat->speed;
66 +               port->duplex = plat->duplex;
67 +#else
68 +               port->speed = plat->speed_10 ? SPEED_10 : SPEED_100;
69 +               port->duplex = plat->half_duplex ? DUPLEX_HALF : DUPLEX_FULL;
70 +#endif
71 +
72 +               return 0;
73 +       }
74 +
75         snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
76                 mdio_bus->id, plat->phy);
77         port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
78 @@ -616,21 +647,32 @@ static void ixp4xx_phy_disconnect(struct
79  {
80         struct port *port = netdev_priv(dev);
81  
82 -       phy_disconnect(port->phydev);
83 +       if (port->phydev)
84 +               phy_disconnect(port->phydev);
85  }
86  
87  static void ixp4xx_phy_start(struct net_device *dev)
88  {
89         struct port *port = netdev_priv(dev);
90  
91 -       phy_start(port->phydev);
92 +       if (port->phydev) {
93 +               phy_start(port->phydev);
94 +       } else {
95 +               port->link = 1;
96 +               ixp4xx_update_link(dev);
97 +       }
98  }
99  
100  static void ixp4xx_phy_stop(struct net_device *dev)
101  {
102         struct port *port = netdev_priv(dev);
103  
104 -       phy_stop(port->phydev);
105 +       if (port->phydev) {
106 +               phy_stop(port->phydev);
107 +       } else {
108 +               port->link = 0;
109 +               ixp4xx_update_link(dev);
110 +       }
111  }
112  
113  static inline void debug_pkt(struct net_device *dev, const char *func,
114 @@ -1028,6 +1070,9 @@ static int eth_ioctl(struct net_device *
115         if (cpu_is_ixp46x() && cmd == SIOCSHWTSTAMP)
116                 return hwtstamp_ioctl(dev, req, cmd);
117  
118 +       if (!port->phydev)
119 +               return -EOPNOTSUPP;
120 +
121         return phy_mii_ioctl(port->phydev, req, cmd);
122  }
123  
124 @@ -1048,18 +1093,30 @@ static void ixp4xx_get_drvinfo(struct ne
125  static int ixp4xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
126  {
127         struct port *port = netdev_priv(dev);
128 +
129 +       if (!port->phydev)
130 +               return -EOPNOTSUPP;
131 +
132         return phy_ethtool_gset(port->phydev, cmd);
133  }
134  
135  static int ixp4xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
136  {
137         struct port *port = netdev_priv(dev);
138 +
139 +       if (!port->phydev)
140 +               return -EOPNOTSUPP;
141 +
142         return phy_ethtool_sset(port->phydev, cmd);
143  }
144  
145  static int ixp4xx_nway_reset(struct net_device *dev)
146  {
147         struct port *port = netdev_priv(dev);
148 +
149 +       if (!port->phydev)
150 +               return -EOPNOTSUPP;
151 +
152         return phy_start_aneg(port->phydev);
153  }
154