Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * MUSB OTG driver host defines
0004  *
0005  * Copyright 2005 Mentor Graphics Corporation
0006  * Copyright (C) 2005-2006 by Texas Instruments
0007  * Copyright (C) 2006-2007 Nokia Corporation
0008  */
0009 
0010 #ifndef _MUSB_HOST_H
0011 #define _MUSB_HOST_H
0012 
0013 #include <linux/scatterlist.h>
0014 
0015 /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
0016 struct musb_qh {
0017     struct usb_host_endpoint *hep;      /* usbcore info */
0018     struct usb_device   *dev;
0019     struct musb_hw_ep   *hw_ep;     /* current binding */
0020 
0021     struct list_head    ring;       /* of musb_qh */
0022     /* struct musb_qh       *next; */   /* for periodic tree */
0023     u8          mux;        /* qh multiplexed to hw_ep */
0024 
0025     unsigned        offset;     /* in urb->transfer_buffer */
0026     unsigned        segsize;    /* current xfer fragment */
0027 
0028     u8          type_reg;   /* {rx,tx} type register */
0029     u8          intv_reg;   /* {rx,tx} interval register */
0030     u8          addr_reg;   /* device address register */
0031     u8          h_addr_reg; /* hub address register */
0032     u8          h_port_reg; /* hub port register */
0033 
0034     u8          is_ready;   /* safe to modify hw_ep */
0035     u8          type;       /* XFERTYPE_* */
0036     u8          epnum;
0037     u8          hb_mult;    /* high bandwidth pkts per uf */
0038     u16         maxpacket;
0039     u16         frame;      /* for periodic schedule */
0040     unsigned        iso_idx;    /* in urb->iso_frame_desc[] */
0041     struct sg_mapping_iter sg_miter;    /* for highmem in PIO mode */
0042     bool            use_sg;     /* to track urb using sglist */
0043 };
0044 
0045 /* map from control or bulk queue head to the first qh on that ring */
0046 static inline struct musb_qh *first_qh(struct list_head *q)
0047 {
0048     if (list_empty(q))
0049         return NULL;
0050     return list_entry(q->next, struct musb_qh, ring);
0051 }
0052 
0053 
0054 #if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
0055 extern struct musb *hcd_to_musb(struct usb_hcd *);
0056 extern irqreturn_t musb_h_ep0_irq(struct musb *);
0057 extern int musb_host_alloc(struct musb *);
0058 extern int musb_host_setup(struct musb *, int);
0059 extern void musb_host_cleanup(struct musb *);
0060 extern void musb_host_tx(struct musb *, u8);
0061 extern void musb_host_rx(struct musb *, u8);
0062 extern void musb_root_disconnect(struct musb *musb);
0063 extern void musb_host_free(struct musb *);
0064 extern void musb_host_resume_root_hub(struct musb *musb);
0065 extern void musb_host_poke_root_hub(struct musb *musb);
0066 extern int musb_port_suspend(struct musb *musb, bool do_suspend);
0067 extern void musb_port_reset(struct musb *musb, bool do_reset);
0068 extern void musb_host_finish_resume(struct work_struct *work);
0069 #else
0070 static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
0071 {
0072     return NULL;
0073 }
0074 
0075 static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
0076 {
0077     return 0;
0078 }
0079 
0080 static inline int musb_host_alloc(struct musb *musb)
0081 {
0082     return 0;
0083 }
0084 
0085 static inline int musb_host_setup(struct musb *musb, int power_budget)
0086 {
0087     return 0;
0088 }
0089 
0090 static inline void musb_host_cleanup(struct musb *musb)     {}
0091 static inline void musb_host_free(struct musb *musb)        {}
0092 static inline void musb_host_tx(struct musb *musb, u8 epnum)    {}
0093 static inline void musb_host_rx(struct musb *musb, u8 epnum)    {}
0094 static inline void musb_root_disconnect(struct musb *musb)  {}
0095 static inline void musb_host_resume_root_hub(struct musb *musb) {}
0096 static inline void musb_host_poke_root_hub(struct musb *musb)   {}
0097 static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
0098 {
0099     return 0;
0100 }
0101 static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
0102 static inline void musb_host_finish_resume(struct work_struct *work) {}
0103 #endif
0104 
0105 struct usb_hcd;
0106 
0107 extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
0108 extern int musb_hub_control(struct usb_hcd *hcd,
0109             u16 typeReq, u16 wValue, u16 wIndex,
0110             char *buf, u16 wLength);
0111 
0112 static inline struct urb *next_urb(struct musb_qh *qh)
0113 {
0114     struct list_head    *queue;
0115 
0116     if (!qh)
0117         return NULL;
0118     queue = &qh->hep->urb_list;
0119     if (list_empty(queue))
0120         return NULL;
0121     return list_entry(queue->next, struct urb, urb_list);
0122 }
0123 
0124 #endif              /* _MUSB_HOST_H */