[U-Boot] [PATCH 3/3] sf: Use shortcut names

Jagannadha Sutradharudu Teki jagannadha.sutradharudu-teki at xilinx.com
Fri Jan 17 15:41:47 CET 2014


- SPI_FLASH -> SF
- ARRAY_SLOW -> AS
- ARRAY_FAST -> AF
- DUAL_OUTPUT_FAST -> DOF
- DUAL_IO_FAST - DIOF
- QUAD_OUTPUT_FAST - QOF
- QUAD_IO_FAST - QIOF

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna at xilinx.com>
Cc: Marek Vasut <marex at denx.de>
---
 drivers/mtd/spi/sf_internal.h | 44 +++++++++++++++++++++----------------------
 drivers/mtd/spi/sf_ops.c      | 25 ++++++++++++------------
 drivers/mtd/spi/sf_probe.c    | 44 +++++++++++++++++++++----------------------
 include/spi_flash.h           | 14 +++++++-------
 4 files changed, 63 insertions(+), 64 deletions(-)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 6bcd522..f959262 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -10,15 +10,15 @@
 #ifndef _SF_INTERNAL_H_
 #define _SF_INTERNAL_H_
 
-#define SPI_FLASH_3B_ADDR_LEN		3
-#define SPI_FLASH_CMD_LEN		(1 + SPI_FLASH_3B_ADDR_LEN)
-#define SPI_FLASH_16MB_BOUN		0x1000000
+#define SF_INST_3BADDR			3
+#define SF_CMD_LEN			(1 + SF_INST_3BADDR)
+#define SF_16MB_BOUN			0x1000000
 
 /* CFI Manufacture ID's */
-#define SPI_FLASH_CFI_MFR_SPANSION	0x01
-#define SPI_FLASH_CFI_MFR_STMICRO	0x20
-#define SPI_FLASH_CFI_MFR_MACRONIX	0xc2
-#define SPI_FLASH_CFI_MFR_WINBOND	0xef
+#define SF_CFI_MFR_SPANSION		0x01
+#define SF_CFI_MFR_STMICRO		0x20
+#define SF_CFI_MFR_MACRONIX		0xc2
+#define SF_CFI_MFR_WINBOND		0xef
 
 /* Erase commands */
 #define CMD_ERASE_4K			0x20
@@ -28,22 +28,22 @@
 
 /* Write commands */
 #define CMD_WRITE_STATUS		0x01
-#define CMD_PAGE_PROGRAM		0x02
+#define CMD_WRITE_PP			0x02
 #define CMD_WRITE_DISABLE		0x04
 #define CMD_READ_STATUS			0x05
-#define CMD_QUAD_PAGE_PROGRAM		0x32
+#define CMD_WRITE_QPP			0x32
 #define CMD_READ_STATUS1		0x35
 #define CMD_WRITE_ENABLE		0x06
 #define CMD_READ_CONFIG			0x35
 #define CMD_FLAG_STATUS			0x70
 
 /* Read commands */
-#define CMD_READ_ARRAY_SLOW		0x03
-#define CMD_READ_ARRAY_FAST		0x0b
-#define CMD_READ_DUAL_OUTPUT_FAST	0x3b
-#define CMD_READ_DUAL_IO_FAST		0xbb
-#define CMD_READ_QUAD_OUTPUT_FAST	0x6b
-#define CMD_READ_QUAD_IO_FAST		0xeb
+#define CMD_READ_AS			0x03
+#define CMD_READ_AF			0x0b
+#define CMD_READ_DOF			0x3b
+#define CMD_READ_DIOF			0xbb
+#define CMD_READ_QOF			0x6b
+#define CMD_READ_QIOF			0xeb
 #define CMD_READ_ID			0x9f
 
 /* Bank addr access commands */
@@ -55,15 +55,15 @@
 #endif
 
 /* Common status */
-#define STATUS_WIP			(1 << 0)
-#define STATUS_QEB_WINSPAN		(1 << 1)
-#define STATUS_QEB_MXIC			(1 << 6)
-#define STATUS_PEC			(1 << 7)
+#define STATUS_WIP			1 << 0
+#define STATUS_QEB_WINSPAN		1 << 1
+#define STATUS_QEB_MXIC			1 << 6
+#define STATUS_PEC			1 << 7
 
 /* Flash timeout values */
-#define SPI_FLASH_PROG_TIMEOUT		(2 * CONFIG_SYS_HZ)
-#define SPI_FLASH_PAGE_ERASE_TIMEOUT	(5 * CONFIG_SYS_HZ)
-#define SPI_FLASH_SECTOR_ERASE_TIMEOUT	(10 * CONFIG_SYS_HZ)
+#define SF_PROG_TIMEOUT			(2 * CONFIG_SYS_HZ)
+#define SF_PAGE_ERASE_TIMEOUT		(5 * CONFIG_SYS_HZ)
+#define SF_SECTOR_ERASE_TIMEOUT		(10 * CONFIG_SYS_HZ)
 
 /* SST specific */
 #ifdef CONFIG_SPI_FLASH_SST
diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
index 0d87e1b..e8e70bb 100644
--- a/drivers/mtd/spi/sf_ops.c
+++ b/drivers/mtd/spi/sf_ops.c
@@ -119,7 +119,7 @@ static int spi_flash_bank(struct spi_flash *flash, u32 offset)
 	u8 bank_sel;
 	int ret;
 
-	bank_sel = offset / (SPI_FLASH_16MB_BOUN << flash->shift);
+	bank_sel = offset / (SF_16MB_BOUN << flash->shift);
 
 	ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
 	if (ret) {
@@ -207,11 +207,11 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 		size_t cmd_len, const void *buf, size_t buf_len)
 {
 	struct spi_slave *spi = flash->spi;
-	unsigned long timeout = SPI_FLASH_PROG_TIMEOUT;
+	unsigned long timeout = SF_PROG_TIMEOUT;
 	int ret;
 
 	if (buf == NULL)
-		timeout = SPI_FLASH_PAGE_ERASE_TIMEOUT;
+		timeout = SF_PAGE_ERASE_TIMEOUT;
 
 	ret = spi_claim_bus(flash->spi);
 	if (ret) {
@@ -233,9 +233,8 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 
 	ret = spi_flash_cmd_wait_ready(flash, timeout);
 	if (ret < 0) {
-		debug("SF: write %s timed out\n",
-		      timeout == SPI_FLASH_PROG_TIMEOUT ?
-			"program" : "page erase");
+		debug("SF: write %s timed out\n", buf != NULL ?
+		      "program" : "page erase");
 		return ret;
 	}
 
@@ -247,7 +246,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len)
 {
 	u32 erase_size, erase_addr;
-	u8 cmd[SPI_FLASH_CMD_LEN];
+	u8 cmd[SF_CMD_LEN];
 	int ret = -1;
 
 	erase_size = flash->erase_size;
@@ -293,7 +292,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
 	unsigned long byte_addr, page_size;
 	u32 write_addr;
 	size_t chunk_len, actual;
-	u8 cmd[SPI_FLASH_CMD_LEN];
+	u8 cmd[SF_CMD_LEN];
 	int ret = -1;
 
 	page_size = flash->page_size;
@@ -380,7 +379,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 		return 0;
 	}
 
-	cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
+	cmdsz = SF_CMD_LEN + flash->dummy_byte;
 	cmd = calloc(1, cmdsz);
 
 	cmd[0] = flash->read_cmd;
@@ -396,8 +395,8 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 		if (bank_sel < 0)
 			return ret;
 #endif
-		remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) *
-				(bank_sel + 1)) - offset;
+		remain_len = ((SF_16MB_BOUN << flash->shift) * (bank_sel + 1)) -
+				offset;
 		if (len < remain_len)
 			read_len = len;
 		else
@@ -441,7 +440,7 @@ static int sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)
 	if (ret)
 		return ret;
 
-	return spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+	return spi_flash_cmd_wait_ready(flash, SF_PROG_TIMEOUT);
 }
 
 int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
@@ -488,7 +487,7 @@ int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
 			break;
 		}
 
-		ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+		ret = spi_flash_cmd_wait_ready(flash, SF_PROG_TIMEOUT);
 		if (ret)
 			break;
 
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 003f635..ae11999 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -21,11 +21,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* Read commands array */
 static u8 spi_read_cmds_array[] = {
-	CMD_READ_ARRAY_SLOW,
-	CMD_READ_DUAL_OUTPUT_FAST,
-	CMD_READ_DUAL_IO_FAST,
-	CMD_READ_QUAD_OUTPUT_FAST,
-	CMD_READ_QUAD_IO_FAST,
+	CMD_READ_AS,
+	CMD_READ_DOF,
+	CMD_READ_DIOF,
+	CMD_READ_QOF,
+	CMD_READ_QIOF,
 };
 
 #ifdef CONFIG_SPI_FLASH_MACRONIX
@@ -76,16 +76,16 @@ static int spi_flash_set_qeb(struct spi_flash *flash, u8 idcode0)
 {
 	switch (idcode0) {
 #ifdef CONFIG_SPI_FLASH_MACRONIX
-	case SPI_FLASH_CFI_MFR_MACRONIX:
+	case SF_CFI_MFR_MACRONIX:
 		return spi_flash_set_qeb_mxic(flash);
 #endif
 #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
-	case SPI_FLASH_CFI_MFR_SPANSION:
-	case SPI_FLASH_CFI_MFR_WINBOND:
+	case SF_CFI_MFR_SPANSION:
+	case SF_CFI_MFR_WINBOND:
 		return spi_flash_set_qeb_winspan(flash);
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO
-	case SPI_FLASH_CFI_MFR_STMICRO:
+	case SF_CFI_MFR_STMICRO:
 		debug("SF: QEB is volatile for %02x flash\n", idcode0);
 		return 0;
 #endif
@@ -141,13 +141,13 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
 		flash->dual_flash = SF_PARALLEL;
 #endif
 	/* Assign spi_flash ops */
+	flash->read = spi_flash_cmd_read_ops;
+	flash->erase = spi_flash_cmd_erase_ops;
 	flash->write = spi_flash_cmd_write_ops;
 #ifdef CONFIG_SPI_FLASH_SST
 	if (params->flags & SST_WP)
 		flash->write = sst_write_wp;
 #endif
-	flash->erase = spi_flash_cmd_erase_ops;
-	flash->read = spi_flash_cmd_read_ops;
 
 	/* Compute the flash size */
 	flash->shift = (flash->dual_flash & SF_PARALLEL) ? 1 : 0;
@@ -178,20 +178,20 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
 		flash->read_cmd = cmd;
 	} else {
 		/* Go for default supported read cmd */
-		flash->read_cmd = CMD_READ_ARRAY_FAST;
+		flash->read_cmd = CMD_READ_AF;
 	}
 
 	/* Not require to look for fastest only two write cmds yet */
 	if (params->flags & WR_QPP && flash->spi->mode_bits & SPI_TX_QPP)
-		flash->write_cmd = CMD_QUAD_PAGE_PROGRAM;
+		flash->write_cmd = CMD_WRITE_QPP;
 	else
 		/* Go for default supported write cmd */
-		flash->write_cmd = CMD_PAGE_PROGRAM;
+		flash->write_cmd = CMD_WRITE_PP;
 
 	/* Set the quad enable bit - only for quad commands */
-	if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
-	    (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
-	    (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
+	if ((flash->read_cmd == CMD_READ_QOF) ||
+	    (flash->read_cmd == CMD_READ_QIOF) ||
+	    (flash->write_cmd == CMD_WRITE_QPP)) {
 		if (spi_flash_set_qeb(flash, idcode[0])) {
 			debug("SF: Fail to set QEB for %02x\n", idcode[0]);
 			return NULL;
@@ -207,10 +207,10 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
 	 * data all go on single line irrespective of command.
 	 */
 	switch (flash->read_cmd) {
-	case CMD_READ_QUAD_IO_FAST:
+	case CMD_READ_QIOF:
 		flash->dummy_byte = 2;
 		break;
-	case CMD_READ_ARRAY_SLOW:
+	case CMD_READ_AS:
 		flash->dummy_byte = 0;
 		break;
 	default:
@@ -227,7 +227,7 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
 	/* Configure the BAR - discover bank cmds and read current bank */
 #ifdef CONFIG_SPI_FLASH_BAR
 	u8 curr_bank = 0;
-	if (flash->size > SPI_FLASH_16MB_BOUN) {
+	if (flash->size > SF_16MB_BOUN) {
 		flash->bank_read_cmd = (idcode[0] == 0x01) ?
 					CMD_BANKADDR_BRRD : CMD_EXTNADDR_RDEAR;
 		flash->bank_write_cmd = (idcode[0] == 0x01) ?
@@ -335,9 +335,9 @@ static struct spi_flash *spi_flash_probe_slave(struct spi_slave *spi)
 #endif
 #ifndef CONFIG_SPI_FLASH_BAR
 	if (((flash->dual_flash == SF_SINGLE) &&
-	     (flash->size > SPI_FLASH_16MB_BOUN)) ||
+	     (flash->size > SF_16MB_BOUN)) ||
 	     ((flash->dual_flash > SF_SINGLE) &&
-	     (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
+	     (flash->size > SF_16MB_BOUN << 1))) {
 		puts("SF: Warning - Only lower 16MiB accessible,");
 		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
 	}
diff --git a/include/spi_flash.h b/include/spi_flash.h
index b4b2f9b..283c569 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -27,14 +27,14 @@
 
 /* Enum list - Full read commands */
 enum spi_read_cmds {
-	ARRAY_SLOW = 1 << 0,
-	DUAL_OUTPUT_FAST = 1 << 1,
-	DUAL_IO_FAST = 1 << 2,
-	QUAD_OUTPUT_FAST = 1 << 3,
-	QUAD_IO_FAST = 1 << 4,
+	SF_AS = 1 << 0,
+	SF_DOF = 1 << 1,
+	SF_DIOF = 1 << 2,
+	SF_QOF = 1 << 3,
+	SF_QIOF = 1 << 4,
 };
-#define RD_EXTN		ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST
-#define RD_FULL		RD_EXTN | QUAD_OUTPUT_FAST | QUAD_IO_FAST
+#define RD_EXTN		SF_AS | SF_DOF | SF_DIOF
+#define RD_FULL		RD_EXTN | SF_QOF | SF_QIOF
 
 /* Dual SPI flash memories */
 enum spi_dual_flash {
-- 
1.8.3




More information about the U-Boot mailing list