drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c- Extension
.c- Size
- 83613 bytes
- Lines
- 2907
- Domain
- Driver Families
- Bucket
- drivers/mtd
- 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/cleanup.hlinux/clk.hlinux/delay.hlinux/slab.hlinux/sched/task_stack.hlinux/interrupt.hlinux/module.hlinux/mtd/partitions.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/pinctrl/consumer.hlinux/dma/mxs-dma.hlinux/string_choices.hgpmi-nand.hgpmi-regs.hbch-regs.h
Detected Declarations
function Copyrightfunction mxs_reset_blockfunction __gpmi_enable_clkfunction gpmi_initfunction gpmi_dump_infofunction gpmi_check_eccfunction bbm_in_data_chunkfunction set_geometry_by_ecc_infofunction get_ecc_strengthfunction set_geometry_for_large_oobfunction legacy_set_geometryfunction common_nfc_set_geometryfunction bch_set_geometryfunction EDOfunction gpmi_nfc_compute_timingsfunction gpmi_nfc_apply_timingsfunction gpmi_setup_interfacefunction gpmi_clear_bchfunction dma_irq_callbackfunction bch_irqfunction gpmi_raw_len_to_lenfunction prepare_data_dmafunction thefunction gpmi_ooblayout_freefunction acquire_register_blockfunction acquire_bch_irqfunction release_dma_channelsfunction acquire_dma_channelsfunction gpmi_get_clksfunction acquire_resourcesfunction release_resourcesfunction gpmi_free_dma_bufferfunction gpmi_alloc_dma_bufferfunction block_mark_swappingfunction gpmi_count_bitflipsfunction gpmi_bch_layout_stdfunction gpmi_ecc_read_pagefunction gpmi_ecc_read_subpagefunction gpmi_ecc_write_pagefunction gpmi_ecc_read_oobfunction gpmi_ecc_write_oobfunction enginefunction enginefunction gpmi_ecc_read_oob_rawfunction gpmi_ecc_write_oob_rawfunction gpmi_block_markbadfunction nand_boot_set_geometryfunction mx23_check_transcription_stamp
Annotated Snippet
if (v) {
ret = clk_prepare_enable(clk);
if (ret)
goto err_clk;
} else {
clk_disable_unprepare(clk);
}
}
return 0;
err_clk:
for (; i > 0; i--)
clk_disable_unprepare(this->resources.clock[i - 1]);
return ret;
}
#define gpmi_enable_clk(x) __gpmi_enable_clk(x, true)
#define gpmi_disable_clk(x) __gpmi_enable_clk(x, false)
static int gpmi_init(struct gpmi_nand_data *this)
{
struct resources *r = &this->resources;
int ret;
ret = pm_runtime_resume_and_get(this->dev);
if (ret < 0)
return ret;
ret = gpmi_reset_block(r->gpmi_regs, false);
if (ret)
goto err_out;
/*
* Reset BCH here, too. We got failures otherwise :(
* See later BCH reset for explanation of MX23 and MX28 handling
*/
ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this));
if (ret)
goto err_out;
/* Choose NAND mode. */
writel(BM_GPMI_CTRL1_GPMI_MODE, r->gpmi_regs + HW_GPMI_CTRL1_CLR);
/* Set the IRQ polarity. */
writel(BM_GPMI_CTRL1_ATA_IRQRDY_POLARITY,
r->gpmi_regs + HW_GPMI_CTRL1_SET);
/* Disable Write-Protection. */
writel(BM_GPMI_CTRL1_DEV_RESET, r->gpmi_regs + HW_GPMI_CTRL1_SET);
/* Select BCH ECC. */
writel(BM_GPMI_CTRL1_BCH_MODE, r->gpmi_regs + HW_GPMI_CTRL1_SET);
/*
* Decouple the chip select from dma channel. We use dma0 for all
* the chips, force all NAND RDY_BUSY inputs to be sourced from
* RDY_BUSY0.
*/
writel(BM_GPMI_CTRL1_DECOUPLE_CS | BM_GPMI_CTRL1_GANGED_RDYBUSY,
r->gpmi_regs + HW_GPMI_CTRL1_SET);
err_out:
pm_runtime_put_autosuspend(this->dev);
return ret;
}
/* This function is very useful. It is called only when the bug occur. */
static void gpmi_dump_info(struct gpmi_nand_data *this)
{
struct resources *r = &this->resources;
struct bch_geometry *geo = &this->bch_geometry;
u32 reg;
int i;
dev_err(this->dev, "Show GPMI registers :\n");
for (i = 0; i <= HW_GPMI_DEBUG / 0x10 + 1; i++) {
reg = readl(r->gpmi_regs + i * 0x10);
dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg);
}
/* start to print out the BCH info */
dev_err(this->dev, "Show BCH registers :\n");
for (i = 0; i <= HW_BCH_VERSION / 0x10 + 1; i++) {
reg = readl(r->bch_regs + i * 0x10);
dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg);
}
dev_err(this->dev, "BCH Geometry :\n"
"GF length : %u\n"
"ECC Strength : %u\n"
"Page Size in Bytes : %u\n"
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/clk.h`, `linux/delay.h`, `linux/slab.h`, `linux/sched/task_stack.h`, `linux/interrupt.h`, `linux/module.h`, `linux/mtd/partitions.h`.
- Detected declarations: `function Copyright`, `function mxs_reset_block`, `function __gpmi_enable_clk`, `function gpmi_init`, `function gpmi_dump_info`, `function gpmi_check_ecc`, `function bbm_in_data_chunk`, `function set_geometry_by_ecc_info`, `function get_ecc_strength`, `function set_geometry_for_large_oob`.
- Atlas domain: Driver Families / drivers/mtd.
- 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.