summaryrefslogtreecommitdiff
path: root/sys/dev/ic/sl811hsvar.h
blob: 9a5b0e21d3cc0fa07a851bbeb2b90f9c2b321f0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*	$NetBSD: sl811hsvar.h,v 1.12 2016/04/23 10:15:31 skrll Exp $	*/

/*
 * Not (c) 2007 Matthew Orgass
 * This file is public domain, meaning anyone can make any use of part or all
 * of this file including copying into other works without credit.  Any use,
 * modified or not, is solely the responsibility of the user.  If this file is
 * part of a collection then use in the collection is governed by the terms of
 * the collection.
 */

/*
 * Cypress/ScanLogic SL811HS USB Host Controller
 */

#include <sys/gcq.h>

#define SC_DEV(sc)	((sc)->sc_dev)
#define SC_NAME(sc)	(device_xname(SC_DEV(sc)))

typedef unsigned int Frame;
struct slhci_pipe;

/* Generally transfer related items. */
struct slhci_transfers {
	struct usbd_xfer *rootintr;
	struct slhci_pipe *spipe[2]; 	/* current transfer (unless canceled) */
	struct gcq_head q[3];		/* transfer queues, Q_* index */
	struct gcq_head timed;		/* intr transfer multi-frame wait */
	struct gcq_head to;		/* timeout list */
	struct gcq_head ap;		/* all pipes */
	Frame frame;			/* current frame */
	unsigned int flags;		/* F_* flags */
	int pend;			/* pending for waitintr */
	int reserved_bustime;
	int16_t len[2];		     	/* length of transfer or -1 if none */
	uint8_t current_tregs[2][4]; 	/* ab, ADR, LEN, PID, DEV */
	uint8_t copyin[2]; 		/* copyin ADR, LEN */
	uint8_t max_current;		/* max current / 2 */
	uint8_t sltype;			/* revision */
};

enum power_change {
	POWER_OFF,
	POWER_ON,
};

typedef void (*PowerFunc)(void *, enum power_change);

/* Attachment code must call slhci_preinit before registering the ISR */
struct slhci_softc {
	device_t		sc_dev;
	struct usbd_bus		sc_bus;

	kmutex_t		sc_lock;
	kmutex_t		sc_intr_lock;

	struct slhci_transfers	sc_transfers;	/* Info useful in transfers. */

	struct gcq_head		sc_waitq;

	bus_space_tag_t		sc_iot;
	bus_space_handle_t	sc_ioh;

	struct callout		sc_timer; 	/* for reset */

	PowerFunc		sc_enable_power;

	device_t		sc_child;

	struct timeval		sc_reserved_warn_rate;
	struct timeval		sc_overflow_warn_rate;

	void			*sc_cb_softintr;

	unsigned int		sc_ier_check;

	int			sc_mem_use; /* XXX SLHCI_MEM_ACCOUNTING */

	uint8_t			sc_ier; 	/* enabled interrupts */
	uint32_t		sc_stride;	/* port stride */
};

/* last preinit arguments are: max current (in mA, not mA/2), port stride */
/* register access uses byte access, but stride offsets the data port */
int  slhci_supported_rev(uint8_t);
void slhci_preinit(struct slhci_softc *, PowerFunc, bus_space_tag_t,
    bus_space_handle_t, uint16_t, uint32_t);
int  slhci_attach(struct slhci_softc *);
int  slhci_detach(struct slhci_softc *, int);
int  slhci_activate(device_t, enum devact);
int  slhci_intr(void *);