Re: [PATCH 1/3] spi: spi-xilinx: Remove ISR race condition

2015-12-03 Thread Shubhrajyoti Datta
>
>>
>> =
>> spi: xilinx - minimize iomem reads
>>
>> If this IP core is accessed through bridges like PCI-e, reads are rather
>> costly. Doing many reads or read-modify-writes is thus long and strenuous
>> on the CPU (active waiting).
>>
>> The transfer workflow of this driver allows some assumptions to be made 
>> and
>> exploited to minimize reads as much as possible.
>>
>> These two assumptions are made:
>> - since we are in control of the CR register, cache it so we don't have 
>> to
>>   read it all the time to modify it.
>
> Makes sense.

I have made an attempt at it can you check if you get any performance
improvemets
on your setup.

http://www.spinics.net/lists/linux-spi/msg05963.html


Thanks,
Shubhrajyoti

--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 1/3] spi: spi-xilinx: Remove ISR race condition

2015-10-12 Thread Shubhrajyoti Datta
On Thu, Oct 8, 2015 at 8:40 PM, Jean-Francois Dagenais
 wrote:
>
>> On Jun 4, 2013, at 1:32 PM, Mark Brown  wrote:
>>
>> Applied but this is a bit sad, having to defer the refill to process
>> context means that we're adding extra latency which takes us further
>> away from being able to saturate the bus.  There ought to be a way to
>> avoid the issue though I can't think of a non-racy one - I guess level
>> triggered interrupts aren't an option?
>
> Hi all,
>
> We've been using an improved version of this driver in production for years 
> here
> in the 3.4 tree. I had to intervene in order to improve performance. I managed
> to double it (not bad).
Thats cool.



>
> Like the other threads I've seen about this, my strategy involved limiting the
> reads to the registers, which, through a pci-e link were kind of long. Here's
> the yet un-submitted commit header I carry in my clone:

Why not send the patches.

>
> =
> spi: xilinx - minimize iomem reads
>
> If this IP core is accessed through bridges like PCI-e, reads are rather
> costly. Doing many reads or read-modify-writes is thus long and strenuous
> on the CPU (active waiting).
>
> The transfer workflow of this driver allows some assumptions to be made 
> and
> exploited to minimize reads as much as possible.
>
> These two assumptions are made:
> - since we are in control of the CR register, cache it so we don't have to
>   read it all the time to modify it.

Makes sense.

> - FIFO (either depth of 1 or 16) are always maxed out, unless the 
> remaining
>   bytes are less than the FIFO depth. For this reason, we can predict the
>   state of the FIFOs without checking with the status register to check if
>   they are empty or full.

Can you explain more details.
>
> Reading 32Mb flash at 32MHz on a core with 8bits/word and FIFO enabled 
> (16),
> has dropped from ~60s to ~30s. Still high, but better. Most of the delay 
> still
> comes from emptying the RX FIFO one "word" at a time.
> ===
>

--
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH v2] spi: Add Lattice ECP3 FPGA configuration via SPI

2012-11-26 Thread Shubhrajyoti Datta
On Mon, Nov 26, 2012 at 4:12 PM, Stefan Roese  wrote:
> +
> +static int __devinit lattice_ecp3_probe(struct spi_device *spi)
> +{
> +   int err;
> +
> +   err = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG,
> + FIRMWARE_NAME, &spi->dev,
> + GFP_KERNEL, spi, firmware_load);
> +   if (err) {
> +   dev_err(&spi->dev, "Firmware loading failed with %d!\n", err);
> +   goto err;
nitpick:
the goto looks un-necessary, could we return err here and save an
un-necessary branch.

> +   }
> +
> +   dev_info(&spi->dev, "FPGA bitstream configuration driver registered 
> (ver %s)\n",
> +   DRIVER_VER);
> +
> +   return 0;
> +
> +err:
> +   return err;
> +}

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] SPI: SSP SPI Controller driver

2012-11-21 Thread Shubhrajyoti Datta
On Wed, Nov 21, 2012 at 5:56 PM, Alan Cox  wrote:

> On Wed, 21 Nov 2012 17:44:21 +0530
> Shubhrajyoti Datta  wrote:
>
> > On Wed, Nov 21, 2012 at 7:46 AM, chao bi  wrote:
> >
> > > +   /* Create the PM_QOS request */
> > > +   if (drv_context->quirks & QUIRKS_USE_PM_QOS)
> > > +   pm_qos_add_request(&drv_context->pm_qos_req,
> > > +   PM_QOS_CPU_DMA_LATENCY,
> > > +   PM_QOS_DEFAULT_VALUE);
> > >
> >
> > What happens if the flag is not set if it is absolutely necessary for
> > the driver it should not be a
> > configurable option
>
> If you read through the code it's set only when the device is
> Moorestown/Oaktrail based and only in slave mode. It is not necessary
> in other configurations.
>

Thats what I was trying to understand.

If I am not wrong the latency is time related.
Why only some platforms / modes need it also the value is not speed
dependent.


My doubt is that the time taken for the dma will be more in lower speed so
the
latency constraint could be relaxed.

Also the spi core today doesnt have slave mode support thats a different
discussion altogether may be we can leave it for now.




>
> Alan
>
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] SPI: SSP SPI Controller driver

2012-11-21 Thread Shubhrajyoti Datta
On Thu, Nov 22, 2012 at 8:56 AM, Bi, Chao  wrote:

>   if (chip_info->enable_loopback)
> +   chip->cr1 |= SSCR1_LBM;
>
> Who sets the enable_loopback?
>
> ** **
>
> [Chao] ‘enable_loopback’ could be configured by SPI Protocol driver before
> it setup SPI controller. Generally it is not set by default because it’s
> used for test and validation.
>

Should it not then depend on  (spi mode ) SPI_LOOP ?

Or am I missing something.

> 
>
> ** **
>
> Thanks
>
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] SPI: SSP SPI Controller driver

2012-11-21 Thread Shubhrajyoti Datta
On Wed, Nov 21, 2012 at 7:46 AM, chao bi  wrote:

> +   /* Create the PM_QOS request */
> +   if (drv_context->quirks & QUIRKS_USE_PM_QOS)
> +   pm_qos_add_request(&drv_context->pm_qos_req,
> +   PM_QOS_CPU_DMA_LATENCY,
> +   PM_QOS_DEFAULT_VALUE);
>

What happens if the flag is not set if it is absolutely necessary for the
driver it should not be a
configurable option?
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] SPI: SSP SPI Controller driver

2012-11-21 Thread Shubhrajyoti Datta
On Wed, Nov 21, 2012 at 7:46 AM, chao bi  wrote:

>
> This patch is to implement SSP SPI controller driver, which has been
> applied and
> validated on intel Moorestown & Medfield platform. The patch are
> originated by
> Ken Mills  and Sylvain Centelles <
> sylvain.centel...@intel.com>,
> and to be further developed by Channing  and Chen Jun
>  according to their integration & validation on
> Medfield platform.
>
> Signed-off-by: Ken Mills 
> Signed-off-by: Sylvain Centelles 
> Signed-off-by: channing 
> Signed-off-by: Chen Jun 
> ---
>  drivers/spi/Kconfig   |9 +
>  drivers/spi/Makefile  |1 +
>  drivers/spi/spi-intel-mid-ssp.c   | 1407
> +
>  include/linux/spi/spi-intel-mid-ssp.h |  326 
>  4 files changed, 1743 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/spi/spi-intel-mid-ssp.c
>  create mode 100644 include/linux/spi/spi-intel-mid-ssp.h
>
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index 1acae35..8b4461b 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -179,6 +179,15 @@ config SPI_IMX
>   This enables using the Freescale i.MX SPI controllers in master
>   mode.
>
> +config SPI_INTEL_MID_SSP
> +   tristate "SSP SPI controller driver for Intel MID platforms"
> +   depends on SPI_MASTER && INTEL_MID_DMAC
> +   help
> + This is the unified SSP SPI master controller driver for
> + the Intel MID platforms, handling Moorestown & Medfield,
> + master clock mode.
> + It supports Bulverde SSP core.
> +
>  config SPI_LM70_LLP
> tristate "Parallel port adapter for LM70 eval board (DEVELOPMENT)"
> depends on PARPORT && EXPERIMENTAL
> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> index c48df47..83f06d0 100644
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -32,6 +32,7 @@ obj-$(CONFIG_SPI_FSL_ESPI)+= spi-fsl-espi.o
>  obj-$(CONFIG_SPI_FSL_SPI)  += spi-fsl-spi.o
>  obj-$(CONFIG_SPI_GPIO) += spi-gpio.o
>  obj-$(CONFIG_SPI_IMX)  += spi-imx.o
> +obj-$(CONFIG_SPI_INTEL_MID_SSP)+= spi-intel-mid-ssp.o
>  obj-$(CONFIG_SPI_LM70_LLP) += spi-lm70llp.o
>  obj-$(CONFIG_SPI_MPC512x_PSC)  += spi-mpc512x-psc.o
>  obj-$(CONFIG_SPI_MPC52xx_PSC)  += spi-mpc52xx-psc.o
> diff --git a/drivers/spi/spi-intel-mid-ssp.c
> b/drivers/spi/spi-intel-mid-ssp.c
> new file mode 100644
> index 000..8fca48f
> --- /dev/null
> +++ b/drivers/spi/spi-intel-mid-ssp.c
> @@ -0,0 +1,1407 @@
> +/*
> + * spi-intel-mid-ssp.c
> + * This driver supports Bulverde SSP core used on Intel MID platforms
> + * It supports SSP of Moorestown & Medfield platforms and handles clock
> + * slave & master modes.
> + *
> + * Copyright (c) 2010, Intel Corporation.
> + *  Ken Mills 
> + *  Sylvain Centelles 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of 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
> along with
> + * this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> + *
> + */
> +
> +/*
> + * Note:
> + *
> + * Supports DMA and non-interrupt polled transfers.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "intel_mid_ssp_spi_unified"
> +
> +MODULE_AUTHOR("Ken Mills");
> +MODULE_DESCRIPTION("Bulverde SSP core SPI contoller");
> +MODULE_LICENSE("GPL");
> +
> +static const struct pci_device_id pci_ids[];
> +
> +#ifdef DUMP_RX
> +static void dump_trailer(const struct device *dev, char *buf, int len,
> int sz)
> +{
> +   int tlen1 = (len < sz ? len : sz);
> +   int tlen2 =  ((len - sz) > sz) ? sz : (len - sz);
> +   unsigned char *p;
> +   static char msg[MAX_SPI_TRANSFER_SIZE];
> +
> +   memset(msg, '\0', sizeof(msg));
> +   p = buf;
> +   while (p < buf + tlen1)
> +   sprintf(msg, "%s%02x", msg, (unsigned int)*p++);
> +
> +   if (tlen2 > 0) {
> +   sprintf(msg, "%s .", msg);
> +   p = (buf+len) - tlen2;
> +   while (p < buf + len)
> +   sprintf(msg, "%s%02x", msg, (unsigned int)*p++);
> +   }
> +
> +   dev_info(dev, "DUMP: %p[0:%d ... %d:%d]:%s", buf, tlen1 - 1,
> +  len-tlen2, len - 1, msg);
> +}
> +#endif
> +
> +static inline u32 i

Re: [PATCH 1/1] spi: omap2-mcspi: remove duplicate inclusion of linux/err.h

2012-11-19 Thread Shubhrajyoti Datta
On Mon, Nov 19, 2012 at 5:07 PM, Sachin Kamat wrote:

> linux/err.h was included twice.
>
Looks good to me.

Wei had also had similar views.

https://lkml.org/lkml/2012/10/7/67


> Signed-off-by: Sachin Kamat 
> ---
>  drivers/spi/spi-omap2-mcspi.c |1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index cc4f2dd..a2cfde6 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -39,7 +39,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>
>  #include 
>
> --
> 1.7.4.1
>
>
>
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Fix the redifine warning

2012-11-18 Thread Shubhrajyoti D
Fix the below warning
drivers/spi/spi-omap2-mcspi.c:336:34: warning: symbol 'tx' shadows an earlier 
one
drivers/spi/spi-omap2-mcspi.c:327:12: originally declared here

So delete the u8 tx as it is assigned and not used(resigned afterwards).

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 251f6d0..c3dcfb3 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -323,14 +323,11 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   const u8* tx;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len;
 
-   tx = xfer->tx_buf;
-
if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
struct scatterlist sg;
-- 
1.7.5.4


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 06/17] spi/atmel_spi: add flag to controller data for lock operations

2012-11-15 Thread Shubhrajyoti Datta
On Mon, Nov 12, 2012 at 2:22 PM, Wenyou Yang  wrote:
> From: Nicolas Ferre 
>
> Will allow to drop the lock during DMA operations.
>
> Signed-off-by: Nicolas Ferre 
> Cc: grant.lik...@secretlab.ca
> Cc: spi-devel-general@lists.sourceforge.net
> ---
>  drivers/spi/spi-atmel.c |   31 +++
>  1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 76a1baf..37f54c3 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -187,6 +187,7 @@
>   */
>  struct atmel_spi {
> spinlock_t  lock;
> +   unsigned long   flags;
>
> resource_size_t phybase;
> void __iomem*regs;
> @@ -323,6 +324,16 @@ static void cs_deactivate(struct atmel_spi *as, struct 
> spi_device *spi)
> gpio_set_value(asd->npcs_pin, !active);
>  }
>
> +static void atmel_spi_lock(struct atmel_spi *as)
> +{
> +   spin_lock_irqsave(&as->lock, as->flags);
> +}
> +
> +static void atmel_spi_unlock(struct atmel_spi *as)
> +{
> +   spin_unlock_irqrestore(&as->lock, as->flags);
> +}

May be this can be called directly.

> +
>  static inline int atmel_spi_xfer_is_last(struct spi_message *msg,
> struct spi_transfer *xfer)
>  {
> @@ -559,9 +570,9 @@ atmel_spi_msg_done(struct spi_master *master, struct 
> atmel_spi *as,
> "xfer complete: %u bytes transferred\n",
> msg->actual_length);
>
> -   spin_unlock(&as->lock);
> +   atmel_spi_unlock(as);
> msg->complete(msg->context);
> -   spin_lock(&as->lock);
> +   atmel_spi_lock(as);
>
> as->current_transfer = NULL;
> as->next_transfer = NULL;
> @@ -788,13 +799,11 @@ static int atmel_spi_setup(struct spi_device *spi)
> spi->controller_state = asd;
> gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH));
> } else {
> -   unsigned long   flags;
> -
> -   spin_lock_irqsave(&as->lock, flags);
> +   atmel_spi_lock(as);
> if (as->stay == spi)
> as->stay = NULL;
> cs_deactivate(as, spi);
> -   spin_unlock_irqrestore(&as->lock, flags);
> +   atmel_spi_unlock(as);
> }
>
> asd->csr = csr;
> @@ -813,7 +822,6 @@ static int atmel_spi_transfer(struct spi_device *spi, 
> struct spi_message *msg)
>  {
> struct atmel_spi*as;
> struct spi_transfer *xfer;
> -   unsigned long   flags;
> struct device   *controller = spi->master->dev.parent;
> u8  bits;
> struct atmel_spi_device *asd;
> @@ -878,11 +886,11 @@ static int atmel_spi_transfer(struct spi_device *spi, 
> struct spi_message *msg)
> msg->status = -EINPROGRESS;
> msg->actual_length = 0;
>
> -   spin_lock_irqsave(&as->lock, flags);
> +   atmel_spi_lock(as);
> list_add_tail(&msg->queue, &as->queue);
> if (!as->current_transfer)
> atmel_spi_next_message(spi->master);
> -   spin_unlock_irqrestore(&as->lock, flags);
> +   atmel_spi_unlock(as);
>
> return 0;
>  }
> @@ -892,17 +900,16 @@ static void atmel_spi_cleanup(struct spi_device *spi)
> struct atmel_spi*as = spi_master_get_devdata(spi->master);
> struct atmel_spi_device *asd = spi->controller_state;
> unsignedgpio = (unsigned) spi->controller_data;
> -   unsigned long   flags;
>
> if (!asd)
> return;
>
> -   spin_lock_irqsave(&as->lock, flags);
> +   atmel_spi_lock(as);
> if (as->stay == spi) {
> as->stay = NULL;
> cs_deactivate(as, spi);
> }
> -   spin_unlock_irqrestore(&as->lock, flags);
> +   atmel_spi_unlock(as);
>
> spi->controller_state = NULL;
> gpio_free(gpio);
> --
> 1.7.9.5
>
>
> --
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_nov
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net

Re: [PATCH resend] SPI: McSPI: fix D0/D1 direction confusion

2012-11-14 Thread Shubhrajyoti Datta
On Wed, Nov 14, 2012 at 8:44 AM, Daniel Mack  wrote:
> 0384e90b8 ("spi/mcspi: allow configuration of pin directions") did what
> it claimed to do the wrong way around. D0/D1 is configured as output by
> *clearing* the bits in the conf registers, hence also breaking the
> former default behaviour.
>
> Fix this before that change is merged to mainline.
>
Indeed. Thanks.
Reviewed-by: Shubhrajyoti D 

> Signed-off-by: Daniel Mack 
> ---
> Resent to apply directly on top of original commit.
>
>  Documentation/devicetree/bindings/spi/omap-spi.txt | 6 +++---
>  drivers/spi/spi-omap2-mcspi.c  | 6 +++---
>  include/linux/platform_data/spi-omap2-mcspi.h  | 4 ++--
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/spi/omap-spi.txt 
> b/Documentation/devicetree/bindings/spi/omap-spi.txt
> index 2ef0a6b..938809c 100644
> --- a/Documentation/devicetree/bindings/spi/omap-spi.txt
> +++ b/Documentation/devicetree/bindings/spi/omap-spi.txt
> @@ -6,9 +6,9 @@ Required properties:
>- "ti,omap4-spi" for OMAP4+.
>  - ti,spi-num-cs : Number of chipselect supported  by the instance.
>  - ti,hwmods: Name of the hwmod associated to the McSPI
> -- ti,pindir-d0-in-d1-out: Select the D0 pin as input and D1 as
> - output. The default is D0 as output and
> - D1 as input.
> +- ti,pindir-d0-out-d1-in: Select the D0 pin as output and D1 as
> + input. The default is D0 as input and
> + D1 as output.
>
>  Example:
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 5104633..89f73c4 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -766,7 +766,7 @@ static int omap2_mcspi_setup_transfer(struct spi_device 
> *spi,
> /* standard 4-wire master mode:  SCK, MOSI/out, MISO/in, nCS
>  * REVISIT: this controller could support SPI_3WIRE mode.
>  */
> -   if (mcspi->pin_dir == MCSPI_PINDIR_D0_OUT_D1_IN) {
> +   if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
> l &= ~OMAP2_MCSPI_CHCONF_IS;
> l &= ~OMAP2_MCSPI_CHCONF_DPE1;
> l |= OMAP2_MCSPI_CHCONF_DPE0;
> @@ -1188,8 +1188,8 @@ static int __devinit omap2_mcspi_probe(struct 
> platform_device *pdev)
> of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
> master->num_chipselect = num_cs;
> master->bus_num = bus_num++;
> -   if (of_get_property(node, "ti,pindir-d0-in-d1-out", NULL))
> -   mcspi->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT;
> +   if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL))
> +   mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
> } else {
> pdata = pdev->dev.platform_data;
> master->num_chipselect = pdata->num_cs;
> diff --git a/include/linux/platform_data/spi-omap2-mcspi.h 
> b/include/linux/platform_data/spi-omap2-mcspi.h
> index ce70f7b..a65572d 100644
> --- a/include/linux/platform_data/spi-omap2-mcspi.h
> +++ b/include/linux/platform_data/spi-omap2-mcspi.h
> @@ -7,8 +7,8 @@
>
>  #define OMAP4_MCSPI_REG_OFFSET 0x100
>
> -#define MCSPI_PINDIR_D0_OUT_D1_IN  0
> -#define MCSPI_PINDIR_D0_IN_D1_OUT  1
> +#define MCSPI_PINDIR_D0_IN_D1_OUT  0
> +#define MCSPI_PINDIR_D0_OUT_D1_IN  1
>
>  struct omap2_mcspi_platform_config {
> unsigned short  num_cs;
> --
> 1.7.11.7
>
>
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: Reorder the wait_for_completion for tx

2012-11-06 Thread Shubhrajyoti Datta
On Tue, Nov 6, 2012 at 2:52 PM, Mark Brown
 wrote:
> On Tue, Nov 06, 2012 at 02:47:27PM +0530, Shubhrajyoti D wrote:
>> The commit  d7b4394e[Cleanup the omap2_mcspi_txrx_dma function]
>> changed the wait_for_completion order. Move the wait so that the
>> rx doesnot wait for the tx to complete.
>
> Is this a resend of the patch I just applied, or is it something
> different?

No please ignore this one.

Something wrong at my end it got sent twice.
Please ignore.

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: Reorder the wait_for_completion for tx

2012-11-06 Thread Shubhrajyoti Datta
On Tue, Nov 6, 2012 at 2:33 PM, Mark Brown
 wrote:
> On Tue, Nov 06, 2012 at 02:30:19PM +0530, Shubhrajyoti D wrote:
>> The commit  d7b4394e[Cleanup the omap2_mcspi_txrx_dma function]
>> changed the wait_for_completion order. Move the wait so that the
>> rx doesnot wait for the tx to complete.
>
> Applied, thanks.

Thanks Mark,

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Reorder the wait_for_completion for tx

2012-11-06 Thread Shubhrajyoti D
The commit  d7b4394e[Cleanup the omap2_mcspi_txrx_dma function]
changed the wait_for_completion order. Move the wait so that the
rx doesnot wait for the tx to complete.

Reported-and-tested-by: Sørensen, Stefan 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   39 +++
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bcfd062..251f6d0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -323,18 +323,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   u8  * rx;
const u8* tx;
-   void __iomem*chstat_reg;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len;
 
-   rx = xfer->rx_buf;
tx = xfer->tx_buf;
-   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
 
if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
@@ -359,19 +354,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
dma_async_issue_pending(mcspi_dma->dma_tx);
omap2_mcspi_set_dma_req(spi, 0, 1);
 
-   wait_for_completion(&mcspi_dma->dma_tx_completion);
-   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
-DMA_TO_DEVICE);
-
-   /* for TX_ONLY mode, be sure all words have shifted out */
-   if (rx == NULL) {
-   if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_TXS) < 0)
-   dev_err(&spi->dev, "TXS timed out\n");
-   else if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_EOT) < 0)
-   dev_err(&spi->dev, "EOT timed out\n");
-   }
 }
 
 static unsigned
@@ -492,6 +474,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
struct dma_slave_config cfg;
enum dma_slave_buswidth width;
unsigned es;
+   void __iomem*chstat_reg;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
@@ -526,8 +509,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
omap2_mcspi_tx_dma(spi, xfer, cfg);
 
if (rx != NULL)
-   return omap2_mcspi_rx_dma(spi, xfer, cfg, es);
-
+   count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
+
+   if (tx != NULL) {
+   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+   }
return count;
 }
 
-- 
1.7.5.4


--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Reorder the wait_for_completion for tx

2012-11-06 Thread Shubhrajyoti D
The commit  d7b4394e[Cleanup the omap2_mcspi_txrx_dma function]
changed the wait_for_completion order. Move the wait so that the
rx doesnot wait for the tx to complete.

Reported-and-tested-by: Sørensen, Stefan 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   39 +++
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bcfd062..251f6d0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -323,18 +323,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   u8  * rx;
const u8* tx;
-   void __iomem*chstat_reg;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len;
 
-   rx = xfer->rx_buf;
tx = xfer->tx_buf;
-   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
 
if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
@@ -359,19 +354,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
dma_async_issue_pending(mcspi_dma->dma_tx);
omap2_mcspi_set_dma_req(spi, 0, 1);
 
-   wait_for_completion(&mcspi_dma->dma_tx_completion);
-   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
-DMA_TO_DEVICE);
-
-   /* for TX_ONLY mode, be sure all words have shifted out */
-   if (rx == NULL) {
-   if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_TXS) < 0)
-   dev_err(&spi->dev, "TXS timed out\n");
-   else if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_EOT) < 0)
-   dev_err(&spi->dev, "EOT timed out\n");
-   }
 }
 
 static unsigned
@@ -492,6 +474,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
struct dma_slave_config cfg;
enum dma_slave_buswidth width;
unsigned es;
+   void __iomem*chstat_reg;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
@@ -526,8 +509,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
omap2_mcspi_tx_dma(spi, xfer, cfg);
 
if (rx != NULL)
-   return omap2_mcspi_rx_dma(spi, xfer, cfg, es);
-
+   count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
+
+   if (tx != NULL) {
+   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+   }
return count;
 }
 
-- 
1.7.5.4


--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [REGRESSION] d7b4394e breaks bi-directional DMA transfers on omap2-mcspi

2012-11-05 Thread Shubhrajyoti Datta
On Wed, Oct 31, 2012 at 8:59 PM, Shubhrajyoti Datta
 wrote:
[...]

Mark,

let me know if you want me to resubmit it as a patch.

>
> From 07a59cb82955c37eff6fe06ba25958dc1b5c5f56 Mon Sep 17 00:00:00 2001
> From: Shubhrajyoti D 
> Date: Wed, 31 Oct 2012 19:15:25 +0530
> Subject: [PATCH] spi: omap2-mcspi: Reorder the wait_for_completion for tx
>
> The commit  d7b4394e[Cleanup the omap2_mcspi_txrx_dma function]
> changed the wait_for_completion order. Move the wait so that the
> rx doesnot wait for the tx to complete.
>
> Reported-by: Sørensen, Stefan 
> Signed-off-by: Shubhrajyoti D 
> ---
>  drivers/spi/spi-omap2-mcspi.c |   39 +++
>  1 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index bcfd062..251f6d0 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -323,18 +323,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
> struct omap2_mcspi  *mcspi;
> struct omap2_mcspi_dma  *mcspi_dma;
> unsigned intcount;
> -   u8  * rx;
> const u8* tx;
> -   void __iomem*chstat_reg;
> -   struct omap2_mcspi_cs   *cs = spi->controller_state;
>
> mcspi = spi_master_get_devdata(spi->master);
> mcspi_dma = &mcspi->dma_channels[spi->chip_select];
> count = xfer->len;
>
> -   rx = xfer->rx_buf;
> tx = xfer->tx_buf;
> -   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
>
> if (mcspi_dma->dma_tx) {
> struct dma_async_tx_descriptor *tx;
> @@ -359,19 +354,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
> dma_async_issue_pending(mcspi_dma->dma_tx);
> omap2_mcspi_set_dma_req(spi, 0, 1);
>
> -   wait_for_completion(&mcspi_dma->dma_tx_completion);
> -   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
> -DMA_TO_DEVICE);
> -
> -   /* for TX_ONLY mode, be sure all words have shifted out */
> -   if (rx == NULL) {
> -   if (mcspi_wait_for_reg_bit(chstat_reg,
> -   OMAP2_MCSPI_CHSTAT_TXS) < 0)
> -   dev_err(&spi->dev, "TXS timed out\n");
> -   else if (mcspi_wait_for_reg_bit(chstat_reg,
> -   OMAP2_MCSPI_CHSTAT_EOT) < 0)
> -   dev_err(&spi->dev, "EOT timed out\n");
> -   }
>  }
>
>  static unsigned
> @@ -492,6 +474,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi,
> struct spi_transfer *xfer)
> struct dma_slave_config cfg;
> enum dma_slave_buswidth width;
> unsigned es;
> +   void __iomem*chstat_reg;
>
> mcspi = spi_master_get_devdata(spi->master);
> mcspi_dma = &mcspi->dma_channels[spi->chip_select];
> @@ -526,8 +509,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi,
> struct spi_transfer *xfer)
> omap2_mcspi_tx_dma(spi, xfer, cfg);
>
> if (rx != NULL)
> -   return omap2_mcspi_rx_dma(spi, xfer, cfg, es);
> -
> +   count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
> +
> +   if (tx != NULL) {
> +   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
> +   wait_for_completion(&mcspi_dma->dma_tx_completion);
> +   dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len,
> +DMA_TO_DEVICE);
> +
> +   /* for TX_ONLY mode, be sure all words have shifted out */
> +   if (rx == NULL) {
> +   if (mcspi_wait_for_reg_bit(chstat_reg,
> +   OMAP2_MCSPI_CHSTAT_TXS) < 0)
> +   dev_err(&spi->dev, "TXS timed out\n");
> +   else if (mcspi_wait_for_reg_bit(chstat_reg,
> +   OMAP2_MCSPI_CHSTAT_EOT) < 0)
> +   dev_err(&spi->dev, "EOT timed out\n");
> +   }
> +   }
> return count;
>  }
>
> --
> 1.7.5.4

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [REGRESSION] d7b4394e breaks bi-directional DMA transfers on omap2-mcspi

2012-10-31 Thread Shubhrajyoti Datta
On Wed, Oct 31, 2012 at 7:27 PM, Shubhrajyoti Datta
 wrote:
> On Wed, Oct 31, 2012 at 5:46 PM, Sørensen, Stefan
[...]
>
> Will test and get back with a proper patch.

Let me know if this solves.

>From 07a59cb82955c37eff6fe06ba25958dc1b5c5f56 Mon Sep 17 00:00:00 2001
From: Shubhrajyoti D 
Date: Wed, 31 Oct 2012 19:15:25 +0530
Subject: [PATCH] spi: omap2-mcspi: Reorder the wait_for_completion for tx

The commit  d7b4394e[Cleanup the omap2_mcspi_txrx_dma function]
changed the wait_for_completion order. Move the wait so that the
rx doesnot wait for the tx to complete.

Reported-by: Sørensen, Stefan 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   39 +++
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bcfd062..251f6d0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -323,18 +323,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   u8  * rx;
const u8* tx;
-   void __iomem*chstat_reg;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;

mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len;

-   rx = xfer->rx_buf;
tx = xfer->tx_buf;
-   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;

if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
@@ -359,19 +354,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
dma_async_issue_pending(mcspi_dma->dma_tx);
omap2_mcspi_set_dma_req(spi, 0, 1);

-   wait_for_completion(&mcspi_dma->dma_tx_completion);
-   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
-DMA_TO_DEVICE);
-
-   /* for TX_ONLY mode, be sure all words have shifted out */
-   if (rx == NULL) {
-   if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_TXS) < 0)
-   dev_err(&spi->dev, "TXS timed out\n");
-   else if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_EOT) < 0)
-   dev_err(&spi->dev, "EOT timed out\n");
-   }
 }

 static unsigned
@@ -492,6 +474,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi,
struct spi_transfer *xfer)
struct dma_slave_config cfg;
enum dma_slave_buswidth width;
unsigned es;
+   void __iomem*chstat_reg;

mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
@@ -526,8 +509,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi,
struct spi_transfer *xfer)
omap2_mcspi_tx_dma(spi, xfer, cfg);

if (rx != NULL)
-   return omap2_mcspi_rx_dma(spi, xfer, cfg, es);
-
+   count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
+
+   if (tx != NULL) {
+   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+   }
return count;
 }

-- 
1.7.5.4

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [REGRESSION] d7b4394e breaks bi-directional DMA transfers on omap2-mcspi

2012-10-31 Thread Shubhrajyoti Datta
On Wed, Oct 31, 2012 at 5:46 PM, Sørensen, Stefan
 wrote:
> Bi-directional SPI transfers using DMA no longer works on omap2-mcspi after
> this commit:
My bad.

>
> commit d7b4394e780b02511c8a7a499380cdd56316c770
> Author: Shubhrajyoti D 
> Date:   Tue Sep 11 12:13:20 2012 +0530
>
> spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function
>
> Currently in omap2_mcspi_txrx_dma the tx and the rx support is
> interleaved. Make the rx related code in omap2_mcspi_rx_dma
> and the tx related code omap2_mcspi_tx_dma and call the functions.
>
> While at it remove the braces in the if statements which has only
> one line.
> Also fix ["foo * bar" to "foo *bar"] warn for the rx and tx variables.
>
>     Only a cleanup no functional change.
>
> Signed-off-by: Shubhrajyoti D 
> Tested-by: Felipe Balbi 
> Signed-off-by: Mark Brown 
>
>
> Basically the patch changes the pattern
> start_tx();
> start_rx();
> wait_for_completion(tx);
> wait_for_completion(tx);
> into
> start_tx();
> wait_for_completion(tx);
> start_rx();
> wait_for_completion(tx);
> which will stall the transfer since the rx channel is not serviced.

So moving the tx completion.

Apologies for breaking in the original commit.


Will test and get back with a proper patch.
---
 drivers/spi/spi-omap2-mcspi.c |   34 --
 1 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 3542fdc..e8e5bbc 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -323,18 +323,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   u8  * rx;
const u8* tx;
-   void __iomem*chstat_reg;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;

mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len;

-   rx = xfer->rx_buf;
tx = xfer->tx_buf;
-   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;

if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
@@ -359,19 +354,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
dma_async_issue_pending(mcspi_dma->dma_tx);
omap2_mcspi_set_dma_req(spi, 0, 1);

-   wait_for_completion(&mcspi_dma->dma_tx_completion);
-   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
-DMA_TO_DEVICE);
-
-   /* for TX_ONLY mode, be sure all words have shifted out */
-   if (rx == NULL) {
-   if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_TXS) < 0)
-   dev_err(&spi->dev, "TXS timed out\n");
-   else if (mcspi_wait_for_reg_bit(chstat_reg,
-   OMAP2_MCSPI_CHSTAT_EOT) < 0)
-   dev_err(&spi->dev, "EOT timed out\n");
-   }
 }

 static unsigned
@@ -492,6 +474,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi,
struct spi_transfer *xfer)
struct dma_slave_config cfg;
enum dma_slave_buswidth width;
unsigned es;
+   void __iomem*chstat_reg;

mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
@@ -528,6 +511,21 @@ omap2_mcspi_txrx_dma(struct spi_device *spi,
struct spi_transfer *xfer)
if (rx != NULL)
return omap2_mcspi_rx_dma(spi, xfer, cfg, es);

+   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+
return count;
 }

-- 
1.7.5.4

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [REPOST PATCH v2 1/2] spi: omap2-mcspi: add pinctrl support

2012-09-18 Thread Shubhrajyoti
On Tuesday 18 September 2012 05:31 PM, Matt Porter wrote:
> Adds pinctrl support to support OMAP platforms that boot from DT
> and rely on pinctrl support to set pinmuxes.
looks good

Acked-by: Shubhrajyoti D 


> Signed-off-by: Matt Porter 
> ---
>  drivers/spi/spi-omap2-mcspi.c |8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index b2fb141..9502566 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -38,6 +38,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #include 
>  
> @@ -1124,6 +1126,7 @@ static int __devinit omap2_mcspi_probe(struct 
> platform_device *pdev)
>   static int  bus_num = 1;
>   struct device_node  *node = pdev->dev.of_node;
>   const struct of_device_id *match;
> + struct pinctrl *pinctrl;
>  
>   master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
>   if (master == NULL) {
> @@ -1219,6 +1222,11 @@ static int __devinit omap2_mcspi_probe(struct 
> platform_device *pdev)
>   if (status < 0)
>   goto dma_chnl_free;
>  
> + pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> + if (IS_ERR(pinctrl))
> + dev_warn(&pdev->dev,
> + "pins are not configured from the driver\n");
> +
>   pm_runtime_use_autosuspend(&pdev->dev);
>   pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
>   pm_runtime_enable(&pdev->dev);


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH v2 1/2] spi: omap2-mcspi: add pinctrl support

2012-09-17 Thread Shubhrajyoti
On Monday 17 September 2012 10:52 PM, Matt Porter wrote:
> Adds pinctrl support to support OMAP platforms that boot from DT
> and rely on pinctrl support to set pinmuxes.
>
> Signed-off-by: Matt Porter 
> ---
looks good to me.
you may want to repost with Mark in cc to review.
Acked-by: Shubhrajyoti D 

>  drivers/spi/spi-omap2-mcspi.c |8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index b2fb141..9502566 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -38,6 +38,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #include 
>  
> @@ -1124,6 +1126,7 @@ static int __devinit omap2_mcspi_probe(struct 
> platform_device *pdev)
>   static int  bus_num = 1;
>   struct device_node  *node = pdev->dev.of_node;
>   const struct of_device_id *match;
> + struct pinctrl *pinctrl;
>  
>   master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
>   if (master == NULL) {
> @@ -1219,6 +1222,11 @@ static int __devinit omap2_mcspi_probe(struct 
> platform_device *pdev)
>   if (status < 0)
>   goto dma_chnl_free;
>  
> + pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> + if (IS_ERR(pinctrl))
> + dev_warn(&pdev->dev,
> + "pins are not configured from the driver\n");
> +
>   pm_runtime_use_autosuspend(&pdev->dev);
>   pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
>   pm_runtime_enable(&pdev->dev);


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function

2012-09-12 Thread Shubhrajyoti
On Wednesday 12 September 2012 07:09 PM, Felipe Balbi wrote:
> seems to be working fine (at least from my quick tests)
>
> Tested-by: Felipe Balbi 
Thanks Felipe.

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function

2012-09-11 Thread Shubhrajyoti
On Wednesday 12 September 2012 08:51 AM, Mark Brown wrote:
> On Tue, Sep 11, 2012 at 12:13:20PM +0530, Shubhrajyoti D wrote:
>> > Currently in omap2_mcspi_txrx_dma the tx and the rx support is
>> > interleaved. Make the rx related code in omap2_mcspi_rx_dma
>> > and the tx related code omap2_mcspi_tx_dma and call the functions.
> I'd ideally like some testing from the OMAP side before applying this -
> is there someone who can give a Tested-by?
I have tested this patch with nfs boot with ethernet being on spi on
omap4sdp and spidev.
On omap3 sdp tested the touchscreen.

However can wait for some tested-bys :-)

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] SPI: OMAP: remove unnecessary includes of plat/clock.h

2012-09-11 Thread Shubhrajyoti
On Wednesday 12 September 2012 05:01 AM, Paul Walmsley wrote:
> Remove unnecessary includes of plat/clock.h from the OMAP SPI
> controller drivers.  These need to be removed to build multi-subarch
> ARM kernels which include these drivers.
Looks good to me
Acked-by: Shubhrajyoti D 
>
> Signed-off-by: Paul Walmsley 
> Cc: Grant Likely 
> ---
>  drivers/spi/spi-omap-100k.c   |2 --
>  drivers/spi/spi-omap2-mcspi.c |1 -
>  2 files changed, 3 deletions(-)
>
> diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
> index 9bd1c92..dfb4b7f 100644
> --- a/drivers/spi/spi-omap-100k.c
> +++ b/drivers/spi/spi-omap-100k.c
> @@ -37,8 +37,6 @@
>  
>  #include 
>  
> -#include 
> -
>  #define OMAP1_SPI100K_MAX_FREQ  4800
>  
>  #define ICR_SPITAS  (OMAP7XX_ICR_BASE + 0x12)
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index b2fb141..b5d6994 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -41,7 +41,6 @@
>  
>  #include 
>  
> -#include 
>  #include 
>  
>  #define OMAP2_MCSPI_MAX_FREQ 4800


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function

2012-09-10 Thread Shubhrajyoti D
Currently in omap2_mcspi_txrx_dma the tx and the rx support is
interleaved. Make the rx related code in omap2_mcspi_rx_dma
and the tx related code omap2_mcspi_tx_dma and call the functions.

While at it remove the braces in the if statements which has only
one line.
Also fix ["foo * bar" to "foo *bar"] warn for the rx and tx variables.

Only a cleanup no functional change.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |  256 +++--
 1 files changed, 144 insertions(+), 112 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1c1dd34..dd8fc88 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -315,49 +315,27 @@ static void omap2_mcspi_tx_callback(void *data)
omap2_mcspi_set_dma_req(spi, 0, 0);
 }
 
-static unsigned
-omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
+static void omap2_mcspi_tx_dma(struct spi_device *spi,
+   struct spi_transfer *xfer,
+   struct dma_slave_config cfg)
 {
struct omap2_mcspi  *mcspi;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   int word_len, element_count;
-   int elements = 0;
-   u32 l;
u8  * rx;
const u8* tx;
void __iomem*chstat_reg;
-   struct dma_slave_config cfg;
-   enum dma_slave_buswidth width;
-   unsigned es;
+   struct omap2_mcspi_cs   *cs = spi->controller_state;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
-   l = mcspi_cached_chconf0(spi);
+   count = xfer->len;
 
+   rx = xfer->rx_buf;
+   tx = xfer->tx_buf;
chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
 
-   if (cs->word_len <= 8) {
-   width = DMA_SLAVE_BUSWIDTH_1_BYTE;
-   es = 1;
-   } else if (cs->word_len <= 16) {
-   width = DMA_SLAVE_BUSWIDTH_2_BYTES;
-   es = 2;
-   } else {
-   width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-   es = 4;
-   }
-
-   memset(&cfg, 0, sizeof(cfg));
-   cfg.src_addr = cs->phys + OMAP2_MCSPI_RX0;
-   cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
-   cfg.src_addr_width = width;
-   cfg.dst_addr_width = width;
-   cfg.src_maxburst = 1;
-   cfg.dst_maxburst = 1;
-
-   if (xfer->tx_buf && mcspi_dma->dma_tx) {
+   if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
struct scatterlist sg;
 
@@ -368,7 +346,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
sg_dma_len(&sg) = xfer->len;
 
tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
-   DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+   DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (tx) {
tx->callback = omap2_mcspi_tx_callback;
tx->callback_param = spi;
@@ -377,8 +355,50 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
/* FIXME: fall back to PIO? */
}
}
+   dma_async_issue_pending(mcspi_dma->dma_tx);
+   omap2_mcspi_set_dma_req(spi, 0, 1);
 
-   if (xfer->rx_buf && mcspi_dma->dma_rx) {
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+}
+
+static unsigned
+omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
+   struct dma_slave_config cfg,
+   unsigned es)
+{
+   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi_dma  *mcspi_dma;
+   unsigned intcount;
+   u32 l;
+   int elements = 0;
+   int word_len, element_count;
+   struct omap2_mcspi_cs   *cs = spi->controller_state;
+   mcspi = spi_master_get_devdata(sp

Re: [PATCH] spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function

2012-09-03 Thread Shubhrajyoti
On Monday 03 September 2012 07:32 PM, Shubhrajyoti D wrote:
> Currently in omap2_mcspi_txrx_dma has the rx 
I meant tx here will resend. please ignore this patch

> and the rx support
> interleaved. Make the rx related code in omap2_mcspi_rx_dma
> and the tx related code omap2_mcspi_tx_dma and call functions.
>
> While at it also remove the braces in the if statements which has only
> one line.
> Also fix ["foo * bar" to "foo *bar"] warn for the rx and tx variables.
>
> Only a cleanup no functional change.
>
> Signed-off-by: Shubhrajyoti D 
> ---
>  drivers/spi/spi-omap2-mcspi.c |  256 
> +++--
>  1 files changed, 144 insertions(+), 112 deletions(-)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 1c1dd34..dd8fc88 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -315,49 +315,27 @@ static void omap2_mcspi_tx_callback(void *data)
>   omap2_mcspi_set_dma_req(spi, 0, 0);
>  }
>  
> -static unsigned
> -omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
> +static void omap2_mcspi_tx_dma(struct spi_device *spi,
> + struct spi_transfer *xfer,
> + struct dma_slave_config cfg)
>  {
>   struct omap2_mcspi  *mcspi;
> - struct omap2_mcspi_cs   *cs = spi->controller_state;
>   struct omap2_mcspi_dma  *mcspi_dma;
>   unsigned intcount;
> - int word_len, element_count;
> - int elements = 0;
> - u32 l;
>   u8  * rx;
>   const u8* tx;
>   void __iomem*chstat_reg;
> - struct dma_slave_config cfg;
> - enum dma_slave_buswidth width;
> - unsigned es;
> + struct omap2_mcspi_cs   *cs = spi->controller_state;
>  
>   mcspi = spi_master_get_devdata(spi->master);
>   mcspi_dma = &mcspi->dma_channels[spi->chip_select];
> - l = mcspi_cached_chconf0(spi);
> + count = xfer->len;
>  
> + rx = xfer->rx_buf;
> + tx = xfer->tx_buf;
>   chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
>  
> - if (cs->word_len <= 8) {
> - width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> - es = 1;
> - } else if (cs->word_len <= 16) {
> - width = DMA_SLAVE_BUSWIDTH_2_BYTES;
> - es = 2;
> - } else {
> - width = DMA_SLAVE_BUSWIDTH_4_BYTES;
> - es = 4;
> - }
> -
> - memset(&cfg, 0, sizeof(cfg));
> - cfg.src_addr = cs->phys + OMAP2_MCSPI_RX0;
> - cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
> - cfg.src_addr_width = width;
> - cfg.dst_addr_width = width;
> - cfg.src_maxburst = 1;
> - cfg.dst_maxburst = 1;
> -
> - if (xfer->tx_buf && mcspi_dma->dma_tx) {
> + if (mcspi_dma->dma_tx) {
>   struct dma_async_tx_descriptor *tx;
>   struct scatterlist sg;
>  
> @@ -368,7 +346,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
> spi_transfer *xfer)
>   sg_dma_len(&sg) = xfer->len;
>  
>   tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
> - DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> + DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>   if (tx) {
>   tx->callback = omap2_mcspi_tx_callback;
>   tx->callback_param = spi;
> @@ -377,8 +355,50 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
> spi_transfer *xfer)
>   /* FIXME: fall back to PIO? */
>   }
>   }
> + dma_async_issue_pending(mcspi_dma->dma_tx);
> + omap2_mcspi_set_dma_req(spi, 0, 1);
>  
> - if (xfer->rx_buf && mcspi_dma->dma_rx) {
> + wait_for_completion(&mcspi_dma->dma_tx_completion);
> + dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
> +  DMA_TO_DEVICE);
> +
> + /* for TX_ONLY mode, be sure all words have shifted out */
> + if (rx == NULL) {
> + if (mcspi_wait_for_reg_bit(chstat_reg,
> + OMAP2_MCSPI_CHSTAT_TXS) < 0)
> + dev_err(&spi->dev, "TXS timed out\n");
> + else if (mcspi_wait_for_reg_bit(chstat_reg,
> + OMAP2_MCSPI_CHSTAT_EOT) < 0)
> + dev_err(&spi->dev, "EOT timed out\n");
> + }
> +}
> +
> +static unsign

[PATCH] spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function

2012-09-03 Thread Shubhrajyoti D
Currently in omap2_mcspi_txrx_dma the tx and the rx support is
interleaved. Make the rx related code in omap2_mcspi_rx_dma
and the tx related code omap2_mcspi_tx_dma and call the functions.

While at it remove the braces in the if statements which has only
one line.
Also fix ["foo * bar" to "foo *bar"] warn for the rx and tx variables.

Only a cleanup no functional change.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |  256 +++--
 1 files changed, 144 insertions(+), 112 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1c1dd34..dd8fc88 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -315,49 +315,27 @@ static void omap2_mcspi_tx_callback(void *data)
omap2_mcspi_set_dma_req(spi, 0, 0);
 }
 
-static unsigned
-omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
+static void omap2_mcspi_tx_dma(struct spi_device *spi,
+   struct spi_transfer *xfer,
+   struct dma_slave_config cfg)
 {
struct omap2_mcspi  *mcspi;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   int word_len, element_count;
-   int elements = 0;
-   u32 l;
u8  * rx;
const u8* tx;
void __iomem*chstat_reg;
-   struct dma_slave_config cfg;
-   enum dma_slave_buswidth width;
-   unsigned es;
+   struct omap2_mcspi_cs   *cs = spi->controller_state;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
-   l = mcspi_cached_chconf0(spi);
+   count = xfer->len;
 
+   rx = xfer->rx_buf;
+   tx = xfer->tx_buf;
chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
 
-   if (cs->word_len <= 8) {
-   width = DMA_SLAVE_BUSWIDTH_1_BYTE;
-   es = 1;
-   } else if (cs->word_len <= 16) {
-   width = DMA_SLAVE_BUSWIDTH_2_BYTES;
-   es = 2;
-   } else {
-   width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-   es = 4;
-   }
-
-   memset(&cfg, 0, sizeof(cfg));
-   cfg.src_addr = cs->phys + OMAP2_MCSPI_RX0;
-   cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
-   cfg.src_addr_width = width;
-   cfg.dst_addr_width = width;
-   cfg.src_maxburst = 1;
-   cfg.dst_maxburst = 1;
-
-   if (xfer->tx_buf && mcspi_dma->dma_tx) {
+   if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
struct scatterlist sg;
 
@@ -368,7 +346,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
sg_dma_len(&sg) = xfer->len;
 
tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
-   DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+   DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (tx) {
tx->callback = omap2_mcspi_tx_callback;
tx->callback_param = spi;
@@ -377,8 +355,50 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
/* FIXME: fall back to PIO? */
}
}
+   dma_async_issue_pending(mcspi_dma->dma_tx);
+   omap2_mcspi_set_dma_req(spi, 0, 1);
 
-   if (xfer->rx_buf && mcspi_dma->dma_rx) {
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+}
+
+static unsigned
+omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
+   struct dma_slave_config cfg,
+   unsigned es)
+{
+   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi_dma  *mcspi_dma;
+   unsigned intcount;
+   u32 l;
+   int elements = 0;
+   int word_len, element_count;
+   struct omap2_mcspi_cs   *cs = spi->controller_state;
+   mcspi = spi_master_get_devdata(sp

[PATCH] spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function

2012-09-03 Thread Shubhrajyoti D
Currently in omap2_mcspi_txrx_dma has the rx and the rx support
interleaved. Make the rx related code in omap2_mcspi_rx_dma
and the tx related code omap2_mcspi_tx_dma and call functions.

While at it also remove the braces in the if statements which has only
one line.
Also fix ["foo * bar" to "foo *bar"] warn for the rx and tx variables.

Only a cleanup no functional change.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |  256 +++--
 1 files changed, 144 insertions(+), 112 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1c1dd34..dd8fc88 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -315,49 +315,27 @@ static void omap2_mcspi_tx_callback(void *data)
omap2_mcspi_set_dma_req(spi, 0, 0);
 }
 
-static unsigned
-omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
+static void omap2_mcspi_tx_dma(struct spi_device *spi,
+   struct spi_transfer *xfer,
+   struct dma_slave_config cfg)
 {
struct omap2_mcspi  *mcspi;
-   struct omap2_mcspi_cs   *cs = spi->controller_state;
struct omap2_mcspi_dma  *mcspi_dma;
unsigned intcount;
-   int word_len, element_count;
-   int elements = 0;
-   u32 l;
u8  * rx;
const u8* tx;
void __iomem*chstat_reg;
-   struct dma_slave_config cfg;
-   enum dma_slave_buswidth width;
-   unsigned es;
+   struct omap2_mcspi_cs   *cs = spi->controller_state;
 
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
-   l = mcspi_cached_chconf0(spi);
+   count = xfer->len;
 
+   rx = xfer->rx_buf;
+   tx = xfer->tx_buf;
chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
 
-   if (cs->word_len <= 8) {
-   width = DMA_SLAVE_BUSWIDTH_1_BYTE;
-   es = 1;
-   } else if (cs->word_len <= 16) {
-   width = DMA_SLAVE_BUSWIDTH_2_BYTES;
-   es = 2;
-   } else {
-   width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-   es = 4;
-   }
-
-   memset(&cfg, 0, sizeof(cfg));
-   cfg.src_addr = cs->phys + OMAP2_MCSPI_RX0;
-   cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
-   cfg.src_addr_width = width;
-   cfg.dst_addr_width = width;
-   cfg.src_maxburst = 1;
-   cfg.dst_maxburst = 1;
-
-   if (xfer->tx_buf && mcspi_dma->dma_tx) {
+   if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
struct scatterlist sg;
 
@@ -368,7 +346,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
sg_dma_len(&sg) = xfer->len;
 
tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
-   DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+   DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (tx) {
tx->callback = omap2_mcspi_tx_callback;
tx->callback_param = spi;
@@ -377,8 +355,50 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
/* FIXME: fall back to PIO? */
}
}
+   dma_async_issue_pending(mcspi_dma->dma_tx);
+   omap2_mcspi_set_dma_req(spi, 0, 1);
 
-   if (xfer->rx_buf && mcspi_dma->dma_rx) {
+   wait_for_completion(&mcspi_dma->dma_tx_completion);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
+DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS) < 0)
+   dev_err(&spi->dev, "TXS timed out\n");
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT) < 0)
+   dev_err(&spi->dev, "EOT timed out\n");
+   }
+}
+
+static unsigned
+omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
+   struct dma_slave_config cfg,
+   unsigned es)
+{
+   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi_dma  *mcspi_dma;
+   unsigned intcount;
+   u32 l;
+   int elements = 0;
+   int word_len, element_count;
+   struct omap2_mcspi_cs   *cs = spi->controller_state;
+   mcspi = spi_master_get_devdata(sp

Re: [PATCHv2 0/3] spi: omap2-mcspi: spi cleanups

2012-08-22 Thread Shubhrajyoti Datta
On Wed, Aug 22, 2012 at 10:29 PM, Mark Brown
 wrote:
> On Wed, Aug 22, 2012 at 11:35:11AM +0530, Shubhrajyoti D wrote:
>> This patch does the following
>>
>> Calls the pm_runtime_* functions directly.
>> Remove the MOD_REG_BIT macro usage thereby removiing un-needed branch.
>> At remove dont use the autosuspend runtime calls.
>
> Applied all, thanks.

thanks.

>
>> The following changes since commit 23dcfa61bac244e1200ff9ad19c6e9144dcb6bb5:
>>
>>   Merge branch 'akpm' (Andrew's patch-bomb) (2012-08-21 17:22:22 -0700)
>
> When sending pull requests please always base them off a tag of some
> kind, normally one of Linus' is a good option if you've no special
> needs.  This one looks like it's based off -next so can't be pulled into
> any other tree, -next is rebased daily.

Actually there was a patch in your tree that I sent which is not yet
in linus tree so I rebased
it to linux-next to avoid any merge conflicts.

Henceforth I will rebase it to your tree.

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv2 1/3] spi: omap2-mcspi: Call pm_runtime_* functions directly

2012-08-21 Thread Shubhrajyoti D
Call the pm_runtime functions directly making room for possible
pm optimisations. Also the runtime functions aren't just about
enabling and disabling of clocks though it does enable clocks also.

Acked-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   28 +++-
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index b2fb141..f542f3d 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -260,16 +260,6 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi 
*mcspi)
list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
-static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
-{
-   pm_runtime_mark_last_busy(mcspi->dev);
-   pm_runtime_put_autosuspend(mcspi->dev);
-}
-
-static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
-{
-   return pm_runtime_get_sync(mcspi->dev);
-}
 
 static int omap2_prepare_transfer(struct spi_master *master)
 {
@@ -848,12 +838,13 @@ static int omap2_mcspi_setup(struct spi_device *spi)
return ret;
}
 
-   ret = omap2_mcspi_enable_clocks(mcspi);
+   ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;
 
ret = omap2_mcspi_setup_transfer(spi, NULL);
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
 
return ret;
 }
@@ -1067,7 +1058,7 @@ static int __devinit omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
int ret = 0;
 
-   ret = omap2_mcspi_enable_clocks(mcspi);
+   ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;
 
@@ -1076,7 +1067,8 @@ static int __devinit omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
 
omap2_mcspi_set_master_mode(master);
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
return 0;
 }
 
@@ -1252,7 +1244,8 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
mcspi = spi_master_get_devdata(master);
dma_channels = mcspi->dma_channels;
 
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
pm_runtime_disable(&pdev->dev);
 
spi_unregister_master(master);
@@ -1278,7 +1271,7 @@ static int omap2_mcspi_resume(struct device *dev)
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_cs   *cs;
 
-   omap2_mcspi_enable_clocks(mcspi);
+   pm_runtime_get_sync(mcspi->dev);
list_for_each_entry(cs, &ctx->cs, node) {
if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) {
/*
@@ -1291,7 +1284,8 @@ static int omap2_mcspi_resume(struct device *dev)
__raw_writel(cs->chconf0, cs->base + 
OMAP2_MCSPI_CHCONF0);
}
}
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
return 0;
 }
 #else
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv2 3/3] spi: omap2-mcspi: At remove dont use the runtime_autosuspend calls

2012-08-21 Thread Shubhrajyoti D
At remove we shouldnt be using the autosuspend timeout as we are
calling pm_runtime_disable immediately after.

Acked-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 8a5e2c0..1c1dd34 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1244,8 +1244,7 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
mcspi = spi_master_get_devdata(master);
dma_channels = mcspi->dma_channels;
 
-   pm_runtime_mark_last_busy(mcspi->dev);
-   pm_runtime_put_autosuspend(mcspi->dev);
+   pm_runtime_put_sync(mcspi->dev);
pm_runtime_disable(&pdev->dev);
 
spi_unregister_master(master);
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv2 2/3] spi: omap2-mcspi: Remove the macro MOD_REG_BIT

2012-08-21 Thread Shubhrajyoti D
Remove the macro MOD_REG_BIT instead make the bit field modifications
directly. This deletes a branch operation in cases where the the set
is predecided. While at it optimise two sequential bit clear in one step.

Acked-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index f542f3d..8a5e2c0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -140,13 +140,6 @@ struct omap2_mcspi_cs {
u32 chconf0;
 };
 
-#define MOD_REG_BIT(val, mask, set) do { \
-   if (set) \
-   val |= mask; \
-   else \
-   val &= ~mask; \
-} while (0)
-
 static inline void mcspi_write_reg(struct spi_master *master,
int idx, u32 val)
 {
@@ -205,7 +198,11 @@ static void omap2_mcspi_set_dma_req(const struct 
spi_device *spi,
else
rw = OMAP2_MCSPI_CHCONF_DMAW;
 
-   MOD_REG_BIT(l, rw, enable);
+   if (enable)
+   l |= rw;
+   else
+   l &= ~rw;
+
mcspi_write_chconf0(spi, l);
 }
 
@@ -224,7 +221,11 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
u32 l;
 
l = mcspi_cached_chconf0(spi);
-   MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
+   if (cs_active)
+   l |= OMAP2_MCSPI_CHCONF_FORCE;
+   else
+   l &= ~OMAP2_MCSPI_CHCONF_FORCE;
+
mcspi_write_chconf0(spi, l);
 }
 
@@ -239,9 +240,8 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
 * to single-channel master mode
 */
l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
-   MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_STEST, 0);
-   MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_MS, 0);
-   MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
+   l &= ~(OMAP2_MCSPI_MODULCTRL_STEST | OMAP2_MCSPI_MODULCTRL_MS);
+   l |= OMAP2_MCSPI_MODULCTRL_SINGLE;
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
ctx->modulctrl = l;
@@ -1278,9 +1278,9 @@ static int omap2_mcspi_resume(struct device *dev)
 * We need to toggle CS state for OMAP take this
 * change in account.
 */
-   MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 1);
+   cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE;
__raw_writel(cs->chconf0, cs->base + 
OMAP2_MCSPI_CHCONF0);
-   MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 0);
+   cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
__raw_writel(cs->chconf0, cs->base + 
OMAP2_MCSPI_CHCONF0);
}
}
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv2 0/3] spi: omap2-mcspi: spi cleanups

2012-08-21 Thread Shubhrajyoti D
This patch does the following

Calls the pm_runtime_* functions directly.
Remove the MOD_REG_BIT macro usage thereby removiing un-needed branch.
At remove dont use the autosuspend runtime calls.

Changes from v1:
Fix the comments on changelogs.
Add acks to the patches.

The following changes since commit 23dcfa61bac244e1200ff9ad19c6e9144dcb6bb5:

  Merge branch 'akpm' (Andrew's patch-bomb) (2012-08-21 17:22:22 -0700)

are available in the git repository at:

  git://gitorious.org/linus-tree/linus-tree.git for_3.6/spi




Shubhrajyoti D (3):
  spi: omap2-mcspi: Call pm_runtime_* functions directly
  spi: omap2-mcspi: Remove the macro MOD_REG_BIT
  spi: omap2-mcspi: At remove dont use the runtime_autosuspend calls

 drivers/spi/spi-omap2-mcspi.c |   55 ++---
 1 files changed, 24 insertions(+), 31 deletions(-)

-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 2/3] spi: omap2-mcspi: Remove the macro MOD_REG_BIT

2012-08-21 Thread Shubhrajyoti
Hi Felipe,
Thanks for the review

On Tuesday 21 August 2012 02:35 PM, Felipe Balbi wrote:
> On Tue, Aug 21, 2012 at 11:47:43AM +0530, Shubhrajyoti D wrote:
>> Remove the macro MOD_REG_BIT instead make the bit field modifications
>> directly. This deletes a branch operation in cases where the the set
>> is predecided.While at it optimise two sequential bit clear in one step.
>^^
>  you need a space here, besides you can add the ack below
Will fix that and resend.
>> Signed-off-by: Shubhrajyoti D 
> Acked-by: Felipe Balbi 
>
>> ---
>>  drivers/spi/spi-omap2-mcspi.c |   28 ++--
>>  1 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
>> index dd887eb..5642111 100644
>> --- a/drivers/spi/spi-omap2-mcspi.c
>> +++ b/drivers/spi/spi-omap2-mcspi.c
>> @@ -140,13 +140,6 @@ struct omap2_mcspi_cs {
>>  u32 chconf0;
>>  };
>>  
>> -#define MOD_REG_BIT(val, mask, set) do { \
>> -if (set) \
>> -val |= mask; \
>> -else \
>> -val &= ~mask; \
>> -} while (0)
>> -
>>  static inline void mcspi_write_reg(struct spi_master *master,
>>  int idx, u32 val)
>>  {
>> @@ -205,7 +198,11 @@ static void omap2_mcspi_set_dma_req(const struct 
>> spi_device *spi,
>>  else
>>  rw = OMAP2_MCSPI_CHCONF_DMAW;
>>  
>> -MOD_REG_BIT(l, rw, enable);
>> +if (enable)
>> +l |= rw;
>> +else
>> +l &= ~rw;
>> +
>>  mcspi_write_chconf0(spi, l);
>>  }
>>  
>> @@ -224,7 +221,11 @@ static void omap2_mcspi_force_cs(struct spi_device 
>> *spi, int cs_active)
>>  u32 l;
>>  
>>  l = mcspi_cached_chconf0(spi);
>> -MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
>> +if (cs_active)
>> +l |= OMAP2_MCSPI_CHCONF_FORCE;
>> +else
>> +l &= ~OMAP2_MCSPI_CHCONF_FORCE;
>> +
>>  mcspi_write_chconf0(spi, l);
>>  }
>>  
>> @@ -239,9 +240,8 @@ static void omap2_mcspi_set_master_mode(struct 
>> spi_master *master)
>>   * to single-channel master mode
>>   */
>>  l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
>> -MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_STEST, 0);
>> -MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_MS, 0);
>> -MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
>> +l &= ~(OMAP2_MCSPI_MODULCTRL_STEST | OMAP2_MCSPI_MODULCTRL_MS);
>> +l |= OMAP2_MCSPI_MODULCTRL_SINGLE;
>>  mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
>>  
>>  ctx->modulctrl = l;
>> @@ -1276,9 +1276,9 @@ static int omap2_mcspi_resume(struct device *dev)
>>   * We need to toggle CS state for OMAP take this
>>   * change in account.
>>   */
>> -MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 1);
>> +cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE;
>>  __raw_writel(cs->chconf0, cs->base + 
>> OMAP2_MCSPI_CHCONF0);
>> -MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 0);
>> +cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
>>  __raw_writel(cs->chconf0, cs->base + 
>> OMAP2_MCSPI_CHCONF0);
>>  }
>>  }
>> -- 
>> 1.7.5.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 3/3] spi: omap2-mcspi: At remove dont use the runtime_autosuspend calls

2012-08-20 Thread Shubhrajyoti D
At remove we shouldnt be using the autosuspend timeout as we are
calling pm_runtime_disable immediately after.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 5642111..f5bf628 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1243,8 +1243,7 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
mcspi = spi_master_get_devdata(master);
dma_channels = mcspi->dma_channels;
 
-   pm_runtime_mark_last_busy(mcspi->dev);
-   pm_runtime_put_autosuspend(mcspi->dev);
+   pm_runtime_put_sync(mcspi->dev);
pm_runtime_disable(&pdev->dev);
 
spi_unregister_master(master);
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 0/3] spi: omap2-mcspi: spi cleanups

2012-08-20 Thread Shubhrajyoti D
This patch does the following

Calls the pm_runtime_* functions directly.
Remove the MOD_REG_BIT macro usage thereby removiing un-needed branch.
At remove dont use the autosuspend runtime calls.

Shubhrajyoti D (3):
  spi: omap2-mcspi: Call pm_runtime_* functions directly
  spi: omap2-mcspi: Remove the macro MOD_REG_BIT
  spi: omap2-mcspi: At remove dont use the runtime_autosuspend calls

 drivers/spi/spi-omap2-mcspi.c |   55 ++---
 1 files changed, 24 insertions(+), 31 deletions(-)

-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 1/3] spi: omap2-mcspi: Call pm_runtime_* functions directly

2012-08-20 Thread Shubhrajyoti D
Call the pm_runtime functions directly making room for possible
pm optimisations. Also the runtime functions aren't just about
enabling and disabling of clocks though it does enable clocks also.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   28 +++-
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 259f601..dd887eb 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -260,16 +260,6 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi 
*mcspi)
list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
-static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
-{
-   pm_runtime_mark_last_busy(mcspi->dev);
-   pm_runtime_put_autosuspend(mcspi->dev);
-}
-
-static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
-{
-   return pm_runtime_get_sync(mcspi->dev);
-}
 
 static int omap2_prepare_transfer(struct spi_master *master)
 {
@@ -848,12 +838,13 @@ static int omap2_mcspi_setup(struct spi_device *spi)
return ret;
}
 
-   ret = omap2_mcspi_enable_clocks(mcspi);
+   ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;
 
ret = omap2_mcspi_setup_transfer(spi, NULL);
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
 
return ret;
 }
@@ -1067,7 +1058,7 @@ static int __devinit omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
int ret = 0;
 
-   ret = omap2_mcspi_enable_clocks(mcspi);
+   ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;
 
@@ -1076,7 +1067,8 @@ static int __devinit omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
 
omap2_mcspi_set_master_mode(master);
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
return 0;
 }
 
@@ -1251,7 +1243,8 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
mcspi = spi_master_get_devdata(master);
dma_channels = mcspi->dma_channels;
 
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
pm_runtime_disable(&pdev->dev);
 
spi_unregister_master(master);
@@ -1276,7 +1269,7 @@ static int omap2_mcspi_resume(struct device *dev)
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_cs   *cs;
 
-   omap2_mcspi_enable_clocks(mcspi);
+   pm_runtime_get_sync(mcspi->dev);
list_for_each_entry(cs, &ctx->cs, node) {
if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) {
/*
@@ -1289,7 +1282,8 @@ static int omap2_mcspi_resume(struct device *dev)
__raw_writel(cs->chconf0, cs->base + 
OMAP2_MCSPI_CHCONF0);
}
}
-   omap2_mcspi_disable_clocks(mcspi);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
return 0;
 }
 #else
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 2/3] spi: omap2-mcspi: Remove the macro MOD_REG_BIT

2012-08-20 Thread Shubhrajyoti D
Remove the macro MOD_REG_BIT instead make the bit field modifications
directly. This deletes a branch operation in cases where the the set
is predecided.While at it optimise two sequential bit clear in one step.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index dd887eb..5642111 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -140,13 +140,6 @@ struct omap2_mcspi_cs {
u32 chconf0;
 };
 
-#define MOD_REG_BIT(val, mask, set) do { \
-   if (set) \
-   val |= mask; \
-   else \
-   val &= ~mask; \
-} while (0)
-
 static inline void mcspi_write_reg(struct spi_master *master,
int idx, u32 val)
 {
@@ -205,7 +198,11 @@ static void omap2_mcspi_set_dma_req(const struct 
spi_device *spi,
else
rw = OMAP2_MCSPI_CHCONF_DMAW;
 
-   MOD_REG_BIT(l, rw, enable);
+   if (enable)
+   l |= rw;
+   else
+   l &= ~rw;
+
mcspi_write_chconf0(spi, l);
 }
 
@@ -224,7 +221,11 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
u32 l;
 
l = mcspi_cached_chconf0(spi);
-   MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
+   if (cs_active)
+   l |= OMAP2_MCSPI_CHCONF_FORCE;
+   else
+   l &= ~OMAP2_MCSPI_CHCONF_FORCE;
+
mcspi_write_chconf0(spi, l);
 }
 
@@ -239,9 +240,8 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
 * to single-channel master mode
 */
l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
-   MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_STEST, 0);
-   MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_MS, 0);
-   MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
+   l &= ~(OMAP2_MCSPI_MODULCTRL_STEST | OMAP2_MCSPI_MODULCTRL_MS);
+   l |= OMAP2_MCSPI_MODULCTRL_SINGLE;
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
ctx->modulctrl = l;
@@ -1276,9 +1276,9 @@ static int omap2_mcspi_resume(struct device *dev)
 * We need to toggle CS state for OMAP take this
 * change in account.
 */
-   MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 1);
+   cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE;
__raw_writel(cs->chconf0, cs->base + 
OMAP2_MCSPI_CHCONF0);
-   MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 0);
+   cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
__raw_writel(cs->chconf0, cs->base + 
OMAP2_MCSPI_CHCONF0);
}
}
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Remove the call to platform_set_drvdata(pdev, NULL)

2012-08-16 Thread Shubhrajyoti D
Remove the call of platform_set_drvdata(pdev, NULL) as they are not
needed anymore.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bc47781..84aeaf0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1240,7 +1240,6 @@ dma_chnl_free:
kfree(mcspi->dma_channels);
 free_master:
kfree(master);
-   platform_set_drvdata(pdev, NULL);
return status;
 }
 
@@ -1259,7 +1258,6 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
 
spi_unregister_master(master);
kfree(dma_channels);
-   platform_set_drvdata(pdev, NULL);
 
return 0;
 }
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: In case of dma errors fall back to pio

2012-08-07 Thread Shubhrajyoti
On Tuesday 07 August 2012 01:17 PM, Tony Lindgren wrote:
>>  };
> Don't you need to check separately for rx and tx dma? There's a slight
> chance that you get a channel for one but not for the other..
In that case I treat it as non usable and fall back to pio.

Are you suggesting that let one channel be dma and only the failed one pio?

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] Revert "spi: omap2-mcspi: convert to module_platform_driver"

2012-08-03 Thread Shubhrajyoti
On Friday 03 August 2012 03:28 PM, Felipe Balbi wrote:
>> [1.496124] spi spi1.0: setup mode 0, 8 bits/w, 600 Hz max --> 0
>> > [1.503265] omap2_mcspi omap2_mcspi.1: registered child spi1.0
>> > 
>> > If I modify the board file so that child spi1.0 is registered before
>> > spi1.2, then it starts to work properly:
> that sounds quite odd... Shubhro, have you seen this before on any of
> our platforms ?
>
I havent seen this behaviour may be I didn't have this configuration.
Will try to see if I have any way of recreating and testing the multi cs
on one of our boards.

BTW I didnt understand why does that matter at all the cs order.

Aaro,
I am missing what is making the order matter.
What is it that I am missing?

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Fix the error handling in probe

2012-08-02 Thread Shubhrajyoti D
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.

Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.

Acked-by: Guenter Roeck 
Reported-by: Guenter Roeck 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bc47781..b2fb141 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1228,18 +1228,16 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
 
status = spi_register_master(master);
if (status < 0)
-   goto err_spi_register;
+   goto disable_pm;
 
return status;
 
-err_spi_register:
-   spi_master_put(master);
 disable_pm:
pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
kfree(mcspi->dma_channels);
 free_master:
-   kfree(master);
+   spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
 }
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: Fix the error handling in probe

2012-08-02 Thread Shubhrajyoti
On Wednesday 01 August 2012 08:37 PM, Guenter Roeck wrote:
> On Wed, Aug 01, 2012 at 03:06:28PM +0530, Shubhrajyoti D wrote:
>> The kfree() is taken care of by the spi core (spi_master_release() function)
>> that is called once the last reference to the underlying struct device has
>> been released. So the driver need not call kfree.
>>
>> Also the put was missed in some of the error handling fix the same.
>> There by fixing the missing device_put in some of the error paths.
>>
>> Cc: Guenter Roeck 
> Reported-by: may be better here.
My bad. I should have done.
>
>> Signed-off-by: Shubhrajyoti D 
> Acked-by: Guenter Roeck 
thanks.
> I suspect that "spi_master_put(master);" may also be missing in
> omap2_mcspi_remove(), but we'll need someone to confirm that.
Looks unlikely.

spi_master_put does a 
...
  if (master)
put_device(&master->dev);
...

In remove I call 

spi_unregister_master
...
*/
void spi_unregister_master(struct spi_master *master)
{
int dummy;
[...]

dummy = device_for_each_child(&master->dev, NULL, __unregister);
device_unregister(&master->dev);
}

and 

void device_unregister(struct device *dev)
{
[..]
device_del(dev);
put_device(dev);
}

Hope my understanding is correct.


> Thanks,
> Guenter
>
>> ---
>>  drivers/spi/spi-omap2-mcspi.c |6 ++
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
>> index 7d46b15..b5035e2 100644
>> --- a/drivers/spi/spi-omap2-mcspi.c
>> +++ b/drivers/spi/spi-omap2-mcspi.c
>> @@ -1203,18 +1203,16 @@ static int __devinit omap2_mcspi_probe(struct 
>> platform_device *pdev)
>>  
>>  status = spi_register_master(master);
>>  if (status < 0)
>> -goto err_spi_register;
>> +goto disable_pm;
>>  
>>  return status;
>>  
>> -err_spi_register:
>> -spi_master_put(master);
>>  disable_pm:
>>  pm_runtime_disable(&pdev->dev);
>>  dma_chnl_free:
>>  kfree(mcspi->dma_channels);
>>  free_master:
>> -kfree(master);
>> +spi_master_put(master);
>>  platform_set_drvdata(pdev, NULL);
>>  return status;
>>  }
>> -- 
>> 1.7.5.4
>>
>>


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Fix the error handling in probe

2012-08-01 Thread Shubhrajyoti D
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.

Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.

Cc: Guenter Roeck 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7d46b15..b5035e2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1203,18 +1203,16 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
 
status = spi_register_master(master);
if (status < 0)
-   goto err_spi_register;
+   goto disable_pm;
 
return status;
 
-err_spi_register:
-   spi_master_put(master);
 disable_pm:
pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
kfree(mcspi->dma_channels);
 free_master:
-   kfree(master);
+   spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
 }
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [06/10,V2] spi: Add SPI driver for mx233/mx28

2012-07-31 Thread Shubhrajyoti Datta
On Wed, Aug 1, 2012 at 10:59 AM, Guenter Roeck  wrote:
> On Wed, Aug 01, 2012 at 07:00:54AM +0200, Marek Vasut wrote:
>> Dear Shawn Guo,
>>
>> > On Tue, Jul 31, 2012 at 08:35:59PM -0700, Guenter Roeck wrote:
>> > > I think the call to spi_master_put() triggers the call to
>> > > spi_master_release(). If so, kfree() would not be needed at all, and the
>> > > documentation is wrong.
>> >
>> > Also those drivers calling kfree in probe.
>>
>> Looks like that to me ...
>>
> Doesn't seem to be far spread, fortunately. Only spi-davinci.c, spi-imx.c, and
> spi-omap2-mcspi.c

I have a  omapsdp I could patch spi-omap2-mcspi.c  file thanks for the catch.

>as far as I can see, plus the misleading comment in spi.c.
>
> Anyone up for writing some patches ? If not, I'll do it.
>
> Thanks,
> Guenter
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: In case of dma errors fall back to pio

2012-07-24 Thread Shubhrajyoti D
In case there are dma errors currently the driver exits.
Make the spi driver fall back to pio mode in case of dma errors.

If the DMA engine is not selected the driver
exits.This patch makes the spi fall back to pio in that case.

Also adds a field dma_unusable to struct omap2_mcspi.
 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   21 +
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bc47781..f243a39 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -129,6 +129,7 @@ struct omap2_mcspi {
struct omap2_mcspi_dma  *dma_channels;
struct device   *dev;
struct omap2_mcspi_regs ctx;
+   int dma_unusable;
 };
 
 struct omap2_mcspi_cs {
@@ -845,7 +846,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
ret = omap2_mcspi_request_dma(spi);
if (ret < 0)
-   return ret;
+   mcspi->dma_unusable = 1;
}
 
ret = omap2_mcspi_enable_clocks(mcspi);
@@ -956,7 +957,8 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, 
struct spi_message *m)
__raw_writel(0, cs->base
+ OMAP2_MCSPI_TX0);
 
-   if (m->is_dma_mapped || t->len >= DMA_MIN_BYTES)
+   if (!mcspi->dma_unusable && (m->is_dma_mapped ||
+   t->len >= DMA_MIN_BYTES))
count = omap2_mcspi_txrx_dma(spi, t);
else
count = omap2_mcspi_txrx_pio(spi, t);
@@ -1030,7 +1032,8 @@ static int omap2_mcspi_transfer_one_message(struct 
spi_master *master,
return -EINVAL;
}
 
-   if (m->is_dma_mapped || len < DMA_MIN_BYTES)
+   if (mcspi->dma_unusable || m->is_dma_mapped ||
+   len < DMA_MIN_BYTES)
continue;
 
if (tx_buf != NULL) {
@@ -1054,6 +1057,7 @@ static int omap2_mcspi_transfer_one_message(struct 
spi_master *master,
return -EINVAL;
}
}
+
}
 
omap2_mcspi_work(mcspi, m);
@@ -1216,9 +1220,12 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start;
}
 
-   if (status < 0)
-   goto dma_chnl_free;
-
+   if (status < 0) {
+   dev_err(&pdev->dev, "cannot get DMA channel switching to 
pio\n");
+   mcspi->dma_unusable = 1;
+   status = 0;
+   kfree(mcspi->dma_channels);
+   }
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
pm_runtime_enable(&pdev->dev);
@@ -1229,14 +1236,12 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
status = spi_register_master(master);
if (status < 0)
goto err_spi_register;
-
return status;
 
 err_spi_register:
spi_master_put(master);
 disable_pm:
pm_runtime_disable(&pdev->dev);
-dma_chnl_free:
kfree(mcspi->dma_channels);
 free_master:
kfree(master);
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: omap2-mcspi: Fix the below warning

2012-07-21 Thread Shubhrajyoti Datta
On Fri, Jul 20, 2012 at 3:40 PM, Mark Brown
 wrote:
> On Thu, Jul 19, 2012 at 11:16:52PM +0530, Shubhrajyoti D wrote:
>> The dma_map and dma_unmap should have same parameter
>> passed otherwise we get the below warn.
>
> Applied, thanks.
thanks,

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi/omap2: mark omap2_mcspi_master_setup as __devinit

2012-07-20 Thread Shubhrajyoti D
From: Arnd Bergmann 

This warning recently appeared with omap2plus_defconfig:

WARNING: drivers/spi/built-in.o(.devinit.text+0x3c4): Section mismatch in 
reference from the function omap2_mcspi_probe() to the function 
.init.text:omap2_mcspi_master_setup()
The function __devinit omap2_mcspi_probe() references
a function __init omap2_mcspi_master_setup().
If omap2_mcspi_master_setup is only used by omap2_mcspi_probe then
annotate omap2_mcspi_master_setup with a matching annotation.

The fix is obviously to mark the omap2_mcspi_master_setup function as
__devinit, rather than __init.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 37ccdb7..7d46b15 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1034,7 +1034,7 @@ static int omap2_mcspi_transfer_one_message(struct 
spi_master *master,
return 0;
 }
 
-static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
+static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
 {
struct spi_master   *master = mcspi->master;
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2-mcspi: Fix the below warning

2012-07-19 Thread Shubhrajyoti D
The dma_map and dma_unmap should have same parameter
passed otherwise we get the below warn.

ks8851 spi1.0: DMA-API: device driver tries to free DMA memory it has not 
allocated [device address=0x9f22]

[2.066925] Modules linked in:
[2.070312]
[2.071929] [] (unwind_backtrace+0x0/0x130) from [] 
(warn_slowpath_common+0x4c/0x64)
[2.081909] [] (warn_slowpath_common+0x4c/0x64) from [] 
(warn_slowpath_fmt+0x30/0x40)
[2.091949] [] (warn_slowpath_fmt+0x30/0x40) from [] 
(check_unmap+0x6d0/0x7b0)
[2.101348] [] (check_unmap+0x6d0/0x7b0) from [] 
(debug_dma_unmap_page+0x64/0x70)
[2.111053] [] (debug_dma_unmap_page+0x64/0x70) from [] 
(omap2_mcspi_txrx_dma+0x2d8/0x4fc)
[2.121582] [] (omap2_mcspi_txrx_dma+0x2d8/0x4fc) from 
[] (omap2_mcspi_work.clone.4+0xf0/0x290)
[2.132537] [] (omap2_mcspi_work.clone.4+0xf0/0x290) from 
[] (omap2_mcspi_transfer_one_message+0x288/0x438)
[2.144592] [] (omap2_mcspi_transfer_one_message+0x288/0x438) from 
[] (spi_pump_messages+0x100/0x160)
[2.156127] [] (spi_pump_messages+0x100/0x160) from [] 
(kthread_worker_fn+0xac/0x180)
[2.166168] [] (kthread_worker_fn+0xac/0x180) from [] 
(kthread+0x90/0x9c)
[2.175140] [] (kthread+0x90/0x9c) from [] 
(kernel_thread_exit+0x0/0x8)
[2.183898] ---[ end trace d1830ce6e44292f2 ]---

Fix the warn by changing the unmap parameter.

Reported-by: Russell King - ARM Linux 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0c73dd4..37ccdb7 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -388,7 +388,8 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
 
if (tx != NULL) {
wait_for_completion(&mcspi_dma->dma_tx_completion);
-   dma_unmap_single(&spi->dev, xfer->tx_dma, count, DMA_TO_DEVICE);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
+DMA_TO_DEVICE);
 
/* for TX_ONLY mode, be sure all words have shifted out */
if (rx == NULL) {
@@ -403,7 +404,8 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
 
if (rx != NULL) {
wait_for_completion(&mcspi_dma->dma_rx_completion);
-   dma_unmap_single(&spi->dev, xfer->rx_dma, count, 
DMA_FROM_DEVICE);
+   dma_unmap_single(mcspi->dev, xfer->rx_dma, count,
+DMA_FROM_DEVICE);
omap2_mcspi_set_enable(spi, 0);
 
if (l & OMAP2_MCSPI_CHCONF_TURBO) {
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: spi/omap2: mark omap2_mcspi_master_setup as __devinit

2012-07-19 Thread Shubhrajyoti
+Mark
Since Grant is moving to a new house.

On Thursday 19 July 2012 08:22 PM, Arnd Bergmann wrote:
> This warning recently appeared with omap2plus_defconfig:
>
> WARNING: drivers/spi/built-in.o(.devinit.text+0x3c4): Section mismatch in 
> reference from the function omap2_mcspi_probe() to the function 
> .init.text:omap2_mcspi_master_setup()
> The function __devinit omap2_mcspi_probe() references
> a function __init omap2_mcspi_master_setup().
> If omap2_mcspi_master_setup is only used by omap2_mcspi_probe then
> annotate omap2_mcspi_master_setup with a matching annotation.
>
> The fix is obviously to mark the omap2_mcspi_master_setup function as
> __devinit, rather than __init.
Acked-by: Shubhrajyoti D mailto:shubhrajy...@ti.com>>

Thanks for the patch.
Apologies for breaking in one  my patch series.
>
> Signed-off-by: Arnd Bergmann 
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 0c73dd4..dc02f2f 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -1032,7 +1032,7 @@ static int omap2_mcspi_transfer_one_message(struct 
> spi_master *master,
>   return 0;
>  }
>  
> -static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
> +static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
>  {
>   struct spi_master   *master = mcspi->master;
>   struct omap2_mcspi_regs *ctx = &mcspi->ctx;


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: Linux SPI slave support

2012-07-17 Thread Shubhrajyoti Datta
On Tue, Jul 17, 2012 at 2:22 PM, Marek Vasut  wrote:
> Dear Shubhrajyoti Datta,
>
>> On Mon, Jul 16, 2012 at 5:56 AM, Marek Vasut  wrote:
>> > Dear Shubhrajyoti Datta,
[..]
>> The other option is to have something like a gpio  for synchronization.
>
> Synchronisation of what exactly? With my hardware (that doesn't exist yet I
> guess), the idea is to simply cross-connect the MISO/MOSI pins and connect the
> CLK signal. Is that possible btw?

IIUC , the clock is to be driven by master. The slave gets the clock.
Master knows when to start and stop the transaction.

However for the slave the options are to
1) Keep listening always.
2) Use something to syncronize( I may have used the word loosely)
master and slave.
So that it doesnt have to listen always.

Btw it is just a suggestion. I am not opposed to any other implementation.

Thanks and Regards,

>
> Thanks!
>

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: Linux SPI slave support

2012-07-17 Thread Shubhrajyoti Datta
On Mon, Jul 16, 2012 at 5:56 AM, Marek Vasut  wrote:
> Dear Shubhrajyoti Datta,
>
>> Hello,
>>
>> On Sat, Jun 30, 2012 at 8:45 AM, Marek Vasut  wrote:
>> > Hello,
>> >
>> > is there currently any ongoing effort to support SPI slave mode in Linux?
>> >
>> > If there is none, could you please share any hints that might help me
>> > better choose and go in the direction of implementing the SPI slave
>> > support?
>>
>> May be you may want to check the archives.
>> You may want to see below before designing.
>>
>> http://permalink.gmane.org/gmane.linux.kernel.spi.devel/7495
> [...]
>
> So, idea V2:
>
> 1) Separate out common parts from struct spi_master
> 2) Create struct spi_slave
> 2a) Implement spi_slave_send_message for spi_slave
> 2b) Implement  netlink interface to push and pull messages to/from 
> userland ?
>
> The protocol won't be done in kernel, but completely in userland.
>
> Is this good approach to take? Or maybe 2b can be replaced by blocking read on
> character device? I think netlink interface might actually be suited quite 
> well
> for this task.


The other option is to have something like a gpio  for synchronization.



>
> Best regards,
> Marek Vasut

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH RFC] spi: omap2-mcspi: Fix the dma_unmap warning

2012-07-05 Thread Shubhrajyoti D
The dma_map and dma_unmap should have same parameter
passed otherwise we get the below warn.

ks8851 spi1.0: DMA-API: device driver tries to free DMA memory it has not 
allocated [device address=0x9f22]

[2.066925] Modules linked in:
[2.070312]
[2.071929] [] (unwind_backtrace+0x0/0x130) from [] 
(warn_slowpath_common+0x4c/0x64)
[2.081909] [] (warn_slowpath_common+0x4c/0x64) from [] 
(warn_slowpath_fmt+0x30/0x40)
[2.091949] [] (warn_slowpath_fmt+0x30/0x40) from [] 
(check_unmap+0x6d0/0x7b0)
[2.101348] [] (check_unmap+0x6d0/0x7b0) from [] 
(debug_dma_unmap_page+0x64/0x70)
[2.111053] [] (debug_dma_unmap_page+0x64/0x70) from [] 
(omap2_mcspi_txrx_dma+0x2d8/0x4fc)
[2.121582] [] (omap2_mcspi_txrx_dma+0x2d8/0x4fc) from 
[] (omap2_mcspi_work.clone.4+0xf0/0x290)
[2.132537] [] (omap2_mcspi_work.clone.4+0xf0/0x290) from 
[] (omap2_mcspi_transfer_one_message+0x288/0x438)
[2.144592] [] (omap2_mcspi_transfer_one_message+0x288/0x438) from 
[] (spi_pump_messages+0x100/0x160)
[2.156127] [] (spi_pump_messages+0x100/0x160) from [] 
(kthread_worker_fn+0xac/0x180)
[2.166168] [] (kthread_worker_fn+0xac/0x180) from [] 
(kthread+0x90/0x9c)
[2.175140] [] (kthread+0x90/0x9c) from [] 
(kernel_thread_exit+0x0/0x8)
[2.183898] ---[ end trace d1830ce6e44292f2 ]---

Fix the warn by changing the unmap parameter to the one used while doing
dma_map.

Reported-by: Russell King 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0c73dd4..37ccdb7 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -388,7 +388,8 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
 
if (tx != NULL) {
wait_for_completion(&mcspi_dma->dma_tx_completion);
-   dma_unmap_single(&spi->dev, xfer->tx_dma, count, DMA_TO_DEVICE);
+   dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
+DMA_TO_DEVICE);
 
/* for TX_ONLY mode, be sure all words have shifted out */
if (rx == NULL) {
@@ -403,7 +404,8 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
 
if (rx != NULL) {
wait_for_completion(&mcspi_dma->dma_rx_completion);
-   dma_unmap_single(&spi->dev, xfer->rx_dma, count, 
DMA_FROM_DEVICE);
+   dma_unmap_single(mcspi->dev, xfer->rx_dma, count,
+DMA_FROM_DEVICE);
omap2_mcspi_set_enable(spi, 0);
 
if (l & OMAP2_MCSPI_CHCONF_TURBO) {
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: Linux SPI slave support

2012-06-29 Thread Shubhrajyoti Datta
Hello,

On Sat, Jun 30, 2012 at 8:45 AM, Marek Vasut  wrote:
> Hello,
>
> is there currently any ongoing effort to support SPI slave mode in Linux?
>
> If there is none, could you please share any hints that might help me better
> choose and go in the direction of implementing the SPI slave support?


May be you may want to check the archives.
You may want to see below before designing.

http://permalink.gmane.org/gmane.linux.kernel.spi.devel/7495

>
> I had this quick idea of simply extending the flags field of struct spi_master
> {} by something like SPI_MASTER_CAN_BE_SWITCHED_TO_SLAVE_MODE (shortened of
> course). Then there'd have to be a function present that can switch the mode,
> also in struct spi_master it seems. And then, any driver willing to use the
> slave support will simply call this switch function. Something amongst those
> lines maybe? Basically, the idea would be to have SPI slave mode drivers and
> master mode drivers using the same API, just make the bus configured
> differently.
>
> Please advise. Thanks in advance!
>
> Best regards,
> Marek Vasut
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [CFT 07/11] spi: omap2-mcspi: add DMA engine support

2012-06-17 Thread Shubhrajyoti
On Thursday 14 June 2012 06:20 PM, Russell King - ARM Linux wrote:
> because, at the time when omap2_mcspi_setup() is called, spi->dev is
> not bound, and so is outside of the devres valid lifetime of that
> struct device.
Agree,
Apologies for breaking in the initial commit.

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: add spi controller master driver for Blackfin 6xx processor

2012-06-04 Thread Shubhrajyoti Datta
Hi Scott,
Some minor comments?

On Tue, Jun 5, 2012 at 12:51 AM, Scott Jiang
 wrote:
> New spi controller is integrated into Blackfin 6xx processor.
> Comparing to bf5xx spi controller, we support 32 bits word size
> and independent receive and transmit DMA channels now.
> Also mode 0 and 2 (CPHA = 0) can get fully supported
> becasue cs line may be controlled by the software.


how about using spi core queuing?
> +
> +       status = bfin_spi_start_queue(drv_data);
> +       if (status != 0) {
> +               dev_err(dev, "problem starting queue\n");
> +               goto err_destroy_queue;
> +       }
> +
> +       bfin_write(&drv_data->regs->control, SPI_CTL_MSTR | SPI_CTL_CPHA);
> +       bfin_write(&drv_data->regs->ssel, 0xFE00);
> +       bfin_write(&drv_data->regs->delay, 0x0);
> +
> +       /* Register with the SPI framework */
> +       platform_set_drvdata(pdev, drv_data);
> +       status = spi_register_master(master);
> +       if (status != 0) {
> +               dev_err(dev, "problem registering spi master\n");
> +               goto err_free_peripheral;
> +       }
> +
> +       dev_info(dev, "bfin-spi probe success\n");
> +       return status;
> +
> +err_destroy_queue:
> +       bfin_spi_destroy_queue(drv_data);
> +err_free_peripheral:
> +       peripheral_free_list(drv_data->pin_req);
> +err_free_rx_dma:
> +       free_dma(drv_data->rx_dma);
> +err_free_tx_dma:
> +       free_dma(drv_data->tx_dma);
> +err_iounmap:
> +       iounmap(drv_data->regs);
> +err_put_master:
> +       spi_master_put(master);
> +
> +       return status;
> +}
> +
> +/* stop hardware and remove the driver */
> +static int __devexit bfin_spi_remove(struct platform_device *pdev)
> +{
> +       struct bfin_spi_master_data *drv_data = platform_get_drvdata(pdev);
> +
> +       if (!drv_data)
> +               return 0;
> +
> +       /* Remove the queue */
> +       bfin_spi_destroy_queue(drv_data);
> +
> +       /* Disable the SSP at the peripheral and SOC level */
> +       bfin_spi_disable(drv_data);
> +
> +       peripheral_free_list(drv_data->pin_req);
> +       free_dma(drv_data->rx_dma);
> +       free_dma(drv_data->tx_dma);
> +       iounmap(drv_data->regs);
> +
> +       /* Disconnect from the SPI framework */
> +       spi_unregister_master(drv_data->master);
> +       spi_master_put(drv_data->master);
> +       /* Prevent double remove */
> +       platform_set_drvdata(pdev, NULL);
> +
> +       return 0;
> +}
> +
> +#ifdef CONFIG_PM
> +static int bfin_spi_suspend(struct platform_device *pdev, pm_message_t state)
> +{
> +       struct bfin_spi_master_data *drv_data = platform_get_drvdata(pdev);
> +       int status = 0;
> +
> +       status = bfin_spi_stop_queue(drv_data);
> +       if (status != 0)
> +               return status;
> +
> +       drv_data->control = bfin_read(&drv_data->regs->control);
> +       drv_data->ssel = bfin_read(&drv_data->regs->ssel);
> +
> +       bfin_write(&drv_data->regs->control, SPI_CTL_MSTR | SPI_CTL_CPHA);
> +       bfin_write(&drv_data->regs->ssel, 0xFE00);
> +
> +       return 0;
> +}
> +
> +static int bfin_spi_resume(struct platform_device *pdev)
> +{
> +       struct bfin_spi_master_data *drv_data = platform_get_drvdata(pdev);
> +       int status = 0;
> +
> +       bfin_write(&drv_data->regs->control, drv_data->control);
> +       bfin_write(&drv_data->regs->ssel, drv_data->ssel);
> +
> +       /* Start the queue running */
> +       status = bfin_spi_start_queue(drv_data);
> +       if (status != 0) {
> +               dev_err(&pdev->dev, "problem starting queue (%d)\n", status);
> +               return status;
> +       }
> +
> +       return 0;
> +}
> +#else
> +#define bfin_spi_suspend NULL
> +#define bfin_spi_resume NULL
> +#endif /* CONFIG_PM */
> +
> +MODULE_ALIAS("platform:bfin-spi");
> +static struct platform_driver bfin_spi_driver = {
> +       .driver = {
> +               .name   = "bfin-spi",
> +               .owner  = THIS_MODULE,
> +       },
> +       .suspend        = bfin_spi_suspend,
> +       .resume         = bfin_spi_resume,

Can we move to dev pm ops instead?

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi/omap2-mcspi: convert to the pump message infrastructure

2012-05-14 Thread Shubhrajyoti Datta
Hi Linus,

On Tue, May 15, 2012 at 1:42 AM, Linus Walleij  wrote:
> On Thu, May 10, 2012 at 2:57 PM, Shubhrajyoti D  wrote:
>
>> This patch converts the OMAP SPI driver to use the SPI infrastructure
>> pump message queue.Also fixes the below warning.
>> master is unqueued, this is deprecated
>>
>> Signed-off-by: Shubhrajyoti D 
>
> Final version of the patch?
Lest someone has comments.

> Acked-by: Linus Walleij 
Thanks.

>
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 2/2] spi: Add SPI master controller for OCTEON SOCs.

2012-05-13 Thread Shubhrajyoti Datta
Hi David,
A few comments.

On Sat, May 12, 2012 at 3:04 AM, David Daney  wrote:
> From: David Daney 
>
> Add the driver, link it into the kbuild system and provide device tree
> binding documentation.
>
> Signed-off-by: David Daney 
> ---
>  .../devicetree/bindings/spi/spi-octeon.txt         |   33 ++
>  drivers/spi/Kconfig                                |    7 +
>  drivers/spi/Makefile                               |    1 +
>  drivers/spi/spi-octeon.c                           |  369 
> 
>  4 files changed, 410 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/spi/spi-octeon.txt
>  create mode 100644 drivers/spi/spi-octeon.c
>
> diff --git a/Documentation/devicetree/bindings/spi/spi-octeon.txt 
> b/Documentation/devicetree/bindings/spi/spi-octeon.txt
> new file mode 100644
> index 000..431add1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/spi/spi-octeon.txt
> @@ -0,0 +1,33 @@
> +Cavium, Inc. OCTEON SOC SPI master controller.
> +
> +Required properties:
> +- compatible : "cavium,octeon-3010-spi"
> +- reg : The register base for the controller.
> +- interrupts : One interrupt, used by the controller.
> +- #address-cells : <1>, as required by generic SPI binding.
> +- #size-cells : <0>, also as required by generic SPI binding.
> +
> +Child nodes as per the generic SPI binding.
> +
> +Example:
> +
> +       spi@107001000 {
> +               compatible = "cavium,octeon-3010-spi";
> +               reg = <0x10700 0x1000 0x0 0x100>;
> +               interrupts = <0 58>;
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +
> +               eeprom@0 {
> +                       compatible = "st,m95256", "atmel,at25";
> +                       reg = <0>;
> +                       spi-max-frequency = <500>;
> +                       spi-cpha;
> +                       spi-cpol;
> +
> +                       pagesize = <64>;
> +                       size = <32768>;
> +                       address-width = <16>;
> +               };
> +       };
> +
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index 00c0240..e1dd0d0 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -228,6 +228,13 @@ config SPI_OC_TINY
>        help
>          This is the driver for OpenCores tiny SPI master controller.
>
> +config SPI_OCTEON
> +       tristate "Cavium OCTEON SPI controller"
> +       depends on CPU_CAVIUM_OCTEON
> +       help
> +         SPI host driver for the hardware found on some Cavium OCTEON
> +         SOCs.
> +
>  config SPI_OMAP_UWIRE
>        tristate "OMAP1 MicroWire"
>        depends on ARCH_OMAP1
> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> index 9d75d21..c7f8b71 100644
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_SPI_MPC52xx_PSC)         += spi-mpc52xx-psc.o
>  obj-$(CONFIG_SPI_MPC52xx)              += spi-mpc52xx.o
>  obj-$(CONFIG_SPI_NUC900)               += spi-nuc900.o
>  obj-$(CONFIG_SPI_OC_TINY)              += spi-oc-tiny.o
> +obj-$(CONFIG_SPI_OCTEON)               += spi-octeon.o
>  obj-$(CONFIG_SPI_OMAP_UWIRE)           += spi-omap-uwire.o
>  obj-$(CONFIG_SPI_OMAP_100K)            += spi-omap-100k.o
>  obj-$(CONFIG_SPI_OMAP24XX)             += spi-omap2-mcspi.o
> diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c
> new file mode 100644
> index 000..7207aaf
> --- /dev/null
> +++ b/drivers/spi/spi-octeon.c
> @@ -0,0 +1,369 @@
> +/*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * Copyright (C) 2011, 2012 Cavium, Inc.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define DRV_VERSION "2.0" /* Version 1 was the out-of-tree driver */
This could be given a miss. As it is less meaningful once accepted.

> +#define DRV_DESCRIPTION "Cavium, Inc. OCTEON SPI bus driver"
> +
> +
> +#define OCTEON_SPI_CFG 0
> +#define OCTEON_SPI_STS 0x08
> +#define OCTEON_SPI_TX 0x10
> +#define OCTEON_SPI_DAT0 0x80
> +
> +#define OCTEON_SPI_MAX_BYTES 9
> +
> +#define OCTEON_SPI_MAX_CLOCK_HZ 1600
> +
> +struct octeon_spi {
> +       struct spi_master *my_master;
> +       u64 register_base;
> +       u64 last_cfg;
> +       u64 cs_enax;
> +};
> +
> +struct octeon_spi_setup {
> +       u32 max_speed_hz;
> +       u8 chip_select;
> +       u8 mode;
> +       u8 bits_per_word;
> +};
> +
> +static void octeon_spi_wait_ready(struct octeon_spi *p)
> +{
> +       union cvmx_mpi_sts mpi_sts;
> +       unsigned int loops = 0;
> +
> +       do {
> +               if (loops++)
> +                       __delay(500);
Could we allow  have a non-busy loop here?

--
Live Security Virtual Conference
Exclusive l

Re: [PATCH] spi: refactor spi-coldfire-qspi to use SPI queue framework.

2012-05-11 Thread Shubhrajyoti Datta
On Fri, May 11, 2012 at 4:03 PM, Steven King  wrote:
> On Friday 11 May 2012 1:33:25 am Shubhrajyoti Datta wrote:
>> Hi Steven,
>>
>> On Thu, May 10, 2012 at 9:56 PM, Steven King  wrote:
>> > Use the new SPI queue framework; remove use of workqueue, replace
>> > mcfqspi_transfer with mcfqspi_transfer_one_message, add
>> > mcfqspi_prepare_transfer_hw and mcfqspi_unprepare_transfer_hw, update
>> > power management routines.
>>
>> By update are you attempting to convert to runtime framework also?
>
> laying the ground work for it; right now its mostly just a big nop as
> currently on Coldfire there isnt any PM support.

OK , BTW my concern was partly clock apis and partly runtime.
Anyways dont have any strong opinions.

>  I suppose it would have
> been better to have that as a separate patch, i can resubmit with that broken
> out if people would prefer.

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi: refactor spi-coldfire-qspi to use SPI queue framework.

2012-05-11 Thread Shubhrajyoti Datta
Hi Steven,

On Thu, May 10, 2012 at 9:56 PM, Steven King  wrote:
> Use the new SPI queue framework; remove use of workqueue, replace
> mcfqspi_transfer with mcfqspi_transfer_one_message, add
> mcfqspi_prepare_transfer_hw and mcfqspi_unprepare_transfer_hw, update power
> management routines.

By update are you attempting to convert to runtime framework also?

>

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated

2012-05-10 Thread Shubhrajyoti D
Currently the prepare/unprepare transfer are called unconditionally.
The assumption is that every driver using the spi core queue infrastructure
has to populate the prepare and unprepare functions. This encourages
drivers to populate empty functions to prevent crashing.
This patch prevents the call to prepare/unprepare if not populated.

Cc: Linus Walleij 
Signed-off-by: Shubhrajyoti D 
---

 drivers/spi/spi.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 37c555e..30e114c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -532,7 +532,7 @@ static void spi_pump_messages(struct kthread_work *work)
/* Lock queue and check for queue work */
spin_lock_irqsave(&master->queue_lock, flags);
if (list_empty(&master->queue) || !master->running) {
-   if (master->busy) {
+   if (master->busy &&  master->unprepare_transfer_hardware) {
ret = master->unprepare_transfer_hardware(master);
if (ret) {
spin_unlock_irqrestore(&master->queue_lock, 
flags);
@@ -562,7 +562,7 @@ static void spi_pump_messages(struct kthread_work *work)
master->busy = true;
spin_unlock_irqrestore(&master->queue_lock, flags);
 
-   if (!was_busy) {
+   if (!was_busy && master->prepare_transfer_hardware) {
ret = master->prepare_transfer_hardware(master);
if (ret) {
dev_err(&master->dev,
-- 
1.7.5.4


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi/omap2-mcspi: convert to the pump message infrastructure

2012-05-10 Thread Shubhrajyoti Datta
On Wed, May 9, 2012 at 4:46 PM, Shubhrajyoti D  wrote:
> This patch converts the OMAP SPI driver to use the SPI infrastructure
> pump message queue.Also fixes the below warning.
> master is unqueued, this is deprecated
Just realised that sent the missed a few cleanups please ignore this patch.
Will resend it in while.

>
> Signed-off-by: Shubhrajyoti D 
> ---
> Applies on Grants spi next branch.
>
>  drivers/spi/spi-omap2-mcspi.c |  244 
> +++--
>  1 files changed, 114 insertions(+), 130 deletions(-)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index f374eee..44f76df 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -120,10 +120,8 @@ struct omap2_mcspi_regs {
>  };
>
>  struct omap2_mcspi {
> -       struct work_struct      work;
>        /* lock protects queue and registers */
>        spinlock_t              lock;
> -       struct list_head        msg_queue;
>        struct spi_master       *master;
>        /* Virtual base address of the controller */
>        void __iomem            *base;
> @@ -131,7 +129,6 @@ struct omap2_mcspi {
>        /* SPI1 has 4 channels, while SPI2 has 2 */
>        struct omap2_mcspi_dma  *dma_channels;
>        struct device           *dev;
> -       struct workqueue_struct *wq;
>        struct omap2_mcspi_regs ctx;
>  };
>
> @@ -275,6 +272,23 @@ static int omap2_mcspi_enable_clocks(struct omap2_mcspi 
> *mcspi)
>        return pm_runtime_get_sync(mcspi->dev);
>  }
>
> +static int omap2_prepare_transfer(struct spi_master *master)
> +{
> +       struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
> +
> +       pm_runtime_get_sync(mcspi->dev);
> +       return 0;
> +}
> +
> +static int omap2_unprepare_transfer(struct spi_master *master)
> +{
> +       struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
> +
> +       pm_runtime_mark_last_busy(mcspi->dev);
> +       pm_runtime_put_autosuspend(mcspi->dev);
> +       return 0;
> +}
> +
>  static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
>  {
>        unsigned long timeout;
> @@ -846,144 +860,126 @@ static void omap2_mcspi_cleanup(struct spi_device 
> *spi)
>        }
>  }
>
> -static void omap2_mcspi_work(struct work_struct *work)
> +static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message 
> *m)
>  {
> -       struct omap2_mcspi      *mcspi;
> -
> -       mcspi = container_of(work, struct omap2_mcspi, work);
> -
> -       if (omap2_mcspi_enable_clocks(mcspi) < 0)
> -               return;
> -
> -       spin_lock_irq(&mcspi->lock);
>
>        /* We only enable one channel at a time -- the one whose message is
> -        * at the head of the queue -- although this controller would gladly
> +        * -- although this controller would gladly
>         * arbitrate among multiple channels.  This corresponds to "single
>         * channel" master mode.  As a side effect, we need to manage the
>         * chipselect with the FORCE bit ... CS != channel enable.
>         */
> -       while (!list_empty(&mcspi->msg_queue)) {
> -               struct spi_message              *m;
> -               struct spi_device               *spi;
> -               struct spi_transfer             *t = NULL;
> -               int                             cs_active = 0;
> -               struct omap2_mcspi_cs           *cs;
> -               struct omap2_mcspi_device_config *cd;
> -               int                             par_override = 0;
> -               int                             status = 0;
> -               u32                             chconf;
> -
> -               m = container_of(mcspi->msg_queue.next, struct spi_message,
> -                                queue);
> -
> -               list_del_init(&m->queue);
> -               spin_unlock_irq(&mcspi->lock);
> -
> -               spi = m->spi;
> -               cs = spi->controller_state;
> -               cd = spi->controller_data;
>
> -               omap2_mcspi_set_enable(spi, 1);
> -               list_for_each_entry(t, &m->transfers, transfer_list) {
> -                       if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) 
> {
> -                               status = -EINVAL;
> -                               break;
> -                       }
> -                       if (par_override || t->speed_hz || t->bits_per_word) {
> -                               par_override = 1;
> -                               status = omap2_mcspi_setup_transfer(spi, t)

[PATCH] spi/omap2-mcspi: convert to the pump message infrastructure

2012-05-10 Thread Shubhrajyoti D
This patch converts the OMAP SPI driver to use the SPI infrastructure
pump message queue.Also fixes the below warning.
master is unqueued, this is deprecated

Signed-off-by: Shubhrajyoti D 
---
Applies on spi/next branch

 drivers/spi/spi-omap2-mcspi.c |  243 +++--
 1 files changed, 110 insertions(+), 133 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index f374eee..46ef5fe 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -120,10 +120,6 @@ struct omap2_mcspi_regs {
 };
 
 struct omap2_mcspi {
-   struct work_struct  work;
-   /* lock protects queue and registers */
-   spinlock_t  lock;
-   struct list_headmsg_queue;
struct spi_master   *master;
/* Virtual base address of the controller */
void __iomem*base;
@@ -131,7 +127,6 @@ struct omap2_mcspi {
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma  *dma_channels;
struct device   *dev;
-   struct workqueue_struct *wq;
struct omap2_mcspi_regs ctx;
 };
 
@@ -275,6 +270,23 @@ static int omap2_mcspi_enable_clocks(struct omap2_mcspi 
*mcspi)
return pm_runtime_get_sync(mcspi->dev);
 }
 
+static int omap2_prepare_transfer(struct spi_master *master)
+{
+   struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
+
+   pm_runtime_get_sync(mcspi->dev);
+   return 0;
+}
+
+static int omap2_unprepare_transfer(struct spi_master *master)
+{
+   struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
+
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
+   return 0;
+}
+
 static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
 {
unsigned long timeout;
@@ -846,144 +858,122 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
}
 }
 
-static void omap2_mcspi_work(struct work_struct *work)
+static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
 {
-   struct omap2_mcspi  *mcspi;
-
-   mcspi = container_of(work, struct omap2_mcspi, work);
-
-   if (omap2_mcspi_enable_clocks(mcspi) < 0)
-   return;
-
-   spin_lock_irq(&mcspi->lock);
 
/* We only enable one channel at a time -- the one whose message is
-* at the head of the queue -- although this controller would gladly
+* -- although this controller would gladly
 * arbitrate among multiple channels.  This corresponds to "single
 * channel" master mode.  As a side effect, we need to manage the
 * chipselect with the FORCE bit ... CS != channel enable.
 */
-   while (!list_empty(&mcspi->msg_queue)) {
-   struct spi_message  *m;
-   struct spi_device   *spi;
-   struct spi_transfer *t = NULL;
-   int cs_active = 0;
-   struct omap2_mcspi_cs   *cs;
-   struct omap2_mcspi_device_config *cd;
-   int par_override = 0;
-   int status = 0;
-   u32 chconf;
-
-   m = container_of(mcspi->msg_queue.next, struct spi_message,
-queue);
-
-   list_del_init(&m->queue);
-   spin_unlock_irq(&mcspi->lock);
-
-   spi = m->spi;
-   cs = spi->controller_state;
-   cd = spi->controller_data;
 
-   omap2_mcspi_set_enable(spi, 1);
-   list_for_each_entry(t, &m->transfers, transfer_list) {
-   if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
-   status = -EINVAL;
-   break;
-   }
-   if (par_override || t->speed_hz || t->bits_per_word) {
-   par_override = 1;
-   status = omap2_mcspi_setup_transfer(spi, t);
-   if (status < 0)
-   break;
-   if (!t->speed_hz && !t->bits_per_word)
-   par_override = 0;
-   }
+   struct spi_device   *spi;
+   struct spi_transfer *t = NULL;
+   int cs_active = 0;
+   struct omap2_mcspi_cs   *cs;
+   struct omap2_mcspi_device_config *cd;
+   int par_override = 0;
+   int status = 0;
+   u32 chconf;
 
-   if (!

[PATCH] spi/omap2-mcspi: convert to the pump message infrastructure

2012-05-09 Thread Shubhrajyoti D
This patch converts the OMAP SPI driver to use the SPI infrastructure
pump message queue.Also fixes the below warning.
master is unqueued, this is deprecated

Signed-off-by: Shubhrajyoti D 
---
Applies on Grants spi next branch.

 drivers/spi/spi-omap2-mcspi.c |  244 +++--
 1 files changed, 114 insertions(+), 130 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index f374eee..44f76df 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -120,10 +120,8 @@ struct omap2_mcspi_regs {
 };
 
 struct omap2_mcspi {
-   struct work_struct  work;
/* lock protects queue and registers */
spinlock_t  lock;
-   struct list_headmsg_queue;
struct spi_master   *master;
/* Virtual base address of the controller */
void __iomem*base;
@@ -131,7 +129,6 @@ struct omap2_mcspi {
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma  *dma_channels;
struct device   *dev;
-   struct workqueue_struct *wq;
struct omap2_mcspi_regs ctx;
 };
 
@@ -275,6 +272,23 @@ static int omap2_mcspi_enable_clocks(struct omap2_mcspi 
*mcspi)
return pm_runtime_get_sync(mcspi->dev);
 }
 
+static int omap2_prepare_transfer(struct spi_master *master)
+{
+   struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
+
+   pm_runtime_get_sync(mcspi->dev);
+   return 0;
+}
+
+static int omap2_unprepare_transfer(struct spi_master *master)
+{
+   struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
+
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
+   return 0;
+}
+
 static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
 {
unsigned long timeout;
@@ -846,144 +860,126 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
}
 }
 
-static void omap2_mcspi_work(struct work_struct *work)
+static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
 {
-   struct omap2_mcspi  *mcspi;
-
-   mcspi = container_of(work, struct omap2_mcspi, work);
-
-   if (omap2_mcspi_enable_clocks(mcspi) < 0)
-   return;
-
-   spin_lock_irq(&mcspi->lock);
 
/* We only enable one channel at a time -- the one whose message is
-* at the head of the queue -- although this controller would gladly
+* -- although this controller would gladly
 * arbitrate among multiple channels.  This corresponds to "single
 * channel" master mode.  As a side effect, we need to manage the
 * chipselect with the FORCE bit ... CS != channel enable.
 */
-   while (!list_empty(&mcspi->msg_queue)) {
-   struct spi_message  *m;
-   struct spi_device   *spi;
-   struct spi_transfer *t = NULL;
-   int cs_active = 0;
-   struct omap2_mcspi_cs   *cs;
-   struct omap2_mcspi_device_config *cd;
-   int par_override = 0;
-   int status = 0;
-   u32 chconf;
-
-   m = container_of(mcspi->msg_queue.next, struct spi_message,
-queue);
-
-   list_del_init(&m->queue);
-   spin_unlock_irq(&mcspi->lock);
-
-   spi = m->spi;
-   cs = spi->controller_state;
-   cd = spi->controller_data;
 
-   omap2_mcspi_set_enable(spi, 1);
-   list_for_each_entry(t, &m->transfers, transfer_list) {
-   if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
-   status = -EINVAL;
-   break;
-   }
-   if (par_override || t->speed_hz || t->bits_per_word) {
-   par_override = 1;
-   status = omap2_mcspi_setup_transfer(spi, t);
-   if (status < 0)
-   break;
-   if (!t->speed_hz && !t->bits_per_word)
-   par_override = 0;
-   }
+   struct spi_device   *spi;
+   struct spi_transfer *t = NULL;
+   int cs_active = 0;
+   struct omap2_mcspi_cs   *cs;
+   struct omap2_mcspi_device_config *cd;
+   int par_override = 0;
+   int status = 0;
+   u32 chconf;
 
-   if (!

Re: [PATCH V2] spi/pl022: Fix range checking for bits per word

2012-04-17 Thread Shubhrajyoti Datta
Hi Vinit,

Looks OK to me ,

On Tue, Apr 17, 2012 at 12:40 PM, Vinit Shenoy  wrote:
> pl022 ssp controller supports word lengths from 4 to 16 (or 32) bits.
> Currently implemented checks were incorrect. It has following check
>
> if (pl022->vendor->max_bpw >= 32)
>
> which must be checking for <=.
>
> Also error print message is incorrect, that prints "range is from 1 to
> 16".
>
> Fix both these issues.

Thanks ,

>
> Signed-off-by: Vinit Shenoy 
> ---
> V1->V2:
> - Fixed the check:
>        if (pl022->vendor->max_bpw >= 32)
> - Re-written complete range check logic.
I think the patches could be split as one is a fix the other corrects the
error msg.

Nit:
Also the changlogs spell the issue and not the solution.
I think that could be improved.
Other than  that feel free to add
Reviewed-by: Shubhrajyoti D 

If you like.
>
>  drivers/spi/spi-pl022.c |   25 +
>  1 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
> index 09c925a..1ead49d 100644
> --- a/drivers/spi/spi-pl022.c
> +++ b/drivers/spi/spi-pl022.c
> @@ -1823,9 +1823,12 @@ static int pl022_setup(struct spi_device *spi)
>        } else
>                chip->cs_control = chip_info->cs_control;
>
> -       if (bits <= 3) {
> -               /* PL022 doesn't support less than 4-bits */
> +       /* Check bits per word with vendor specific range */
> +       if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) {
>                status = -ENOTSUPP;
> +               dev_err(&spi->dev, "illegal data size for this 
> controller!\n");
> +               dev_err(&spi->dev, "This controller can only handle 4 <= n <= 
> %d bit words\n",
> +                               pl022->vendor->max_bpw);
>                goto err_config_params;
>        } else if (bits <= 8) {
>                dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
> @@ -1838,20 +1841,10 @@ static int pl022_setup(struct spi_device *spi)
>                chip->read = READING_U16;
>                chip->write = WRITING_U16;
>        } else {
> -               if (pl022->vendor->max_bpw >= 32) {
> -                       dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
> -                       chip->n_bytes = 4;
> -                       chip->read = READING_U32;
> -                       chip->write = WRITING_U32;
> -               } else {
> -                       dev_err(&spi->dev,
> -                               "illegal data size for this controller!\n");
> -                       dev_err(&spi->dev,
> -                               "a standard pl022 can only handle "
> -                               "1 <= n <= 16 bit words\n");
> -                       status = -ENOTSUPP;
> -                       goto err_config_params;
> -               }
> +               dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
> +               chip->n_bytes = 4;
> +               chip->read = READING_U32;
> +               chip->write = WRITING_U32;
>        }
>
>        /* Now Initialize all register settings required for this chip */
> --
> 1.7.3.4
>

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi/pl022: Fix error print while setting bits/word on pl022

2012-04-16 Thread Shubhrajyoti Datta
Hi Vinit ,
A minor comment/ suggestion.

On Tue, Apr 17, 2012 at 11:28 AM, Vinit Shenoy  wrote:
> pl022 ssp controller supports word lengths from 4 to 16 bits.
> The kernel error message says:
> "a standard pl022 can only handle 1 <= n <= 16 bit words".
>
> Fixed above range to 4 <= n <= 16.
>
> Signed-off-by: Vinit Shenoy 
> ---
>  drivers/spi/spi-pl022.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
> index 09c925a..905752f 100644
> --- a/drivers/spi/spi-pl022.c
> +++ b/drivers/spi/spi-pl022.c
> @@ -1848,7 +1848,7 @@ static int pl022_setup(struct spi_device *spi)
>                                "illegal data size for this controller!\n");
>                        dev_err(&spi->dev,
>                                "a standard pl022 can only handle "
> -                               "1 <= n <= 16 bit words\n");
> +                               "4 <= n <= 16 bit words\n");
However this print will not executed for sizes < 4
Can we have something like. [1]


>                        status = -ENOTSUPP;
>                        goto err_config_params;
>                }
> --
> 1.7.3.4
>
>
> --
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
[1]

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 09c925a..6444a5e 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1823,11 +1823,7 @@ static int pl022_setup(struct spi_device *spi)
} else
chip->cs_control = chip_info->cs_control;

-   if (bits <= 3) {
-   /* PL022 doesn't support less than 4-bits */
-   status = -ENOTSUPP;
-   goto err_config_params;
-   } else if (bits <= 8) {
+   if (bits <= 8 && bits > 3) {
dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
chip->n_bytes = 1;
chip->read = READING_U8;
@@ -1848,7 +1844,7 @@ static int pl022_setup(struct spi_device *spi)
"illegal data size for this controller!\n");
dev_err(&spi->dev,
"a standard pl022 can only handle "
-   "1 <= n <= 16 bit words\n");
+   "4 <= n <= 16 bit words\n");
status = -ENOTSUPP;
goto err_config_params;
}

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCHv3 0/3] spi: omap2-mcspi: driver updates

2012-04-02 Thread Shubhrajyoti Datta
Hi Grant

On Tue, Apr 3, 2012 at 1:10 AM, Grant Likely  wrote:
> On Sat, 31 Mar 2012 17:06:55 +0530, Shubhrajyoti D  
> wrote:
>> The patch series does the following cleanups
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>> - The tmp variable is used to write this can be optimised
>>  as it is not needed if the value is directly written.
>>  Acknowledge  Tarun for the suggestion.
>>
>> This is also available through
>> git     : git://gitorious.org/linus-tree/linus-tree.git
>> branch  : spi_next
>>
>> Rebased to Grant's spi/next branch.
>
> Merged, thanks.
Thanks ,

>
> BTW, it's easier to pull if you put the branch after the git URL (I
> can cut and paste all at once):
>
>        git://gitorious.org/linus-tree/linus-tree.git spi_next
>
> "git request-pull" can be your friend here.
>
OK good idea will do that.

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 3/3] spi: omap2-mcspi: Trivial optimisation

2012-03-31 Thread Shubhrajyoti D
Trivial optimisation of tmp variable by directly writing the value
to the register.

Cc :  Tarun Kanti DebBarma 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0b0da2f..f374eee 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1050,16 +1050,15 @@ static int __init omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
 {
struct spi_master   *master = mcspi->master;
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
-   u32 tmp;
int ret = 0;
 
ret = omap2_mcspi_enable_clocks(mcspi);
if (ret < 0)
return ret;
 
-   tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
-   mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp);
-   ctx->wakeupenable = tmp;
+   mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE,
+   OMAP2_MCSPI_WAKEUPENABLE_WKEN);
+   ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
 
omap2_mcspi_set_master_mode(master);
omap2_mcspi_disable_clocks(mcspi);
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 1/3] spi/omap: Remove bus_num usage for instance index

2012-03-31 Thread Shubhrajyoti D
From: Benoit Cousson 

bus_num was used to reference the mcspi controller instance in a fixed array.
Remove this array and store this information directly inside drvdata structure.

bus_num is now just set if the pdev->id is present or with -1 for dynamic
allocation by SPI core, but the driver does not access it anymore.

Clean some bad comments format, and remove un-needed space.

Signed-off-by: Benoit Cousson 
[Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore]
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   75 ++--
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 33f54cd..1907ed2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -45,9 +45,6 @@
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
 
-/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
-#define OMAP2_MCSPI_MAX_CTRL   4
-
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
 #define OMAP2_MCSPI_IRQSTATUS  0x18
@@ -111,6 +108,16 @@ struct omap2_mcspi_dma {
 #define DMA_MIN_BYTES  160
 
 
+/*
+ * Used for context save and restore, structure members to be updated whenever
+ * corresponding registers are modified.
+ */
+struct omap2_mcspi_regs {
+   u32 modulctrl;
+   u32 wakeupenable;
+   struct list_head cs;
+};
+
 struct omap2_mcspi {
struct work_struct  work;
/* lock protects queue and registers */
@@ -122,8 +129,9 @@ struct omap2_mcspi {
unsigned long   phys;
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma  *dma_channels;
-   struct  device  *dev;
+   struct device   *dev;
struct workqueue_struct *wq;
+   struct omap2_mcspi_regs ctx;
 };
 
 struct omap2_mcspi_cs {
@@ -135,17 +143,6 @@ struct omap2_mcspi_cs {
u32 chconf0;
 };
 
-/* used for context save and restore, structure members to be updated whenever
- * corresponding registers are modified.
- */
-struct omap2_mcspi_regs {
-   u32 modulctrl;
-   u32 wakeupenable;
-   struct list_head cs;
-};
-
-static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL];
-
 #define MOD_REG_BIT(val, mask, set) do { \
if (set) \
val |= mask; \
@@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
 
 static void omap2_mcspi_set_master_mode(struct spi_master *master)
 {
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
u32 l;
 
-   /* setup when switching from (reset default) slave mode
+   /*
+* Setup when switching from (reset default) slave mode
 * to single-channel master mode
 */
l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
@@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
-   omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l;
+   ctx->modulctrl = l;
 }
 
 static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
 {
-   struct spi_master *spi_cntrl;
-   struct omap2_mcspi_cs *cs;
-   spi_cntrl = mcspi->master;
+   struct spi_master   *spi_cntrl = mcspi->master;
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
+   struct omap2_mcspi_cs   *cs;
 
/* McSPI: context restore */
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
 
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
-
-   list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
-   node)
+   list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
@@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
 static int omap2_mcspi_setup(struct spi_device *spi)
 {
int ret;
-   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(spi->master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_dma  *mcspi_dma;
struct omap2_mcspi_cs   *cs = spi->controller_state;
 
@@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)

[PATCHv3 2/3] spi: omap2-mcspi: add support for pm_runtime autosuspend

2012-03-31 Thread Shubhrajyoti D
Adds support for configuring the omap2-mcspi driver use autosuspend for
runtime power management. This can reduce the latency in starting an
spi transfer by not suspending the device immediately following
completion of a transfer. If another transfer then takes place before
the autosuspend timeout (2 secs), the call to resume the device can
return immediately saving some save/ restore cycles.

Acked-by: Govindraj.R 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1907ed2..0b0da2f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -44,6 +44,7 @@
 #include 
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
+#define SPI_AUTOSUSPEND_TIMEOUT2000
 
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
@@ -265,7 +266,8 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi 
*mcspi)
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
 {
-   pm_runtime_put_sync(mcspi->dev);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
 }
 
 static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
@@ -1212,6 +1214,8 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
if (status < 0)
goto dma_chnl_free;
 
+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
pm_runtime_enable(&pdev->dev);
 
if (status || omap2_mcspi_master_setup(mcspi) < 0)
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 0/3] spi: omap2-mcspi: driver updates

2012-03-31 Thread Shubhrajyoti D
The patch series does the following cleanups
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series
- The tmp variable is used to write this can be optimised 
 as it is not needed if the value is directly written.
 Acknowledge  Tarun for the suggestion.

This is also available through
git : git://gitorious.org/linus-tree/linus-tree.git
branch  : spi_next

Rebased to Grant's spi/next branch.

 

Benoit Cousson (1):
  spi/omap: Remove bus_num usage for instance index

Shubhrajyoti D (2):
  spi: omap2-mcspi: add support for pm_runtime autosuspend
  spi: omap2-mcspi: Trivial optimisation

 drivers/spi/spi-omap2-mcspi.c |   86 +++-
 1 files changed, 41 insertions(+), 45 deletions(-)


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCHv3 0/6] spi: omap2-mcspi: driver updates

2012-03-31 Thread Shubhrajyoti
On Saturday 31 March 2012 11:14 AM, Grant Likely wrote:
> On Fri, 30 Mar 2012 15:50:16 +0530, Shubhrajyoti D  
> wrote:
>> The patch series does the following cleanups
>> - Converts the spi to module_platform_driver
>> - Use the devm functions so that the freeing need not 
>>   be done in the driver.
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>>
>> Changes from v1
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>>
>> Changes from v2
>> - The tmp variable is used to write this can be optimised 
>>  as it is not needed if the value is directly written.
>>  Acknowledge  Tarun for the suggestion.
>>
>> This is also available through
>> git : git://gitorious.org/linus-tree/linus-tree.git
>> branch  : spi
>>
>> This is targeted for v3.5. 
> Okay, now is a good time to talk about git pull request workflow.  10
> days ago you published a git tree and I replied that I had pulled it
> into mine.  Now you've got a new branch with the patches from the old
> branch rebased onto a new head.  Compairing your branch with mine now
> looks like this:
>
> $ git fetch git://gitorious.org/linus-tree/linus-tree.git spi
> remote: Counting objects: 34, done.
> remote: Compressing objects: 100% (28/28), done.
> remote: Total 30 (delta 24), reused 6 (delta 2)
> Unpacking objects: 100% (30/30), done.
> From git://gitorious.org/linus-tree/linus-tree
>  * branchspi-> FETCH_HEAD
> $ git show-branch --topic origin spi/next FETCH_HEAD
> ! [origin] Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
>  ! [spi/next] Merge branch 'spi' of git://gitorious.org/linus-tree/linus-tree 
> into spi/next
>   ! [FETCH_HEAD] spi: omap2-mcspi: Trivial optimisation
> ---
>   + [FETCH_HEAD] spi: omap2-mcspi: Trivial optimisation
>   + [FETCH_HEAD^] spi: omap2-mcspi: add support for pm_runtime autosuspend
>   + [FETCH_HEAD~2] spi: omap2-mcspi: use devm_* functions
>   + [FETCH_HEAD~3] spi: omap2-mcspi: convert to module_platform_driver
>   + [FETCH_HEAD~4] spi: omap2-mcspi: make it behave as a module
>   + [FETCH_HEAD~5] spi/omap: Remove bus_num usage for instance index
>  -  [spi/next] Merge branch 'spi' of 
> git://gitorious.org/linus-tree/linus-tree into spi/next
>  +  [spi/next^2] OMAP : SPI : use devm_* functions
>  +  [spi/next^2^] spi: omap2-mcspi: convert to module_platform_driver
>  +  [spi/next^2~2] spi: omap2-mcspi: make it behave as a module
> +++ [origin~189] Linux 3.3
>
> I cannot merge this branch.  If I did it would result in 2 commits for
> each of the commits from the original branch.  You'll need go back and
> rebase the new commits on top of the old base or on top of my current
> spi/next branch[1]
>
> [1] git://git.secretlab.ca/git/linux-2.6 spi/next
>
> I've already published that branch, so I will not rebase it either to
> remove the original commits.  The new commits must go on top.
>
> Next time, *don't* rebase a branch that has been pulled.  It should be
> left alone and new commits added on top of it.
Apologies for this time.
Yes will take care henceforth.
>   If your in the
> situation where mainline has commits that you need to bring into the
> branch, then *merge* mainline into your branch (preferably at a tagged
> release point), or ask me to merge in mainline to give you a new
> baseline to work from.
>
> One option I do have is to apply only the patches I'm missing to my
> tree, but I'm not going to because I don't actually know if patches
> 1, 2, or 3 have changed since the version that I've posted.  It's
> safer for me to get you to rebase back onto the proper base and post
> only the new patches.  Your cover letter should state specifically
> which branch the patches apply on top of.
Will send another pull request.



--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 4/6] spi: omap2-mcspi: use devm_* functions

2012-03-30 Thread Shubhrajyoti D
The various devm_* functions allocate memory that is released when a driver
detaches. This patch uses devm_request_and_ioremap
to request memory in probe function. Since the freeing is not
needed the calls are deleted from remove function.Also use
use devm_kzalloc for the cs memory allocation.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   24 
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 66cbf22..1907ed2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -787,7 +787,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
if (!cs) {
-   cs = kzalloc(sizeof *cs, GFP_KERNEL);
+   cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL);
if (!cs)
return -ENOMEM;
cs->base = mcspi->base + spi->chip_select * 0x14;
@@ -828,7 +828,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
cs = spi->controller_state;
list_del(&cs->node);
 
-   kfree(spi->controller_state);
}
 
if (spi->chip_select < spi->master->num_chipselect) {
@@ -1160,17 +1159,12 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
r->start += regs_offset;
r->end += regs_offset;
mcspi->phys = r->start;
-   if (!request_mem_region(r->start, resource_size(r),
-   dev_name(&pdev->dev))) {
-   status = -EBUSY;
-   goto free_master;
-   }
 
-   mcspi->base = ioremap(r->start, resource_size(r));
+   mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
if (!mcspi->base) {
dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
status = -ENOMEM;
-   goto release_region;
+   goto free_master;
}
 
mcspi->dev = &pdev->dev;
@@ -1185,7 +1179,7 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
GFP_KERNEL);
 
if (mcspi->dma_channels == NULL)
-   goto unmap_io;
+   goto free_master;
 
for (i = 0; i < master->num_chipselect; i++) {
char dma_ch_name[14];
@@ -1235,10 +1229,6 @@ disable_pm:
pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
kfree(mcspi->dma_channels);
-unmap_io:
-   iounmap(mcspi->base);
-release_region:
-   release_mem_region(r->start, resource_size(r));
 free_master:
kfree(master);
platform_set_drvdata(pdev, NULL);
@@ -1250,8 +1240,6 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
struct spi_master   *master;
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *dma_channels;
-   struct resource *r;
-   void __iomem *base;
 
master = dev_get_drvdata(&pdev->dev);
mcspi = spi_master_get_devdata(master);
@@ -1259,12 +1247,8 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
 
omap2_mcspi_disable_clocks(mcspi);
pm_runtime_disable(&pdev->dev);
-   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   release_mem_region(r->start, resource_size(r));
 
-   base = mcspi->base;
spi_unregister_master(master);
-   iounmap(base);
kfree(dma_channels);
destroy_workqueue(mcspi->wq);
platform_set_drvdata(pdev, NULL);
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index

2012-03-30 Thread Shubhrajyoti D
From: Benoit Cousson 

bus_num was used to reference the mcspi controller instance in a fixed array.
Remove this array and store this information directly inside drvdata structure.

bus_num is now just set if the pdev->id is present or with -1 for dynamic
allocation by SPI core, but the driver does not access it anymore.

Clean some bad comments format, and remove un-needed space.

Signed-off-by: Benoit Cousson 
[Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore]
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   75 ++--
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bb9274c..7785091 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -45,9 +45,6 @@
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
 
-/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
-#define OMAP2_MCSPI_MAX_CTRL   4
-
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
 #define OMAP2_MCSPI_IRQSTATUS  0x18
@@ -111,6 +108,16 @@ struct omap2_mcspi_dma {
 #define DMA_MIN_BYTES  160
 
 
+/*
+ * Used for context save and restore, structure members to be updated whenever
+ * corresponding registers are modified.
+ */
+struct omap2_mcspi_regs {
+   u32 modulctrl;
+   u32 wakeupenable;
+   struct list_head cs;
+};
+
 struct omap2_mcspi {
struct work_struct  work;
/* lock protects queue and registers */
@@ -122,8 +129,9 @@ struct omap2_mcspi {
unsigned long   phys;
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma  *dma_channels;
-   struct  device  *dev;
+   struct device   *dev;
struct workqueue_struct *wq;
+   struct omap2_mcspi_regs ctx;
 };
 
 struct omap2_mcspi_cs {
@@ -135,17 +143,6 @@ struct omap2_mcspi_cs {
u32 chconf0;
 };
 
-/* used for context save and restore, structure members to be updated whenever
- * corresponding registers are modified.
- */
-struct omap2_mcspi_regs {
-   u32 modulctrl;
-   u32 wakeupenable;
-   struct list_head cs;
-};
-
-static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL];
-
 #define MOD_REG_BIT(val, mask, set) do { \
if (set) \
val |= mask; \
@@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
 
 static void omap2_mcspi_set_master_mode(struct spi_master *master)
 {
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
u32 l;
 
-   /* setup when switching from (reset default) slave mode
+   /*
+* Setup when switching from (reset default) slave mode
 * to single-channel master mode
 */
l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
@@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
-   omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l;
+   ctx->modulctrl = l;
 }
 
 static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
 {
-   struct spi_master *spi_cntrl;
-   struct omap2_mcspi_cs *cs;
-   spi_cntrl = mcspi->master;
+   struct spi_master   *spi_cntrl = mcspi->master;
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
+   struct omap2_mcspi_cs   *cs;
 
/* McSPI: context restore */
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
 
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
-
-   list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
-   node)
+   list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
@@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
 static int omap2_mcspi_setup(struct spi_device *spi)
 {
int ret;
-   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(spi->master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_dma  *mcspi_dma;
struct omap2_mcspi_cs   *cs = spi->controller_state;
 
@@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)

[PATCHv3 2/6] spi: omap2-mcspi: make it behave as a module

2012-03-30 Thread Shubhrajyoti D
From: Felipe Balbi 

move probe away from __init section and use
platform_driver_register() instead of
platform_driver_probe().

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7785091..26dd79f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1098,7 +1098,7 @@ static const struct of_device_id omap_mcspi_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
 
-static int __init omap2_mcspi_probe(struct platform_device *pdev)
+static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 {
struct spi_master   *master;
struct omap2_mcspi_platform_config *pdata;
@@ -1245,7 +1245,7 @@ free_master:
return status;
 }
 
-static int __exit omap2_mcspi_remove(struct platform_device *pdev)
+static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 {
struct spi_master   *master;
struct omap2_mcspi  *mcspi;
@@ -1320,13 +1320,14 @@ static struct platform_driver omap2_mcspi_driver = {
.pm =   &omap2_mcspi_pm_ops,
.of_match_table = omap_mcspi_of_match,
},
-   .remove =   __exit_p(omap2_mcspi_remove),
+   .probe =omap2_mcspi_probe,
+   .remove =   __devexit_p(omap2_mcspi_remove),
 };
 
 
 static int __init omap2_mcspi_init(void)
 {
-   return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe);
+   return platform_driver_register(&omap2_mcspi_driver);
 }
 subsys_initcall(omap2_mcspi_init);
 
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 3/6] spi: omap2-mcspi: convert to module_platform_driver

2012-03-30 Thread Shubhrajyoti D
From: Felipe Balbi 

this will delete a few lines of code, no functional
changes.

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   15 +--
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 26dd79f..66cbf22 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1324,18 +1324,5 @@ static struct platform_driver omap2_mcspi_driver = {
.remove =   __devexit_p(omap2_mcspi_remove),
 };
 
-
-static int __init omap2_mcspi_init(void)
-{
-   return platform_driver_register(&omap2_mcspi_driver);
-}
-subsys_initcall(omap2_mcspi_init);
-
-static void __exit omap2_mcspi_exit(void)
-{
-   platform_driver_unregister(&omap2_mcspi_driver);
-
-}
-module_exit(omap2_mcspi_exit);
-
+module_platform_driver(omap2_mcspi_driver);
 MODULE_LICENSE("GPL");
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 0/6] spi: omap2-mcspi: driver updates

2012-03-30 Thread Shubhrajyoti D
The patch series does the following cleanups
- Converts the spi to module_platform_driver
- Use the devm functions so that the freeing need not 
  be done in the driver.
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from v1
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from v2
- The tmp variable is used to write this can be optimised 
 as it is not needed if the value is directly written.
 Acknowledge  Tarun for the suggestion.

This is also available through
git : git://gitorious.org/linus-tree/linus-tree.git
branch  : spi

This is targeted for v3.5. 

Benoit Cousson (1):
  spi/omap: Remove bus_num usage for instance index

Felipe Balbi (2):
  spi: omap2-mcspi: make it behave as a module
  spi: omap2-mcspi: convert to module_platform_driver

Shubhrajyoti D (3):
  spi: omap2-mcspi: use devm_* functions
  spi: omap2-mcspi: add support for pm_runtime autosuspend
  spi: omap2-mcspi: Trivial optimisation

 drivers/spi/spi-omap2-mcspi.c |  132 +++-
 1 files changed, 50 insertions(+), 82 deletions(-)


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index

2012-03-30 Thread Shubhrajyoti D
From: Benoit Cousson 

bus_num was used to reference the mcspi controller instance in a fixed array.
Remove this array and store this information directly inside drvdata structure.

bus_num is now just set if the pdev->id is present or with -1 for dynamic
allocation by SPI core, but the driver does not access it anymore.

Clean some bad comments format, and remove un-needed space.

Signed-off-by: Benoit Cousson 
[Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore]
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   75 ++--
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bb9274c..7785091 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -45,9 +45,6 @@
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
 
-/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
-#define OMAP2_MCSPI_MAX_CTRL   4
-
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
 #define OMAP2_MCSPI_IRQSTATUS  0x18
@@ -111,6 +108,16 @@ struct omap2_mcspi_dma {
 #define DMA_MIN_BYTES  160
 
 
+/*
+ * Used for context save and restore, structure members to be updated whenever
+ * corresponding registers are modified.
+ */
+struct omap2_mcspi_regs {
+   u32 modulctrl;
+   u32 wakeupenable;
+   struct list_head cs;
+};
+
 struct omap2_mcspi {
struct work_struct  work;
/* lock protects queue and registers */
@@ -122,8 +129,9 @@ struct omap2_mcspi {
unsigned long   phys;
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma  *dma_channels;
-   struct  device  *dev;
+   struct device   *dev;
struct workqueue_struct *wq;
+   struct omap2_mcspi_regs ctx;
 };
 
 struct omap2_mcspi_cs {
@@ -135,17 +143,6 @@ struct omap2_mcspi_cs {
u32 chconf0;
 };
 
-/* used for context save and restore, structure members to be updated whenever
- * corresponding registers are modified.
- */
-struct omap2_mcspi_regs {
-   u32 modulctrl;
-   u32 wakeupenable;
-   struct list_head cs;
-};
-
-static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL];
-
 #define MOD_REG_BIT(val, mask, set) do { \
if (set) \
val |= mask; \
@@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
 
 static void omap2_mcspi_set_master_mode(struct spi_master *master)
 {
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
u32 l;
 
-   /* setup when switching from (reset default) slave mode
+   /*
+* Setup when switching from (reset default) slave mode
 * to single-channel master mode
 */
l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
@@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
-   omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l;
+   ctx->modulctrl = l;
 }
 
 static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
 {
-   struct spi_master *spi_cntrl;
-   struct omap2_mcspi_cs *cs;
-   spi_cntrl = mcspi->master;
+   struct spi_master   *spi_cntrl = mcspi->master;
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
+   struct omap2_mcspi_cs   *cs;
 
/* McSPI: context restore */
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
 
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
-
-   list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
-   node)
+   list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
@@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
 static int omap2_mcspi_setup(struct spi_device *spi)
 {
int ret;
-   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(spi->master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_dma  *mcspi_dma;
struct omap2_mcspi_cs   *cs = spi->controller_state;
 
@@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)

[PATCHv3 6/6] spi: omap2-mcspi: Trivial optimisation

2012-03-30 Thread Shubhrajyoti D
Trivial optimisation of tmp variable by directly writing the value
to the register.

Cc :  Tarun Kanti DebBarma 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0b0da2f..f374eee 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1050,16 +1050,15 @@ static int __init omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
 {
struct spi_master   *master = mcspi->master;
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
-   u32 tmp;
int ret = 0;
 
ret = omap2_mcspi_enable_clocks(mcspi);
if (ret < 0)
return ret;
 
-   tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
-   mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp);
-   ctx->wakeupenable = tmp;
+   mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE,
+   OMAP2_MCSPI_WAKEUPENABLE_WKEN);
+   ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
 
omap2_mcspi_set_master_mode(master);
omap2_mcspi_disable_clocks(mcspi);
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 5/6] spi: omap2-mcspi: add support for pm_runtime autosuspend

2012-03-30 Thread Shubhrajyoti D
Adds support for configuring the omap2-mcspi driver use autosuspend for
runtime power management. This can reduce the latency in starting an
spi transfer by not suspending the device immediately following
completion of a transfer. If another transfer then takes place before
the autosuspend timeout (2 secs), the call to resume the device can
return immediately saving some save/ restore cycles.

Acked-by: Govindraj.R 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1907ed2..0b0da2f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -44,6 +44,7 @@
 #include 
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
+#define SPI_AUTOSUSPEND_TIMEOUT2000
 
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
@@ -265,7 +266,8 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi 
*mcspi)
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
 {
-   pm_runtime_put_sync(mcspi->dev);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
 }
 
 static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
@@ -1212,6 +1214,8 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
if (status < 0)
goto dma_chnl_free;
 
+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
pm_runtime_enable(&pdev->dev);
 
if (status || omap2_mcspi_master_setup(mcspi) < 0)
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCHv3 0/6] spi: omap2-mcspi: driver updates

2012-03-30 Thread Shubhrajyoti D
The patch series does the following cleanups
- Converts the spi to module_platform_driver
- Use the devm functions so that the freeing need not 
  be done in the driver.
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from v1
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from v2
- The tmp variable is used to write this can be optimised 
 as it is not needed if the value is directly written.
 Acknowledge  Tarun for the suggestion.

This is also available through
git : git://gitorious.org/linus-tree/linus-tree.git
branch  : spi

This is targeted for v3.5. 

Benoit Cousson (1):
  spi/omap: Remove bus_num usage for instance index

Felipe Balbi (2):
  spi: omap2-mcspi: make it behave as a module
  spi: omap2-mcspi: convert to module_platform_driver

Shubhrajyoti D (3):
  spi: omap2-mcspi: use devm_* functions
  spi: omap2-mcspi: add support for pm_runtime autosuspend
  spi: omap2-mcspi: Trivial optimisation

 drivers/spi/spi-omap2-mcspi.c |  132 +++-
 1 files changed, 50 insertions(+), 82 deletions(-)


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index

2012-03-29 Thread Shubhrajyoti Datta
Hi Tarun,

On Wed, Mar 28, 2012 at 2:15 PM, DebBarma, Tarun Kanti
 wrote:
> On Mon, Mar 26, 2012 at 7:14 PM, Shubhrajyoti D  wrote:
>> From: Benoit Cousson 
>>
>> bus_num was used to reference the mcspi controller instance in a fixed array.
>> Remove this array and store this information directly inside drvdata 
>> structure.
>>
>> bus_num is now just set if the pdev->id is present or with -1 for dynamic
>> allocation by SPI core, but the driver does not access it anymore.
>>
>> Clean some bad comments format, and remove un-needed space.
>>
>> Signed-off-by: Benoit Cousson 
>> [Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore]
>> Signed-off-by: Shubhrajyoti D 
>> ---
>>  drivers/spi/spi-omap2-mcspi.c |   75 
>> ++--
>>  1 files changed, 34 insertions(+), 41 deletions(-)
>>
>> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
>> index bb9274c..7785091 100644
>> --- a/drivers/spi/spi-omap2-mcspi.c
>> +++ b/drivers/spi/spi-omap2-mcspi.c
>> @@ -45,9 +45,6 @@
>>

>>
>>        tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
>>        mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp);
>> -       omap2_mcspi_ctx[master->bus_num - 1].wakeupenable = tmp;
>> +       ctx->wakeupenable = tmp;
> Can't we get rid of tmp now? For example:
> ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
> mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);

Yes the tmp variable could be optimized
since it is in addition to the $SUBJECT will do it in a separate patch .
Is that fine?

> --
> Tarun
>

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 0/5] spi: omap2-mcspi: driver updates

2012-03-27 Thread Shubhrajyoti Datta
Hi Grant,

On Wed, Mar 28, 2012 at 3:28 AM, Grant Likely  wrote:
> On Mon, 26 Mar 2012 19:14:35 +0530, Shubhrajyoti D  
> wrote:
>> The patch series does the following cleanups
>> - Converts the spi to module_platform_driver
>> - Use the devm functions so that the freeing need not
>>   be done in the driver.
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>>
>> Changes from the previous version
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>>
>>
>> This is also available through
>> git     : git://gitorious.org/linus-tree/linus-tree.git
>> branch  : spi
>
> Hi Shubhrajyoti,
>
> I'll queue these ones up for v3.5 unless you make the argument that
> they are bug fixes that must go into v3.4.

No  thats fine if targeted for v3.5 .
Thanks,

>
> g.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi-imx: Remove duplicate spi_imx_data definition

2012-03-26 Thread Shubhrajyoti Datta
Hi Fabio,

On Tue, Mar 27, 2012 at 12:34 AM, Fabio Estevam
 wrote:
> Shubhrajyoti Datta wrote:
>> Hi Fabio,
>>
>> On Mon, Mar 26, 2012 at 11:43 PM, Fabio Estevam
>>  wrote:
>>> Structure struct spi_imx_data is defined twice.
>>>
>>> Remove one of its definition.
>>>
>>> Signed-off-by: Fabio Estevam 
>>> ---
>>>  drivers/spi/spi-imx.c |   20 +---
>>>  1 files changed, 9 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
>>> index 31054e3..f1f6700 100644
>>> --- a/drivers/spi/spi-imx.c
>>> +++ b/drivers/spi/spi-imx.c
>>> @@ -68,17 +68,6 @@ enum spi_imx_devtype {
>>>        IMX51_ECSPI,    /* ECSPI on i.mx51 and later */
>>>  };
>>>
>>> -struct spi_imx_data;
>>> -
>>> -struct spi_imx_devtype_data {
>>> -       void (*intctrl)(struct spi_imx_data *, int);
>>> -       int (*config)(struct spi_imx_data *, struct spi_imx_config *);
>>> -       void (*trigger)(struct spi_imx_data *);
>>> -       int (*rx_available)(struct spi_imx_data *);
>>> -       void (*reset)(struct spi_imx_data *);
>>> -       enum spi_imx_devtype devtype;
>>> -};
>>
>> Is this change intentional
>
> Yes, struct spi_imx_data must be defined prior to spi_imx_devtype_data.
>
How about specifying in the changelogs.
> Thanks,
>
> Fabio Estevam
>
>
> --
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi-imx: Remove duplicate spi_imx_data definition

2012-03-26 Thread Shubhrajyoti Datta
Hi Fabio,

On Mon, Mar 26, 2012 at 11:43 PM, Fabio Estevam
 wrote:
> Structure struct spi_imx_data is defined twice.
>
> Remove one of its definition.
>
> Signed-off-by: Fabio Estevam 
> ---
>  drivers/spi/spi-imx.c |   20 +---
>  1 files changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 31054e3..f1f6700 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -68,17 +68,6 @@ enum spi_imx_devtype {
>        IMX51_ECSPI,    /* ECSPI on i.mx51 and later */
>  };
>
> -struct spi_imx_data;
> -
> -struct spi_imx_devtype_data {
> -       void (*intctrl)(struct spi_imx_data *, int);
> -       int (*config)(struct spi_imx_data *, struct spi_imx_config *);
> -       void (*trigger)(struct spi_imx_data *);
> -       int (*rx_available)(struct spi_imx_data *);
> -       void (*reset)(struct spi_imx_data *);
> -       enum spi_imx_devtype devtype;
> -};

Is this change intentional

> -
>  struct spi_imx_data {
>        struct spi_bitbang bitbang;
>
> @@ -99,6 +88,15 @@ struct spi_imx_data {
>        int chipselect[0];
>  };
>
> +struct spi_imx_devtype_data {
> +       void (*intctrl)(struct spi_imx_data *, int);
> +       int (*config)(struct spi_imx_data *, struct spi_imx_config *);
> +       void (*trigger)(struct spi_imx_data *);
> +       int (*rx_available)(struct spi_imx_data *);
> +       void (*reset)(struct spi_imx_data *);
> +       enum spi_imx_devtype devtype;
> +};
> +
>  static inline int is_imx27_cspi(struct spi_imx_data *d)
>  {
>        return d->devtype_data->devtype == IMX27_CSPI;
> --
> 1.7.1
>
>
>
> --
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index

2012-03-26 Thread Shubhrajyoti D
From: Benoit Cousson 

bus_num was used to reference the mcspi controller instance in a fixed array.
Remove this array and store this information directly inside drvdata structure.

bus_num is now just set if the pdev->id is present or with -1 for dynamic
allocation by SPI core, but the driver does not access it anymore.

Clean some bad comments format, and remove un-needed space.

Signed-off-by: Benoit Cousson 
[Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore]
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   75 ++--
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bb9274c..7785091 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -45,9 +45,6 @@
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
 
-/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
-#define OMAP2_MCSPI_MAX_CTRL   4
-
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
 #define OMAP2_MCSPI_IRQSTATUS  0x18
@@ -111,6 +108,16 @@ struct omap2_mcspi_dma {
 #define DMA_MIN_BYTES  160
 
 
+/*
+ * Used for context save and restore, structure members to be updated whenever
+ * corresponding registers are modified.
+ */
+struct omap2_mcspi_regs {
+   u32 modulctrl;
+   u32 wakeupenable;
+   struct list_head cs;
+};
+
 struct omap2_mcspi {
struct work_struct  work;
/* lock protects queue and registers */
@@ -122,8 +129,9 @@ struct omap2_mcspi {
unsigned long   phys;
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma  *dma_channels;
-   struct  device  *dev;
+   struct device   *dev;
struct workqueue_struct *wq;
+   struct omap2_mcspi_regs ctx;
 };
 
 struct omap2_mcspi_cs {
@@ -135,17 +143,6 @@ struct omap2_mcspi_cs {
u32 chconf0;
 };
 
-/* used for context save and restore, structure members to be updated whenever
- * corresponding registers are modified.
- */
-struct omap2_mcspi_regs {
-   u32 modulctrl;
-   u32 wakeupenable;
-   struct list_head cs;
-};
-
-static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL];
-
 #define MOD_REG_BIT(val, mask, set) do { \
if (set) \
val |= mask; \
@@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
 
 static void omap2_mcspi_set_master_mode(struct spi_master *master)
 {
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
u32 l;
 
-   /* setup when switching from (reset default) slave mode
+   /*
+* Setup when switching from (reset default) slave mode
 * to single-channel master mode
 */
l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
@@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
-   omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l;
+   ctx->modulctrl = l;
 }
 
 static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
 {
-   struct spi_master *spi_cntrl;
-   struct omap2_mcspi_cs *cs;
-   spi_cntrl = mcspi->master;
+   struct spi_master   *spi_cntrl = mcspi->master;
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
+   struct omap2_mcspi_cs   *cs;
 
/* McSPI: context restore */
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl);
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
 
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
-
-   list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
-   node)
+   list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
@@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
 static int omap2_mcspi_setup(struct spi_device *spi)
 {
int ret;
-   struct omap2_mcspi  *mcspi;
+   struct omap2_mcspi  *mcspi = spi_master_get_devdata(spi->master);
+   struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_dma  *mcspi_dma;
struct omap2_mcspi_cs   *cs = spi->controller_state;
 
@@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)

[PATCH v2 5/5] spi: omap2-mcspi: add support for pm_runtime autosuspend

2012-03-26 Thread Shubhrajyoti D
Adds support for configuring the omap2-mcspi driver use autosuspend for
runtime power management. This can reduce the latency in starting an
spi transfer by not suspending the device immediately following
completion of a transfer. If another transfer then takes place before
the autosuspend timeout (2 secs), the call to resume the device can
return immediately saving some save/ restore cycles.

Acked-by: Govindraj.R 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1907ed2..0b0da2f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -44,6 +44,7 @@
 #include 
 
 #define OMAP2_MCSPI_MAX_FREQ   4800
+#define SPI_AUTOSUSPEND_TIMEOUT2000
 
 #define OMAP2_MCSPI_REVISION   0x00
 #define OMAP2_MCSPI_SYSSTATUS  0x14
@@ -265,7 +266,8 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi 
*mcspi)
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
 {
-   pm_runtime_put_sync(mcspi->dev);
+   pm_runtime_mark_last_busy(mcspi->dev);
+   pm_runtime_put_autosuspend(mcspi->dev);
 }
 
 static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
@@ -1212,6 +1214,8 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
if (status < 0)
goto dma_chnl_free;
 
+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
pm_runtime_enable(&pdev->dev);
 
if (status || omap2_mcspi_master_setup(mcspi) < 0)
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v2 4/5] spi: omap2-mcspi: use devm_* functions

2012-03-26 Thread Shubhrajyoti D
The various devm_* functions allocate memory that is released when a driver
detaches. This patch uses devm_request_and_ioremap
to request memory in probe function. Since the freeing is not
needed the calls are deleted from remove function.Also use
use devm_kzalloc for the cs memory allocation.

Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   24 
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 66cbf22..1907ed2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -787,7 +787,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
if (!cs) {
-   cs = kzalloc(sizeof *cs, GFP_KERNEL);
+   cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL);
if (!cs)
return -ENOMEM;
cs->base = mcspi->base + spi->chip_select * 0x14;
@@ -828,7 +828,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
cs = spi->controller_state;
list_del(&cs->node);
 
-   kfree(spi->controller_state);
}
 
if (spi->chip_select < spi->master->num_chipselect) {
@@ -1160,17 +1159,12 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
r->start += regs_offset;
r->end += regs_offset;
mcspi->phys = r->start;
-   if (!request_mem_region(r->start, resource_size(r),
-   dev_name(&pdev->dev))) {
-   status = -EBUSY;
-   goto free_master;
-   }
 
-   mcspi->base = ioremap(r->start, resource_size(r));
+   mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
if (!mcspi->base) {
dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
status = -ENOMEM;
-   goto release_region;
+   goto free_master;
}
 
mcspi->dev = &pdev->dev;
@@ -1185,7 +1179,7 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
GFP_KERNEL);
 
if (mcspi->dma_channels == NULL)
-   goto unmap_io;
+   goto free_master;
 
for (i = 0; i < master->num_chipselect; i++) {
char dma_ch_name[14];
@@ -1235,10 +1229,6 @@ disable_pm:
pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
kfree(mcspi->dma_channels);
-unmap_io:
-   iounmap(mcspi->base);
-release_region:
-   release_mem_region(r->start, resource_size(r));
 free_master:
kfree(master);
platform_set_drvdata(pdev, NULL);
@@ -1250,8 +1240,6 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
struct spi_master   *master;
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *dma_channels;
-   struct resource *r;
-   void __iomem *base;
 
master = dev_get_drvdata(&pdev->dev);
mcspi = spi_master_get_devdata(master);
@@ -1259,12 +1247,8 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
 
omap2_mcspi_disable_clocks(mcspi);
pm_runtime_disable(&pdev->dev);
-   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   release_mem_region(r->start, resource_size(r));
 
-   base = mcspi->base;
spi_unregister_master(master);
-   iounmap(base);
kfree(dma_channels);
destroy_workqueue(mcspi->wq);
platform_set_drvdata(pdev, NULL);
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v2 2/5] spi: omap2-mcspi: make it behave as a module

2012-03-26 Thread Shubhrajyoti D
From: Felipe Balbi 

move probe away from __init section and use
platform_driver_register() instead of
platform_driver_probe().

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7785091..26dd79f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1098,7 +1098,7 @@ static const struct of_device_id omap_mcspi_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
 
-static int __init omap2_mcspi_probe(struct platform_device *pdev)
+static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 {
struct spi_master   *master;
struct omap2_mcspi_platform_config *pdata;
@@ -1245,7 +1245,7 @@ free_master:
return status;
 }
 
-static int __exit omap2_mcspi_remove(struct platform_device *pdev)
+static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 {
struct spi_master   *master;
struct omap2_mcspi  *mcspi;
@@ -1320,13 +1320,14 @@ static struct platform_driver omap2_mcspi_driver = {
.pm =   &omap2_mcspi_pm_ops,
.of_match_table = omap_mcspi_of_match,
},
-   .remove =   __exit_p(omap2_mcspi_remove),
+   .probe =omap2_mcspi_probe,
+   .remove =   __devexit_p(omap2_mcspi_remove),
 };
 
 
 static int __init omap2_mcspi_init(void)
 {
-   return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe);
+   return platform_driver_register(&omap2_mcspi_driver);
 }
 subsys_initcall(omap2_mcspi_init);
 
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 0/5] spi: omap2-mcspi: driver updates

2012-03-26 Thread Shubhrajyoti D
The patch series does the following cleanups
- Converts the spi to module_platform_driver
- Use the devm functions so that the freeing need not 
  be done in the driver.
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from the previous version
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series


This is also available through
git : git://gitorious.org/linus-tree/linus-tree.git
branch  : spi



Benoit Cousson (1):
  spi/omap: Remove bus_num usage for instance index

Felipe Balbi (2):
  spi: omap2-mcspi: make it behave as a module
  spi: omap2-mcspi: convert to module_platform_driver

Shubhrajyoti D (2):
  spi: omap2-mcspi: use devm_* functions
  spi: omap2-mcspi: add support for pm_runtime autosuspend

 drivers/spi/spi-omap2-mcspi.c |  127 +++-
 1 files changed, 48 insertions(+), 79 deletions(-)


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v2 3/5] spi: omap2-mcspi: convert to module_platform_driver

2012-03-26 Thread Shubhrajyoti D
From: Felipe Balbi 

this will delete a few lines of code, no functional
changes.

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   15 +--
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 26dd79f..66cbf22 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1324,18 +1324,5 @@ static struct platform_driver omap2_mcspi_driver = {
.remove =   __devexit_p(omap2_mcspi_remove),
 };
 
-
-static int __init omap2_mcspi_init(void)
-{
-   return platform_driver_register(&omap2_mcspi_driver);
-}
-subsys_initcall(omap2_mcspi_init);
-
-static void __exit omap2_mcspi_exit(void)
-{
-   platform_driver_unregister(&omap2_mcspi_driver);
-
-}
-module_exit(omap2_mcspi_exit);
-
+module_platform_driver(omap2_mcspi_driver);
 MODULE_LICENSE("GPL");
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH RFC] spi: spi-davinci: Fix DMA API usage in davinci

2012-03-22 Thread Shubhrajyoti Datta
Hi Sekhar,

On Thu, Mar 22, 2012 at 8:08 PM, Nori, Sekhar  wrote:
> Hi Grant,
>
> On Tue, Mar 20, 2012 at 21:53:34, Grant Likely wrote:
>> On Tue, 20 Mar 2012 16:10:09 +0530, Shubhrajyoti D  
>> wrote:
>> > The driver uses NULL for dma_unmap_single instead of
>> > the struct device that the API expects.
>> >
>> > Signed-off-by: Shubhrajyoti D 
>> > ---
>> > I do not have the board ,untested.
>>
>> Can someone with this hardware please test?
>
> Akshay from TI tested this on DA850 EVM. He doesn't have
> this e-mail so posting the tested-by on his behalf:
>
> Tested-by: Shankarmurthy, Akshay < aksha...@ti.com>

Thanks Akshay,

>
> Thanks,
> Sekhar
>
> --
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> ___
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: omap2_mcspi: Make the runtime functions depend on CONFIG_PM_RUNTIME

2012-03-20 Thread Shubhrajyoti D
Makes the function omap_mcspi_runtime_resume depend on CONFIG_PM_RUNTIME.

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   41 +++--
 1 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index cb2c0e3..f9d694d 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -248,23 +248,6 @@ static void omap2_mcspi_set_master_mode(struct spi_master 
*master)
omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l;
 }
 
-static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
-{
-   struct spi_master *spi_cntrl;
-   struct omap2_mcspi_cs *cs;
-   spi_cntrl = mcspi->master;
-
-   /* McSPI: context restore */
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
-
-   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
-   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
-
-   list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
-   node)
-   __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
-}
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
 {
pm_runtime_put_sync(mcspi->dev);
@@ -1066,6 +1049,26 @@ static int __init omap2_mcspi_master_setup(struct 
omap2_mcspi *mcspi)
return 0;
 }
 
+#ifdef CONFIG_PM_RUNTIME
+static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
+{
+   struct spi_master *spi_cntrl;
+   struct omap2_mcspi_cs *cs;
+
+   spi_cntrl = mcspi->master;
+
+   /* McSPI: context restore */
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
+   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
+
+   mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
+   omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
+
+   list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
+   node)
+   __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
+}
+
 static int omap_mcspi_runtime_resume(struct device *dev)
 {
struct omap2_mcspi  *mcspi;
@@ -1077,7 +1080,9 @@ static int omap_mcspi_runtime_resume(struct device *dev)
 
return 0;
 }
-
+#else
+#defineomap_mcspi_runtime_resume   NULL
+#endif
 
 static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 {
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 0/3] SPI updates

2012-03-20 Thread Shubhrajyoti
On Tuesday 20 March 2012 09:50 PM, Grant Likely wrote:
> On Tue, 20 Mar 2012 15:59:46 +0530, Shubhrajyoti D  
> wrote:
>> The patch series does the following cleanups
>> - Converts the spi to module_platform_driver
>> - Use the devm functions so that the freeing need not 
>>   be done in the driver.
>>
>> This is also available through
>> git : git://gitorious.org/linus-tree/linus-tree.git
>> branch  : spi
>>
>>
>> Felipe Balbi (2):
>>   spi: omap2-mcspi: make it behave as a module
>>   spi: omap2-mcspi: convert to module_platform_driver
>>
>> Shubhrajyoti D (1):
>>   spi: omap2-mcspi: use devm_* functions
>>
>>  drivers/spi/spi-omap2-mcspi.c |   46 
>> -
>>  1 files changed, 9 insertions(+), 37 deletions(-)
> Merged for v3.5 (it's too late for v3.4)
>
> g.
Thanks Grant.


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH RFC] spi: spi-davinci: Fix DMA API usage in davinci

2012-03-20 Thread Shubhrajyoti D
The driver uses NULL for dma_unmap_single instead of
the struct device that the API expects.

Signed-off-by: Shubhrajyoti D 
---
I do not have the board ,untested.

 drivers/spi/spi-davinci.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 31bfba8..9b2901f 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -653,7 +653,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct 
spi_transfer *t)
dev_dbg(sdev, "Couldn't DMA map a %d bytes RX buffer\n",
rx_buf_count);
if (t->tx_buf)
-   dma_unmap_single(NULL, t->tx_dma, t->len,
+   dma_unmap_single(&spi->dev, t->tx_dma, t->len,
DMA_TO_DEVICE);
return -ENOMEM;
}
@@ -692,10 +692,10 @@ static int davinci_spi_bufs(struct spi_device *spi, 
struct spi_transfer *t)
if (spicfg->io_type == SPI_IO_TYPE_DMA) {
 
if (t->tx_buf)
-   dma_unmap_single(NULL, t->tx_dma, t->len,
+   dma_unmap_single(&spi->dev, t->tx_dma, t->len,
DMA_TO_DEVICE);
 
-   dma_unmap_single(NULL, t->rx_dma, rx_buf_count,
+   dma_unmap_single(&spi->dev, t->rx_dma, rx_buf_count,
DMA_FROM_DEVICE);
 
clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN);
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 3/3] spi: omap2-mcspi: use devm_* functions

2012-03-20 Thread Shubhrajyoti D
The various devm_* functions allocate memory that is released when a driver
detaches. This patch uses devm_request_and_ioremap
to request memory in probe function. Since the freeing is not
needed the calls are deleted from remove function.Also use
use devm_kzalloc for the cs memory allocation.

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   24 
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7745f91..cb2c0e3 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -789,7 +789,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
if (!cs) {
-   cs = kzalloc(sizeof *cs, GFP_KERNEL);
+   cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL);
if (!cs)
return -ENOMEM;
cs->base = mcspi->base + spi->chip_select * 0x14;
@@ -831,7 +831,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
cs = spi->controller_state;
list_del(&cs->node);
 
-   kfree(spi->controller_state);
}
 
if (spi->chip_select < spi->master->num_chipselect) {
@@ -1127,17 +1126,12 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
r->start += pdata->regs_offset;
r->end += pdata->regs_offset;
mcspi->phys = r->start;
-   if (!request_mem_region(r->start, resource_size(r),
-   dev_name(&pdev->dev))) {
-   status = -EBUSY;
-   goto free_master;
-   }
 
-   mcspi->base = ioremap(r->start, resource_size(r));
+   mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
if (!mcspi->base) {
dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
status = -ENOMEM;
-   goto release_region;
+   goto free_master;
}
 
mcspi->dev = &pdev->dev;
@@ -1152,7 +1146,7 @@ static int __devinit omap2_mcspi_probe(struct 
platform_device *pdev)
GFP_KERNEL);
 
if (mcspi->dma_channels == NULL)
-   goto unmap_io;
+   goto free_master;
 
for (i = 0; i < master->num_chipselect; i++) {
char dma_ch_name[14];
@@ -1202,10 +1196,6 @@ disable_pm:
pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
kfree(mcspi->dma_channels);
-unmap_io:
-   iounmap(mcspi->base);
-release_region:
-   release_mem_region(r->start, resource_size(r));
 free_master:
kfree(master);
platform_set_drvdata(pdev, NULL);
@@ -1217,8 +1207,6 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
struct spi_master   *master;
struct omap2_mcspi  *mcspi;
struct omap2_mcspi_dma  *dma_channels;
-   struct resource *r;
-   void __iomem *base;
 
master = dev_get_drvdata(&pdev->dev);
mcspi = spi_master_get_devdata(master);
@@ -1226,12 +1214,8 @@ static int __devexit omap2_mcspi_remove(struct 
platform_device *pdev)
 
omap2_mcspi_disable_clocks(mcspi);
pm_runtime_disable(&pdev->dev);
-   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   release_mem_region(r->start, resource_size(r));
 
-   base = mcspi->base;
spi_unregister_master(master);
-   iounmap(base);
kfree(dma_channels);
destroy_workqueue(mcspi->wq);
platform_set_drvdata(pdev, NULL);
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 2/3] spi: omap2-mcspi: convert to module_platform_driver

2012-03-20 Thread Shubhrajyoti D
From: Felipe Balbi 

this will delete a few lines of code, no functional
changes.

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |   15 +--
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 5f4419e..7745f91 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1291,18 +1291,5 @@ static struct platform_driver omap2_mcspi_driver = {
.remove =   __devexit_p(omap2_mcspi_remove),
 };
 
-
-static int __init omap2_mcspi_init(void)
-{
-   return platform_driver_register(&omap2_mcspi_driver);
-}
-subsys_initcall(omap2_mcspi_init);
-
-static void __exit omap2_mcspi_exit(void)
-{
-   platform_driver_unregister(&omap2_mcspi_driver);
-
-}
-module_exit(omap2_mcspi_exit);
-
+module_platform_driver(omap2_mcspi_driver);
 MODULE_LICENSE("GPL");
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 1/3] spi: omap2-mcspi: make it behave as a module

2012-03-20 Thread Shubhrajyoti D
From: Felipe Balbi 

move probe away from __init section and use
platform_driver_register() instead of
platform_driver_probe().

Signed-off-by: Felipe Balbi 
Signed-off-by: Shubhrajyoti D 
---
 drivers/spi/spi-omap2-mcspi.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0b0dfb7..5f4419e 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1080,7 +1080,7 @@ static int omap_mcspi_runtime_resume(struct device *dev)
 }
 
 
-static int __init omap2_mcspi_probe(struct platform_device *pdev)
+static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 {
struct spi_master   *master;
struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
@@ -1212,7 +1212,7 @@ free_master:
return status;
 }
 
-static int __exit omap2_mcspi_remove(struct platform_device *pdev)
+static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 {
struct spi_master   *master;
struct omap2_mcspi  *mcspi;
@@ -1287,13 +1287,14 @@ static struct platform_driver omap2_mcspi_driver = {
.owner =THIS_MODULE,
.pm =   &omap2_mcspi_pm_ops
},
-   .remove =   __exit_p(omap2_mcspi_remove),
+   .probe =omap2_mcspi_probe,
+   .remove =   __devexit_p(omap2_mcspi_remove),
 };
 
 
 static int __init omap2_mcspi_init(void)
 {
-   return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe);
+   return platform_driver_register(&omap2_mcspi_driver);
 }
 subsys_initcall(omap2_mcspi_init);
 
-- 
1.7.1


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 0/3] SPI updates

2012-03-20 Thread Shubhrajyoti D
The patch series does the following cleanups
- Converts the spi to module_platform_driver
- Use the devm functions so that the freeing need not 
  be done in the driver.

This is also available through
git : git://gitorious.org/linus-tree/linus-tree.git
branch  : spi


Felipe Balbi (2):
  spi: omap2-mcspi: make it behave as a module
  spi: omap2-mcspi: convert to module_platform_driver

Shubhrajyoti D (1):
  spi: omap2-mcspi: use devm_* functions

 drivers/spi/spi-omap2-mcspi.c |   46 -
 1 files changed, 9 insertions(+), 37 deletions(-)


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH v3 6/6] mfd: mc13xxx: Add i2c driver

2012-03-15 Thread Shubhrajyoti Datta
Hi Marc,

On Thu, Mar 15, 2012 at 2:13 AM, Marc Reilly  wrote:
> Adds support for mc13xxx family ICs connected via i2c.
>
> Signed-off-by: Marc Reilly 
> ---


> +static int mc13xxx_i2c_probe(struct i2c_client *client,
> +               const struct i2c_device_id *id)
> +{
> +       const struct of_device_id *of_id;
> +       struct i2c_driver *idrv = to_i2c_driver(client->dev.driver);
> +       struct mc13xxx *mc13xxx;
> +       struct mc13xxx_platform_data *pdata = dev_get_platdata(&client->dev);
> +       int ret;
> +
> +       of_id = of_match_device(mc13xxx_dt_ids, &client->dev);
> +       if (of_id)
> +               idrv->id_table =
> +                       &mc13xxx_i2c_device_id[(enum mc13xxx_id) of_id->data];
> +
> +       mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
> +       if (!mc13xxx)
> +               return -ENOMEM;
> +
> +       dev_set_drvdata(&client->dev, mc13xxx);
> +
> +       mc13xxx->dev = &client->dev;
> +       mutex_init(&mc13xxx->lock);
> +
> +       mc13xxx->regmap = regmap_init_i2c(client, &mc13xxx_regmap_i2c_config);
> +       if (IS_ERR(mc13xxx->regmap)) {
> +               ret = PTR_ERR(mc13xxx->regmap);
> +               dev_err(mc13xxx->dev, "Failed to initialize register map: 
> %d\n",
> +                               ret);
> +               dev_set_drvdata(&client->dev, NULL);
Are we  leaking mc13xxx here
May be you can consider using devm* functions ?

>  +               return ret;
> +       }
> +

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH RFC] spi/omap: Trivial cleanup

2012-03-06 Thread Shubhrajyoti
On Tuesday 06 March 2012 03:46 PM, Cousson, Benoit wrote:
> Hi Shubhro,
>
> On 2/29/2012 3:04 PM, Shubhrajyoti D wrote:
>> The context is stored directly inside drvdata structure post
>> [f887876 spi/omap: Remove bus_num usage for instance index].
>> Remove the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore.
>>
>> Cc: Benoit Cousson
>> Signed-off-by: Shubhrajyoti D
>
> Thanks for that extra cleanup, I missed it.
>
> Acked-by: Benoit Cousson 
>
>> ---
>> Applies on Benoit's for_3.4/dt_spi_eth
>>
>>   drivers/spi/spi-omap2-mcspi.c |3 ---
>>   1 files changed, 0 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/spi/spi-omap2-mcspi.c
>> b/drivers/spi/spi-omap2-mcspi.c
>> index d1eb26c..3526281 100644
>> --- a/drivers/spi/spi-omap2-mcspi.c
>> +++ b/drivers/spi/spi-omap2-mcspi.c
>> @@ -45,9 +45,6 @@
>>
>>   #define OMAP2_MCSPI_MAX_FREQ4800
>>
>> -/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
>> -#define OMAP2_MCSPI_MAX_CTRL 4
>> -
>
> I guess it can be included in the "spi/omap: Remove bus_num usage for
> instance index"?
> Is that OK for you?
Yes, sure.
>
>
> Thanks,
> Benoit
>


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


  1   2   >