All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Stuebner <heiko@sntech.de>
To: John Keeping <john@metanate.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: rk3x: support master_xfer_atomic
Date: Fri, 03 Jul 2020 12:08:53 +0200	[thread overview]
Message-ID: <2391901.EFyQHPvyDf@phil> (raw)
In-Reply-To: <20200623120646.2175569-1-john@metanate.com>

Am Dienstag, 23. Juni 2020, 14:06:46 CEST schrieb John Keeping:
> Enable i2c transactions in irq disabled contexts like poweroff where the
> PMIC is connected via i2c.
> 
> Signed-off-by: John Keeping <john@metanate.com>

on a rk3288:
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>

> ---
>  drivers/i2c/busses/i2c-rk3x.c | 39 +++++++++++++++++++++++++++++++----
>  1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
> index 15324bfbc6cb..8e3cc85d1921 100644
> --- a/drivers/i2c/busses/i2c-rk3x.c
> +++ b/drivers/i2c/busses/i2c-rk3x.c
> @@ -10,6 +10,7 @@
>  #include <linux/module.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/iopoll.h>
>  #include <linux/errno.h>
>  #include <linux/err.h>
>  #include <linux/platform_device.h>
> @@ -1040,8 +1041,21 @@ static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num)
>  	return ret;
>  }
>  
> -static int rk3x_i2c_xfer(struct i2c_adapter *adap,
> -			 struct i2c_msg *msgs, int num)
> +static int rk3x_i2c_wait_xfer_poll(struct rk3x_i2c *i2c)
> +{
> +	ktime_t timeout = ktime_add_ms(ktime_get(), WAIT_TIMEOUT);
> +
> +	while (READ_ONCE(i2c->busy) &&
> +	       ktime_compare(ktime_get(), timeout) < 0) {
> +		udelay(5);
> +		rk3x_i2c_irq(0, i2c);
> +	}
> +
> +	return !i2c->busy;
> +}
> +
> +static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
> +				struct i2c_msg *msgs, int num, bool polling)
>  {
>  	struct rk3x_i2c *i2c = (struct rk3x_i2c *)adap->algo_data;
>  	unsigned long timeout, flags;
> @@ -1075,8 +1089,12 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
>  
>  		rk3x_i2c_start(i2c);
>  
> -		timeout = wait_event_timeout(i2c->wait, !i2c->busy,
> -					     msecs_to_jiffies(WAIT_TIMEOUT));
> +		if (!polling) {
> +			timeout = wait_event_timeout(i2c->wait, !i2c->busy,
> +						     msecs_to_jiffies(WAIT_TIMEOUT));
> +		} else {
> +			timeout = rk3x_i2c_wait_xfer_poll(i2c);
> +		}
>  
>  		spin_lock_irqsave(&i2c->lock, flags);
>  
> @@ -1110,6 +1128,18 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
>  	return ret < 0 ? ret : num;
>  }
>  
> +static int rk3x_i2c_xfer(struct i2c_adapter *adap,
> +			 struct i2c_msg *msgs, int num)
> +{
> +	return rk3x_i2c_xfer_common(adap, msgs, num, false);
> +}
> +
> +static int rk3x_i2c_xfer_polling(struct i2c_adapter *adap,
> +				 struct i2c_msg *msgs, int num)
> +{
> +	return rk3x_i2c_xfer_common(adap, msgs, num, true);
> +}
> +
>  static __maybe_unused int rk3x_i2c_resume(struct device *dev)
>  {
>  	struct rk3x_i2c *i2c = dev_get_drvdata(dev);
> @@ -1126,6 +1156,7 @@ static u32 rk3x_i2c_func(struct i2c_adapter *adap)
>  
>  static const struct i2c_algorithm rk3x_i2c_algorithm = {
>  	.master_xfer		= rk3x_i2c_xfer,
> +	.master_xfer_atomic	= rk3x_i2c_xfer_polling,
>  	.functionality		= rk3x_i2c_func,
>  };
>  
> 





WARNING: multiple messages have this Message-ID (diff)
From: Heiko Stuebner <heiko@sntech.de>
To: John Keeping <john@metanate.com>
Cc: linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: rk3x: support master_xfer_atomic
Date: Fri, 03 Jul 2020 12:08:53 +0200	[thread overview]
Message-ID: <2391901.EFyQHPvyDf@phil> (raw)
In-Reply-To: <20200623120646.2175569-1-john@metanate.com>

Am Dienstag, 23. Juni 2020, 14:06:46 CEST schrieb John Keeping:
> Enable i2c transactions in irq disabled contexts like poweroff where the
> PMIC is connected via i2c.
> 
> Signed-off-by: John Keeping <john@metanate.com>

on a rk3288:
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>

> ---
>  drivers/i2c/busses/i2c-rk3x.c | 39 +++++++++++++++++++++++++++++++----
>  1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
> index 15324bfbc6cb..8e3cc85d1921 100644
> --- a/drivers/i2c/busses/i2c-rk3x.c
> +++ b/drivers/i2c/busses/i2c-rk3x.c
> @@ -10,6 +10,7 @@
>  #include <linux/module.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/iopoll.h>
>  #include <linux/errno.h>
>  #include <linux/err.h>
>  #include <linux/platform_device.h>
> @@ -1040,8 +1041,21 @@ static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num)
>  	return ret;
>  }
>  
> -static int rk3x_i2c_xfer(struct i2c_adapter *adap,
> -			 struct i2c_msg *msgs, int num)
> +static int rk3x_i2c_wait_xfer_poll(struct rk3x_i2c *i2c)
> +{
> +	ktime_t timeout = ktime_add_ms(ktime_get(), WAIT_TIMEOUT);
> +
> +	while (READ_ONCE(i2c->busy) &&
> +	       ktime_compare(ktime_get(), timeout) < 0) {
> +		udelay(5);
> +		rk3x_i2c_irq(0, i2c);
> +	}
> +
> +	return !i2c->busy;
> +}
> +
> +static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
> +				struct i2c_msg *msgs, int num, bool polling)
>  {
>  	struct rk3x_i2c *i2c = (struct rk3x_i2c *)adap->algo_data;
>  	unsigned long timeout, flags;
> @@ -1075,8 +1089,12 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
>  
>  		rk3x_i2c_start(i2c);
>  
> -		timeout = wait_event_timeout(i2c->wait, !i2c->busy,
> -					     msecs_to_jiffies(WAIT_TIMEOUT));
> +		if (!polling) {
> +			timeout = wait_event_timeout(i2c->wait, !i2c->busy,
> +						     msecs_to_jiffies(WAIT_TIMEOUT));
> +		} else {
> +			timeout = rk3x_i2c_wait_xfer_poll(i2c);
> +		}
>  
>  		spin_lock_irqsave(&i2c->lock, flags);
>  
> @@ -1110,6 +1128,18 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
>  	return ret < 0 ? ret : num;
>  }
>  
> +static int rk3x_i2c_xfer(struct i2c_adapter *adap,
> +			 struct i2c_msg *msgs, int num)
> +{
> +	return rk3x_i2c_xfer_common(adap, msgs, num, false);
> +}
> +
> +static int rk3x_i2c_xfer_polling(struct i2c_adapter *adap,
> +				 struct i2c_msg *msgs, int num)
> +{
> +	return rk3x_i2c_xfer_common(adap, msgs, num, true);
> +}
> +
>  static __maybe_unused int rk3x_i2c_resume(struct device *dev)
>  {
>  	struct rk3x_i2c *i2c = dev_get_drvdata(dev);
> @@ -1126,6 +1156,7 @@ static u32 rk3x_i2c_func(struct i2c_adapter *adap)
>  
>  static const struct i2c_algorithm rk3x_i2c_algorithm = {
>  	.master_xfer		= rk3x_i2c_xfer,
> +	.master_xfer_atomic	= rk3x_i2c_xfer_polling,
>  	.functionality		= rk3x_i2c_func,
>  };
>  
> 





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-03 10:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 12:06 [PATCH] i2c: rk3x: support master_xfer_atomic John Keeping
2020-07-03 10:08 ` Heiko Stuebner [this message]
2020-07-03 10:08   ` Heiko Stuebner
2020-07-04  6:46 ` Wolfram Sang
2020-07-04  6:46   ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2020-06-25 21:21 kernel test robot

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=2391901.EFyQHPvyDf@phil \
    --to=heiko@sntech.de \
    --cc=john@metanate.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.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.