From: "João Ramos" <joao.ramos@inov.pt>
To: Sergei Shtylyov <sshtylyov@ru.mvista.com>
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: Fri, 08 May 2009 13:47:42 +0100 [thread overview]
Message-ID: <4A0429EE.6000906@inov.pt> (raw)
In-Reply-To: <4A041632.10609@ru.mvista.com>
Sergei Shtylyov escreveu:
> João Ramos wrote:
>
>>>> Sergei: I've added the delays you suggested in the read/write
>>>> procedures, accordingly to the delays specified in the processor's
>>>> user manual for PIO Mode 4.
>
>>> Why only for PIO mode 4 if you're claiming support for modes 0
>>> thru 4?
>
>> The patch currently supports only PIO Mode 4, as it is hardcoded into
>> the CPU's IDE configuration register:
>
>> writel(IDECFG_IDEEN | IDECFG_PIO | IDECFG_PIO_MODE_4 |
>> ((1 << 8) & IDECFG_WST), IDE_REGISTER(IDECFG));
>
>> And also in the ide_port_info struct:
>
>> static struct ide_port_info ep93xx_ide_port_info = {
>> .name = MODULE_NAME,
>> .init_hwif = ep93xx_ide_init_hwif,
>> .tp_ops = &ep93xx_ide_tp_ops,
>> .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_NO_DMA | IDE_HFLAG_MMIO |
>> IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_UNMASK_IRQS,
>> .pio_mask = ATA_PIO4,
>
> Note that the ATA_PIO4 mask means support for PIO modes 0 thru 4,
> not just PIO mode 4 (although in the absense of the set_pio_mode()
> method this mask hardly matters at all)...
I've already seen that, as stated in my earlier mails. Now I've got the
full picture about the IDE subsystem ;-) .
>
>> };
>
>> So you're saying I should support all PIO modes? If so, I would have to
>
> For the safe functining of your IDE driver, yes; you should support
> at least PIO0 as a safe bet. Think about CompactFlash -- the older
> cards don't even support PIO4, only PIO2 maximum.
I've already done that, implementing the 'pio_set_mode' method.
>
>> make conditional code, checking perhaps a module param to sort which
>> PIO mode to use.
>
>
>> Also, the manual delays should also depend on the PIO mode selected...
>
> Sure.
As discussed with Bartlomiej Zolnierkiewicz, I will use struct
ide_timing to figure out the correct timings for each PIO mode, and use
the adequate delays in my read/write functions.
>
>> It would be done either by a module param (defaulting to PIO Mode 4),
>> or through a kernel configuration variable...
>
> Why? We have set_pio_mode() method in 'struct ide_port_ops' for that.
> The IDE core will select the best PIO mode for you based on the
> drive's capabilities -- you just need to implement this method.
Now I got it ;-) . Sorry, I'm quite inexperient in the IDE subsystem
(and in kernel programming) so it took me a while to figure that out.
But I've done that and I've already tested it, and it works.
I am just finishing some other fixes and I will submit a new patch soon.
>
>>>> +
>>>> +/*
>>>> + * EP93xx IDE PIO low-level hardware initialization routine
>>>> + */
>>>> +static void ep93xx_ide_init_hwif(ide_hwif_t *hwif)
>>>> +{
>>>> + unsigned long base = hwif->config_data;
>>>> +
>>>> + /* enforce reset state */
>>>> + ep93xx_ide_clean_regs(base);
>>>> +
>>>> + /* set gpio port E, G and H for IDE */
>>>> + ep93xx_ide_on_gpio(1);
>
>>> Shouldn't this be done in the platform code instead?
>
>> The idea is to make this driver loadable, as suggested earlier by
>> Ryan and Hartley.
>> The IDE pins are initially (and by default) set to GPIO function. If
>> the IDE driver is registered, through specific platform code or by
>> loading the module at runtime, then the IDE driver cares to configure
>> the IDE pins for IDE function, returning them to GPIO function once
>> the driver is unloaded.
>
> I'm not sure you can just "return the pins to GPIO function" since
> they will remain connected to the IDE port and will affect its state
> even being in GPIO mode... I think you don't have a choice here: they
> are either always belong to GPIO (if there's no IDE port) or always
> belong to IDE (if the IDE port is present).
The point is that user's may select (or not) the IDE driver.
Some patches are already in the arm-linux mailing list for this; by
default all pins are configured for GPIO function, and they remain that
way if no IDE option is selected.
If the IDE driver is selected and compiled (and running), the driver
will then care to claim the IDE pins to the IDE function, through a
machine-specific core call (such as ep93xx_ide_on_gpio).
This approach works for both systems with and without IDE driver selected.
>
>> [...]
>
>>>> +static u8 ep93xx_ide_readb(unsigned long base, unsigned long addr)
>>>> +{
>>>> + u32 reg;
>>>> +
>>>> + reg = ((addr & 0x07) << 2) | ((addr >> 3) & 0x03) |
>>>> IDECTRL_DIORN |
>>>> + IDECTRL_DIOWN;
>>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>>> + ndelay(25);
>>>> +
>>>> + reg &= ~IDECTRL_DIORN;
>>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>>> + ndelay(70);
>>>> +
>>>> + while (!ep93xx_ide_check_iordy())
>>>> + cpu_relax();
>>>> +
>>>> + reg |= IDECTRL_DIORN;
>>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>>> + ndelay(25);
>>>> +
>>>> + return readl(IDE_REGISTER(IDEDATAIN));
>
>>> Hey, how this even works (if the data doesn't get latched
>>> somehow)?! You
>>> should read the register right *before* the deassertion of -DIORx! The
>>> minimum data hold time is only 5 ns and the data lines will be
>>> tristated
>>> within 30 ns maximum...
>
>> Will be fixed.
>
> Again, I don't know, maybe the data register is indeed latched by
> the controller at the rising edge of -DIOR... because this code most
> probably wouldn't work otherwise. Please check the documentation,
> maybe it's illegal to read the data before the deassertion of -DIOR.
> But at least doing it after 25 ns delay looked too much fishy...
Please check my earliest emails; i've described the behaviour of the IDE
controller.
>
>>>> +
>>>> + reg &= ~IDECTRL_DIOWN;
>>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>>> + ndelay(70);
>>>> +
>>>> + while (!ep93xx_ide_check_iordy())
>>>> + cpu_relax();
>>>> +
>>>> + reg |= IDECTRL_DIOWN;
>>>> + writel(reg, IDE_REGISTER(IDECTRL));
>>>> + ndelay(25);
>>>> +}
>>>> +
>
>>> [...]
>
>>> The same question: why we need both ep93xx_ide_write[bw]()?
>
>> Same answer as before. Perhaps there's no need for those.
>
>>> Since this is not a hotplug driver, you can save some memory on
>>> making ep93xx_ide_probe() __init -- using platform_driver_probe()
>>> here instead of platform_driver_register() and *not* initializing
>>> the 'probe' field of the 'struct platform_driver'.
>
>> I think Ryan and Hartley would like this driver to be
>> loadable/unloadable at runtime, as I pointed out earlier in this mail.
>
> So what? It'll remain [un]loadable...
I've also came to that conclusion (now).
Gosh, I really need to study harder my "Linux Device Drivers" book ;-) .
Best regards,
João Ramos
--
************************************************************************
João Ramos <joao.ramos@inov.pt>
INOV INESC Inovação - ESTG Leiria
Escola Superior de Tecnologia e Gestão de Leiria
Edíficio C1, Campus 2
Morro do Lena, Alto do Vieiro
Leiria
2411-901 Leiria
Portugal
Tel: +351244843424
Fax: +351244843424
************************************************************************
next prev parent reply other threads:[~2009-05-08 12:48 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
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 [this message]
[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=4A0429EE.6000906@inov.pt \
--to=joao.ramos@inov.pt \
--cc=hartleys@visionengravers.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-ide@vger.kernel.org \
--cc=ryan@bluewatersys.com \
--cc=sshtylyov@ru.mvista.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).