Lines Matching refs:usb_phy
33 struct usb_phy *phy;
51 static struct usb_phy *__usb_find_phy(struct list_head *list, in __usb_find_phy()
54 struct usb_phy *phy = NULL; in __usb_find_phy()
66 static struct usb_phy *__of_usb_find_phy(struct device_node *node) in __of_usb_find_phy()
68 struct usb_phy *phy; in __of_usb_find_phy()
83 static struct usb_phy *__device_to_usb_phy(const struct device *dev) in __device_to_usb_phy()
85 struct usb_phy *usb_phy; in __device_to_usb_phy() local
87 list_for_each_entry(usb_phy, &phy_list, head) { in __device_to_usb_phy()
88 if (usb_phy->dev == dev) in __device_to_usb_phy()
89 return usb_phy; in __device_to_usb_phy()
95 static void usb_phy_set_default_current(struct usb_phy *usb_phy) in usb_phy_set_default_current() argument
97 usb_phy->chg_cur.sdp_min = DEFAULT_SDP_CUR_MIN; in usb_phy_set_default_current()
98 usb_phy->chg_cur.sdp_max = DEFAULT_SDP_CUR_MAX; in usb_phy_set_default_current()
99 usb_phy->chg_cur.dcp_min = DEFAULT_DCP_CUR_MIN; in usb_phy_set_default_current()
100 usb_phy->chg_cur.dcp_max = DEFAULT_DCP_CUR_MAX; in usb_phy_set_default_current()
101 usb_phy->chg_cur.cdp_min = DEFAULT_CDP_CUR_MIN; in usb_phy_set_default_current()
102 usb_phy->chg_cur.cdp_max = DEFAULT_CDP_CUR_MAX; in usb_phy_set_default_current()
103 usb_phy->chg_cur.aca_min = DEFAULT_ACA_CUR_MIN; in usb_phy_set_default_current()
104 usb_phy->chg_cur.aca_max = DEFAULT_ACA_CUR_MAX; in usb_phy_set_default_current()
125 struct usb_phy *usb_phy = container_of(work, struct usb_phy, chg_work); in usb_phy_notify_charger_work() local
128 switch (usb_phy->chg_state) { in usb_phy_notify_charger_work()
130 usb_phy_get_charger_current(usb_phy, &min, &max); in usb_phy_notify_charger_work()
132 atomic_notifier_call_chain(&usb_phy->notifier, max, usb_phy); in usb_phy_notify_charger_work()
135 usb_phy_set_default_current(usb_phy); in usb_phy_notify_charger_work()
137 atomic_notifier_call_chain(&usb_phy->notifier, 0, usb_phy); in usb_phy_notify_charger_work()
140 dev_warn(usb_phy->dev, "Unknown USB charger state: %d\n", in usb_phy_notify_charger_work()
141 usb_phy->chg_state); in usb_phy_notify_charger_work()
145 kobject_uevent(&usb_phy->dev->kobj, KOBJ_CHANGE); in usb_phy_notify_charger_work()
150 const struct usb_phy *usb_phy; in usb_phy_uevent() local
156 usb_phy = __device_to_usb_phy(dev); in usb_phy_uevent()
159 if (!usb_phy) in usb_phy_uevent()
163 "USB_CHARGER_STATE=%s", usb_chger_state[usb_phy->chg_state]); in usb_phy_uevent()
166 "USB_CHARGER_TYPE=%s", usb_chger_type[usb_phy->chg_type]); in usb_phy_uevent()
177 static void __usb_phy_get_charger_type(struct usb_phy *usb_phy) in __usb_phy_get_charger_type() argument
179 if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_SDP) > 0) { in __usb_phy_get_charger_type()
180 usb_phy->chg_type = SDP_TYPE; in __usb_phy_get_charger_type()
181 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
182 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_CDP) > 0) { in __usb_phy_get_charger_type()
183 usb_phy->chg_type = CDP_TYPE; in __usb_phy_get_charger_type()
184 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
185 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_DCP) > 0) { in __usb_phy_get_charger_type()
186 usb_phy->chg_type = DCP_TYPE; in __usb_phy_get_charger_type()
187 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
188 } else if (extcon_get_state(usb_phy->edev, EXTCON_CHG_USB_ACA) > 0) { in __usb_phy_get_charger_type()
189 usb_phy->chg_type = ACA_TYPE; in __usb_phy_get_charger_type()
190 usb_phy->chg_state = USB_CHARGER_PRESENT; in __usb_phy_get_charger_type()
192 usb_phy->chg_type = UNKNOWN_TYPE; in __usb_phy_get_charger_type()
193 usb_phy->chg_state = USB_CHARGER_ABSENT; in __usb_phy_get_charger_type()
196 schedule_work(&usb_phy->chg_work); in __usb_phy_get_charger_type()
211 struct usb_phy *usb_phy = container_of(nb, struct usb_phy, type_nb); in usb_phy_get_charger_type() local
213 __usb_phy_get_charger_type(usb_phy); in usb_phy_get_charger_type()
231 void usb_phy_set_charger_current(struct usb_phy *usb_phy, unsigned int mA) in usb_phy_set_charger_current() argument
233 switch (usb_phy->chg_type) { in usb_phy_set_charger_current()
235 if (usb_phy->chg_cur.sdp_max == mA) in usb_phy_set_charger_current()
238 usb_phy->chg_cur.sdp_max = (mA > DEFAULT_SDP_CUR_MAX_SS) ? in usb_phy_set_charger_current()
242 if (usb_phy->chg_cur.dcp_max == mA) in usb_phy_set_charger_current()
245 usb_phy->chg_cur.dcp_max = (mA > DEFAULT_DCP_CUR_MAX) ? in usb_phy_set_charger_current()
249 if (usb_phy->chg_cur.cdp_max == mA) in usb_phy_set_charger_current()
252 usb_phy->chg_cur.cdp_max = (mA > DEFAULT_CDP_CUR_MAX) ? in usb_phy_set_charger_current()
256 if (usb_phy->chg_cur.aca_max == mA) in usb_phy_set_charger_current()
259 usb_phy->chg_cur.aca_max = (mA > DEFAULT_ACA_CUR_MAX) ? in usb_phy_set_charger_current()
266 schedule_work(&usb_phy->chg_work); in usb_phy_set_charger_current()
280 void usb_phy_get_charger_current(struct usb_phy *usb_phy, in usb_phy_get_charger_current() argument
283 switch (usb_phy->chg_type) { in usb_phy_get_charger_current()
285 *min = usb_phy->chg_cur.sdp_min; in usb_phy_get_charger_current()
286 *max = usb_phy->chg_cur.sdp_max; in usb_phy_get_charger_current()
289 *min = usb_phy->chg_cur.dcp_min; in usb_phy_get_charger_current()
290 *max = usb_phy->chg_cur.dcp_max; in usb_phy_get_charger_current()
293 *min = usb_phy->chg_cur.cdp_min; in usb_phy_get_charger_current()
294 *max = usb_phy->chg_cur.cdp_max; in usb_phy_get_charger_current()
297 *min = usb_phy->chg_cur.aca_min; in usb_phy_get_charger_current()
298 *max = usb_phy->chg_cur.aca_max; in usb_phy_get_charger_current()
317 void usb_phy_set_charger_state(struct usb_phy *usb_phy, in usb_phy_set_charger_state() argument
320 if (usb_phy->chg_state == state || !usb_phy->charger_detect) in usb_phy_set_charger_state()
323 usb_phy->chg_state = state; in usb_phy_set_charger_state()
324 if (usb_phy->chg_state == USB_CHARGER_PRESENT) in usb_phy_set_charger_state()
325 usb_phy->chg_type = usb_phy->charger_detect(usb_phy); in usb_phy_set_charger_state()
327 usb_phy->chg_type = UNKNOWN_TYPE; in usb_phy_set_charger_state()
329 schedule_work(&usb_phy->chg_work); in usb_phy_set_charger_state()
335 struct usb_phy *phy = *(struct usb_phy **)res; in devm_usb_phy_release()
351 struct usb_phy **phy = res; in devm_usb_phy_match()
356 static void usb_charger_init(struct usb_phy *usb_phy) in usb_charger_init() argument
358 usb_phy->chg_type = UNKNOWN_TYPE; in usb_charger_init()
359 usb_phy->chg_state = USB_CHARGER_DEFAULT; in usb_charger_init()
360 usb_phy_set_default_current(usb_phy); in usb_charger_init()
361 INIT_WORK(&usb_phy->chg_work, usb_phy_notify_charger_work); in usb_charger_init()
364 static int usb_add_extcon(struct usb_phy *x) in usb_add_extcon()
464 struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) in devm_usb_get_phy()
466 struct usb_phy **ptr, *phy; in devm_usb_get_phy()
493 struct usb_phy *usb_get_phy(enum usb_phy_type type) in usb_get_phy()
495 struct usb_phy *phy = NULL; in usb_get_phy()
535 struct usb_phy *devm_usb_get_phy_by_node(struct device *dev, in devm_usb_get_phy_by_node()
539 struct usb_phy *phy = ERR_PTR(-ENOMEM); in devm_usb_get_phy_by_node()
594 struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, in devm_usb_get_phy_by_phandle()
598 struct usb_phy *phy; in devm_usb_get_phy_by_phandle()
627 void devm_usb_put_phy(struct device *dev, struct usb_phy *phy) in devm_usb_put_phy()
644 void usb_put_phy(struct usb_phy *x) in usb_put_phy()
664 int usb_add_phy(struct usb_phy *x, enum usb_phy_type type) in usb_add_phy()
668 struct usb_phy *phy; in usb_add_phy()
715 int usb_add_phy_dev(struct usb_phy *x) in usb_add_phy_dev()
748 void usb_remove_phy(struct usb_phy *x) in usb_remove_phy()
766 void usb_phy_set_event(struct usb_phy *x, unsigned long event) in usb_phy_set_event()