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