drivers/nfc/pn544/i2c.c
Source file repositories/reference/linux-study-clean/drivers/nfc/pn544/i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/pn544/i2c.c- Extension
.c- Size
- 24300 bytes
- Lines
- 963
- 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.
- 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/crc-ccitt.hlinux/module.hlinux/i2c.hlinux/acpi.hlinux/interrupt.hlinux/delay.hlinux/nfc.hlinux/firmware.hlinux/gpio/consumer.hlinux/unaligned.hnet/nfc/hci.hnet/nfc/llc.hnet/nfc/nfc.hpn544.h
Detected Declarations
struct pn544_i2c_fw_frame_writestruct pn544_i2c_fw_frame_checkstruct pn544_i2c_fw_frame_responsestruct pn544_i2c_fw_blobstruct pn544_i2c_fw_secure_framestruct pn544_i2c_fw_secure_blobstruct pn544_i2c_phyfunction pn544_hci_i2c_platform_initfunction pn544_hci_i2c_enable_modefunction pn544_hci_i2c_enablefunction pn544_hci_i2c_disablefunction pn544_hci_i2c_add_len_crcfunction pn544_hci_i2c_remove_len_crcfunction pn544_hci_i2c_writefunction check_crcfunction pn544_hci_i2c_readfunction pn544_hci_i2c_fw_read_statusfunction onefunction pn544_hci_i2c_fw_downloadfunction pn544_hci_i2c_fw_work_completefunction pn544_hci_i2c_fw_write_cmdfunction pn544_hci_i2c_fw_check_cmdfunction pn544_hci_i2c_fw_write_chunkfunction pn544_hci_i2c_fw_secure_write_frame_cmdfunction pn544_hci_i2c_fw_secure_write_framefunction pn544_hci_i2c_fw_workfunction pn544_hci_i2c_probefunction pn544_hci_i2c_remove
Annotated Snippet
struct pn544_i2c_fw_frame_write {
u8 cmd;
u16 be_length;
u8 be_dest_addr[3];
u16 be_datalen;
u8 data[];
} __packed;
struct pn544_i2c_fw_frame_check {
u8 cmd;
u16 be_length;
u8 be_start_addr[3];
u16 be_datalen;
u16 be_crc;
} __packed;
struct pn544_i2c_fw_frame_response {
u8 status;
u16 be_length;
} __packed;
struct pn544_i2c_fw_blob {
u32 be_size;
u32 be_destaddr;
u8 data[];
};
struct pn544_i2c_fw_secure_frame {
u8 cmd;
u16 be_datalen;
u8 data[];
} __packed;
struct pn544_i2c_fw_secure_blob {
u64 header;
u8 data[];
};
#define PN544_FW_CMD_RESULT_TIMEOUT 0x01
#define PN544_FW_CMD_RESULT_BAD_CRC 0x02
#define PN544_FW_CMD_RESULT_ACCESS_DENIED 0x08
#define PN544_FW_CMD_RESULT_PROTOCOL_ERROR 0x0B
#define PN544_FW_CMD_RESULT_INVALID_PARAMETER 0x11
#define PN544_FW_CMD_RESULT_UNSUPPORTED_COMMAND 0x13
#define PN544_FW_CMD_RESULT_INVALID_LENGTH 0x18
#define PN544_FW_CMD_RESULT_CRYPTOGRAPHIC_ERROR 0x19
#define PN544_FW_CMD_RESULT_VERSION_CONDITIONS_ERROR 0x1D
#define PN544_FW_CMD_RESULT_MEMORY_ERROR 0x20
#define PN544_FW_CMD_RESULT_CHUNK_OK 0x21
#define PN544_FW_CMD_RESULT_WRITE_FAILED 0x74
#define PN544_FW_CMD_RESULT_COMMAND_REJECTED 0xE0
#define PN544_FW_CMD_RESULT_CHUNK_ERROR 0xE6
#define PN544_FW_WRITE_BUFFER_MAX_LEN 0x9f7
#define PN544_FW_I2C_MAX_PAYLOAD PN544_HCI_I2C_LLC_MAX_SIZE
#define PN544_FW_I2C_WRITE_FRAME_HEADER_LEN 8
#define PN544_FW_I2C_WRITE_DATA_MAX_LEN MIN((PN544_FW_I2C_MAX_PAYLOAD -\
PN544_FW_I2C_WRITE_FRAME_HEADER_LEN),\
PN544_FW_WRITE_BUFFER_MAX_LEN)
#define PN544_FW_SECURE_CHUNK_WRITE_HEADER_LEN 3
#define PN544_FW_SECURE_CHUNK_WRITE_DATA_MAX_LEN (PN544_FW_I2C_MAX_PAYLOAD -\
PN544_FW_SECURE_CHUNK_WRITE_HEADER_LEN)
#define PN544_FW_SECURE_FRAME_HEADER_LEN 3
#define PN544_FW_SECURE_BLOB_HEADER_LEN 8
#define FW_WORK_STATE_IDLE 1
#define FW_WORK_STATE_START 2
#define FW_WORK_STATE_WAIT_WRITE_ANSWER 3
#define FW_WORK_STATE_WAIT_CHECK_ANSWER 4
#define FW_WORK_STATE_WAIT_SECURE_WRITE_ANSWER 5
struct pn544_i2c_phy {
struct i2c_client *i2c_dev;
struct nfc_hci_dev *hdev;
struct gpio_desc *gpiod_en;
struct gpio_desc *gpiod_fw;
unsigned int en_polarity;
u8 hw_variant;
struct work_struct fw_work;
int fw_work_state;
char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
const struct firmware *fw;
u32 fw_blob_dest_addr;
size_t fw_blob_size;
const u8 *fw_blob_data;
size_t fw_written;
Annotation
- Immediate include surface: `linux/crc-ccitt.h`, `linux/module.h`, `linux/i2c.h`, `linux/acpi.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/nfc.h`, `linux/firmware.h`.
- Detected declarations: `struct pn544_i2c_fw_frame_write`, `struct pn544_i2c_fw_frame_check`, `struct pn544_i2c_fw_frame_response`, `struct pn544_i2c_fw_blob`, `struct pn544_i2c_fw_secure_frame`, `struct pn544_i2c_fw_secure_blob`, `struct pn544_i2c_phy`, `function pn544_hci_i2c_platform_init`, `function pn544_hci_i2c_enable_mode`, `function pn544_hci_i2c_enable`.
- Atlas domain: Driver Families / drivers/nfc.
- Implementation status: source implementation candidate.
- 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.