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

2013-06-03 Thread Viresh Kumar
On Tue, Jun 4, 2013 at 3:13 AM, Scott Jiang scott.jiang.li...@gmail.com wrote:
 diff --git a/drivers/spi/spi-bfin6xx.c b/drivers/spi/spi-bfin6xx.c

 +#include linux/workqueue.h

Why do you need this?

--
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with 2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 1/2] spi:pl022: Disable/Enable functional clock from suspend/resume

2012-09-26 Thread viresh kumar
On Wed, Sep 26, 2012 at 5:49 PM, Mark Brown
broo...@opensource.wolfsonmicro.com wrote:
 On Wed, Sep 26, 2012 at 02:17:36PM +0200, Linus Walleij wrote:
 On Wed, Sep 26, 2012 at 1:24 PM, Vipul Kumar Samar

  SPI functional clock must be disalble/enable in non RTPM suspend/resume
  hooks. Currently it is only done for RTPM cases.

  This patch add support to disable/enbale clock for conventional
  suspend/resume calls.

 Cross dependency between runtime suspend/resume and
 common suspend/resume. Oh the horror ...

 This should be fine, we runtime resume before we suspend.

I believe Vipul sent this patch for the cases where RTPM in not
enabled in the configs.

--
viresh

--
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: pl022: Add clk_{un}prepare() support in runtime PM

2012-09-17 Thread viresh kumar
On Mon, Sep 17, 2012 at 4:07 PM, Vipul Kumar Samar
vipulkumar.sa...@st.com wrote:
 clk_{un}prepare is mandatory for platforms using common clock framework. Add
 clk_{un}prepare() support for spi-pl022 runtime PM.

You are not calling these routines in actualy patch.. Fix commit log and add my
Reviewed-by.

 Signed-off-by: Vipul Kumar Samar vipulkumar.sa...@st.com
 ---
  drivers/spi/spi-pl022.c |9 ++---
  1 files changed, 6 insertions(+), 3 deletions(-)

 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index f2a80ff..500e75e 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -2334,7 +2334,7 @@ static int pl022_runtime_suspend(struct device *dev)
  {
 struct pl022 *pl022 = dev_get_drvdata(dev);

 -   clk_disable(pl022-clk);
 +   clk_disable_unprepare(pl022-clk);

 return 0;
  }
 @@ -2342,10 +2342,13 @@ static int pl022_runtime_suspend(struct device *dev)
  static int pl022_runtime_resume(struct device *dev)
  {
 struct pl022 *pl022 = dev_get_drvdata(dev);
 +   int ret = 0;

 -   clk_enable(pl022-clk);
 +   ret = clk_prepare_enable(pl022-clk);
 +   if (ret)
 +   dev_err(dev, could not enable SSP/SPI bus clock\n);

 -   return 0;
 +   return ret;
  }
  #endif

 --
 1.7.2.2


 --
 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: [PATCH] spi: pl022: Add clk_{un}prepare() support in runtime PM

2012-09-17 Thread viresh kumar
On Mon, Sep 17, 2012 at 7:09 PM, Linus Walleij linus.wall...@linaro.org wrote:
 This driver does clk_prepare/unprepare at probe
 and removed, so I guess what you're trying to say is that
 on your platform the clk_unprepare() process context call
 is needed to save power?

 Please elaborate...

Hi Linus,

Yes, we don't need to call prepare() again atleast for SPEAr. You are correct.
I saw the driver after a long time :)
Can you please elaborate, why can't i see any clk_disable/enable calls anywhere
else from probe. If i remember correctly, earlier we used to enable/disable
clk after transfers and also during suspend/resume.

The amba layer is taking care of interface clock only and not
functional clock. So
i believe that's not the magic code. :)

--
viresh

--
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/pl022: Fill master-dev.of_node to get spi devices registered via DT

2012-08-22 Thread Viresh Kumar
On 19 August 2012 03:56, Linus Walleij linus.wall...@linaro.org wrote:

 On Sat, Aug 18, 2012 at 4:25 AM, Viresh Kumar viresh.ku...@linaro.org
 wrote:

  spi_register_master() calls of_register_spi_devices() to register spi
 devices.
  This routine expects master-dev.of_node to be a valid pointer. This is
  responsibility of master driver to fill this field, which wasn't done
 for pl022.
  Fix it to get devices added to pl022.

 Isn't this one of those things that *have* to be #ifdef CONFIG_OF?

 Next iteration, remember to add Mark Brown on To: because je's taking
 care of SPI patches for the moment.


Ahh!! Forgot to reply :(

Dropping this patch as it is already fixed in Roland's patches

viresh
--
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/pl022: Fill master-dev.of_node to get spi devices registered via DT

2012-08-17 Thread Viresh Kumar
spi_register_master() calls of_register_spi_devices() to register spi devices.
This routine expects master-dev.of_node to be a valid pointer. This is
responsibility of master driver to fill this field, which wasn't done for pl022.
Fix it to get devices added to pl022.

Signed-off-by: Viresh Kumar viresh.ku...@linaro.org
---
 drivers/spi/spi-pl022.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index aab518e..3a46848 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2029,6 +2029,7 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
master-transfer_one_message = pl022_transfer_one_message;
master-unprepare_transfer_hardware = pl022_unprepare_transfer_hardware;
master-rt = platform_info-rt;
+   master-dev.of_node = dev-of_node;
 
/*
 * Supports mode 0-3, loopback, and active low CS. Transfers are
-- 
1.7.12.rc2.18.g61b472e


--
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: pl022: Fix calculate_effective_freq()

2012-04-26 Thread Viresh Kumar
On 4/19/2012 2:44 PM, Viresh KUMAR wrote:
 calculate_effective_freq() was still not optimized and there were cases when 
 it
 returned without error and with values of cpsr and scr as zero.
 
 Also, the variable named found is not used well.
 
 This patch targets to optimize and correct this routine. Tested for SPEAr.
 
 Signed-off-by: Viresh Kumar viresh.ku...@st.com
 Tested-by: Vinit Kamalaksha Shenoy vinit.she...@st.com

You forgot to review this :)

-- 
viresh

--
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: pl022: Allow request for higher frequency than maximum possible

2012-04-19 Thread Viresh Kumar
Currently, if we request for frequency greater than maximum possible, spi driver
returns error.

For example, if the spi block src frequency is 333/4 MHz, i.e. 83.33.. MHz,
maximum frequency programmable would be src/2. Which would come around 41.6...

It is difficult to pass frequency in these figures. We normally try to program
in round figures, like 42 MHz and it should get programmed to =
requested_frequency, i.e. 41.6...

For this to happen, we must not return error even if requested freq is higher
than max possible. But should program it to max possible.

Reported-by: Vinit Kamalaksha Shenoy vinit.she...@st.com
Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/spi-pl022.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 09c925a..99d5f6d 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, 
int freq, struct
/* cpsdvsr = 254  scr = 255 */
min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
 
-   if (!((freq = max_tclk)  (freq = min_tclk))) {
+   if (freq  max_tclk)
+   dev_warn(pl022-adev-dev,
+   Max speed that can be programmed is %d Hz, you 
requested %d\n,
+   max_tclk, freq);
+
+   if (freq  min_tclk) {
dev_err(pl022-adev-dev,
-   controller data is incorrect: out of range frequency);
+   Requested frequency: %d Hz is less than minimum 
possible %d Hz\n,
+   freq, min_tclk);
return -EINVAL;
}
 
-- 
1.7.9


--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi: pl022: Fix calculate_effective_freq()

2012-04-19 Thread Viresh Kumar
calculate_effective_freq() was still not optimized and there were cases when it
returned without error and with values of cpsr and scr as zero.

Also, the variable named found is not used well.

This patch targets to optimize and correct this routine. Tested for SPEAr.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Vinit Kamalaksha Shenoy vinit.she...@st.com
---
 drivers/spi/spi-pl022.c |   23 +--
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 99d5f6d..490be03 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1687,26 +1687,37 @@ static int calculate_effective_freq(struct pl022 
*pl022, int freq, struct
while (scr = SCR_MAX) {
tmp = spi_rate(rate, cpsdvsr, scr);
 
-   if (tmp  freq)
+   if (tmp  freq) {
+   /* we need lower freq */
scr++;
+   continue;
+   }
+
/*
-* If found exact value, update and break.
-* If found more closer value, update and continue.
+* If found exact value, mark found and break.
+* If found more closer value, update and break.
 */
-   else if ((tmp == freq) || (tmp  best_freq)) {
+   if (tmp  best_freq) {
best_freq = tmp;
best_cpsdvsr = cpsdvsr;
best_scr = scr;
 
if (tmp == freq)
-   break;
+   found = 1;
}
-   scr++;
+   /*
+* increased scr will give lower rates, which are not
+* required
+*/
+   break;
}
cpsdvsr += 2;
scr = SCR_MIN;
}
 
+   WARN(!best_freq, pl022: Matching cpsdvsr and scr not found for %d Hz 
rate \n,
+   freq);
+
clk_freq-cpsdvsr = (u8) (best_cpsdvsr  0xFF);
clk_freq-scr = (u8) (best_scr  0xFF);
dev_dbg(pl022-adev-dev,
-- 
1.7.9


--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi/pl022: Add high priority message pump support

2012-01-24 Thread Viresh Kumar
-pump_messages, pump_messages);
 - pl022-workqueue = create_singlethread_workqueue(
 + init_kthread_worker(pl022-kworker);
 + pl022-kworker_task = kthread_run(kthread_worker_fn,
 + pl022-kworker,
   dev_name(pl022-master-dev.parent));
 - if (pl022-workqueue == NULL)
 - return -EBUSY;
 + if (IS_ERR(pl022-kworker_task)) {
 + dev_err(pl022-adev-dev,
 + failed to create message pump task\n);
 + return -ENOMEM;
 + }
 + init_kthread_work(pl022-pump_messages, pump_messages);
 +
 + /*
 +  * Board config will indicate if this controller should run the
 +  * message pump with high (realtime) priority to reduce the transfer
 +  * latency on the bus by minimising the delay between a transfer
 +  * request and the scheduling of the message pump thread. Without this
 +  * setting the message pump thread will remain at default priority.
 +  */
 + if (pl022-master_info-rt) {
 + dev_info(pl022-adev-dev,
 + will run message pump with realtime priority\n);
 + sched_setscheduler(pl022-kworker_task, SCHED_FIFO, param);
 + }
  
   return 0;
  }
 @@ -1608,7 +1631,7 @@ static int start_queue(struct pl022 *pl022)
   pl022-next_msg_cs_active = false;
   spin_unlock_irqrestore(pl022-queue_lock, flags);
  
 - queue_work(pl022-workqueue, pl022-pump_messages);
 + queue_kthread_work(pl022-kworker, pl022-pump_messages);
  
   return 0;
  }
 @@ -1646,16 +1669,20 @@ static int destroy_queue(struct pl022 *pl022)
   int status;
  
   status = stop_queue(pl022);
 - /* we are unloading the module or failing to load (only two calls
 +
 + /*
 +  * We are unloading the module or failing to load (only two calls
* to this routine), and neither call can handle a return value.
 -  * However, destroy_workqueue calls flush_workqueue, and that will
 -  * block until all work is done.  If the reason that stop_queue
 -  * timed out is that the work will never finish, then it does no
 -  * good to call destroy_workqueue, so return anyway. */
 +  * However, flush_kthread_worker will block until all work is done.
 +  * If the reason that stop_queue timed out is that the work will never
 +  * finish, then it does no good to call flush/stop thread, so
 +  * return anyway.
 +  */
   if (status != 0)
   return status;
  
 - destroy_workqueue(pl022-workqueue);
 + flush_kthread_worker(pl022-kworker);
 + kthread_stop(pl022-kworker_task);
  
   return 0;
  }
 @@ -1802,7 +1829,7 @@ static int pl022_transfer(struct spi_device *spi, 
 struct spi_message *msg)
  
   list_add_tail(msg-queue, pl022-queue);
   if (pl022-running  !pl022-busy)
 - queue_work(pl022-workqueue, pl022-pump_messages);
 + queue_kthread_work(pl022-kworker, pl022-pump_messages);
  
   spin_unlock_irqrestore(pl022-queue_lock, flags);
   return 0;
 diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h
 index 572f637..3672f40 100644
 --- a/include/linux/amba/pl022.h
 +++ b/include/linux/amba/pl022.h
 @@ -241,6 +241,8 @@ struct dma_chan;
   * @autosuspend_delay: delay in ms following transfer completion before the
   * runtime power management system suspends the device. A setting of 0
   * indicates no delay and the device will be suspended immediately.
 + * @rt: indicates the controller should run the message pump with realtime
 + * priority to minimise the transfer latency on the bus.
   */
  struct pl022_ssp_controller {
   u16 bus_id;
 @@ -250,6 +252,7 @@ struct pl022_ssp_controller {
   void *dma_rx_param;
   void *dma_tx_param;
   int autosuspend_delay;
 + bool rt;
  };
  
  /**

Looks fine.

Acked-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
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


Re: [PATCH 3/7] spi/pl022: skip default configuration before suspending

2011-11-22 Thread Viresh Kumar
On 11/22/2011 1:54 PM, Linus WALLEIJ wrote:
 From: Virupax Sadashivpetimath virupax.sadashivpetim...@stericsson.com
 
 The loading of the default configuration before suspending has
 been in the driver since its inception, but it is not really
 needed. Especially so since we take to all the trouble of
 enabling and disabling power and clock just to do this. Let's
 scrap this now.
 
 Signed-off-by: Virupax Sadashivpetimath 
 virupax.sadashivpetim...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
 ChangeLog v1-v2:
 - Use local dev pointer instead of copy/paste bug adev-dev
 ---
  drivers/spi/spi-pl022.c |5 -
  1 files changed, 0 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index 0d0b165..b4038f9 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -2310,11 +2310,6 @@ static int pl022_suspend(struct device *dev)
   return status;
   }
  
 - amba_vcore_enable(pl022-adev);
 - amba_pclk_enable(pl022-adev);
 - load_ssp_default_config(pl022);
 - amba_pclk_disable(pl022-adev);
 - amba_vcore_disable(pl022-adev);
   dev_dbg(dev, suspended\n);
   return 0;
  }

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 4/7] spi/pl022: move device disable to workqueue thread

2011-11-22 Thread Viresh Kumar
On 11/22/2011 1:55 PM, Linus WALLEIJ wrote:
   if (list_empty(pl022-queue) || !pl022-running) {
 + if (pl022-busy) {
 + pm_runtime_put(pl022-adev-dev);
 + }

We used to get warnings from checkpatch, for single line code inside {}.
Don't we get them anymore?

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 7/7] spi/pl022: make the chip deselect handling thread safe

2011-11-22 Thread Viresh Kumar
);
   spin_unlock_irqrestore(pl022-queue_lock, flags);
  
 - /* see if the next and current messages point
 -  * to the same chip
 + /*
 +  * see if the next and current messages point
 +  * to the same spi device.
*/
 - if (next_msg  next_msg-spi != msg-spi)
 + if (next_msg  next_msg-spi != pl022-cur_msg-spi)
   next_msg = NULL;
 - if (!next_msg || msg-state == STATE_ERROR)
 - curr_cs_control(SSP_CHIP_DESELECT);
 + if (!next_msg || pl022-cur_msg-state == STATE_ERROR)
 + pl022-cur_chip-cs_control(SSP_CHIP_DESELECT);
 + else
 + pl022-next_msg_cs_active = true;
   }
 +
 + spin_lock_irqsave(pl022-queue_lock, flags);
 + msg = pl022-cur_msg;
 + pl022-cur_msg = NULL;
 + pl022-cur_transfer = NULL;
 + pl022-cur_chip = NULL;
 + queue_work(pl022-workqueue, pl022-pump_messages);
 + spin_unlock_irqrestore(pl022-queue_lock, flags);
 +
   msg-state = NULL;
   if (msg-complete)
   msg-complete(msg-context);
 @@ -1350,7 +1348,7 @@ static void pump_transfers(unsigned long data)
*/
   udelay(previous-delay_usecs);
  
 - /* Drop chip select only if cs_change is requested */
 + /* Reselect chip select only if cs_change was requested */
   if (previous-cs_change)
   pl022-cur_chip-cs_control(SSP_CHIP_SELECT);
   } else {
 @@ -1389,8 +1387,10 @@ static void do_interrupt_dma_transfer(struct pl022 
 *pl022)
*/
   u32 irqflags = ENABLE_ALL_INTERRUPTS  ~SSP_IMSC_MASK_RXIM;
  
 - /* Enable target chip */
 - pl022-cur_chip-cs_control(SSP_CHIP_SELECT);
 + /* Enable target chip, if not already active */
 + if (!pl022-next_msg_cs_active)
 + pl022-cur_chip-cs_control(SSP_CHIP_SELECT);
 +
   if (set_up_next_transfer(pl022, pl022-cur_transfer)) {
   /* Error path */
   pl022-cur_msg-state = STATE_ERROR;
 @@ -1445,7 +1445,8 @@ static void do_polling_transfer(struct pl022 *pl022)
   } else {
   /* STATE_START */
   message-state = STATE_RUNNING;
 - pl022-cur_chip-cs_control(SSP_CHIP_SELECT);
 + if (!pl022-next_msg_cs_active)
 + pl022-cur_chip-cs_control(SSP_CHIP_SELECT);
   }
  
   /* Configuration Changing Per Transfer */
 @@ -1604,6 +1605,7 @@ static int start_queue(struct pl022 *pl022)
   pl022-cur_msg = NULL;
   pl022-cur_transfer = NULL;
   pl022-cur_chip = NULL;
 + pl022-next_msg_cs_active = false;
   spin_unlock_irqrestore(pl022-queue_lock, flags);
  
   queue_work(pl022-workqueue, pl022-pump_messages);

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 1/6] spi/pl022: only enable RX interrupts when TX is complete

2011-11-09 Thread Viresh Kumar
On 11/9/2011 4:08 PM, Linus WALLEIJ wrote:
 + /* default is to enable all interrupts except RX -
 +  * this will be enabled once TX is complete
 +  */

Other than fixing this multiline comment, everything other looks fine.

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 2/6] spi/pl022: fix build warnings

2011-11-09 Thread Viresh Kumar
On 11/9/2011 4:08 PM, Linus WALLEIJ wrote:
 From: Jonas Aaberg jonas.ab...@stericsson.com
 
 The driver build complains with newer compilers unless you
 initialize this struct properly.
 
 Signed-off-by: Jonas Aaberg jonas.ab...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
  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 b251926..305f2ba 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -1885,7 +1885,7 @@ static int pl022_setup(struct spi_device *spi)
  {
   struct pl022_config_chip const *chip_info;
   struct chip_data *chip;
 - struct ssp_clock_params clk_freq = {0, };
 + struct ssp_clock_params clk_freq = { .cpsdvsr = 0, .scr = 0};
   int status = 0;
   struct pl022 *pl022 = spi_master_get_devdata(spi-master);
   unsigned int bits = spi-bits_per_word;

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 3/6] spi/pl022: disable the PL022 block when unused

2011-11-09 Thread Viresh Kumar
On 11/9/2011 4:09 PM, Linus WALLEIJ wrote:
 From: Virupax Sadashivpetimath virupax.sadashivpetim...@stericsson.com
 
 Make sure we clear the enable bit when the block is not used.
 This will save some energy in certain hardware versions.
 
 Signed-off-by: Virupax Sadashivpetimath 
 virupax.sadashivpetim...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
  drivers/spi/spi-pl022.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index 305f2ba..fa3eaae 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -512,6 +512,11 @@ static void giveback(struct pl022 *pl022)
   msg-state = NULL;
   if (msg-complete)
   msg-complete(msg-context);
 +
 + /* disable the SPI/SSP operation */
 + writew((readw(SSP_CR1(pl022-virtbase)) 
 + (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022-virtbase));
 +
   /* This message is completed, so let's turn off the clocks  power */
   pm_runtime_put(pl022-adev-dev);
  }

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 4/6] spi/pl022: skip default configuration before suspending

2011-11-09 Thread Viresh Kumar
On 11/9/2011 4:09 PM, Linus WALLEIJ wrote:
 From: Virupax Sadashivpetimath virupax.sadashivpetim...@stericsson.com
 
 The loading of the default configuration before suspending has
 been in the driver since its inception, but it is not really
 needed. Especially so since we take to all the trouble of
 enabling and disabling power and clock just to do this. Let's
 scrap this now.
 
 Signed-off-by: Virupax Sadashivpetimath 
 virupax.sadashivpetim...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
  drivers/spi/spi-pl022.c |7 +--
  1 files changed, 1 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index fa3eaae..bffad2a 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -2314,12 +2314,7 @@ static int pl022_suspend(struct device *dev)
   return status;
   }
  
 - amba_vcore_enable(pl022-adev);
 - amba_pclk_enable(pl022-adev);
 - load_ssp_default_config(pl022);
 - amba_pclk_disable(pl022-adev);
 - amba_vcore_disable(pl022-adev);
 - dev_dbg(dev, suspended\n);
 + dev_dbg(adev-dev, suspended\n);

why adev-dev instead of dev?

   return 0;
  }
  


-- 
viresh

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 5/6] spi/pl022: move device disable to workqueue thread

2011-11-09 Thread Viresh Kumar
On 11/9/2011 4:09 PM, Linus WALLEIJ wrote:
 From: Chris Blair chris.bl...@stericsson.com

 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index bffad2a..2e3522d 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -512,13 +512,6 @@ static void giveback(struct pl022 *pl022)
   msg-state = NULL;
   if (msg-complete)
   msg-complete(msg-context);
 -
 - /* disable the SPI/SSP operation */
 - writew((readw(SSP_CR1(pl022-virtbase)) 
 - (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022-virtbase));
 -

We added this in an earlier patch in the same patchset. It would be better
if we can shift that patch after this one.

 - /* This message is completed, so let's turn off the clocks  power */
 - pm_runtime_put(pl022-adev-dev);
  }
  
  /**
 @@ -1513,10 +1506,17 @@ static void pump_messages(struct work_struct *work)
   struct pl022 *pl022 =
   container_of(work, struct pl022, pump_messages);
   unsigned long flags;
 + bool was_busy = false;
  
   /* Lock queue and check for queue work */
   spin_lock_irqsave(pl022-queue_lock, flags);
   if (list_empty(pl022-queue) || !pl022-running) {
 + if (pl022-busy) {
 + /* nothing more to do - disable spi/ssp and power off */
 + writew((readw(SSP_CR1(pl022-virtbase)) 
 + (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022-virtbase));
 + pm_runtime_put(pl022-adev-dev);
 + }

Probably it will look better if we add a blank line here.

-- 
viresh

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 6/6] spi/pl022: add support for pm_runtime autosuspend

2011-11-09 Thread Viresh Kumar
On 11/9/2011 4:09 PM, Linus WALLEIJ wrote:
 From: Chris Blair chris.bl...@stericsson.com
 
 Adds support for configuring the spi bus to 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, the call to resume the device can return
 immediately rather than needing to risk sleeping in order to resume
 the device.
 
 Signed-off-by: Chris Blair chris.bl...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
  drivers/spi/spi-pl022.c|   20 ++--
  include/linux/amba/pl022.h |4 
  2 files changed, 22 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index 2e3522d..d3d6521 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -1515,7 +1515,13 @@ static void pump_messages(struct work_struct *work)
   /* nothing more to do - disable spi/ssp and power off */
   writew((readw(SSP_CR1(pl022-virtbase)) 
   (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022-virtbase));
 - pm_runtime_put(pl022-adev-dev);
 +
 + if (pl022-master_info-autosuspend_delay  0) {
 + pm_runtime_mark_last_busy(pl022-adev-dev);
 + pm_runtime_put_autosuspend(pl022-adev-dev);
 + } else {
 + pm_runtime_put(pl022-adev-dev);
 + }
   }
   pl022-busy = false;
   spin_unlock_irqrestore(pl022-queue_lock, flags);
 @@ -2245,7 +2251,17 @@ pl022_probe(struct amba_device *adev, const struct 
 amba_id *id)
   dev_dbg(dev, probe succeeded\n);
  
   /* let runtime pm put suspend */
 - pm_runtime_put(dev);
 + if (platform_info-autosuspend_delay  0) {
 + dev_info(adev-dev,
 + will use autosuspend for runtime pm, delay %dms\n,
 + platform_info-autosuspend_delay);
 + pm_runtime_set_autosuspend_delay(dev,
 + platform_info-autosuspend_delay);
 + pm_runtime_use_autosuspend(dev);
 + pm_runtime_put_autosuspend(dev);
 + } else {
 + pm_runtime_put(dev);
 + }
   return 0;
  
   err_spi_register:
 diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h
 index 4ce98f5..572f637 100644
 --- a/include/linux/amba/pl022.h
 +++ b/include/linux/amba/pl022.h
 @@ -238,6 +238,9 @@ struct dma_chan;
   * @enable_dma: if true enables DMA driven transfers.
   * @dma_rx_param: parameter to locate an RX DMA channel.
   * @dma_tx_param: parameter to locate a TX DMA channel.
 + * @autosuspend_delay: delay in ms following transfer completion before the
 + * runtime power management system suspends the device. A setting of 0
 + * indicates no delay and the device will be suspended immediately.
   */
  struct pl022_ssp_controller {
   u16 bus_id;
 @@ -246,6 +249,7 @@ struct pl022_ssp_controller {
   bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
   void *dma_rx_param;
   void *dma_tx_param;
 + int autosuspend_delay;
  };
  
  /**

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
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/pl022: fix build warnings

2011-10-18 Thread Viresh Kumar
On 10/17/2011 6:42 PM, Linus WALLEIJ wrote:
 From: Jonas Aaberg jonas.ab...@stericsson.com
 
 The driver build complains with newer compilers unless you
 initialize this struct properly.
 
 Signed-off-by: Jonas Aaberg jonas.ab...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
  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 debdaeb..91700bb 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -1930,7 +1930,7 @@ static int pl022_setup(struct spi_device *spi)
  {
   struct pl022_config_chip const *chip_info;
   struct chip_data *chip;
 - struct ssp_clock_params clk_freq = {0, };
 + struct ssp_clock_params clk_freq = { .cpsdvsr = 0, .scr = 0};
   int status = 0;
   struct pl022 *pl022 = spi_master_get_devdata(spi-master);
   unsigned int bits = spi-bits_per_word;

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 3/3] spi/pl022: skip default configuration before suspending

2011-10-18 Thread Viresh Kumar
On 10/17/2011 6:42 PM, Linus WALLEIJ wrote:
 From: Virupax Sadashivpetimath virupax.sadashivpetim...@stericsson.com
 
 The loading of the default configuration before suspending has
 been in the driver since its inception, but it is not really
 needed. Especially so since we take to all the trouble of
 enabling and disabling power and clock just to do this. Let's
 scrap this now.
 
 Signed-off-by: Virupax Sadashivpetimath 
 virupax.sadashivpetim...@stericsson.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 ---
  drivers/spi/spi-pl022.c |5 -
  1 files changed, 0 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
 index 0a1d8ed..29dc70f 100644
 --- a/drivers/spi/spi-pl022.c
 +++ b/drivers/spi/spi-pl022.c
 @@ -2342,11 +2342,6 @@ static int pl022_suspend(struct amba_device *adev, 
 pm_message_t state)
   return status;
   }
  
 - amba_vcore_enable(adev);
 - amba_pclk_enable(adev);
 - load_ssp_default_config(pl022);
 - amba_pclk_disable(adev);
 - amba_vcore_disable(adev);
   dev_dbg(adev-dev, suspended\n);
   return 0;
  }

Reviewed-by: Viresh Kumar viresh.ku...@st.com

-- 
viresh

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH V2 0/6] spi/spi-pl022 fixes

2011-09-20 Thread Viresh Kumar
On 9/1/2011 4:26 PM, Linus Walleij wrote:
 I agree. Acked-by: Linus Walleij linus.wall...@linaro.org for
 all except 6/6, it's probably just as possible to keep the channel handle
 taken in the driver if we modify the affected DMA driver instead.
 This would be better for performance I think.

Hi Grant,

Any updates on this?

-- 
viresh

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH V2 0/6] spi/spi-pl022 fixes

2011-09-01 Thread Viresh Kumar
On 8/10/2011 2:20 PM, Viresh KUMAR wrote:
 Hi Grant,
 
 I have added Tested-by: Linus Walleij linus.wall...@linaro.org on all 
 patches.
 
 This patchset mainly covers following fixes:
 - formatting related issues
 - Passing GFP_ATOMIC for sg allocation from tasklet
 - Fixing calculate_effective_freq() routine
 - Allocate/free DMA channels as and when required.
 

Grant,

Did you already pushed this patchset?
There are few concerns on PATCH 6/6 and i am not sure if there are any decisions
on it.
@Linus: What do you say?

So, probably you can push first 5 patches for now.

--
viresh

--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V2 2/6] spi/spi-pl022: Use GFP_ATOMIC for allocation from tasklet

2011-08-10 Thread Viresh Kumar
tasklets don't allow invocation to sleeping routines. In configure_dma()
routine, sg_alloc_table() was called with GFP_KERNEL flag and so this causes
crash when called from tasklet.

Replace GFP_KERNEL with GFP_ATOMIC to get this fixed.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/spi-pl022.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index f600d00..80116be 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1019,11 +1019,11 @@ static int configure_dma(struct pl022 *pl022)
pages = (pl022-cur_transfer-len  PAGE_SHIFT) + 1;
dev_dbg(pl022-adev-dev, using %d pages for transfer\n, pages);
 
-   ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_KERNEL);
+   ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_ATOMIC);
if (ret)
goto err_alloc_rx_sg;
 
-   ret = sg_alloc_table(pl022-sgt_tx, pages, GFP_KERNEL);
+   ret = sg_alloc_table(pl022-sgt_tx, pages, GFP_ATOMIC);
if (ret)
goto err_alloc_tx_sg;
 
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V2 1/6] spi/spi-pl022: Resolve formatting issues

2011-08-10 Thread Viresh Kumar
There were few formatting related issues in code. This patch fixes them.
Fixes include:
- Remove extra blank lines
- align code to 80 cols
- combine several lines to one line
- Replace multiple spaces with tabs
- Remove spaces before labels

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/spi-pl022.c |   54 +-
 1 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 730b4a3..f600d00 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -113,7 +113,6 @@
 #define SSP_CR0_MASK_CSS_ST(0x1FUL  16)
 #define SSP_CR0_MASK_FRF_ST(0x3UL  21)
 
-
 /*
  * SSP Control Register 0  - SSP_CR1
  */
@@ -283,7 +282,6 @@
 
 #define SPI_POLLING_TIMEOUT 1000
 
-
 /*
  * The type of reading going on on this chip
  */
@@ -752,7 +750,6 @@ static void readwriter(struct pl022 *pl022)
 */
 }
 
-
 /**
  * next_transfer - Move to the Next transfer in the current spi message
  * @pl022: SSP driver private data structure
@@ -1534,8 +1531,7 @@ static void pump_messages(struct work_struct *work)
/* Initial message state */
pl022-cur_msg-state = STATE_START;
pl022-cur_transfer = list_entry(pl022-cur_msg-transfers.next,
-   struct spi_transfer,
-   transfer_list);
+   struct spi_transfer, transfer_list);
 
/* Setup the SPI using the per chip configuration */
pl022-cur_chip = spi_get_ctldata(pl022-cur_msg-spi);
@@ -1557,7 +1553,6 @@ static void pump_messages(struct work_struct *work)
do_interrupt_dma_transfer(pl022);
 }
 
-
 static int __init init_queue(struct pl022 *pl022)
 {
INIT_LIST_HEAD(pl022-queue);
@@ -1566,8 +1561,8 @@ static int __init init_queue(struct pl022 *pl022)
pl022-running = false;
pl022-busy = false;
 
-   tasklet_init(pl022-pump_transfers,
-   pump_transfers, (unsigned long)pl022);
+   tasklet_init(pl022-pump_transfers, pump_transfers,
+   (unsigned long)pl022);
 
INIT_WORK(pl022-pump_messages, pump_messages);
pl022-workqueue = create_singlethread_workqueue(
@@ -1578,7 +1573,6 @@ static int __init init_queue(struct pl022 *pl022)
return 0;
 }
 
-
 static int start_queue(struct pl022 *pl022)
 {
unsigned long flags;
@@ -1601,7 +1595,6 @@ static int start_queue(struct pl022 *pl022)
return 0;
 }
 
-
 static int stop_queue(struct pl022 *pl022)
 {
unsigned long flags;
@@ -1861,7 +1854,6 @@ static int calculate_effective_freq(struct pl022 *pl022,
return 0;
 }
 
-
 /*
  * A piece of default chip info unless the platform
  * supplies it.
@@ -1879,7 +1871,6 @@ static const struct pl022_config_chip 
pl022_default_chip_info = {
.cs_control = null_cs_control,
 };
 
-
 /**
  * pl022_setup - setup function registered to SPI master framework
  * @spi: spi device which is requesting setup
@@ -1956,7 +1947,6 @@ static int pl022_setup(struct spi_device *spi)
goto err_config_params;
}
 
-
status = verify_controller_parameters(pl022, chip_info);
if (status) {
dev_err(spi-dev, controller data is incorrect);
@@ -2096,12 +2086,13 @@ static int pl022_setup(struct spi_device *spi)
}
SSP_WRITE_BITS(chip-cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1);
SSP_WRITE_BITS(chip-cr1, chip_info-hierarchy, SSP_CR1_MASK_MS, 2);
-   SSP_WRITE_BITS(chip-cr1, chip_info-slave_tx_disable, 
SSP_CR1_MASK_SOD, 3);
+   SSP_WRITE_BITS(chip-cr1, chip_info-slave_tx_disable, SSP_CR1_MASK_SOD,
+   3);
 
/* Save controller_state */
spi_set_ctldata(spi, chip);
return status;
- err_config_params:
+err_config_params:
spi_set_ctldata(spi, NULL);
kfree(chip);
return status;
@@ -2122,7 +2113,6 @@ static void pl022_cleanup(struct spi_device *spi)
kfree(chip);
 }
 
-
 static int __devinit
 pl022_probe(struct amba_device *adev, const struct amba_id *id)
 {
@@ -2243,23 +2233,23 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
amba_vcore_disable(adev);
return 0;
 
- err_spi_register:
- err_start_queue:
- err_init_queue:
+err_spi_register:
+err_start_queue:
+err_init_queue:
destroy_queue(pl022);
pl022_dma_remove(pl022);
free_irq(adev-irq[0], pl022);
pm_runtime_disable(adev-dev);
- err_no_irq:
+err_no_irq:
clk_put(pl022-clk);
- err_no_clk:
+err_no_clk:
iounmap(pl022-virtbase);
- err_no_ioremap:
+err_no_ioremap:
amba_release_regions(adev);
- err_no_ioregion:
+err_no_ioregion:
spi_master_put(master);
- err_no_master:
- err_no_pdata:
+err_no_master:
+err_no_pdata:
return status;
 }
 
@@ -2337,7 +2327,6 @@ static struct vendor_data

[PATCH V2 4/6] spi/spi-pl022: calculate_effective_freq() must set rate = requested rate

2011-08-10 Thread Viresh Kumar
There were few issues with calculate_effective_freq() routine:
- It was returning first rate found = requested rate. Now, if system have spi's
  rate as 83 MHz, with possible prescaled rates as 83, 41.5, 20.75, 13.83 (as we
  can prescale with multiples of 2). If user has given rate to be programmed as
  22 MHz, then driver programmes it to 41.5 MHz. This looks to be incorrect, as
  user might have given the upper limit of the device, and we are programming it
  above it.
- Driver finds the first satisfying rate and programmes it, but with other
  values of scr  cpsdvsr, it is possible to get more closer rate.

This patch fixes these two issues, with some reformatting inside the code.  This
also creates a inline routine to calculate prescaled rate based on spi's rate,
cpsdvsr and scr.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/spi-pl022.c |  102 +++---
 1 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 1c8b9ec..d1bcc79 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1791,67 +1791,67 @@ static int pl022_transfer(struct spi_device *spi, 
struct spi_message *msg)
return 0;
 }
 
-static int calculate_effective_freq(struct pl022 *pl022,
-   int freq,
-   struct ssp_clock_params *clk_freq)
+static inline u32 spi_rate(u32 rate, u16 cpsdvsr, u16 scr)
+{
+   return rate / (cpsdvsr * (1 + scr));
+}
+
+static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
+   ssp_clock_params * clk_freq)
 {
/* Lets calculate the frequency parameters */
-   u16 cpsdvsr = 2;
-   u16 scr = 0;
-   bool freq_found = false;
-   u32 rate;
-   u32 max_tclk;
-   u32 min_tclk;
+   u16 cpsdvsr = CPSDVR_MIN, scr = SCR_MIN;
+   u32 rate, max_tclk, min_tclk, best_freq = 0, best_cpsdvsr = 0,
+   best_scr = 0, tmp, found = 0;
 
rate = clk_get_rate(pl022-clk);
/* cpsdvscr = 2  scr 0 */
-   max_tclk = (rate / (CPSDVR_MIN * (1 + SCR_MIN)));
+   max_tclk = spi_rate(rate, CPSDVR_MIN, SCR_MIN);
/* cpsdvsr = 254  scr = 255 */
-   min_tclk = (rate / (CPSDVR_MAX * (1 + SCR_MAX)));
-
-   if ((freq = max_tclk)  (freq = min_tclk)) {
-   while (cpsdvsr = CPSDVR_MAX  !freq_found) {
-   while (scr = SCR_MAX  !freq_found) {
-   if ((rate /
-(cpsdvsr * (1 + scr)))  freq)
-   scr += 1;
-   else {
-   /*
-* This bool is made true when
-* effective frequency =
-* target frequency is found
-*/
-   freq_found = true;
-   if ((rate /
-(cpsdvsr * (1 + scr))) != freq) {
-   if (scr == SCR_MIN) {
-   cpsdvsr -= 2;
-   scr = SCR_MAX;
-   } else
-   scr -= 1;
-   }
-   }
-   }
-   if (!freq_found) {
-   cpsdvsr += 2;
-   scr = SCR_MIN;
-   }
-   }
-   if (cpsdvsr != 0) {
-   dev_dbg(pl022-adev-dev,
-   SSP Effective Frequency is %u\n,
-   (rate / (cpsdvsr * (1 + scr;
-   clk_freq-cpsdvsr = (u8) (cpsdvsr  0xFF);
-   clk_freq-scr = (u8) (scr  0xFF);
-   dev_dbg(pl022-adev-dev,
-   SSP cpsdvsr = %d, scr = %d\n,
-   clk_freq-cpsdvsr, clk_freq-scr);
-   }
-   } else {
+   min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
+
+   if (!((freq = max_tclk)  (freq = min_tclk))) {
dev_err(pl022-adev-dev,
controller data is incorrect: out of range frequency);
return -EINVAL;
}
+
+   /*
+* best_freq will give closest possible available rate (= requested
+* freq) for all values of scr  cpsdvsr.
+*/
+   while ((cpsdvsr = CPSDVR_MAX)  !found) {
+   while (scr = SCR_MAX) {
+   tmp = spi_rate(rate, cpsdvsr, scr

[PATCH V2 3/6] spi/spi-pl022: Don't allocate more sg than required.

2011-08-10 Thread Viresh Kumar
In routine configure_dma(), if transfer-len = PAGE_SIZE, then pages is one more
than required. While leads to one more sg getting allocated.

This is wrong. Correct this to allocate correct number of sg.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/spi-pl022.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 80116be..1c8b9ec 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1016,7 +1016,8 @@ static int configure_dma(struct pl022 *pl022)
dmaengine_slave_config(txchan, tx_conf);
 
/* Create sglists for the transfers */
-   pages = (pl022-cur_transfer-len  PAGE_SHIFT) + 1;
+   pages = ((pl022-cur_transfer-len + (1  PAGE_SHIFT) - 1)
+PAGE_SHIFT);
dev_dbg(pl022-adev-dev, using %d pages for transfer\n, pages);
 
ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_ATOMIC);
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V2 5/6] spi/spi-pl022: Call pl022_dma_remove(pl022) only if enable_dma is true

2011-08-10 Thread Viresh Kumar
pl022_dma_remove() should be called only if enable_dma is true. There is no
point calling it when pl022_dma_probe() is not called, which again depends on
enable_dma.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/spi-pl022.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index d1bcc79..01e84e3 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2238,7 +2238,9 @@ err_spi_register:
 err_start_queue:
 err_init_queue:
destroy_queue(pl022);
-   pl022_dma_remove(pl022);
+   if (platform_info-enable_dma)
+   pl022_dma_remove(pl022);
+
free_irq(adev-irq[0], pl022);
pm_runtime_disable(adev-dev);
 err_no_irq:
@@ -2266,7 +2268,9 @@ pl022_remove(struct amba_device *adev)
if (destroy_queue(pl022) != 0)
dev_err(adev-dev, queue remove failed\n);
load_ssp_default_config(pl022);
-   pl022_dma_remove(pl022);
+   if (pl022-master_info-enable_dma)
+   pl022_dma_remove(pl022);
+
free_irq(adev-irq[0], pl022);
clk_disable(pl022-clk);
clk_put(pl022-clk);
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH V2 6/6] spi/spi-pl022: Request/free DMA channels as and when required.

2011-08-10 Thread viresh kumar
On 08/10/2011 02:30 PM, Russell King - ARM Linux wrote:
  They must be allocated when they are required and must be freed after we 
  are
  done with transfers. So that they can be used by other users.
 Which DMA engine driver requires this?
 

dw_dmac.c

 Normally, when we have DMA engine drivers with multiple request signals,
 the slave peripheral side publishes several virtual channels which are
 claimed by the peripheral drivers.  This (amongst other things) allows
 the peripheral drivers to hold claim to one of the virtual channels
 all the time that it's required.

If users of DMA expect DMA engine drivers to work this way, then we should
have this mentioned clearly in DMA slave documentation.

@Dan/Vinod: What do you say?

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH V2 3/6] spi/spi-pl022: Don't allocate more sg than required.

2011-08-10 Thread viresh kumar
On 08/10/2011 02:24 PM, Russell King - ARM Linux wrote:
 It would be far better for this to be:
 
   pages = DIV_ROUND_UP(pl022-cur_transfer-len, PAGE_SIZE);
 
 The compiler will probably optimize it to the same code anyway.

I thought of it too, but missed to update code. Thanks.

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V2 6/6] spi/spi-pl022: Request/free DMA channels as and when required.

2011-08-10 Thread Viresh Kumar
Currently we request DMA channels at probe time and free them at remove. They
are always occupied, irrespective of their usage.

They must be allocated when they are required and must be freed after we are
done with transfers. So that they can be used by other users.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/spi-pl022.c |   98 +-
 1 files changed, 70 insertions(+), 28 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 01e84e3..a596b96 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -389,6 +389,7 @@ struct pl022 {
struct sg_table sgt_rx;
struct sg_table sgt_tx;
char*dummypage;
+   dma_cap_mask_t  mask;
 #endif
 };
 
@@ -1093,16 +1094,33 @@ err_alloc_rx_sg:
 
 static int __init pl022_dma_probe(struct pl022 *pl022)
 {
-   dma_cap_mask_t mask;
+   /* set dma mask */
+   dma_cap_zero(pl022-mask);
+   dma_cap_set(DMA_SLAVE, pl022-mask);
 
-   /* Try to acquire a generic DMA engine slave channel */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
+   pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
+   if (!pl022-dummypage) {
+   dev_err(pl022-adev-dev,
+   Failed to work in dma mode, work without dma!\n);
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+static int pl022_alloc_dmachan(struct pl022 *pl022)
+{
/*
-* We need both RX and TX channels to do DMA, else do none
-* of them.
+* Both channels should be allocated or not allocated. It is wrong if
+* only one allocated
 */
-   pl022-dma_rx_channel = dma_request_channel(mask,
+   if (pl022-dma_rx_channel  pl022-dma_tx_channel)
+   return 0;
+
+   BUG_ON(pl022-dma_rx_channel || pl022-dma_tx_channel);
+
+   /* We need both RX and TX channels to do DMA, else do none of them. */
+   pl022-dma_rx_channel = dma_request_channel(pl022-mask,
pl022-master_info-dma_filter,
pl022-master_info-dma_rx_param);
if (!pl022-dma_rx_channel) {
@@ -1110,7 +1128,7 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
goto err_no_rxchan;
}
 
-   pl022-dma_tx_channel = dma_request_channel(mask,
+   pl022-dma_tx_channel = dma_request_channel(pl022-mask,
pl022-master_info-dma_filter,
pl022-master_info-dma_tx_param);
if (!pl022-dma_tx_channel) {
@@ -1118,20 +1136,12 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
goto err_no_txchan;
}
 
-   pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
-   if (!pl022-dummypage) {
-   dev_dbg(pl022-adev-dev, no DMA dummypage!\n);
-   goto err_no_dummypage;
-   }
-
-   dev_info(pl022-adev-dev, setup for DMA on RX %s, TX %s\n,
+   dev_dbg(pl022-adev-dev, setup for DMA on RX %s, TX %s\n,
 dma_chan_name(pl022-dma_rx_channel),
 dma_chan_name(pl022-dma_tx_channel));
 
return 0;
 
-err_no_dummypage:
-   dma_release_channel(pl022-dma_tx_channel);
 err_no_txchan:
dma_release_channel(pl022-dma_rx_channel);
pl022-dma_rx_channel = NULL;
@@ -1143,22 +1153,30 @@ err_no_rxchan:
 
 static void terminate_dma(struct pl022 *pl022)
 {
-   struct dma_chan *rxchan = pl022-dma_rx_channel;
-   struct dma_chan *txchan = pl022-dma_tx_channel;
-
-   dmaengine_terminate_all(rxchan);
-   dmaengine_terminate_all(txchan);
-   unmap_free_dma_scatter(pl022);
+   if (pl022-dma_rx_channel)
+   dmaengine_terminate_all(pl022-dma_rx_channel);
+   if (pl022-dma_tx_channel)
+   dmaengine_terminate_all(pl022-dma_tx_channel);
 }
 
-static void pl022_dma_remove(struct pl022 *pl022)
+static void pl022_free_dmachan(struct pl022 *pl022)
 {
-   if (pl022-busy)
-   terminate_dma(pl022);
if (pl022-dma_tx_channel)
dma_release_channel(pl022-dma_tx_channel);
if (pl022-dma_rx_channel)
dma_release_channel(pl022-dma_rx_channel);
+
+   pl022-dma_rx_channel = pl022-dma_tx_channel = NULL;
+}
+
+static void pl022_dma_remove(struct pl022 *pl022)
+{
+   if (pl022-busy) {
+   terminate_dma(pl022);
+   unmap_free_dma_scatter(pl022);
+   }
+
+   pl022_free_dmachan(pl022);
kfree(pl022-dummypage);
 }
 
@@ -1176,6 +1194,19 @@ static inline int pl022_dma_probe(struct pl022 *pl022)
 static inline void pl022_dma_remove(struct pl022 *pl022)
 {
 }
+
+static inline int pl022_alloc_dmachan(struct pl022 *pl022)
+{
+   return 0;
+}
+
+static inline void

Re: [PATCH V2 6/6] spi/spi-pl022: Request/free DMA channels as and when required.

2011-08-10 Thread viresh kumar
On 08/10/2011 03:31 PM, Koul, Vinod wrote:
 And on your patch, are you able to dynamically assign the channels for
 platform? What is the intended usage? (as Russell articulated it is bad
 to dynamically assign channel for something like uart)

Are you talking about channels or DMA request lines? For channels yes,
we can always allocate channels as they are independent of peripherals.
About request lines, they are muxed in our case between several
peripherals, but support for that has to be added in dw_dmac.

SPI is not as much heavily used as uart. So, it might be fine there to
allocate channels dynamically.

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 3/6] spi/spi-pl022: Don't allocate more sg than required.

2011-08-10 Thread Viresh Kumar
In routine configure_dma(), if transfer-len = PAGE_SIZE, then pages is one more
than required. While leads to one more sg getting allocated.

This is wrong. Correct this to allocate correct number of sg.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Tested-by: Linus Walleij linus.wall...@linaro.org
---
 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 80116be..832361e3a 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1016,7 +1016,7 @@ static int configure_dma(struct pl022 *pl022)
dmaengine_slave_config(txchan, tx_conf);
 
/* Create sglists for the transfers */
-   pages = (pl022-cur_transfer-len  PAGE_SHIFT) + 1;
+   pages = DIV_ROUND_UP(pl022-cur_transfer-len, PAGE_SIZE);
dev_dbg(pl022-adev-dev, using %d pages for transfer\n, pages);
 
ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_ATOMIC);
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH V2 3/6] spi/spi-pl022: Don't allocate more sg than required.

2011-08-10 Thread viresh kumar
On 08/10/2011 05:12 PM, Sergei Shtylyov wrote:
  -  pages = (pl022-cur_transfer-len  PAGE_SHIFT) + 1;
  +  pages = ((pl022-cur_transfer-len + (1  PAGE_SHIFT) - 1)
  +PAGE_SHIFT);
 No need for parens around the rvalue.

Oops, that was a mistake. Anyway i have send V3 for the same and this issue
is not present anymore.

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 1/6] spi/spi-pl022: Resolve formatting issues

2011-08-09 Thread Viresh Kumar
There were few formatting related issues in code. This patch fixes them.
Fixes include:
- Remove extra blank lines
- align code to 80 cols
- combine several lines to one line
- Replace multiple spaces with tabs
- Remove spaces before labels

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/spi-pl022.c |   54 +-
 1 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 730b4a3..f600d00 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -113,7 +113,6 @@
 #define SSP_CR0_MASK_CSS_ST(0x1FUL  16)
 #define SSP_CR0_MASK_FRF_ST(0x3UL  21)
 
-
 /*
  * SSP Control Register 0  - SSP_CR1
  */
@@ -283,7 +282,6 @@
 
 #define SPI_POLLING_TIMEOUT 1000
 
-
 /*
  * The type of reading going on on this chip
  */
@@ -752,7 +750,6 @@ static void readwriter(struct pl022 *pl022)
 */
 }
 
-
 /**
  * next_transfer - Move to the Next transfer in the current spi message
  * @pl022: SSP driver private data structure
@@ -1534,8 +1531,7 @@ static void pump_messages(struct work_struct *work)
/* Initial message state */
pl022-cur_msg-state = STATE_START;
pl022-cur_transfer = list_entry(pl022-cur_msg-transfers.next,
-   struct spi_transfer,
-   transfer_list);
+   struct spi_transfer, transfer_list);
 
/* Setup the SPI using the per chip configuration */
pl022-cur_chip = spi_get_ctldata(pl022-cur_msg-spi);
@@ -1557,7 +1553,6 @@ static void pump_messages(struct work_struct *work)
do_interrupt_dma_transfer(pl022);
 }
 
-
 static int __init init_queue(struct pl022 *pl022)
 {
INIT_LIST_HEAD(pl022-queue);
@@ -1566,8 +1561,8 @@ static int __init init_queue(struct pl022 *pl022)
pl022-running = false;
pl022-busy = false;
 
-   tasklet_init(pl022-pump_transfers,
-   pump_transfers, (unsigned long)pl022);
+   tasklet_init(pl022-pump_transfers, pump_transfers,
+   (unsigned long)pl022);
 
INIT_WORK(pl022-pump_messages, pump_messages);
pl022-workqueue = create_singlethread_workqueue(
@@ -1578,7 +1573,6 @@ static int __init init_queue(struct pl022 *pl022)
return 0;
 }
 
-
 static int start_queue(struct pl022 *pl022)
 {
unsigned long flags;
@@ -1601,7 +1595,6 @@ static int start_queue(struct pl022 *pl022)
return 0;
 }
 
-
 static int stop_queue(struct pl022 *pl022)
 {
unsigned long flags;
@@ -1861,7 +1854,6 @@ static int calculate_effective_freq(struct pl022 *pl022,
return 0;
 }
 
-
 /*
  * A piece of default chip info unless the platform
  * supplies it.
@@ -1879,7 +1871,6 @@ static const struct pl022_config_chip 
pl022_default_chip_info = {
.cs_control = null_cs_control,
 };
 
-
 /**
  * pl022_setup - setup function registered to SPI master framework
  * @spi: spi device which is requesting setup
@@ -1956,7 +1947,6 @@ static int pl022_setup(struct spi_device *spi)
goto err_config_params;
}
 
-
status = verify_controller_parameters(pl022, chip_info);
if (status) {
dev_err(spi-dev, controller data is incorrect);
@@ -2096,12 +2086,13 @@ static int pl022_setup(struct spi_device *spi)
}
SSP_WRITE_BITS(chip-cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1);
SSP_WRITE_BITS(chip-cr1, chip_info-hierarchy, SSP_CR1_MASK_MS, 2);
-   SSP_WRITE_BITS(chip-cr1, chip_info-slave_tx_disable, 
SSP_CR1_MASK_SOD, 3);
+   SSP_WRITE_BITS(chip-cr1, chip_info-slave_tx_disable, SSP_CR1_MASK_SOD,
+   3);
 
/* Save controller_state */
spi_set_ctldata(spi, chip);
return status;
- err_config_params:
+err_config_params:
spi_set_ctldata(spi, NULL);
kfree(chip);
return status;
@@ -2122,7 +2113,6 @@ static void pl022_cleanup(struct spi_device *spi)
kfree(chip);
 }
 
-
 static int __devinit
 pl022_probe(struct amba_device *adev, const struct amba_id *id)
 {
@@ -2243,23 +2233,23 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
amba_vcore_disable(adev);
return 0;
 
- err_spi_register:
- err_start_queue:
- err_init_queue:
+err_spi_register:
+err_start_queue:
+err_init_queue:
destroy_queue(pl022);
pl022_dma_remove(pl022);
free_irq(adev-irq[0], pl022);
pm_runtime_disable(adev-dev);
- err_no_irq:
+err_no_irq:
clk_put(pl022-clk);
- err_no_clk:
+err_no_clk:
iounmap(pl022-virtbase);
- err_no_ioremap:
+err_no_ioremap:
amba_release_regions(adev);
- err_no_ioregion:
+err_no_ioregion:
spi_master_put(master);
- err_no_master:
- err_no_pdata:
+err_no_master:
+err_no_pdata:
return status;
 }
 
@@ -2337,7 +2327,6 @@ static struct vendor_data vendor_arm = {
.loopback = true

[PATCH 5/6] spi/spi-pl022: Call pl022_dma_remove(pl022) only if enable_dma is true

2011-08-09 Thread Viresh Kumar
pl022_dma_remove() should be called only if enable_dma is true. There is no
point calling it when pl022_dma_probe() is not called, which again depends on
enable_dma.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/spi-pl022.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index e0cfb8c..e2333e7 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2234,7 +2234,9 @@ err_spi_register:
 err_start_queue:
 err_init_queue:
destroy_queue(pl022);
-   pl022_dma_remove(pl022);
+   if (platform_info-enable_dma)
+   pl022_dma_remove(pl022);
+
free_irq(adev-irq[0], pl022);
pm_runtime_disable(adev-dev);
 err_no_irq:
@@ -2262,7 +2264,9 @@ pl022_remove(struct amba_device *adev)
if (destroy_queue(pl022) != 0)
dev_err(adev-dev, queue remove failed\n);
load_ssp_default_config(pl022);
-   pl022_dma_remove(pl022);
+   if (pl022-master_info-enable_dma)
+   pl022_dma_remove(pl022);
+
free_irq(adev-irq[0], pl022);
clk_disable(pl022-clk);
clk_put(pl022-clk);
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 0/6] spi/spi-pl022 fixes

2011-08-09 Thread Viresh Kumar
Hi Linus,

This patchset mainly covers following fixes:
- formatting related issues
- Passing GFP_NOWAIT for sg allocation from tasklet
- Fixing calculate_effective_freq() routine
- Allocate/free DMA channels as and when required.

I have rebased them on linux-next/master over following patch:

commit 9be355da3bae9feb09cdaf80c3ab560f1f0172cb
Author: Stephen Rothwell s...@canb.auug.org.au
Date:   Tue Aug 9 13:30:19 2011 +1000

Add linux-next specific files for 20110809

Signed-off-by: Stephen Rothwell s...@canb.auug.org.au

Looking forward to see your view on the patchset.

Viresh Kumar (6):
  spi/spi-pl022: Resolve formatting issues
  spi/spi-pl022: Use GFP_NOWAIT for allocation from tasklet
  spi/spi-pl022: Don't allocate more sg than required.
  spi/spi-pl022: calculate_effective_freq() must set rate = requested
rate
  spi/spi-pl022: Call pl022_dma_remove(pl022) only if enable_dma is
true
  spi/spi-pl022: Request/free DMA channels as and when required.

 drivers/spi/spi-pl022.c |  265 ++-
 1 files changed, 147 insertions(+), 118 deletions(-)

-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 3/6] spi/spi-pl022: Don't allocate more sg than required.

2011-08-09 Thread Viresh Kumar
In routine configure_dma(), if transfer-len = PAGE_SIZE, then pages is one more
than required. While leads to one more sg getting allocated.

This is wrong. Correct this to allocate correct number of sg.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/spi-pl022.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index cbd9afe..452952b 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1016,7 +1016,8 @@ static int configure_dma(struct pl022 *pl022)
dmaengine_slave_config(txchan, tx_conf);
 
/* Create sglists for the transfers */
-   pages = (pl022-cur_transfer-len  PAGE_SHIFT) + 1;
+   pages = ((pl022-cur_transfer-len + (1  PAGE_SHIFT) - 1)
+PAGE_SHIFT);
dev_dbg(pl022-adev-dev, using %d pages for transfer\n, pages);
 
ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_NOWAIT);
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 6/6] spi/spi-pl022: Request/free DMA channels as and when required.

2011-08-09 Thread Viresh Kumar
Currently we request DMA channels at probe time and free them at remove. They
are always occupied, irrespective of their usage.

They must be allocated when they are required and must be freed after we are
done with transfers. So that they can be used by other users.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/spi-pl022.c |   98 +-
 1 files changed, 70 insertions(+), 28 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index e2333e7..3653f00 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -389,6 +389,7 @@ struct pl022 {
struct sg_table sgt_rx;
struct sg_table sgt_tx;
char*dummypage;
+   dma_cap_mask_t  mask;
 #endif
 };
 
@@ -1093,16 +1094,33 @@ err_alloc_rx_sg:
 
 static int __init pl022_dma_probe(struct pl022 *pl022)
 {
-   dma_cap_mask_t mask;
+   /* set dma mask */
+   dma_cap_zero(pl022-mask);
+   dma_cap_set(DMA_SLAVE, pl022-mask);
 
-   /* Try to acquire a generic DMA engine slave channel */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
+   pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
+   if (!pl022-dummypage) {
+   dev_err(pl022-adev-dev,
+   Failed to work in dma mode, work without dma!\n);
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+static int pl022_alloc_dmachan(struct pl022 *pl022)
+{
/*
-* We need both RX and TX channels to do DMA, else do none
-* of them.
+* Both channels should be allocated or not allocated. It is wrong if
+* only one allocated
 */
-   pl022-dma_rx_channel = dma_request_channel(mask,
+   if (pl022-dma_rx_channel  pl022-dma_tx_channel)
+   return 0;
+
+   BUG_ON(pl022-dma_rx_channel || pl022-dma_tx_channel);
+
+   /* We need both RX and TX channels to do DMA, else do none of them. */
+   pl022-dma_rx_channel = dma_request_channel(pl022-mask,
pl022-master_info-dma_filter,
pl022-master_info-dma_rx_param);
if (!pl022-dma_rx_channel) {
@@ -1110,7 +1128,7 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
goto err_no_rxchan;
}
 
-   pl022-dma_tx_channel = dma_request_channel(mask,
+   pl022-dma_tx_channel = dma_request_channel(pl022-mask,
pl022-master_info-dma_filter,
pl022-master_info-dma_tx_param);
if (!pl022-dma_tx_channel) {
@@ -1118,20 +1136,12 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
goto err_no_txchan;
}
 
-   pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
-   if (!pl022-dummypage) {
-   dev_dbg(pl022-adev-dev, no DMA dummypage!\n);
-   goto err_no_dummypage;
-   }
-
-   dev_info(pl022-adev-dev, setup for DMA on RX %s, TX %s\n,
+   dev_dbg(pl022-adev-dev, setup for DMA on RX %s, TX %s\n,
 dma_chan_name(pl022-dma_rx_channel),
 dma_chan_name(pl022-dma_tx_channel));
 
return 0;
 
-err_no_dummypage:
-   dma_release_channel(pl022-dma_tx_channel);
 err_no_txchan:
dma_release_channel(pl022-dma_rx_channel);
pl022-dma_rx_channel = NULL;
@@ -1143,22 +1153,30 @@ err_no_rxchan:
 
 static void terminate_dma(struct pl022 *pl022)
 {
-   struct dma_chan *rxchan = pl022-dma_rx_channel;
-   struct dma_chan *txchan = pl022-dma_tx_channel;
-
-   dmaengine_terminate_all(rxchan);
-   dmaengine_terminate_all(txchan);
-   unmap_free_dma_scatter(pl022);
+   if (pl022-dma_rx_channel)
+   dmaengine_terminate_all(pl022-dma_rx_channel);
+   if (pl022-dma_tx_channel)
+   dmaengine_terminate_all(pl022-dma_tx_channel);
 }
 
-static void pl022_dma_remove(struct pl022 *pl022)
+static void pl022_free_dmachan(struct pl022 *pl022)
 {
-   if (pl022-busy)
-   terminate_dma(pl022);
if (pl022-dma_tx_channel)
dma_release_channel(pl022-dma_tx_channel);
if (pl022-dma_rx_channel)
dma_release_channel(pl022-dma_rx_channel);
+
+   pl022-dma_rx_channel = pl022-dma_tx_channel = NULL;
+}
+
+static void pl022_dma_remove(struct pl022 *pl022)
+{
+   if (pl022-busy) {
+   terminate_dma(pl022);
+   unmap_free_dma_scatter(pl022);
+   }
+
+   pl022_free_dmachan(pl022);
kfree(pl022-dummypage);
 }
 
@@ -1176,6 +1194,19 @@ static inline int pl022_dma_probe(struct pl022 *pl022)
 static inline void pl022_dma_remove(struct pl022 *pl022)
 {
 }
+
+static inline int pl022_alloc_dmachan(struct pl022 *pl022)
+{
+   return 0;
+}
+
+static inline void terminate_dma(struct pl022 *pl022)
+{
+}
+
+static void

[PATCH 2/6] spi/spi-pl022: Use GFP_NOWAIT for allocation from tasklet

2011-08-09 Thread Viresh Kumar
tasklets don't allow invocation to sleeping routines. In configure_dma()
routine, sg_alloc_table() was called with GFP_KERNEL flag and so this causes
crash when called from tasklet.

Replace GFP_KERNEL with GFP_NOWAIT to get this fixed.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/spi-pl022.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index f600d00..cbd9afe 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1019,11 +1019,11 @@ static int configure_dma(struct pl022 *pl022)
pages = (pl022-cur_transfer-len  PAGE_SHIFT) + 1;
dev_dbg(pl022-adev-dev, using %d pages for transfer\n, pages);
 
-   ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_KERNEL);
+   ret = sg_alloc_table(pl022-sgt_rx, pages, GFP_NOWAIT);
if (ret)
goto err_alloc_rx_sg;
 
-   ret = sg_alloc_table(pl022-sgt_tx, pages, GFP_KERNEL);
+   ret = sg_alloc_table(pl022-sgt_tx, pages, GFP_NOWAIT);
if (ret)
goto err_alloc_tx_sg;
 
-- 
1.7.2.2


--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 2/6] spi/spi-pl022: Use GFP_NOWAIT for allocation from tasklet

2011-08-09 Thread viresh kumar
On 08/09/2011 04:56 PM, Jassi Brar wrote:
 Since this could be called from when we actually need the transfer start,
 maybe we could try harder using GFP_ATOMIC instead ?

Yes. Will do it.

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 4/6] spi/spi-pl022: calculate_effective_freq() must set rate = requested rate

2011-08-09 Thread viresh kumar
[Probably you missed reply-all by mistake, so adding them again]

On 08/10/2011 01:34 AM, Linus Walleij wrote:
 On Tue, Aug 9, 2011 at 1:05 PM, Viresh Kumar viresh.ku...@st.com wrote:
 
 There were few issues with calculate_effective_freq() routine:
 - It was returning first rate found = requested rate. Now, if system have 
 spi's
  rate as 83 MHz, with possible prescaled rates as 83, 41.5, 20.75, 13.83 (as 
 we
  can prescale with multiples of 2). If user has given rate to be programmed 
 as
  22 MHz, then driver programmes it to 41.5 MHz. This looks to be incorrect, 
 as
  user might have given the upper limit of the device, and we are programming 
 it
  above it.
 - Driver finds the first satisfying rate and programmes it, but with other
  values of scr  cpsdvsr, it is possible to get more closer rate.
 
 Good that you found this bug!
 
 +#define SPI_RATE(rate, cpsdvsr, scr)   (rate / (cpsdvsr * (1 + scr)))
 
 Can you use a static inline instead of a macro? It is often preferred.
 If you do, this is Acked-by.
 

Not a problem. Will surely do that.

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 0/6] spi/spi-pl022 fixes

2011-08-09 Thread viresh kumar
On 08/10/2011 01:40 AM, Linus Walleij wrote:
 On Tue, Aug 9, 2011 at 1:05 PM, Viresh Kumar viresh.ku...@st.com wrote:
 
 This patchset mainly covers following fixes:
 - formatting related issues
 - Passing GFP_NOWAIT for sg allocation from tasklet
 - Fixing calculate_effective_freq() routine
 - Allocate/free DMA channels as and when required.
 
 Excellent work Viresh, apart from the small comment on 4/6
 they all look good.
 
 I also tested them all on the U300, works perfectly.
 
 Please fixup 4/6 and respin with my:
 Tested-by: Linus Walleij linus.wall...@linaro.org

Thanks for testing.

 
 So that Grant can pick them up.
 
 I have rebased them on linux-next/master over following patch:

 commit 9be355da3bae9feb09cdaf80c3ab560f1f0172cb
 Author: Stephen Rothwell s...@canb.auug.org.au
 Date:   Tue Aug 9 13:30:19 2011 +1000

Add linux-next specific files for 20110809
 
 They all work perfectly well on top of v3.1-rc1, please use
 mainline kernel tags as patch base if you can.
 

Sure, can take care of this. But i have a doubt here,
What if a patch on the same driver is applied after kernel tag.
Shouldn't i rebase my patches on the latest commit available.

-- 
viresh

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: spi/spi-pl022: Query on working of DMA mode

2011-08-04 Thread viresh kumar
On 08/04/2011 03:46 PM, Linus Walleij wrote:
 No maybe not, my test cases are for single messages, and on production
 systems we mainly use IRQ-driven traffic. I need to have these
 tests added I believe :-/
 
 If you fix this up it will be much appreciated!

Ya I am fixing this up. I have resolved this yesterday only, with GFP_NOWAIT.
But it looks there are few more issues. Let me fix everything first
and then will send patchset with updates.

-- 
viresh

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


spi/spi-pl022: Query on working of DMA mode

2011-08-03 Thread viresh kumar

Hi Linus,

I am preparing few patches for spi-pl022 for Allocating DMA channels as and 
when required.
And i found something strange.

When we have many transfers in a single message, following routines are called 
in
specified order:

tasklet_schedule(pump_transfers)
pump_transfers(unsigned long data)
configure_dma(pl022)
sg_alloc_table(pl022-sgt_rx, pages, GFP_KERNEL);

Here, allocation is requested with GFP_KERNEL flag, from a tasklet.
Which gives following crash logs:

BUG: sleeping function called from invalid context at 
/data/csd_sw/spear/drives_os/vireshk/spear/kernel/linux-2.6/mm/slub.c:7
93
in_atomic(): 1, irqs_disabled(): 0, pid: 11, name: kworker/u:1
Backtrace: 
[8003dabc] (dump_backtrace+0x0/0x10c) from [803aa4ec] (dump_stack+0x18/0x1c)
 r6:0001 r5:00d0 r4:bf402200 r3:6113
[803aa4d4] (dump_stack+0x0/0x1c) from [8004f330] (__might_sleep+0xec/0x10c)
[8004f244] (__might_sleep+0x0/0x10c) from [800bbd2c] (__kmalloc+0x74/0x110)
[800bbcb8] (__kmalloc+0x0/0x110) from [8019f69c] (sg_kmalloc+0x2c/0x30)
 r8:80541b40 r7:0001 r6:0001 r5:0100 r4:bf47f1e8
r3:
[8019f670] (sg_kmalloc+0x0/0x30) from [8019f710] 
(__sg_alloc_table+0x70/0x118)
[8019f6a0] (__sg_alloc_table+0x0/0x118) from [8019f7e0] 
(sg_alloc_table+0x28/0x54)
[8019f7b8] (sg_alloc_table+0x0/0x54) from [802649a0] 
(configure_dma+0x230/0x3fc)
 r5:bf47def8 r4:bf47f150
[80264770] (configure_dma+0x0/0x3fc) from [8026509c] 
(pump_transfers+0xcc/0x100)
[80264fd0] (pump_transfers+0x0/0x100) from [8005ecb0] 
(tasklet_action+0xb0/0x160)
 r7:805203c4 r6:bf488000 r5:bf47f1a0 r4:bf47f19c
[8005ec00] (tasklet_action+0x0/0x160) from [8005f104] 
(__do_softirq+0xa4/0x13c)
[8005f060] (__do_softirq+0x0/0x13c) from [8005f590] (irq_exit+0x4c/0x54)
[8005f544] (irq_exit+0x0/0x54) from [80034094] (asm_do_IRQ+0x94/0xd0)
[80034000] (asm_do_IRQ+0x0/0xd0) from [800396f4] (__irq_svc+0x34/0xc0)
Exception stack(0xbf489e90 to 0xbf489ed8)


Now, i didn't get them earlier due to a mistake of mine. I have updated
pl022_ssp_controller.enable_dma = 1,
but didn't do pl022_config_chip.com_mode = DMA_TRANSFER

So, finally DMA channels are allocated but never used, as both above must have
been set.
Today only I came to know of this mistake, and found it is actually not
working, with above crash occurring.

Is DMA mode working in your case?

-- 
viresh

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH resend] spi/amba-pl022: work in polling or interrupt mode if pl022_dma_probe fails

2011-05-16 Thread viresh kumar
On 05/16/2011 04:34 PM, Russell King - ARM Linux wrote:
 On Mon, May 16, 2011 at 09:40:10AM +0530, Viresh Kumar wrote:
  If pl022_dma_probe fails, we can try to transfer data in polling or 
  interrupt
  mode. Also, set platform_info-enable_dma to 0, so that no other code 
  tries to
  use dma.
  
  Signed-off-by: Viresh Kumar viresh.ku...@st.com
  Acked-by: Linus Walleij linus.wall...@linaro.org
 Shouldn't this go via the SPI people rather than my tree?

This can, but i have seen amba drivers patches going through your
drivers branch, so sent to tracker. Should i get them through spi-devel??

-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH resend] spi/amba-pl022: work in polling or interrupt mode if pl022_dma_probe fails

2011-05-16 Thread viresh kumar
On 05/16/2011 09:40 AM, Viresh KUMAR wrote:
 If pl022_dma_probe fails, we can try to transfer data in polling or interrupt
 mode. Also, set platform_info-enable_dma to 0, so that no other code tries to
 use dma.
 
 Signed-off-by: Viresh Kumar viresh.ku...@st.com
 Acked-by: Linus Walleij linus.wall...@linaro.org
 ---
  drivers/spi/amba-pl022.c |   11 ++-
  1 files changed, 6 insertions(+), 5 deletions(-)
 

David,

Sorry for missing you earlier in to list. Can you please push this
through spi-devel tree.

--
viresh

 diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
 index dae886e..77f90de 100644
 --- a/drivers/spi/amba-pl022.c
 +++ b/drivers/spi/amba-pl022.c
 @@ -1068,7 +1068,7 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
   pl022-master_info-dma_filter,
   pl022-master_info-dma_rx_param);
   if (!pl022-dma_rx_channel) {
 - dev_err(pl022-adev-dev, no RX DMA channel!\n);
 + dev_dbg(pl022-adev-dev, no RX DMA channel!\n);
   goto err_no_rxchan;
   }
  
 @@ -1076,13 +1076,13 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
   pl022-master_info-dma_filter,
   pl022-master_info-dma_tx_param);
   if (!pl022-dma_tx_channel) {
 - dev_err(pl022-adev-dev, no TX DMA channel!\n);
 + dev_dbg(pl022-adev-dev, no TX DMA channel!\n);
   goto err_no_txchan;
   }
  
   pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
   if (!pl022-dummypage) {
 - dev_err(pl022-adev-dev, no DMA dummypage!\n);
 + dev_dbg(pl022-adev-dev, no DMA dummypage!\n);
   goto err_no_dummypage;
   }
  
 @@ -1098,6 +1098,8 @@ err_no_txchan:
   dma_release_channel(pl022-dma_rx_channel);
   pl022-dma_rx_channel = NULL;
  err_no_rxchan:
 + dev_err(pl022-adev-dev,
 + Failed to work in dma mode, work without dma!\n);
   return -ENODEV;
  }
  
 @@ -2111,7 +2113,7 @@ pl022_probe(struct amba_device *adev, const struct 
 amba_id *id)
   if (platform_info-enable_dma) {
   status = pl022_dma_probe(pl022);
   if (status != 0)
 - goto err_no_dma;
 + platform_info-enable_dma = 0;
   }
  
   /* Initialize and start queue */
 @@ -2143,7 +2145,6 @@ pl022_probe(struct amba_device *adev, const struct 
 amba_id *id)
   err_init_queue:
   destroy_queue(pl022);
   pl022_dma_remove(pl022);
 - err_no_dma:
   free_irq(adev-irq[0], pl022);
   err_no_irq:
   clk_put(pl022-clk);


-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH resend] spi/amba-pl022: work in polling or interrupt mode if pl022_dma_probe fails

2011-05-15 Thread Viresh Kumar
If pl022_dma_probe fails, we can try to transfer data in polling or interrupt
mode. Also, set platform_info-enable_dma to 0, so that no other code tries to
use dma.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
Acked-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/spi/amba-pl022.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index dae886e..77f90de 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -1068,7 +1068,7 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
pl022-master_info-dma_filter,
pl022-master_info-dma_rx_param);
if (!pl022-dma_rx_channel) {
-   dev_err(pl022-adev-dev, no RX DMA channel!\n);
+   dev_dbg(pl022-adev-dev, no RX DMA channel!\n);
goto err_no_rxchan;
}
 
@@ -1076,13 +1076,13 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
pl022-master_info-dma_filter,
pl022-master_info-dma_tx_param);
if (!pl022-dma_tx_channel) {
-   dev_err(pl022-adev-dev, no TX DMA channel!\n);
+   dev_dbg(pl022-adev-dev, no TX DMA channel!\n);
goto err_no_txchan;
}
 
pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!pl022-dummypage) {
-   dev_err(pl022-adev-dev, no DMA dummypage!\n);
+   dev_dbg(pl022-adev-dev, no DMA dummypage!\n);
goto err_no_dummypage;
}
 
@@ -1098,6 +1098,8 @@ err_no_txchan:
dma_release_channel(pl022-dma_rx_channel);
pl022-dma_rx_channel = NULL;
 err_no_rxchan:
+   dev_err(pl022-adev-dev,
+   Failed to work in dma mode, work without dma!\n);
return -ENODEV;
 }
 
@@ -2111,7 +2113,7 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
if (platform_info-enable_dma) {
status = pl022_dma_probe(pl022);
if (status != 0)
-   goto err_no_dma;
+   platform_info-enable_dma = 0;
}
 
/* Initialize and start queue */
@@ -2143,7 +2145,6 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
  err_init_queue:
destroy_queue(pl022);
pl022_dma_remove(pl022);
- err_no_dma:
free_irq(adev-irq[0], pl022);
  err_no_irq:
clk_put(pl022-clk);
-- 
1.7.2.2


--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [QUERY] amba/pl022: DMA channel allocation always fail.

2011-05-15 Thread viresh kumar
On 05/13/2011 08:01 PM, Linus Walleij wrote:
 2011/5/13 viresh kumar viresh.ku...@st.com:
 
 amba/pl022 and my dma driver dw_dmac.c, both have registered init() routines
 with subsys_initcall(). Now at bootup, spi boots up before DMA and so DMA
 channels are never available at spi probe.

 What should be done to solve this issue?
 
 If you check drivers/dma/ste_dma40.c you can see that our solution was to
 simply move the DMA engine to arch_initcall().
 
 Which sort of makes sense for a DMA engine.
 
 Does this work for dw_dmac.c?

Yes, it worked here too..

-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [QUERY] Behavior of spi slave memories w.r.t chip select signal.

2011-05-13 Thread viresh kumar
On 05/13/2011 12:24 PM, Linus Walleij wrote:
 2011/5/13 viresh kumar viresh.ku...@st.com:
 Linus, Jamie,

 Have you ever seen this kind of issue? Which spi slave memories did you used 
 for testing?
 I am using standard pl0022 and m25p80 driver. Tried in all modes: polling, 
 interrupt, dma.
 
 Not really. I'll throw in a few people on CC and see if they have some hints.
 

Thanks guys.

Issue is solved now, data must be latched on Rising Edge and i have passed 
phase as falling edge.

--
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] spi/amba-pl022: work in polling or interrupt mode if pl022_dma_probe fails

2011-05-13 Thread Viresh Kumar
If pl022_dma_probe fails, we can try to transfer data in polling or interrupt
mode. Also, set platform_info-enable_dma to 0, so that no other code tries to
use dma.

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/amba-pl022.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index 08de58e..82b98b8 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -1063,7 +1063,7 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
pl022-master_info-dma_filter,
pl022-master_info-dma_rx_param);
if (!pl022-dma_rx_channel) {
-   dev_err(pl022-adev-dev, no RX DMA channel!\n);
+   dev_warn(pl022-adev-dev, no RX DMA channel!\n);
goto err_no_rxchan;
}
 
@@ -1071,13 +1071,13 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
pl022-master_info-dma_filter,
pl022-master_info-dma_tx_param);
if (!pl022-dma_tx_channel) {
-   dev_err(pl022-adev-dev, no TX DMA channel!\n);
+   dev_warn(pl022-adev-dev, no TX DMA channel!\n);
goto err_no_txchan;
}
 
pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!pl022-dummypage) {
-   dev_err(pl022-adev-dev, no DMA dummypage!\n);
+   dev_warn(pl022-adev-dev, no DMA dummypage!\n);
goto err_no_dummypage;
}
 
@@ -1093,6 +1093,8 @@ err_no_txchan:
dma_release_channel(pl022-dma_rx_channel);
pl022-dma_rx_channel = NULL;
 err_no_rxchan:
+   dev_warn(pl022-adev-dev,
+   Failed to work in dma mode, work without dma!\n);
return -ENODEV;
 }
 
@@ -2107,7 +2109,7 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
if (platform_info-enable_dma) {
status = pl022_dma_probe(pl022);
if (status != 0)
-   goto err_no_dma;
+   platform_info-enable_dma = 0;
}
 
/* Initialize and start queue */
@@ -2143,7 +2145,6 @@ pl022_probe(struct amba_device *adev, const struct 
amba_id *id)
  err_init_queue:
destroy_queue(pl022);
pl022_dma_remove(pl022);
- err_no_dma:
free_irq(adev-irq[0], pl022);
  err_no_irq:
clk_put(pl022-clk);
-- 
1.7.2.2


--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[QUERY] amba/pl022: DMA channel allocation always fail.

2011-05-13 Thread viresh kumar
Linus,

amba/pl022 and my dma driver dw_dmac.c, both have registered init() routines
with subsys_initcall(). Now at bootup, spi boots up before DMA and so DMA
channels are never available at spi probe.

What should be done to solve this issue?

One idea is allocate DMA channel as and when required, instead of allocating 
them
at probe. But in that case too i am not sure, that this issue will be solved.
As, if spi slave device is added from board file, then it will also try to 
transfer
data as soon as spi driver is up. So that too may be called before dma_probe().

-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi/amba-pl022: work in polling or interrupt mode if pl022_dma_probe fails

2011-05-13 Thread viresh kumar
On 5/13/11, Viresh Kumar viresh.ku...@st.com wrote:
 diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
 index 08de58e..82b98b8 100644
 --- a/drivers/spi/amba-pl022.c
 +++ b/drivers/spi/amba-pl022.c
 @@ -1063,7 +1063,7 @@ static int __init pl022_dma_probe(struct pl022 *pl022)
   pl022-master_info-dma_filter,
   pl022-master_info-dma_rx_param);
   if (!pl022-dma_rx_channel) {
 - dev_err(pl022-adev-dev, no RX DMA channel!\n);
 + dev_warn(pl022-adev-dev, no RX DMA channel!\n);

Sorry, this must be dev_dbg

   goto err_no_rxchan;
   }

 @@ -1071,13 +1071,13 @@ static int __init pl022_dma_probe(struct pl022
 *pl022)
   pl022-master_info-dma_filter,
   pl022-master_info-dma_tx_param);
   if (!pl022-dma_tx_channel) {
 - dev_err(pl022-adev-dev, no TX DMA channel!\n);
 + dev_warn(pl022-adev-dev, no TX DMA channel!\n);

dev_dbg

   goto err_no_txchan;
   }

   pl022-dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
   if (!pl022-dummypage) {
 - dev_err(pl022-adev-dev, no DMA dummypage!\n);
 + dev_warn(pl022-adev-dev, no DMA dummypage!\n);

dev_dbg

   goto err_no_dummypage;
   }

 @@ -1093,6 +1093,8 @@ err_no_txchan:
   dma_release_channel(pl022-dma_rx_channel);
   pl022-dma_rx_channel = NULL;
  err_no_rxchan:
 + dev_warn(pl022-adev-dev,

dev_err

 + Failed to work in dma mode, work without dma!\n);
   return -ENODEV;
  }


Will resend patch on Monday. Till that time, please see if this patch
with mentioned changes is acceptable or not.

--
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [QUERY] Behavior of spi slave memories w.r.t chip select signal.

2011-05-12 Thread viresh kumar
On 05/11/2011 09:37 AM, viresh kumar wrote:
 
 Hello,
 
 Following is what i understood after reading m25p80 driver and spi master
 drivers in drivers/spi folder.
 
 chip_select signal controls start and end of transfer. For ex: if we have to 
 read
 status reg of spi memory, then we use write_and_then_read() routine. which 
 writes
 0x9F in one spi transfer and writes dummy bytes and reads rx reg in other 
 transfer.
 And these two transfers are part of single spi_message.
 
 Now, it is controllable to handle cs, and if we send cs_change == 0, then 
 chip select
 is activated at start of message and deactivated at end of message, instead 
 at end
 of every transfer.
 
 Which means, even if there is a delay between command and dummy bytes 
 received at
 spi memory, current transfer will not be terminated by memory as cs is low.
 
 Is this correct??
 
 Actually i am seeing a different behavior by some of the spi memories, like 
 m25p10.
 If there is a delay between read_sts_reg command and dummy bytes, then 
 0xFF is
 returned in response. If there is no delay then transfer always passes.
 

Linus, Jamie,

Have you ever seen this kind of issue? Which spi slave memories did you used 
for testing?
I am using standard pl0022 and m25p80 driver. Tried in all modes: polling, 
interrupt, dma.

-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [QUERY] Behavior of spi slave memories w.r.t chip select signal.

2011-05-11 Thread viresh kumar
On 05/11/2011 12:47 PM, Jamie Iles wrote:
 What SPI controller are you using?  I've seen a similar issue with the 
 Synopsys DesignWare SPI controller where the controller manages the chip 
 select itself, and once the FIFO is emptied the CS goes away, but the 
 flash chip requires it to stay high for the whole transaction.  In this 
 case the workaround is to use a GPIO as a chip select and there are 
 other controllers that do the same thing for the same reason (I think 
 that pxa2xx_spi is one of them).

I am using amba pl022 controller and using external gpio's to control
chip select signal. cs is kept low for entire message, but still i am facing
this issue.

-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[QUERY] Behavior of spi slave memories w.r.t chip select signal.

2011-05-10 Thread viresh kumar

Hello,

Following is what i understood after reading m25p80 driver and spi master
drivers in drivers/spi folder.

chip_select signal controls start and end of transfer. For ex: if we have to 
read
status reg of spi memory, then we use write_and_then_read() routine. which 
writes
0x9F in one spi transfer and writes dummy bytes and reads rx reg in other 
transfer.
And these two transfers are part of single spi_message.

Now, it is controllable to handle cs, and if we send cs_change == 0, then chip 
select
is activated at start of message and deactivated at end of message, instead at 
end
of every transfer.

Which means, even if there is a delay between command and dummy bytes received 
at
spi memory, current transfer will not be terminated by memory as cs is low.

Is this correct??

Actually i am seeing a different behavior by some of the spi memories, like 
m25p10.
If there is a delay between read_sts_reg command and dummy bytes, then 0xFF 
is
returned in response. If there is no delay then transfer always passes.

-- 
viresh

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH] amba-pl022: fixing compilation warning.

2011-01-13 Thread Viresh Kumar
clk_freq is used uninitialized in pl022_setup routine. This patch
fix compilation warning for using uninitialized variable

Signed-off-by: Viresh Kumar viresh.ku...@st.com
---
 drivers/spi/amba-pl022.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index fb3d1b3..3903ab9 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -1799,7 +1799,7 @@ static int pl022_setup(struct spi_device *spi)
 {
struct pl022_config_chip const *chip_info;
struct chip_data *chip;
-   struct ssp_clock_params clk_freq;
+   struct ssp_clock_params clk_freq = {0, };
int status = 0;
struct pl022 *pl022 = spi_master_get_devdata(spi-master);
unsigned int bits = spi-bits_per_word;
-- 
1.7.2.2


--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general