From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: "João Ramos" <joao.ramos@inov.pt>
Cc: H Hartley Sweeten <hartleys@visionengravers.com>,
Ryan Mallon <ryan@bluewatersys.com>,
linux-arm-kernel@lists.arm.linux.org.uk,
linux-ide@vger.kernel.org
Subject: Re: EP93xx PIO IDE driver proposal
Date: Tue, 05 May 2009 16:04:38 +0400 [thread overview]
Message-ID: <4A002B56.1000802@ru.mvista.com> (raw)
In-Reply-To: <49FED069.9080501@inov.pt>
Hello.
João Ramos wrote:
>>> Patch follows.
>>>
>>> diff -urN linux-2.6.29.orig/arch/arm/mach-ep93xx/core.c
>>> linux-2.6.29/arch/arm/mach-ep93xx/core.c
>>> --- linux-2.6.29.orig/arch/arm/mach-ep93xx/core.c 2009-03-23
>>> 23:12:14.000000000 +0000
>>> +++ linux-2.6.29/arch/arm/mach-ep93xx/core.c 2009-03-30
>>> 13:52:04.000000000 +0100
>>> @@ -537,6 +537,51 @@
>>> platform_device_register(&ep93xx_i2c_device);
>>> }
>>>
>>> +static struct resource ep93xx_ide_resources[] = {
>>> + [0] = {
>> Your code uses 4-space indentation instead of single-tab -- this
>> style is not acceptable. I'd advise to run the patch thru
>> scripts/checkpatch.pl to find and fix the coding style mistakes.
> The problem is mainly my mailer settings: it deforms the patch output.
> Perhaps next time I should send the patch as an attachment?
Well, if the IDE maintainer doesn't mind, I don't either. Just make sure
the attachment will have the MIME type of text/plain.
>>> +/*
>>> + * IDE Interface register map default state
>>> + * (shutdown)
>>> + */
>>> +static void
>>> +ep93xx_ide_pio_clean_regs(unsigned long base)
>>> +{
>>> + /* disable IDE interface initially, ensuring that no device is
>>> selected */
>>> + writel((IDECTRL_CS0N | IDECTRL_CS1N), IDE_REGISTER(IDECTRL));
>>> +
>>> + /* clear IDE registers */
>>> + writel(0, IDE_REGISTER(IDECFG));
>>
>>
>> Writing 0 to this register generates an invalid cycle on IDE bus if
>> I don't mistake (CS0/1 and DIOR/W all asserted), are you sure you want
>> this?
> Zero (0) is the default value for the IDE Configuration Register, as
> stated in EP93xx User's Guide (Section 27, page 11).
> Besides, CS0/1 and DIOR/W lines are controlled through IDE Control
> Register.
Sorry, I seem to have mixed them up...
> In that case, perhaps it would be best to have it also set to it's
> default value, deasserting DIOR/W as well:
> writel((IDECTRL_CS0N | IDECTRL_CS1N | IDECTRL_DIORN | IDECTRL_DIOWN),
> IDE_REGISTER(IDECTRL));
Yes, that's what I had in mind...
>>> +/*
>>> + * EP93xx IDE PIO low-level hardware initialization routine
>>> + */
>>> +static void
>>> +ep93xx_ide_pio_init_hwif(ide_hwif_t *hwif)
>>> +{
>>> + unsigned long base = hwif->config_data;
>>> +
>>> + /* enforce reset state */
>>> + ep93xx_ide_pio_clean_regs(base);
>>> +
>>> + /* set gpio port E, G and H for IDE */
>>> + ep93xx_ide_gpio_on_ide();
>>> +
>>> + /*
>>> + * configure IDE interface:
>>> + * - IDE Master Enable
>>> + * - Polled IO Operation
>>> + * - PIO Mode 4 (16.67 MBps)
>>> + * - 1 Wait State (10 ns)
>>> + */
>>> + writel(IDECFG_IDEEN | IDECFG_PIO | IDECFG_PIO_MODE_4 |
>>> + ((1 << 8) & IDECFG_WST), IDE_REGISTER(IDECFG));
>>> +}
>>> +
>>> +/*
>>> + * EP93xx IDE PIO low-level byte-read procedure.
>>> + */
>>> +static u8
>>> +ep93xx_ide_pio_readb(unsigned long base, unsigned long addr)
>>> +{
>>> + u32 reg;
>>> +
>>> + /*
>>> + * initial state: DIORn=1, DIOWn=1
>>> + * write address out
>>> + * select CS configuration
>>> + */
>>> + reg = ((addr & 0x07) << 2) | ((addr >> 3) & 0x03) | IDECTRL_DIORN |
>>> + IDECTRL_DIOWN;
>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>> +
>>> + /*
>>> + * bring DIORn low
>>> + */
>>> + reg &= ~IDECTRL_DIORN;
>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>> +
>>> + /*
>>> + * bring DIORn high
>>> + */
>>> + reg |= IDECTRL_DIORN;
>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>> +
>>> + /*
>>> + * read IDE Data Input Register
>>> + */
>>> + return (readl(IDE_REGISTER(IDEDATAIN)) & 0xFF);
>> Masking is pointless, it's achieved by truncation to 'u8'.
>>> +}
>> I don't see what warrants minimum active/recovery time here. And I
>> don't see how you're supporitng PIO modes 3/4 as you're not checking
>> -IORDY.
> So, you're saying I should check for the IORDY value at the beginning
> and end of each transfer?
Only before deasserting -DIOx.
> What exactly do you mean by 'warrant minimum active/recovery time'?
> Should I insert manual delays to ensure timing issues?
Yes, since Cirrus seems to have left you with no option other than
bit-banging to emulate I/O cycles, you'll have to use delays...
> [...]
>>> +/*
>>> + * EP93xx IDE PIO low-level word buffer-read procedure
>>> + */
>>> +static void
>>> +ep93xx_ide_pio_readsw(unsigned long base, unsigned long addr, void
>>> *buf,
>>> + unsigned int len)
>>> +{
>>> + u16 *data = (u16 *)buf;
>>> +
>>> + for (;len;len--)
>> Put spaces after ; please.
>>> + *data++ = ep93xx_ide_pio_readw(base, addr);
>> Is this little-endian only code? If not, it's not valid in the big
>> endian mode...
> Should I instead use array-indexing code such as:
> for (; len; len--, i++)
> data[i] = ep93xx_ide_pio_readw(base, addr);
> And the same for 'ep93xx_ide_pio_writesw()' function?
No, it won't change anything. You should use cpu_to_le16() -- unless
somehow ep93xx_ide_pio_readw() always returns little-endian data...
MBR, Sergei
next prev parent reply other threads:[~2009-05-05 12:03 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <49CCD7C4.8000207@inov.pt>
[not found] ` <49CFDD8F.1030306@bluewatersys.com>
[not found] ` <BD79186B4FD85F4B8E60E381CAEE1909014E2E09@mi8nycmail19.Mi8.com>
[not found] ` <49D0CAE4.9090306@inov.pt>
2009-03-30 15:34 ` EP93xx PIO IDE driver proposal Sergei Shtylyov
2009-05-04 11:24 ` João Ramos
2009-05-05 12:04 ` Sergei Shtylyov [this message]
2009-05-06 14:17 ` João Ramos
2009-05-06 17:05 ` Sergei Shtylyov
2009-05-07 9:36 ` João Ramos
2009-05-07 11:01 ` João Ramos
2009-05-07 13:53 ` Alan Cox
2009-05-07 15:33 ` João Ramos
2009-05-08 12:04 ` Bartlomiej Zolnierkiewicz
2009-05-08 12:16 ` João Ramos
2009-05-08 12:40 ` Bartlomiej Zolnierkiewicz
2009-05-08 13:30 ` Sergei Shtylyov
2009-05-08 14:09 ` Bartlomiej Zolnierkiewicz
2009-05-08 17:28 ` João Ramos
2009-05-08 18:02 ` Bartlomiej Zolnierkiewicz
2009-05-08 18:16 ` João Ramos
2009-05-08 18:55 ` Bartlomiej Zolnierkiewicz
2009-05-08 20:24 ` joao.ramos
2009-05-08 21:01 ` Sergei Shtylyov
2009-05-08 22:07 ` Bartlomiej Zolnierkiewicz
2009-05-11 11:10 ` João Ramos
2009-05-12 16:49 ` Sergei Shtylyov
2009-05-12 17:23 ` Bartlomiej Zolnierkiewicz
2009-05-13 11:01 ` João Ramos
2009-05-17 15:20 ` Bartlomiej Zolnierkiewicz
2009-05-22 17:52 ` Sergei Shtylyov
2009-05-13 14:18 ` João Ramos
2009-05-14 19:44 ` Bartlomiej Zolnierkiewicz
2009-05-15 17:01 ` João Ramos
2009-05-17 16:16 ` Bartlomiej Zolnierkiewicz
2009-05-18 13:49 ` João Ramos
2009-05-19 13:06 ` Bartlomiej Zolnierkiewicz
2009-05-19 13:20 ` João Ramos
2009-05-19 13:56 ` Bartlomiej Zolnierkiewicz
2009-05-19 14:05 ` João Ramos
2009-05-19 15:50 ` João Ramos
2009-06-06 15:26 ` Sergei Shtylyov
2009-06-22 10:01 ` Bartlomiej Zolnierkiewicz
2009-05-14 16:30 ` Sergei Shtylyov
2009-05-14 16:36 ` Sergei Shtylyov
2009-05-14 18:58 ` Bartlomiej Zolnierkiewicz
2009-05-11 13:20 ` João Ramos
2009-05-12 16:41 ` Bartlomiej Zolnierkiewicz
2009-05-12 16:57 ` Sergei Shtylyov
2009-05-12 16:01 ` João Ramos
2009-05-12 16:30 ` Bartlomiej Zolnierkiewicz
2009-05-12 16:45 ` João Ramos
2009-05-07 16:52 ` H Hartley Sweeten
2009-05-07 22:09 ` Ryan Mallon
2009-05-07 22:31 ` H Hartley Sweeten
2009-05-07 22:51 ` Ryan Mallon
2009-05-07 23:01 ` H Hartley Sweeten
2009-05-07 23:12 ` Ryan Mallon
2009-05-07 23:32 ` João Ramos
2009-05-07 23:58 ` H Hartley Sweeten
2009-05-08 11:23 ` Sergei Shtylyov
2009-05-08 12:47 ` João Ramos
[not found] ` <49D12669.4030207@bluewatersys.com>
2009-03-31 10:36 ` Sergei Shtylyov
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=4A002B56.1000802@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=hartleys@visionengravers.com \
--cc=joao.ramos@inov.pt \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-ide@vger.kernel.org \
--cc=ryan@bluewatersys.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).