drivers/usb/host/max3421-hcd.c

Source file repositories/reference/linux-study-clean/drivers/usb/host/max3421-hcd.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/host/max3421-hcd.c
Extension
.c
Size
51567 bytes
Lines
1976
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 max3421_dma_buf {
	u8 data[2];
};

struct max3421_hcd {
	spinlock_t lock;

	struct task_struct *spi_thread;

	enum max3421_rh_state rh_state;
	/* lower 16 bits contain port status, upper 16 bits the change mask: */
	u32 port_status;

	unsigned active:1;

	struct list_head ep_list;	/* list of EP's with work */

	/*
	 * The following are owned by spi_thread (may be accessed by
	 * SPI-thread without acquiring the HCD lock:
	 */
	u8 rev;				/* chip revision */
	u16 frame_number;
	/*
	 * kmalloc'd buffers guaranteed to be in separate (DMA)
	 * cache-lines:
	 */
	struct max3421_dma_buf *tx;
	struct max3421_dma_buf *rx;
	/*
	 * URB we're currently processing.  Must not be reset to NULL
	 * unless MAX3421E chip is idle:
	 */
	struct urb *curr_urb;
	enum scheduling_pass sched_pass;
	int urb_done;			/* > 0 -> no errors, < 0: errno */
	size_t curr_len;
	u8 hien;
	u8 mode;
	u8 iopins[2];
	unsigned long todo;
#ifdef DEBUG
	unsigned long err_stat[16];
#endif
};

struct max3421_ep {
	struct usb_host_endpoint *ep;
	struct list_head ep_list;
	u32 naks;
	u16 last_active;		/* frame # this ep was last active */
	enum pkt_state pkt_state;
	u8 retries;
	u8 retransmit;			/* packet needs retransmission */
};

#define MAX3421_FIFO_SIZE	64

#define MAX3421_SPI_DIR_RD	0	/* read register from MAX3421 */
#define MAX3421_SPI_DIR_WR	1	/* write register to MAX3421 */

/* SPI commands: */
#define MAX3421_SPI_DIR_SHIFT	1
#define MAX3421_SPI_REG_SHIFT	3

#define MAX3421_REG_RCVFIFO	1
#define MAX3421_REG_SNDFIFO	2
#define MAX3421_REG_SUDFIFO	4
#define MAX3421_REG_RCVBC	6
#define MAX3421_REG_SNDBC	7
#define MAX3421_REG_USBIRQ	13
#define MAX3421_REG_USBIEN	14
#define MAX3421_REG_USBCTL	15
#define MAX3421_REG_CPUCTL	16
#define MAX3421_REG_PINCTL	17
#define MAX3421_REG_REVISION	18
#define MAX3421_REG_IOPINS1	20
#define MAX3421_REG_IOPINS2	21
#define MAX3421_REG_GPINIRQ	22
#define MAX3421_REG_GPINIEN	23
#define MAX3421_REG_GPINPOL	24
#define MAX3421_REG_HIRQ	25
#define MAX3421_REG_HIEN	26
#define MAX3421_REG_MODE	27
#define MAX3421_REG_PERADDR	28
#define MAX3421_REG_HCTL	29
#define MAX3421_REG_HXFR	30
#define MAX3421_REG_HRSL	31

enum {

Annotation

Implementation Notes