orion: remove unmaintained target
[openwrt/staging/mkresin.git] / target / linux / ixp4xx / patches-4.9 / 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 @@ -95,12 +95,23 @@ struct ixp4xx_pata_data {
6 #define IXP4XX_ETH_NPEB 0x10
7 #define IXP4XX_ETH_NPEC 0x20
8
9 +#define IXP4XX_ETH_PHY_MAX_ADDR 32
10 +
11 /* Information about built-in Ethernet MAC interfaces */
12 struct eth_plat_info {
13 u8 phy; /* MII PHY ID, 0 - 31 */
14 u8 rxq; /* configurable, currently 0 - 31 only */
15 u8 txreadyq;
16 u8 hwaddr[6];
17 +
18 + u32 phy_mask;
19 +#if 0
20 + int speed;
21 + int duplex;
22 +#else
23 + int speed_10;
24 + int half_duplex;
25 +#endif
26 };
27
28 /* Information about built-in HSS (synchronous serial) interfaces */
29 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
30 +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
31 @@ -605,6 +605,37 @@ static int ixp4xx_phy_connect(struct net
32 struct eth_plat_info *plat = port->plat;
33 char phy_id[MII_BUS_ID_SIZE + 3];
34
35 + if (plat->phy == IXP4XX_ETH_PHY_MAX_ADDR) {
36 +#if 0
37 + switch (plat->speed) {
38 + case SPEED_10:
39 + case SPEED_100:
40 + break;
41 + default:
42 + printk(KERN_ERR "%s: invalid speed (%d)\n",
43 + dev->name, plat->speed);
44 + return -EINVAL;
45 + }
46 +
47 + switch (plat->duplex) {
48 + case DUPLEX_HALF:
49 + case DUPLEX_FULL:
50 + break;
51 + default:
52 + printk(KERN_ERR "%s: invalid duplex mode (%d)\n",
53 + dev->name, plat->duplex);
54 + return -EINVAL;
55 + }
56 + port->speed = plat->speed;
57 + port->duplex = plat->duplex;
58 +#else
59 + port->speed = plat->speed_10 ? SPEED_10 : SPEED_100;
60 + port->duplex = plat->half_duplex ? DUPLEX_HALF : DUPLEX_FULL;
61 +#endif
62 +
63 + return 0;
64 + }
65 +
66 snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
67 mdio_bus->id, plat->phy);
68 port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
69 @@ -627,21 +658,32 @@ static void ixp4xx_phy_disconnect(struct
70 {
71 struct port *port = netdev_priv(dev);
72
73 - phy_disconnect(port->phydev);
74 + if (port->phydev)
75 + phy_disconnect(port->phydev);
76 }
77
78 static void ixp4xx_phy_start(struct net_device *dev)
79 {
80 struct port *port = netdev_priv(dev);
81
82 - phy_start(port->phydev);
83 + if (port->phydev) {
84 + phy_start(port->phydev);
85 + } else {
86 + port->link = 1;
87 + ixp4xx_update_link(dev);
88 + }
89 }
90
91 static void ixp4xx_phy_stop(struct net_device *dev)
92 {
93 struct port *port = netdev_priv(dev);
94
95 - phy_stop(port->phydev);
96 + if (port->phydev) {
97 + phy_stop(port->phydev);
98 + } else {
99 + port->link = 0;
100 + ixp4xx_update_link(dev);
101 + }
102 }
103
104 static inline void debug_pkt(struct net_device *dev, const char *func,
105 @@ -1030,6 +1072,8 @@ static void eth_set_mcast_list(struct ne
106
107 static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
108 {
109 + struct port *port = netdev_priv(dev);
110 +
111 if (!netif_running(dev))
112 return -EINVAL;
113
114 @@ -1040,6 +1084,9 @@ static int eth_ioctl(struct net_device *
115 return hwtstamp_get(dev, req);
116 }
117
118 + if (!port->phydev)
119 + return -EOPNOTSUPP;
120 +
121 return phy_mii_ioctl(dev->phydev, req, cmd);
122 }
123
124 @@ -1059,6 +1106,11 @@ static void ixp4xx_get_drvinfo(struct ne
125
126 static int ixp4xx_nway_reset(struct net_device *dev)
127 {
128 + struct port *port = netdev_priv(dev);
129 +
130 + if (!port->phydev)
131 + return -EOPNOTSUPP;
132 +
133 return phy_start_aneg(dev->phydev);
134 }
135
136 @@ -1519,7 +1571,7 @@ static int eth_init_one(struct platform_
137 return 0;
138
139 err_phy_dis:
140 - ixp4xx_phy_disconnect(phydev);
141 + ixp4xx_phy_disconnect(port->netdev);
142 err_free_mem:
143 npe_port_tab[NPE_ID(port->id)] = NULL;
144 release_resource(port->mem_res);
145 @@ -1537,7 +1589,7 @@ static int eth_remove_one(struct platfor
146 struct port *port = netdev_priv(dev);
147
148 unregister_netdev(dev);
149 - ixp4xx_phy_disconnect(phydev);
150 + ixp4xx_phy_disconnect(port->netdev);
151 npe_port_tab[NPE_ID(port->id)] = NULL;
152 npe_release(port->npe);
153 release_resource(port->mem_res);