1 // SPDX-License-Identifier: GPL-1.0+
5 * Copyright (C) 2011 Renesas Solutions Corp.
6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
8 #ifndef RENESAS_USB_MOD_H
9 #define RENESAS_USB_MOD_H
11 #include <linux/spinlock.h>
12 #include <linux/usb/renesas_usbhs.h>
18 struct usbhs_irq_state
{
30 * entry point from common.c
32 int (*start
)(struct usbhs_priv
*priv
);
33 int (*stop
)(struct usbhs_priv
*priv
);
40 int (*irq_dev_state
)(struct usbhs_priv
*priv
,
41 struct usbhs_irq_state
*irq_state
);
44 int (*irq_ctrl_stage
)(struct usbhs_priv
*priv
,
45 struct usbhs_irq_state
*irq_state
);
48 int (*irq_empty
)(struct usbhs_priv
*priv
,
49 struct usbhs_irq_state
*irq_state
);
53 int (*irq_ready
)(struct usbhs_priv
*priv
,
54 struct usbhs_irq_state
*irq_state
);
62 int (*irq_attch
)(struct usbhs_priv
*priv
,
63 struct usbhs_irq_state
*irq_state
);
66 int (*irq_dtch
)(struct usbhs_priv
*priv
,
67 struct usbhs_irq_state
*irq_state
);
70 int (*irq_sign
)(struct usbhs_priv
*priv
,
71 struct usbhs_irq_state
*irq_state
);
74 int (*irq_sack
)(struct usbhs_priv
*priv
,
75 struct usbhs_irq_state
*irq_state
);
77 struct usbhs_priv
*priv
;
80 struct usbhs_mod_info
{
81 struct usbhs_mod
*mod
[USBHS_MAX
];
82 struct usbhs_mod
*curt
; /* current mod */
87 * This function will be used as autonomy mode
88 * when platform cannot call notify_hotplug.
90 * This callback cannot be member of "struct usbhs_mod"
91 * because it will be used even though
92 * host/gadget has not been selected.
94 int (*irq_vbus
)(struct usbhs_priv
*priv
,
95 struct usbhs_irq_state
*irq_state
);
99 * for host/gadget module
101 struct usbhs_mod
*usbhs_mod_get(struct usbhs_priv
*priv
, int id
);
102 struct usbhs_mod
*usbhs_mod_get_current(struct usbhs_priv
*priv
);
103 void usbhs_mod_register(struct usbhs_priv
*priv
, struct usbhs_mod
*usb
, int id
);
104 int usbhs_mod_is_host(struct usbhs_priv
*priv
);
105 int usbhs_mod_change(struct usbhs_priv
*priv
, int id
);
106 int usbhs_mod_probe(struct usbhs_priv
*priv
);
107 void usbhs_mod_remove(struct usbhs_priv
*priv
);
109 void usbhs_mod_autonomy_mode(struct usbhs_priv
*priv
);
114 int usbhs_status_get_device_state(struct usbhs_irq_state
*irq_state
);
115 int usbhs_status_get_ctrl_stage(struct usbhs_irq_state
*irq_state
);
120 void usbhs_irq_callback_update(struct usbhs_priv
*priv
, struct usbhs_mod
*mod
);
123 #define usbhs_mod_call(priv, func, param...) \
125 struct usbhs_mod *mod; \
126 mod = usbhs_mod_get_current(priv); \
133 * host / gadget control
135 #if defined(CONFIG_USB_RENESAS_USBHS_HCD) || \
136 defined(CONFIG_USB_RENESAS_USBHS_HCD_MODULE)
137 extern int usbhs_mod_host_probe(struct usbhs_priv
*priv
);
138 extern int usbhs_mod_host_remove(struct usbhs_priv
*priv
);
140 static inline int usbhs_mod_host_probe(struct usbhs_priv
*priv
)
144 static inline void usbhs_mod_host_remove(struct usbhs_priv
*priv
)
149 #if defined(CONFIG_USB_RENESAS_USBHS_UDC) || \
150 defined(CONFIG_USB_RENESAS_USBHS_UDC_MODULE)
151 extern int usbhs_mod_gadget_probe(struct usbhs_priv
*priv
);
152 extern void usbhs_mod_gadget_remove(struct usbhs_priv
*priv
);
154 static inline int usbhs_mod_gadget_probe(struct usbhs_priv
*priv
)
158 static inline void usbhs_mod_gadget_remove(struct usbhs_priv
*priv
)
163 #endif /* RENESAS_USB_MOD_H */