Skip to contentSkip to conversation

mmio ide support

PATCH In review Vitaly Bordug 9 participants 20 messages Jul 7, 2007 – Jul 11, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mmio ide support

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

---

 drivers/ide/Kconfig           |    6 +
 drivers/ide/legacy/Makefile   |    2 
 drivers/ide/legacy/mmio-ide.c |  211 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+), 0 deletions(-)
drivers/ide/Kconfig +6 -0
index b1a9b81..0dab799 100644
@@ -946,6 +946,12 @@ config BLK_DEV_MPC8xx_IDE
 
 	  If unsure, say N.
 
+config BLK_DEV_MMIOIDE
+	tristate "Memory Mapped IDE support"
+	help
+	  This is the IDE driver for Memory Mapped IDE devices. Like
+	  Compact Flash running in True IDE mode.
+
 choice
 	prompt "Type of MPC8xx IDE interface"
 	depends on BLK_DEV_MPC8xx_IDE
drivers/ide/legacy/Makefile +2 -0
index c797106..61bd21e 100644
@@ -7,6 +7,8 @@ obj-$(CONFIG_BLK_DEV_UMC8672)		+= umc8672.o
 
 obj-$(CONFIG_BLK_DEV_IDECS)		+= ide-cs.o
 
+obj-$(CONFIG_BLK_DEV_MMIOIDE)		+= mmio-ide.o
+
 # Last of all
 obj-$(CONFIG_BLK_DEV_HD)		+= hd.o
 
drivers/ide/legacy/mmio-ide.c new file +211 -0

211 lines not on this page · raw message

#1 lore raw

PATCH 2/2 mmio ide support for mpc8349-itx target

This updates relevant platform code (freescale mpc8349itx target) to make the CompactFlash work in TrueIDE mode.

---

 arch/powerpc/boot/dts/mpc8349emitx.dts |   17 +++++
 arch/powerpc/sysdev/fsl_soc.c          |  113 ++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+), 1 deletions(-)
arch/powerpc/boot/dts/mpc8349emitx.dts +16 -1
index db0d003..b3e80ab 100644
@@ -42,7 +42,7 @@
 		#size-cells = <1>;
 		#interrupt-cells = <2>;
 		device_type = "soc";
-		ranges = <0 e0000000 00100000>;
+		ranges = <0 e0000000 1f000000>;
 		reg = <e0000000 00000200>;
 		bus-frequency = <0>;                    // from bootloader
 
@@ -229,6 +229,21 @@
 			descriptor-types-mask = <01010ebf>;
 		};
 
+		ide@10000000 {
+ 			#interrupt-cells = <2>;
+ 			interrupts = <17 8>;
+ 			interrupt-map = <0 0 0 1 700 17 8>;
+ 			interrupt-map-mask = <0>;
+ 
+ 			#size-cells = <1>;
+ 			#address-cells = <1>;
+ 			reg = <10000000 10 10000200 10>;
+ 
+ 			device_type = "ide";
+ 			compatible = "mmio-ide";
+ 			interrupt-parent = < &ipic >;
+ 		};
+
 		ipic: pic@700 {
 			interrupt-controller;
 			#address-cells = <0>;
arch/powerpc/sysdev/fsl_soc.c +113 -0

116 lines not on this page · raw message

#8 lore raw
In reply to Vitaly Bordug
Quoted 6 lines · Vitaly Bordug

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Hmm, are we still adding new IDE drivers? Do you also have a driver for the new libata layer? I think it would even be simpler to do.

You could also make it an of_platform_driver at the same time instead of adding more cruft to fsl_soc.c. Since we're already about to add the electra_ide.c driver in 2.6.23, I guess there should really be _one_ driver that is able to handle all of_device based ATA hosts.

	Arnd <><
#15 lore raw
In reply to Vitaly Bordug
Quoted 3 lines · Vitaly Bordug

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Doesn't this duplicate most of pata_platform, but as the no-longer-preferred legacy IDE device? Did you try using pata_platform instead?

-Olof

#2 lore raw

Re: [PATCH 2/2] [POWERPC] mmio ide support for mpc8349-itx target

In reply to Vitaly Bordug
Quoted 4 lines · Vitaly Bordug

This updates relevant platform code (freescale mpc8349itx target) to make the CompactFlash work in TrueIDE mode.

Shouldn't you be writing a PCMCIA driver instead for the CF, so it handles other devices as well? Then you get storage "for free", as well as hotplug, etc.

It's not hard:

http://patchwork.ozlabs.org/linuxppc/patch?person=124&id=12044

-Olof

#3 lore raw

Re: [PATCH 2/2] [POWERPC] mmio ide support for mpc8349-itx target

Quoted 9 lines · Olof Johansson
Quoted 4 lines · Vitaly Bordug

This updates relevant platform code (freescale mpc8349itx target) to make the CompactFlash work in TrueIDE mode.

Shouldn't you be writing a PCMCIA driver instead for the CF, so it handles other devices as well? Then you get storage "for free", as well as hotplug, etc.

CF memory cards can be in either TrueIDE mode or PCMCIA mode. If you only need to support memory cards, you should always use True-IDE mode, because that offers a _much_ higher throughput with PIO mode 6 (25 MB/s) or UDMA mode 6 (133MB/s), compared to the PIO mode 0 (3.3 MB/s) in PCMCIA mode.

Of course, if the bus can only sustain PIO mode 0 anyway, you can just as well do a PCMCIA driver, and get the ability to plug in other cards, e.g. wlan or modem cards.

	Arnd <><
#4 lore raw

Re: [PATCH 2/2] [POWERPC] mmio ide support for mpc8349-itx target

In reply to Vitaly Bordug

Hello.

Quoted 6 lines · Vitaly Bordug

This updates relevant platform code (freescale mpc8349itx target) to make the CompactFlash work in TrueIDE mode.

It would have been good if you tried to actualy compile your code. ;-)

Quoted 14 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +1 -1
index db0d003..b3e80ab 100644
@@ -42,7 +42,7 @@
 		#size-cells = <1>;
 		#interrupt-cells = <2>;
 		device_type = "soc";
-		ranges = <0 e0000000 00100000>;
+		ranges = <0 e0000000 1f000000>;
 		reg = <e0000000 00000200>;
 		bus-frequency = <0>;                    // from bootloader
 

arch/powerpc/boot/dts/mpc8349emitx.dts line 233

Quoted 5 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +2 -0
@@ -229,6 +229,21 @@
 			descriptor-types-mask = <01010ebf>;
 		};
 
+		ide@10000000 {
+ 			#interrupt-cells = <2>;

Hm, why define that prop for a node with no children?

arch/powerpc/boot/dts/mpc8349emitx.dts line 239

Quoted 6 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +6 -0
+ 			interrupts = <17 8>;
+ 			interrupt-map = <0 0 0 1 700 17 8>;
+ 			interrupt-map-mask = <0>;
+ 
+ 			#size-cells = <1>;
+ 			#address-cells = <1>;

Same question here.

arch/powerpc/boot/dts/mpc8349emitx.dts line 242

Quoted 3 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +3 -0
+ 			reg = <10000000 10 10000200 10>;
+ 
+ 			device_type = "ide";

I think that already adopted device type is "ata", not "ide".

Quoted 12 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +4 -0
+ 			compatible = "mmio-ide";
+ 			interrupt-parent = < &ipic >;
+ 		};
+
 		ipic: pic@700 {
 			interrupt-controller;
 			#address-cells = <0>;
arch/powerpc/sysdev/fsl_soc.c +0 -0
index cad1757..b3fe011 100644

arch/powerpc/sysdev/fsl_soc.c err: · line 1107

Quoted 5 lines
arch/powerpc/sysdev/fsl_soc.c +2 -0
@@ -1103,3 +1103,116 @@ err:
 arch_initcall(cpm_smc_uart_of_init);
 
 #endif /* CONFIG_8xx */
+
+#ifdef CONFIG_MPC834x_ITX

Erm, isn't this stuff misplaced? Is this really SoC device? I remember
seeng this in the arch/ppc/ platform code before (in the internal tree)...

Quoted 8 lines
arch/powerpc/sysdev/fsl_soc.c +8 -0
+#include <linux/ide.h>
+#include <linux/mmio-ide.h>
+#include <asm-ppc/mpc83xx.h>
+
+static void mmio_ide_outsw(unsigned long port, void *addr, u32 count)
+{
+	_outsw_ns((void __iomem *)port, addr, count);
+}

arch/powerpc/sysdev/fsl_soc.c err: · line 1126

Quoted 10 lines
arch/powerpc/sysdev/fsl_soc.c +10 -0
+
+static void mmio_ide_insw(unsigned long port, void *addr, u32 count)
+{
+	_insw_ns((void __iomem *)port, addr, count);
+}
+
+void mmio_ide_mmiops (ide_hwif_t *hwif)
+{
+	default_hwif_mmiops(hwif);
+	hwif->OUTL = NULL;

OUTL() method no longer exists.

arch/powerpc/sysdev/fsl_soc.c err: · line 1129

Quoted 3 lines
arch/powerpc/sysdev/fsl_soc.c +3 -0
+	hwif->OUTSW = mmio_ide_outsw;
+	hwif->OUTSL = NULL;
+	hwif->INL = NULL;

And neither INL() does.

Quoted 5 lines
arch/powerpc/sysdev/fsl_soc.c +5 -0
+	hwif->INSW = mmio_ide_insw;
+	hwif->INSL = NULL;
+}
+
+void mmio_ide_selectproc (ide_drive_t *drive)

arch/powerpc/sysdev/fsl_soc.c err: · line 1144

Quoted 10 lines
arch/powerpc/sysdev/fsl_soc.c +10 -0
+{
+	u8 stat;
+
+	stat = drive->hwif->INB(IDE_STATUS_REG);
+	if ((stat & READY_STAT) && (stat & BUSY_STAT))
+		drive->present = 0;
+	else
+		drive->present = 1;
+}
+

Heh, attempt to emulate hotplug. :-)

Quoted 7 lines
arch/powerpc/sysdev/fsl_soc.c +7 -0
+static int __init fsl_mmio_ide_of_init(void)
+{
+	struct device_node *np;
+	unsigned int i;
+
+	for (np = NULL, i = 0;
+	     (np = of_find_compatible_node(np, "ide", "mmio-ide")) != NULL;

arch/powerpc/sysdev/fsl_soc.c err: · line 1161

Quoted 10 lines
arch/powerpc/sysdev/fsl_soc.c +10 -0
+	     i++) {
+		int ret = 0;
+		struct resource res[3];
+		struct platform_device *pdev = NULL;
+		static struct mmio_ide_platform_data pdata = {
+			/* TODO: pass via OF? */
+			.byte_lanes_swapping = 0,
+			.regaddr_step        = 2,
+			.mmiops              = mmio_ide_mmiops,
+			.selectproc          = mmio_ide_selectproc,

Definitely, you won't be able to pass methods via of_platform_device. :-)

arch/powerpc/sysdev/fsl_soc.c err: · line 1169

Quoted 8 lines
arch/powerpc/sysdev/fsl_soc.c +8 -0
+		};
+
+		memset(res, 0, sizeof(res));
+
+		ret = of_address_to_resource(np, 0, &res[0]);
+		if (ret) {
+			printk(KERN_ERR "mmio-ide.%d: unable to get "
+			       "resource from OF\n",i );

CodingStyle: space after comma, no space before paren.

[...]

arch/powerpc/sysdev/fsl_soc.c err: · line 1186

Quoted 2 lines
arch/powerpc/sysdev/fsl_soc.c +2 -0
+		res[2].name = "mmio-ide";
+		res[2].flags = IORESOURCE_IRQ;;

One ; too many here. ;-)

MBR, Sergei

#9 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Hmm, are we still adding new IDE drivers? Do you also have a

Yes, why not?

Quoted 1 line

driver for the new libata layer?

No (sorry for replying for Vitaly but I know the situation).

Quoted 1 line

I think it would even be simpler to do.

Wel have no interest in it right now.

Quoted 2 lines

You could also make it an of_platform_driver at the same time instead of adding more cruft to fsl_soc.c. Since we're already

That's a fair point (and fsl_soc.c doesn't seem proper place anyway).

Quoted 3 lines

about to add the electra_ide.c driver in 2.6.23, I guess there should really be _one_ driver that is able to handle all of_device based ATA hosts.

One driver to rule them all. :-)
That may be not so simple as it seems...

MBR, Sergei

#17 lore raw
In reply to Vitaly Bordug

Hello.

Quoted 3 lines · Vitaly Bordug

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

[...]

Quoted 5 lines
drivers/ide/legacy/mmio-ide.c new file +0 -0
new file mode 100644
index 0000000..77fb7dd

[...]

drivers/ide/legacy/mmio-ide.c line 72

Quoted 1 line
drivers/ide/legacy/mmio-ide.c new file +1 -0
+	hwif->mmio = 2;
    That hwif->mmio is single-bit field now, so can only be 0 or 1.

MBR, Sergei

#10 lore raw
In reply to Sergei Shtylyov
Quoted 11 lines · Sergei Shtylyov
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Hmm, are we still adding new IDE drivers? Do you also have a

Yes, why not?

The last time someone (I think Akira Iguchi) wanted to add a new powerpc specific IDE driver, that was rejected based on the argument that drivers/ide/ is going away soon. Most current distros have already moved over to using libata exclusively.

Quoted 6 lines
Quoted 3 lines

about to add the electra_ide.c driver in 2.6.23, I guess there should really be _one_ driver that is able to handle all of_device based ATA hosts.

One driver to rule them all. :-)
That may be not so simple as it seems...

It's certainly not easy to support all ATA chips that have special capabilities and bugs, but the electra and the mpc8349-itx both seem to support only the most basic ATA PIO mode anyway, which does not require much special handling beyond finding the right mmio addresses.

	Arnd <><
#13 lore raw
In reply to Arnd Bergmann
Quoted 5 lines

You could also make it an of_platform_driver at the same time instead of adding more cruft to fsl_soc.c. Since we're already about to add the electra_ide.c driver in 2.6.23, I guess there should really be _one_ driver that is able to handle all of_device based ATA hosts.

and do so using libata. Preferably ata_platform but it does look like ata_of would make sense as a companion.

Alan

#18 lore raw
In reply to Vitaly Bordug
Quoted 3 lines · On Sat, 07 Jul 2007 13:48:52 +0400 Vitaly Bordug <[email protected]>…

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Really we should be working towards libata support for all new devices. This looks like a candidate for the existing (or a little enhanced) pata_platform driver.

drivers/ide/Kconfig config BLK_DEV_MPC8xx_IDE · line 950

Quoted 2 lines
drivers/ide/Kconfig +2 -0
+config BLK_DEV_MMIOIDE
+	tristate "Memory Mapped IDE support"

Please pick a better description. This isn't a generic option for enabling MMIO based IDE as you make it sound.

Also we have an accepted match name for ATA platform devices - and adding another one messes it up irrespective of whether you want libata or legacy IDE support. If you use the same matches then your platform code, and everyone elses platform code can work with both drivers, except for hotpluggability.

Other bugs

- Your remove code releases the resources before the hwif which means it races another user trying to claim the resource
- Be careful with ide_unregister. It exists and you can call it but its actually not very safe and there are lots of unfixed races in the IDE layer if you do

The "should we have a legacy ide driver that matches the libata pata_platform" question I don't really care about. Its a waste of effort in many ways but if you've written the code the work is done so why not use it.

However it needs to be *compatible* so that platform devices can be claimed by either so the kernel build can pick legacy IDE v libata and not have to #ifdef all the platform code.

Alan

#14 lore raw
In reply to Alan Cox
Quoted 8 lines · Alan Cox
Quoted 5 lines

You could also make it an of_platform_driver at the same time instead of adding more cruft to fsl_soc.c. Since we're already about to add the electra_ide.c driver in 2.6.23, I guess there should really be _one_ driver that is able to handle all of_device based ATA hosts.

and do so using libata. Preferably ata_platform but it does look like ata_of would make sense as a companion.

I wouldn't push for it too much tho. It's perfectly fine to have "helpers" generate xx_platform from the device-tree. Since I added the generic dev_archdata to struct device, it's easy for the arch to keep track of OF devices for anything, it doesn't have to be an of_platform device or anything like that anymore.

One of the things I have in mind is to provide a way to register "constructors" that are based on an OF match set. Those would then be called by the arch code for every OF node that matches, and would then "construct" the appropriate linux device. Could be some kind of platform device, could even be PCI devs.

Ben.

#11 lore raw
In reply to Arnd Bergmann

Hi,

Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Sergei Shtylyov
Quoted 5 lines · Arnd Bergmann
Quoted 5 lines

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Hmm, are we still adding new IDE drivers? Do you also have a

Yes, why not?

The last time someone (I think Akira Iguchi) wanted to add a new powerpc specific IDE driver, that was rejected based

linux/drivers/ide/pci/scc_pata.c

New IDE host drivers are still fine.

Quoted 3 lines

on the argument that drivers/ide/ is going away soon. Most current distros have already moved over to using libata exclusively.

The in-kernel default for PATA systems is still IDE subsystem.

Thanks,
Bart

#5 lore raw

Re: [PATCH 2/2] [POWERPC] mmio ide support for mpc8349-itx target

In reply to Sergei Shtylyov
Quoted 8 lines

arch/powerpc/boot/dts/mpc8349emitx.dts line 233

Quoted 2 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +2 -0
+		ide@10000000 {
+ 			#interrupt-cells = <2>;

Hm, why define that prop for a node with no children?

Quoted 3 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +3 -0
+ 			interrupts = <17 8>;
+ 			interrupt-map = <0 0 0 1 700 17 8>;
+ 			interrupt-map-mask = <0>;

This map-mask makes no sense either. And neither does the map itself.

Quoted 5 lines

arch/powerpc/boot/dts/mpc8349emitx.dts line 239

Quoted 3 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +3 -0
+
+ 			#size-cells = <1>;
+ 			#address-cells = <1>;

Same question here.

The ide node might want children, namely disks or optical drives or such, but #size-cells should be 0.

Quoted 5 lines

arch/powerpc/boot/dts/mpc8349emitx.dts line 242

Quoted 3 lines
arch/powerpc/boot/dts/mpc8349emitx.dts +3 -0
+ 			reg = <10000000 10 10000200 10>;
+
+ 			device_type = "ide";

I think that already adopted device type is "ata", not "ide".

"ata" is not a hardware thing, "ide" is. Or so I'm told. I'd leave out the "device_type" completely though, certainly if you can't point me at a published device binding :-)

Segher

#12 lore raw
In reply to Bartlomiej Zolnierkiewicz
Quoted 6 lines · Bartlomiej Zolnierkiewicz
Quoted 4 lines

on the argument that drivers/ide/ is going away soon. Most current distros have already moved over to using libata exclusively.

The in-kernel default for PATA systems is still IDE subsystem.

In part because libata still does not yet work correctly for at least some (older) ide chipsets (like mine).

--linas

#16 lore raw
In reply to Olof Johansson
Quoted 9 lines · On Sat, 7 Jul 2007 10:01:47 -0500 Olof Johansson wrote:
Quoted 3 lines · Vitaly Bordug

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Doesn't this duplicate most of pata_platform, but as the no-longer-preferred legacy IDE device? Did you try using pata_platform instead?

prolly true,
but as Sergei told upper, that's not an option so far due to internal reasons. But it is likely to be followed-up that way a little bit later.

Quoted 2 lines

-Olof

Signature · 4 lines
Sincerely, Vitaly

-- 
Sincerely, Vitaly
#19 lore raw
In reply to Alan Cox
Quoted 11 lines · On Sat, 7 Jul 2007 21:13:06 +0100 Alan Cox wrote:
Quoted 3 lines · On Sat, 07 Jul 2007 13:48:52 +0400 Vitaly Bordug <[email protected]>…

This adds support for MMIO IDE device like CompactFlash in TrueIDE mode.

Really we should be working towards libata support for all new devices. This looks like a candidate for the existing (or a little enhanced) pata_platform driver.

Yes I am aware of it, yet, the code was created for IDE subsystem due to internal reasons, and I thought to better make it available for others at least. We'll prolly pick it up to move to libata/pata_platform but not instantly afaict now.

Quoted 13 lines

drivers/ide/Kconfig config BLK_DEV_MPC8xx_IDE · line 950

Quoted 2 lines
drivers/ide/Kconfig +2 -0
+config BLK_DEV_MMIOIDE
+	tristate "Memory Mapped IDE support"

Please pick a better description. This isn't a generic option for enabling MMIO based IDE as you make it sound.

Also we have an accepted match name for ATA platform devices - and adding another one messes it up irrespective of whether you want libata or legacy IDE support. If you use the same matches then your platform code, and everyone elses platform code can work with both drivers, except for hotpluggability.

Quoted 8 lines

Other bugs

- Your remove code releases the resources before the hwif which means it races another user trying to claim the resource
- Be careful with ide_unregister. It exists and you can call it but its actually not very safe and there are lots of unfixed races in the IDE layer if you do

OK, makes sense.

Quoted 10 lines

The "should we have a legacy ide driver that matches the libata pata_platform" question I don't really care about. Its a waste of effort in many ways but if you've written the code the work is done so why not use it.

However it needs to be *compatible* so that platform devices can be claimed by either so the kernel build can pick legacy IDE v libata and not have to #ifdef all the platform code.

Sounds good. I'll look forward to address the issues, thanks.

Quoted 1 line

Alan

Signature · 1 line
Sincerely, Vitaly
#6 lore raw

Re: [PATCH 2/2] [POWERPC] mmio ide support for mpc8349-itx target

In reply to Sergei Shtylyov
Quoted 6 lines · On Sat, 07 Jul 2007 20:46:46 +0400 Sergei Shtylyov wrote:

arch/powerpc/sysdev/fsl_soc.c err: · line 1107

Quoted 2 lines
arch/powerpc/sysdev/fsl_soc.c +2 -0
+
+#ifdef CONFIG_MPC834x_ITX  

Erm, isn't this stuff misplaced? Is this really SoC device? I
remember seeng this in the arch/ppc/ platform code before (in the internal tree)...

The point is to declare methods bsp, as mmio access may effectively vary (having bugs or intentionally) from platform to platform. All-in-one driver approach is nice but might be an issue to handle/maintain.

Thanks for looking at it, other notes make sense.

Signature · 1 line
Sincerely, Vitaly
#7 lore raw

Re: [PATCH 2/2] [POWERPC] mmio ide support for mpc8349-itx target

Hello.

Quoted 8 lines · Vitaly Bordug
Quoted 6 lines

arch/powerpc/sysdev/fsl_soc.c err: · line 1107

Quoted 2 lines
arch/powerpc/sysdev/fsl_soc.c +2 -0
+
+#ifdef CONFIG_MPC834x_ITX  

Erm, isn't this stuff misplaced? Is this really SoC device? I
remember seeng this in the arch/ppc/ platform code before (in the internal tree)...

The point is to declare methods bsp, as mmio access may effectively vary (having bugs or intentionally) from platform to platform. All-in-one driver approach is nice but might be an issue to handle/maintain.

You misunderstood. Why this was placed in fsl_soc.c and not in the proper
platform code (as it was in the internal tree even)?

MBR, Sergei