drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
Source file repositories/reference/linux-study-clean/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c- Extension
.c- Size
- 55083 bytes
- Lines
- 1769
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/bitfield.hlinux/math.hlinux/regmap.hlinux/string_choices.hintel-thc-dev.hintel-thc-hw.h
Detected Declarations
function thc_regmap_readfunction thc_regmap_writefunction thc_clear_statefunction prepare_piofunction pio_startfunction pio_completefunction pio_waitfunction thc_tic_pio_readfunction thc_tic_pio_writefunction thc_tic_pio_write_and_readfunction thc_interrupt_configfunction thc_int_trigger_type_selectfunction thc_interrupt_enablefunction thc_interrupt_quiescefunction thc_set_pio_interrupt_supportfunction thc_ltr_configfunction thc_change_ltr_modefunction thc_ltr_unconfigfunction thc_int_cause_readfunction thc_print_txn_error_causefunction thc_interrupt_handlerfunction thc_port_selectfunction thc_get_spi_freq_div_valfunction thc_spi_read_configfunction thc_spi_write_configfunction thc_spi_input_output_address_configfunction thc_i2c_subip_pio_readfunction thc_i2c_subip_pio_writefunction thc_i2c_subip_set_speedfunction thc_i2c_subip_initfunction thc_i2c_subip_regs_savefunction thc_i2c_subip_regs_restorefunction thc_i2c_set_rx_max_sizefunction thc_i2c_set_rx_max_sizefunction thc_i2c_set_rx_int_delayfunction thc_i2c_set_rx_int_delay
Annotated Snippet
#include <linux/bitfield.h>
#include <linux/math.h>
#include <linux/regmap.h>
#include <linux/string_choices.h>
#include "intel-thc-dev.h"
#include "intel-thc-hw.h"
static int thc_regmap_read(void *context, unsigned int reg,
unsigned int *val)
{
struct thc_device *thc_ctx = context;
void __iomem *base = thc_ctx->mmio_addr;
*val = ioread32(base + reg);
return 0;
}
static int thc_regmap_write(void *context, unsigned int reg,
unsigned int val)
{
struct thc_device *thc_ctx = context;
void __iomem *base = thc_ctx->mmio_addr;
iowrite32(val, base + reg);
return 0;
}
static const struct regmap_range thc_rw_ranges[] = {
regmap_reg_range(0x10, 0x14),
regmap_reg_range(0x1000, 0x1320),
};
static const struct regmap_access_table thc_rw_table = {
.yes_ranges = thc_rw_ranges,
.n_yes_ranges = ARRAY_SIZE(thc_rw_ranges),
};
static const struct regmap_config thc_regmap_cfg = {
.name = "thc_regmap_common",
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
.max_register = 0x1320,
.reg_read = thc_regmap_read,
.reg_write = thc_regmap_write,
.cache_type = REGCACHE_NONE,
.fast_io = true,
.rd_table = &thc_rw_table,
.wr_table = &thc_rw_table,
.volatile_table = &thc_rw_table,
};
/**
* thc_clear_state - Clear THC hardware state
*
* @dev: The pointer of THC device structure
*/
static void thc_clear_state(const struct thc_device *dev)
{
u32 val;
/* Clear interrupt cause register */
val = THC_M_PRT_ERR_CAUSE_INVLD_DEV_ENTRY |
THC_M_PRT_ERR_CAUSE_FRAME_BABBLE_ERR |
THC_M_PRT_ERR_CAUSE_BUF_OVRRUN_ERR |
THC_M_PRT_ERR_CAUSE_PRD_ENTRY_ERR;
regmap_write_bits(dev->thc_regmap, THC_M_PRT_ERR_CAUSE_OFFSET, val, val);
/* Clear interrupt error state */
regmap_write_bits(dev->thc_regmap, THC_M_PRT_READ_DMA_CNTRL_1_OFFSET,
THC_M_PRT_READ_DMA_CNTRL_IE_STALL,
THC_M_PRT_READ_DMA_CNTRL_IE_STALL);
regmap_write_bits(dev->thc_regmap, THC_M_PRT_READ_DMA_CNTRL_2_OFFSET,
THC_M_PRT_READ_DMA_CNTRL_IE_STALL,
THC_M_PRT_READ_DMA_CNTRL_IE_STALL);
regmap_write_bits(dev->thc_regmap, THC_M_PRT_INT_STATUS_OFFSET,
THC_M_PRT_INT_STATUS_TXN_ERR_INT_STS,
THC_M_PRT_INT_STATUS_TXN_ERR_INT_STS);
regmap_write_bits(dev->thc_regmap, THC_M_PRT_INT_STATUS_OFFSET,
THC_M_PRT_INT_STATUS_FATAL_ERR_INT_STS,
THC_M_PRT_INT_STATUS_FATAL_ERR_INT_STS);
val = THC_M_PRT_INT_EN_TXN_ERR_INT_EN |
THC_M_PRT_INT_EN_FATAL_ERR_INT_EN |
THC_M_PRT_INT_EN_BUF_OVRRUN_ERR_INT_EN;
regmap_write_bits(dev->thc_regmap, THC_M_PRT_INT_EN_OFFSET, val, val);
val = THC_M_PRT_SW_SEQ_STS_THC_SS_ERR |
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/math.h`, `linux/regmap.h`, `linux/string_choices.h`, `intel-thc-dev.h`, `intel-thc-hw.h`.
- Detected declarations: `function thc_regmap_read`, `function thc_regmap_write`, `function thc_clear_state`, `function prepare_pio`, `function pio_start`, `function pio_complete`, `function pio_wait`, `function thc_tic_pio_read`, `function thc_tic_pio_write`, `function thc_tic_pio_write_and_read`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.