Home | History | Annotate | Line # | Download | only in ic
sl811hsvar.h revision 1.9
      1 /*	$NetBSD: sl811hsvar.h,v 1.9 2012/10/27 17:18:22 chs Exp $	*/
      2 
      3 /*
      4  * Not (c) 2007 Matthew Orgass
      5  * This file is public domain, meaning anyone can make any use of part or all
      6  * of this file including copying into other works without credit.  Any use,
      7  * modified or not, is solely the responsibility of the user.  If this file is
      8  * part of a collection then use in the collection is governed by the terms of
      9  * the collection.
     10  */
     11 
     12 /*
     13  * Cypress/ScanLogic SL811HS USB Host Controller
     14  */
     15 
     16 #include <sys/gcq.h>
     17 #include <sys/simplelock.h>
     18 
     19 #define SC_DEV(sc)	((sc)->sc_dev)
     20 #define SC_NAME(sc)	(device_xname(SC_DEV(sc)))
     21 
     22 typedef unsigned int Frame;
     23 struct slhci_pipe;
     24 
     25 /* Generally transfer related items. */
     26 struct slhci_transfers {
     27 	struct usbd_xfer *rootintr;
     28 	struct slhci_pipe *spipe[2]; 	/* current transfer (unless canceled) */
     29 	struct gcq_head q[3];		/* transfer queues, Q_* index */
     30 	struct gcq_head timed;		/* intr transfer multi-frame wait */
     31 	struct gcq_head to;		/* timeout list */
     32 	struct gcq_head ap;		/* all pipes */
     33 	Frame frame;			/* current frame */
     34 	unsigned int flags;		/* F_* flags */
     35 	int pend;			/* pending for waitintr */
     36 	int reserved_bustime;
     37 	int16_t len[2];		     	/* length of transfer or -1 if none */
     38 	uint8_t current_tregs[2][4]; 	/* ab, ADR, LEN, PID, DEV */
     39 	uint8_t copyin[2]; 		/* copyin ADR, LEN */
     40 	uint8_t rootaddr;		/* device address of root hub */
     41 	uint8_t rootconf;		/* root configuration */
     42 	uint8_t max_current;		/* max current / 2 */
     43 	uint8_t sltype;			/* revision */
     44 };
     45 
     46 enum power_change {
     47 	POWER_OFF,
     48 	POWER_ON,
     49 };
     50 
     51 typedef void (*PowerFunc)(void *, enum power_change);
     52 
     53 /* Attachment code must call slhci_preinit before registering the ISR */
     54 struct slhci_softc {
     55 	device_t		sc_dev;
     56 	struct usbd_bus		sc_bus;
     57 
     58 	struct simplelock	sc_lock;
     59 	struct simplelock	sc_wait_lock;
     60 
     61 	struct slhci_transfers	sc_transfers;	/* Info useful in transfers. */
     62 
     63 	struct gcq_head		sc_waitq;
     64 
     65 	bus_space_tag_t		sc_iot;
     66 	bus_space_handle_t	sc_ioh;
     67 
     68 	struct callout		sc_timer; 	/* for reset */
     69 
     70 	PowerFunc		sc_enable_power;
     71 
     72 	device_t		sc_child;
     73 
     74 	struct timeval		sc_reserved_warn_rate;
     75 	struct timeval		sc_overflow_warn_rate;
     76 
     77 	void			*sc_cb_softintr;
     78 
     79 	unsigned int		sc_ier_check;
     80 
     81 	int			sc_mem_use; /* XXX SLHCI_MEM_ACCOUNTING */
     82 
     83 	uint8_t			sc_ier; 	/* enabled interrupts */
     84 	uint32_t		sc_stride;	/* port stride */
     85 };
     86 
     87 /* last preinit arguments are: max current (in mA, not mA/2), port stride */
     88 /* register access uses byte access, but stride offsets the data port */
     89 int  slhci_supported_rev(uint8_t);
     90 void slhci_preinit(struct slhci_softc *, PowerFunc, bus_space_tag_t,
     91     bus_space_handle_t, uint16_t, uint32_t);
     92 int  slhci_attach(struct slhci_softc *);
     93 int  slhci_detach(struct slhci_softc *, int);
     94 int  slhci_activate(device_t, enum devact);
     95 int  slhci_intr(void *);
     96 
     97