drivers/mtd/nand/raw/lpc32xx_slc.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/lpc32xx_slc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/lpc32xx_slc.c- Extension
.c- Size
- 29004 bytes
- Lines
- 1028
- 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/slab.hlinux/module.hlinux/platform_device.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/clk.hlinux/err.hlinux/delay.hlinux/io.hlinux/mm.hlinux/dma-mapping.hlinux/dmaengine.hlinux/gpio/consumer.hlinux/of.hlinux/mtd/lpc32xx_slc.h
Detected Declarations
struct lpc32xx_nand_cfg_slcstruct lpc32xx_nand_hostfunction lpc32xx_ooblayout_eccfunction lpc32xx_ooblayout_freefunction lpc32xx_nand_setupfunction lpc32xx_nand_cmd_ctrlfunction lpc32xx_nand_device_readyfunction lpc32xx_wp_enablefunction lpc32xx_wp_disablefunction lpc32xx_nand_ecc_enablefunction lpc32xx_nand_read_bytefunction lpc32xx_nand_read_buffunction lpc32xx_nand_write_buffunction lpc32xx_nand_read_oob_syndromefunction lpc32xx_nand_write_oob_syndromefunction lpc32xx_slc_ecc_copyfunction lpc32xx_dma_complete_funcfunction lpc32xx_xmit_dmafunction lpc32xx_xferfunction driverfunction lpc32xx_nand_read_page_syndromefunction lpc32xx_nand_read_page_raw_syndromefunction lpc32xx_nand_write_page_syndromefunction lpc32xx_nand_write_page_raw_syndromefunction lpc32xx_nand_dma_setupfunction lpc32xx_nand_attach_chipfunction lpc32xx_nand_probefunction lpc32xx_nand_removefunction lpc32xx_nand_resumefunction lpc32xx_nand_suspend
Annotated Snippet
struct lpc32xx_nand_cfg_slc {
uint32_t wdr_clks;
uint32_t wwidth;
uint32_t whold;
uint32_t wsetup;
uint32_t rdr_clks;
uint32_t rwidth;
uint32_t rhold;
uint32_t rsetup;
struct mtd_partition *parts;
unsigned num_parts;
};
struct lpc32xx_nand_host {
struct nand_chip nand_chip;
struct lpc32xx_slc_platform_data *pdata;
struct clk *clk;
struct gpio_desc *wp_gpio;
void __iomem *io_base;
struct lpc32xx_nand_cfg_slc *ncfg;
struct completion comp;
struct dma_chan *dma_chan;
uint32_t dma_buf_len;
struct dma_slave_config dma_slave_config;
struct scatterlist sgl;
/*
* DMA and CPU addresses of ECC work area and data buffer
*/
uint32_t *ecc_buf;
uint8_t *data_buf;
dma_addr_t io_base_dma;
};
static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)
{
uint32_t clkrate, tmp;
/* Reset SLC controller */
writel(SLCCTRL_SW_RESET, SLC_CTRL(host->io_base));
udelay(1000);
/* Basic setup */
writel(0, SLC_CFG(host->io_base));
writel(0, SLC_IEN(host->io_base));
writel((SLCSTAT_INT_TC | SLCSTAT_INT_RDY_EN),
SLC_ICR(host->io_base));
/* Get base clock for SLC block */
clkrate = clk_get_rate(host->clk);
if (clkrate == 0)
clkrate = LPC32XX_DEF_BUS_RATE;
/* Compute clock setup values */
tmp = SLCTAC_WDR(host->ncfg->wdr_clks) |
SLCTAC_WWIDTH(clkrate, host->ncfg->wwidth) |
SLCTAC_WHOLD(clkrate, host->ncfg->whold) |
SLCTAC_WSETUP(clkrate, host->ncfg->wsetup) |
SLCTAC_RDR(host->ncfg->rdr_clks) |
SLCTAC_RWIDTH(clkrate, host->ncfg->rwidth) |
SLCTAC_RHOLD(clkrate, host->ncfg->rhold) |
SLCTAC_RSETUP(clkrate, host->ncfg->rsetup);
writel(tmp, SLC_TAC(host->io_base));
}
/*
* Hardware specific access to control lines
*/
static void lpc32xx_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
unsigned int ctrl)
{
uint32_t tmp;
struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
/* Does CE state need to be changed? */
tmp = readl(SLC_CFG(host->io_base));
if (ctrl & NAND_NCE)
tmp |= SLCCFG_CE_LOW;
else
tmp &= ~SLCCFG_CE_LOW;
writel(tmp, SLC_CFG(host->io_base));
if (cmd != NAND_CMD_NONE) {
if (ctrl & NAND_CLE)
writel(cmd, SLC_CMD(host->io_base));
else
writel(cmd, SLC_ADDR(host->io_base));
}
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/platform_device.h`, `linux/mtd/mtd.h`, `linux/mtd/rawnand.h`, `linux/mtd/partitions.h`, `linux/clk.h`, `linux/err.h`.
- Detected declarations: `struct lpc32xx_nand_cfg_slc`, `struct lpc32xx_nand_host`, `function lpc32xx_ooblayout_ecc`, `function lpc32xx_ooblayout_free`, `function lpc32xx_nand_setup`, `function lpc32xx_nand_cmd_ctrl`, `function lpc32xx_nand_device_ready`, `function lpc32xx_wp_enable`, `function lpc32xx_wp_disable`, `function lpc32xx_nand_ecc_enable`.
- 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.