drivers/usb/gadget/udc/renesas_usbf.c

Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/renesas_usbf.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/gadget/udc/renesas_usbf.c
Extension
.c
Size
89003 bytes
Lines
3394
Domain
Driver Families
Bucket
drivers/usb
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct usbf_req {
	struct usb_request	req;
	struct list_head	queue;
	unsigned int		is_zero_sent : 1;
	unsigned int		is_mapped : 1;
	enum {
		USBF_XFER_START,
		USBF_XFER_WAIT_DMA,
		USBF_XFER_SEND_NULL,
		USBF_XFER_WAIT_END,
		USBF_XFER_WAIT_DMA_SHORT,
		USBF_XFER_WAIT_BRIDGE,
	}			xfer_step;
	size_t			dma_size;
};

/* USB Endpoint */
struct usbf_ep {
	struct usb_ep		ep;
	char			name[32];
	struct list_head	queue;
	unsigned int		is_processing : 1;
	unsigned int		is_in : 1;
	struct			usbf_udc *udc;
	void __iomem		*regs;
	void __iomem		*dma_regs;
	unsigned int		id : 8;
	unsigned int		disabled : 1;
	unsigned int		is_wedged : 1;
	unsigned int		delayed_status : 1;
	u32			status;
	void			(*bridge_on_dma_end)(struct usbf_ep *ep);
};

enum usbf_ep0state {
	EP0_IDLE,
	EP0_IN_DATA_PHASE,
	EP0_OUT_DATA_PHASE,
	EP0_OUT_STATUS_START_PHASE,
	EP0_OUT_STATUS_PHASE,
	EP0_OUT_STATUS_END_PHASE,
	EP0_IN_STATUS_START_PHASE,
	EP0_IN_STATUS_PHASE,
	EP0_IN_STATUS_END_PHASE,
};

struct usbf_udc {
	struct usb_gadget		gadget;
	struct usb_gadget_driver	*driver;
	struct device			*dev;
	void __iomem			*regs;
	spinlock_t			lock;
	bool				is_remote_wakeup;
	bool				is_usb_suspended;
	struct usbf_ep			ep[USBF_NUM_ENDPOINTS];
	/* for EP0 control messages */
	enum usbf_ep0state		ep0state;
	struct usbf_req			setup_reply;
	u8				ep0_buf[USBF_EP0_MAX_PCKT_SIZE];
};

struct usbf_ep_info {
	const char		*name;
	struct usb_ep_caps	caps;
	u16			base_addr;
	unsigned int		is_double : 1;
	u16			maxpacket_limit;
};

#define USBF_SINGLE_BUFFER 0
#define USBF_DOUBLE_BUFFER 1
#define USBF_EP_INFO(_name, _caps, _base_addr, _is_double, _maxpacket_limit)  \
	{                                                                     \
		.name            = _name,                                     \
		.caps            = _caps,                                     \
		.base_addr       = _base_addr,                                \
		.is_double       = _is_double,                                \
		.maxpacket_limit = _maxpacket_limit,                          \
	}

/* This table is computed from the recommended values provided in the SOC
 * datasheet. The buffer type (single/double) and the endpoint type cannot
 * be changed. The mapping in internal RAM (base_addr and number of words)
 * for each endpoints depends on the max packet size and the buffer type.
 */
static const struct usbf_ep_info usbf_ep_info[USBF_NUM_ENDPOINTS] = {
	/* ep0: buf @0x0000 64 bytes, fixed 32 words */
	[0] = USBF_EP_INFO("ep0-ctrl",
			   USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL,
				       USB_EP_CAPS_DIR_ALL),

Annotation

Implementation Notes