Linux Audio

Check our new training course

Loading...
v3.1
 
  1/*
  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	 * INTSTS0 :: VBINT
 74	 *
 75	 * This function will be used as autonomy mode
 76	 * when platform cannot call notify_hotplug.
 77	 *
 78	 * This callback cannot be member of "struct usbhs_mod"
 79	 * because it will be used even though
 80	 * host/gadget has not been selected.
 81	 */
 82	int (*irq_vbus)(struct usbhs_priv *priv,
 83			struct usbhs_irq_state *irq_state);
 84};
 85
 86/*
 87 *		for host/gadget module
 88 */
 89struct usbhs_mod *usbhs_mod_get(struct usbhs_priv *priv, int id);
 90struct usbhs_mod *usbhs_mod_get_current(struct usbhs_priv *priv);
 91void usbhs_mod_register(struct usbhs_priv *priv, struct usbhs_mod *usb, int id);
 92int usbhs_mod_is_host(struct usbhs_priv *priv, struct usbhs_mod *mod);
 93int usbhs_mod_change(struct usbhs_priv *priv, int id);
 94int usbhs_mod_probe(struct usbhs_priv *priv);
 95void usbhs_mod_remove(struct usbhs_priv *priv);
 96
 97void usbhs_mod_autonomy_mode(struct usbhs_priv *priv);
 98
 99/*
100 *		status functions
101 */
102int usbhs_status_get_usb_speed(struct usbhs_irq_state *irq_state);
103int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state);
104int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state);
105
106/*
107 *		callback functions
108 */
109void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
110
111
112#define usbhs_mod_call(priv, func, param...)		\
113	({						\
114		struct usbhs_mod *mod;			\
115		mod = usbhs_mod_get_current(priv);	\
116		!mod		? -ENODEV :		\
117		!mod->func	? 0 :			\
118		 mod->func(param);			\
119	})
120
121/*
122 * gadget control
123 */
124#ifdef CONFIG_USB_RENESAS_USBHS_UDC
125extern int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv);
126extern void __devexit usbhs_mod_gadget_remove(struct usbhs_priv *priv);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127#else
128static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
129{
130	return 0;
131}
132static inline void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
133{
134}
135#endif
136
137#endif /* RENESAS_USB_MOD_H */
v4.17
  1// SPDX-License-Identifier: GPL-1.0+
  2/*
  3 * Renesas USB driver
  4 *
  5 * Copyright (C) 2011 Renesas Solutions Corp.
  6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
 
 
 
 
 
 
 
 
 
 
  7 */
  8#ifndef RENESAS_USB_MOD_H
  9#define RENESAS_USB_MOD_H
 10
 11#include <linux/spinlock.h>
 12#include <linux/usb/renesas_usbhs.h>
 13#include "common.h"
 14
 15/*
 16 *	struct
 17 */
 18struct usbhs_irq_state {
 19	u16 intsts0;
 20	u16 intsts1;
 21	u16 brdysts;
 22	u16 nrdysts;
 23	u16 bempsts;
 
 24};
 25
 26struct usbhs_mod {
 27	char *name;
 28
 29	/*
 30	 * entry point from common.c
 31	 */
 32	int (*start)(struct usbhs_priv *priv);
 33	int (*stop)(struct usbhs_priv *priv);
 34
 35	/*
 36	 * INTSTS0
 37	 */
 38
 39	/* DVST (DVSQ) */
 40	int (*irq_dev_state)(struct usbhs_priv *priv,
 41			     struct usbhs_irq_state *irq_state);
 42
 43	/* CTRT (CTSQ) */
 44	int (*irq_ctrl_stage)(struct usbhs_priv *priv,
 45			      struct usbhs_irq_state *irq_state);
 46
 47	/* BEMP / BEMPSTS */
 
 48	int (*irq_empty)(struct usbhs_priv *priv,
 49			 struct usbhs_irq_state *irq_state);
 50	u16 irq_bempsts;
 51
 52	/* BRDY / BRDYSTS */
 
 53	int (*irq_ready)(struct usbhs_priv *priv,
 54			 struct usbhs_irq_state *irq_state);
 55	u16 irq_brdysts;
 56
 57	/*
 58	 * INTSTS1
 59	 */
 60
 61	/* ATTCHE */
 62	int (*irq_attch)(struct usbhs_priv *priv,
 63			 struct usbhs_irq_state *irq_state);
 64
 65	/* DTCHE */
 66	int (*irq_dtch)(struct usbhs_priv *priv,
 67			struct usbhs_irq_state *irq_state);
 68
 69	/* SIGN */
 70	int (*irq_sign)(struct usbhs_priv *priv,
 71			struct usbhs_irq_state *irq_state);
 72
 73	/* SACK */
 74	int (*irq_sack)(struct usbhs_priv *priv,
 75			struct usbhs_irq_state *irq_state);
 76
 77	struct usbhs_priv *priv;
 78};
 79
 80struct usbhs_mod_info {
 81	struct usbhs_mod *mod[USBHS_MAX];
 82	struct usbhs_mod *curt; /* current mod */
 83
 84	/*
 85	 * INTSTS0 :: VBINT
 86	 *
 87	 * This function will be used as autonomy mode
 88	 * when platform cannot call notify_hotplug.
 89	 *
 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.
 93	 */
 94	int (*irq_vbus)(struct usbhs_priv *priv,
 95			struct usbhs_irq_state *irq_state);
 96};
 97
 98/*
 99 *		for host/gadget module
100 */
101struct usbhs_mod *usbhs_mod_get(struct usbhs_priv *priv, int id);
102struct usbhs_mod *usbhs_mod_get_current(struct usbhs_priv *priv);
103void usbhs_mod_register(struct usbhs_priv *priv, struct usbhs_mod *usb, int id);
104int usbhs_mod_is_host(struct usbhs_priv *priv);
105int usbhs_mod_change(struct usbhs_priv *priv, int id);
106int usbhs_mod_probe(struct usbhs_priv *priv);
107void usbhs_mod_remove(struct usbhs_priv *priv);
108
109void usbhs_mod_autonomy_mode(struct usbhs_priv *priv);
110
111/*
112 *		status functions
113 */
 
114int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state);
115int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state);
116
117/*
118 *		callback functions
119 */
120void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
121
122
123#define usbhs_mod_call(priv, func, param...)		\
124	({						\
125		struct usbhs_mod *mod;			\
126		mod = usbhs_mod_get_current(priv);	\
127		!mod		? -ENODEV :		\
128		!mod->func	? 0 :			\
129		 mod->func(param);			\
130	})
131
132/*
133 * host / gadget control
134 */
135#if	defined(CONFIG_USB_RENESAS_USBHS_HCD) || \
136	defined(CONFIG_USB_RENESAS_USBHS_HCD_MODULE)
137extern int usbhs_mod_host_probe(struct usbhs_priv *priv);
138extern int usbhs_mod_host_remove(struct usbhs_priv *priv);
139#else
140static inline int usbhs_mod_host_probe(struct usbhs_priv *priv)
141{
142	return 0;
143}
144static inline void usbhs_mod_host_remove(struct usbhs_priv *priv)
145{
146}
147#endif
148
149#if	defined(CONFIG_USB_RENESAS_USBHS_UDC) || \
150	defined(CONFIG_USB_RENESAS_USBHS_UDC_MODULE)
151extern int usbhs_mod_gadget_probe(struct usbhs_priv *priv);
152extern void usbhs_mod_gadget_remove(struct usbhs_priv *priv);
153#else
154static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
155{
156	return 0;
157}
158static inline void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
159{
160}
161#endif
162
163#endif /* RENESAS_USB_MOD_H */