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