From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-ide@vger.kernel.org
Subject: Re: [PATCH v2 1/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY
Date: Fri, 11 Jul 2014 16:33:38 +0200 [thread overview]
Message-ID: <2632799.IFO1aEjqtg@amdc1032> (raw)
In-Reply-To: <53BFE8F9.7050700@linaro.org>
On Friday, July 11, 2014 02:39:05 PM Srinivas Kandagatla wrote:
> Thankyou for the comments,
>
> On 11/07/14 13:38, Bartlomiej Zolnierkiewicz wrote:
> >
> > Hi,
> >
> > On Wednesday, July 09, 2014 12:04:06 PM Srinivas Kandagatla wrote:
> >> Add a PHY driver for uses with AHCI based SATA controller driver on the
> >> APQ8064 family of SoCs.
> >>
> >> This patch is a forward port from Qualcomm's v3.4 andriod kernel.
> >
> > Android?
> yep.
> >
> > unused define, please remove it
> >
> Will fix these instances in next version.
> >> +
> >> +#define UNIPHY_PLL_LOCK BIT(0)
> >> +#define SATA_PHY_TX_CAL BIT(0)
> >> +#define SATA_PHY_RX_CAL BIT(0)
> >> +
> >> +/* default timeout set to 1 sec */
> >> +#define TIMEOUT_MS 10000
> >> +
> >> +struct qcom_apq8064_sata_phy {
> >> + void __iomem *mmio;
> >> + struct clk *cfg_clk;
> >> + struct device *dev;
> >> +};
> >> +
> >> +/* Helper function to do poll and timeout */
> >> +static int read_poll_timeout(void __iomem *addr, u32 mask)
> >> +{
> >> + unsigned long timeout = jiffies + msecs_to_jiffies(TIMEOUT_MS);
> >> + u32 val;
> >> +
> >> + do {
> >> + cpu_relax();
> >> + val = readl_relaxed(addr);
> >> + if (val & mask)
> >> + break;
> >> + } while (!time_after(jiffies, timeout));
> >
> > It would be better to use usleep_[range]() (or even msleep() if needed)
> > instead of just using cpu_relax().
>
> We really want to poll the register here, usleep/msleep would be useful
> if we know already know how much delay is required, but in this case the
> its not true.
I don't mean replacing the whole function, you can still do polling with
i.e. doing usleep_range(1000, 2000) with 1000 retries. The advantage of
doing it this way would be that processor could do some useful work or
sleep during wait time instead of just busy waiting.
One example of many how to do it:
drivers/i2c/busses/i2c-s3c2410.c:
static bool is_ack(struct s3c24xx_i2c *i2c)
{
int tries;
for (tries = 50; tries; --tries) {
if (readl(i2c->regs + S3C2410_IICCON)
& S3C2410_IICCON_IRQPEND) {
if (!(readl(i2c->regs + S3C2410_IICSTAT)
& S3C2410_IICSTAT_LASTBIT))
return true;
}
usleep_range(1000, 2000);
}
dev_err(i2c->dev, "ack was not recieved\n");
return false;
}
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2014-07-11 14:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 18:00 [PATCH] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Srinivas Kandagatla
2014-06-23 18:12 ` Kumar Gala
2014-06-23 18:38 ` Srinivas Kandagatla
2014-07-09 9:36 ` Srinivas Kandagatla
2014-07-09 10:08 ` Kishon Vijay Abraham I
2014-07-09 11:03 ` [PATCH v2 0/2] Add Qcom AP8064 SATA PHY support Srinivas Kandagatla
2014-07-09 11:04 ` [PATCH v2 1/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Srinivas Kandagatla
2014-07-11 12:38 ` Bartlomiej Zolnierkiewicz
2014-07-11 13:39 ` Srinivas Kandagatla
2014-07-11 14:33 ` Bartlomiej Zolnierkiewicz [this message]
2014-07-11 19:42 ` Srinivas Kandagatla
2014-07-09 11:04 ` [PATCH v2 2/2] phy: qcom: Update APQ8064 PHY device tree bindings Srinivas Kandagatla
2014-07-14 8:47 ` [PATCH v3 0/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Srinivas Kandagatla
2014-07-14 8:48 ` [PATCH v3 1/2] " Srinivas Kandagatla
2014-07-14 8:48 ` [PATCH v3 2/2] phy: qcom: Update APQ8064 PHY device tree bindings Srinivas Kandagatla
2014-07-14 10:30 ` [PATCH v3 0/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Kishon Vijay Abraham I
2014-07-14 10:32 ` Srinivas Kandagatla
2014-07-14 11:17 ` [PATCH v4 " Srinivas Kandagatla
2014-07-14 11:17 ` [PATCH v4 1/2] " Srinivas Kandagatla
2014-07-15 16:56 ` Bartlomiej Zolnierkiewicz
2014-07-16 6:28 ` Srinivas Kandagatla
2014-07-14 11:18 ` [PATCH v4 2/2] phy: qcom: Add APQ8064 SATA PHY device tree bindings Srinivas Kandagatla
2014-07-14 10:53 ` [PATCH] phy: qcom: Add driver for QCOM APQ8064 SATA PHY kiran padwal
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=2632799.IFO1aEjqtg@amdc1032 \
--to=b.zolnierkie@samsung.com \
--cc=grant.likely@linaro.org \
--cc=kishon@ti.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.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