Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: Add media type and speed serdes configuration interfaces

Provide new phy configuration interfaces for media type and speed that
allows e.g. PHYs used for ethernet to be configured with this
information.

Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-By: Kishon Vijay Abraham I <kishon@ti.com>
Link: https://lore.kernel.org/r/20210218161451.3489955-3-steen.hegelund@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Steen Hegelund and committed by
Vinod Koul
6c172e73 13f99ac6

+56
+30
drivers/phy/phy-core.c
··· 373 373 } 374 374 EXPORT_SYMBOL_GPL(phy_set_mode_ext); 375 375 376 + int phy_set_media(struct phy *phy, enum phy_media media) 377 + { 378 + int ret; 379 + 380 + if (!phy || !phy->ops->set_media) 381 + return 0; 382 + 383 + mutex_lock(&phy->mutex); 384 + ret = phy->ops->set_media(phy, media); 385 + mutex_unlock(&phy->mutex); 386 + 387 + return ret; 388 + } 389 + EXPORT_SYMBOL_GPL(phy_set_media); 390 + 391 + int phy_set_speed(struct phy *phy, int speed) 392 + { 393 + int ret; 394 + 395 + if (!phy || !phy->ops->set_speed) 396 + return 0; 397 + 398 + mutex_lock(&phy->mutex); 399 + ret = phy->ops->set_speed(phy, speed); 400 + mutex_unlock(&phy->mutex); 401 + 402 + return ret; 403 + } 404 + EXPORT_SYMBOL_GPL(phy_set_speed); 405 + 376 406 int phy_reset(struct phy *phy) 377 407 { 378 408 int ret;
+26
include/linux/phy/phy.h
··· 44 44 PHY_MODE_DP 45 45 }; 46 46 47 + enum phy_media { 48 + PHY_MEDIA_DEFAULT, 49 + PHY_MEDIA_SR, 50 + PHY_MEDIA_DAC, 51 + }; 52 + 47 53 /** 48 54 * union phy_configure_opts - Opaque generic phy configuration 49 55 * ··· 70 64 * @power_on: powering on the phy 71 65 * @power_off: powering off the phy 72 66 * @set_mode: set the mode of the phy 67 + * @set_media: set the media type of the phy (optional) 68 + * @set_speed: set the speed of the phy (optional) 73 69 * @reset: resetting the phy 74 70 * @calibrate: calibrate the phy 75 71 * @release: ops to be performed while the consumer relinquishes the PHY ··· 83 75 int (*power_on)(struct phy *phy); 84 76 int (*power_off)(struct phy *phy); 85 77 int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode); 78 + int (*set_media)(struct phy *phy, enum phy_media media); 79 + int (*set_speed)(struct phy *phy, int speed); 86 80 87 81 /** 88 82 * @configure: ··· 225 215 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode); 226 216 #define phy_set_mode(phy, mode) \ 227 217 phy_set_mode_ext(phy, mode, 0) 218 + int phy_set_media(struct phy *phy, enum phy_media media); 219 + int phy_set_speed(struct phy *phy, int speed); 228 220 int phy_configure(struct phy *phy, union phy_configure_opts *opts); 229 221 int phy_validate(struct phy *phy, enum phy_mode mode, int submode, 230 222 union phy_configure_opts *opts); ··· 355 343 356 344 #define phy_set_mode(phy, mode) \ 357 345 phy_set_mode_ext(phy, mode, 0) 346 + 347 + static inline int phy_set_media(struct phy *phy, enum phy_media media) 348 + { 349 + if (!phy) 350 + return 0; 351 + return -ENODEV; 352 + } 353 + 354 + static inline int phy_set_speed(struct phy *phy, int speed) 355 + { 356 + if (!phy) 357 + return 0; 358 + return -ENODEV; 359 + } 358 360 359 361 static inline enum phy_mode phy_get_mode(struct phy *phy) 360 362 {