* [PATCH] mtd: fsl-quadspi: Access multiple chips simultaneously
@ 2015-01-15 23:26 Han Xu
2015-01-16 0:40 ` Huang Shijie
0 siblings, 1 reply; 3+ messages in thread
From: Han Xu @ 2015-01-15 23:26 UTC (permalink / raw)
To: computersforpeace; +Cc: linux-mtd, shijie8, Han Xu
Add supports for simultaneous access to multiple chips. Need to lock
the mutex before any quad spi operations and unlock the mutex after
operations complete.
Signed-off-by: Han Xu <han.xu@freescale.com>
---
drivers/mtd/spi-nor/fsl-quadspi.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 39763b9..7964511 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -26,6 +26,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/spi-nor.h>
+#include <linux/mutex.h>
/* The registers */
#define QUADSPI_MCR 0x00
@@ -227,6 +228,7 @@ struct fsl_qspi {
u32 nor_num;
u32 clk_rate;
unsigned int chip_base_addr; /* We may support two chips. */
+ struct mutex lock;
};
static inline int is_vybrid_qspi(struct fsl_qspi *q)
@@ -751,6 +753,8 @@ static int fsl_qspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
struct fsl_qspi *q = nor->priv;
int ret;
+ mutex_lock(&q->lock);
+
ret = clk_enable(q->clk_en);
if (ret)
return ret;
@@ -771,6 +775,7 @@ static void fsl_qspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
clk_disable(q->clk);
clk_disable(q->clk_en);
+ mutex_unlock(&q->lock);
}
static int fsl_qspi_probe(struct platform_device *pdev)
@@ -862,6 +867,8 @@ static int fsl_qspi_probe(struct platform_device *pdev)
if (of_get_property(np, "fsl,qspi-has-second-chip", NULL))
has_second_chip = true;
+ mutex_init(&q->lock);
+
/* iterate the subnodes. */
for_each_available_child_of_node(dev->of_node, np) {
char modalias[40];
--
1.7.8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: fsl-quadspi: Access multiple chips simultaneously
2015-01-15 23:26 [PATCH] mtd: fsl-quadspi: Access multiple chips simultaneously Han Xu
@ 2015-01-16 0:40 ` Huang Shijie
2015-03-24 21:17 ` Brian Norris
0 siblings, 1 reply; 3+ messages in thread
From: Huang Shijie @ 2015-01-16 0:40 UTC (permalink / raw)
To: Han Xu; +Cc: shijie8, computersforpeace, linux-mtd
On Fri, Jan 16, 2015 at 07:26:55AM +0800, Han Xu wrote:
> Add supports for simultaneous access to multiple chips. Need to lock
> the mutex before any quad spi operations and unlock the mutex after
> operations complete.
>
> Signed-off-by: Han Xu <han.xu@freescale.com>
> ---
> drivers/mtd/spi-nor/fsl-quadspi.c | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
> index 39763b9..7964511 100644
> --- a/drivers/mtd/spi-nor/fsl-quadspi.c
> +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
> @@ -26,6 +26,7 @@
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/partitions.h>
> #include <linux/mtd/spi-nor.h>
> +#include <linux/mutex.h>
>
> /* The registers */
> #define QUADSPI_MCR 0x00
> @@ -227,6 +228,7 @@ struct fsl_qspi {
> u32 nor_num;
> u32 clk_rate;
> unsigned int chip_base_addr; /* We may support two chips. */
> + struct mutex lock;
> };
>
> static inline int is_vybrid_qspi(struct fsl_qspi *q)
> @@ -751,6 +753,8 @@ static int fsl_qspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
> struct fsl_qspi *q = nor->priv;
> int ret;
>
> + mutex_lock(&q->lock);
> +
> ret = clk_enable(q->clk_en);
> if (ret)
> return ret;
> @@ -771,6 +775,7 @@ static void fsl_qspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
>
> clk_disable(q->clk);
> clk_disable(q->clk_en);
> + mutex_unlock(&q->lock);
> }
>
> static int fsl_qspi_probe(struct platform_device *pdev)
> @@ -862,6 +867,8 @@ static int fsl_qspi_probe(struct platform_device *pdev)
> if (of_get_property(np, "fsl,qspi-has-second-chip", NULL))
> has_second_chip = true;
>
> + mutex_init(&q->lock);
> +
> /* iterate the subnodes. */
> for_each_available_child_of_node(dev->of_node, np) {
> char modalias[40];
> --
Acked-by: Huang Shijie <shijie.huang@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: fsl-quadspi: Access multiple chips simultaneously
2015-01-16 0:40 ` Huang Shijie
@ 2015-03-24 21:17 ` Brian Norris
0 siblings, 0 replies; 3+ messages in thread
From: Brian Norris @ 2015-03-24 21:17 UTC (permalink / raw)
To: Huang Shijie; +Cc: shijie8, linux-mtd, Han Xu
On Fri, Jan 16, 2015 at 08:40:31AM +0800, Huang Shijie wrote:
> On Fri, Jan 16, 2015 at 07:26:55AM +0800, Han Xu wrote:
> > Add supports for simultaneous access to multiple chips. Need to lock
> > the mutex before any quad spi operations and unlock the mutex after
> > operations complete.
> >
> > Signed-off-by: Han Xu <han.xu@freescale.com>
> > ---
> > drivers/mtd/spi-nor/fsl-quadspi.c | 7 +++++++
> > 1 files changed, 7 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
> > index 39763b9..7964511 100644
> > --- a/drivers/mtd/spi-nor/fsl-quadspi.c
> > +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
> > @@ -26,6 +26,7 @@
> > #include <linux/mtd/mtd.h>
> > #include <linux/mtd/partitions.h>
> > #include <linux/mtd/spi-nor.h>
> > +#include <linux/mutex.h>
> >
> > /* The registers */
> > #define QUADSPI_MCR 0x00
> > @@ -227,6 +228,7 @@ struct fsl_qspi {
> > u32 nor_num;
> > u32 clk_rate;
> > unsigned int chip_base_addr; /* We may support two chips. */
> > + struct mutex lock;
> > };
> >
> > static inline int is_vybrid_qspi(struct fsl_qspi *q)
> > @@ -751,6 +753,8 @@ static int fsl_qspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
> > struct fsl_qspi *q = nor->priv;
> > int ret;
> >
> > + mutex_lock(&q->lock);
> > +
> > ret = clk_enable(q->clk_en);
> > if (ret)
> > return ret;
> > @@ -771,6 +775,7 @@ static void fsl_qspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
> >
> > clk_disable(q->clk);
> > clk_disable(q->clk_en);
> > + mutex_unlock(&q->lock);
> > }
> >
> > static int fsl_qspi_probe(struct platform_device *pdev)
> > @@ -862,6 +867,8 @@ static int fsl_qspi_probe(struct platform_device *pdev)
> > if (of_get_property(np, "fsl,qspi-has-second-chip", NULL))
> > has_second_chip = true;
> >
> > + mutex_init(&q->lock);
> > +
> > /* iterate the subnodes. */
> > for_each_available_child_of_node(dev->of_node, np) {
> > char modalias[40];
> > --
>
> Acked-by: Huang Shijie <shijie.huang@intel.com>
This doesn't apply to the latest l2-mtd.git. Can you rebase and resend?
Brian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-24 21:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15 23:26 [PATCH] mtd: fsl-quadspi: Access multiple chips simultaneously Han Xu
2015-01-16 0:40 ` Huang Shijie
2015-03-24 21:17 ` Brian Norris
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.