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