Lines Matching +full:phy +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0+
4 * multiple (actual) PHY devices. This is comes handy when initializing
10 #include <linux/device.h>
12 #include <linux/phy/phy.h>
15 #include "phy.h"
18 struct phy *phy; member
22 /* Allocate the roothub_entry by specific name of phy */
23 static int usb_phy_roothub_add_phy_by_name(struct device *dev, const char *name, in usb_phy_roothub_add_phy_by_name()
27 struct phy *phy; in usb_phy_roothub_add_phy_by_name() local
29 phy = devm_of_phy_get(dev, dev->of_node, name); in usb_phy_roothub_add_phy_by_name()
30 if (IS_ERR(phy)) in usb_phy_roothub_add_phy_by_name()
31 return PTR_ERR(phy); in usb_phy_roothub_add_phy_by_name()
35 return -ENOMEM; in usb_phy_roothub_add_phy_by_name()
37 INIT_LIST_HEAD(&roothub_entry->list); in usb_phy_roothub_add_phy_by_name()
39 roothub_entry->phy = phy; in usb_phy_roothub_add_phy_by_name()
41 list_add_tail(&roothub_entry->list, list); in usb_phy_roothub_add_phy_by_name()
46 static int usb_phy_roothub_add_phy(struct device *dev, int index, in usb_phy_roothub_add_phy()
50 struct phy *phy; in usb_phy_roothub_add_phy() local
52 phy = devm_of_phy_get_by_index(dev, dev->of_node, index); in usb_phy_roothub_add_phy()
53 if (IS_ERR(phy)) { in usb_phy_roothub_add_phy()
54 if (PTR_ERR(phy) == -ENODEV) in usb_phy_roothub_add_phy()
57 return PTR_ERR(phy); in usb_phy_roothub_add_phy()
62 return -ENOMEM; in usb_phy_roothub_add_phy()
64 INIT_LIST_HEAD(&roothub_entry->list); in usb_phy_roothub_add_phy()
66 roothub_entry->phy = phy; in usb_phy_roothub_add_phy()
68 list_add_tail(&roothub_entry->list, list); in usb_phy_roothub_add_phy()
73 struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev) in usb_phy_roothub_alloc()
81 num_phys = of_count_phandle_with_args(dev->of_node, "phys", in usb_phy_roothub_alloc()
82 "#phy-cells"); in usb_phy_roothub_alloc()
88 return ERR_PTR(-ENOMEM); in usb_phy_roothub_alloc()
90 INIT_LIST_HEAD(&phy_roothub->list); in usb_phy_roothub_alloc()
92 if (!usb_phy_roothub_add_phy_by_name(dev, "usb2-phy", &phy_roothub->list)) in usb_phy_roothub_alloc()
96 err = usb_phy_roothub_add_phy(dev, i, &phy_roothub->list); in usb_phy_roothub_alloc()
106 * usb_phy_roothub_alloc_usb3_phy - alloc the roothub
107 * @dev: the device of the host controller
109 * Allocate the usb phy roothub if the host use a generic usb3-phy.
112 * %NULL if no use usb3 phy or %-ENOMEM if out of memory.
114 struct usb_phy_roothub *usb_phy_roothub_alloc_usb3_phy(struct device *dev) in usb_phy_roothub_alloc_usb3_phy()
122 num_phys = of_count_phandle_with_args(dev->of_node, "phys", in usb_phy_roothub_alloc_usb3_phy()
123 "#phy-cells"); in usb_phy_roothub_alloc_usb3_phy()
129 return ERR_PTR(-ENOMEM); in usb_phy_roothub_alloc_usb3_phy()
131 INIT_LIST_HEAD(&phy_roothub->list); in usb_phy_roothub_alloc_usb3_phy()
133 if (!usb_phy_roothub_add_phy_by_name(dev, "usb3-phy", &phy_roothub->list)) in usb_phy_roothub_alloc_usb3_phy()
149 head = &phy_roothub->list; in usb_phy_roothub_init()
152 err = phy_init(roothub_entry->phy); in usb_phy_roothub_init()
161 phy_exit(roothub_entry->phy); in usb_phy_roothub_init()
176 head = &phy_roothub->list; in usb_phy_roothub_exit()
179 err = phy_exit(roothub_entry->phy); in usb_phy_roothub_exit()
198 head = &phy_roothub->list; in usb_phy_roothub_set_mode()
201 err = phy_set_mode(roothub_entry->phy, mode); in usb_phy_roothub_set_mode()
210 phy_power_off(roothub_entry->phy); in usb_phy_roothub_set_mode()
225 head = &phy_roothub->list; in usb_phy_roothub_calibrate()
228 err = phy_calibrate(roothub_entry->phy); in usb_phy_roothub_calibrate()
238 * usb_phy_roothub_notify_connect() - connect notification
239 * @phy_roothub: the phy of roothub, if the host use a generic phy.
242 * If the phy needs to get connection status, the callback can be used.
254 head = &phy_roothub->list; in usb_phy_roothub_notify_connect()
257 err = phy_notify_connect(roothub_entry->phy, port); in usb_phy_roothub_notify_connect()
267 * usb_phy_roothub_notify_disconnect() - disconnect notification
268 * @phy_roothub: the phy of roothub, if the host use a generic phy.
271 * If the phy needs to get connection status, the callback can be used.
283 head = &phy_roothub->list; in usb_phy_roothub_notify_disconnect()
286 err = phy_notify_disconnect(roothub_entry->phy, port); in usb_phy_roothub_notify_disconnect()
304 head = &phy_roothub->list; in usb_phy_roothub_power_on()
307 err = phy_power_on(roothub_entry->phy); in usb_phy_roothub_power_on()
316 phy_power_off(roothub_entry->phy); in usb_phy_roothub_power_on()
329 list_for_each_entry_reverse(roothub_entry, &phy_roothub->list, list) in usb_phy_roothub_power_off()
330 phy_power_off(roothub_entry->phy); in usb_phy_roothub_power_off()
334 int usb_phy_roothub_suspend(struct device *controller_dev, in usb_phy_roothub_suspend()
339 /* keep the PHYs initialized so the device can wake up the system */ in usb_phy_roothub_suspend()
347 int usb_phy_roothub_resume(struct device *controller_dev, in usb_phy_roothub_resume()
352 /* if the device can't wake up the system _exit was called */ in usb_phy_roothub_resume()