sl811hsvar.h revision 1.11 1 1.11 skrll /* $NetBSD: sl811hsvar.h,v 1.11 2013/10/02 22:55:04 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 rootaddr; /* device address of root hub */
40 1.2 kiyohara uint8_t rootconf; /* root configuration */
41 1.2 kiyohara uint8_t max_current; /* max current / 2 */
42 1.2 kiyohara uint8_t sltype; /* revision */
43 1.1 isaki };
44 1.1 isaki
45 1.2 kiyohara enum power_change {
46 1.2 kiyohara POWER_OFF,
47 1.2 kiyohara POWER_ON,
48 1.2 kiyohara };
49 1.2 kiyohara
50 1.2 kiyohara typedef void (*PowerFunc)(void *, enum power_change);
51 1.2 kiyohara
52 1.2 kiyohara /* Attachment code must call slhci_preinit before registering the ISR */
53 1.1 isaki struct slhci_softc {
54 1.4 drochner device_t sc_dev;
55 1.2 kiyohara struct usbd_bus sc_bus;
56 1.2 kiyohara
57 1.11 skrll kmutex_t sc_lock;
58 1.11 skrll kmutex_t sc_intr_lock;
59 1.2 kiyohara
60 1.2 kiyohara struct slhci_transfers sc_transfers; /* Info useful in transfers. */
61 1.2 kiyohara
62 1.2 kiyohara struct gcq_head sc_waitq;
63 1.2 kiyohara
64 1.2 kiyohara bus_space_tag_t sc_iot;
65 1.2 kiyohara bus_space_handle_t sc_ioh;
66 1.2 kiyohara
67 1.2 kiyohara struct callout sc_timer; /* for reset */
68 1.2 kiyohara
69 1.2 kiyohara PowerFunc sc_enable_power;
70 1.2 kiyohara
71 1.9 chs device_t sc_child;
72 1.2 kiyohara
73 1.2 kiyohara struct timeval sc_reserved_warn_rate;
74 1.2 kiyohara struct timeval sc_overflow_warn_rate;
75 1.2 kiyohara
76 1.2 kiyohara void *sc_cb_softintr;
77 1.2 kiyohara
78 1.2 kiyohara unsigned int sc_ier_check;
79 1.2 kiyohara
80 1.2 kiyohara int sc_mem_use; /* XXX SLHCI_MEM_ACCOUNTING */
81 1.2 kiyohara
82 1.2 kiyohara uint8_t sc_ier; /* enabled interrupts */
83 1.8 kiyohara uint32_t sc_stride; /* port stride */
84 1.1 isaki };
85 1.1 isaki
86 1.2 kiyohara /* last preinit arguments are: max current (in mA, not mA/2), port stride */
87 1.2 kiyohara /* register access uses byte access, but stride offsets the data port */
88 1.2 kiyohara int slhci_supported_rev(uint8_t);
89 1.10 skrll void slhci_preinit(struct slhci_softc *, PowerFunc, bus_space_tag_t,
90 1.8 kiyohara bus_space_handle_t, uint16_t, uint32_t);
91 1.2 kiyohara int slhci_attach(struct slhci_softc *);
92 1.2 kiyohara int slhci_detach(struct slhci_softc *, int);
93 1.6 cegger int slhci_activate(device_t, enum devact);
94 1.1 isaki int slhci_intr(void *);
95 1.2 kiyohara
96