4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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.
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
17 #ifndef RENESAS_USB_MOD_H
18 #define RENESAS_USB_MOD_H
20 #include <linux/spinlock.h>
21 #include <linux/usb/renesas_usbhs.h>
27 struct usbhs_irq_state {
39 * entry point from common.c
41 int (*start)(struct usbhs_priv *priv);
42 int (*stop)(struct usbhs_priv *priv);
49 int (*irq_dev_state)(struct usbhs_priv *priv,
50 struct usbhs_irq_state *irq_state);
53 int (*irq_ctrl_stage)(struct usbhs_priv *priv,
54 struct usbhs_irq_state *irq_state);
57 int (*irq_empty)(struct usbhs_priv *priv,
58 struct usbhs_irq_state *irq_state);
62 int (*irq_ready)(struct usbhs_priv *priv,
63 struct usbhs_irq_state *irq_state);
71 int (*irq_attch)(struct usbhs_priv *priv,
72 struct usbhs_irq_state *irq_state);
75 int (*irq_dtch)(struct usbhs_priv *priv,
76 struct usbhs_irq_state *irq_state);
79 int (*irq_sign)(struct usbhs_priv *priv,
80 struct usbhs_irq_state *irq_state);
83 int (*irq_sack)(struct usbhs_priv *priv,
84 struct usbhs_irq_state *irq_state);
86 struct usbhs_priv *priv;
89 struct usbhs_mod_info {
90 struct usbhs_mod *mod[USBHS_MAX];
91 struct usbhs_mod *curt; /* current mod */
96 * This function will be used as autonomy mode
97 * when platform cannot call notify_hotplug.
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.
103 int (*irq_vbus)(struct usbhs_priv *priv,
104 struct usbhs_irq_state *irq_state);
108 * for host/gadget module
110 struct usbhs_mod *usbhs_mod_get(struct usbhs_priv *priv, int id);
111 struct usbhs_mod *usbhs_mod_get_current(struct usbhs_priv *priv);
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);
118 void usbhs_mod_autonomy_mode(struct usbhs_priv *priv);
123 int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state);
124 int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state);
129 void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
132 #define usbhs_mod_call(priv, func, param...) \
134 struct usbhs_mod *mod; \
135 mod = usbhs_mod_get_current(priv); \
142 * host / gadget control
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);
149 static inline int usbhs_mod_host_probe(struct usbhs_priv *priv)
153 static inline void usbhs_mod_host_remove(struct usbhs_priv *priv)
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);
163 static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
167 static inline void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
172 #endif /* RENESAS_USB_MOD_H */