Lines Matching refs:usb_phy
33 struct usb_phy *phy;
37 static struct usb_phy *__usb_find_phy(struct list_head *list, in __usb_find_phy()
40 struct usb_phy *phy = NULL; in __usb_find_phy()
52 static struct usb_phy *__of_usb_find_phy(struct device_node *node) in __of_usb_find_phy()
54 struct usb_phy *phy; in __of_usb_find_phy()
69 static void usb_phy_set_default_current(struct usb_phy *usb_phy) in usb_phy_set_default_current() argument
71 usb_phy->chg_cur.sdp_min = DEFAULT_SDP_CUR_MIN; in usb_phy_set_default_current()
72 usb_phy->chg_cur.sdp_max = DEFAULT_SDP_CUR_MAX; in usb_phy_set_default_current()
73 usb_phy->chg_cur.dcp_min = DEFAULT_DCP_CUR_MIN; in usb_phy_set_default_current()
74 usb_phy->chg_cur.dcp_max = DEFAULT_DCP_CUR_MAX; in usb_phy_set_default_current()
75 usb_phy->chg_cur.cdp_min = DEFAULT_CDP_CUR_MIN; in usb_phy_set_default_current()
76 usb_phy->chg_cur.cdp_max = DEFAULT_CDP_CUR_MAX; in usb_phy_set_default_current()
77 usb_phy->chg_cur.aca_min = DEFAULT_ACA_CUR_MIN; in usb_phy_set_default_current()
78 usb_phy->chg_cur.aca_max = DEFAULT_ACA_CUR_MAX; in usb_phy_set_default_current()
99 struct usb_phy *usb_phy = container_of(work, struct usb_phy, chg_work); in usb_phy_notify_charger_work() local
104 switch (usb_phy->chg_state) { in usb_phy_notify_charger_work()
106 usb_phy_get_charger_current(usb_phy, &min, &max); in usb_phy_notify_charger_work()
108 atomic_notifier_call_chain(&usb_phy->notifier, max, usb_phy); in usb_phy_notify_charger_work()
113 usb_phy_set_default_current(usb_phy); in usb_phy_notify_charger_work()
115 atomic_notifier_call_chain(&usb_phy->notifier, 0, usb_phy); in usb_phy_notify_charger_work()
120 dev_warn(usb_phy->dev, "Unknown USB charger state: %d\n", in usb_phy_notify_charger_work()
121 usb_phy->chg_state); in usb_phy_notify_charger_work()
125 kobject_uevent_env(&usb_phy->dev->kobj, KOBJ_CHANGE, envp); in usb_phy_notify_charger_work()
128 static void __usb_phy_get_charger_type(struct usb_phy *usb_phy) in __usb_phy_get_charger_type() argument
130 if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_SDP) > 0) { in __usb_phy_get_charger_type()
131 usb_phy->chg_type = SDP_TYPE; in __usb_phy_get_charger_type()
132 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
133 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_CDP) > 0) { in __usb_phy_get_charger_type()
134 usb_phy->chg_type = CDP_TYPE; in __usb_phy_get_charger_type()
135 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
136 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_DCP) > 0) { in __usb_phy_get_charger_type()
137 usb_phy->chg_type = DCP_TYPE; in __usb_phy_get_charger_type()
138 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
139 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_ACA) > 0) { in __usb_phy_get_charger_type()
140 usb_phy->chg_type = ACA_TYPE; in __usb_phy_get_charger_type()
141 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
143 usb_phy->chg_type = UNKNOWN_TYPE; in __usb_phy_get_charger_type()
144 usb_phy->chg_state = USB_CHARGER_ABSENT; in __usb_phy_get_charger_type()
147 schedule_work(&usb_phy->chg_work); in __usb_phy_get_charger_type()
162 struct usb_phy *usb_phy = container_of(nb, struct usb_phy, type_nb); in usb_phy_get_charger_type() local
164 __usb_phy_get_charger_type(usb_phy); in usb_phy_get_charger_type()
182 void usb_phy_set_charger_current(struct usb_phy *usb_phy, unsigned int mA) in usb_phy_set_charger_current() argument
184 switch (usb_phy->chg_type) { in usb_phy_set_charger_current()
186 if (usb_phy->chg_cur.sdp_max == mA) in usb_phy_set_charger_current()
189 usb_phy->chg_cur.sdp_max = (mA > DEFAULT_SDP_CUR_MAX_SS) ? in usb_phy_set_charger_current()
193 if (usb_phy->chg_cur.dcp_max == mA) in usb_phy_set_charger_current()
196 usb_phy->chg_cur.dcp_max = (mA > DEFAULT_DCP_CUR_MAX) ? in usb_phy_set_charger_current()
200 if (usb_phy->chg_cur.cdp_max == mA) in usb_phy_set_charger_current()
203 usb_phy->chg_cur.cdp_max = (mA > DEFAULT_CDP_CUR_MAX) ? in usb_phy_set_charger_current()
207 if (usb_phy->chg_cur.aca_max == mA) in usb_phy_set_charger_current()
210 usb_phy->chg_cur.aca_max = (mA > DEFAULT_ACA_CUR_MAX) ? in usb_phy_set_charger_current()
217 schedule_work(&usb_phy->chg_work); in usb_phy_set_charger_current()
231 void usb_phy_get_charger_current(struct usb_phy *usb_phy, in usb_phy_get_charger_current() argument
234 switch (usb_phy->chg_type) { in usb_phy_get_charger_current()
236 *min = usb_phy->chg_cur.sdp_min; in usb_phy_get_charger_current()
237 *max = usb_phy->chg_cur.sdp_max; in usb_phy_get_charger_current()
240 *min = usb_phy->chg_cur.dcp_min; in usb_phy_get_charger_current()
241 *max = usb_phy->chg_cur.dcp_max; in usb_phy_get_charger_current()
244 *min = usb_phy->chg_cur.cdp_min; in usb_phy_get_charger_current()
245 *max = usb_phy->chg_cur.cdp_max; in usb_phy_get_charger_current()
248 *min = usb_phy->chg_cur.aca_min; in usb_phy_get_charger_current()
249 *max = usb_phy->chg_cur.aca_max; in usb_phy_get_charger_current()
268 void usb_phy_set_charger_state(struct usb_phy *usb_phy, in usb_phy_set_charger_state() argument
271 if (usb_phy->chg_state == state || !usb_phy->charger_detect) in usb_phy_set_charger_state()
274 usb_phy->chg_state = state; in usb_phy_set_charger_state()
275 if (usb_phy->chg_state == USB_CHARGER_PRESENT) in usb_phy_set_charger_state()
276 usb_phy->chg_type = usb_phy->charger_detect(usb_phy); in usb_phy_set_charger_state()
278 usb_phy->chg_type = UNKNOWN_TYPE; in usb_phy_set_charger_state()
280 schedule_work(&usb_phy->chg_work); in usb_phy_set_charger_state()
286 struct usb_phy *phy = *(struct usb_phy **)res; in devm_usb_phy_release()
302 struct usb_phy **phy = res; in devm_usb_phy_match()
307 static void usb_charger_init(struct usb_phy *usb_phy) in usb_charger_init() argument
309 usb_phy->chg_type = UNKNOWN_TYPE; in usb_charger_init()
310 usb_phy->chg_state = USB_CHARGER_DEFAULT; in usb_charger_init()
311 usb_phy_set_default_current(usb_phy); in usb_charger_init()
312 INIT_WORK(&usb_phy->chg_work, usb_phy_notify_charger_work); in usb_charger_init()
315 static int usb_add_extcon(struct usb_phy *x) in usb_add_extcon()
415 struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) in devm_usb_get_phy()
417 struct usb_phy **ptr, *phy; in devm_usb_get_phy()
444 struct usb_phy *usb_get_phy(enum usb_phy_type type) in usb_get_phy()
446 struct usb_phy *phy = NULL; in usb_get_phy()
486 struct usb_phy *devm_usb_get_phy_by_node(struct device *dev, in devm_usb_get_phy_by_node()
490 struct usb_phy *phy = ERR_PTR(-ENOMEM); in devm_usb_get_phy_by_node()
545 struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, in devm_usb_get_phy_by_phandle()
549 struct usb_phy *phy; in devm_usb_get_phy_by_phandle()
578 void devm_usb_put_phy(struct device *dev, struct usb_phy *phy) in devm_usb_put_phy()
595 void usb_put_phy(struct usb_phy *x) in usb_put_phy()
615 int usb_add_phy(struct usb_phy *x, enum usb_phy_type type) in usb_add_phy()
619 struct usb_phy *phy; in usb_add_phy()
661 int usb_add_phy_dev(struct usb_phy *x) in usb_add_phy_dev()
692 void usb_remove_phy(struct usb_phy *x) in usb_remove_phy()
709 void usb_phy_set_event(struct usb_phy *x, unsigned long event) in usb_phy_set_event()