#include <linux/slab.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/mtd/lpc32xx_slc.h>
#define LPC32XX_MODNAME …
#define SLC_DATA(x) …
#define SLC_ADDR(x) …
#define SLC_CMD(x) …
#define SLC_STOP(x) …
#define SLC_CTRL(x) …
#define SLC_CFG(x) …
#define SLC_STAT(x) …
#define SLC_INT_STAT(x) …
#define SLC_IEN(x) …
#define SLC_ISR(x) …
#define SLC_ICR(x) …
#define SLC_TAC(x) …
#define SLC_TC(x) …
#define SLC_ECC(x) …
#define SLC_DMA_DATA(x) …
#define SLCCTRL_SW_RESET …
#define SLCCTRL_ECC_CLEAR …
#define SLCCTRL_DMA_START …
#define SLCCFG_CE_LOW …
#define SLCCFG_DMA_ECC …
#define SLCCFG_ECC_EN …
#define SLCCFG_DMA_BURST …
#define SLCCFG_DMA_DIR …
#define SLCCFG_WIDTH …
#define SLCSTAT_DMA_FIFO …
#define SLCSTAT_SLC_FIFO …
#define SLCSTAT_NAND_READY …
#define SLCSTAT_INT_TC …
#define SLCSTAT_INT_RDY_EN …
#define SLCTAC_CLOCKS(c, n, s) …
#define SLCTAC_WDR(n) …
#define SLCTAC_WWIDTH(c, n) …
#define SLCTAC_WHOLD(c, n) …
#define SLCTAC_WSETUP(c, n) …
#define SLCTAC_RDR(n) …
#define SLCTAC_RWIDTH(c, n) …
#define SLCTAC_RHOLD(c, n) …
#define SLCTAC_RSETUP(c, n) …
#define SLCECC_TO_LINEPAR(n) …
#define SLCECC_TO_COLPAR(n) …
#define LPC32XX_DMA_DATA_SIZE …
#define LPC32XX_ECC_SAVE_SIZE …
#define LPC32XX_SLC_DEV_ECC_BYTES …
#define LPC32XX_DEF_BUS_RATE …
#define LPC32XX_DMA_TIMEOUT …
static int lpc32xx_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static int lpc32xx_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static const struct mtd_ooblayout_ops lpc32xx_ooblayout_ops = …;
static u8 bbt_pattern[] = …;
static u8 mirror_pattern[] = …;
static struct nand_bbt_descr bbt_smallpage_main_descr = …;
static struct nand_bbt_descr bbt_smallpage_mirror_descr = …;
struct lpc32xx_nand_cfg_slc { … };
struct lpc32xx_nand_host { … };
static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)
{ … }
static void lpc32xx_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
unsigned int ctrl)
{ … }
static int lpc32xx_nand_device_ready(struct nand_chip *chip)
{ … }
static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host)
{ … }
static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host)
{ … }
static void lpc32xx_nand_ecc_enable(struct nand_chip *chip, int mode)
{ … }
static int lpc32xx_nand_ecc_calculate(struct nand_chip *chip,
const unsigned char *buf,
unsigned char *code)
{ … }
static uint8_t lpc32xx_nand_read_byte(struct nand_chip *chip)
{ … }
static void lpc32xx_nand_read_buf(struct nand_chip *chip, u_char *buf, int len)
{ … }
static void lpc32xx_nand_write_buf(struct nand_chip *chip, const uint8_t *buf,
int len)
{ … }
static int lpc32xx_nand_read_oob_syndrome(struct nand_chip *chip, int page)
{ … }
static int lpc32xx_nand_write_oob_syndrome(struct nand_chip *chip, int page)
{ … }
static void lpc32xx_slc_ecc_copy(uint8_t *spare, const uint32_t *ecc, int count)
{ … }
static void lpc32xx_dma_complete_func(void *completion)
{ … }
static int lpc32xx_xmit_dma(struct mtd_info *mtd, dma_addr_t dma,
void *mem, int len, enum dma_transfer_direction dir)
{ … }
static int lpc32xx_xfer(struct mtd_info *mtd, uint8_t *buf, int eccsubpages,
int read)
{ … }
static int lpc32xx_nand_read_page_syndrome(struct nand_chip *chip, uint8_t *buf,
int oob_required, int page)
{ … }
static int lpc32xx_nand_read_page_raw_syndrome(struct nand_chip *chip,
uint8_t *buf, int oob_required,
int page)
{ … }
static int lpc32xx_nand_write_page_syndrome(struct nand_chip *chip,
const uint8_t *buf,
int oob_required, int page)
{ … }
static int lpc32xx_nand_write_page_raw_syndrome(struct nand_chip *chip,
const uint8_t *buf,
int oob_required, int page)
{ … }
static int lpc32xx_nand_dma_setup(struct lpc32xx_nand_host *host)
{ … }
static struct lpc32xx_nand_cfg_slc *lpc32xx_parse_dt(struct device *dev)
{ … }
static int lpc32xx_nand_attach_chip(struct nand_chip *chip)
{ … }
static const struct nand_controller_ops lpc32xx_nand_controller_ops = …;
static int lpc32xx_nand_probe(struct platform_device *pdev)
{ … }
static void lpc32xx_nand_remove(struct platform_device *pdev)
{ … }
static int lpc32xx_nand_resume(struct platform_device *pdev)
{ … }
static int lpc32xx_nand_suspend(struct platform_device *pdev, pm_message_t pm)
{ … }
static const struct of_device_id lpc32xx_nand_match[] = …;
MODULE_DEVICE_TABLE(of, lpc32xx_nand_match);
static struct platform_driver lpc32xx_nand_driver = …;
module_platform_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;