Home | History | Annotate | Line # | Download | only in usb
motgvar.h revision 1.2.4.1.4.1
      1  1.2.4.1.4.1   skrll /*	$NetBSD: motgvar.h,v 1.2.4.1.4.1 2016/09/06 20:33:09 skrll Exp $	*/
      2          1.1  bouyer 
      3          1.1  bouyer /*
      4          1.1  bouyer  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5          1.1  bouyer  * All rights reserved.
      6          1.1  bouyer  *
      7          1.1  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8          1.1  bouyer  * by Lennart Augustsson (lennart (at) augustsson.net) at
      9          1.1  bouyer  * Carlstedt Research & Technology.
     10          1.1  bouyer  *
     11          1.1  bouyer  * Redistribution and use in source and binary forms, with or without
     12          1.1  bouyer  * modification, are permitted provided that the following conditions
     13          1.1  bouyer  * are met:
     14          1.1  bouyer  * 1. Redistributions of source code must retain the above copyright
     15          1.1  bouyer  *    notice, this list of conditions and the following disclaimer.
     16          1.1  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     17          1.1  bouyer  *    notice, this list of conditions and the following disclaimer in the
     18          1.1  bouyer  *    documentation and/or other materials provided with the distribution.
     19          1.1  bouyer  *
     20          1.1  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21          1.1  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22          1.1  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23          1.1  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24          1.1  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25          1.1  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26          1.1  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27          1.1  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28          1.1  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29          1.1  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30          1.1  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     31          1.1  bouyer  */
     32          1.1  bouyer 
     33          1.1  bouyer #ifndef _MOTGVAR_H_
     34          1.1  bouyer #define _MOTGVAR_H_
     35          1.1  bouyer 
     36          1.1  bouyer struct motg_pipe {
     37          1.1  bouyer 	struct usbd_pipe pipe;
     38          1.1  bouyer 	int nexttoggle;
     39          1.1  bouyer 	struct motg_hw_ep *hw_ep; /* pointer to the hardware EP used */
     40  1.2.4.1.4.1   skrll 	SIMPLEQ_ENTRY(motg_pipe) ep_pipe_list;
     41          1.1  bouyer };
     42          1.1  bouyer 
     43          1.1  bouyer /* description of a hardware endpoint */
     44          1.1  bouyer typedef enum {
     45          1.1  bouyer 	IDLE = 0,
     46          1.1  bouyer 	SETUP,
     47          1.1  bouyer 	DATA_IN,
     48          1.1  bouyer 	DATA_OUT,
     49          1.1  bouyer 	STATUS_IN,
     50          1.1  bouyer 	STATUS_OUT,
     51          1.1  bouyer } usb_phase_t;
     52          1.1  bouyer 
     53          1.1  bouyer SIMPLEQ_HEAD(ep_pipes_head, motg_pipe);
     54          1.1  bouyer struct motg_hw_ep {
     55          1.1  bouyer 	int ep_number;
     56          1.1  bouyer 	int ep_fifo_size;
     57  1.2.4.1.4.1   skrll 	struct usbd_xfer *xfer;	/* active xfer on this EP */
     58          1.1  bouyer 	char *data; /* pointer to data to be transmitted/received */
     59          1.1  bouyer 	int datalen; /* data len to be transmitted */
     60          1.1  bouyer 	usb_phase_t phase; /* current phase of the transfer, if any */
     61          1.1  bouyer 	int refcount; /* how many devices using this EP */
     62          1.1  bouyer 	struct ep_pipes_head ep_pipes; /* list of pipes using this EP */
     63          1.1  bouyer 	bool need_short_xfer;
     64          1.1  bouyer };
     65          1.1  bouyer #define MOTG_MAX_HW_EP 16
     66          1.1  bouyer 
     67          1.1  bouyer struct motg_softc {
     68          1.1  bouyer 	device_t sc_dev;
     69          1.1  bouyer 	struct usbd_bus sc_bus;
     70          1.1  bouyer 	bus_space_tag_t sc_iot;
     71          1.1  bouyer 	bus_space_handle_t sc_ioh;
     72          1.1  bouyer 	int sc_size;
     73          1.1  bouyer 	int sc_mode;
     74          1.1  bouyer #define MOTG_MODE_HOST	0
     75          1.1  bouyer #define MOTG_MODE_DEVICE 1
     76          1.1  bouyer 	void (*sc_intr_poll)(void *);
     77          1.1  bouyer 	void *sc_intr_poll_arg;
     78      1.2.4.1  martin 	int sc_ep_max;
     79      1.2.4.1  martin 	u_int sc_ep_fifosize;
     80          1.1  bouyer 
     81          1.1  bouyer 	uint16_t sc_intr_tx_ep;
     82          1.1  bouyer 	uint16_t sc_intr_rx_ep;
     83          1.1  bouyer 	uint8_t  sc_intr_ctrl;
     84          1.1  bouyer 
     85          1.1  bouyer 	struct motg_hw_ep sc_in_ep[MOTG_MAX_HW_EP];
     86          1.1  bouyer 	struct motg_hw_ep sc_out_ep[MOTG_MAX_HW_EP];
     87          1.1  bouyer 
     88          1.1  bouyer 	kmutex_t sc_lock;
     89          1.1  bouyer 	kmutex_t sc_intr_lock;
     90          1.1  bouyer 	int sc_dying;
     91          1.1  bouyer 
     92          1.1  bouyer 	pool_cache_t sc_xferpool;
     93          1.1  bouyer 
     94          1.1  bouyer 	/* Info for the root hub interrupt "pipe". */
     95  1.2.4.1.4.1   skrll 	struct usbd_xfer *sc_intr_xfer;	/* root hub interrupt transfer */
     96          1.1  bouyer 
     97          1.1  bouyer 	char sc_vendor[32];		/* vendor string for root hub */
     98          1.1  bouyer 	int sc_id_vendor;		/* vendor ID for root hub */
     99          1.1  bouyer 
    100          1.1  bouyer 	int	sc_port_enabled : 1;
    101          1.1  bouyer 	int	sc_port_enabled_changed : 1;
    102          1.1  bouyer 	int	sc_port_suspended : 1;
    103          1.1  bouyer 	int	sc_port_suspended_change : 1;
    104          1.1  bouyer 	int	sc_high_speed : 1;
    105          1.1  bouyer 	int	sc_connected : 1;
    106          1.1  bouyer 	int	sc_connected_changed : 1;
    107          1.1  bouyer 	int	sc_isreset : 1;
    108          1.1  bouyer 
    109          1.1  bouyer 	device_t sc_child;		/* /dev/usb# device */
    110          1.1  bouyer };
    111          1.1  bouyer 
    112          1.1  bouyer struct motg_xfer {
    113          1.1  bouyer 	struct usbd_xfer xfer;
    114          1.1  bouyer };
    115          1.1  bouyer 
    116  1.2.4.1.4.1   skrll #define MOTG_BUS2SC(bus)	((bus)->ub_hcpriv)
    117  1.2.4.1.4.1   skrll #define MOTG_PIPE2SC(pipe)	MOTG_BUS2SC((pipe)->up_dev->ud_bus)
    118  1.2.4.1.4.1   skrll #define MOTG_XFER2SC(xfer)	MOTG_BUS2SC((xfer)->ux_bus)
    119  1.2.4.1.4.1   skrll #define MOTG_MPIPE2SC(mpipe)	MOTG_BUS2SC((mpipe)->pipe.up_dev->ud_bus)
    120          1.1  bouyer 
    121  1.2.4.1.4.1   skrll #define MOTG_XFER2MXFER(xfer)	((struct motg_xfer *)(xfer))
    122  1.2.4.1.4.1   skrll #define MOTG_PIPE2MPIPE(pipe)	((struct motg_pipe *)(pipe))
    123          1.1  bouyer 
    124  1.2.4.1.4.1   skrll int		motg_init(struct motg_softc *);
    125          1.2  bouyer int		motg_intr(struct motg_softc *, uint16_t, uint16_t, uint8_t);
    126          1.2  bouyer int		motg_intr_vbus(struct motg_softc *, int);
    127          1.1  bouyer int		motg_detach(struct motg_softc *, int);
    128          1.1  bouyer void		motg_childdet(device_t, device_t);
    129          1.1  bouyer int		motg_activate(device_t, enum devact);
    130          1.1  bouyer bool		motg_resume(device_t, const pmf_qual_t *);
    131          1.1  bouyer bool		motg_suspend(device_t, const pmf_qual_t *);
    132          1.1  bouyer 
    133          1.1  bouyer #endif /* _MOTGVAR_H_ */
    134