From: Dmitry Osipenko <digetx@gmail.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Ludovic Desroches" <ludovic.desroches@microchip.com>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Cc: Stefan Lengfeld <contact@stefanchrist.eu>,
Marco Felsch <m.felsch@pengutronix.de>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] i2c: at91: support atomic write xfer
Date: Sun, 22 Mar 2020 04:39:58 +0300 [thread overview]
Message-ID: <c789352c-5517-1fd9-980d-f8f6c2017901@gmail.com> (raw)
In-Reply-To: <6466e066d7cbad20cb6a334ad8e37cdcf521c492.1584822011.git.mirq-linux@rere.qmqm.pl>
22.03.2020 00:03, Michał Mirosław пишет:
> Implement basic support for atomic write - enough to get a simple
> write to PMIC on shutdown. Only for chips having ALT_CMD register,
> eg. SAMA5D2.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> v2: remove runtime-PM usage
> switch to readl*poll*atomic() for transfer completion wait
> ---
> drivers/i2c/busses/i2c-at91-master.c | 69 +++++++++++++++++++++++++++-
> 1 file changed, 67 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c
> index ba6fbb9c7390..d9226207157a 100644
> --- a/drivers/i2c/busses/i2c-at91-master.c
> +++ b/drivers/i2c/busses/i2c-at91-master.c
> @@ -21,6 +21,7 @@
> #include <linux/i2c.h>
> #include <linux/interrupt.h>
> #include <linux/io.h>
> +#include <linux/iopoll.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/platform_device.h>
> @@ -709,6 +710,69 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
> return ret;
> }
>
> +static int at91_twi_xfer_atomic(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
> +{
> + struct at91_twi_dev *dev = i2c_get_adapdata(adap);
> + unsigned long timeout;
> + struct pinctrl *pins;
> + __u32 stat;
> + int ret;
> +
> + /* FIXME: only single write request supported to 7-bit addr */
> + if (num != 1)
> + return -EOPNOTSUPP;
> + if (msg->flags & I2C_M_RD)
> + return -EOPNOTSUPP;
> + if (msg->flags & I2C_M_TEN)
> + return -EOPNOTSUPP;
> + if (msg->len > dev->fifo_size && msg->len > 1)
> + return -EOPNOTSUPP;
> + if (!dev->pdata->has_alt_cmd)
> + return -EOPNOTSUPP;
> +
> + pins = pinctrl_get_select_default(&adap->dev);
> +
> + ret = clk_prepare_enable(twi_dev->clk);
Hello Michał,
Please see comments to the clk_prepare_enable() and clk_prepare().
/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
static inline int clk_prepare_enable(struct clk *clk)
...
* clk_prepare may sleep, which differentiates it from clk_enable.
next prev parent reply other threads:[~2020-03-22 1:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-21 21:03 [PATCH v2] i2c: at91: support atomic write xfer Michał Mirosław
2020-03-22 1:39 ` Dmitry Osipenko [this message]
2020-03-22 16:35 ` Michał Mirosław
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=c789352c-5517-1fd9-980d-f8f6c2017901@gmail.com \
--to=digetx@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=contact@stefanchrist.eu \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=m.felsch@pengutronix.de \
--cc=mirq-linux@rere.qmqm.pl \
--cc=nicolas.ferre@microchip.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).