drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h

Source file repositories/reference/linux-study-clean/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h

File Facts

System
Linux kernel
Corpus path
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h
Extension
.h
Size
5267 bytes
Lines
157
Domain
Driver Families
Bucket
drivers/hid
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 thc_prd_entry {
	u64  dest_addr : 54;
	u64  reserved1 : 9;
	u64  int_on_completion : 1;
	u64  len : 24;
	u64  end_of_prd : 1;
	u64  hw_status : 2;
	u64  reserved2 : 37;
};

/*
 * Max OS memory fragmentation will be at a 4KB boundary, thus to address 1MB
 * of virtually contiguous memory 256 PRD entries are required for a single
 * PRD Table. SW writes the number of PRD Entries for each PRD table in the
 * THC_M_PRT_RPRD_CNTRL.PTEC register field. The PRD entry's length must be
 * multiple of 4KB except for the last entry in a PRD table.
 * This is the max possible number of etries supported by HW, in practise we
 * there will be less entries in each prd table(the actual number will be
 * given by scatter-gather list allocation).
 */
#define PRD_ENTRIES_NUM 16

/*
 * Number of PRD tables equals to number of data buffers.
 * The max number of PRD tables supported by the HW is 128,
 * but we allocate only 16.
 */
#define PRD_TABLES_NUM  16

/* THC DMA Physical Memory Descriptor Table */
struct thc_prd_table {
	struct thc_prd_entry entries[PRD_ENTRIES_NUM];
};

#define PRD_TABLE_SIZE	sizeof(struct thc_prd_table)

/**
 * struct thc_dma_configuration - THC DMA configure
 * @dma_channel: DMA channel for current DMA configuration
 * @prd_tbls_dma_handle: DMA buffer handle
 * @dir: Direction of DMA for this config
 * @prd_tbls: PRD tables for current DMA
 * @sgls: Array of pointers to scatter-gather lists
 * @sgls_nent_pages: Number of pages per scatter-gather list
 * @sgls_nent: Actual number of entries per scatter-gather list
 * @prd_tbl_num: Actual number of PRD tables
 * @max_packet_size: Size of the buffer needed for 1 DMA message (1 PRD table)
 * @prd_base_addr_high: High 32bits memory address where stores PRD table
 * @prd_base_addr_low: Low 32bits memory address where stores PRD table
 * @prd_cntrl: PRD control register value
 * @dma_cntrl: DMA control register value
 */
struct thc_dma_configuration {
	enum thc_dma_channel dma_channel;
	dma_addr_t prd_tbls_dma_handle;
	enum dma_data_direction dir;
	bool is_enabled;

	struct thc_prd_table *prd_tbls;
	struct scatterlist *sgls[PRD_TABLES_NUM];
	u8 sgls_nent_pages[PRD_TABLES_NUM];
	u8 sgls_nent[PRD_TABLES_NUM];
	u8 prd_tbl_num;

	size_t max_packet_size;
	u32 prd_base_addr_high;
	u32 prd_base_addr_low;
	u32 prd_cntrl;
	u32 dma_cntrl;
};

/**
 * struct thc_dma_context - THC DMA context
 * @thc_dma_configuration: Array of all THC Channel configures
 * @use_write_interrupts: Indicate TxDMA using interrupt or polling
 * @rx_max_size_en: Temp flag to indicate THC I2C Rx max input size control feature
 *                  enabled or not, only be used during SWDMA operation.
 * @rx_int_delay_en: Temp flag to indicate THC I2C Rx interrupt delay feature
 *                   enabled or not, only be used during SWDMA operation.
 */
struct thc_dma_context {
	struct thc_dma_configuration dma_config[MAX_THC_DMA_CHANNEL];
	u8 use_write_interrupts;

	bool rx_max_size_en;
	bool rx_int_delay_en;
};

struct thc_device;

Annotation

Implementation Notes