public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sourav Poddar <sourav.poddar@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 08/12] sf: Discover read dummy_cycles
Date: Mon, 6 Jan 2014 12:34:31 +0530	[thread overview]
Message-ID: <52CA557F.3070402@ti.com> (raw)
In-Reply-To: <4c399e81-548a-4121-a938-6df85186f5b4@DB9EHSMHS029.ehs.local>

On Saturday 04 January 2014 08:34 PM, Jagannadha Sutradharudu Teki wrote:
> Discovered the read dummy_cycles based on the configured
> read command.
>
> Signed-off-by: Jagannadha Sutradharudu Teki<jaganna@xilinx.com>
> ---
>   drivers/mtd/spi/sf_internal.h |  2 ++
>   drivers/mtd/spi/sf_ops.c      | 10 ++++++----
>   drivers/mtd/spi/sf_probe.c    | 12 ++++++++++++
>   include/spi_flash.h           |  2 ++
>   4 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
> index 7be0292..a9f5a81 100644
> --- a/drivers/mtd/spi/sf_internal.h
> +++ b/drivers/mtd/spi/sf_internal.h
> @@ -10,6 +10,8 @@
>   #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
>
>   /* CFI Manufacture ID's */
> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
> index 827f719..dda75b1 100644
> --- a/drivers/mtd/spi/sf_ops.c
> +++ b/drivers/mtd/spi/sf_ops.c
> @@ -9,6 +9,7 @@
>    */
>
>   #include<common.h>
> +#include<malloc.h>
>   #include<spi.h>
>   #include<spi_flash.h>
>   #include<watchdog.h>
> @@ -216,7 +217,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;
> -	u8 cmd[4];
> +	u8 cmd[SPI_FLASH_CMD_LEN];
>   	int ret = -1;
>
>   	erase_size = flash->erase_size;
> @@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
>   {
>   	unsigned long byte_addr, page_size;
>   	size_t chunk_len, actual;
> -	u8 cmd[4];
> +	u8 cmd[SPI_FLASH_CMD_LEN];
>   	int ret = -1;
>
>   	page_size = flash->page_size;
> @@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
>   int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
>   		size_t len, void *data)
>   {
> -	u8 cmd[5], bank_sel = 0;
> +	u8 *cmd, bank_sel = 0;
>   	u32 remain_len, read_len;
>   	int ret = -1;
>
> @@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
>   		return 0;
>   	}
>
> +	cmd = malloc(SPI_FLASH_CMD_LEN + flash->dummy_cycles);
> +	memset(cmd, 0, SPI_FLASH_CMD_LEN + flash->dummy_cycles);
>   	cmd[0] = flash->read_cmd;
> -	cmd[4] = 0x00;
>
>   	while (len) {
>   #ifdef CONFIG_SPI_FLASH_BAR
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index a049e72..b070adc 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
>   		}
>   	}
>
> +	/* Read dummy cycles */
> +	switch (flash->read_cmd) {
> +	case CMD_READ_QUAD_IO_FAST:
> +		flash->dummy_cycles = 2;
> +		break;
> +	case CMD_READ_ARRAY_SLOW:
> +		flash->dummy_cycles = 0;
> +		break;
> +	default:
> +		flash->dummy_cycles = 1;
> +	}
> +
what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy 
cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?
>   	/* Poll cmd seclection */
>   	flash->poll_cmd = CMD_READ_STATUS;
>   #ifdef CONFIG_SPI_FLASH_STMICRO
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index d24e40a..bdd4141 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -72,6 +72,7 @@ extern const struct spi_flash_params spi_flash_params_table[];
>    * @erase_cmd:		Erase cmd 4K, 32K, 64K
>    * @read_cmd:		Read cmd - Array Fast, Extn read and quad read.
>    * @write_cmd:		Write cmd - page and quad program.
> + * @dummy_cycles:	Dummy cycles for read operation.
>    * @memory_map:		Address of read-only SPI flash access
>    * @read:		Flash read ops: Read len bytes at offset into buf
>    *			Supported cmds: Fast Array Read
> @@ -98,6 +99,7 @@ struct spi_flash {
>   	u8 erase_cmd;
>   	u8 read_cmd;
>   	u8 write_cmd;
> +	u8 dummy_cycles;
>
>   	void *memory_map;
>   	int (*read)(struct spi_flash *flash, u32 offset, size_t len, void *buf);

  reply	other threads:[~2014-01-06  7:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1388847888-19474-1-git-send-email-jaganna@xilinx.com>
2014-01-04 15:04 ` [U-Boot] [PATCH v6 01/12] sf: Add extended read commands support Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 02/12] sf: Add quad read/write " Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 03/12] sf: ops: Add configuration register writing support Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 04/12] sf: Set quad enable bit support Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 05/12] sf: probe: Enable RD_FULL and WR_QPP Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 06/12] sf: Separate the flash params table Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 07/12] sf: Add QUAD_IO_FAST read support Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 08/12] sf: Discover read dummy_cycles Jagannadha Sutradharudu Teki
2014-01-06  7:04   ` Sourav Poddar [this message]
2014-01-06 10:18     ` Jagan Teki
2014-01-06 10:21       ` Sourav Poddar
2014-01-06 10:30         ` Jagan Teki
2014-01-06 10:35           ` Sourav Poddar
2014-01-06 10:37             ` Jagan Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 09/12] sf: Add macronix set QEB support Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 10/12] sf: probe: Enable macronix quad read/write cmds support Jagannadha Sutradharudu Teki
2014-01-04 15:04 ` [U-Boot] [PATCH v6 11/12] sf: Divide flash register ops from QEB code Jagannadha Sutradharudu Teki
2014-01-06  7:09   ` Sourav Poddar
2014-01-06  7:40     ` Jagan Teki
2014-01-06  8:22       ` Sourav Poddar
2014-01-04 15:04 ` [U-Boot] [PATCH v6 12/12] sf: Code cleanups Jagannadha Sutradharudu Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52CA557F.3070402@ti.com \
    --to=sourav.poddar@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox