From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
To: Andy Gross <agross@codeaurora.org>
Cc: Mark Brown <broonie@kernel.org>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
linux-spi@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Alok Chauhan <alokc@codeaurora.org>,
Gilad Avidov <gavidov@codeaurora.org>,
Kiran Gunda <kgunda@codeaurora.org>,
Sagar Dharia <sdharia@codeaurora.org>
Subject: Re: [PATCH 2/2] spi: Add Qualcomm QUP SPI controller support
Date: Mon, 10 Feb 2014 18:55:02 +0200 [thread overview]
Message-ID: <1392051302.2853.56.camel@iivanov-dev> (raw)
In-Reply-To: <20140207173207.GA19974@qualcomm.com>
Hi Andy,
On Fri, 2014-02-07 at 11:32 -0600, Andy Gross wrote:
> On Fri, Feb 07, 2014 at 11:52:33AM +0200, Ivan T. Ivanov wrote:
> >
<snip>
> > > > +static int spi_qup_transfer_do(struct spi_qup *controller,
> > > > + struct spi_qup_device *chip,
> > > > + struct spi_transfer *xfer)
> > > > +{
> > > > + unsigned long timeout;
> > > > + int ret = -EIO;
> > > > +
> > > > + reinit_completion(&controller->done);
> > > > +
> > > > + timeout = DIV_ROUND_UP(controller->speed_hz, MSEC_PER_SEC);
> > > > + timeout = DIV_ROUND_UP(xfer->len * 8, timeout);
> > > > + timeout = 100 * msecs_to_jiffies(timeout);
> > > > +
> > > > + controller->rx_bytes = 0;
> > > > + controller->tx_bytes = 0;
> > > > + controller->error = 0;
> > > > + controller->xfer = xfer;
> > > > +
> > > > + if (spi_qup_set_state(controller, QUP_STATE_RUN)) {
> > > > + dev_warn(controller->dev, "cannot set RUN state\n");
> > > > + goto exit;
> > > > + }
> > > > +
> > > > + if (spi_qup_set_state(controller, QUP_STATE_PAUSE)) {
> > > > + dev_warn(controller->dev, "cannot set PAUSE state\n");
> > > > + goto exit;
> > > > + }
> > > > +
> > > > + spi_qup_fifo_write(controller, xfer);
> > > > +
> > > > + if (spi_qup_set_state(controller, QUP_STATE_RUN)) {
> > > > + dev_warn(controller->dev, "cannot set EXECUTE state\n");
> > > > + goto exit;
> > > > + }
> > > > +
> > > > + if (!wait_for_completion_timeout(&controller->done, timeout))
> > > > + ret = -ETIMEDOUT;
> > > > + else
> > > > + ret = controller->error;
> > > > +exit:
> > > > + controller->xfer = NULL;
> > >
> > > Should the manipulation of controller->xfer be protected by spinlock?
> >
> > :-). Probably. I am wondering, could I avoid locking if firstly place
> > QUP into RESET state and then access these field. This should stop
> > all activities in it, right?
>
> It's generally safest to not assume the hardware is going to do sane things.
> I'm concerned about spurious IRQs.
Ok, will add protection.
<snip>
> > > > +
> > > > + if (of_property_read_u32(dev->of_node, "spi-max-frequency", &max_freq))
> > > > + max_freq = 19200000;
> > >
> > > I'd set the default to 50MHz as that is the max supported by hardware. I'd just
> > > set max_freq declaration to 50MHz and then check the value if it is changed via
> > > DT.
> >
> > 50MHz doesn't seems to be supported on all chip sets. Currently common
> > denominator on all chip sets, that I can see, is 19.2MHz. I have tried
> > to test it with more than 19.2MHz on APQ8074 and it fails.
> >
>
> I guess my stance is to set it to the hardware max supported frequency if it is
> not specified. If that needs to be lower on a board because of whatever reason,
> they override it.
Ok, I will do in this way.
<snip>
> > >
> > > > +
> > > > + ret = clk_set_rate(cclk, max_freq);
> > > > + if (ret)
> > > > + dev_warn(dev, "fail to set SPI frequency %d\n", max_freq);
> > >
> > > Bail here?
> >
> > I don't know. What will be the consequences if controller continue to
> > operate on its default rate?
> >
>
> It is unclear. But if you can't set the rate that is configured or if there is
> a misconfiguration, it's probably better to exit the probe and catch it here.
My preference is to delay clock speed change till first
SPI transfer. And use wherever transfer itself mandate.
<snip>
> > > > +
> > > > +static int spi_qup_remove(struct platform_device *pdev)
> > > > +{
> > > > + struct spi_master *master = dev_get_drvdata(&pdev->dev);
> > > > + struct spi_qup *controller = spi_master_get_devdata(master);
> > > > +
> > > > + pm_runtime_get_sync(&pdev->dev);
> > > > +
> > >
> > > Do we need to wait for any current transactions to complete
> > > and do a devm_free_irq()?
> > >
> > > > + clk_disable_unprepare(controller->cclk);
> > > > + clk_disable_unprepare(controller->iclk);
> >
> > My understanding is:
> >
> > Disabling clocks will timeout transaction, if any. Core Device driver
> > will call: devm_spi_unregister(), which will wait pending transactions
> > to complete and then remove the SPI master.
>
> Disabling clocks will confuse the hardware. We cannot disable clocks while the
> spi core is active and transferring data.
I could follow approach taken by other SPI drivers, just reset
controller and disable clocks.
>
> >
> > > > +
> > > > + pm_runtime_put_noidle(&pdev->dev);
> > > > + pm_runtime_disable(&pdev->dev);
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static struct of_device_id spi_qup_dt_match[] = {
> > > > + { .compatible = "qcom,spi-qup-v2", },
> > >
> > > Need compatible tags of qcom,spi-qup-v2.1.1 (msm8974 v1) or qcom,spi-qup-v2.2.1
> > > (msm8974 v2)
> >
> > I am not aware of the difference. My board report v.20020000.
> > Is there difference of handling these controllers?
>
> There were some bug fixes between versions. None of those affect SPI (that I
> can tell), but it's better to be more descriptive and use the full versions in
> the compatible tags.
No strong preference here. Should I add qcom,spi-qup-v2.2.0, then? :-)
Regards,
Ivan
next prev parent reply other threads:[~2014-02-10 16:55 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 16:57 [PATCH 0/2] spi: Add Qualcomm QUP SPI controller support Ivan T. Ivanov
2014-02-06 16:57 ` [PATCH 1/2] spi: qup: Add device tree bindings information Ivan T. Ivanov
[not found] ` <1391705868-20091-2-git-send-email-iivanov-NEYub+7Iv8PQT0dZR+AlfA@public.gmane.org>
2014-02-07 7:43 ` Andy Gross
2014-02-06 16:57 ` [PATCH 2/2] spi: Add Qualcomm QUP SPI controller support Ivan T. Ivanov
2014-02-07 7:39 ` Andy Gross
[not found] ` <20140207073952.GA2610-zC7DfRvBq/JWk0Htik3J/w@public.gmane.org>
2014-02-07 9:52 ` Ivan T. Ivanov
2014-02-07 17:32 ` Andy Gross
2014-02-07 17:52 ` Mark Brown
[not found] ` <20140207175234.GJ1757-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-07 19:12 ` Andy Gross
2014-02-10 16:55 ` Ivan T. Ivanov [this message]
2014-02-10 17:47 ` Andy Gross
[not found] ` <20140210174738.GA31596-zC7DfRvBq/JWk0Htik3J/w@public.gmane.org>
2014-02-10 19:41 ` Ivan T. Ivanov
2014-02-10 20:29 ` Courtney Cavin
2014-02-10 20:59 ` Ivan T. Ivanov
2014-02-10 21:40 ` Mark Brown
[not found] ` <20140210202926.GV1706-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
2014-02-11 15:46 ` Ivan T. Ivanov
2014-02-07 16:51 ` Josh Cartwright
[not found] ` <20140207165127.GV20228-OP5zVEFNDbfdOxZ39nK119BPR1lH4CV8@public.gmane.org>
2014-02-07 17:18 ` Mark Brown
2014-02-07 17:20 ` Josh Cartwright
[not found] ` <20140207172051.GW20228-OP5zVEFNDbfdOxZ39nK119BPR1lH4CV8@public.gmane.org>
2014-02-07 17:31 ` Mark Brown
[not found] ` <20140207173108.GH1757-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-07 17:46 ` Josh Cartwright
2014-02-07 17:57 ` Mark Brown
[not found] ` <CACceFXdUobQvN2hcv5kh+QL=o8bWM_PVkAtrOx+euZSeVDm8hQ@mail.gmail.com>
2014-02-07 16:34 ` Fwd: " dsneddon
2014-02-07 17:16 ` Mark Brown
[not found] ` <214fe9fc7e62ab30bdfbb4ac5d1ee250.squirrel-mMfbam+mt9083fI46fginR2eb7JE58TQ@public.gmane.org>
2014-02-10 15:54 ` Ivan T. Ivanov
2014-02-10 16:21 ` dsneddon
[not found] ` <3388d68dc907e9190d997fad95830d74.squirrel-mMfbam+mt9083fI46fginR2eb7JE58TQ@public.gmane.org>
2014-02-10 17:11 ` Ivan T. Ivanov
2014-02-10 17:41 ` dsneddon
[not found] ` <1391705868-20091-3-git-send-email-iivanov-NEYub+7Iv8PQT0dZR+AlfA@public.gmane.org>
2014-02-07 17:12 ` Mark Brown
[not found] ` <20140207171202.GD1757-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-10 16:29 ` Ivan T. Ivanov
2014-02-10 17:09 ` Mark Brown
2014-02-06 17:50 ` [PATCH 0/2] " Mark Brown
2014-02-07 7:43 ` [PATCH RESEND 1/2] spi: qup: Add device tree bindings information Ivan T. Ivanov
2014-02-07 12:27 ` Mark Brown
2014-02-07 13:00 ` Ivan T. Ivanov
2014-02-07 13:13 ` Mark Brown
2014-02-07 13:35 ` Ivan T. Ivanov
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=1392051302.2853.56.camel@iivanov-dev \
--to=iivanov@mm-sol.com \
--cc=agross@codeaurora.org \
--cc=alokc@codeaurora.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gavidov@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=kgunda@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sdharia@codeaurora.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 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).