Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mod.h
Go to the documentation of this file.
1 /*
2  * Renesas USB driver
3  *
4  * Copyright (C) 2011 Renesas Solutions Corp.
5  * Kuninori Morimoto <[email protected]>
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  */
17 #ifndef RENESAS_USB_MOD_H
18 #define RENESAS_USB_MOD_H
19 
20 #include <linux/spinlock.h>
22 #include "common.h"
23 
24 /*
25  * struct
26  */
33 };
34 
35 struct usbhs_mod {
36  char *name;
37 
38  /*
39  * entry point from common.c
40  */
41  int (*start)(struct usbhs_priv *priv);
42  int (*stop)(struct usbhs_priv *priv);
43 
44  /*
45  * INTSTS0
46  */
47 
48  /* DVST (DVSQ) */
50  struct usbhs_irq_state *irq_state);
51 
52  /* CTRT (CTSQ) */
54  struct usbhs_irq_state *irq_state);
55 
56  /* BEMP / BEMPSTS */
58  struct usbhs_irq_state *irq_state);
60 
61  /* BRDY / BRDYSTS */
63  struct usbhs_irq_state *irq_state);
65 
66  /*
67  * INTSTS1
68  */
69 
70  /* ATTCHE */
72  struct usbhs_irq_state *irq_state);
73 
74  /* DTCHE */
76  struct usbhs_irq_state *irq_state);
77 
78  /* SIGN */
80  struct usbhs_irq_state *irq_state);
81 
82  /* SACK */
84  struct usbhs_irq_state *irq_state);
85 
86  struct usbhs_priv *priv;
87 };
88 
91  struct usbhs_mod *curt; /* current mod */
92 
93  /*
94  * INTSTS0 :: VBINT
95  *
96  * This function will be used as autonomy mode
97  * when platform cannot call notify_hotplug.
98  *
99  * This callback cannot be member of "struct usbhs_mod"
100  * because it will be used even though
101  * host/gadget has not been selected.
102  */
104  struct usbhs_irq_state *irq_state);
105 };
106 
107 /*
108  * for host/gadget module
109  */
110 struct usbhs_mod *usbhs_mod_get(struct usbhs_priv *priv, int id);
112 void usbhs_mod_register(struct usbhs_priv *priv, struct usbhs_mod *usb, int id);
113 int usbhs_mod_is_host(struct usbhs_priv *priv);
114 int usbhs_mod_change(struct usbhs_priv *priv, int id);
115 int usbhs_mod_probe(struct usbhs_priv *priv);
116 void usbhs_mod_remove(struct usbhs_priv *priv);
117 
119 
120 /*
121  * status functions
122  */
125 
126 /*
127  * callback functions
128  */
129 void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
130 
131 
132 #define usbhs_mod_call(priv, func, param...) \
133  ({ \
134  struct usbhs_mod *mod; \
135  mod = usbhs_mod_get_current(priv); \
136  !mod ? -ENODEV : \
137  !mod->func ? 0 : \
138  mod->func(param); \
139  })
140 
141 /*
142  * host / gadget control
143  */
144 #if defined(CONFIG_USB_RENESAS_USBHS_HCD) || \
145  defined(CONFIG_USB_RENESAS_USBHS_HCD_MODULE)
146 extern int usbhs_mod_host_probe(struct usbhs_priv *priv);
147 extern int usbhs_mod_host_remove(struct usbhs_priv *priv);
148 #else
149 static inline int usbhs_mod_host_probe(struct usbhs_priv *priv)
150 {
151  return 0;
152 }
153 static inline void usbhs_mod_host_remove(struct usbhs_priv *priv)
154 {
155 }
156 #endif
157 
158 #if defined(CONFIG_USB_RENESAS_USBHS_UDC) || \
159  defined(CONFIG_USB_RENESAS_USBHS_UDC_MODULE)
160 extern int usbhs_mod_gadget_probe(struct usbhs_priv *priv);
161 extern void usbhs_mod_gadget_remove(struct usbhs_priv *priv);
162 #else
163 static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
164 {
165  return 0;
166 }
167 static inline void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
168 {
169 }
170 #endif
171 
172 #endif /* RENESAS_USB_MOD_H */