File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,41 @@ static inline unsigned int phy_find_valid(unsigned int idx, u32 features)
260
260
return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1 ;
261
261
}
262
262
263
+ /**
264
+ * phy_supported_speeds - return all speeds currently supported by a phy device
265
+ * @phy: The phy device to return supported speeds of.
266
+ * @speeds: buffer to store supported speeds in.
267
+ * @size: size of speeds buffer.
268
+ *
269
+ * Description: Returns the number of supported speeds, and fills the speeds
270
+ * buffer with the supported speeds. If speeds buffer is too small to contain
271
+ * all currently supported speeds, will return as many speeds as can fit.
272
+ */
273
+ unsigned int phy_supported_speeds (struct phy_device * phy ,
274
+ unsigned int * speeds ,
275
+ unsigned int size )
276
+ {
277
+ unsigned int count = 0 ;
278
+ unsigned int idx = 0 ;
279
+
280
+ while (idx < MAX_NUM_SETTINGS && count < size ) {
281
+ idx = phy_find_valid (idx , phy -> supported );
282
+
283
+ if (!(settings [idx ].setting & phy -> supported ))
284
+ break ;
285
+
286
+ /* Assumes settings are grouped by speed */
287
+ if ((count == 0 ) ||
288
+ (speeds [count - 1 ] != settings [idx ].speed )) {
289
+ speeds [count ] = settings [idx ].speed ;
290
+ count ++ ;
291
+ }
292
+ idx ++ ;
293
+ }
294
+
295
+ return count ;
296
+ }
297
+
263
298
/**
264
299
* phy_check_valid - check if there is a valid PHY setting which matches
265
300
* speed, duplex, and feature mask
Original file line number Diff line number Diff line change @@ -84,6 +84,21 @@ typedef enum {
84
84
PHY_INTERFACE_MODE_MAX ,
85
85
} phy_interface_t ;
86
86
87
+ /**
88
+ * phy_supported_speeds - return all speeds currently supported by a phy device
89
+ * @phy: The phy device to return supported speeds of.
90
+ * @speeds: buffer to store supported speeds in.
91
+ * @size: size of speeds buffer.
92
+ *
93
+ * Description: Returns the number of supported speeds, and
94
+ * fills the speeds * buffer with the supported speeds. If speeds buffer is
95
+ * too small to contain * all currently supported speeds, will return as
96
+ * many speeds as can fit.
97
+ */
98
+ unsigned int phy_supported_speeds (struct phy_device * phy ,
99
+ unsigned int * speeds ,
100
+ unsigned int size );
101
+
87
102
/**
88
103
* It maps 'enum phy_interface_t' found in include/linux/phy.h
89
104
* into the device tree binding of 'phy-mode', so that Ethernet
You can’t perform that action at this time.
0 commit comments