linux/drivers/misc/eeprom/at25.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Driver for most of the SPI EEPROMs, such as Atmel AT25 models
 * and Cypress FRAMs FM25 models.
 *
 * Copyright (C) 2006 David Brownell
 */

#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/sched.h>
#include <linux/slab.h>

#include <linux/spi/eeprom.h>
#include <linux/spi/spi.h>

#include <linux/nvmem-provider.h>

/*
 * NOTE: this is an *EEPROM* driver. The vagaries of product naming
 * mean that some AT25 products are EEPROMs, and others are FLASH.
 * Handle FLASH chips with the drivers/mtd/devices/m25p80.c driver,
 * not this one!
 *
 * EEPROMs that can be used with this driver include, for example:
 *   AT25M02, AT25128B
 */

#define FM25_SN_LEN
#define EE_MAXADDRLEN

struct at25_data {};

#define AT25_WREN
#define AT25_WRDI
#define AT25_RDSR
#define AT25_WRSR
#define AT25_READ
#define AT25_WRITE
#define FM25_SLEEP
#define FM25_RDID
#define FM25_RDSN

#define AT25_SR_nRDY
#define AT25_SR_WEN
#define AT25_SR_BP0
#define AT25_SR_BP1
#define AT25_SR_WPEN

#define AT25_INSTR_BIT3

#define FM25_ID_LEN

/*
 * Specs often allow 5ms for a page write, sometimes 20ms;
 * it's important to recover from write timeouts.
 */
#define EE_TIMEOUT

/*-------------------------------------------------------------------------*/

#define io_limit

static int at25_ee_read(void *priv, unsigned int offset,
			void *val, size_t count)
{}

/* Read extra registers as ID or serial number */
static int fm25_aux_read(struct at25_data *at25, u8 *buf, uint8_t command,
			 int len)
{}

static ssize_t sernum_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(sernum);

static struct attribute *sernum_attrs[] =;
ATTRIBUTE_GROUPS();

static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
{}

/*-------------------------------------------------------------------------*/

static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip)
{}

static int at25_fram_to_chip(struct device *dev, struct spi_eeprom *chip)
{}

static const struct of_device_id at25_of_match[] =;
MODULE_DEVICE_TABLE(of, at25_of_match);

static const struct spi_device_id at25_spi_ids[] =;
MODULE_DEVICE_TABLE(spi, at25_spi_ids);

static int at25_probe(struct spi_device *spi)
{}

/*-------------------------------------------------------------------------*/

static struct spi_driver at25_driver =;

module_spi_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();