#include <linux/module.h>
#include <linux/of.h>
#include <linux/device.h>
#include <linux/dmapool.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/vmalloc.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/hrtimer.h>
#include <linux/list.h>
#include <linux/interrupt.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/moduleparam.h>
#include <linux/dma-mapping.h>
#include <linux/debugfs.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
#include <asm/unaligned.h>
#include "fotg210.h"
static const char hcd_name[] = …;
#undef FOTG210_URB_TRACE
#define FOTG210_STATS
#define FOTG210_TUNE_CERR …
#define FOTG210_TUNE_RL_HS …
#define FOTG210_TUNE_RL_TT …
#define FOTG210_TUNE_MULT_HS …
#define FOTG210_TUNE_MULT_TT …
#define FOTG210_TUNE_FLS …
static int log2_irq_thresh;
module_param(log2_irq_thresh, int, S_IRUGO);
MODULE_PARM_DESC(…) …;
static unsigned park;
module_param(park, uint, S_IRUGO);
MODULE_PARM_DESC(…) …;
static unsigned int hird;
module_param(hird, int, S_IRUGO);
MODULE_PARM_DESC(…) …;
#define INTR_MASK …
#include "fotg210-hcd.h"
#define fotg210_dbg(fotg210, fmt, args...) …
#define fotg210_err(fotg210, fmt, args...) …
#define fotg210_info(fotg210, fmt, args...) …
#define fotg210_warn(fotg210, fmt, args...) …
static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label)
{ … }
static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label)
{ … }
static void __maybe_unused
dbg_qtd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd)
{ … }
static void __maybe_unused
dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static void __maybe_unused
dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
{ … }
static int __maybe_unused
dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
{ … }
static int __maybe_unused
dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
{ … }
static const char *const fls_strings[] = …;
static int dbg_command_buf(char *buf, unsigned len, const char *label,
u32 command)
{ … }
static char *dbg_port_buf(char *buf, unsigned len, const char *label, int port,
u32 status)
{ … }
#define dbg_status(fotg210, label, status) …
#define dbg_cmd(fotg210, label, command) …
#define dbg_port(fotg210, label, port, status) …
static int debug_async_open(struct inode *, struct file *);
static int debug_periodic_open(struct inode *, struct file *);
static int debug_registers_open(struct inode *, struct file *);
static int debug_async_open(struct inode *, struct file *);
static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
static int debug_close(struct inode *, struct file *);
static const struct file_operations debug_async_fops = …;
static const struct file_operations debug_periodic_fops = …;
static const struct file_operations debug_registers_fops = …;
static struct dentry *fotg210_debug_root;
struct debug_buffer { … };
static inline char speed_char(u32 scratch)
{ … }
static inline char token_mark(struct fotg210_hcd *fotg210, __hc32 token)
{ … }
static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
char **nextp, unsigned *sizep)
{ … }
static ssize_t fill_async_buffer(struct debug_buffer *buf)
{ … }
static unsigned output_buf_tds_dir(char *buf, struct fotg210_hcd *fotg210,
struct fotg210_qh_hw *hw, struct fotg210_qh *qh, unsigned size)
{ … }
#define DBG_SCHED_LIMIT …
static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
{ … }
#undef DBG_SCHED_LIMIT
static const char *rh_state_string(struct fotg210_hcd *fotg210)
{ … }
static ssize_t fill_registers_buffer(struct debug_buffer *buf)
{ … }
static struct debug_buffer
*alloc_buffer(struct usb_bus *bus, ssize_t (*fill_func)(struct debug_buffer *))
{ … }
static int fill_buffer(struct debug_buffer *buf)
{ … }
static ssize_t debug_output(struct file *file, char __user *user_buf,
size_t len, loff_t *offset)
{ … }
static int debug_close(struct inode *inode, struct file *file)
{ … }
static int debug_async_open(struct inode *inode, struct file *file)
{ … }
static int debug_periodic_open(struct inode *inode, struct file *file)
{ … }
static int debug_registers_open(struct inode *inode, struct file *file)
{ … }
static inline void create_debug_files(struct fotg210_hcd *fotg210)
{ … }
static inline void remove_debug_files(struct fotg210_hcd *fotg210)
{ … }
static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr,
u32 mask, u32 done, int usec)
{ … }
static int fotg210_halt(struct fotg210_hcd *fotg210)
{ … }
static int fotg210_reset(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_quiesce(struct fotg210_hcd *fotg210)
{ … }
static void end_unlink_async(struct fotg210_hcd *fotg210);
static void unlink_empty_async(struct fotg210_hcd *fotg210);
static void fotg210_work(struct fotg210_hcd *fotg210);
static void start_unlink_intr(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh);
static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
static void fotg210_set_command_bit(struct fotg210_hcd *fotg210, u32 bit)
{ … }
static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit)
{ … }
static unsigned event_delays_ns[] = …;
static void fotg210_enable_event(struct fotg210_hcd *fotg210, unsigned event,
bool resched)
{ … }
static void fotg210_poll_ASS(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_disable_ASE(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_poll_PSS(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_disable_PSE(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_handle_controller_death(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210)
{ … }
static void start_free_itds(struct fotg210_hcd *fotg210)
{ … }
static void end_free_itds(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_iaa_watchdog(struct fotg210_hcd *fotg210)
{ … }
static void turn_on_io_watchdog(struct fotg210_hcd *fotg210)
{ … }
static void (*event_handlers[])(struct fotg210_hcd *) = …;
static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t)
{ … }
#define fotg210_bus_suspend …
#define fotg210_bus_resume …
static int check_reset_complete(struct fotg210_hcd *fotg210, int index,
u32 __iomem *status_reg, int port_status)
{ … }
static int fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
{ … }
static void fotg210_hub_descriptor(struct fotg210_hcd *fotg210,
struct usb_hub_descriptor *desc)
{ … }
static int fotg210_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
{ … }
static void __maybe_unused fotg210_relinquish_port(struct usb_hcd *hcd,
int portnum)
{ … }
static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd,
int portnum)
{ … }
static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210,
struct fotg210_qtd *qtd, dma_addr_t dma)
{ … }
static struct fotg210_qtd *fotg210_qtd_alloc(struct fotg210_hcd *fotg210,
gfp_t flags)
{ … }
static inline void fotg210_qtd_free(struct fotg210_hcd *fotg210,
struct fotg210_qtd *qtd)
{ … }
static void qh_destroy(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210,
gfp_t flags)
{ … }
static void fotg210_mem_cleanup(struct fotg210_hcd *fotg210)
{ … }
static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
{ … }
static int qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd,
dma_addr_t buf, size_t len, int token, int maxpacket)
{ … }
static inline void qh_update(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh, struct fotg210_qtd *qtd)
{ … }
static void qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd,
struct usb_host_endpoint *ep)
{ … }
static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh, struct urb *urb, u32 token)
{ … }
static int qtd_copy_status(struct fotg210_hcd *fotg210, struct urb *urb,
size_t length, u32 token)
{ … }
static void fotg210_urb_done(struct fotg210_hcd *fotg210, struct urb *urb,
int status)
__releases(fotg210->lock)
__acquires(fotg210->lock)
{ … }
static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
static unsigned qh_completions(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh)
{ … }
static void qtd_list_free(struct fotg210_hcd *fotg210, struct urb *urb,
struct list_head *head)
{ … }
static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
struct urb *urb, struct list_head *head, gfp_t flags)
{ … }
static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
gfp_t flags)
{ … }
static void enable_async(struct fotg210_hcd *fotg210)
{ … }
static void disable_async(struct fotg210_hcd *fotg210)
{ … }
static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static struct fotg210_qh *qh_append_tds(struct fotg210_hcd *fotg210,
struct urb *urb, struct list_head *qtd_list,
int epnum, void **ptr)
{ … }
static int submit_async(struct fotg210_hcd *fotg210, struct urb *urb,
struct list_head *qtd_list, gfp_t mem_flags)
{ … }
static void single_unlink_async(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh)
{ … }
static void start_iaa_cycle(struct fotg210_hcd *fotg210, bool nested)
{ … }
static void end_unlink_async(struct fotg210_hcd *fotg210)
{ … }
static void unlink_empty_async(struct fotg210_hcd *fotg210)
{ … }
static void start_unlink_async(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh)
{ … }
static void scan_async(struct fotg210_hcd *fotg210)
{ … }
static int fotg210_get_frame(struct usb_hcd *hcd);
static union fotg210_shadow *periodic_next_shadow(struct fotg210_hcd *fotg210,
union fotg210_shadow *periodic, __hc32 tag)
{ … }
static __hc32 *shadow_next_periodic(struct fotg210_hcd *fotg210,
union fotg210_shadow *periodic, __hc32 tag)
{ … }
static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame,
void *ptr)
{ … }
static unsigned short periodic_usecs(struct fotg210_hcd *fotg210,
unsigned frame, unsigned uframe)
{ … }
static int same_tt(struct usb_device *dev1, struct usb_device *dev2)
{ … }
static int tt_no_collision(struct fotg210_hcd *fotg210, unsigned period,
struct usb_device *dev, unsigned frame, u32 uf_mask)
{ … }
static void enable_periodic(struct fotg210_hcd *fotg210)
{ … }
static void disable_periodic(struct fotg210_hcd *fotg210)
{ … }
static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static void qh_unlink_periodic(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh)
{ … }
static void start_unlink_intr(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh)
{ … }
static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static int check_period(struct fotg210_hcd *fotg210, unsigned frame,
unsigned uframe, unsigned period, unsigned usecs)
{ … }
static int check_intr_schedule(struct fotg210_hcd *fotg210, unsigned frame,
unsigned uframe, const struct fotg210_qh *qh, __hc32 *c_maskp)
{ … }
static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ … }
static int intr_submit(struct fotg210_hcd *fotg210, struct urb *urb,
struct list_head *qtd_list, gfp_t mem_flags)
{ … }
static void scan_intr(struct fotg210_hcd *fotg210)
{ … }
static struct fotg210_iso_stream *iso_stream_alloc(gfp_t mem_flags)
{ … }
static void iso_stream_init(struct fotg210_hcd *fotg210,
struct fotg210_iso_stream *stream, struct usb_device *dev,
int pipe, unsigned interval)
{ … }
static struct fotg210_iso_stream *iso_stream_find(struct fotg210_hcd *fotg210,
struct urb *urb)
{ … }
static struct fotg210_iso_sched *iso_sched_alloc(unsigned packets,
gfp_t mem_flags)
{ … }
static inline void itd_sched_init(struct fotg210_hcd *fotg210,
struct fotg210_iso_sched *iso_sched,
struct fotg210_iso_stream *stream, struct urb *urb)
{ … }
static void iso_sched_free(struct fotg210_iso_stream *stream,
struct fotg210_iso_sched *iso_sched)
{ … }
static int itd_urb_transaction(struct fotg210_iso_stream *stream,
struct fotg210_hcd *fotg210, struct urb *urb, gfp_t mem_flags)
{ … }
static inline int itd_slot_ok(struct fotg210_hcd *fotg210, u32 mod, u32 uframe,
u8 usecs, u32 period)
{ … }
#define SCHEDULE_SLOP …
static int iso_stream_schedule(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_iso_stream *stream)
{ … }
static inline void itd_init(struct fotg210_hcd *fotg210,
struct fotg210_iso_stream *stream, struct fotg210_itd *itd)
{ … }
static inline void itd_patch(struct fotg210_hcd *fotg210,
struct fotg210_itd *itd, struct fotg210_iso_sched *iso_sched,
unsigned index, u16 uframe)
{ … }
static inline void itd_link(struct fotg210_hcd *fotg210, unsigned frame,
struct fotg210_itd *itd)
{ … }
static void itd_link_urb(struct fotg210_hcd *fotg210, struct urb *urb,
unsigned mod, struct fotg210_iso_stream *stream)
{ … }
#define ISO_ERRS …
static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
{ … }
static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
gfp_t mem_flags)
{ … }
static inline int scan_frame_queue(struct fotg210_hcd *fotg210, unsigned frame,
unsigned now_frame, bool live)
{ … }
static void scan_isoc(struct fotg210_hcd *fotg210)
{ … }
static ssize_t uframe_periodic_max_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t uframe_periodic_max_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(uframe_periodic_max);
static inline int create_sysfs_files(struct fotg210_hcd *fotg210)
{ … }
static inline void remove_sysfs_files(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_turn_off_all_ports(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_silence_controller(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_shutdown(struct usb_hcd *hcd)
{ … }
static void fotg210_work(struct fotg210_hcd *fotg210)
{ … }
static void fotg210_stop(struct usb_hcd *hcd)
{ … }
static int hcd_fotg210_init(struct usb_hcd *hcd)
{ … }
static int fotg210_run(struct usb_hcd *hcd)
{ … }
static int fotg210_setup(struct usb_hcd *hcd)
{ … }
static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
{ … }
static int fotg210_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
gfp_t mem_flags)
{ … }
static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{ … }
static void fotg210_endpoint_disable(struct usb_hcd *hcd,
struct usb_host_endpoint *ep)
{ … }
static void fotg210_endpoint_reset(struct usb_hcd *hcd,
struct usb_host_endpoint *ep)
{ … }
static int fotg210_get_frame(struct usb_hcd *hcd)
{ … }
static const struct hc_driver fotg210_fotg210_hc_driver = …;
static void fotg210_init(struct fotg210_hcd *fotg210)
{ … }
int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
{ … }
int fotg210_hcd_remove(struct platform_device *pdev)
{ … }
int __init fotg210_hcd_init(void)
{ … }
void __exit fotg210_hcd_cleanup(void)
{ … }