[U-Boot] [PATCH v4] sf: Macronix additional chips supported

Prafulla Wadaskar prafulla at marvell.com
Mon Jul 6 09:34:54 CEST 2009


Hi Mike
I hope this is through :-)
While sending a patch I cut pasted --in-reply-to field wrongly, that does not hard patch contents.

Is this okay or shall I re-send this patch?

Regards..
Prafulla . .
 

> -----Original Message-----
> From: Prafulla Wadaskar [mailto:prafulla at marvell.com] 
> Sent: Monday, July 06, 2009 5:51 PM
> To: u-boot at lists.denx.de
> Cc: Nicolas Pitre; Manas Saksena; Lennert Buijtenhek; 
> Prabhanjan Sarnaik; Ronen Shitrit; Ashish Karkare; Prafulla 
> Wadaskar; Piyush Shah
> Subject: [PATCH v4] sf: Macronix additional chips supported
> 
> new chips supported:-
> MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which 
> MX25L6405D and MX25L12855E tested on Kirkwood platforms
> 
> Modified the Macronix flash support to use 2 bytes of device 
> id instead of 1 This was required to support MX25L12855E
> 
> Done some indentation fixes
> 
> Signed-off-by: Piyush Shah <spiyush at marvell.com>
> Signed-off-by: Prafulla Wadaskar <prafulla at marvell.com>
> ---
> Change log:-
> v2: leading spaces removed for clean patch apply build error 
> fixed tested for new added chip MX25L6405D
> 
> v3: updated contributors info
> ids combined to u16
> ids list of defines removed, used values in the struct
> 
> v4: indentation fixes,
> line lengths brought below 78 chars
> alligned access fixed for idcode
> 
>  drivers/mtd/spi/macronix.c |   83 
> +++++++++++++++++++++++++++++--------------
>  1 files changed, 56 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/mtd/spi/macronix.c 
> b/drivers/mtd/spi/macronix.c index 9464c84..64922b5 100644
> --- a/drivers/mtd/spi/macronix.c
> +++ b/drivers/mtd/spi/macronix.c
> @@ -20,7 +20,7 @@
>   *
>   * This program is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>   * GNU General Public License for more details.
>   *
>   * You should have received a copy of the GNU General Public 
> License @@ -47,20 +47,12 @@
>  #define CMD_MX25XX_BE		0xD8	/* Block Erase */
>  #define CMD_MX25XX_CE		0xc7	/* Chip Erase */
>  #define CMD_MX25XX_DP		0xb9	/* Deep Power-down */
> -#define CMD_MX25XX_RES		0xab	/* Release from 
> DP, and Read Signature */
> -
> -#define MXIC_ID_MX2516		0x15
> -#define MXIC_ID_MX2520		0x12
> -#define MXIC_ID_MX2532		0x16
> -#define MXIC_ID_MX2540		0x13
> -#define MXIC_ID_MX2564		0x17
> -#define MXIC_ID_MX2580		0x14
> -#define MXIC_ID_MX25128		0x18
> +#define CMD_MX25XX_RES		0xab	/* Release from 
> DP, and Read Sign */
>  
>  #define MACRONIX_SR_WIP		(1 << 0)	/* 
> Write-in-Progress */
>  
>  struct macronix_spi_flash_params {
> -	u8 idcode1;
> +	u16 idcode;
>  	u16 page_size;
>  	u16 pages_per_sector;
>  	u16 sectors_per_block;
> @@ -73,24 +65,57 @@ struct macronix_spi_flash {
>  	const struct macronix_spi_flash_params *params;  };
>  
> -static inline struct macronix_spi_flash 
> *to_macronix_spi_flash(struct spi_flash
> -							       *flash)
> +static inline struct macronix_spi_flash *to_macronix_spi_flash(
> +					struct spi_flash *flash)
>  {
>  	return container_of(flash, struct macronix_spi_flash, flash);  }
>  
>  static const struct macronix_spi_flash_params 
> macronix_spi_flash_table[] = {
>  	{
> -		.idcode1 = MXIC_ID_MX25128,
> +		.idcode = 0x2015,
> +		.page_size = 256,
> +		.pages_per_sector = 16,
> +		.sectors_per_block = 16,
> +		.nr_blocks = 32,
> +		.name = "MX25L1605D",
> +	},
> +	{
> +		.idcode = 0x2016,
> +		.page_size = 256,
> +		.pages_per_sector = 16,
> +		.sectors_per_block = 16,
> +		.nr_blocks = 64,
> +		.name = "MX25L3205D",
> +	},
> +	{
> +		.idcode = 0x2017,
> +		.page_size = 256,
> +		.pages_per_sector = 16,
> +		.sectors_per_block = 16,
> +		.nr_blocks = 128,
> +		.name = "MX25L6405D",
> +	},
> +	{
> +		.idcode = 0x2018,
>  		.page_size = 256,
>  		.pages_per_sector = 16,
>  		.sectors_per_block = 16,
>  		.nr_blocks = 256,
>  		.name = "MX25L12805D",
>  	},
> +	{
> +		.idcode = 0x2618,
> +		.page_size = 256,
> +		.pages_per_sector = 16,
> +		.sectors_per_block = 16,
> +		.nr_blocks = 256,
> +		.name = "MX25L12855E",
> +	},
>  };
>  
> -static int macronix_wait_ready(struct spi_flash *flash, 
> unsigned long timeout)
> +static int macronix_wait_ready(struct spi_flash *flash,
> +					unsigned long timeout)
>  {
>  	struct spi_slave *spi = flash->spi;
>  	unsigned long timebase;
> @@ -125,7 +150,7 @@ static int macronix_wait_ready(struct 
> spi_flash *flash, unsigned long timeout)  }
>  
>  static int macronix_read_fast(struct spi_flash *flash,
> -			      u32 offset, size_t len, void *buf)
> +				u32 offset, size_t len, void *buf)
>  {
>  	struct macronix_spi_flash *mcx = to_macronix_spi_flash(flash);
>  	unsigned long page_addr;
> @@ -145,7 +170,7 @@ static int macronix_read_fast(struct 
> spi_flash *flash,  }
>  
>  static int macronix_write(struct spi_flash *flash,
> -			  u32 offset, size_t len, const void *buf)
> +			u32 offset, size_t len, const void *buf)
>  {
>  	struct macronix_spi_flash *mcx = to_macronix_spi_flash(flash);
>  	unsigned long page_addr;
> @@ -176,8 +201,10 @@ static int macronix_write(struct 
> spi_flash *flash,
>  		cmd[3] = byte_addr;
>  
>  		debug
> -		    ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x 
> } chunk_len = %d\n",
> -		     buf + actual, cmd[0], cmd[1], cmd[2], 
> cmd[3], chunk_len);
> +			("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x }"
> +			" chunk_len = %d\n",
> +			buf + actual, cmd[0], cmd[1], cmd[2], cmd[3],
> +			chunk_len);
>  
>  		ret = spi_flash_cmd(flash->spi, 
> CMD_MX25XX_WREN, NULL, 0);
>  		if (ret < 0) {
> @@ -186,7 +213,7 @@ static int macronix_write(struct spi_flash *flash,
>  		}
>  
>  		ret = spi_flash_cmd_write(flash->spi, cmd, 4,
> -					  buf + actual, chunk_len);
> +					buf + actual, chunk_len);
>  		if (ret < 0) {
>  			debug("SF: Macronix Page Program failed\n");
>  			break;
> @@ -203,7 +230,7 @@ static int macronix_write(struct spi_flash *flash,
>  	}
>  
>  	debug("SF: Macronix: Successfully programmed %u bytes @ 0x%x\n",
> -	      len, offset);
> +		len, offset);
>  
>  	spi_release_bus(flash->spi);
>  	return ret;
> @@ -227,7 +254,7 @@ int macronix_erase(struct spi_flash 
> *flash, u32 offset, size_t len)
>  			* mcx->params->sectors_per_block;
>  
>  	if (offset % sector_size || len % sector_size) {
> -		debug("SF: Erase offset/length not multiple of 
> sector size\n");
> +		debug("SF: Erase offset/len not multiple of 
> sector size\n");
>  		return -1;
>  	}
>  
> @@ -258,7 +285,8 @@ int macronix_erase(struct spi_flash 
> *flash, u32 offset, size_t len)
>  			break;
>  		}
>  
> -		ret = macronix_wait_ready(flash, 
> SPI_FLASH_PAGE_ERASE_TIMEOUT);
> +		ret = macronix_wait_ready(flash,
> +				SPI_FLASH_PAGE_ERASE_TIMEOUT);
>  		if (ret < 0) {
>  			debug("SF: Macronix page erase timed out\n");
>  			break;
> @@ -277,15 +305,16 @@ struct spi_flash 
> *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
>  	const struct macronix_spi_flash_params *params;
>  	struct macronix_spi_flash *mcx;
>  	unsigned int i;
> +	u16 id = idcode[0] | idcode[1] << 8;
>  
>  	for (i = 0; i < ARRAY_SIZE(macronix_spi_flash_table); i++) {
>  		params = &macronix_spi_flash_table[i];
> -		if (params->idcode1 == idcode[2])
> +                if (params->idcode == id)
>  			break;
>  	}
>  
>  	if (i == ARRAY_SIZE(macronix_spi_flash_table)) {
> -		debug("SF: Unsupported Macronix ID %02x\n", idcode[1]);
> +		debug("SF: Unsupported Macronix ID %04x\n", id);
>  		return NULL;
>  	}
>  
> @@ -303,10 +332,10 @@ struct spi_flash 
> *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
>  	mcx->flash.erase = macronix_erase;
>  	mcx->flash.read = macronix_read_fast;
>  	mcx->flash.size = params->page_size * params->pages_per_sector
> -	    * params->sectors_per_block * params->nr_blocks;
> +		* params->sectors_per_block * params->nr_blocks;
>  
>  	printf("SF: Detected %s with page size %u, total %u bytes\n",
> -	      params->name, params->page_size, mcx->flash.size);
> +		params->name, params->page_size, mcx->flash.size);
>  
>  	return &mcx->flash;
>  }
> --
> 1.5.3.3
> 
> 


More information about the U-Boot mailing list