drivers/char/tpm/tpm_tis_spi_main.c
Source file repositories/reference/linux-study-clean/drivers/char/tpm/tpm_tis_spi_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/tpm/tpm_tis_spi_main.c- Extension
.c- Size
- 9413 bytes
- Lines
- 363
- Domain
- Driver Families
- Bucket
- drivers/char
- 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.
- 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/acpi.hlinux/completion.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/of.hlinux/spi/spi.hlinux/tpm.htpm.htpm_tis_core.htpm_tis_spi.h
Detected Declarations
function Copyrightfunction tpm_tis_spi_transfer_halffunction tpm_tis_spi_transfer_fullfunction tpm_tis_spi_transferfunction tpm_tis_spi_read_bytesfunction tpm_tis_spi_write_bytesfunction tpm_tis_spi_initfunction tpm_tis_spi_probefunction tpm_tis_spi_driver_probefunction tpm_tis_spi_remove
Annotated Snippet
if (out) {
spi_xfer[2].tx_buf = &phy->iobuf[4];
spi_xfer[2].rx_buf = NULL;
memcpy(&phy->iobuf[4], out, transfer_len);
out += transfer_len;
}
if (in) {
spi_xfer[2].tx_buf = NULL;
spi_xfer[2].rx_buf = &phy->iobuf[4];
}
spi_xfer[2].len = transfer_len;
spi_message_add_tail(&spi_xfer[2], &m);
reinit_completion(&phy->ready);
ret = spi_sync(phy->spi_device, &m);
if (ret < 0)
return ret;
if (in) {
memcpy(in, &phy->iobuf[4], transfer_len);
in += transfer_len;
}
len -= transfer_len;
}
return ret;
}
static int tpm_tis_spi_transfer_full(struct tpm_tis_data *data, u32 addr,
u16 len, u8 *in, const u8 *out)
{
struct tpm_tis_spi_phy *phy = to_tpm_tis_spi_phy(data);
int ret = 0;
struct spi_message m;
struct spi_transfer spi_xfer;
u8 transfer_len;
spi_bus_lock(phy->spi_device->controller);
while (len) {
transfer_len = min_t(u16, len, MAX_SPI_FRAMESIZE);
phy->iobuf[0] = (in ? 0x80 : 0) | (transfer_len - 1);
phy->iobuf[1] = 0xd4;
phy->iobuf[2] = addr >> 8;
phy->iobuf[3] = addr;
memset(&spi_xfer, 0, sizeof(spi_xfer));
spi_xfer.tx_buf = phy->iobuf;
spi_xfer.rx_buf = phy->iobuf;
spi_xfer.len = 4;
spi_xfer.cs_change = 1;
spi_message_init(&m);
spi_message_add_tail(&spi_xfer, &m);
ret = spi_sync_locked(phy->spi_device, &m);
if (ret < 0)
goto exit;
/* Flow control transfers are receive only */
spi_xfer.tx_buf = NULL;
ret = phy->flow_control(phy, &spi_xfer);
if (ret < 0)
goto exit;
spi_xfer.cs_change = 0;
spi_xfer.len = transfer_len;
spi_xfer.delay.value = 5;
spi_xfer.delay.unit = SPI_DELAY_UNIT_USECS;
if (out) {
spi_xfer.tx_buf = phy->iobuf;
spi_xfer.rx_buf = NULL;
memcpy(phy->iobuf, out, transfer_len);
out += transfer_len;
}
spi_message_init(&m);
spi_message_add_tail(&spi_xfer, &m);
reinit_completion(&phy->ready);
ret = spi_sync_locked(phy->spi_device, &m);
if (ret < 0)
goto exit;
if (in) {
memcpy(in, phy->iobuf, transfer_len);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/completion.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/of.h`.
- Detected declarations: `function Copyright`, `function tpm_tis_spi_transfer_half`, `function tpm_tis_spi_transfer_full`, `function tpm_tis_spi_transfer`, `function tpm_tis_spi_read_bytes`, `function tpm_tis_spi_write_bytes`, `function tpm_tis_spi_init`, `function tpm_tis_spi_probe`, `function tpm_tis_spi_driver_probe`, `function tpm_tis_spi_remove`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: source implementation candidate.
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.