1 // SPDX-License-Identifier: GPL-1.0+
5 * Copyright (C) 2011 Renesas Solutions Corp.
6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef RENESAS_USB_MOD_H
19 #define RENESAS_USB_MOD_H
21 #include <linux/spinlock.h>
22 #include <linux/usb/renesas_usbhs.h>
28 struct usbhs_irq_state {
40 * entry point from common.c
42 int (*start)(struct usbhs_priv *priv);
43 int (*stop)(struct usbhs_priv *priv);
50 int (*irq_dev_state)(struct usbhs_priv *priv,
51 struct usbhs_irq_state *irq_state);
54 int (*irq_ctrl_stage)(struct usbhs_priv *priv,
55 struct usbhs_irq_state *irq_state);
58 int (*irq_empty)(struct usbhs_priv *priv,
59 struct usbhs_irq_state *irq_state);
63 int (*irq_ready)(struct usbhs_priv *priv,
64 struct usbhs_irq_state *irq_state);
72 int (*irq_attch)(struct usbhs_priv *priv,
73 struct usbhs_irq_state *irq_state);
76 int (*irq_dtch)(struct usbhs_priv *priv,
77 struct usbhs_irq_state *irq_state);
80 int (*irq_sign)(struct usbhs_priv *priv,
81 struct usbhs_irq_state *irq_state);
84 int (*irq_sack)(struct usbhs_priv *priv,
85 struct usbhs_irq_state *irq_state);
87 struct usbhs_priv *priv;
90 struct usbhs_mod_info {
91 struct usbhs_mod *mod[USBHS_MAX];
92 struct usbhs_mod *curt; /* current mod */
97 * This function will be used as autonomy mode
98 * when platform cannot call notify_hotplug.
100 * This callback cannot be member of "struct usbhs_mod"
101 * because it will be used even though
102 * host/gadget has not been selected.
104 int (*irq_vbus)(struct usbhs_priv *priv,
105 struct usbhs_irq_state *irq_state);
109 * for host/gadget module
111 struct usbhs_mod *usbhs_mod_get(struct usbhs_priv *priv, int id);
112 struct usbhs_mod *usbhs_mod_get_current(struct usbhs_priv *priv);
113 void usbhs_mod_register(struct usbhs_priv *priv, struct usbhs_mod *usb, int id);
114 int usbhs_mod_is_host(struct usbhs_priv *priv);
115 int usbhs_mod_change(struct usbhs_priv *priv, int id);
116 int usbhs_mod_probe(struct usbhs_priv *priv);
117 void usbhs_mod_remove(struct usbhs_priv *priv);
119 void usbhs_mod_autonomy_mode(struct usbhs_priv *priv);
124 int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state);
125 int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state);
130 void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
133 #define usbhs_mod_call(priv, func, param...) \
135 struct usbhs_mod *mod; \
136 mod = usbhs_mod_get_current(priv); \
143 * host / gadget control
145 #if defined(CONFIG_USB_RENESAS_USBHS_HCD) || \
146 defined(CONFIG_USB_RENESAS_USBHS_HCD_MODULE)
147 extern int usbhs_mod_host_probe(struct usbhs_priv *priv);
148 extern int usbhs_mod_host_remove(struct usbhs_priv *priv);
150 static inline int usbhs_mod_host_probe(struct usbhs_priv *priv)
154 static inline void usbhs_mod_host_remove(struct usbhs_priv *priv)
159 #if defined(CONFIG_USB_RENESAS_USBHS_UDC) || \
160 defined(CONFIG_USB_RENESAS_USBHS_UDC_MODULE)
161 extern int usbhs_mod_gadget_probe(struct usbhs_priv *priv);
162 extern void usbhs_mod_gadget_remove(struct usbhs_priv *priv);
164 static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
168 static inline void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
173 #endif /* RENESAS_USB_MOD_H */