All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
To: Sifan Naeem <sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>,
	Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 7/7] i2c: img-scb: add handle for Master halt interrupt
Date: Wed, 29 Jul 2015 16:59:05 +0100	[thread overview]
Message-ID: <55B8F849.4080105@imgtec.com> (raw)
In-Reply-To: <1437998162-32724-8-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4037 bytes --]

On 27/07/15 12:56, Sifan Naeem wrote:
> Master halt is issued after each byte of a transaction is processed in
> IP version 3.3.
> Master halt will stall the bus by holding the SCK line low until the
> halt bit in the scb_general_control is cleared.
> 
> After the last byte of a transfer is processed we can use the Master
> Halt interrupt to facilitate a repeated start transfer without
> issuing a stop bit.
> 
> Signed-off-by: Sifan Naeem <sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-img-scb.c |   25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
> index 90faf48..df3d25a 100644
> --- a/drivers/i2c/busses/i2c-img-scb.c
> +++ b/drivers/i2c/busses/i2c-img-scb.c
> @@ -151,6 +151,7 @@
>  #define INT_FIFO_EMPTYING		BIT(12)
>  #define INT_TRANSACTION_DONE		BIT(15)
>  #define INT_SLAVE_EVENT			BIT(16)
> +#define INT_MASTER_HALTED		BIT(17)
>  #define INT_TIMING			BIT(18)
>  #define INT_STOP_DETECTED		BIT(19)
>  
> @@ -177,6 +178,7 @@
>  					 INT_FIFO_FULL        | \
>  					 INT_FIFO_FILLING     | \
>  					 INT_FIFO_EMPTY       | \
> +					 INT_MASTER_HALTED    | \
>  					 INT_STOP_DETECTED)
>  
>  #define INT_ENABLE_MASK_WAITSTOP	(INT_SLAVE_EVENT      | \
> @@ -901,6 +903,17 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,
>  	mod_timer(&i2c->check_timer, jiffies + msecs_to_jiffies(1));
>  
>  	if (i2c->msg.flags & I2C_M_RD) {
> +		if (int_status & INT_MASTER_HALTED) {
> +			img_i2c_read_fifo(i2c);
> +			if (i2c->msg.len == 0)
> +				return ISR_COMPLETE(0);

don't you still need to wait for stop bit on last message?

I suspect you could have a bit less duplication with something like this
(again untested):

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index f694b47dcf74..2de2d63083e5 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -875,13 +875,14 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,
 	}
 
 	if (i2c->msg.flags & I2C_M_RD) {
-		if (int_status & INT_FIFO_FULL_FILLING) {
+		if (int_status & (INT_FIFO_FULL_FILLING | INT_MASTER_HALTED)) {
 			img_i2c_read_fifo(i2c);
 			if (i2c->msg.len == 0)
 				return ISR_WAITSTOP;
 		}
 	} else {
-		if (int_status & INT_FIFO_EMPTY_EMPTYING) {
+		if (int_status & (INT_FIFO_EMPTY_EMPTYING |
+				  INT_MASTER_HALTED)) {
 			/*
 			 * The write fifo empty indicates that we're in the
 			 * last byte so it's safe to start a new write
@@ -895,6 +896,14 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,
 			img_i2c_write_fifo(i2c);
 		}
 	}
+	if (int_status & INT_MASTER_HALTED) {
+		/*
+		 * Release and then enable transaction halt, to allow only a
+		 * single byte to proceed.
+		 */
+		img_i2c_transaction_halt(i2c, false);
+		img_i2c_transaction_halt(i2c, !i2c->last_msg);
+	}
 
 	return 0;
 }

would that do the trick?

Cheers
James

> +			/*
> +			 * Release and then enable transaction halt, to
> +			 * allow only a single byte to proceed.
> +			 */
> +			img_i2c_transaction_halt(i2c, false);
> +			img_i2c_transaction_halt(i2c, !i2c->last_msg);
> +		}
>  		if (int_status & INT_FIFO_FULL_FILLING) {
>  			img_i2c_read_fifo(i2c);
>  			if (i2c->msg.len == 0) {
> @@ -922,6 +935,18 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,
>  			return ISR_COMPLETE(ret);
>  		}
>  	} else {
> +		if (int_status & INT_MASTER_HALTED) {
> +			if ((int_status & INT_FIFO_EMPTY) &&
> +			    i2c->msg.len == 0)
> +				return ISR_COMPLETE(0);
> +			img_i2c_write_fifo(i2c);
> +			/*
> +			 * Release and then enable transaction halt, to
> +			 * allow only a single byte to proceed.
> +			 */
> +			img_i2c_transaction_halt(i2c, false);
> +			img_i2c_transaction_halt(i2c, !i2c->last_msg);
> +		}
>  		if (int_status & INT_FIFO_EMPTY) {
>  			if (i2c->msg.len == 0) {
>  				if (i2c->last_msg)
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-07-29 15:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 11:55 [PATCH 0/7] i2c: img-scb: enchancements to support i2c on pistachio Sifan Naeem
     [not found] ` <1437998162-32724-1-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-27 11:55   ` [PATCH 1/7] i2c: img-scb: support I2C_M_IGNORE_NAK Sifan Naeem
     [not found]     ` <1437998162-32724-2-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 13:58       ` James Hogan
2015-07-27 11:55   ` [PATCH 2/7] i2c: img-scb: support repeated starts on IP v3.3 Sifan Naeem
     [not found]     ` <1437998162-32724-3-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 14:17       ` James Hogan
2015-07-27 11:55   ` [PATCH 3/7] i2c: img-scb: mark transaction as complete when all data is read Sifan Naeem
     [not found]     ` <1437998162-32724-4-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 14:21       ` James Hogan
     [not found]         ` <55B8E15B.9070002-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 14:37           ` Sifan Naeem
2015-07-27 11:55   ` [PATCH 4/7] i2c: img-scb: mark transaction as complete when no more data to write Sifan Naeem
     [not found]     ` <1437998162-32724-5-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 14:22       ` James Hogan
     [not found]         ` <55B8E19A.8010302-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 14:38           ` Sifan Naeem
2015-07-27 11:56   ` [PATCH 5/7] i2c: img-scb: remove fifo EMPTYING interrupts handle Sifan Naeem
     [not found]     ` <1437998162-32724-6-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 16:01       ` James Hogan
     [not found]         ` <55B8F8C1.8030507-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 17:00           ` Sifan Naeem
2015-07-27 11:56   ` [PATCH 6/7] i2c: img-scb: add handle for stop detected interrupt Sifan Naeem
     [not found]     ` <1437998162-32724-7-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 15:34       ` James Hogan
     [not found]         ` <55B8F271.6060003-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 17:06           ` Sifan Naeem
     [not found]             ` <A0E307549471DA4DBAF2DE2DE6CBFB7E4966DE38-brIQrgj5TFtJFJhlrACyRFBRoQTxkR7k@public.gmane.org>
2015-07-29 21:23               ` James Hogan
2015-07-27 11:56   ` [PATCH 7/7] i2c: img-scb: add handle for Master halt interrupt Sifan Naeem
     [not found]     ` <1437998162-32724-8-git-send-email-sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 15:59       ` James Hogan [this message]
     [not found]         ` <55B8F849.4080105-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-07-29 17:13           ` Sifan Naeem

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=55B8F849.4080105@imgtec.com \
    --to=james.hogan-1axoqhu6uovqt0dzr+alfa@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sifan.naeem-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /path/to/YOUR_REPLY

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

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