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

Merge tag 'phy-set-mode-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy into next

Add new set_mode phy ops

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

+34 -2
+15
drivers/phy/phy-core.c
··· 342 342 } 343 343 EXPORT_SYMBOL_GPL(phy_power_off); 344 344 345 + int phy_set_mode(struct phy *phy, enum phy_mode mode) 346 + { 347 + int ret; 348 + 349 + if (!phy || !phy->ops->set_mode) 350 + return 0; 351 + 352 + mutex_lock(&phy->mutex); 353 + ret = phy->ops->set_mode(phy, mode); 354 + mutex_unlock(&phy->mutex); 355 + 356 + return ret; 357 + } 358 + EXPORT_SYMBOL_GPL(phy_set_mode); 359 + 345 360 /** 346 361 * _of_phy_get() - lookup and obtain a reference to a phy by phandle 347 362 * @np: device_node for which to get the phy
+2 -2
drivers/phy/phy-xgene.c
··· 518 518 CLK_INT_SING = 2, /* Internal single ended */ 519 519 }; 520 520 521 - enum phy_mode { 521 + enum xgene_phy_mode { 522 522 MODE_SATA = 0, /* List them for simple reference */ 523 523 MODE_SGMII = 1, 524 524 MODE_PCIE = 2, ··· 542 542 struct xgene_phy_ctx { 543 543 struct device *dev; 544 544 struct phy *phy; 545 - enum phy_mode mode; /* Mode of operation */ 545 + enum xgene_phy_mode mode; /* Mode of operation */ 546 546 enum clk_type_t clk_type; /* Input clock selection */ 547 547 void __iomem *sds_base; /* PHY CSR base addr */ 548 548 struct clk *clk; /* Optional clock */
+17
include/linux/phy/phy.h
··· 22 22 23 23 struct phy; 24 24 25 + enum phy_mode { 26 + PHY_MODE_INVALID, 27 + PHY_MODE_USB_HOST, 28 + PHY_MODE_USB_DEVICE, 29 + PHY_MODE_USB_OTG, 30 + }; 31 + 25 32 /** 26 33 * struct phy_ops - set of function pointers for performing phy operations 27 34 * @init: operation to be performed for initializing phy 28 35 * @exit: operation to be performed while exiting 29 36 * @power_on: powering on the phy 30 37 * @power_off: powering off the phy 38 + * @set_mode: set the mode of the phy 31 39 * @owner: the module owner containing the ops 32 40 */ 33 41 struct phy_ops { ··· 43 35 int (*exit)(struct phy *phy); 44 36 int (*power_on)(struct phy *phy); 45 37 int (*power_off)(struct phy *phy); 38 + int (*set_mode)(struct phy *phy, enum phy_mode mode); 46 39 struct module *owner; 47 40 }; 48 41 ··· 135 126 int phy_exit(struct phy *phy); 136 127 int phy_power_on(struct phy *phy); 137 128 int phy_power_off(struct phy *phy); 129 + int phy_set_mode(struct phy *phy, enum phy_mode mode); 138 130 static inline int phy_get_bus_width(struct phy *phy) 139 131 { 140 132 return phy->attrs.bus_width; ··· 237 227 } 238 228 239 229 static inline int phy_power_off(struct phy *phy) 230 + { 231 + if (!phy) 232 + return 0; 233 + return -ENOSYS; 234 + } 235 + 236 + static inline int phy_set_mode(struct phy *phy, enum phy_mode mode) 240 237 { 241 238 if (!phy) 242 239 return 0;