From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: linux-mips@linux-mips.org, linux-ide@vger.kernel.org,
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
ralf@linux-mips.org
Subject: Re: [PATCH] ide: Add tx4938ide driver (v2)
Date: Thu, 23 Oct 2008 21:38:48 +0400 [thread overview]
Message-ID: <4900B6A8.30705@ru.mvista.com> (raw)
In-Reply-To: <20081023.012013.52129771.anemo@mba.ocn.ne.jp>
Hello.
Atsushi Nemoto wrote:
> This is the driver for the Toshiba TX4938 SoC EBUS controller ATA mode.
> It has custom set_pio_mode and some hacks for big endian.
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> diff --git a/drivers/ide/mips/tx4938ide.c b/drivers/ide/mips/tx4938ide.c
> new file mode 100644
> index 0000000..fa660f9
> --- /dev/null
> +++ b/drivers/ide/mips/tx4938ide.c
> @@ -0,0 +1,310 @@
> +/*
> + * TX4938 internal IDE driver
> + * Based on tx4939ide.c.
> + *
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License. See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * (C) Copyright TOSHIBA CORPORATION 2005-2007
> + */
> +
> +#include <linux/module.h>
> +#include <linux/types.h>
> +#include <linux/ide.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/io.h>
> +#include <asm/txx9/tx4938.h>
> +
> +static void tx4938ide_tune_ebusc(unsigned int ebus_ch,
> + unsigned int gbus_clock,
> + u8 pio)
> +{
> + struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
> + u64 cr = __raw_readq(&tx4938_ebuscptr->cr[ebus_ch]);
> + unsigned int sp = (cr >> 4) & 3;
> + unsigned int clock = gbus_clock / (4 - sp);
> + unsigned int cycle = 1000000000 / clock;
Hm, couldn't all these values be calculated only once?
> + unsigned int wt, shwt;
> +
> + /* Minimum DIOx- active time */
> + wt = DIV_ROUND_UP(t->act8b, cycle) - 2;
> + /* IORDY setup time: 35ns */
> + wt = max(wt, DIV_ROUND_UP(35, cycle));
Same comment about calculating only once...
> + /* actual wait-cycle is max(wt & ~1, 1) */
> + if (wt > 2 && (wt & 1))
> + wt++;
> + wt &= ~1;
> + /* Address-valid to DIOR/DIOW setup */
It's really address valid to -CSx assertion and -CSx to -DIOx assertion
setup time, and contrarywise, -DIOx to -CSx release and -CSx release to
address invalid hold time, so it actualy applies 4 times and so constitutes
-DIOx recovery time. It's worth to check if the minimum cycle time is reached
with the setup time -- for PIO mode 0, minimum setup is 70 ns, multiplying
that by 4 gives 280 ns recovery and adding 290 ns active time gives 570 ns
cycle while the minimum is 600 ns. Luckily, PIO0 seems the only problematic
mode as I doubt that EBUS controller can do back-to-back IDE reads/writes
keeping address and/or -CSx asserted in-between amounting to recovery time
being only 2x/3x setup times -- in the worst, 2x case PIO mode 3 would also
have too little cycle/recovery time...
> + shwt = DIV_ROUND_UP(t->setup, cycle);
> +
> + pr_debug("tx4938ide: ebus %d, bus cycle %dns, WT %d, SHWT %d\n",
> + ebus_ch, cycle, wt, shwt);
> +
> + __raw_writeq((cr & ~(0x3f007ull)) | (wt << 12) | shwt,
> + &tx4938_ebuscptr->cr[ebus_ch]);
Unneeded parens around the numeric constant.
> +static int __init tx4938ide_probe(struct platform_device *pdev)
> +{
[...]
> + mapbase = (unsigned long)devm_ioremap(&pdev->dev, res->start,
> + res->end - res->start + 1);
Calling devm_ioremap() on the whole 128 KB region wasn't such a great idea
perhaps...
> + ret = ide_host_add(&d, hws, &host);
> + if (ret)
> + return ret;
> + platform_set_drvdata(pdev, host);
> + return 0;
I'd suggest shorter:
if (!ret)
platform_set_drvdata(pdev, host);
return ret;
MBR, Sergei
next prev parent reply other threads:[~2008-10-23 17:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-22 16:20 [PATCH] ide: Add tx4938ide driver (v2) Atsushi Nemoto
2008-10-23 17:38 ` Sergei Shtylyov [this message]
2008-10-24 15:55 ` Atsushi Nemoto
2008-10-24 16:06 ` Atsushi Nemoto
2008-10-23 20:47 ` Bartlomiej Zolnierkiewicz
2008-10-24 11:12 ` Sergei Shtylyov
2008-10-24 14:20 ` Atsushi Nemoto
2009-02-08 11:44 ` Sergei Shtylyov
2009-02-08 11:52 ` Sergei Shtylyov
2009-02-08 16:53 ` Atsushi Nemoto
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=4900B6A8.30705@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.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.