]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/usb/c67x00/c67x00-hcd.h
USB: add SPDX identifiers to all remaining files in drivers/usb/
[mirror_ubuntu-jammy-kernel.git] / drivers / usb / c67x00 / c67x00-hcd.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * c67x00-hcd.h: Cypress C67X00 USB HCD
4 *
5 * Copyright (C) 2006-2008 Barco N.V.
6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
7 * based on multiple host controller drivers inside the linux kernel.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301 USA.
23 */
24
25 #ifndef _USB_C67X00_HCD_H
26 #define _USB_C67X00_HCD_H
27
28 #include <linux/kernel.h>
29 #include <linux/spinlock.h>
30 #include <linux/list.h>
31 #include <linux/usb.h>
32 #include <linux/usb/hcd.h>
33 #include "c67x00.h"
34
35 /*
36 * The following parameters depend on the CPU speed, bus speed, ...
37 * These can be tuned for specific use cases, e.g. if isochronous transfers
38 * are very important, bandwidth can be sacrificed to guarantee that the
39 * 1ms deadline will be met.
40 * If bulk transfers are important, the MAX_FRAME_BW can be increased,
41 * but some (or many) isochronous deadlines might not be met.
42 *
43 * The values are specified in bittime.
44 */
45
46 /*
47 * The current implementation switches between _STD (default) and _ISO (when
48 * isochronous transfers are scheduled), in order to optimize the throughput
49 * in normal circumstances, but also provide good isochronous behaviour.
50 *
51 * Bandwidth is described in bit time so with a 12MHz USB clock and 1ms
52 * frames; there are 12000 bit times per frame.
53 */
54
55 #define TOTAL_FRAME_BW 12000
56 #define DEFAULT_EOT 2250
57
58 #define MAX_FRAME_BW_STD (TOTAL_FRAME_BW - DEFAULT_EOT)
59 #define MAX_FRAME_BW_ISO 2400
60
61 /*
62 * Periodic transfers may only use 90% of the full frame, but as
63 * we currently don't even use 90% of the full frame, we may
64 * use the full usable time for periodic transfers.
65 */
66 #define MAX_PERIODIC_BW(full_bw) full_bw
67
68 /* -------------------------------------------------------------------------- */
69
70 struct c67x00_hcd {
71 spinlock_t lock;
72 struct c67x00_sie *sie;
73 unsigned int low_speed_ports; /* bitmask of low speed ports */
74 unsigned int urb_count;
75 unsigned int urb_iso_count;
76
77 struct list_head list[4]; /* iso, int, ctrl, bulk */
78 #if PIPE_BULK != 3
79 #error "Sanity check failed, this code presumes PIPE_... to range from 0 to 3"
80 #endif
81
82 /* USB bandwidth allocated to td_list */
83 int bandwidth_allocated;
84 /* USB bandwidth allocated for isoc/int transfer */
85 int periodic_bw_allocated;
86 struct list_head td_list;
87 int max_frame_bw;
88
89 u16 td_base_addr;
90 u16 buf_base_addr;
91 u16 next_td_addr;
92 u16 next_buf_addr;
93
94 struct tasklet_struct tasklet;
95
96 struct completion endpoint_disable;
97
98 u16 current_frame;
99 u16 last_frame;
100 };
101
102 static inline struct c67x00_hcd *hcd_to_c67x00_hcd(struct usb_hcd *hcd)
103 {
104 return (struct c67x00_hcd *)(hcd->hcd_priv);
105 }
106
107 static inline struct usb_hcd *c67x00_hcd_to_hcd(struct c67x00_hcd *c67x00)
108 {
109 return container_of((void *)c67x00, struct usb_hcd, hcd_priv);
110 }
111
112 /* ---------------------------------------------------------------------
113 * Functions used by c67x00-drv
114 */
115
116 int c67x00_hcd_probe(struct c67x00_sie *sie);
117 void c67x00_hcd_remove(struct c67x00_sie *sie);
118
119 /* ---------------------------------------------------------------------
120 * Transfer Descriptor scheduling functions
121 */
122 int c67x00_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
123 int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
124 void c67x00_endpoint_disable(struct usb_hcd *hcd,
125 struct usb_host_endpoint *ep);
126
127 void c67x00_hcd_msg_received(struct c67x00_sie *sie, u16 msg);
128 void c67x00_sched_kick(struct c67x00_hcd *c67x00);
129 int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00);
130 void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00);
131
132 #define c67x00_hcd_dev(x) (c67x00_hcd_to_hcd(x)->self.controller)
133
134 #endif /* _USB_C67X00_HCD_H */