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