4
4
#include <linux/fsl/enetc_mdio.h>
5
5
#include <linux/of_mdio.h>
6
6
#include <linux/of_net.h>
7
- #include <linux/pcs-lynx.h>
8
7
9
8
#include "enetc_pf_common.h"
10
9
10
+ static void enetc_set_si_hw_addr (struct enetc_pf * pf , int si ,
11
+ const u8 * mac_addr )
12
+ {
13
+ struct enetc_hw * hw = & pf -> si -> hw ;
14
+
15
+ pf -> ops -> set_si_primary_mac (hw , si , mac_addr );
16
+ }
17
+
18
+ static void enetc_get_si_hw_addr (struct enetc_pf * pf , int si , u8 * mac_addr )
19
+ {
20
+ struct enetc_hw * hw = & pf -> si -> hw ;
21
+
22
+ pf -> ops -> get_si_primary_mac (hw , si , mac_addr );
23
+ }
24
+
11
25
int enetc_pf_set_mac_addr (struct net_device * ndev , void * addr )
12
26
{
13
27
struct enetc_ndev_priv * priv = netdev_priv (ndev );
28
+ struct enetc_pf * pf = enetc_si_priv (priv -> si );
14
29
struct sockaddr * saddr = addr ;
15
30
16
31
if (!is_valid_ether_addr (saddr -> sa_data ))
17
32
return - EADDRNOTAVAIL ;
18
33
19
34
eth_hw_addr_set (ndev , saddr -> sa_data );
20
- enetc_pf_set_primary_mac_addr ( & priv -> si -> hw , 0 , saddr -> sa_data );
35
+ enetc_set_si_hw_addr ( pf , 0 , saddr -> sa_data );
21
36
22
37
return 0 ;
23
38
}
39
+ EXPORT_SYMBOL_GPL (enetc_pf_set_mac_addr );
24
40
25
41
static int enetc_setup_mac_address (struct device_node * np , struct enetc_pf * pf ,
26
42
int si )
27
43
{
28
44
struct device * dev = & pf -> si -> pdev -> dev ;
29
- struct enetc_hw * hw = & pf -> si -> hw ;
30
45
u8 mac_addr [ETH_ALEN ] = { 0 };
31
46
int err ;
32
47
@@ -39,7 +54,7 @@ static int enetc_setup_mac_address(struct device_node *np, struct enetc_pf *pf,
39
54
40
55
/* (2) bootloader supplied MAC address */
41
56
if (is_zero_ether_addr (mac_addr ))
42
- enetc_pf_get_primary_mac_addr ( hw , si , mac_addr );
57
+ enetc_get_si_hw_addr ( pf , si , mac_addr );
43
58
44
59
/* (3) choose a random one */
45
60
if (is_zero_ether_addr (mac_addr )) {
@@ -48,7 +63,7 @@ static int enetc_setup_mac_address(struct device_node *np, struct enetc_pf *pf,
48
63
si , mac_addr );
49
64
}
50
65
51
- enetc_pf_set_primary_mac_addr ( hw , si , mac_addr );
66
+ enetc_set_si_hw_addr ( pf , si , mac_addr );
52
67
53
68
return 0 ;
54
69
}
@@ -70,11 +85,13 @@ int enetc_setup_mac_addresses(struct device_node *np, struct enetc_pf *pf)
70
85
71
86
return 0 ;
72
87
}
88
+ EXPORT_SYMBOL_GPL (enetc_setup_mac_addresses );
73
89
74
90
void enetc_pf_netdev_setup (struct enetc_si * si , struct net_device * ndev ,
75
91
const struct net_device_ops * ndev_ops )
76
92
{
77
93
struct enetc_ndev_priv * priv = netdev_priv (ndev );
94
+ struct enetc_pf * pf = enetc_si_priv (si );
78
95
79
96
SET_NETDEV_DEV (ndev , & si -> pdev -> dev );
80
97
priv -> ndev = ndev ;
@@ -107,7 +124,8 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
107
124
NETDEV_XDP_ACT_NDO_XMIT | NETDEV_XDP_ACT_RX_SG |
108
125
NETDEV_XDP_ACT_NDO_XMIT_SG ;
109
126
110
- if (si -> hw_features & ENETC_SI_F_PSFP && !enetc_psfp_enable (priv )) {
127
+ if (si -> hw_features & ENETC_SI_F_PSFP && pf -> ops -> enable_psfp &&
128
+ !pf -> ops -> enable_psfp (priv )) {
111
129
priv -> active_offloads |= ENETC_F_QCI ;
112
130
ndev -> features |= NETIF_F_HW_TC ;
113
131
ndev -> hw_features |= NETIF_F_HW_TC ;
@@ -116,6 +134,7 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
116
134
/* pick up primary MAC address from SI */
117
135
enetc_load_primary_mac_addr (& si -> hw , ndev );
118
136
}
137
+ EXPORT_SYMBOL_GPL (enetc_pf_netdev_setup );
119
138
120
139
static int enetc_mdio_probe (struct enetc_pf * pf , struct device_node * np )
121
140
{
@@ -162,6 +181,12 @@ static int enetc_imdio_create(struct enetc_pf *pf)
162
181
struct mii_bus * bus ;
163
182
int err ;
164
183
184
+ if (!pf -> ops -> create_pcs ) {
185
+ dev_err (dev , "Creating PCS is not supported\n" );
186
+
187
+ return - EOPNOTSUPP ;
188
+ }
189
+
165
190
bus = mdiobus_alloc_size (sizeof (* mdio_priv ));
166
191
if (!bus )
167
192
return - ENOMEM ;
@@ -184,7 +209,7 @@ static int enetc_imdio_create(struct enetc_pf *pf)
184
209
goto free_mdio_bus ;
185
210
}
186
211
187
- phylink_pcs = lynx_pcs_create_mdiodev ( bus , 0 );
212
+ phylink_pcs = pf -> ops -> create_pcs ( pf , bus );
188
213
if (IS_ERR (phylink_pcs )) {
189
214
err = PTR_ERR (phylink_pcs );
190
215
dev_err (dev , "cannot create lynx pcs (%d)\n" , err );
@@ -205,8 +230,8 @@ static int enetc_imdio_create(struct enetc_pf *pf)
205
230
206
231
static void enetc_imdio_remove (struct enetc_pf * pf )
207
232
{
208
- if (pf -> pcs )
209
- lynx_pcs_destroy (pf -> pcs );
233
+ if (pf -> pcs && pf -> ops -> destroy_pcs )
234
+ pf -> ops -> destroy_pcs (pf -> pcs );
210
235
211
236
if (pf -> imdio ) {
212
237
mdiobus_unregister (pf -> imdio );
@@ -246,12 +271,14 @@ int enetc_mdiobus_create(struct enetc_pf *pf, struct device_node *node)
246
271
247
272
return 0 ;
248
273
}
274
+ EXPORT_SYMBOL_GPL (enetc_mdiobus_create );
249
275
250
276
void enetc_mdiobus_destroy (struct enetc_pf * pf )
251
277
{
252
278
enetc_mdio_remove (pf );
253
279
enetc_imdio_remove (pf );
254
280
}
281
+ EXPORT_SYMBOL_GPL (enetc_mdiobus_destroy );
255
282
256
283
int enetc_phylink_create (struct enetc_ndev_priv * priv , struct device_node * node ,
257
284
const struct phylink_mac_ops * ops )
@@ -288,8 +315,13 @@ int enetc_phylink_create(struct enetc_ndev_priv *priv, struct device_node *node,
288
315
289
316
return 0 ;
290
317
}
318
+ EXPORT_SYMBOL_GPL (enetc_phylink_create );
291
319
292
320
void enetc_phylink_destroy (struct enetc_ndev_priv * priv )
293
321
{
294
322
phylink_destroy (priv -> phylink );
295
323
}
324
+ EXPORT_SYMBOL_GPL (enetc_phylink_destroy );
325
+
326
+ MODULE_DESCRIPTION ("NXP ENETC PF common functionality driver" );
327
+ MODULE_LICENSE ("Dual BSD/GPL" );
0 commit comments