Home | History | Annotate | Line # | Download | only in ic
sl811hsvar.h revision 1.5
      1 /*	$NetBSD: sl811hsvar.h,v 1.5 2008/04/08 12:07:27 cegger 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 #include "opt_slhci.h"
     19 
     20 #define SC_DEV(sc)	((sc)->sc_dev)
     21 #define SC_NAME(sc)	(device_xname(SC_DEV(sc)))
     22 
     23 typedef unsigned int Frame;
     24 struct slhci_pipe;
     25 
     26 /* Generally transfer related items. */
     27 struct slhci_transfers {
     28 	struct usbd_xfer *rootintr;
     29 	struct slhci_pipe *spipe[2]; 	/* current transfer (unless canceled) */
     30 	struct gcq_head q[3];		/* transfer queues, Q_* index */
     31 	struct gcq_head timed;		/* intr transfer multi-frame wait */
     32 	struct gcq_head to;		/* timeout list */
     33 	struct gcq_head ap;		/* all pipes */
     34 	Frame frame;			/* current frame */
     35 	unsigned int flags;		/* F_* flags */
     36 	int pend;			/* pending for waitintr */
     37 	int reserved_bustime;
     38 	int16_t len[2];		     	/* length of transfer or -1 if none */
     39 	uint8_t current_tregs[2][4]; 	/* ab, ADR, LEN, PID, DEV */
     40 	uint8_t copyin[2]; 		/* copyin ADR, LEN */
     41 	uint8_t rootaddr;		/* device address of root hub */
     42 	uint8_t rootconf;		/* root configuration */
     43 	uint8_t max_current;		/* max current / 2 */
     44 	uint8_t sltype;			/* revision */
     45 };
     46 
     47 enum power_change {
     48 	POWER_OFF,
     49 	POWER_ON,
     50 };
     51 
     52 typedef void (*PowerFunc)(void *, enum power_change);
     53 
     54 /* Attachment code must call slhci_preinit before registering the ISR */
     55 struct slhci_softc {
     56 	device_t		sc_dev;
     57 	struct usbd_bus		sc_bus;
     58 
     59 	struct simplelock	sc_lock;
     60 	struct simplelock	sc_wait_lock;
     61 
     62 	struct slhci_transfers	sc_transfers;	/* Info useful in transfers. */
     63 
     64 	struct gcq_head		sc_waitq;
     65 
     66 	bus_space_tag_t		sc_iot;
     67 	bus_space_handle_t	sc_ioh;
     68 
     69 	struct callout		sc_timer; 	/* for reset */
     70 
     71 	PowerFunc		sc_enable_power;
     72 
     73 	struct device		*sc_child;
     74 
     75 	struct timeval		sc_reserved_warn_rate;
     76 	struct timeval		sc_overflow_warn_rate;
     77 
     78 	void			*sc_cb_softintr;
     79 
     80 	unsigned int		sc_ier_check;
     81 
     82 	int			sc_mem_use; /* XXX SLHCI_MEM_ACCOUNTING */
     83 
     84 	uint8_t			sc_ier; 	/* enabled interrupts */
     85 	uint8_t			sc_stride;	/* port stride */
     86 };
     87 
     88 /* last preinit arguments are: max current (in mA, not mA/2), port stride */
     89 /* register access uses byte access, but stride offsets the data port */
     90 int  slhci_supported_rev(uint8_t);
     91 void slhci_preinit(struct slhci_softc *, PowerFunc, bus_space_tag_t,
     92     bus_space_handle_t, uint16_t, uint8_t);
     93 int  slhci_attach(struct slhci_softc *);
     94 int  slhci_detach(struct slhci_softc *, int);
     95 int  slhci_activate(struct device *, enum devact);
     96 int  slhci_intr(void *);
     97 
     98