drivers/nfc/trf7970a.c
Source file repositories/reference/linux-study-clean/drivers/nfc/trf7970a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/trf7970a.c- Extension
.c- Size
- 66067 bytes
- Lines
- 2336
- Domain
- Driver Families
- Bucket
- drivers/nfc
- 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/module.hlinux/device.hlinux/netdevice.hlinux/interrupt.hlinux/pm_runtime.hlinux/nfc.hlinux/skbuff.hlinux/delay.hlinux/gpio/consumer.hlinux/of.hlinux/spi/spi.hlinux/regulator/consumer.hnet/nfc/nfc.hnet/nfc/digital.h
Detected Declarations
struct trf7970aenum trf7970a_statefunction trf7970a_cmdfunction trf7970a_readfunction trf7970a_read_contfunction trf7970a_writefunction trf7970a_read_irqstatusfunction trf7970a_update_rx_gain_reductionfunction trf7970a_update_iso_ctrl_registerfunction trf7970a_read_target_protofunction trf7970a_mode_detectfunction trf7970a_send_upstreamfunction trf7970a_send_err_upstreamfunction trf7970a_transmitfunction trf7970a_fill_fifofunction trf7970a_drain_fifofunction trf7970a_irqfunction trf7970a_issue_eoffunction trf7970a_timeout_work_handlerfunction trf7970a_initfunction trf7970a_switch_rf_offfunction trf7970a_switch_rf_onfunction trf7970a_switch_rffunction trf7970a_in_config_rf_techfunction trf7970a_is_rf_fieldfunction trf7970a_in_config_framingfunction trf7970a_in_configure_hwfunction trf7970a_is_iso15693_write_or_lockfunction trf7970a_per_cmd_configfunction trf7970a_send_cmdfunction trf7970a_tg_config_rf_techfunction trf7970a_tg_config_framingfunction trf7970a_tg_config_framingfunction trf7970a_tg_configure_hwfunction _trf7970a_tg_listenfunction trf7970a_tg_listenfunction trf7970a_tg_listen_mdfunction trf7970a_tg_get_rf_techfunction trf7970a_abort_cmdfunction trf7970a_power_upfunction trf7970a_power_downfunction trf7970a_startupfunction trf7970a_shutdownfunction trf7970a_get_autosuspend_delayfunction trf7970a_probefunction trf7970a_removefunction trf7970a_suspendfunction trf7970a_resume
Annotated Snippet
struct trf7970a {
enum trf7970a_state state;
struct device *dev;
struct spi_device *spi;
struct regulator *vin_regulator;
struct regulator *vddio_regulator;
struct nfc_digital_dev *ddev;
u32 quirks;
bool is_initiator;
bool aborting;
struct sk_buff *tx_skb;
struct sk_buff *rx_skb;
nfc_digital_cmd_complete_t cb;
void *cb_arg;
u8 chip_status_ctrl;
u8 iso_ctrl;
u8 iso_ctrl_tech;
u8 modulator_sys_clk_ctrl;
u8 special_fcn_reg1;
u8 io_ctrl;
unsigned int guard_time;
int technology;
int framing;
u8 md_rf_tech;
u8 tx_cmd;
bool issue_eof;
struct gpio_desc *en_gpiod;
struct gpio_desc *en2_gpiod;
struct mutex lock;
unsigned int timeout;
bool ignore_timeout;
struct delayed_work timeout_work;
u8 rx_gain_reduction;
bool custom_rx_gain_reduction;
};
static int trf7970a_cmd(struct trf7970a *trf, u8 opcode)
{
u8 cmd = TRF7970A_CMD_BIT_CTRL | TRF7970A_CMD_BIT_OPCODE(opcode);
int ret;
dev_dbg(trf->dev, "cmd: 0x%x\n", cmd);
ret = spi_write(trf->spi, &cmd, 1);
if (ret)
dev_err(trf->dev, "%s - cmd: 0x%x, ret: %d\n", __func__, cmd,
ret);
return ret;
}
static int trf7970a_read(struct trf7970a *trf, u8 reg, u8 *val)
{
u8 addr = TRF7970A_CMD_BIT_RW | reg;
int ret;
ret = spi_write_then_read(trf->spi, &addr, 1, val, 1);
if (ret)
dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr,
ret);
dev_dbg(trf->dev, "read(0x%x): 0x%x\n", addr, *val);
return ret;
}
static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, u8 *buf,
size_t len)
{
u8 addr = reg | TRF7970A_CMD_BIT_RW | TRF7970A_CMD_BIT_CONTINUOUS;
struct spi_transfer t[2];
struct spi_message m;
int ret;
dev_dbg(trf->dev, "read_cont(0x%x, %zd)\n", addr, len);
spi_message_init(&m);
memset(&t, 0, sizeof(t));
t[0].tx_buf = &addr;
t[0].len = sizeof(addr);
spi_message_add_tail(&t[0], &m);
t[1].rx_buf = buf;
t[1].len = len;
spi_message_add_tail(&t[1], &m);
ret = spi_sync(trf->spi, &m);
if (ret)
dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr,
Annotation
- Immediate include surface: `linux/module.h`, `linux/device.h`, `linux/netdevice.h`, `linux/interrupt.h`, `linux/pm_runtime.h`, `linux/nfc.h`, `linux/skbuff.h`, `linux/delay.h`.
- Detected declarations: `struct trf7970a`, `enum trf7970a_state`, `function trf7970a_cmd`, `function trf7970a_read`, `function trf7970a_read_cont`, `function trf7970a_write`, `function trf7970a_read_irqstatus`, `function trf7970a_update_rx_gain_reduction`, `function trf7970a_update_iso_ctrl_register`, `function trf7970a_read_target_proto`.
- Atlas domain: Driver Families / drivers/nfc.
- 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.