aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/phy.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb/phy.h')
-rw-r--r--include/linux/usb/phy.h54
1 files changed, 53 insertions, 1 deletions
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 299245105610..8c6914873a16 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -12,6 +12,7 @@
12#include <linux/extcon.h> 12#include <linux/extcon.h>
13#include <linux/notifier.h> 13#include <linux/notifier.h>
14#include <linux/usb.h> 14#include <linux/usb.h>
15#include <uapi/linux/usb/charger.h>
15 16
16enum usb_phy_interface { 17enum usb_phy_interface {
17 USBPHY_INTERFACE_MODE_UNKNOWN, 18 USBPHY_INTERFACE_MODE_UNKNOWN,
@@ -72,6 +73,17 @@ struct usb_phy_io_ops {
72 int (*write)(struct usb_phy *x, u32 val, u32 reg); 73 int (*write)(struct usb_phy *x, u32 val, u32 reg);
73}; 74};
74 75
76struct usb_charger_current {
77 unsigned int sdp_min;
78 unsigned int sdp_max;
79 unsigned int dcp_min;
80 unsigned int dcp_max;
81 unsigned int cdp_min;
82 unsigned int cdp_max;
83 unsigned int aca_min;
84 unsigned int aca_max;
85};
86
75struct usb_phy { 87struct usb_phy {
76 struct device *dev; 88 struct device *dev;
77 const char *label; 89 const char *label;
@@ -91,6 +103,13 @@ struct usb_phy {
91 struct extcon_dev *id_edev; 103 struct extcon_dev *id_edev;
92 struct notifier_block vbus_nb; 104 struct notifier_block vbus_nb;
93 struct notifier_block id_nb; 105 struct notifier_block id_nb;
106 struct notifier_block type_nb;
107
108 /* Support USB charger */
109 enum usb_charger_type chg_type;
110 enum usb_charger_state chg_state;
111 struct usb_charger_current chg_cur;
112 struct work_struct chg_work;
94 113
95 /* for notification of usb_phy_events */ 114 /* for notification of usb_phy_events */
96 struct atomic_notifier_head notifier; 115 struct atomic_notifier_head notifier;
@@ -129,6 +148,12 @@ struct usb_phy {
129 enum usb_device_speed speed); 148 enum usb_device_speed speed);
130 int (*notify_disconnect)(struct usb_phy *x, 149 int (*notify_disconnect)(struct usb_phy *x,
131 enum usb_device_speed speed); 150 enum usb_device_speed speed);
151
152 /*
153 * Charger detection method can be implemented if you need to
154 * manually detect the charger type.
155 */
156 enum usb_charger_type (*charger_detect)(struct usb_phy *x);
132}; 157};
133 158
134/** 159/**
@@ -219,6 +244,12 @@ extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
219extern int usb_bind_phy(const char *dev_name, u8 index, 244extern int usb_bind_phy(const char *dev_name, u8 index,
220 const char *phy_dev_name); 245 const char *phy_dev_name);
221extern void usb_phy_set_event(struct usb_phy *x, unsigned long event); 246extern void usb_phy_set_event(struct usb_phy *x, unsigned long event);
247extern void usb_phy_set_charger_current(struct usb_phy *usb_phy,
248 unsigned int mA);
249extern void usb_phy_get_charger_current(struct usb_phy *usb_phy,
250 unsigned int *min, unsigned int *max);
251extern void usb_phy_set_charger_state(struct usb_phy *usb_phy,
252 enum usb_charger_state state);
222#else 253#else
223static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) 254static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
224{ 255{
@@ -270,12 +301,33 @@ static inline int usb_bind_phy(const char *dev_name, u8 index,
270static inline void usb_phy_set_event(struct usb_phy *x, unsigned long event) 301static inline void usb_phy_set_event(struct usb_phy *x, unsigned long event)
271{ 302{
272} 303}
304
305static inline void usb_phy_set_charger_current(struct usb_phy *usb_phy,
306 unsigned int mA)
307{
308}
309
310static inline void usb_phy_get_charger_current(struct usb_phy *usb_phy,
311 unsigned int *min,
312 unsigned int *max)
313{
314}
315
316static inline void usb_phy_set_charger_state(struct usb_phy *usb_phy,
317 enum usb_charger_state state)
318{
319}
273#endif 320#endif
274 321
275static inline int 322static inline int
276usb_phy_set_power(struct usb_phy *x, unsigned mA) 323usb_phy_set_power(struct usb_phy *x, unsigned mA)
277{ 324{
278 if (x && x->set_power) 325 if (!x)
326 return 0;
327
328 usb_phy_set_charger_current(x, mA);
329
330 if (x->set_power)
279 return x->set_power(x, mA); 331 return x->set_power(x, mA);
280 return 0; 332 return 0;
281} 333}