drivers/mtd/nand/qpic_common.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/qpic_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/qpic_common.c- Extension
.c- Size
- 21905 bytes
- Lines
- 780
- Domain
- Driver Families
- Bucket
- drivers/mtd
- 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.
- 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/clk.hlinux/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/dma/qcom_adm.hlinux/dma/qcom_bam_dma.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/mtd/nand-qpic-common.h
Detected Declarations
function Copyrightfunction qcom_alloc_bam_transactionfunction qcom_clear_bam_transactionfunction qcom_qpic_bam_dma_donefunction qcom_nandc_dev_to_memfunction qcom_prepare_bam_async_descfunction qcom_prep_bam_dma_desc_cmdfunction qcom_prep_bam_dma_desc_datafunction qcom_prep_adm_dma_descfunction qcom_read_reg_dmafunction qcom_write_reg_dmafunction qcom_read_data_dmafunction qcom_write_data_dmafunction qcom_submit_descsfunction qcom_prepare_bam_async_descfunction qcom_clear_read_regsfunction qcom_nandc_unallocfunction qcom_nandc_allocexport qcom_free_bam_transactionexport qcom_alloc_bam_transactionexport qcom_clear_bam_transactionexport qcom_qpic_bam_dma_doneexport qcom_nandc_dev_to_memexport qcom_prepare_bam_async_descexport qcom_prep_bam_dma_desc_cmdexport qcom_prep_bam_dma_desc_dataexport qcom_prep_adm_dma_descexport qcom_read_reg_dmaexport qcom_write_reg_dmaexport qcom_read_data_dmaexport qcom_write_data_dmaexport qcom_submit_descsexport qcom_clear_read_regsexport qcom_nandc_unallocexport qcom_nandc_alloc
Annotated Snippet
if (bam_txn->cmd_sgl_pos >= bam_txn->cmd_sgl_nitems) {
dev_err(nandc->dev, "BAM %s array is full\n",
"CMD sgl");
return -EINVAL;
}
bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_start];
bam_ce_size = (bam_txn->bam_ce_pos -
bam_txn->bam_ce_start) *
sizeof(struct bam_cmd_element);
sg_set_buf(&bam_txn->cmd_sgl[bam_txn->cmd_sgl_pos],
bam_ce_buffer, bam_ce_size);
bam_txn->cmd_sgl_pos++;
bam_txn->bam_ce_start = bam_txn->bam_ce_pos;
if (flags & NAND_BAM_NWD) {
ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan,
DMA_PREP_FENCE | DMA_PREP_CMD);
if (ret)
return ret;
}
}
return 0;
}
EXPORT_SYMBOL(qcom_prep_bam_dma_desc_cmd);
/**
* qcom_prep_bam_dma_desc_data() - Prepares the data descriptor for BAM DMA
* @nandc: qpic nand controller
* @read: read or write type
* @vaddr: virtual address of the buffer we want to write to
* @size: DMA transaction size in bytes
* @flags: flags to control DMA descriptor preparation
*
* This function will prepares the data descriptor for BAM DMA which
* will be used for NAND data reads and writes.
*/
int qcom_prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read,
const void *vaddr, int size, unsigned int flags)
{
int ret;
struct bam_transaction *bam_txn = nandc->bam_txn;
if (read) {
if (bam_txn->rx_sgl_pos >= bam_txn->data_sgl_nitems) {
dev_err(nandc->dev, "BAM %s array is full\n", "RX sgl");
return -EINVAL;
}
sg_set_buf(&bam_txn->data_sgl[bam_txn->rx_sgl_pos],
vaddr, size);
bam_txn->rx_sgl_pos++;
} else {
if (bam_txn->tx_sgl_pos >= bam_txn->data_sgl_nitems) {
dev_err(nandc->dev, "BAM %s array is full\n", "TX sgl");
return -EINVAL;
}
sg_set_buf(&bam_txn->data_sgl[bam_txn->tx_sgl_pos],
vaddr, size);
bam_txn->tx_sgl_pos++;
/*
* BAM will only set EOT for DMA_PREP_INTERRUPT so if this flag
* is not set, form the DMA descriptor
*/
if (!(flags & NAND_BAM_NO_EOT)) {
ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan,
DMA_PREP_INTERRUPT);
if (ret)
return ret;
}
}
return 0;
}
EXPORT_SYMBOL(qcom_prep_bam_dma_desc_data);
/**
* qcom_prep_adm_dma_desc() - Prepare descriptor for adma
* @nandc: qpic nand controller
* @read: read or write type
* @reg_off: offset within the controller's data buffer
* @vaddr: virtual address of the buffer we want to write to
* @size: adm dma transaction size in bytes
* @flow_control: flow controller
*
* This function will prepare descriptor for adma
*/
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/dma/qcom_adm.h`, `linux/dma/qcom_bam_dma.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `function Copyright`, `function qcom_alloc_bam_transaction`, `function qcom_clear_bam_transaction`, `function qcom_qpic_bam_dma_done`, `function qcom_nandc_dev_to_mem`, `function qcom_prepare_bam_async_desc`, `function qcom_prep_bam_dma_desc_cmd`, `function qcom_prep_bam_dma_desc_data`, `function qcom_prep_adm_dma_desc`, `function qcom_read_reg_dma`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: integration 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.