Greg Kroah-Hartman | 5fd54ac | 2017-11-03 11:28:30 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 2 | /* |
| 3 | * MUSB OTG driver host defines |
| 4 | * |
| 5 | * Copyright 2005 Mentor Graphics Corporation |
| 6 | * Copyright (C) 2005-2006 by Texas Instruments |
| 7 | * Copyright (C) 2006-2007 Nokia Corporation |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef _MUSB_HOST_H |
| 11 | #define _MUSB_HOST_H |
| 12 | |
Virupax Sadashivpetimath | 8e8a551 | 2012-08-07 14:46:20 +0530 | [diff] [blame] | 13 | #include <linux/scatterlist.h> |
| 14 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 15 | /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */ |
| 16 | struct musb_qh { |
| 17 | struct usb_host_endpoint *hep; /* usbcore info */ |
| 18 | struct usb_device *dev; |
| 19 | struct musb_hw_ep *hw_ep; /* current binding */ |
| 20 | |
| 21 | struct list_head ring; /* of musb_qh */ |
| 22 | /* struct musb_qh *next; */ /* for periodic tree */ |
Ajay Kumar Gupta | 23d15e0 | 2008-10-29 15:10:35 +0200 | [diff] [blame] | 23 | u8 mux; /* qh multiplexed to hw_ep */ |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 24 | |
| 25 | unsigned offset; /* in urb->transfer_buffer */ |
| 26 | unsigned segsize; /* current xfer fragment */ |
| 27 | |
| 28 | u8 type_reg; /* {rx,tx} type register */ |
| 29 | u8 intv_reg; /* {rx,tx} interval register */ |
| 30 | u8 addr_reg; /* device address register */ |
| 31 | u8 h_addr_reg; /* hub address register */ |
| 32 | u8 h_port_reg; /* hub port register */ |
| 33 | |
| 34 | u8 is_ready; /* safe to modify hw_ep */ |
| 35 | u8 type; /* XFERTYPE_* */ |
| 36 | u8 epnum; |
Ajay Kumar Gupta | a483d70 | 2009-04-03 16:16:17 -0700 | [diff] [blame] | 37 | u8 hb_mult; /* high bandwidth pkts per uf */ |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 38 | u16 maxpacket; |
| 39 | u16 frame; /* for periodic schedule */ |
| 40 | unsigned iso_idx; /* in urb->iso_frame_desc[] */ |
Virupax Sadashivpetimath | 8e8a551 | 2012-08-07 14:46:20 +0530 | [diff] [blame] | 41 | struct sg_mapping_iter sg_miter; /* for highmem in PIO mode */ |
Virupax Sadashivpetimath | ed74df1 | 2013-04-24 08:38:48 +0200 | [diff] [blame] | 42 | bool use_sg; /* to track urb using sglist */ |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | /* map from control or bulk queue head to the first qh on that ring */ |
| 46 | static inline struct musb_qh *first_qh(struct list_head *q) |
| 47 | { |
| 48 | if (list_empty(q)) |
| 49 | return NULL; |
| 50 | return list_entry(q->next, struct musb_qh, ring); |
| 51 | } |
| 52 | |
| 53 | |
Daniel Mack | b7b741e | 2013-04-10 21:55:46 +0200 | [diff] [blame] | 54 | #if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE) |
| 55 | extern struct musb *hcd_to_musb(struct usb_hcd *); |
Daniel Mack | c2a2759 | 2013-04-10 21:55:41 +0200 | [diff] [blame] | 56 | extern irqreturn_t musb_h_ep0_irq(struct musb *); |
Daniel Mack | 74c2e93 | 2013-04-10 21:55:45 +0200 | [diff] [blame] | 57 | extern int musb_host_alloc(struct musb *); |
Daniel Mack | 2cc65fe | 2013-04-10 21:55:47 +0200 | [diff] [blame] | 58 | extern int musb_host_setup(struct musb *, int); |
| 59 | extern void musb_host_cleanup(struct musb *); |
Daniel Mack | c2a2759 | 2013-04-10 21:55:41 +0200 | [diff] [blame] | 60 | extern void musb_host_tx(struct musb *, u8); |
| 61 | extern void musb_host_rx(struct musb *, u8); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 62 | extern void musb_root_disconnect(struct musb *musb); |
Daniel Mack | 74c2e93 | 2013-04-10 21:55:45 +0200 | [diff] [blame] | 63 | extern void musb_host_free(struct musb *); |
| 64 | extern void musb_host_cleanup(struct musb *); |
| 65 | extern void musb_host_tx(struct musb *, u8); |
| 66 | extern void musb_host_rx(struct musb *, u8); |
| 67 | extern void musb_root_disconnect(struct musb *musb); |
Daniel Mack | 0b3eba4 | 2013-04-10 21:55:42 +0200 | [diff] [blame] | 68 | extern void musb_host_resume_root_hub(struct musb *musb); |
| 69 | extern void musb_host_poke_root_hub(struct musb *musb); |
Daniel Mack | 94f7213 | 2013-11-25 22:26:41 +0100 | [diff] [blame] | 70 | extern void musb_port_suspend(struct musb *musb, bool do_suspend); |
Daniel Mack | 869c597 | 2013-11-26 13:31:14 +0100 | [diff] [blame] | 71 | extern void musb_port_reset(struct musb *musb, bool do_reset); |
Daniel Mack | 8ed1fb7 | 2013-12-18 20:23:46 +0100 | [diff] [blame] | 72 | extern void musb_host_finish_resume(struct work_struct *work); |
Daniel Mack | b7b741e | 2013-04-10 21:55:46 +0200 | [diff] [blame] | 73 | #else |
| 74 | static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) |
| 75 | { |
| 76 | return NULL; |
| 77 | } |
| 78 | |
| 79 | static inline irqreturn_t musb_h_ep0_irq(struct musb *musb) |
| 80 | { |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | static inline int musb_host_alloc(struct musb *musb) |
| 85 | { |
| 86 | return 0; |
| 87 | } |
| 88 | |
Daniel Mack | 2cc65fe | 2013-04-10 21:55:47 +0200 | [diff] [blame] | 89 | static inline int musb_host_setup(struct musb *musb, int power_budget) |
| 90 | { |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | static inline void musb_host_cleanup(struct musb *musb) {} |
Daniel Mack | b7b741e | 2013-04-10 21:55:46 +0200 | [diff] [blame] | 95 | static inline void musb_host_free(struct musb *musb) {} |
| 96 | static inline void musb_host_tx(struct musb *musb, u8 epnum) {} |
| 97 | static inline void musb_host_rx(struct musb *musb, u8 epnum) {} |
| 98 | static inline void musb_root_disconnect(struct musb *musb) {} |
| 99 | static inline void musb_host_resume_root_hub(struct musb *musb) {} |
| 100 | static inline void musb_host_poll_rh_status(struct musb *musb) {} |
| 101 | static inline void musb_host_poke_root_hub(struct musb *musb) {} |
Daniel Mack | 94f7213 | 2013-11-25 22:26:41 +0100 | [diff] [blame] | 102 | static inline void musb_port_suspend(struct musb *musb, bool do_suspend) {} |
Daniel Mack | 071f58b | 2013-12-20 10:47:14 +0100 | [diff] [blame] | 103 | static inline void musb_port_reset(struct musb *musb, bool do_reset) {} |
Daniel Mack | 8ed1fb7 | 2013-12-18 20:23:46 +0100 | [diff] [blame] | 104 | static inline void musb_host_finish_resume(struct work_struct *work) {} |
Daniel Mack | b7b741e | 2013-04-10 21:55:46 +0200 | [diff] [blame] | 105 | #endif |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 106 | |
| 107 | struct usb_hcd; |
| 108 | |
| 109 | extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf); |
| 110 | extern int musb_hub_control(struct usb_hcd *hcd, |
| 111 | u16 typeReq, u16 wValue, u16 wIndex, |
| 112 | char *buf, u16 wLength); |
| 113 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 114 | static inline struct urb *next_urb(struct musb_qh *qh) |
| 115 | { |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 116 | struct list_head *queue; |
| 117 | |
| 118 | if (!qh) |
| 119 | return NULL; |
| 120 | queue = &qh->hep->urb_list; |
| 121 | if (list_empty(queue)) |
| 122 | return NULL; |
| 123 | return list_entry(queue->next, struct urb, urb_list); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | #endif /* _MUSB_HOST_H */ |