#include <linux/module.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/err.h>
#include <linux/math64.h>
#include <linux/of.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#define OP_READ_CONTINUOUS …
#define OP_READ_PAGE …
#define OP_READ_STATUS …
#define OP_READ_BUFFER1 …
#define OP_READ_BUFFER2 …
#define OP_WRITE_BUFFER1 …
#define OP_WRITE_BUFFER2 …
#define OP_ERASE_PAGE …
#define OP_ERASE_BLOCK …
#define OP_TRANSFER_BUF1 …
#define OP_TRANSFER_BUF2 …
#define OP_MREAD_BUFFER1 …
#define OP_MREAD_BUFFER2 …
#define OP_MWERASE_BUFFER1 …
#define OP_MWERASE_BUFFER2 …
#define OP_MWRITE_BUFFER1 …
#define OP_MWRITE_BUFFER2 …
#define OP_PROGRAM_VIA_BUF1 …
#define OP_PROGRAM_VIA_BUF2 …
#define OP_COMPARE_BUF1 …
#define OP_COMPARE_BUF2 …
#define OP_REWRITE_VIA_BUF1 …
#define OP_REWRITE_VIA_BUF2 …
#define OP_READ_ID …
#define OP_READ_SECURITY …
#define OP_WRITE_SECURITY_REVC …
#define OP_WRITE_SECURITY …
#define CFI_MFR_ATMEL …
#define DATAFLASH_SHIFT_EXTID …
#define DATAFLASH_SHIFT_ID …
struct dataflash { … };
#ifdef CONFIG_OF
static const struct of_device_id dataflash_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, dataflash_dt_ids);
#endif
static const struct spi_device_id dataflash_spi_ids[] = …;
MODULE_DEVICE_TABLE(spi, dataflash_spi_ids);
static inline int dataflash_status(struct spi_device *spi)
{ … }
static int dataflash_waitready(struct spi_device *spi)
{ … }
static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
{ … }
static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{ … }
static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t * retlen, const u_char * buf)
{ … }
#ifdef CONFIG_MTD_DATAFLASH_OTP
static int dataflash_get_otp_info(struct mtd_info *mtd, size_t len,
size_t *retlen, struct otp_info *info)
{ … }
static ssize_t otp_read(struct spi_device *spi, unsigned base,
u8 *buf, loff_t off, size_t len)
{ … }
static int dataflash_read_fact_otp(struct mtd_info *mtd,
loff_t from, size_t len, size_t *retlen, u_char *buf)
{ … }
static int dataflash_read_user_otp(struct mtd_info *mtd,
loff_t from, size_t len, size_t *retlen, u_char *buf)
{ … }
static int dataflash_write_user_otp(struct mtd_info *mtd,
loff_t from, size_t len, size_t *retlen, const u_char *buf)
{ … }
static char *otp_setup(struct mtd_info *device, char revision)
{ … }
#else
static char *otp_setup(struct mtd_info *device, char revision)
{
return " (OTP)";
}
#endif
static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
int pagesize, int pageoffset, char revision)
{ … }
static inline int add_dataflash(struct spi_device *spi, char *name,
int nr_pages, int pagesize, int pageoffset)
{ … }
struct flash_info { … };
static struct flash_info dataflash_data[] = …;
static struct flash_info *jedec_lookup(struct spi_device *spi,
u64 jedec, bool use_extid)
{ … }
static struct flash_info *jedec_probe(struct spi_device *spi)
{ … }
static int dataflash_probe(struct spi_device *spi)
{ … }
static void dataflash_remove(struct spi_device *spi)
{ … }
static struct spi_driver dataflash_driver = …;
module_spi_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_ALIAS(…) …;