#include <linux/module.h>
#include <linux/clk.h>
#include <linux/mtd/rawnand.h>
#include <linux/of.h>
#include <linux/iopoll.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/unaligned.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/dma/pxa-dma.h>
#include <linux/platform_data/mtd-nand-pxa3xx.h>
#define FIFO_DEPTH …
#define FIFO_REP(x) …
#define BCH_SEQ_READS …
#define MAX_CHUNK_SIZE …
#define NFCV1_READID_LEN …
#define POLL_PERIOD …
#define POLL_TIMEOUT …
#define IRQ_TIMEOUT …
#define MIN_RD_DEL_CNT …
#define MAX_ADDRESS_CYC_NFCV1 …
#define MAX_ADDRESS_CYC_NFCV2 …
#define GENCONF_SOC_DEVICE_MUX …
#define GENCONF_SOC_DEVICE_MUX_NFC_EN …
#define GENCONF_SOC_DEVICE_MUX_ECC_CLK_RST …
#define GENCONF_SOC_DEVICE_MUX_ECC_CORE_RST …
#define GENCONF_SOC_DEVICE_MUX_NFC_INT_EN …
#define GENCONF_SOC_DEVICE_MUX_NFC_DEVBUS_ARB_EN …
#define GENCONF_CLK_GATING_CTRL …
#define GENCONF_CLK_GATING_CTRL_ND_GATE …
#define GENCONF_ND_CLK_CTRL …
#define GENCONF_ND_CLK_CTRL_EN …
#define NDCR …
#define NDCR_ALL_INT …
#define NDCR_CS1_CMDDM …
#define NDCR_CS0_CMDDM …
#define NDCR_RDYM …
#define NDCR_ND_ARB_EN …
#define NDCR_RA_START …
#define NDCR_RD_ID_CNT(x) …
#define NDCR_PAGE_SZ(x) …
#define NDCR_DWIDTH_M …
#define NDCR_DWIDTH_C …
#define NDCR_ND_RUN …
#define NDCR_DMA_EN …
#define NDCR_ECC_EN …
#define NDCR_SPARE_EN …
#define NDCR_GENERIC_FIELDS_MASK …
#define NDTR0 …
#define NDTR0_TRP(x) …
#define NDTR0_TRH(x) …
#define NDTR0_ETRP(x) …
#define NDTR0_SEL_NRE_EDGE …
#define NDTR0_TWP(x) …
#define NDTR0_TWH(x) …
#define NDTR0_TCS(x) …
#define NDTR0_TCH(x) …
#define NDTR0_RD_CNT_DEL(x) …
#define NDTR0_SELCNTR …
#define NDTR0_TADL(x) …
#define NDTR1 …
#define NDTR1_TAR(x) …
#define NDTR1_TWHR(x) …
#define NDTR1_TRHW(x) …
#define NDTR1_PRESCALE …
#define NDTR1_WAIT_MODE …
#define NDTR1_TR(x) …
#define NDSR …
#define NDSR_WRCMDREQ …
#define NDSR_RDDREQ …
#define NDSR_WRDREQ …
#define NDSR_CORERR …
#define NDSR_UNCERR …
#define NDSR_CMDD(cs) …
#define NDSR_RDY(rb) …
#define NDSR_ERRCNT(x) …
#define NDECCCTRL …
#define NDECCCTRL_BCH_EN …
#define NDDB …
#define NDCB0 …
#define NDCB0_CMD1(x) …
#define NDCB0_CMD2(x) …
#define NDCB0_ADDR_CYC(x) …
#define NDCB0_ADDR_GET_NUM_CYC(x) …
#define NDCB0_DBC …
#define NDCB0_CMD_TYPE(x) …
#define NDCB0_CSEL …
#define NDCB0_RDY_BYP …
#define NDCB0_LEN_OVRD …
#define NDCB0_CMD_XTYPE(x) …
#define NDCB1 …
#define NDCB1_COLS(x) …
#define NDCB1_ADDRS_PAGE(x) …
#define NDCB2 …
#define NDCB2_ADDR5_PAGE(x) …
#define NDCB2_ADDR5_CYC(x) …
#define NDCB3 …
#define NDCB3_ADDR6_CYC(x) …
#define NDCB3_ADDR7_CYC(x) …
#define TYPE_READ …
#define TYPE_WRITE …
#define TYPE_ERASE …
#define TYPE_READ_ID …
#define TYPE_STATUS …
#define TYPE_RESET …
#define TYPE_NAKED_CMD …
#define TYPE_NAKED_ADDR …
#define TYPE_MASK …
#define XTYPE_MONOLITHIC_RW …
#define XTYPE_LAST_NAKED_RW …
#define XTYPE_FINAL_COMMAND …
#define XTYPE_READ …
#define XTYPE_WRITE_DISPATCH …
#define XTYPE_NAKED_RW …
#define XTYPE_COMMAND_DISPATCH …
#define XTYPE_MASK …
struct marvell_hw_ecc_layout { … };
#define MARVELL_LAYOUT(ws, dc, ds, nc, fcc, db, sb, eb, ldb, lsb, leb) …
static const struct marvell_hw_ecc_layout marvell_nfc_layouts[] = …;
struct marvell_nand_chip_sel { … };
struct marvell_nand_chip { … };
static inline struct marvell_nand_chip *to_marvell_nand(struct nand_chip *chip)
{ … }
static inline struct marvell_nand_chip_sel *to_nand_sel(struct marvell_nand_chip
*nand)
{ … }
struct marvell_nfc_caps { … };
struct marvell_nfc { … };
static inline struct marvell_nfc *to_marvell_nfc(struct nand_controller *ctrl)
{ … }
struct marvell_nfc_timings { … };
#define TO_CYCLES(ps, period_ns) …
#define TO_CYCLES64(ps, period_ns) …
struct marvell_nfc_op { … };
static void cond_delay(unsigned int ns)
{ … }
static void marvell_nfc_disable_int(struct marvell_nfc *nfc, u32 int_mask)
{ … }
static void marvell_nfc_enable_int(struct marvell_nfc *nfc, u32 int_mask)
{ … }
static u32 marvell_nfc_clear_int(struct marvell_nfc *nfc, u32 int_mask)
{ … }
static void marvell_nfc_force_byte_access(struct nand_chip *chip,
bool force_8bit)
{ … }
static int marvell_nfc_wait_ndrun(struct nand_chip *chip)
{ … }
static int marvell_nfc_prepare_cmd(struct nand_chip *chip)
{ … }
static void marvell_nfc_send_cmd(struct nand_chip *chip,
struct marvell_nfc_op *nfc_op)
{ … }
static int marvell_nfc_end_cmd(struct nand_chip *chip, int flag,
const char *label)
{ … }
static int marvell_nfc_wait_cmdd(struct nand_chip *chip)
{ … }
static int marvell_nfc_poll_status(struct marvell_nfc *nfc, u32 mask,
u32 expected_val, unsigned long timeout_ms)
{ … }
static int marvell_nfc_wait_op(struct nand_chip *chip, unsigned int timeout_ms)
{ … }
static void marvell_nfc_select_target(struct nand_chip *chip,
unsigned int die_nr)
{ … }
static irqreturn_t marvell_nfc_isr(int irq, void *dev_id)
{ … }
static void marvell_nfc_enable_hw_ecc(struct nand_chip *chip)
{ … }
static void marvell_nfc_disable_hw_ecc(struct nand_chip *chip)
{ … }
static void marvell_nfc_enable_dma(struct marvell_nfc *nfc)
{ … }
static void marvell_nfc_disable_dma(struct marvell_nfc *nfc)
{ … }
static int marvell_nfc_xfer_data_dma(struct marvell_nfc *nfc,
enum dma_data_direction direction,
unsigned int len)
{ … }
static int marvell_nfc_xfer_data_in_pio(struct marvell_nfc *nfc, u8 *in,
unsigned int len)
{ … }
static int marvell_nfc_xfer_data_out_pio(struct marvell_nfc *nfc, const u8 *out,
unsigned int len)
{ … }
static void marvell_nfc_check_empty_chunk(struct nand_chip *chip,
u8 *data, int data_len,
u8 *spare, int spare_len,
u8 *ecc, int ecc_len,
unsigned int *max_bitflips)
{ … }
static int marvell_nfc_hw_ecc_check_bitflips(struct nand_chip *chip,
unsigned int *max_bitflips)
{ … }
static int marvell_nfc_hw_ecc_hmg_do_read_page(struct nand_chip *chip,
u8 *data_buf, u8 *oob_buf,
bool raw, int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_read_page_raw(struct nand_chip *chip, u8 *buf,
int oob_required, int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_read_page(struct nand_chip *chip, u8 *buf,
int oob_required, int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_read_oob_raw(struct nand_chip *chip, int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
const u8 *data_buf,
const u8 *oob_buf, bool raw,
int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_write_page_raw(struct nand_chip *chip,
const u8 *buf,
int oob_required, int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_write_page(struct nand_chip *chip,
const u8 *buf,
int oob_required, int page)
{ … }
static int marvell_nfc_hw_ecc_hmg_write_oob_raw(struct nand_chip *chip,
int page)
{ … }
static int marvell_nfc_hw_ecc_bch_read_page_raw(struct nand_chip *chip, u8 *buf,
int oob_required, int page)
{ … }
static void marvell_nfc_hw_ecc_bch_read_chunk(struct nand_chip *chip, int chunk,
u8 *data, unsigned int data_len,
u8 *spare, unsigned int spare_len,
int page)
{ … }
static int marvell_nfc_hw_ecc_bch_read_page(struct nand_chip *chip,
u8 *buf, int oob_required,
int page)
{ … }
static int marvell_nfc_hw_ecc_bch_read_oob_raw(struct nand_chip *chip, int page)
{ … }
static int marvell_nfc_hw_ecc_bch_read_oob(struct nand_chip *chip, int page)
{ … }
static int marvell_nfc_hw_ecc_bch_write_page_raw(struct nand_chip *chip,
const u8 *buf,
int oob_required, int page)
{ … }
static int
marvell_nfc_hw_ecc_bch_write_chunk(struct nand_chip *chip, int chunk,
const u8 *data, unsigned int data_len,
const u8 *spare, unsigned int spare_len,
int page)
{ … }
static int marvell_nfc_hw_ecc_bch_write_page(struct nand_chip *chip,
const u8 *buf,
int oob_required, int page)
{ … }
static int marvell_nfc_hw_ecc_bch_write_oob_raw(struct nand_chip *chip,
int page)
{ … }
static int marvell_nfc_hw_ecc_bch_write_oob(struct nand_chip *chip, int page)
{ … }
static void marvell_nfc_parse_instructions(struct nand_chip *chip,
const struct nand_subop *subop,
struct marvell_nfc_op *nfc_op)
{ … }
static int marvell_nfc_xfer_data_pio(struct nand_chip *chip,
const struct nand_subop *subop,
struct marvell_nfc_op *nfc_op)
{ … }
static int marvell_nfc_monolithic_access_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static int marvell_nfc_naked_access_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static int marvell_nfc_naked_waitrdy_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static int marvell_nfc_read_id_type_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static int marvell_nfc_read_status_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static int marvell_nfc_reset_cmd_type_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static int marvell_nfc_erase_cmd_type_exec(struct nand_chip *chip,
const struct nand_subop *subop)
{ … }
static const struct nand_op_parser marvell_nfcv2_op_parser = …;
static const struct nand_op_parser marvell_nfcv1_op_parser = …;
static int marvell_nfc_exec_op(struct nand_chip *chip,
const struct nand_operation *op,
bool check_only)
{ … }
static int marvell_nand_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static int marvell_nand_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{ … }
static const struct mtd_ooblayout_ops marvell_nand_ooblayout_ops = …;
static int marvell_nand_hw_ecc_controller_init(struct mtd_info *mtd,
struct nand_ecc_ctrl *ecc)
{ … }
static int marvell_nand_ecc_init(struct mtd_info *mtd,
struct nand_ecc_ctrl *ecc)
{ … }
static u8 bbt_pattern[] = …;
static u8 bbt_mirror_pattern[] = …;
static struct nand_bbt_descr bbt_main_descr = …;
static struct nand_bbt_descr bbt_mirror_descr = …;
static int marvell_nfc_setup_interface(struct nand_chip *chip, int chipnr,
const struct nand_interface_config *conf)
{ … }
static int marvell_nand_attach_chip(struct nand_chip *chip)
{ … }
static const struct nand_controller_ops marvell_nand_controller_ops = …;
static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc,
struct device_node *np)
{ … }
static void marvell_nand_chips_cleanup(struct marvell_nfc *nfc)
{ … }
static int marvell_nand_chips_init(struct device *dev, struct marvell_nfc *nfc)
{ … }
static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
{ … }
static void marvell_nfc_reset(struct marvell_nfc *nfc)
{ … }
static int marvell_nfc_init(struct marvell_nfc *nfc)
{ … }
static int marvell_nfc_probe(struct platform_device *pdev)
{ … }
static void marvell_nfc_remove(struct platform_device *pdev)
{ … }
static int __maybe_unused marvell_nfc_suspend(struct device *dev)
{ … }
static int __maybe_unused marvell_nfc_resume(struct device *dev)
{ … }
static const struct dev_pm_ops marvell_nfc_pm_ops = …;
static const struct marvell_nfc_caps marvell_armada_8k_nfc_caps = …;
static const struct marvell_nfc_caps marvell_ac5_caps = …;
static const struct marvell_nfc_caps marvell_armada370_nfc_caps = …;
static const struct marvell_nfc_caps marvell_pxa3xx_nfc_caps = …;
static const struct marvell_nfc_caps marvell_armada_8k_nfc_legacy_caps = …;
static const struct marvell_nfc_caps marvell_armada370_nfc_legacy_caps = …;
static const struct marvell_nfc_caps marvell_pxa3xx_nfc_legacy_caps = …;
static const struct platform_device_id marvell_nfc_platform_ids[] = …;
MODULE_DEVICE_TABLE(platform, marvell_nfc_platform_ids);
static const struct of_device_id marvell_nfc_of_ids[] = …;
MODULE_DEVICE_TABLE(of, marvell_nfc_of_ids);
static struct platform_driver marvell_nfc_driver = …;
module_platform_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;