diff options
Diffstat (limited to 'drivers/mtd')
| -rw-r--r-- | drivers/mtd/nand/Makefile | 1 | ||||
| -rw-r--r-- | drivers/mtd/nand/fsl_elbc_spl.c | 27 | ||||
| -rw-r--r-- | drivers/mtd/nand/nand_util.c | 3 | ||||
| -rw-r--r-- | drivers/mtd/spi/Makefile | 1 | ||||
| -rw-r--r-- | drivers/mtd/spi/atmel.c | 10 | ||||
| -rw-r--r-- | drivers/mtd/spi/eon.c | 3 | ||||
| -rw-r--r-- | drivers/mtd/spi/fsl_espi_spl.c | 62 | ||||
| -rw-r--r-- | drivers/mtd/spi/gigadevice.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/spi/ramtron.c | 8 | ||||
| -rw-r--r-- | drivers/mtd/spi/spansion.c | 5 | ||||
| -rw-r--r-- | drivers/mtd/spi/spi_flash.c | 13 | ||||
| -rw-r--r-- | drivers/mtd/spi/spi_spl_load.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/spi/sst.c | 40 | ||||
| -rw-r--r-- | drivers/mtd/spi/stmicro.c | 12 | ||||
| -rw-r--r-- | drivers/mtd/spi/winbond.c | 2 | 
15 files changed, 143 insertions, 48 deletions
| diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index e27e0b705..366dee667 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -23,6 +23,7 @@ COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o  COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o  COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o  COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o +COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o  else # not spl diff --git a/drivers/mtd/nand/fsl_elbc_spl.c b/drivers/mtd/nand/fsl_elbc_spl.c index 7e5599ac6..a7476b49b 100644 --- a/drivers/mtd/nand/fsl_elbc_spl.c +++ b/drivers/mtd/nand/fsl_elbc_spl.c @@ -34,7 +34,11 @@ static void nand_wait(void)  	}  } +#ifdef CONFIG_TPL_BUILD +int nand_spl_load_image(uint32_t offs, unsigned int uboot_size, void *vdst) +#else  static int nand_load_image(uint32_t offs, unsigned int uboot_size, void *vdst) +#endif  {  	fsl_lbc_t *regs = LBC_BASE_ADDR;  	uchar *buf = (uchar *)CONFIG_SYS_NAND_BASE; @@ -114,6 +118,15 @@ static int nand_load_image(uint32_t offs, unsigned int uboot_size, void *vdst)  }  /* + * Defines a static function nand_load_image() here, because non-static makes + * the code too large for certain SPLs(minimal SPL, maximum size <= 4Kbytes) + */ +#ifndef CONFIG_TPL_BUILD +#define nand_spl_load_image(offs, uboot_size, vdst) \ +	nand_load_image(offs, uboot_size, vdst) +#endif + +/*   * The main entry for NAND booting. It's necessary that SDRAM is already   * configured and available since this code loads the main U-Boot image   * from NAND into SDRAM and starts it from there. @@ -124,17 +137,17 @@ void nand_boot(void)  	/*  	 * Load U-Boot image from NAND into RAM  	 */ -	nand_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, -			CONFIG_SYS_NAND_U_BOOT_SIZE, -			(void *)CONFIG_SYS_NAND_U_BOOT_DST); +	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, +			    CONFIG_SYS_NAND_U_BOOT_SIZE, +			    (void *)CONFIG_SYS_NAND_U_BOOT_DST);  #ifdef CONFIG_NAND_ENV_DST -	nand_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, -			(void *)CONFIG_NAND_ENV_DST); +	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, +			    (void *)CONFIG_NAND_ENV_DST);  #ifdef CONFIG_ENV_OFFSET_REDUND -	nand_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, -			(void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); +	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, +			    (void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE);  #endif  #endif diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 1e0210a9a..d149a6dae 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -51,7 +51,6 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)  	struct jffs2_unknown_node cleanmarker;  	erase_info_t erase;  	unsigned long erase_length, erased_length; /* in blocks */ -	int bbtest = 1;  	int result;  	int percent_complete = -1;  	const char *mtd_device = meminfo->name; @@ -102,7 +101,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)  			puts("Size of erase exceeds limit\n");  			return -EFBIG;  		} -		if (!opts->scrub && bbtest) { +		if (!opts->scrub) {  			int ret = mtd_block_isbad(meminfo, erase.addr);  			if (ret > 0) {  				if (!opts->quiet) diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile index e537fcf54..191138ad1 100644 --- a/drivers/mtd/spi/Makefile +++ b/drivers/mtd/spi/Makefile @@ -11,6 +11,7 @@ LIB	:= $(obj)libspi_flash.o  ifdef CONFIG_SPL_BUILD  COBJS-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o +COBJS-$(CONFIG_SPL_SPI_BOOT)	+= fsl_espi_spl.o  endif  COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c index 6a92c4b77..f34df43f5 100644 --- a/drivers/mtd/spi/atmel.c +++ b/drivers/mtd/spi/atmel.c @@ -252,7 +252,7 @@ static int dataflash_write_p2(struct spi_flash *flash,  	}  	debug("SF: AT45: Successfully programmed %zu bytes @ 0x%x\n", -			len, offset); +	      len, offset);  	ret = 0;  out: @@ -325,7 +325,7 @@ static int dataflash_write_at45(struct spi_flash *flash,  	}  	debug("SF: AT45: Successfully programmed %zu bytes @ 0x%x\n", -			len, offset); +	      len, offset);  	ret = 0;  out: @@ -387,7 +387,7 @@ static int dataflash_erase_p2(struct spi_flash *flash, u32 offset, size_t len)  	}  	debug("SF: AT45: Successfully erased %zu bytes @ 0x%x\n", -			len, offset); +	      len, offset);  	ret = 0;  out: @@ -450,7 +450,7 @@ static int dataflash_erase_at45(struct spi_flash *flash, u32 offset, size_t len)  	}  	debug("SF: AT45: Successfully erased %zu bytes @ 0x%x\n", -			len, offset); +	      len, offset);  	ret = 0;  out: @@ -476,7 +476,7 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)  	if (i == ARRAY_SIZE(atmel_spi_flash_table)) {  		debug("SF: Unsupported DataFlash ID %02x\n", -				idcode[1]); +		      idcode[1]);  		return NULL;  	} diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c index b16e7ab09..25cfc1252 100644 --- a/drivers/mtd/spi/eon.c +++ b/drivers/mtd/spi/eon.c @@ -54,8 +54,7 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)  	flash->page_size = 256;  	flash->sector_size = 256 * 16 * 16; -	flash->size = 256 * 16 -	    * params->nr_sectors; +	flash->size = 256 * 16 * params->nr_sectors;  	return flash;  } diff --git a/drivers/mtd/spi/fsl_espi_spl.c b/drivers/mtd/spi/fsl_espi_spl.c new file mode 100644 index 000000000..6263d8c22 --- /dev/null +++ b/drivers/mtd/spi/fsl_espi_spl.c @@ -0,0 +1,62 @@ +/* + * Copyright 2013 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier:	GPL-2.0+ + */ + +#include <common.h> +#include <spi_flash.h> +#include <malloc.h> + +#define ESPI_BOOT_IMAGE_SIZE	0x48 +#define ESPI_BOOT_IMAGE_ADDR	0x50 +#define CONFIG_CFG_DATA_SECTOR	0 + +/* + * The main entry for SPI booting. It's necessary that SDRAM is already + * configured and available since this code loads the main U-Boot image + * from SPI into SDRAM and starts it from there. + */ +void spi_boot(void) +{ +	void (*uboot)(void) __noreturn; +	u32 offset, code_len; +	unsigned char *buf = NULL; +	struct spi_flash *flash; + +	flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, +			CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); +	if (flash == NULL) { +		puts("\nspi_flash_probe failed"); +		hang(); +	} + +	/* +	* Load U-Boot image from SPI flash into RAM +	*/ +	buf = malloc(flash->page_size); +	if (buf == NULL) { +		puts("\nmalloc failed"); +		hang(); +	} +	memset(buf, 0, flash->page_size); + +	spi_flash_read(flash, CONFIG_CFG_DATA_SECTOR, +		       flash->page_size, (void *)buf); +	offset = *(u32 *)(buf + ESPI_BOOT_IMAGE_ADDR); +	/* Skip spl code */ +	offset += CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS; +	/* Get the code size from offset 0x48 */ +	code_len = *(u32 *)(buf + ESPI_BOOT_IMAGE_SIZE); +	/* Skip spl code */ +	code_len = code_len - CONFIG_SPL_MAX_SIZE; +	/* copy code to DDR */ +	spi_flash_read(flash, offset, code_len, +		       (void *)CONFIG_SYS_SPI_FLASH_U_BOOT_DST); +	/* +	* Jump to U-Boot image +	*/ +	flush_cache(CONFIG_SYS_SPI_FLASH_U_BOOT_DST, code_len); +	uboot = (void *)CONFIG_SYS_SPI_FLASH_U_BOOT_START; +	(*uboot)(); +} diff --git a/drivers/mtd/spi/gigadevice.c b/drivers/mtd/spi/gigadevice.c index 950c7770a..b42581a70 100644 --- a/drivers/mtd/spi/gigadevice.c +++ b/drivers/mtd/spi/gigadevice.c @@ -45,7 +45,7 @@ struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode)  	if (i == ARRAY_SIZE(gigadevice_spi_flash_table)) {  		debug("SF: Unsupported Gigadevice ID %02x%02x\n", -				idcode[1], idcode[2]); +		      idcode[1], idcode[2]);  		return NULL;  	} diff --git a/drivers/mtd/spi/ramtron.c b/drivers/mtd/spi/ramtron.c index f67ddd696..38f9d6916 100644 --- a/drivers/mtd/spi/ramtron.c +++ b/drivers/mtd/spi/ramtron.c @@ -230,7 +230,8 @@ struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)  		/* JEDEC conformant RAMTRON id */  		for (i = 0; i < ARRAY_SIZE(ramtron_spi_fram_table); i++) {  			params = &ramtron_spi_fram_table[i]; -			if (idcode[1] == params->id1 && idcode[2] == params->id2) +			if (idcode[1] == params->id1 && +			    idcode[2] == params->id2)  				goto found;  		}  		break; @@ -251,7 +252,8 @@ struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)  		/* now find the device */  		for (i = 0; i < ARRAY_SIZE(ramtron_spi_fram_table); i++) {  			params = &ramtron_spi_fram_table[i]; -			if (!strcmp(params->name, CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC)) +			if (!strcmp(params->name, +				    CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC))  				goto found;  		}  		debug("SF: Unsupported non-JEDEC RAMTRON device " @@ -264,7 +266,7 @@ struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)  	/* arriving here means no method has found a device we can handle */  	debug("SF/ramtron: unsupported device id0=%02x id1=%02x id2=%02x\n", -		idcode[0], idcode[1], idcode[2]); +	      idcode[0], idcode[1], idcode[2]);  	return NULL;  found: diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c index 47a48976b..fa7ac8c93 100644 --- a/drivers/mtd/spi/spansion.c +++ b/drivers/mtd/spi/spansion.c @@ -6,7 +6,7 @@   * TsiChung Liew (Tsi-Chung.Liew@freescale.com),   * and  Jason McMullan (mcmullan@netapp.com)   * - * SPDX-License-Identifier:	GPL-2.0+  + * SPDX-License-Identifier:	GPL-2.0+   */  #include <common.h> @@ -122,7 +122,8 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)  	}  	if (i == ARRAY_SIZE(spansion_spi_flash_table)) { -		debug("SF: Unsupported SPANSION ID %04x %04x\n", jedec, ext_jedec); +		debug("SF: Unsupported SPANSION ID %04x %04x\n", +		      jedec, ext_jedec);  		return NULL;  	} diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 6a6fe37e0..5d5055ff3 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -40,12 +40,13 @@ static int spi_flash_read_write(struct spi_slave *spi,  	ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);  	if (ret) {  		debug("SF: Failed to send command (%zu bytes): %d\n", -				cmd_len, ret); +		      cmd_len, ret);  	} else if (data_len != 0) { -		ret = spi_xfer(spi, data_len * 8, data_out, data_in, SPI_XFER_END); +		ret = spi_xfer(spi, data_len * 8, data_out, data_in, +					SPI_XFER_END);  		if (ret)  			debug("SF: Failed to transfer %zu bytes of data: %d\n", -					data_len, ret); +			      data_len, ret);  	}  	return ret; @@ -86,7 +87,7 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)  	ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);  	if (ret) {  		debug("SF: fail to read %s status register\n", -			cmd == CMD_READ_STATUS ? "read" : "flag"); +		      cmd == CMD_READ_STATUS ? "read" : "flag");  		return ret;  	} @@ -144,7 +145,7 @@ 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 ? +		      timeout == SPI_FLASH_PROG_TIMEOUT ?  			"program" : "page erase");  		return ret;  	} @@ -554,12 +555,14 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,  		goto err_manufacturer_probe;  	}  #endif +#ifndef CONFIG_SPL_BUILD  	printf("SF: Detected %s with page size ", flash->name);  	print_size(flash->sector_size, ", total ");  	print_size(flash->size, "");  	if (flash->memory_map)  		printf(", mapped at %p", flash->memory_map);  	puts("\n"); +#endif  #ifndef CONFIG_SPI_FLASH_BAR  	if (flash->size > SPI_FLASH_16MB_BOUN) {  		puts("SF: Warning - Only lower 16MiB accessible,"); diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c index 7c799ca48..29355307f 100644 --- a/drivers/mtd/spi/spi_spl_load.c +++ b/drivers/mtd/spi/spi_spl_load.c @@ -39,7 +39,7 @@ void spl_spi_load_image(void)  	/* Load u-boot, mkimage header is 64 bytes. */  	spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40, -			(void *) header); +		       (void *)header);  	spl_parse_image_header(header);  	spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,  		       spl_image.size, (void *)spl_image.load_addr); diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c index 95f5490c3..256867c84 100644 --- a/drivers/mtd/spi/sst.c +++ b/drivers/mtd/spi/sst.c @@ -19,7 +19,7 @@  #include "spi_flash_internal.h"  #define CMD_SST_BP		0x02	/* Byte Program */ -#define CMD_SST_AAI_WP		0xAD	/* Auto Address Increment Word Program */ +#define CMD_SST_AAI_WP		0xAD	/* Auto Address Incr Word Program */  #define SST_SR_WIP		(1 << 0)	/* Write-in-Progress */  #define SST_SR_WEL		(1 << 1)	/* Write enable */ @@ -50,47 +50,61 @@ static const struct sst_spi_flash_params sst_spi_flash_table[] = {  		.flags = SST_FEAT_WP,  		.nr_sectors = 128,  		.name = "SST25VF040B", -	},{ +	}, +	{  		.idcode1 = 0x8e,  		.flags = SST_FEAT_WP,  		.nr_sectors = 256,  		.name = "SST25VF080B", -	},{ +	}, +	{  		.idcode1 = 0x41,  		.flags = SST_FEAT_WP,  		.nr_sectors = 512,  		.name = "SST25VF016B", -	},{ +	}, +	{  		.idcode1 = 0x4a,  		.flags = SST_FEAT_WP,  		.nr_sectors = 1024,  		.name = "SST25VF032B", -	},{ +	}, +	{  		.idcode1 = 0x4b,  		.flags = SST_FEAT_MBP,  		.nr_sectors = 2048,  		.name = "SST25VF064C", -	},{ +	}, +	{  		.idcode1 = 0x01,  		.flags = SST_FEAT_WP,  		.nr_sectors = 16,  		.name = "SST25WF512", -	},{ +	}, +	{  		.idcode1 = 0x02,  		.flags = SST_FEAT_WP,  		.nr_sectors = 32,  		.name = "SST25WF010", -	},{ +	}, +	{  		.idcode1 = 0x03,  		.flags = SST_FEAT_WP,  		.nr_sectors = 64,  		.name = "SST25WF020", -	},{ +	}, +	{  		.idcode1 = 0x04,  		.flags = SST_FEAT_WP,  		.nr_sectors = 128,  		.name = "SST25WF040",  	}, +	{ +		.idcode1 = 0x05, +		.flags = SST_FEAT_WP, +		.nr_sectors = 256, +		.name = "SST25WF080", +	},  };  static int @@ -105,7 +119,7 @@ sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)  	};  	debug("BP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n", -		spi_w8r8(flash->spi, CMD_READ_STATUS), buf, cmd[0], offset); +	      spi_w8r8(flash->spi, CMD_READ_STATUS), buf, cmd[0], offset);  	ret = spi_flash_cmd_write_enable(flash);  	if (ret) @@ -152,11 +166,11 @@ sst_write_wp(struct spi_flash *flash, u32 offset, size_t len, const void *buf)  	for (; actual < len - 1; actual += 2) {  		debug("WP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n", -		     spi_w8r8(flash->spi, CMD_READ_STATUS), buf + actual, cmd[0], -		     offset); +		      spi_w8r8(flash->spi, CMD_READ_STATUS), buf + actual, +		      cmd[0], offset);  		ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len, -		                          buf + actual, 2); +					buf + actual, 2);  		if (ret) {  			debug("SF: sst word program failed\n");  			break; diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index 0ca00f158..c5fa64e37 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -8,7 +8,7 @@   * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.   * TsiChung Liew (Tsi-Chung.Liew@freescale.com)   * - * SPDX-License-Identifier:	GPL-2.0+  + * SPDX-License-Identifier:	GPL-2.0+   */  #include <common.h> @@ -18,7 +18,7 @@  #include "spi_flash_internal.h"  /* M25Pxx-specific commands */ -#define CMD_M25PXX_RES		0xab	/* Release from DP, and Read Signature */ +#define CMD_M25PXX_RES	0xab	/* Release from DP, and Read Signature */  struct stmicro_spi_flash_params {  	u16 id; @@ -150,7 +150,7 @@ static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {  	},  }; -struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) +struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode)  {  	const struct stmicro_spi_flash_params *params;  	struct spi_flash *flash; @@ -166,17 +166,17 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)  			idcode[0] = 0x20;  			idcode[1] = 0x20;  			idcode[2] = idcode[3] + 1; -		} else +		} else {  			return NULL; +		}  	}  	id = ((idcode[1] << 8) | idcode[2]);  	for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) {  		params = &stmicro_spi_flash_table[i]; -		if (params->id == id) { +		if (params->id == id)  			break; -		}  	}  	if (i == ARRAY_SIZE(stmicro_spi_flash_table)) { diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c index c399bf14d..b31911a40 100644 --- a/drivers/mtd/spi/winbond.c +++ b/drivers/mtd/spi/winbond.c @@ -123,7 +123,7 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)  	if (i == ARRAY_SIZE(winbond_spi_flash_table)) {  		debug("SF: Unsupported Winbond ID %02x%02x\n", -				idcode[1], idcode[2]); +		      idcode[1], idcode[2]);  		return NULL;  	} |