tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / linux / usb_notify.h
1 /*
2  *  usb notify header
3  *
4  * Copyright (C) 2011-2013 Samsung, Inc.
5  * Author: Dongrak Shin <dongrak.shin@samsung.com>
6  *
7 */
8
9 #ifndef __LINUX_USB_NOTIFY_H__
10 #define __LINUX_USB_NOTIFY_H__
11
12 #include <linux/notifier.h>
13 #include <linux/host_notify.h>
14
15 enum otg_notify_events {
16         NOTIFY_EVENT_NONE,
17         NOTIFY_EVENT_VBUS,
18         NOTIFY_EVENT_HOST,
19         NOTIFY_EVENT_CHARGER,
20         NOTIFY_EVENT_SMARTDOCK_TA,
21         NOTIFY_EVENT_SMARTDOCK_USB,
22         NOTIFY_EVENT_AUDIODOCK,
23         NOTIFY_EVENT_LANHUB,
24         NOTIFY_EVENT_LANHUB_TA,
25         NOTIFY_EVENT_MMDOCK,
26         NOTIFY_EVENT_DRIVE_VBUS,
27         NOTIFY_EVENT_OVERCURRENT,
28         NOTIFY_EVENT_SMSC_OVC,
29         NOTIFY_EVENT_SMTD_EXT_CURRENT,
30         NOTIFY_EVENT_MMD_EXT_CURRENT,
31         NOTIFY_EVENT_VBUSPOWER,
32 };
33
34 enum otg_notify_evt_type {
35         NOTIFY_EVENT_EXTRA = (1 << 0),
36         NOTIFY_EVENT_STATE = (1 << 1),
37         NOTIFY_EVENT_DELAY = (1 << 2),
38 };
39
40 enum otg_notify_gpio {
41         NOTIFY_VBUS,
42         NOTIFY_REDRIVER,
43 };
44
45 enum ovc_check_value {
46         HNOTIFY_LOW,
47         HNOTIFY_HIGH,
48         HNOTIFY_INITIAL,
49 };
50
51 struct otg_notify {
52         struct atomic_notifier_head     otg_notifier;
53         struct blocking_notifier_head extra_notifier;
54         int vbus_detect_gpio;
55         int redriver_en_gpio;
56         int is_wakelock;
57         int unsupport_host;
58         int smsc_ovc_poll_sec;
59         int auto_drive_vbus;
60         int booting_delay_sec;
61         const char *muic_name;
62         int (*pre_gpio) (int gpio, int use);
63         int (*post_gpio) (int gpio, int use);
64         int (*vbus_drive) (bool);
65         int (*set_host) (bool);
66         int (*set_peripheral)(bool);
67         int (*set_charger)(bool);
68         int (*post_vbus_detect)(bool);
69         int (*set_lanhubta)(int);
70         int (*set_battcall)(int, int);
71         void *o_data;
72 };
73
74 struct otg_booster {
75         char *name;
76         int (*booster) (bool);
77 };
78
79 #ifdef CONFIG_USB_NOTIFY_LAYER
80 extern void send_otg_notify(struct otg_notify *n,
81                                         unsigned long event, int enable);
82 extern struct otg_booster *find_get_booster(void);
83 extern int register_booster(struct otg_booster *b);
84 extern int register_ovc_func(int (*check_state)(void *), void *data);
85 extern int get_usb_mode(void);
86 extern unsigned long get_cable_type(void);
87 extern void *get_notify_data(struct otg_notify *n);
88 extern void set_notify_data(struct otg_notify *n, void *data);
89 extern struct otg_notify *get_otg_notify(void);
90 extern int set_otg_notify(struct otg_notify *n);
91 extern void put_otg_notify(struct otg_notify *n);
92 #else
93 static inline void send_otg_notify(struct otg_notify *n,
94                                         unsigned long event, int enable) { }
95 static inline struct otg_booster *find_get_booster(void) {return NULL; }
96 static inline int register_booster(struct otg_booster *b) {return 0; }
97 static inline int register_ovc_func
98                 (int (*check_state)(void *), void *data) {return 0; }
99 static inline int get_usb_mode(void) {return 0; }
100 static inline unsigned long get_cable_type(void) {return 0; }
101 static inline void *get_notify_data(struct otg_notify *n) {return NULL; }
102 static inline void set_notify_data(struct otg_notify *n, void *data) {}
103 static inline struct otg_notify *get_otg_notify(void) {return NULL; }
104 static inline int set_otg_notify(struct otg_notify *n) {return 0; }
105 static inline void put_otg_notify(struct otg_notify *n) {}
106 #endif
107
108 #endif /* __LINUX_USB_NOTIFY_H__ */