1 // SPDX-License-Identifier: GPL-2.0+
3 * c67x00-hcd.h: Cypress C67X00 USB HCD
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.
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.
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.
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,
25 #ifndef _USB_C67X00_HCD_H
26 #define _USB_C67X00_HCD_H
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>
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.
43 * The values are specified in bittime.
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.
51 * Bandwidth is described in bit time so with a 12MHz USB clock and 1ms
52 * frames; there are 12000 bit times per frame.
55 #define TOTAL_FRAME_BW 12000
56 #define DEFAULT_EOT 2250
58 #define MAX_FRAME_BW_STD (TOTAL_FRAME_BW - DEFAULT_EOT)
59 #define MAX_FRAME_BW_ISO 2400
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.
66 #define MAX_PERIODIC_BW(full_bw) full_bw
68 /* -------------------------------------------------------------------------- */
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
;
77 struct list_head list
[4]; /* iso, int, ctrl, bulk */
79 #error "Sanity check failed, this code presumes PIPE_... to range from 0 to 3"
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
;
94 struct tasklet_struct tasklet
;
96 struct completion endpoint_disable
;
102 static inline struct c67x00_hcd
*hcd_to_c67x00_hcd(struct usb_hcd
*hcd
)
104 return (struct c67x00_hcd
*)(hcd
->hcd_priv
);
107 static inline struct usb_hcd
*c67x00_hcd_to_hcd(struct c67x00_hcd
*c67x00
)
109 return container_of((void *)c67x00
, struct usb_hcd
, hcd_priv
);
112 /* ---------------------------------------------------------------------
113 * Functions used by c67x00-drv
116 int c67x00_hcd_probe(struct c67x00_sie
*sie
);
117 void c67x00_hcd_remove(struct c67x00_sie
*sie
);
119 /* ---------------------------------------------------------------------
120 * Transfer Descriptor scheduling functions
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
);
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
);
132 #define c67x00_hcd_dev(x) (c67x00_hcd_to_hcd(x)->self.controller)
134 #endif /* _USB_C67X00_HCD_H */