blob: 8644191e164f2ff3304c3054967c8848cf92ebcd [file] [log] [blame]
Kuninori Morimotof1407d52011-04-04 13:44:59 +09001/*
2 * Renesas USB driver
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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>
21#include <linux/usb/renesas_usbhs.h>
22#include "./common.h"
23
24/*
25 * struct
26 */
27struct usbhs_irq_state {
28 u16 intsts0;
29 u16 intsts1;
30 u16 brdysts;
31 u16 nrdysts;
32 u16 bempsts;
33 u16 dvstctr;
34};
35
36struct usbhs_mod {
37 char *name;
38
39 /*
40 * entry point from common.c
41 */
42 int (*start)(struct usbhs_priv *priv);
43 int (*stop)(struct usbhs_priv *priv);
44
45 /* INTSTS0 :: DVST (DVSQ) */
46 int (*irq_dev_state)(struct usbhs_priv *priv,
47 struct usbhs_irq_state *irq_state);
48
49 /* INTSTS0 :: CTRT (CTSQ) */
50 int (*irq_ctrl_stage)(struct usbhs_priv *priv,
51 struct usbhs_irq_state *irq_state);
52
53 /* INTSTS0 :: BEMP */
54 /* BEMPSTS */
55 int (*irq_empty)(struct usbhs_priv *priv,
56 struct usbhs_irq_state *irq_state);
57 u16 irq_bempsts;
58
59 /* INTSTS0 :: BRDY */
60 /* BRDYSTS */
61 int (*irq_ready)(struct usbhs_priv *priv,
62 struct usbhs_irq_state *irq_state);
63 u16 irq_brdysts;
64
65 struct usbhs_priv *priv;
66};
67
68struct usbhs_mod_info {
69 struct usbhs_mod *mod[USBHS_MAX];
70 struct usbhs_mod *curt; /* current mod */
71};
72
73/*
74 * for host/gadget module
75 */
76struct usbhs_mod *usbhs_mod_get(struct usbhs_priv *priv, int id);
77struct usbhs_mod *usbhs_mod_get_current(struct usbhs_priv *priv);
78void usbhs_mod_register(struct usbhs_priv *priv, struct usbhs_mod *usb, int id);
79int usbhs_mod_is_host(struct usbhs_priv *priv, struct usbhs_mod *mod);
80int usbhs_mod_change(struct usbhs_priv *priv, int id);
81int usbhs_mod_probe(struct usbhs_priv *priv);
82void usbhs_mod_remove(struct usbhs_priv *priv);
83
84/*
85 * status functions
86 */
87int usbhs_status_get_usb_speed(struct usbhs_irq_state *irq_state);
88int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state);
89int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state);
90
91/*
92 * callback functions
93 */
94void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
95
96
97#define usbhs_mod_call(priv, func, param...) \
98 ({ \
99 struct usbhs_mod *mod; \
100 mod = usbhs_mod_get_current(priv); \
101 !mod ? -ENODEV : \
102 !mod->func ? 0 : \
103 mod->func(param); \
104 })
105
Kuninori Morimoto2f983822011-04-05 11:40:54 +0900106/*
107 * gadget control
108 */
109#ifdef CONFIG_USB_RENESAS_USBHS_UDC
110extern int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv);
111extern void __devexit usbhs_mod_gadget_remove(struct usbhs_priv *priv);
112#else
113static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
114{
115 return 0;
116}
117static inline void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
118{
119}
120#endif
121
Kuninori Morimotof1407d52011-04-04 13:44:59 +0900122#endif /* RENESAS_USB_MOD_H */