#include <linux/platform_device.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/sched.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand-ecc-sw-bch.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
#include <linux/omap-dma.h>
#include <linux/iopoll.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_data/elm.h>
#include <linux/omap-gpmc.h>
#include <linux/platform_data/mtd-nand-omap2.h>
#define DRIVER_NAME …
#define OMAP_NAND_TIMEOUT_MS …
#define NAND_Ecc_P1e …
#define NAND_Ecc_P2e …
#define NAND_Ecc_P4e …
#define NAND_Ecc_P8e …
#define NAND_Ecc_P16e …
#define NAND_Ecc_P32e …
#define NAND_Ecc_P64e …
#define NAND_Ecc_P128e …
#define NAND_Ecc_P256e …
#define NAND_Ecc_P512e …
#define NAND_Ecc_P1024e …
#define NAND_Ecc_P2048e …
#define NAND_Ecc_P1o …
#define NAND_Ecc_P2o …
#define NAND_Ecc_P4o …
#define NAND_Ecc_P8o …
#define NAND_Ecc_P16o …
#define NAND_Ecc_P32o …
#define NAND_Ecc_P64o …
#define NAND_Ecc_P128o …
#define NAND_Ecc_P256o …
#define NAND_Ecc_P512o …
#define NAND_Ecc_P1024o …
#define NAND_Ecc_P2048o …
#define TF(value) …
#define P2048e(a) …
#define P2048o(a) …
#define P1e(a) …
#define P1o(a) …
#define P2e(a) …
#define P2o(a) …
#define P4e(a) …
#define P4o(a) …
#define P8e(a) …
#define P8o(a) …
#define P16e(a) …
#define P16o(a) …
#define P32e(a) …
#define P32o(a) …
#define P64e(a) …
#define P64o(a) …
#define P128e(a) …
#define P128o(a) …
#define P256e(a) …
#define P256o(a) …
#define P512e(a) …
#define P512o(a) …
#define P1024e(a) …
#define P1024o(a) …
#define P8e_s(a) …
#define P8o_s(a) …
#define P16e_s(a) …
#define P16o_s(a) …
#define P1e_s(a) …
#define P1o_s(a) …
#define P2e_s(a) …
#define P2o_s(a) …
#define P4e_s(a) …
#define P4o_s(a) …
#define PREFETCH_CONFIG1_CS_SHIFT …
#define ECC_CONFIG_CS_SHIFT …
#define CS_MASK …
#define ENABLE_PREFETCH …
#define DMA_MPU_MODE_SHIFT …
#define ECCSIZE0_SHIFT …
#define ECCSIZE1_SHIFT …
#define ECC1RESULTSIZE …
#define ECCCLEAR …
#define ECC1 …
#define PREFETCH_FIFOTHRESHOLD_MAX …
#define PREFETCH_FIFOTHRESHOLD(val) …
#define PREFETCH_STATUS_COUNT(val) …
#define PREFETCH_STATUS_FIFO_CNT(val) …
#define STATUS_BUFF_EMPTY …
#define SECTOR_BYTES …
#define BCH4_BIT_PAD …
#define BCH_WRAPMODE_1 …
#define BCH8R_ECC_SIZE0 …
#define BCH8R_ECC_SIZE1 …
#define BCH4R_ECC_SIZE0 …
#define BCH4R_ECC_SIZE1 …
#define BCH_WRAPMODE_6 …
#define BCH_ECC_SIZE0 …
#define BCH_ECC_SIZE1 …
#define BBM_LEN …
static u_char bch16_vector[] = …;
static u_char bch8_vector[] = …;
static u_char bch4_vector[] = …;
struct omap_nand_info { … };
static inline struct omap_nand_info *mtd_to_omap(struct mtd_info *mtd)
{ … }
static void omap_nand_data_in(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit);
static void omap_nand_data_out(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit);
static int omap_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write, struct omap_nand_info *info)
{ … }
static int omap_prefetch_reset(int cs, struct omap_nand_info *info)
{ … }
static void omap_nand_data_in_pref(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit)
{ … }
static void omap_nand_data_out_pref(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit)
{ … }
static void omap_nand_dma_callback(void *data)
{ … }
static inline int omap_nand_dma_transfer(struct nand_chip *chip,
const void *addr, unsigned int len,
int is_write)
{ … }
static void omap_nand_data_in_dma_pref(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit)
{ … }
static void omap_nand_data_out_dma_pref(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit)
{ … }
static irqreturn_t omap_nand_irq(int this_irq, void *dev)
{ … }
static void omap_nand_data_in_irq_pref(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit)
{ … }
static void omap_nand_data_out_irq_pref(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit)
{ … }
static void gen_true_ecc(u8 *ecc_buf)
{ … }
static int omap_compare_ecc(u8 *ecc_data1,
u8 *ecc_data2,
u8 *page_data)
{ … }
static int omap_correct_data(struct nand_chip *chip, u_char *dat,
u_char *read_ecc, u_char *calc_ecc)
{ … }
static int omap_calculate_ecc(struct nand_chip *chip, const u_char *dat,
u_char *ecc_code)
{ … }
static void omap_enable_hwecc(struct nand_chip *chip, int mode)
{ … }
static void __maybe_unused omap_enable_hwecc_bch(struct nand_chip *chip,
int mode)
{ … }
static u8 bch4_polynomial[] = …;
static u8 bch8_polynomial[] = …;
static int _omap_calculate_ecc_bch(struct mtd_info *mtd,
const u_char *dat, u_char *ecc_calc, int i)
{ … }
static int omap_calculate_ecc_bch_sw(struct nand_chip *chip,
const u_char *dat, u_char *ecc_calc)
{ … }
static int omap_calculate_ecc_bch_multi(struct mtd_info *mtd,
const u_char *dat, u_char *ecc_calc)
{ … }
static int erased_sector_bitflips(u_char *data, u_char *oob,
struct omap_nand_info *info)
{ … }
static int omap_elm_correct_data(struct nand_chip *chip, u_char *data,
u_char *read_ecc, u_char *calc_ecc)
{ … }
static int omap_write_page_bch(struct nand_chip *chip, const uint8_t *buf,
int oob_required, int page)
{ … }
static int omap_write_subpage_bch(struct nand_chip *chip, u32 offset,
u32 data_len, const u8 *buf,
int oob_required, int page)
{ … }
static int omap_read_page_bch(struct nand_chip *chip, uint8_t *buf,
int oob_required, int page)
{ … }
static bool is_elm_present(struct omap_nand_info *info,
struct device_node *elm_node)
{ … }
static bool omap2_nand_ecc_check(struct omap_nand_info *info)
{ … }
static const char * const nand_xfer_types[] = …;
static int omap_get_dt_info(struct device *dev, struct omap_nand_info *info)
{ … }
static int omap_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static int omap_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static const struct mtd_ooblayout_ops omap_ooblayout_ops = …;
static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static const struct mtd_ooblayout_ops omap_sw_ooblayout_ops = …;
static int omap_nand_attach_chip(struct nand_chip *chip)
{ … }
static void omap_nand_data_in(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit)
{ … }
static void omap_nand_data_out(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit)
{ … }
static int omap_nand_exec_instr(struct nand_chip *chip,
const struct nand_op_instr *instr)
{ … }
static int omap_nand_exec_op(struct nand_chip *chip,
const struct nand_operation *op,
bool check_only)
{ … }
static const struct nand_controller_ops omap_nand_controller_ops = …;
static struct nand_controller omap_gpmc_controller;
static bool omap_gpmc_controller_initialized;
static int omap_nand_probe(struct platform_device *pdev)
{ … }
static void omap_nand_remove(struct platform_device *pdev)
{ … }
MODULE_DEVICE_TABLE(of, omap_nand_ids);
static struct platform_driver omap_nand_driver = …;
module_platform_driver(…) …;
MODULE_ALIAS(…) …;
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;