drivers/mtd/nand/raw/sh_flctl.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/sh_flctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/sh_flctl.c- Extension
.c- Size
- 29807 bytes
- Lines
- 1232
- 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/module.hlinux/kernel.hlinux/completion.hlinux/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/sh_dma.hlinux/slab.hlinux/string.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/mtd/sh_flctl.h
Detected Declarations
struct flctl_soc_configfunction Copyrightfunction flctl_4secc_ooblayout_sp_freefunction flctl_4secc_ooblayout_lp_eccfunction flctl_4secc_ooblayout_lp_freefunction empty_fifofunction start_translationfunction timeout_errorfunction wait_completionfunction flctl_dma_completefunction flctl_release_dmafunction flctl_setup_dmafunction set_addrfunction wait_rfifo_readyfunction wait_wfifo_readyfunction wait_recfifo_readyfunction wait_wecfifo_readyfunction flctl_dma_fifo0_transferfunction read_dataregfunction read_fiforegfunction read_ecfiforegfunction write_fiforegfunction write_ec_fiforegfunction set_cmd_regsfunction flctl_read_page_hweccfunction flctl_write_page_hweccfunction execmd_read_page_sectorfunction execmd_read_oobfunction execmd_write_page_sectorfunction execmd_write_oobfunction flctl_cmdfuncfunction flctl_select_chipfunction flctl_write_buffunction flctl_read_bytefunction flctl_read_buffunction flctl_chip_attach_chipfunction flctl_handle_flstefunction flctl_probefunction flctl_remove
Annotated Snippet
struct flctl_soc_config {
unsigned long flcmncr_val;
unsigned has_hwecc:1;
unsigned use_holden:1;
};
static struct flctl_soc_config flctl_sh7372_config = {
.flcmncr_val = CLK_16B_12L_4H | TYPESEL_SET | SHBUSSEL,
.has_hwecc = 1,
.use_holden = 1,
};
static const struct of_device_id of_flctl_match[] = {
{ .compatible = "renesas,shmobile-flctl-sh7372",
.data = &flctl_sh7372_config },
{},
};
MODULE_DEVICE_TABLE(of, of_flctl_match);
static struct sh_flctl_platform_data *flctl_parse_dt(struct device *dev)
{
const struct flctl_soc_config *config;
struct sh_flctl_platform_data *pdata;
config = of_device_get_match_data(dev);
if (!config) {
dev_err(dev, "%s: no OF configuration attached\n", __func__);
return NULL;
}
pdata = devm_kzalloc(dev, sizeof(struct sh_flctl_platform_data),
GFP_KERNEL);
if (!pdata)
return NULL;
/* set SoC specific options */
pdata->flcmncr_val = config->flcmncr_val;
pdata->has_hwecc = config->has_hwecc;
pdata->use_holden = config->use_holden;
return pdata;
}
static int flctl_probe(struct platform_device *pdev)
{
struct resource *res;
struct sh_flctl *flctl;
struct mtd_info *flctl_mtd;
struct nand_chip *nand;
struct sh_flctl_platform_data *pdata;
int ret;
int irq;
flctl = devm_kzalloc(&pdev->dev, sizeof(struct sh_flctl), GFP_KERNEL);
if (!flctl)
return -ENOMEM;
flctl->reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(flctl->reg))
return PTR_ERR(flctl->reg);
flctl->fifo = res->start + 0x24; /* FLDTFIFO */
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
ret = devm_request_irq(&pdev->dev, irq, flctl_handle_flste, IRQF_SHARED,
"flste", flctl);
if (ret) {
dev_err(&pdev->dev, "request interrupt failed.\n");
return ret;
}
if (pdev->dev.of_node)
pdata = flctl_parse_dt(&pdev->dev);
else
pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
dev_err(&pdev->dev, "no setup data defined\n");
return -EINVAL;
}
platform_set_drvdata(pdev, flctl);
nand = &flctl->chip;
flctl_mtd = nand_to_mtd(nand);
nand_set_flash_node(nand, pdev->dev.of_node);
flctl_mtd->dev.parent = &pdev->dev;
flctl->pdev = pdev;
flctl->hwecc = pdata->has_hwecc;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/completion.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct flctl_soc_config`, `function Copyright`, `function flctl_4secc_ooblayout_sp_free`, `function flctl_4secc_ooblayout_lp_ecc`, `function flctl_4secc_ooblayout_lp_free`, `function empty_fifo`, `function start_translation`, `function timeout_error`, `function wait_completion`, `function flctl_dma_complete`.
- 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.