From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Vladimir Zapolskiy <vz@mleia.com>
Cc: Tejun Heo <tj@kernel.org>,
linux-ide@vger.kernel.org,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Subject: Re: [PATCH 3/4] pata: imx: add support of setting timings for PIO modes
Date: Mon, 14 Nov 2016 15:22:16 +0100 [thread overview]
Message-ID: <1550314.zPK4oZKyMC@amdc3058> (raw)
In-Reply-To: <20161109005638.17691-4-vz@mleia.com>
Hi,
On Wednesday, November 09, 2016 02:56:37 AM Vladimir Zapolskiy wrote:
> The controller is capable to operate in up to PIO4 mode, however
> before the change the driver relies on timing settings done by
> a bootloader for PIO0 mode only. The change adds more flexibility
> in PIO mode selection at runtime and makes the driver to work even if
> bootloader does not preset ATA timings.
>
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
> drivers/ata/pata_imx.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 46 insertions(+), 1 deletion(-)
[...]
> +static void pata_imx_set_timing(struct ata_device *adev,
> + struct pata_imx_priv *priv)
> +{
> + struct ata_timing timing;
> + unsigned long clkrate;
> + u32 T, mode;
> +
> + clkrate = clk_get_rate(priv->clk);
> +
> + if (adev->pio_mode < XFER_PIO_0 || adev->pio_mode > XFER_PIO_4 ||
> + !clkrate)
No need check for adev->pio_mode < XFER_PIO_0 || adev->pio_mode > XFER_PIO_4
as the libata core code guarantees that these conditions will never happen.
Also you should at least print an error on !clkrate condition. [ IMHO it
is actually better to BUG_ON() on this condition as the further operations
may be risky for the data integrity (wrong PIO timings may be used). ]
> + return;
> +
> + T = 1000000000 / clkrate;
> + ata_timing_compute(adev, adev->pio_mode, &timing, T * 1000, 0);
> +
> + mode = adev->pio_mode - XFER_PIO_0;
> +
> + writeb(3, priv->host_regs + PATA_IMX_ATA_TIME_OFF);
> + writeb(3, priv->host_regs + PATA_IMX_ATA_TIME_ON);
> + writeb(timing.setup, priv->host_regs + PATA_IMX_ATA_TIME_1);
> + writeb(timing.act8b, priv->host_regs + PATA_IMX_ATA_TIME_2W);
> + writeb(timing.act8b, priv->host_regs + PATA_IMX_ATA_TIME_2R);
> + writeb(1, priv->host_regs + PATA_IMX_ATA_TIME_PIO_RDX);
> +
> + writeb(pio_t4[mode] / T + 1, priv->host_regs + PATA_IMX_ATA_TIME_4);
> + writeb(pio_t9[mode] / T + 1, priv->host_regs + PATA_IMX_ATA_TIME_9);
> + writeb(pio_tA[mode] / T + 1, priv->host_regs + PATA_IMX_ATA_TIME_AX);
> +}
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2016-11-14 14:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 0:56 [PATCH 0/4] pata: imx: set timings for PIO modes up to PIO4 Vladimir Zapolskiy
2016-11-09 0:56 ` [PATCH 1/4] pata: imx: sort headers out Vladimir Zapolskiy
2016-11-09 0:56 ` [PATCH 2/4] pata: imx: set controller PIO mode with .set_piomode callback Vladimir Zapolskiy
2016-11-09 0:56 ` [PATCH 3/4] pata: imx: add support of setting timings for PIO modes Vladimir Zapolskiy
2016-11-09 9:39 ` Sergei Shtylyov
2016-11-10 1:33 ` Vladimir Zapolskiy
2016-11-10 16:10 ` Tejun Heo
2016-11-14 14:22 ` Bartlomiej Zolnierkiewicz [this message]
2016-11-09 0:56 ` [PATCH 4/4] pata: imx: support controller modes up to PIO4 Vladimir Zapolskiy
2016-11-09 16:49 ` [PATCH 0/4] pata: imx: set timings for PIO " Tejun Heo
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=1550314.zPK4oZKyMC@amdc3058 \
--to=b.zolnierkie@samsung.com \
--cc=linux-ide@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=tj@kernel.org \
--cc=vz@mleia.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 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.