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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/jiffies.hlinux/module.hlinux/spi/spi.hlinux/usb.hlinux/usb/hcd.hlinux/of.hlinux/platform_data/max3421-hcd.h
Detected Declarations
struct max3421_dma_bufstruct max3421_hcdstruct max3421_epenum max3421_rh_stateenum pkt_stateenum scheduling_passfunction frame_difffunction hcd_to_max3421function max3421_to_hcdfunction spi_rd8function spi_wr8function spi_rd_buffunction spi_wr_buffunction max3421_set_speedfunction max3421_set_addressfunction max3421_ctrl_setupfunction max3421_transfer_infunction max3421_transfer_outfunction max3421_next_transferfunction max3421_select_and_start_urbfunction list_for_eachfunction max3421_check_unlinkfunction list_for_each_entry_safefunction max3421_slow_retransmitfunction max3421_recv_data_availablefunction max3421_handle_errorfunction max3421_transfer_in_donefunction max3421_transfer_out_donefunction max3421_host_transfer_donefunction max3421_detect_connfunction max3421_irq_handlerfunction dump_epsfunction list_for_each_entryfunction max3421_handle_irqsfunction max3421_reset_hcdfunction max3421_urb_donefunction max3421_spi_threadfunction max3421_reset_portfunction max3421_resetfunction max3421_startfunction max3421_stopfunction max3421_urb_dequeuefunction max3421_endpoint_disablefunction max3421_get_frame_numberfunction max3421_hub_status_datafunction hub_descriptorfunction VALUEfunction max3421_hub_control
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
- Immediate include surface: `linux/jiffies.h`, `linux/module.h`, `linux/spi/spi.h`, `linux/usb.h`, `linux/usb/hcd.h`, `linux/of.h`, `linux/platform_data/max3421-hcd.h`.
- Detected declarations: `struct max3421_dma_buf`, `struct max3421_hcd`, `struct max3421_ep`, `enum max3421_rh_state`, `enum pkt_state`, `enum scheduling_pass`, `function frame_diff`, `function hcd_to_max3421`, `function max3421_to_hcd`, `function spi_rd8`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.