Linux Audio

Check our new training course

Linux kernel drivers training

May 6-19, 2025
Register
Loading...
v3.1
 
  1/*
  2 * MUSB OTG driver host defines
  3 *
  4 * Copyright 2005 Mentor Graphics Corporation
  5 * Copyright (C) 2005-2006 by Texas Instruments
  6 * Copyright (C) 2006-2007 Nokia Corporation
  7 *
  8 * This program is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU General Public License
 10 * version 2 as published by the Free Software Foundation.
 11 *
 12 * This program is distributed in the hope that it will be useful, but
 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15 * General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program; if not, write to the Free Software
 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA
 21 *
 22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32 *
 33 */
 34
 35#ifndef _MUSB_HOST_H
 36#define _MUSB_HOST_H
 37
 38static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
 39{
 40	return container_of((void *) musb, struct usb_hcd, hcd_priv);
 41}
 42
 43static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
 44{
 45	return (struct musb *) (hcd->hcd_priv);
 46}
 47
 48/* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
 49struct musb_qh {
 50	struct usb_host_endpoint *hep;		/* usbcore info */
 51	struct usb_device	*dev;
 52	struct musb_hw_ep	*hw_ep;		/* current binding */
 53
 54	struct list_head	ring;		/* of musb_qh */
 55	/* struct musb_qh		*next; */	/* for periodic tree */
 56	u8			mux;		/* qh multiplexed to hw_ep */
 57
 58	unsigned		offset;		/* in urb->transfer_buffer */
 59	unsigned		segsize;	/* current xfer fragment */
 60
 61	u8			type_reg;	/* {rx,tx} type register */
 62	u8			intv_reg;	/* {rx,tx} interval register */
 63	u8			addr_reg;	/* device address register */
 64	u8			h_addr_reg;	/* hub address register */
 65	u8			h_port_reg;	/* hub port register */
 66
 67	u8			is_ready;	/* safe to modify hw_ep */
 68	u8			type;		/* XFERTYPE_* */
 69	u8			epnum;
 70	u8			hb_mult;	/* high bandwidth pkts per uf */
 71	u16			maxpacket;
 72	u16			frame;		/* for periodic schedule */
 73	unsigned		iso_idx;	/* in urb->iso_frame_desc[] */
 
 
 74};
 75
 76/* map from control or bulk queue head to the first qh on that ring */
 77static inline struct musb_qh *first_qh(struct list_head *q)
 78{
 79	if (list_empty(q))
 80		return NULL;
 81	return list_entry(q->next, struct musb_qh, ring);
 82}
 83
 84
 
 
 
 
 
 
 
 
 85extern void musb_root_disconnect(struct musb *musb);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 86
 87struct usb_hcd;
 88
 89extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
 90extern int musb_hub_control(struct usb_hcd *hcd,
 91			u16 typeReq, u16 wValue, u16 wIndex,
 92			char *buf, u16 wLength);
 93
 94extern const struct hc_driver musb_hc_driver;
 95
 96static inline struct urb *next_urb(struct musb_qh *qh)
 97{
 98	struct list_head	*queue;
 99
100	if (!qh)
101		return NULL;
102	queue = &qh->hep->urb_list;
103	if (list_empty(queue))
104		return NULL;
105	return list_entry(queue->next, struct urb, urb_list);
106}
107
108#endif				/* _MUSB_HOST_H */
v5.9
  1/* SPDX-License-Identifier: GPL-2.0 */
  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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  8 */
  9
 10#ifndef _MUSB_HOST_H
 11#define _MUSB_HOST_H
 12
 13#include <linux/scatterlist.h>
 
 
 
 
 
 
 
 
 14
 15/* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
 16struct 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 */
 23	u8			mux;		/* qh multiplexed to hw_ep */
 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;
 37	u8			hb_mult;	/* high bandwidth pkts per uf */
 38	u16			maxpacket;
 39	u16			frame;		/* for periodic schedule */
 40	unsigned		iso_idx;	/* in urb->iso_frame_desc[] */
 41	struct sg_mapping_iter sg_miter;	/* for highmem in PIO mode */
 42	bool			use_sg;		/* to track urb using sglist */
 43};
 44
 45/* map from control or bulk queue head to the first qh on that ring */
 46static 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
 54#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
 55extern struct musb *hcd_to_musb(struct usb_hcd *);
 56extern irqreturn_t musb_h_ep0_irq(struct musb *);
 57extern int musb_host_alloc(struct musb *);
 58extern int musb_host_setup(struct musb *, int);
 59extern void musb_host_cleanup(struct musb *);
 60extern void musb_host_tx(struct musb *, u8);
 61extern void musb_host_rx(struct musb *, u8);
 62extern void musb_root_disconnect(struct musb *musb);
 63extern void musb_host_free(struct musb *);
 64extern void musb_host_cleanup(struct musb *);
 65extern void musb_host_tx(struct musb *, u8);
 66extern void musb_host_rx(struct musb *, u8);
 67extern void musb_root_disconnect(struct musb *musb);
 68extern void musb_host_resume_root_hub(struct musb *musb);
 69extern void musb_host_poke_root_hub(struct musb *musb);
 70extern int musb_port_suspend(struct musb *musb, bool do_suspend);
 71extern void musb_port_reset(struct musb *musb, bool do_reset);
 72extern void musb_host_finish_resume(struct work_struct *work);
 73#else
 74static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
 75{
 76	return NULL;
 77}
 78
 79static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
 80{
 81	return 0;
 82}
 83
 84static inline int musb_host_alloc(struct musb *musb)
 85{
 86	return 0;
 87}
 88
 89static inline int musb_host_setup(struct musb *musb, int power_budget)
 90{
 91	return 0;
 92}
 93
 94static inline void musb_host_cleanup(struct musb *musb)		{}
 95static inline void musb_host_free(struct musb *musb)		{}
 96static inline void musb_host_tx(struct musb *musb, u8 epnum)	{}
 97static inline void musb_host_rx(struct musb *musb, u8 epnum)	{}
 98static inline void musb_root_disconnect(struct musb *musb)	{}
 99static inline void musb_host_resume_root_hub(struct musb *musb)	{}
100static inline void musb_host_poke_root_hub(struct musb *musb)	{}
101static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
102{
103	return 0;
104}
105static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
106static inline void musb_host_finish_resume(struct work_struct *work) {}
107#endif
108
109struct usb_hcd;
110
111extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
112extern int musb_hub_control(struct usb_hcd *hcd,
113			u16 typeReq, u16 wValue, u16 wIndex,
114			char *buf, u16 wLength);
 
 
115
116static inline struct urb *next_urb(struct musb_qh *qh)
117{
118	struct list_head	*queue;
119
120	if (!qh)
121		return NULL;
122	queue = &qh->hep->urb_list;
123	if (list_empty(queue))
124		return NULL;
125	return list_entry(queue->next, struct urb, urb_list);
126}
127
128#endif				/* _MUSB_HOST_H */