2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2008-05-16 09:10:33 +00:00
|
|
|
/*
|
|
|
|
* SPI flash internal definitions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Atmel Corporation
|
2013-10-02 14:08:49 +00:00
|
|
|
* Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
|
2008-05-16 09:10:33 +00:00
|
|
|
*/
|
|
|
|
|
2013-10-10 16:44:09 +00:00
|
|
|
#ifndef _SF_INTERNAL_H_
|
|
|
|
#define _SF_INTERNAL_H_
|
2008-05-16 09:10:33 +00:00
|
|
|
|
2014-10-14 05:42:04 +00:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
2019-02-05 05:59:23 +00:00
|
|
|
#define SPI_NOR_MAX_ID_LEN 6
|
|
|
|
#define SPI_NOR_MAX_ADDR_WIDTH 4
|
2016-10-30 17:46:10 +00:00
|
|
|
|
2019-02-05 05:59:23 +00:00
|
|
|
struct flash_info {
|
2019-02-05 05:59:25 +00:00
|
|
|
#if !CONFIG_IS_ENABLED(SPI_FLASH_TINY)
|
2019-02-05 05:59:23 +00:00
|
|
|
char *name;
|
2019-02-05 05:59:25 +00:00
|
|
|
#endif
|
2016-10-30 17:46:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This array stores the ID bytes.
|
|
|
|
* The first three bytes are the JEDIC ID.
|
|
|
|
* JEDEC ID zero means "no ID" (mostly older chips).
|
|
|
|
*/
|
2019-02-05 05:59:23 +00:00
|
|
|
u8 id[SPI_NOR_MAX_ID_LEN];
|
2016-10-30 17:46:10 +00:00
|
|
|
u8 id_len;
|
|
|
|
|
2019-02-05 05:59:23 +00:00
|
|
|
/* The size listed here is what works with SPINOR_OP_SE, which isn't
|
2016-10-30 17:46:13 +00:00
|
|
|
* necessarily called a "sector" by the vendor.
|
|
|
|
*/
|
2019-02-05 05:59:23 +00:00
|
|
|
unsigned int sector_size;
|
|
|
|
u16 n_sectors;
|
2016-10-30 17:46:13 +00:00
|
|
|
|
|
|
|
u16 page_size;
|
2019-02-05 05:59:23 +00:00
|
|
|
u16 addr_width;
|
2016-10-30 17:46:13 +00:00
|
|
|
|
|
|
|
u16 flags;
|
2019-02-05 05:59:23 +00:00
|
|
|
#define SECT_4K BIT(0) /* SPINOR_OP_BE_4K works uniformly */
|
|
|
|
#define SPI_NOR_NO_ERASE BIT(1) /* No erase command needed */
|
|
|
|
#define SST_WRITE BIT(2) /* use SST byte programming */
|
|
|
|
#define SPI_NOR_NO_FR BIT(3) /* Can't do fastread */
|
|
|
|
#define SECT_4K_PMC BIT(4) /* SPINOR_OP_BE_4K_PMC works uniformly */
|
|
|
|
#define SPI_NOR_DUAL_READ BIT(5) /* Flash supports Dual Read */
|
|
|
|
#define SPI_NOR_QUAD_READ BIT(6) /* Flash supports Quad Read */
|
|
|
|
#define USE_FSR BIT(7) /* use flag status register */
|
|
|
|
#define SPI_NOR_HAS_LOCK BIT(8) /* Flash supports lock/unlock via SR */
|
|
|
|
#define SPI_NOR_HAS_TB BIT(9) /*
|
|
|
|
* Flash SR has Top/Bottom (TB) protect
|
|
|
|
* bit. Must be used with
|
|
|
|
* SPI_NOR_HAS_LOCK.
|
|
|
|
*/
|
|
|
|
#define SPI_S3AN BIT(10) /*
|
|
|
|
* Xilinx Spartan 3AN In-System Flash
|
|
|
|
* (MFR cannot be used for probing
|
|
|
|
* because it has the same value as
|
|
|
|
* ATMEL flashes)
|
|
|
|
*/
|
|
|
|
#define SPI_NOR_4B_OPCODES BIT(11) /*
|
|
|
|
* Use dedicated 4byte address op codes
|
|
|
|
* to support memory size above 128Mib.
|
|
|
|
*/
|
|
|
|
#define NO_CHIP_ERASE BIT(12) /* Chip does not support chip erase */
|
|
|
|
#define SPI_NOR_SKIP_SFDP BIT(13) /* Skip parsing of SFDP tables */
|
|
|
|
#define USE_CLSR BIT(14) /* use CLSR command */
|
2014-10-14 05:42:04 +00:00
|
|
|
};
|
|
|
|
|
2019-02-05 05:59:23 +00:00
|
|
|
extern const struct flash_info spi_nor_ids[];
|
|
|
|
|
|
|
|
#define JEDEC_MFR(info) ((info)->id[0])
|
|
|
|
#define JEDEC_ID(info) (((info)->id[1]) << 8 | ((info)->id[2]))
|
2014-10-14 05:42:04 +00:00
|
|
|
|
2008-05-16 09:10:33 +00:00
|
|
|
/* Send a single-byte command to the device and read the response */
|
|
|
|
int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a multi-byte command to the device and read the response. Used
|
|
|
|
* for flash array reads, etc.
|
|
|
|
*/
|
|
|
|
int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
|
|
|
|
size_t cmd_len, void *data, size_t data_len);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a multi-byte command to the device followed by (optional)
|
|
|
|
* data. Used for programming the flash array, etc.
|
|
|
|
*/
|
|
|
|
int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
|
|
|
|
const void *data, size_t data_len);
|
|
|
|
|
2011-04-25 06:58:29 +00:00
|
|
|
|
2018-11-06 22:21:41 +00:00
|
|
|
/* Get software write-protect value (BP bits) */
|
|
|
|
int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash);
|
|
|
|
|
2011-01-10 07:20:12 +00:00
|
|
|
|
2015-04-27 05:42:04 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_MTD
|
|
|
|
int spi_flash_mtd_register(struct spi_flash *flash);
|
|
|
|
void spi_flash_mtd_unregister(void);
|
|
|
|
#endif
|
2013-10-10 16:44:09 +00:00
|
|
|
#endif /* _SF_INTERNAL_H_ */
|