Lines Matching full:usb_phy
33 struct usb_phy *phy;
45 static struct usb_phy *__usb_find_phy(struct list_head *list, in __usb_find_phy()
48 struct usb_phy *phy = NULL; in __usb_find_phy()
60 static struct usb_phy *__of_usb_find_phy(struct device_node *node) in __of_usb_find_phy()
62 struct usb_phy *phy; in __of_usb_find_phy()
77 static void usb_phy_set_default_current(struct usb_phy *usb_phy) in usb_phy_set_default_current() argument
79 usb_phy->chg_cur.sdp_min = DEFAULT_SDP_CUR_MIN; in usb_phy_set_default_current()
80 usb_phy->chg_cur.sdp_max = DEFAULT_SDP_CUR_MAX; in usb_phy_set_default_current()
81 usb_phy->chg_cur.dcp_min = DEFAULT_DCP_CUR_MIN; in usb_phy_set_default_current()
82 usb_phy->chg_cur.dcp_max = DEFAULT_DCP_CUR_MAX; in usb_phy_set_default_current()
83 usb_phy->chg_cur.cdp_min = DEFAULT_CDP_CUR_MIN; in usb_phy_set_default_current()
84 usb_phy->chg_cur.cdp_max = DEFAULT_CDP_CUR_MAX; in usb_phy_set_default_current()
85 usb_phy->chg_cur.aca_min = DEFAULT_ACA_CUR_MIN; in usb_phy_set_default_current()
86 usb_phy->chg_cur.aca_max = DEFAULT_ACA_CUR_MAX; in usb_phy_set_default_current()
107 struct usb_phy *usb_phy = container_of(work, struct usb_phy, chg_work); in usb_phy_notify_charger_work() local
113 switch (usb_phy->chg_state) { in usb_phy_notify_charger_work()
115 usb_phy_get_charger_current(usb_phy, &min, &max); in usb_phy_notify_charger_work()
117 atomic_notifier_call_chain(&usb_phy->notifier, max, usb_phy); in usb_phy_notify_charger_work()
122 usb_phy_set_default_current(usb_phy); in usb_phy_notify_charger_work()
124 atomic_notifier_call_chain(&usb_phy->notifier, 0, usb_phy); in usb_phy_notify_charger_work()
129 dev_warn(usb_phy->dev, "Unknown USB charger state: %d\n", in usb_phy_notify_charger_work()
130 usb_phy->chg_state); in usb_phy_notify_charger_work()
135 "USB_CHARGER_TYPE=%s", usb_chger_type[usb_phy->chg_type]); in usb_phy_notify_charger_work()
136 kobject_uevent_env(&usb_phy->dev->kobj, KOBJ_CHANGE, envp); in usb_phy_notify_charger_work()
139 static void __usb_phy_get_charger_type(struct usb_phy *usb_phy) in __usb_phy_get_charger_type() argument
141 if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_SDP) > 0) { in __usb_phy_get_charger_type()
142 usb_phy->chg_type = SDP_TYPE; in __usb_phy_get_charger_type()
143 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
144 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_CDP) > 0) { in __usb_phy_get_charger_type()
145 usb_phy->chg_type = CDP_TYPE; in __usb_phy_get_charger_type()
146 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
147 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_DCP) > 0) { in __usb_phy_get_charger_type()
148 usb_phy->chg_type = DCP_TYPE; in __usb_phy_get_charger_type()
149 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
150 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_ACA) > 0) { in __usb_phy_get_charger_type()
151 usb_phy->chg_type = ACA_TYPE; in __usb_phy_get_charger_type()
152 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
154 usb_phy->chg_type = UNKNOWN_TYPE; in __usb_phy_get_charger_type()
155 usb_phy->chg_state = USB_CHARGER_ABSENT; in __usb_phy_get_charger_type()
158 schedule_work(&usb_phy->chg_work); in __usb_phy_get_charger_type()
173 struct usb_phy *usb_phy = container_of(nb, struct usb_phy, type_nb); in usb_phy_get_charger_type() local
175 __usb_phy_get_charger_type(usb_phy); in usb_phy_get_charger_type()
181 * @usb_phy: the USB phy to be used
193 void usb_phy_set_charger_current(struct usb_phy *usb_phy, unsigned int mA) in usb_phy_set_charger_current() argument
195 switch (usb_phy->chg_type) { in usb_phy_set_charger_current()
197 if (usb_phy->chg_cur.sdp_max == mA) in usb_phy_set_charger_current()
200 usb_phy->chg_cur.sdp_max = (mA > DEFAULT_SDP_CUR_MAX_SS) ? in usb_phy_set_charger_current()
204 if (usb_phy->chg_cur.dcp_max == mA) in usb_phy_set_charger_current()
207 usb_phy->chg_cur.dcp_max = (mA > DEFAULT_DCP_CUR_MAX) ? in usb_phy_set_charger_current()
211 if (usb_phy->chg_cur.cdp_max == mA) in usb_phy_set_charger_current()
214 usb_phy->chg_cur.cdp_max = (mA > DEFAULT_CDP_CUR_MAX) ? in usb_phy_set_charger_current()
218 if (usb_phy->chg_cur.aca_max == mA) in usb_phy_set_charger_current()
221 usb_phy->chg_cur.aca_max = (mA > DEFAULT_ACA_CUR_MAX) ? in usb_phy_set_charger_current()
228 schedule_work(&usb_phy->chg_work); in usb_phy_set_charger_current()
234 * @usb_phy: the USB phy to be used
242 void usb_phy_get_charger_current(struct usb_phy *usb_phy, in usb_phy_get_charger_current() argument
245 switch (usb_phy->chg_type) { in usb_phy_get_charger_current()
247 *min = usb_phy->chg_cur.sdp_min; in usb_phy_get_charger_current()
248 *max = usb_phy->chg_cur.sdp_max; in usb_phy_get_charger_current()
251 *min = usb_phy->chg_cur.dcp_min; in usb_phy_get_charger_current()
252 *max = usb_phy->chg_cur.dcp_max; in usb_phy_get_charger_current()
255 *min = usb_phy->chg_cur.cdp_min; in usb_phy_get_charger_current()
256 *max = usb_phy->chg_cur.cdp_max; in usb_phy_get_charger_current()
259 *min = usb_phy->chg_cur.aca_min; in usb_phy_get_charger_current()
260 *max = usb_phy->chg_cur.aca_max; in usb_phy_get_charger_current()
272 * @usb_phy: the USB phy to be used
279 void usb_phy_set_charger_state(struct usb_phy *usb_phy, in usb_phy_set_charger_state() argument
282 if (usb_phy->chg_state == state || !usb_phy->charger_detect) in usb_phy_set_charger_state()
285 usb_phy->chg_state = state; in usb_phy_set_charger_state()
286 if (usb_phy->chg_state == USB_CHARGER_PRESENT) in usb_phy_set_charger_state()
287 usb_phy->chg_type = usb_phy->charger_detect(usb_phy); in usb_phy_set_charger_state()
289 usb_phy->chg_type = UNKNOWN_TYPE; in usb_phy_set_charger_state()
291 schedule_work(&usb_phy->chg_work); in usb_phy_set_charger_state()
297 struct usb_phy *phy = *(struct usb_phy **)res; in devm_usb_phy_release()
313 struct usb_phy **phy = res; in devm_usb_phy_match()
318 static void usb_charger_init(struct usb_phy *usb_phy) in usb_charger_init() argument
320 usb_phy->chg_type = UNKNOWN_TYPE; in usb_charger_init()
321 usb_phy->chg_state = USB_CHARGER_DEFAULT; in usb_charger_init()
322 usb_phy_set_default_current(usb_phy); in usb_charger_init()
323 INIT_WORK(&usb_phy->chg_work, usb_phy_notify_charger_work); in usb_charger_init()
326 static int usb_add_extcon(struct usb_phy *x) in usb_add_extcon()
426 struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) in devm_usb_get_phy()
428 struct usb_phy **ptr, *phy; in devm_usb_get_phy()
455 struct usb_phy *usb_get_phy(enum usb_phy_type type) in usb_get_phy()
457 struct usb_phy *phy = NULL; in usb_get_phy()
497 struct usb_phy *devm_usb_get_phy_by_node(struct device *dev, in devm_usb_get_phy_by_node()
501 struct usb_phy *phy = ERR_PTR(-ENOMEM); in devm_usb_get_phy_by_node()
556 struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, in devm_usb_get_phy_by_phandle()
560 struct usb_phy *phy; in devm_usb_get_phy_by_phandle()
589 void devm_usb_put_phy(struct device *dev, struct usb_phy *phy) in devm_usb_put_phy()
606 void usb_put_phy(struct usb_phy *x) in usb_put_phy()
626 int usb_add_phy(struct usb_phy *x, enum usb_phy_type type) in usb_add_phy()
630 struct usb_phy *phy; in usb_add_phy()
672 int usb_add_phy_dev(struct usb_phy *x) in usb_add_phy_dev()
703 void usb_remove_phy(struct usb_phy *x) in usb_remove_phy()
721 void usb_phy_set_event(struct usb_phy *x, unsigned long event) in usb_phy_set_event()