All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Frank.Li@freescale.com
Cc: linux-mtd@lists.infradead.org, b45815@freescale.com, lznuaa@gmail.com
Subject: Re: [PATCH v3 2/8] mtd: spi-nor: fsl-quadspi: use quirk to distinguish different qspi version
Date: Fri, 31 Jul 2015 13:35:39 -0700	[thread overview]
Message-ID: <20150731203539.GB10676@google.com> (raw)
In-Reply-To: <1437761188-8179-3-git-send-email-Frank.Li@freescale.com>

On Sat, Jul 25, 2015 at 02:06:22AM +0800, Frank.Li@freescale.com wrote:
> From: Han Xu <b45815@freescale.com>
> 
> add several quirk to distinguish different version of qspi module.
> 
> Signed-off-by: Han Xu <b45815@freescale.com>
> ---
>  drivers/mtd/spi-nor/fsl-quadspi.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
> index ac9d633..5f31bc7 100644
> --- a/drivers/mtd/spi-nor/fsl-quadspi.c
> +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
> @@ -28,6 +28,11 @@
>  #include <linux/mtd/spi-nor.h>
>  #include <linux/mutex.h>
>  
> +/* Controller needs driver to swap endian */
> +#define QUADSPI_QUIRK_SWAP_ENDIAN	(1 << 0)
> +/* Controller needs 4x internal clock */
> +#define QUADSPI_QUIRK_4X_INT_CLK	(1 << 1)
> +
>  /* The registers */
>  #define QUADSPI_MCR			0x00
>  #define QUADSPI_MCR_RESERVED_SHIFT	16
> @@ -202,20 +207,23 @@ struct fsl_qspi_devtype_data {
>  	int rxfifo;
>  	int txfifo;
>  	int ahb_buf_size;
> +	int driver_data;
>  };
>  
>  static struct fsl_qspi_devtype_data vybrid_data = {
>  	.devtype = FSL_QUADSPI_VYBRID,
>  	.rxfifo = 128,
>  	.txfifo = 64,
> -	.ahb_buf_size = 1024
> +	.ahb_buf_size = 1024,
> +	.driver_data = QUADSPI_QUIRK_SWAP_ENDIAN

All field entries (including the last) should end the line with a comma,
so if you add fields in the future, you don't need to mess with the
previous line. This helps to keep the line-diff history a little more
clear.

>  };
>  
>  static struct fsl_qspi_devtype_data imx6sx_data = {
>  	.devtype = FSL_QUADSPI_IMX6SX,
>  	.rxfifo = 128,
>  	.txfifo = 512,
> -	.ahb_buf_size = 1024
> +	.ahb_buf_size = 1024,
> +	.driver_data = QUADSPI_QUIRK_4X_INT_CLK

Ditto.

Otherwise, looks good:

Reviewed-by: Brian Norris <computersforpeace@gmail.com>

>  };
>  
>  #define FSL_QSPI_MAX_CHIP	4
> @@ -239,14 +247,14 @@ struct fsl_qspi {
>  	struct mutex lock;
>  };
>  
> -static inline int is_vybrid_qspi(struct fsl_qspi *q)
> +static inline int needs_swap_endian(struct fsl_qspi *q)
>  {
> -	return q->devtype_data->devtype == FSL_QUADSPI_VYBRID;
> +	return q->devtype_data->driver_data & QUADSPI_QUIRK_SWAP_ENDIAN;
>  }
>  
> -static inline int is_imx6sx_qspi(struct fsl_qspi *q)
> +static inline int needs_4x_clock(struct fsl_qspi *q)
>  {
> -	return q->devtype_data->devtype == FSL_QUADSPI_IMX6SX;
> +	return q->devtype_data->driver_data & QUADSPI_QUIRK_4X_INT_CLK;
>  }
>  
>  /*
> @@ -255,7 +263,7 @@ static inline int is_imx6sx_qspi(struct fsl_qspi *q)
>   */
>  static inline u32 fsl_qspi_endian_xchg(struct fsl_qspi *q, u32 a)
>  {
> -	return is_vybrid_qspi(q) ? __swab32(a) : a;
> +	return needs_swap_endian(q) ? __swab32(a) : a;
>  }
>  
>  static inline void fsl_qspi_unlock_lut(struct fsl_qspi *q)
> @@ -650,7 +658,7 @@ static int fsl_qspi_nor_setup_last(struct fsl_qspi *q)
>  	unsigned long rate = q->clk_rate;
>  	int ret;
>  
> -	if (is_imx6sx_qspi(q))
> +	if (needs_4x_clock(q))
>  		rate *= 4;
>  
>  	ret = clk_set_rate(q->clk, rate);
> -- 
> 1.9.1
> 

  reply	other threads:[~2015-07-31 20:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 18:06 [PATCH v3 0/8] mtd: spi-nor: fsl-quadspi fix and added i.mx7d and i.mxul support Frank.Li
2015-07-24 18:06 ` [PATCH v3 1/8] mtd: spi-nor: fsl-qspi: dynamically map memory space for AHB read Frank.Li
2015-07-31 20:28   ` Brian Norris
2015-07-24 18:06 ` [PATCH v3 2/8] mtd: spi-nor: fsl-quadspi: use quirk to distinguish different qspi version Frank.Li
2015-07-31 20:35   ` Brian Norris [this message]
2015-07-24 18:06 ` [PATCH v3 3/8] mtd: spi-nor: fsl-quadspi: add imx7d support Frank.Li
2015-07-31 20:41   ` Brian Norris
2015-07-31 20:45   ` Brian Norris
2015-07-24 18:06 ` [PATCH v3 4/8] mtd: spi-nor: fsl-quadspi: add i.mx6ul support Frank.Li
2015-07-31 20:46   ` Brian Norris
2015-07-24 18:06 ` [PATCH v3 5/8] mtd: spi-nor: fsl-quadspi: i.MX6SX: fixed the random QSPI access failed issue Frank.Li
2015-07-31 21:00   ` Brian Norris
2015-07-24 18:06 ` [PATCH v3 6/8] mtd: spi-nor: fsl-quadspi: workaround qspi can't wakeup from wait mode Frank.Li
2015-07-24 18:06 ` [PATCH v3 7/8] mtd: spi-nor: fsl-quadspi: reset the module in the probe Frank.Li
2015-07-24 18:06 ` [PATCH v3 8/8] mtd: spi-nor: fsl-quadspi: fix unsupported cmd when run flash_erase Frank.Li
2015-07-31 21:20   ` Brian Norris
2015-07-31 21:58     ` Zhi Li
2015-07-24 19:42 ` [PATCH v3 0/8] mtd: spi-nor: fsl-quadspi fix and added i.mx7d and i.mxul support Brian Norris
2015-07-24 19:46   ` Zhi Li
2015-07-24 19:51     ` Zhi Li
2015-07-24 19:54       ` Brian Norris
2015-07-24 19:57         ` Zhi Li

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=20150731203539.GB10676@google.com \
    --to=computersforpeace@gmail.com \
    --cc=Frank.Li@freescale.com \
    --cc=b45815@freescale.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lznuaa@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.