1
2
3
4
5
6
7
8
9
10
11#ifndef __PHY_H
12#define __PHY_H
13
14#include <linux/compiler.h>
15#include <linux/spinlock.h>
16#include <linux/ethtool.h>
17#include <linux/linkmode.h>
18#include <linux/netlink.h>
19#include <linux/mdio.h>
20#include <linux/mii.h>
21#include <linux/mii_timestamper.h>
22#include <linux/module.h>
23#include <linux/timer.h>
24#include <linux/workqueue.h>
25#include <linux/mod_devicetable.h>
26#include <linux/u64_stats_sync.h>
27#include <linux/irqreturn.h>
28#include <linux/iopoll.h>
29#include <linux/refcount.h>
30
31#include <linux/atomic.h>
32
33#define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \
34 SUPPORTED_TP | \
35 SUPPORTED_MII)
36
37#define PHY_10BT_FEATURES (SUPPORTED_10baseT_Half | \
38 SUPPORTED_10baseT_Full)
39
40#define PHY_100BT_FEATURES (SUPPORTED_100baseT_Half | \
41 SUPPORTED_100baseT_Full)
42
43#define PHY_1000BT_FEATURES (SUPPORTED_1000baseT_Half | \
44 SUPPORTED_1000baseT_Full)
45
46extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_features) __ro_after_init;
47extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_t1_features) __ro_after_init;
48extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_gbit_features) __ro_after_init;
49extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_gbit_fibre_features) __ro_after_init;
50extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_gbit_all_ports_features) __ro_after_init;
51extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_features) __ro_after_init;
52extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_fec_features) __ro_after_init;
53extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_full_features) __ro_after_init;
54
55#define PHY_BASIC_FEATURES ((unsigned long *)&phy_basic_features)
56#define PHY_BASIC_T1_FEATURES ((unsigned long *)&phy_basic_t1_features)
57#define PHY_GBIT_FEATURES ((unsigned long *)&phy_gbit_features)
58#define PHY_GBIT_FIBRE_FEATURES ((unsigned long *)&phy_gbit_fibre_features)
59#define PHY_GBIT_ALL_PORTS_FEATURES ((unsigned long *)&phy_gbit_all_ports_features)
60#define PHY_10GBIT_FEATURES ((unsigned long *)&phy_10gbit_features)
61#define PHY_10GBIT_FEC_FEATURES ((unsigned long *)&phy_10gbit_fec_features)
62#define PHY_10GBIT_FULL_FEATURES ((unsigned long *)&phy_10gbit_full_features)
63
64extern const int phy_basic_ports_array[3];
65extern const int phy_fibre_port_array[1];
66extern const int phy_all_ports_features_array[7];
67extern const int phy_10_100_features_array[4];
68extern const int phy_basic_t1_features_array[2];
69extern const int phy_gbit_features_array[2];
70extern const int phy_10gbit_features_array[1];
71
72
73
74
75
76
77#define PHY_POLL -1
78#define PHY_MAC_INTERRUPT -2
79
80#define PHY_IS_INTERNAL 0x00000001
81#define PHY_RST_AFTER_CLK_EN 0x00000002
82#define PHY_POLL_CABLE_TEST 0x00000004
83#define MDIO_DEVICE_IS_PHY 0x80000000
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122typedef enum {
123 PHY_INTERFACE_MODE_NA,
124 PHY_INTERFACE_MODE_INTERNAL,
125 PHY_INTERFACE_MODE_MII,
126 PHY_INTERFACE_MODE_GMII,
127 PHY_INTERFACE_MODE_SGMII,
128 PHY_INTERFACE_MODE_TBI,
129 PHY_INTERFACE_MODE_REVMII,
130 PHY_INTERFACE_MODE_RMII,
131 PHY_INTERFACE_MODE_REVRMII,
132 PHY_INTERFACE_MODE_RGMII,
133 PHY_INTERFACE_MODE_RGMII_ID,
134 PHY_INTERFACE_MODE_RGMII_RXID,
135 PHY_INTERFACE_MODE_RGMII_TXID,
136 PHY_INTERFACE_MODE_RTBI,
137 PHY_INTERFACE_MODE_SMII,
138 PHY_INTERFACE_MODE_XGMII,
139 PHY_INTERFACE_MODE_XLGMII,
140 PHY_INTERFACE_MODE_MOCA,
141 PHY_INTERFACE_MODE_QSGMII,
142 PHY_INTERFACE_MODE_TRGMII,
143 PHY_INTERFACE_MODE_100BASEX,
144 PHY_INTERFACE_MODE_1000BASEX,
145 PHY_INTERFACE_MODE_2500BASEX,
146 PHY_INTERFACE_MODE_5GBASER,
147 PHY_INTERFACE_MODE_RXAUI,
148 PHY_INTERFACE_MODE_XAUI,
149
150 PHY_INTERFACE_MODE_10GBASER,
151 PHY_INTERFACE_MODE_25GBASER,
152 PHY_INTERFACE_MODE_USXGMII,
153
154 PHY_INTERFACE_MODE_10GKR,
155 PHY_INTERFACE_MODE_MAX,
156} phy_interface_t;
157
158
159
160
161unsigned int phy_supported_speeds(struct phy_device *phy,
162 unsigned int *speeds,
163 unsigned int size);
164
165
166
167
168
169
170
171
172
173static inline const char *phy_modes(phy_interface_t interface)
174{
175 switch (interface) {
176 case PHY_INTERFACE_MODE_NA:
177 return "";
178 case PHY_INTERFACE_MODE_INTERNAL:
179 return "internal";
180 case PHY_INTERFACE_MODE_MII:
181 return "mii";
182 case PHY_INTERFACE_MODE_GMII:
183 return "gmii";
184 case PHY_INTERFACE_MODE_SGMII:
185 return "sgmii";
186 case PHY_INTERFACE_MODE_TBI:
187 return "tbi";
188 case PHY_INTERFACE_MODE_REVMII:
189 return "rev-mii";
190 case PHY_INTERFACE_MODE_RMII:
191 return "rmii";
192 case PHY_INTERFACE_MODE_REVRMII:
193 return "rev-rmii";
194 case PHY_INTERFACE_MODE_RGMII:
195 return "rgmii";
196 case PHY_INTERFACE_MODE_RGMII_ID:
197 return "rgmii-id";
198 case PHY_INTERFACE_MODE_RGMII_RXID:
199 return "rgmii-rxid";
200 case PHY_INTERFACE_MODE_RGMII_TXID:
201 return "rgmii-txid";
202 case PHY_INTERFACE_MODE_RTBI:
203 return "rtbi";
204 case PHY_INTERFACE_MODE_SMII:
205 return "smii";
206 case PHY_INTERFACE_MODE_XGMII:
207 return "xgmii";
208 case PHY_INTERFACE_MODE_XLGMII:
209 return "xlgmii";
210 case PHY_INTERFACE_MODE_MOCA:
211 return "moca";
212 case PHY_INTERFACE_MODE_QSGMII:
213 return "qsgmii";
214 case PHY_INTERFACE_MODE_TRGMII:
215 return "trgmii";
216 case PHY_INTERFACE_MODE_1000BASEX:
217 return "1000base-x";
218 case PHY_INTERFACE_MODE_2500BASEX:
219 return "2500base-x";
220 case PHY_INTERFACE_MODE_5GBASER:
221 return "5gbase-r";
222 case PHY_INTERFACE_MODE_RXAUI:
223 return "rxaui";
224 case PHY_INTERFACE_MODE_XAUI:
225 return "xaui";
226 case PHY_INTERFACE_MODE_10GBASER:
227 return "10gbase-r";
228 case PHY_INTERFACE_MODE_25GBASER:
229 return "25gbase-r";
230 case PHY_INTERFACE_MODE_USXGMII:
231 return "usxgmii";
232 case PHY_INTERFACE_MODE_10GKR:
233 return "10gbase-kr";
234 case PHY_INTERFACE_MODE_100BASEX:
235 return "100base-x";
236 default:
237 return "unknown";
238 }
239}
240
241
242#define PHY_INIT_TIMEOUT 100000
243#define PHY_FORCE_TIMEOUT 10
244
245#define PHY_MAX_ADDR 32
246
247
248#define PHY_ID_FMT "%s:%02x"
249
250#define MII_BUS_ID_SIZE 61
251
252struct device;
253struct phylink;
254struct sfp_bus;
255struct sfp_upstream_ops;
256struct sk_buff;
257
258
259
260
261
262
263
264
265
266struct mdio_bus_stats {
267 u64_stats_t transfers;
268 u64_stats_t errors;
269 u64_stats_t writes;
270 u64_stats_t reads;
271
272 struct u64_stats_sync syncp;
273};
274
275
276
277
278
279
280
281
282
283
284
285
286
287struct phy_package_shared {
288 int addr;
289 refcount_t refcnt;
290 unsigned long flags;
291 size_t priv_size;
292
293
294
295
296
297
298
299 void *priv;
300};
301
302
303#define PHY_SHARED_F_INIT_DONE 0
304#define PHY_SHARED_F_PROBE_DONE 1
305
306
307
308
309
310
311
312
313
314
315
316
317struct mii_bus {
318 struct module *owner;
319 const char *name;
320 char id[MII_BUS_ID_SIZE];
321 void *priv;
322
323 int (*read)(struct mii_bus *bus, int addr, int regnum);
324
325 int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
326
327 int (*reset)(struct mii_bus *bus);
328
329
330 struct mdio_bus_stats stats[PHY_MAX_ADDR];
331
332
333
334
335
336 struct mutex mdio_lock;
337
338
339 struct device *parent;
340
341 enum {
342 MDIOBUS_ALLOCATED = 1,
343 MDIOBUS_REGISTERED,
344 MDIOBUS_UNREGISTERED,
345 MDIOBUS_RELEASED,
346 } state;
347
348
349 struct device dev;
350
351
352 struct mdio_device *mdio_map[PHY_MAX_ADDR];
353
354
355 u32 phy_mask;
356
357
358 u32 phy_ignore_ta_mask;
359
360
361
362
363
364 int irq[PHY_MAX_ADDR];
365
366
367 int reset_delay_us;
368
369 int reset_post_delay_us;
370
371 struct gpio_desc *reset_gpiod;
372
373
374 enum {
375 MDIOBUS_NO_CAP = 0,
376 MDIOBUS_C22,
377 MDIOBUS_C45,
378 MDIOBUS_C22_C45,
379 } probe_capabilities;
380
381
382 struct mutex shared_lock;
383
384
385 struct phy_package_shared *shared[PHY_MAX_ADDR];
386};
387#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
388
389struct mii_bus *mdiobus_alloc_size(size_t size);
390
391
392
393
394
395
396
397static inline struct mii_bus *mdiobus_alloc(void)
398{
399 return mdiobus_alloc_size(0);
400}
401
402int __mdiobus_register(struct mii_bus *bus, struct module *owner);
403int __devm_mdiobus_register(struct device *dev, struct mii_bus *bus,
404 struct module *owner);
405#define mdiobus_register(bus) __mdiobus_register(bus, THIS_MODULE)
406#define devm_mdiobus_register(dev, bus) \
407 __devm_mdiobus_register(dev, bus, THIS_MODULE)
408
409void mdiobus_unregister(struct mii_bus *bus);
410void mdiobus_free(struct mii_bus *bus);
411struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv);
412static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev)
413{
414 return devm_mdiobus_alloc_size(dev, 0);
415}
416
417struct mii_bus *mdio_find_bus(const char *mdio_name);
418struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
419
420#define PHY_INTERRUPT_DISABLED false
421#define PHY_INTERRUPT_ENABLED true
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459enum phy_state {
460 PHY_DOWN = 0,
461 PHY_READY,
462 PHY_HALTED,
463 PHY_UP,
464 PHY_RUNNING,
465 PHY_NOLINK,
466 PHY_CABLETEST,
467};
468
469#define MDIO_MMD_NUM 32
470
471
472
473
474
475
476
477struct phy_c45_device_ids {
478 u32 devices_in_package;
479 u32 mmds_present;
480 u32 device_ids[MDIO_MMD_NUM];
481};
482
483struct macsec_context;
484struct macsec_ops;
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563struct phy_device {
564 struct mdio_device mdio;
565
566
567
568 struct phy_driver *drv;
569
570 u32 phy_id;
571
572 struct phy_c45_device_ids c45_ids;
573 unsigned is_c45:1;
574 unsigned is_internal:1;
575 unsigned is_pseudo_fixed_link:1;
576 unsigned is_gigabit_capable:1;
577 unsigned has_fixups:1;
578 unsigned suspended:1;
579 unsigned suspended_by_mdio_bus:1;
580 unsigned sysfs_links:1;
581 unsigned loopback_enabled:1;
582 unsigned downshifted_rate:1;
583 unsigned is_on_sfp_module:1;
584 unsigned mac_managed_pm:1;
585
586 unsigned autoneg:1;
587
588 unsigned link:1;
589 unsigned autoneg_complete:1;
590
591
592 unsigned interrupts:1;
593
594 enum phy_state state;
595
596 u32 dev_flags;
597
598 phy_interface_t interface;
599
600
601
602
603
604 int speed;
605 int duplex;
606 int port;
607 int pause;
608 int asym_pause;
609 u8 master_slave_get;
610 u8 master_slave_set;
611 u8 master_slave_state;
612
613
614
615 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
616 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
617 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
618
619 __ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old);
620
621
622 u32 eee_broken_modes;
623
624#ifdef CONFIG_LED_TRIGGER_PHY
625 struct phy_led_trigger *phy_led_triggers;
626 unsigned int phy_num_led_triggers;
627 struct phy_led_trigger *last_triggered;
628
629 struct phy_led_trigger *led_link_trigger;
630#endif
631
632
633
634
635
636 int irq;
637
638
639
640 void *priv;
641
642
643
644 struct phy_package_shared *shared;
645
646
647 struct sk_buff *skb;
648 void *ehdr;
649 struct nlattr *nest;
650
651
652 struct delayed_work state_queue;
653
654 struct mutex lock;
655
656
657 bool sfp_bus_attached;
658 struct sfp_bus *sfp_bus;
659 struct phylink *phylink;
660 struct net_device *attached_dev;
661 struct mii_timestamper *mii_ts;
662
663 u8 mdix;
664 u8 mdix_ctrl;
665
666 void (*phy_link_change)(struct phy_device *phydev, bool up);
667 void (*adjust_link)(struct net_device *dev);
668
669#if IS_ENABLED(CONFIG_MACSEC)
670
671 const struct macsec_ops *macsec_ops;
672#endif
673};
674
675static inline struct phy_device *to_phy_device(const struct device *dev)
676{
677 return container_of(to_mdio_device(dev), struct phy_device, mdio);
678}
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693struct phy_tdr_config {
694 u32 first;
695 u32 last;
696 u32 step;
697 s8 pair;
698};
699#define PHY_PAIR_ALL -1
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724struct phy_driver {
725 struct mdio_driver_common mdiodrv;
726 u32 phy_id;
727 char *name;
728 u32 phy_id_mask;
729 const unsigned long * const features;
730 u32 flags;
731 const void *driver_data;
732
733
734
735
736 int (*soft_reset)(struct phy_device *phydev);
737
738
739
740
741
742 int (*config_init)(struct phy_device *phydev);
743
744
745
746
747
748 int (*probe)(struct phy_device *phydev);
749
750
751
752
753
754 int (*get_features)(struct phy_device *phydev);
755
756
757
758 int (*suspend)(struct phy_device *phydev);
759
760 int (*resume)(struct phy_device *phydev);
761
762
763
764
765
766
767
768 int (*config_aneg)(struct phy_device *phydev);
769
770
771 int (*aneg_done)(struct phy_device *phydev);
772
773
774 int (*read_status)(struct phy_device *phydev);
775
776
777
778
779
780
781 int (*config_intr)(struct phy_device *phydev);
782
783
784 irqreturn_t (*handle_interrupt)(struct phy_device *phydev);
785
786
787 void (*remove)(struct phy_device *phydev);
788
789
790
791
792
793
794 int (*match_phy_device)(struct phy_device *phydev);
795
796
797
798
799
800
801
802 int (*set_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
803
804
805
806
807
808 void (*get_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
809
810
811
812
813
814
815
816
817
818 void (*link_change_notify)(struct phy_device *dev);
819
820
821
822
823
824
825
826
827
828
829
830 int (*read_mmd)(struct phy_device *dev, int devnum, u16 regnum);
831
832
833
834
835
836
837
838
839
840
841
842 int (*write_mmd)(struct phy_device *dev, int devnum, u16 regnum,
843 u16 val);
844
845
846 int (*read_page)(struct phy_device *dev);
847
848 int (*write_page)(struct phy_device *dev, int page);
849
850
851
852
853
854 int (*module_info)(struct phy_device *dev,
855 struct ethtool_modinfo *modinfo);
856
857
858
859
860
861 int (*module_eeprom)(struct phy_device *dev,
862 struct ethtool_eeprom *ee, u8 *data);
863
864
865 int (*cable_test_start)(struct phy_device *dev);
866
867
868 int (*cable_test_tdr_start)(struct phy_device *dev,
869 const struct phy_tdr_config *config);
870
871
872
873
874
875 int (*cable_test_get_status)(struct phy_device *dev, bool *finished);
876
877
878
879 int (*get_sset_count)(struct phy_device *dev);
880
881 void (*get_strings)(struct phy_device *dev, u8 *data);
882
883 void (*get_stats)(struct phy_device *dev,
884 struct ethtool_stats *stats, u64 *data);
885
886
887
888 int (*get_tunable)(struct phy_device *dev,
889 struct ethtool_tunable *tuna, void *data);
890
891 int (*set_tunable)(struct phy_device *dev,
892 struct ethtool_tunable *tuna,
893 const void *data);
894
895 int (*set_loopback)(struct phy_device *dev, bool enable);
896
897 int (*get_sqi)(struct phy_device *dev);
898
899 int (*get_sqi_max)(struct phy_device *dev);
900};
901#define to_phy_driver(d) container_of(to_mdio_common_driver(d), \
902 struct phy_driver, mdiodrv)
903
904#define PHY_ANY_ID "MATCH ANY PHY"
905#define PHY_ANY_UID 0xffffffff
906
907#define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0)
908#define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4)
909#define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10)
910
911
912struct phy_fixup {
913 struct list_head list;
914 char bus_id[MII_BUS_ID_SIZE + 3];
915 u32 phy_uid;
916 u32 phy_uid_mask;
917 int (*run)(struct phy_device *phydev);
918};
919
920const char *phy_speed_to_str(int speed);
921const char *phy_duplex_to_str(unsigned int duplex);
922
923
924
925
926struct phy_setting {
927 u32 speed;
928 u8 duplex;
929 u8 bit;
930};
931
932const struct phy_setting *
933phy_lookup_setting(int speed, int duplex, const unsigned long *mask,
934 bool exact);
935size_t phy_speeds(unsigned int *speeds, size_t size,
936 unsigned long *mask);
937void of_set_phy_supported(struct phy_device *phydev);
938void of_set_phy_eee_broken(struct phy_device *phydev);
939int phy_speed_down_core(struct phy_device *phydev);
940
941
942
943
944
945static inline bool phy_is_started(struct phy_device *phydev)
946{
947 return phydev->state >= PHY_UP;
948}
949
950void phy_resolve_aneg_pause(struct phy_device *phydev);
951void phy_resolve_aneg_linkmode(struct phy_device *phydev);
952void phy_check_downshift(struct phy_device *phydev);
953
954
955
956
957
958
959
960
961
962
963static inline int phy_read(struct phy_device *phydev, u32 regnum)
964{
965 return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum);
966}
967
968#define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \
969 timeout_us, sleep_before_read) \
970({ \
971 int __ret = read_poll_timeout(phy_read, val, (cond) || val < 0, \
972 sleep_us, timeout_us, sleep_before_read, phydev, regnum); \
973 if (val < 0) \
974 __ret = val; \
975 if (__ret) \
976 phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \
977 __ret; \
978})
979
980
981
982
983
984
985
986
987
988static inline int __phy_read(struct phy_device *phydev, u32 regnum)
989{
990 return __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum);
991}
992
993
994
995
996
997
998
999
1000
1001
1002
1003static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
1004{
1005 return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, val);
1006}
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val)
1017{
1018 return __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum,
1019 val);
1020}
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034static inline int __phy_modify_changed(struct phy_device *phydev, u32 regnum,
1035 u16 mask, u16 set)
1036{
1037 return __mdiobus_modify_changed(phydev->mdio.bus, phydev->mdio.addr,
1038 regnum, mask, set);
1039}
1040
1041
1042
1043
1044
1045int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065#define phy_read_mmd_poll_timeout(phydev, devaddr, regnum, val, cond, \
1066 sleep_us, timeout_us, sleep_before_read) \
1067({ \
1068 int __ret = read_poll_timeout(phy_read_mmd, val, (cond) || val < 0, \
1069 sleep_us, timeout_us, sleep_before_read, \
1070 phydev, devaddr, regnum); \
1071 if (val < 0) \
1072 __ret = val; \
1073 if (__ret) \
1074 phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \
1075 __ret; \
1076})
1077
1078
1079
1080
1081
1082int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
1083
1084
1085
1086
1087
1088int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val);
1089
1090
1091
1092
1093
1094int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val);
1095
1096int __phy_modify_changed(struct phy_device *phydev, u32 regnum, u16 mask,
1097 u16 set);
1098int phy_modify_changed(struct phy_device *phydev, u32 regnum, u16 mask,
1099 u16 set);
1100int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
1101int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
1102
1103int __phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum,
1104 u16 mask, u16 set);
1105int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum,
1106 u16 mask, u16 set);
1107int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
1108 u16 mask, u16 set);
1109int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
1110 u16 mask, u16 set);
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120static inline int __phy_set_bits(struct phy_device *phydev, u32 regnum, u16 val)
1121{
1122 return __phy_modify(phydev, regnum, 0, val);
1123}
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133static inline int __phy_clear_bits(struct phy_device *phydev, u32 regnum,
1134 u16 val)
1135{
1136 return __phy_modify(phydev, regnum, val, 0);
1137}
1138
1139
1140
1141
1142
1143
1144
1145static inline int phy_set_bits(struct phy_device *phydev, u32 regnum, u16 val)
1146{
1147 return phy_modify(phydev, regnum, 0, val);
1148}
1149
1150
1151
1152
1153
1154
1155
1156static inline int phy_clear_bits(struct phy_device *phydev, u32 regnum, u16 val)
1157{
1158 return phy_modify(phydev, regnum, val, 0);
1159}
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171static inline int __phy_set_bits_mmd(struct phy_device *phydev, int devad,
1172 u32 regnum, u16 val)
1173{
1174 return __phy_modify_mmd(phydev, devad, regnum, 0, val);
1175}
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187static inline int __phy_clear_bits_mmd(struct phy_device *phydev, int devad,
1188 u32 regnum, u16 val)
1189{
1190 return __phy_modify_mmd(phydev, devad, regnum, val, 0);
1191}
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201static inline int phy_set_bits_mmd(struct phy_device *phydev, int devad,
1202 u32 regnum, u16 val)
1203{
1204 return phy_modify_mmd(phydev, devad, regnum, 0, val);
1205}
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad,
1216 u32 regnum, u16 val)
1217{
1218 return phy_modify_mmd(phydev, devad, regnum, val, 0);
1219}
1220
1221
1222
1223
1224
1225
1226
1227
1228static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
1229{
1230 return phydev->irq != PHY_POLL && phydev->irq != PHY_MAC_INTERRUPT;
1231}
1232
1233
1234
1235
1236
1237
1238static inline bool phy_polling_mode(struct phy_device *phydev)
1239{
1240 if (phydev->state == PHY_CABLETEST)
1241 if (phydev->drv->flags & PHY_POLL_CABLE_TEST)
1242 return true;
1243
1244 return phydev->irq == PHY_POLL;
1245}
1246
1247
1248
1249
1250
1251static inline bool phy_has_hwtstamp(struct phy_device *phydev)
1252{
1253 return phydev && phydev->mii_ts && phydev->mii_ts->hwtstamp;
1254}
1255
1256
1257
1258
1259
1260static inline bool phy_has_rxtstamp(struct phy_device *phydev)
1261{
1262 return phydev && phydev->mii_ts && phydev->mii_ts->rxtstamp;
1263}
1264
1265
1266
1267
1268
1269
1270static inline bool phy_has_tsinfo(struct phy_device *phydev)
1271{
1272 return phydev && phydev->mii_ts && phydev->mii_ts->ts_info;
1273}
1274
1275
1276
1277
1278
1279static inline bool phy_has_txtstamp(struct phy_device *phydev)
1280{
1281 return phydev && phydev->mii_ts && phydev->mii_ts->txtstamp;
1282}
1283
1284static inline int phy_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
1285{
1286 return phydev->mii_ts->hwtstamp(phydev->mii_ts, ifr);
1287}
1288
1289static inline bool phy_rxtstamp(struct phy_device *phydev, struct sk_buff *skb,
1290 int type)
1291{
1292 return phydev->mii_ts->rxtstamp(phydev->mii_ts, skb, type);
1293}
1294
1295static inline int phy_ts_info(struct phy_device *phydev,
1296 struct ethtool_ts_info *tsinfo)
1297{
1298 return phydev->mii_ts->ts_info(phydev->mii_ts, tsinfo);
1299}
1300
1301static inline void phy_txtstamp(struct phy_device *phydev, struct sk_buff *skb,
1302 int type)
1303{
1304 phydev->mii_ts->txtstamp(phydev->mii_ts, skb, type);
1305}
1306
1307
1308
1309
1310
1311static inline bool phy_is_internal(struct phy_device *phydev)
1312{
1313 return phydev->is_internal;
1314}
1315
1316
1317
1318
1319
1320static inline bool phy_on_sfp(struct phy_device *phydev)
1321{
1322 return phydev->is_on_sfp_module;
1323}
1324
1325
1326
1327
1328
1329
1330static inline bool phy_interface_mode_is_rgmii(phy_interface_t mode)
1331{
1332 return mode >= PHY_INTERFACE_MODE_RGMII &&
1333 mode <= PHY_INTERFACE_MODE_RGMII_TXID;
1334};
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344static inline bool phy_interface_mode_is_8023z(phy_interface_t mode)
1345{
1346 return mode == PHY_INTERFACE_MODE_1000BASEX ||
1347 mode == PHY_INTERFACE_MODE_2500BASEX;
1348}
1349
1350
1351
1352
1353
1354
1355static inline bool phy_interface_is_rgmii(struct phy_device *phydev)
1356{
1357 return phy_interface_mode_is_rgmii(phydev->interface);
1358};
1359
1360
1361
1362
1363
1364
1365static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
1366{
1367 return phydev->is_pseudo_fixed_link;
1368}
1369
1370int phy_save_page(struct phy_device *phydev);
1371int phy_select_page(struct phy_device *phydev, int page);
1372int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);
1373int phy_read_paged(struct phy_device *phydev, int page, u32 regnum);
1374int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val);
1375int phy_modify_paged_changed(struct phy_device *phydev, int page, u32 regnum,
1376 u16 mask, u16 set);
1377int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
1378 u16 mask, u16 set);
1379
1380struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
1381 bool is_c45,
1382 struct phy_c45_device_ids *c45_ids);
1383#if IS_ENABLED(CONFIG_PHYLIB)
1384int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id);
1385struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
1386struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
1387struct phy_device *device_phy_find_device(struct device *dev);
1388struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode);
1389struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
1390int phy_device_register(struct phy_device *phy);
1391void phy_device_free(struct phy_device *phydev);
1392#else
1393static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
1394{
1395 return 0;
1396}
1397static inline
1398struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
1399{
1400 return 0;
1401}
1402
1403static inline
1404struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
1405{
1406 return NULL;
1407}
1408
1409static inline struct phy_device *device_phy_find_device(struct device *dev)
1410{
1411 return NULL;
1412}
1413
1414static inline
1415struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode)
1416{
1417 return NULL;
1418}
1419
1420static inline
1421struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
1422{
1423 return NULL;
1424}
1425
1426static inline int phy_device_register(struct phy_device *phy)
1427{
1428 return 0;
1429}
1430
1431static inline void phy_device_free(struct phy_device *phydev) { }
1432#endif
1433void phy_device_remove(struct phy_device *phydev);
1434int phy_init_hw(struct phy_device *phydev);
1435int phy_suspend(struct phy_device *phydev);
1436int phy_resume(struct phy_device *phydev);
1437int __phy_resume(struct phy_device *phydev);
1438int phy_loopback(struct phy_device *phydev, bool enable);
1439void phy_sfp_attach(void *upstream, struct sfp_bus *bus);
1440void phy_sfp_detach(void *upstream, struct sfp_bus *bus);
1441int phy_sfp_probe(struct phy_device *phydev,
1442 const struct sfp_upstream_ops *ops);
1443struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
1444 phy_interface_t interface);
1445struct phy_device *phy_find_first(struct mii_bus *bus);
1446int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
1447 u32 flags, phy_interface_t interface);
1448int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
1449 void (*handler)(struct net_device *),
1450 phy_interface_t interface);
1451struct phy_device *phy_connect(struct net_device *dev, const char *bus_id,
1452 void (*handler)(struct net_device *),
1453 phy_interface_t interface);
1454void phy_disconnect(struct phy_device *phydev);
1455void phy_detach(struct phy_device *phydev);
1456void phy_start(struct phy_device *phydev);
1457void phy_stop(struct phy_device *phydev);
1458int phy_config_aneg(struct phy_device *phydev);
1459int phy_start_aneg(struct phy_device *phydev);
1460int phy_aneg_done(struct phy_device *phydev);
1461int phy_speed_down(struct phy_device *phydev, bool sync);
1462int phy_speed_up(struct phy_device *phydev);
1463
1464int phy_restart_aneg(struct phy_device *phydev);
1465int phy_reset_after_clk_enable(struct phy_device *phydev);
1466
1467#if IS_ENABLED(CONFIG_PHYLIB)
1468int phy_start_cable_test(struct phy_device *phydev,
1469 struct netlink_ext_ack *extack);
1470int phy_start_cable_test_tdr(struct phy_device *phydev,
1471 struct netlink_ext_ack *extack,
1472 const struct phy_tdr_config *config);
1473#else
1474static inline
1475int phy_start_cable_test(struct phy_device *phydev,
1476 struct netlink_ext_ack *extack)
1477{
1478 NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
1479 return -EOPNOTSUPP;
1480}
1481static inline
1482int phy_start_cable_test_tdr(struct phy_device *phydev,
1483 struct netlink_ext_ack *extack,
1484 const struct phy_tdr_config *config)
1485{
1486 NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
1487 return -EOPNOTSUPP;
1488}
1489#endif
1490
1491int phy_cable_test_result(struct phy_device *phydev, u8 pair, u16 result);
1492int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair,
1493 u16 cm);
1494
1495static inline void phy_device_reset(struct phy_device *phydev, int value)
1496{
1497 mdio_device_reset(&phydev->mdio, value);
1498}
1499
1500#define phydev_err(_phydev, format, args...) \
1501 dev_err(&_phydev->mdio.dev, format, ##args)
1502
1503#define phydev_info(_phydev, format, args...) \
1504 dev_info(&_phydev->mdio.dev, format, ##args)
1505
1506#define phydev_warn(_phydev, format, args...) \
1507 dev_warn(&_phydev->mdio.dev, format, ##args)
1508
1509#define phydev_dbg(_phydev, format, args...) \
1510 dev_dbg(&_phydev->mdio.dev, format, ##args)
1511
1512static inline const char *phydev_name(const struct phy_device *phydev)
1513{
1514 return dev_name(&phydev->mdio.dev);
1515}
1516
1517static inline void phy_lock_mdio_bus(struct phy_device *phydev)
1518{
1519 mutex_lock(&phydev->mdio.bus->mdio_lock);
1520}
1521
1522static inline void phy_unlock_mdio_bus(struct phy_device *phydev)
1523{
1524 mutex_unlock(&phydev->mdio.bus->mdio_lock);
1525}
1526
1527void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
1528 __printf(2, 3);
1529char *phy_attached_info_irq(struct phy_device *phydev)
1530 __malloc;
1531void phy_attached_info(struct phy_device *phydev);
1532
1533
1534int genphy_read_abilities(struct phy_device *phydev);
1535int genphy_setup_forced(struct phy_device *phydev);
1536int genphy_restart_aneg(struct phy_device *phydev);
1537int genphy_check_and_restart_aneg(struct phy_device *phydev, bool restart);
1538int genphy_config_eee_advert(struct phy_device *phydev);
1539int __genphy_config_aneg(struct phy_device *phydev, bool changed);
1540int genphy_aneg_done(struct phy_device *phydev);
1541int genphy_update_link(struct phy_device *phydev);
1542int genphy_read_lpa(struct phy_device *phydev);
1543int genphy_read_status_fixed(struct phy_device *phydev);
1544int genphy_read_status(struct phy_device *phydev);
1545int genphy_suspend(struct phy_device *phydev);
1546int genphy_resume(struct phy_device *phydev);
1547int genphy_loopback(struct phy_device *phydev, bool enable);
1548int genphy_soft_reset(struct phy_device *phydev);
1549irqreturn_t genphy_handle_interrupt_no_ack(struct phy_device *phydev);
1550
1551static inline int genphy_config_aneg(struct phy_device *phydev)
1552{
1553 return __genphy_config_aneg(phydev, false);
1554}
1555
1556static inline int genphy_no_config_intr(struct phy_device *phydev)
1557{
1558 return 0;
1559}
1560int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad,
1561 u16 regnum);
1562int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
1563 u16 regnum, u16 val);
1564
1565
1566int genphy_c37_config_aneg(struct phy_device *phydev);
1567int genphy_c37_read_status(struct phy_device *phydev);
1568
1569
1570int genphy_c45_restart_aneg(struct phy_device *phydev);
1571int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart);
1572int genphy_c45_aneg_done(struct phy_device *phydev);
1573int genphy_c45_read_link(struct phy_device *phydev);
1574int genphy_c45_read_lpa(struct phy_device *phydev);
1575int genphy_c45_read_pma(struct phy_device *phydev);
1576int genphy_c45_pma_setup_forced(struct phy_device *phydev);
1577int genphy_c45_an_config_aneg(struct phy_device *phydev);
1578int genphy_c45_an_disable_aneg(struct phy_device *phydev);
1579int genphy_c45_read_mdix(struct phy_device *phydev);
1580int genphy_c45_pma_read_abilities(struct phy_device *phydev);
1581int genphy_c45_read_status(struct phy_device *phydev);
1582int genphy_c45_config_aneg(struct phy_device *phydev);
1583int genphy_c45_loopback(struct phy_device *phydev, bool enable);
1584int genphy_c45_pma_resume(struct phy_device *phydev);
1585int genphy_c45_pma_suspend(struct phy_device *phydev);
1586
1587
1588extern struct phy_driver genphy_c45_driver;
1589
1590
1591int gen10g_config_aneg(struct phy_device *phydev);
1592
1593static inline int phy_read_status(struct phy_device *phydev)
1594{
1595 if (!phydev->drv)
1596 return -EIO;
1597
1598 if (phydev->drv->read_status)
1599 return phydev->drv->read_status(phydev);
1600 else
1601 return genphy_read_status(phydev);
1602}
1603
1604void phy_driver_unregister(struct phy_driver *drv);
1605void phy_drivers_unregister(struct phy_driver *drv, int n);
1606int phy_driver_register(struct phy_driver *new_driver, struct module *owner);
1607int phy_drivers_register(struct phy_driver *new_driver, int n,
1608 struct module *owner);
1609void phy_error(struct phy_device *phydev);
1610void phy_state_machine(struct work_struct *work);
1611void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies);
1612void phy_trigger_machine(struct phy_device *phydev);
1613void phy_mac_interrupt(struct phy_device *phydev);
1614void phy_start_machine(struct phy_device *phydev);
1615void phy_stop_machine(struct phy_device *phydev);
1616void phy_ethtool_ksettings_get(struct phy_device *phydev,
1617 struct ethtool_link_ksettings *cmd);
1618int phy_ethtool_ksettings_set(struct phy_device *phydev,
1619 const struct ethtool_link_ksettings *cmd);
1620int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
1621int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
1622int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd);
1623int phy_disable_interrupts(struct phy_device *phydev);
1624void phy_request_interrupt(struct phy_device *phydev);
1625void phy_free_interrupt(struct phy_device *phydev);
1626void phy_print_status(struct phy_device *phydev);
1627int phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
1628void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode);
1629void phy_advertise_supported(struct phy_device *phydev);
1630void phy_support_sym_pause(struct phy_device *phydev);
1631void phy_support_asym_pause(struct phy_device *phydev);
1632void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx,
1633 bool autoneg);
1634void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);
1635bool phy_validate_pause(struct phy_device *phydev,
1636 struct ethtool_pauseparam *pp);
1637void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause);
1638
1639s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
1640 const int *delay_values, int size, bool is_rx);
1641
1642void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
1643 bool *tx_pause, bool *rx_pause);
1644
1645int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
1646 int (*run)(struct phy_device *));
1647int phy_register_fixup_for_id(const char *bus_id,
1648 int (*run)(struct phy_device *));
1649int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
1650 int (*run)(struct phy_device *));
1651
1652int phy_unregister_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask);
1653int phy_unregister_fixup_for_id(const char *bus_id);
1654int phy_unregister_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask);
1655
1656int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable);
1657int phy_get_eee_err(struct phy_device *phydev);
1658int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data);
1659int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data);
1660int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol);
1661void phy_ethtool_get_wol(struct phy_device *phydev,
1662 struct ethtool_wolinfo *wol);
1663int phy_ethtool_get_link_ksettings(struct net_device *ndev,
1664 struct ethtool_link_ksettings *cmd);
1665int phy_ethtool_set_link_ksettings(struct net_device *ndev,
1666 const struct ethtool_link_ksettings *cmd);
1667int phy_ethtool_nway_reset(struct net_device *ndev);
1668int phy_package_join(struct phy_device *phydev, int addr, size_t priv_size);
1669void phy_package_leave(struct phy_device *phydev);
1670int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
1671 int addr, size_t priv_size);
1672
1673#if IS_ENABLED(CONFIG_PHYLIB)
1674int __init mdio_bus_init(void);
1675void mdio_bus_exit(void);
1676#endif
1677
1678int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
1679int phy_ethtool_get_sset_count(struct phy_device *phydev);
1680int phy_ethtool_get_stats(struct phy_device *phydev,
1681 struct ethtool_stats *stats, u64 *data);
1682
1683static inline int phy_package_read(struct phy_device *phydev, u32 regnum)
1684{
1685 struct phy_package_shared *shared = phydev->shared;
1686
1687 if (!shared)
1688 return -EIO;
1689
1690 return mdiobus_read(phydev->mdio.bus, shared->addr, regnum);
1691}
1692
1693static inline int __phy_package_read(struct phy_device *phydev, u32 regnum)
1694{
1695 struct phy_package_shared *shared = phydev->shared;
1696
1697 if (!shared)
1698 return -EIO;
1699
1700 return __mdiobus_read(phydev->mdio.bus, shared->addr, regnum);
1701}
1702
1703static inline int phy_package_write(struct phy_device *phydev,
1704 u32 regnum, u16 val)
1705{
1706 struct phy_package_shared *shared = phydev->shared;
1707
1708 if (!shared)
1709 return -EIO;
1710
1711 return mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val);
1712}
1713
1714static inline int __phy_package_write(struct phy_device *phydev,
1715 u32 regnum, u16 val)
1716{
1717 struct phy_package_shared *shared = phydev->shared;
1718
1719 if (!shared)
1720 return -EIO;
1721
1722 return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val);
1723}
1724
1725static inline bool __phy_package_set_once(struct phy_device *phydev,
1726 unsigned int b)
1727{
1728 struct phy_package_shared *shared = phydev->shared;
1729
1730 if (!shared)
1731 return false;
1732
1733 return !test_and_set_bit(b, &shared->flags);
1734}
1735
1736static inline bool phy_package_init_once(struct phy_device *phydev)
1737{
1738 return __phy_package_set_once(phydev, PHY_SHARED_F_INIT_DONE);
1739}
1740
1741static inline bool phy_package_probe_once(struct phy_device *phydev)
1742{
1743 return __phy_package_set_once(phydev, PHY_SHARED_F_PROBE_DONE);
1744}
1745
1746extern struct bus_type mdio_bus_type;
1747
1748struct mdio_board_info {
1749 const char *bus_id;
1750 char modalias[MDIO_NAME_SIZE];
1751 int mdio_addr;
1752 const void *platform_data;
1753};
1754
1755#if IS_ENABLED(CONFIG_MDIO_DEVICE)
1756int mdiobus_register_board_info(const struct mdio_board_info *info,
1757 unsigned int n);
1758#else
1759static inline int mdiobus_register_board_info(const struct mdio_board_info *i,
1760 unsigned int n)
1761{
1762 return 0;
1763}
1764#endif
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776#define phy_module_driver(__phy_drivers, __count) \
1777static int __init phy_module_init(void) \
1778{ \
1779 return phy_drivers_register(__phy_drivers, __count, THIS_MODULE); \
1780} \
1781module_init(phy_module_init); \
1782static void __exit phy_module_exit(void) \
1783{ \
1784 phy_drivers_unregister(__phy_drivers, __count); \
1785} \
1786module_exit(phy_module_exit)
1787
1788#define module_phy_driver(__phy_drivers) \
1789 phy_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers))
1790
1791bool phy_driver_is_genphy(struct phy_device *phydev);
1792bool phy_driver_is_genphy_10g(struct phy_device *phydev);
1793
1794#endif
1795