linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-23 17:52 [RFC][PATCH 0/3] OF-platform PATA driver Anton Vorontsov
@ 2007-11-23 17:53 ` Anton Vorontsov
  0 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-23 17:53 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide


Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/ata/Kconfig            |   10 +++++
 drivers/ata/Makefile           |    1 +
 drivers/ata/pata_of_platform.c |   88 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_of_platform.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba63619..5a492fa 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -614,6 +614,16 @@ config PATA_PLATFORM
 
 	  If unsure, say N.
 
+config PATA_OF_PLATFORM
+	tristate "OpenFirmware platform device PATA support"
+	depends on PATA_PLATFORM && PPC_OF
+	help
+	  This option enables support for generic directly connected ATA
+	  devices commonly found on embedded systems with OpenFirmware
+	  bindings.
+
+	  If unsure, say N.
+
 config PATA_ICSIDE
 	tristate "Acorn ICS PATA support"
 	depends on ARM && ARCH_ACORN
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b13feb2..ebcee64 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
 obj-$(CONFIG_PATA_SCC)		+= pata_scc.o
 obj-$(CONFIG_PATA_BF54X)	+= pata_bf54x.o
 obj-$(CONFIG_PATA_PLATFORM)	+= pata_platform.o
+obj-$(CONFIG_PATA_OF_PLATFORM)	+= pata_of_platform.o
 obj-$(CONFIG_PATA_ICSIDE)	+= pata_icside.o
 # Should be last but two libata driver
 obj-$(CONFIG_PATA_ACPI)		+= pata_acpi.o
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
new file mode 100644
index 0000000..b4eca70
--- /dev/null
+++ b/drivers/ata/pata_of_platform.c
@@ -0,0 +1,88 @@
+/*
+ * OF-platform PATA driver
+ *
+ * Copyright (c) 2007  MontaVista Software, Inc.
+ *                     Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (Version 2) as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include "pata_platform.h"
+
+static int __devinit pata_of_platform_probe(struct of_device *ofdev,
+					    const struct of_device_id *match)
+{
+	int ret;
+	struct device_node *dn = ofdev->node;
+	struct resource io_res;
+	struct resource ctl_res;
+	struct resource irq_res;
+	unsigned int ioport_shift = 0;
+	uint32_t *prop;
+
+	ret = of_address_to_resource(dn, 0, &io_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get IO address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_address_to_resource(dn, 1, &ctl_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get CTL address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_irq_to_resource(dn, 0, &irq_res);
+	if (ret == NO_IRQ)
+		irq_res.start = irq_res.end = -1;
+	else
+		irq_res.flags = 0;
+
+	prop = (uint32_t *)of_get_property(dn, "ioport-shift", NULL);
+	if (prop)
+		ioport_shift = *prop;
+
+	return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res,
+				     ioport_shift);
+}
+
+static int __devexit pata_of_platform_remove(struct of_device *ofdev)
+{
+	return __pata_platform_remove(&ofdev->dev);
+}
+
+static struct of_device_id pata_of_platform_match[] = {
+	{
+		.compatible = "pata-platform",
+	},
+};
+
+static struct of_platform_driver pata_of_platform_driver = {
+	.name		= "pata_of_platform",
+	.match_table	= pata_of_platform_match,
+	.probe		= pata_of_platform_probe,
+	.remove		= __devexit_p(pata_of_platform_remove),
+};
+
+static int __init pata_of_platform_init(void)
+{
+	return of_register_platform_driver(&pata_of_platform_driver);
+}
+module_init(pata_of_platform_init);
+
+static void __exit pata_platform_exit(void)
+{
+	of_unregister_platform_driver(&pata_of_platform_driver);
+}
+module_exit(pata_platform_exit);
+
+MODULE_DESCRIPTION("OF-platform PATA driver");
+MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
+MODULE_LICENSE("GPL");
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 15:37 [PATCH 0/3] OF-platform PATA driver Anton Vorontsov
@ 2007-11-27 15:39 ` Anton Vorontsov
  2007-11-27 21:22   ` Olof Johansson
                     ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-27 15:39 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide

This driver nicely wraps around pata_platform library functions,
and provides OF platform bus bindings to the PATA devices.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/ata/Kconfig            |   10 +++++
 drivers/ata/Makefile           |    1 +
 drivers/ata/pata_of_platform.c |   86 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_of_platform.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba63619..5a492fa 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -614,6 +614,16 @@ config PATA_PLATFORM
 
 	  If unsure, say N.
 
+config PATA_OF_PLATFORM
+	tristate "OpenFirmware platform device PATA support"
+	depends on PATA_PLATFORM && PPC_OF
+	help
+	  This option enables support for generic directly connected ATA
+	  devices commonly found on embedded systems with OpenFirmware
+	  bindings.
+
+	  If unsure, say N.
+
 config PATA_ICSIDE
 	tristate "Acorn ICS PATA support"
 	depends on ARM && ARCH_ACORN
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b13feb2..ebcee64 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
 obj-$(CONFIG_PATA_SCC)		+= pata_scc.o
 obj-$(CONFIG_PATA_BF54X)	+= pata_bf54x.o
 obj-$(CONFIG_PATA_PLATFORM)	+= pata_platform.o
+obj-$(CONFIG_PATA_OF_PLATFORM)	+= pata_of_platform.o
 obj-$(CONFIG_PATA_ICSIDE)	+= pata_icside.o
 # Should be last but two libata driver
 obj-$(CONFIG_PATA_ACPI)		+= pata_acpi.o
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
new file mode 100644
index 0000000..e6c769c
--- /dev/null
+++ b/drivers/ata/pata_of_platform.c
@@ -0,0 +1,86 @@
+/*
+ * OF-platform PATA driver
+ *
+ * Copyright (c) 2007  MontaVista Software, Inc.
+ *                     Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (Version 2) as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/pata_platform.h>
+
+static int __devinit pata_of_platform_probe(struct of_device *ofdev,
+					    const struct of_device_id *match)
+{
+	int ret;
+	struct device_node *dn = ofdev->node;
+	struct resource io_res;
+	struct resource ctl_res;
+	struct resource irq_res;
+	unsigned int ioport_shift = 0;
+	uint32_t *prop;
+
+	ret = of_address_to_resource(dn, 0, &io_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get IO address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_address_to_resource(dn, 1, &ctl_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get CTL address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_irq_to_resource(dn, 0, &irq_res);
+	if (ret == NO_IRQ)
+		irq_res.start = irq_res.end = -1;
+	else
+		irq_res.flags = 0;
+
+	prop = (uint32_t *)of_get_property(dn, "ioport-shift", NULL);
+	if (prop)
+		ioport_shift = *prop;
+
+	return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res,
+				     ioport_shift);
+}
+
+static int __devexit pata_of_platform_remove(struct of_device *ofdev)
+{
+	return __pata_platform_remove(&ofdev->dev);
+}
+
+static struct of_device_id pata_of_platform_match[] = {
+	{ .compatible = "pata-platform", },
+};
+
+static struct of_platform_driver pata_of_platform_driver = {
+	.name		= "pata_of_platform",
+	.match_table	= pata_of_platform_match,
+	.probe		= pata_of_platform_probe,
+	.remove		= __devexit_p(pata_of_platform_remove),
+};
+
+static int __init pata_of_platform_init(void)
+{
+	return of_register_platform_driver(&pata_of_platform_driver);
+}
+module_init(pata_of_platform_init);
+
+static void __exit pata_of_platform_exit(void)
+{
+	of_unregister_platform_driver(&pata_of_platform_driver);
+}
+module_exit(pata_of_platform_exit);
+
+MODULE_DESCRIPTION("OF-platform PATA driver");
+MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
+MODULE_LICENSE("GPL");
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 15:39 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
@ 2007-11-27 21:22   ` Olof Johansson
  2007-11-27 21:32     ` Arnd Bergmann
  2007-11-28  0:41   ` Stephen Rothwell
  2007-12-02  3:59   ` Olof Johansson
  2 siblings, 1 reply; 30+ messages in thread
From: Olof Johansson @ 2007-11-27 21:22 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, linux-ide

On Tue, Nov 27, 2007 at 06:39:08PM +0300, Anton Vorontsov wrote:
> This driver nicely wraps around pata_platform library functions,
> and provides OF platform bus bindings to the PATA devices.

> +static struct of_device_id pata_of_platform_match[] = {
> +	{ .compatible = "pata-platform", },
> +};

"pata-platform" really means nothing outside of linux. A more
generic label would be useful.


-Olof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 21:22   ` Olof Johansson
@ 2007-11-27 21:32     ` Arnd Bergmann
  2007-11-28 15:49       ` Anton Vorontsov
  2007-11-28 16:29       ` Sergei Shtylyov
  0 siblings, 2 replies; 30+ messages in thread
From: Arnd Bergmann @ 2007-11-27 21:32 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Olof Johansson, linux-ide

On Tuesday 27 November 2007, Olof Johansson wrote:
> On Tue, Nov 27, 2007 at 06:39:08PM +0300, Anton Vorontsov wrote:
> > This driver nicely wraps around pata_platform library functions,
> > and provides OF platform bus bindings to the PATA devices.
>=20
> > +static struct of_device_id pata_of_platform_match[] =3D {
> > +=A0=A0=A0=A0=A0{ .compatible =3D "pata-platform", },
> > +};
>=20
> "pata-platform" really means nothing outside of linux. A more
> generic label would be useful.

Maybe the name of the standards it supports? Could be
"ata-4", "ata-5" and the like, or the exact transfer mode, like
"pata-udma-5", "pata-pio-3", "sata-150", etc.

	Arnd <><

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 15:39 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
  2007-11-27 21:22   ` Olof Johansson
@ 2007-11-28  0:41   ` Stephen Rothwell
  2007-12-02  3:59   ` Olof Johansson
  2 siblings, 0 replies; 30+ messages in thread
From: Stephen Rothwell @ 2007-11-28  0:41 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, linux-ide

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On Tue, 27 Nov 2007 18:39:08 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
>
> +static int __devinit pata_of_platform_probe(struct of_device *ofdev,
> +					    const struct of_device_id *match)
> +{
> +	uint32_t *prop;

Make this "const uint32_t *prop" or (more kernel like) "const u32 *prop" ...

> +	prop = (uint32_t *)of_get_property(dn, "ioport-shift", NULL);

then you don't need this cast.  Anytime you use a cast to get rid of
"const", is probably a mistake.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 21:32     ` Arnd Bergmann
@ 2007-11-28 15:49       ` Anton Vorontsov
  2007-11-28 16:11         ` Sergei Shtylyov
  2007-11-28 16:29       ` Sergei Shtylyov
  1 sibling, 1 reply; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-28 15:49 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Olof Johansson, linuxppc-dev, linux-ide

On Tue, Nov 27, 2007 at 10:32:58PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 November 2007, Olof Johansson wrote:
> > On Tue, Nov 27, 2007 at 06:39:08PM +0300, Anton Vorontsov wrote:
> > > This driver nicely wraps around pata_platform library functions,
> > > and provides OF platform bus bindings to the PATA devices.
> > 
> > > +static struct of_device_id pata_of_platform_match[] = {
> > > +     { .compatible = "pata-platform", },
> > > +};
> > 
> > "pata-platform" really means nothing outside of linux. A more
> > generic label would be useful.

Agreed.

> Maybe the name of the standards it supports? Could be
> "ata-4", "ata-5" and the like, or the exact transfer mode, like
> "pata-udma-5", "pata-pio-3", "sata-150", etc.

You're quite optimistic about pata_platform capabilities. ;-)

As far as I know it is [obviously] supports PIO modes only. And so
far I was able to get max 5.28 MB/s read transfers. Which looks like
ideal case for PIO1 (CF I'm testing on is 3.0, max. PIO4).

I've modified pio_mask appropriately, plus I've tried to comment
out .set_mode = pata_platform_set_mode, and now it says:

ata5: PATA max PIO4 mmio cmd 0xf0000000 ctl 0xf000020c irq 24
ata5.00: CFA: TOSHIBA THNCF512MQG, 3.00, max PIO4
ata5.00: configured for PIO4
ata5.00: configured for PIO4

That looks good, but speed is the same. Oh well, it's another
matter.


Back to dts, I think pata-pio-X is good scheme. That way we can
pass pio_mask via device tree. Sounds reasonable?

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-28 15:49       ` Anton Vorontsov
@ 2007-11-28 16:11         ` Sergei Shtylyov
  2007-11-29  0:54           ` Anton Vorontsov
  0 siblings, 1 reply; 30+ messages in thread
From: Sergei Shtylyov @ 2007-11-28 16:11 UTC (permalink / raw)
  To: avorontsov; +Cc: Olof Johansson, linuxppc-dev, Arnd Bergmann, linux-ide

Anton Vorontsov wrote:

>>>>This driver nicely wraps around pata_platform library functions,
>>>>and provides OF platform bus bindings to the PATA devices.

>>>>+static struct of_device_id pata_of_platform_match[] = {
>>>>+     { .compatible = "pata-platform", },
>>>>+};

>>>"pata-platform" really means nothing outside of linux. A more
>>>generic label would be useful.

> Agreed.

    Now you're quick to agree. :-)

>>Maybe the name of the standards it supports? Could be
>>"ata-4", "ata-5" and the like, or the exact transfer mode, like
>>"pata-udma-5", "pata-pio-3", "sata-150", etc.

> You're quite optimistic about pata_platform capabilities. ;-)

    Indeed. :-)

> As far as I know it is [obviously] supports PIO modes only. And so
> far I was able to get max 5.28 MB/s read transfers. Which looks like
> ideal case for PIO1 (CF I'm testing on is 3.0, max. PIO4).

    Believe me, it's a great speed even for PIO4. Most systems only show 3+ 
MiB/s in this mode according to hdparm.

> I've modified pio_mask appropriately, plus I've tried to comment
> out .set_mode = pata_platform_set_mode, and now it says:

> ata5: PATA max PIO4 mmio cmd 0xf0000000 ctl 0xf000020c irq 24
> ata5.00: CFA: TOSHIBA THNCF512MQG, 3.00, max PIO4
> ata5.00: configured for PIO4
> ata5.00: configured for PIO4

> That looks good, but speed is the same. Oh well, it's another
> matter.

> Back to dts, I think pata-pio-X is good scheme. That way we can
> pass pio_mask via device tree. Sounds reasonable?

    Grumble. Can't we pass this via some property other than "compatible"? I'm 
opposed to "ata-5" and the like in there as well cause it's not clear what 
information this would provide. Why people so love to make things complex WRT 
the "compatible" property -- instead of making the task of selecting a proper 
driver more simple, they tend to make it mode complex by trying to specify 
values that have quite little to do with the device's programming interface 
itself...

MBR, Sergei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 21:32     ` Arnd Bergmann
  2007-11-28 15:49       ` Anton Vorontsov
@ 2007-11-28 16:29       ` Sergei Shtylyov
  1 sibling, 0 replies; 30+ messages in thread
From: Sergei Shtylyov @ 2007-11-28 16:29 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Olof Johansson, linuxppc-dev, linux-ide

Hello.

Arnd Bergmann wrote:

>>>This driver nicely wraps around pata_platform library functions,
>>>and provides OF platform bus bindings to the PATA devices.

>>>+static struct of_device_id pata_of_platform_match[] = {
>>>+     { .compatible = "pata-platform", },
>>>+};

>>"pata-platform" really means nothing outside of linux. A more
>>generic label would be useful.

> Maybe the name of the standards it supports? Could be
> "ata-4", "ata-5" and the like,

    It's not clear what info this would provide.

> or the exact transfer mode, like
> "pata-udma-5", "pata-pio-3", "sata-150", etc.

    I think this info should follow from the compatible property value 
implicitly, or maybe this info should be conveyed in some optional properties. 
It doesn't make sense to the generic platform driver anyway since it has no 
notion about the mode programming specifics. I think that as the device being 
driven is assumed to be a generic IDE device, the "compatible" property should 
contain "generic" or something alike (as well as usual board's and chip's names).

> 	Arnd <><

MBR, Sergei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-28 16:11         ` Sergei Shtylyov
@ 2007-11-29  0:54           ` Anton Vorontsov
  2007-11-30 10:17             ` Sergei Shtylyov
  0 siblings, 1 reply; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-29  0:54 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Olof Johansson, linuxppc-dev, Arnd Bergmann, linux-ide

On Wed, Nov 28, 2007 at 07:11:19PM +0300, Sergei Shtylyov wrote:
> Anton Vorontsov wrote:
> 
> >>>>This driver nicely wraps around pata_platform library functions,
> >>>>and provides OF platform bus bindings to the PATA devices.
> 
> >>>>+static struct of_device_id pata_of_platform_match[] = {
> >>>>+     { .compatible = "pata-platform", },
> >>>>+};
> 
> >>>"pata-platform" really means nothing outside of linux. A more
> >>>generic label would be useful.
> 
> > Agreed.
> 
>     Now you're quick to agree. :-)

I'm quick to change my mind either. ;-)

*BOOM*, I changed my mind.

> >>Maybe the name of the standards it supports? Could be
> >>"ata-4", "ata-5" and the like, or the exact transfer mode, like
> >>"pata-udma-5", "pata-pio-3", "sata-150", etc.
> 
> > You're quite optimistic about pata_platform capabilities. ;-)
> 
>     Indeed. :-)
> 
> > As far as I know it is [obviously] supports PIO modes only. And so
> > far I was able to get max 5.28 MB/s read transfers. Which looks like
> > ideal case for PIO1 (CF I'm testing on is 3.0, max. PIO4).
> 
>     Believe me, it's a great speed even for PIO4. Most systems only show 3+ 
> MiB/s in this mode according to hdparm.
> 
> > I've modified pio_mask appropriately, plus I've tried to comment
> > out .set_mode = pata_platform_set_mode, and now it says:
> 
> > ata5: PATA max PIO4 mmio cmd 0xf0000000 ctl 0xf000020c irq 24
> > ata5.00: CFA: TOSHIBA THNCF512MQG, 3.00, max PIO4
> > ata5.00: configured for PIO4
> > ata5.00: configured for PIO4
> 
> > That looks good, but speed is the same. Oh well, it's another
> > matter.
> 
> > Back to dts, I think pata-pio-X is good scheme. That way we can
> > pass pio_mask via device tree. Sounds reasonable?
> 
>     Grumble. Can't we pass this via some property other than "compatible"? I'm 
> opposed to "ata-5" and the like in there as well cause it's not clear what 
> information this would provide. Why people so love to make things complex WRT 
> the "compatible" property -- instead of making the task of selecting a proper 
> driver more simple, they tend to make it mode complex by trying to specify 
> values that have quite little to do with the device's programming interface 
> itself...

Ok, now I'm agree here. dts already specifying "fsl,mpc8349emitx-pata",
second compatible entry is okay to mean nothing outside Linux itself,
there are plenty of examples for such kind.

Remaining question: any preferred name for that property? pio-mode okay?
It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-29  0:54           ` Anton Vorontsov
@ 2007-11-30 10:17             ` Sergei Shtylyov
  2007-11-30 10:58               ` Anton Vorontsov
  0 siblings, 1 reply; 30+ messages in thread
From: Sergei Shtylyov @ 2007-11-30 10:17 UTC (permalink / raw)
  To: cbou; +Cc: Olof Johansson, linuxppc-dev, Arnd Bergmann, linux-ide

Anton Vorontsov wrote:

> Remaining question: any preferred name for that property? pio-mode okay?
> It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.

    I've already suggested "generic". A name "simple" also comes to my mind.

WBR, Sergei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-30 10:17             ` Sergei Shtylyov
@ 2007-11-30 10:58               ` Anton Vorontsov
  2007-11-30 11:05                 ` Sergei Shtylyov
  2007-11-30 11:43                 ` Sergei Shtylyov
  0 siblings, 2 replies; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-30 10:58 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Olof Johansson, cbou, linux-ide, Arnd Bergmann, linuxppc-dev

On Fri, Nov 30, 2007 at 01:17:22PM +0300, Sergei Shtylyov wrote:
> Anton Vorontsov wrote:
> 
> >Remaining question: any preferred name for that property? pio-mode okay?
> >It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.
> 
>    I've already suggested "generic". A name "simple" also comes to my mind.

You've misread my question. I didn't ask about driver name, but pio-mode
property.


As for the driver name, it doesn't matter at all, as I've said already:
it's Linux specific anyway, and another compatible properties could be
added at any time, to a device tree and/or to the OF driver itself (if
some real OpenFirmware will pass some meaningful compatible property
that we'll have to match in that driver).

"generic" name is also bad one, it's confusing wrt ata_generic.c
driver (PCI). "simple" name doesn't tell anything at all. So, I'd
rather stick with -platform name.

Thanks,

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-30 10:58               ` Anton Vorontsov
@ 2007-11-30 11:05                 ` Sergei Shtylyov
  2007-11-30 11:45                   ` Anton Vorontsov
  2007-11-30 11:43                 ` Sergei Shtylyov
  1 sibling, 1 reply; 30+ messages in thread
From: Sergei Shtylyov @ 2007-11-30 11:05 UTC (permalink / raw)
  To: avorontsov; +Cc: Olof Johansson, cbou, linux-ide, Arnd Bergmann, linuxppc-dev

Anton Vorontsov wrote:

>>>Remaining question: any preferred name for that property? pio-mode okay?
>>>It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.

>>   I've already suggested "generic". A name "simple" also comes to my mind.

> You've misread my question. I didn't ask about driver name, but pio-mode
> property.

    I'm OK with "pio-mode" then. Just don't think it makes much sense in the 
context of this driver which has no provision for the programming the mode 
timings (and if there were some provision, the *generic* platform driver 
couldn't handle it anyway).

> As for the driver name, it doesn't matter at all, as I've said already:
> it's Linux specific anyway, and another compatible properties could be
> added at any time, to a device tree and/or to the OF driver itself (if
> some real OpenFirmware will pass some meaningful compatible property
> that we'll have to match in that driver).

> "generic" name is also bad one, it's confusing wrt ata_generic.c
> driver (PCI).

    The "compatible" property doesn't have to contain the driver name, so 
there should be no confusion with the driver names. It's just different name 
spaces. :-)

> "simple" name doesn't tell anything at all. So, I'd rather stick with -platform name.

    Well, those two should be "generic-ata" and "simple-ata" of course. And it 
*does* tell that the driver just provides taskfile control, without the 
transfer timing control and other fancy stuff...

> Thanks,

MBR, Sergei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-30 10:58               ` Anton Vorontsov
  2007-11-30 11:05                 ` Sergei Shtylyov
@ 2007-11-30 11:43                 ` Sergei Shtylyov
  2007-11-30 12:09                   ` Anton Vorontsov
  1 sibling, 1 reply; 30+ messages in thread
From: Sergei Shtylyov @ 2007-11-30 11:43 UTC (permalink / raw)
  To: avorontsov; +Cc: Olof Johansson, cbou, linux-ide, Arnd Bergmann, linuxppc-dev

Anton Vorontsov wrote:

>>>Remaining question: any preferred name for that property? pio-mode okay?
>>>It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.

>>   I've already suggested "generic". A name "simple" also comes to my mind.

> You've misread my question. I didn't ask about driver name, but pio-mode
> property.

    Probably "max-pio-mode" is a better variant.

MBR, Sergei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-30 11:05                 ` Sergei Shtylyov
@ 2007-11-30 11:45                   ` Anton Vorontsov
  0 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-30 11:45 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Olof Johansson, cbou, linux-ide, Arnd Bergmann, linuxppc-dev

On Fri, Nov 30, 2007 at 02:05:01PM +0300, Sergei Shtylyov wrote:
> Anton Vorontsov wrote:
> 
> >>>Remaining question: any preferred name for that property? pio-mode okay?
> >>>It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.
> 
> >>  I've already suggested "generic". A name "simple" also comes to my mind.
> 
> >You've misread my question. I didn't ask about driver name, but pio-mode
> >property.
> 
>    I'm OK with "pio-mode" then. Just don't think it makes much sense in the 
> context of this driver which has no provision for the programming the mode 
> timings (and if there were some provision, the *generic* platform driver 
> couldn't handle it anyway).

What sense it makes then?.. We're specifying bus limitations wrt
PIO modes.

Oh, I think you meant that bus can't be reconfigured by generic
driver, that's true. But I didn't mean this as a purpose for
pio-mode property (though it still could be used for that
purpose by other drivers).

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-30 11:43                 ` Sergei Shtylyov
@ 2007-11-30 12:09                   ` Anton Vorontsov
  0 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2007-11-30 12:09 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Olof Johansson, cbou, linux-ide, Arnd Bergmann, linuxppc-dev

On Fri, Nov 30, 2007 at 02:43:50PM +0300, Sergei Shtylyov wrote:
> Anton Vorontsov wrote:
> 
> >>>Remaining question: any preferred name for that property? pio-mode okay?
> >>>It's assuming that PIO6 capable bus supports PIO0 as well, thus no mask.
> 
> >>  I've already suggested "generic". A name "simple" also comes to my mind.
> 
> >You've misread my question. I didn't ask about driver name, but pio-mode
> >property.
> 
>    Probably "max-pio-mode" is a better variant.

Why? pio-mode in pata-platform context is just something highly
dependent on hardware, can not be touched. And we're passing
pio-mode information from the hardware dependent source --
device tree.

The only difference between pata-platform's max-pio-mode and
dedicated ata driver's pio-mode is that that for the first case
bus already configured for specified mode, and for the second
case dedicated driver should actually use this information
to configure hardware.

No need for max- prefix, I think.

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-11-27 15:39 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
  2007-11-27 21:22   ` Olof Johansson
  2007-11-28  0:41   ` Stephen Rothwell
@ 2007-12-02  3:59   ` Olof Johansson
  2 siblings, 0 replies; 30+ messages in thread
From: Olof Johansson @ 2007-12-02  3:59 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, linux-ide

On Tue, Nov 27, 2007 at 06:39:08PM +0300, Anton Vorontsov wrote:

> +static struct of_device_id pata_of_platform_match[] = {
> +	{ .compatible = "pata-platform", },
> +};

On top of previous comment about the compatible string being
inappropriate:

You should add a MODULE_DEVICE_TABLE() entry for this. Dave Woodhouse
pointed out it's needed for autoloading modules (i.e. by the fedora
installer, etc).


-Olof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-12-14 18:21 [PATCH v3 0/3] OF-platform PATA driver Anton Vorontsov
@ 2007-12-14 18:24 ` Anton Vorontsov
  2007-12-15 14:09   ` Stephen Rothwell
  0 siblings, 1 reply; 30+ messages in thread
From: Anton Vorontsov @ 2007-12-14 18:24 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide
  Cc: Jeff Garzik, Arnd Bergmann, Paul Mundt, Olof Johansson

This driver nicely wraps around pata_platform library functions,
and provides OF platform bus bindings to the PATA devices.

Also add || PPC to the PATA_PLATFORM's "depends on" Kconfig entry,
needed for PA Semi Electra.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Reviewed-by: Olof Johansson <olof@lixom.net>
---
 drivers/ata/Kconfig            |   12 ++++-
 drivers/ata/Makefile           |    1 +
 drivers/ata/pata_of_platform.c |  104 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 1 deletions(-)
 create mode 100644 drivers/ata/pata_of_platform.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba63619..64b4964 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -607,13 +607,23 @@ config PATA_WINBOND_VLB
 
 config PATA_PLATFORM
 	tristate "Generic platform device PATA support"
-	depends on EMBEDDED || ARCH_RPC
+	depends on EMBEDDED || ARCH_RPC || PPC
 	help
 	  This option enables support for generic directly connected ATA
 	  devices commonly found on embedded systems.
 
 	  If unsure, say N.
 
+config PATA_OF_PLATFORM
+	tristate "OpenFirmware platform device PATA support"
+	depends on PATA_PLATFORM && PPC_OF
+	help
+	  This option enables support for generic directly connected ATA
+	  devices commonly found on embedded systems with OpenFirmware
+	  bindings.
+
+	  If unsure, say N.
+
 config PATA_ICSIDE
 	tristate "Acorn ICS PATA support"
 	depends on ARM && ARCH_ACORN
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b13feb2..ebcee64 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
 obj-$(CONFIG_PATA_SCC)		+= pata_scc.o
 obj-$(CONFIG_PATA_BF54X)	+= pata_bf54x.o
 obj-$(CONFIG_PATA_PLATFORM)	+= pata_platform.o
+obj-$(CONFIG_PATA_OF_PLATFORM)	+= pata_of_platform.o
 obj-$(CONFIG_PATA_ICSIDE)	+= pata_icside.o
 # Should be last but two libata driver
 obj-$(CONFIG_PATA_ACPI)		+= pata_acpi.o
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
new file mode 100644
index 0000000..4daf118
--- /dev/null
+++ b/drivers/ata/pata_of_platform.c
@@ -0,0 +1,104 @@
+/*
+ * OF-platform PATA driver
+ *
+ * Copyright (c) 2007  MontaVista Software, Inc.
+ *                     Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (Version 2) as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/pata_platform.h>
+
+static int __devinit pata_of_platform_probe(struct of_device *ofdev,
+					    const struct of_device_id *match)
+{
+	int ret;
+	struct device_node *dn = ofdev->node;
+	struct resource io_res;
+	struct resource ctl_res;
+	struct resource irq_res;
+	unsigned int reg_shift = 0;
+	int pio_mode = 0;
+	int pio_mask;
+	const u32 *prop;
+
+	ret = of_address_to_resource(dn, 0, &io_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get IO address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_address_to_resource(dn, 1, &ctl_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get CTL address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_irq_to_resource(dn, 0, &irq_res);
+	if (ret == NO_IRQ)
+		irq_res.start = irq_res.end = -1;
+	else
+		irq_res.flags = 0;
+
+	prop = (u32 *)of_get_property(dn, "reg-shift", NULL);
+	if (prop)
+		reg_shift = *prop;
+
+	prop = (u32 *)of_get_property(dn, "pio-mode", NULL);
+	if (prop) {
+		pio_mode = *prop;
+		if (pio_mode > 6) {
+			dev_err(&ofdev->dev, "invalid pio-mode\n");
+			return -EINVAL;
+		}
+	} else {
+		dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n");
+	}
+
+	pio_mask = 1 << pio_mode;
+	pio_mask |= (1 << pio_mode) - 1;
+
+	return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res,
+				     reg_shift, pio_mask);
+}
+
+static int __devexit pata_of_platform_remove(struct of_device *ofdev)
+{
+	return __pata_platform_remove(&ofdev->dev);
+}
+
+static struct of_device_id pata_of_platform_match[] = {
+	{ .compatible = "ata-generic", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, pata_of_platform_match);
+
+static struct of_platform_driver pata_of_platform_driver = {
+	.name		= "pata_of_platform",
+	.match_table	= pata_of_platform_match,
+	.probe		= pata_of_platform_probe,
+	.remove		= __devexit_p(pata_of_platform_remove),
+};
+
+static int __init pata_of_platform_init(void)
+{
+	return of_register_platform_driver(&pata_of_platform_driver);
+}
+module_init(pata_of_platform_init);
+
+static void __exit pata_of_platform_exit(void)
+{
+	of_unregister_platform_driver(&pata_of_platform_driver);
+}
+module_exit(pata_of_platform_exit);
+
+MODULE_DESCRIPTION("OF-platform PATA driver");
+MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
+MODULE_LICENSE("GPL");
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-12-14 18:24 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
@ 2007-12-15 14:09   ` Stephen Rothwell
  2007-12-15 15:19     ` Anton Vorontsov
  0 siblings, 1 reply; 30+ messages in thread
From: Stephen Rothwell @ 2007-12-15 14:09 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Jeff Garzik, Arnd Bergmann, linux-ide, linuxppc-dev, Paul Mundt,
	Olof Johansson

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

On Fri, 14 Dec 2007 21:24:38 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
>
> +	prop = (u32 *)of_get_property(dn, "reg-shift", NULL);

This cast is unnecessary.

> +	if (prop)
> +		reg_shift = *prop;
> +
> +	prop = (u32 *)of_get_property(dn, "pio-mode", NULL);

So is this one.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2007-12-15 14:09   ` Stephen Rothwell
@ 2007-12-15 15:19     ` Anton Vorontsov
  0 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2007-12-15 15:19 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Jeff Garzik, Arnd Bergmann, linux-ide, linuxppc-dev, Paul Mundt,
	Olof Johansson

On Sun, Dec 16, 2007 at 01:09:22AM +1100, Stephen Rothwell wrote:
> On Fri, 14 Dec 2007 21:24:38 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
> >
> > +	prop = (u32 *)of_get_property(dn, "reg-shift", NULL);
> 
> This cast is unnecessary.
> 
> > +	if (prop)
> > +		reg_shift = *prop;
> > +
> > +	prop = (u32 *)of_get_property(dn, "pio-mode", NULL);
> 
> So is this one.

Thanks. I changed "prop" to const but obviously forgot to remove casts.

- - - - 
From: Anton Vorontsov <avorontsov@ru.mvista.com>

[libata] pata_of_platform: OF-Platform PATA device driver

This driver nicely wraps around pata_platform library functions,
and provides OF platform bus bindings to the PATA devices.

Also add || PPC to the PATA_PLATFORM's "depends on" Kconfig entry,
needed for PA Semi Electra.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Reviewed-by: Olof Johansson <olof@lixom.net>
---
 drivers/ata/Kconfig            |   12 ++++-
 drivers/ata/Makefile           |    1 +
 drivers/ata/pata_of_platform.c |  104 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 1 deletions(-)
 create mode 100644 drivers/ata/pata_of_platform.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba63619..64b4964 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -607,13 +607,23 @@ config PATA_WINBOND_VLB
 
 config PATA_PLATFORM
 	tristate "Generic platform device PATA support"
-	depends on EMBEDDED || ARCH_RPC
+	depends on EMBEDDED || ARCH_RPC || PPC
 	help
 	  This option enables support for generic directly connected ATA
 	  devices commonly found on embedded systems.
 
 	  If unsure, say N.
 
+config PATA_OF_PLATFORM
+	tristate "OpenFirmware platform device PATA support"
+	depends on PATA_PLATFORM && PPC_OF
+	help
+	  This option enables support for generic directly connected ATA
+	  devices commonly found on embedded systems with OpenFirmware
+	  bindings.
+
+	  If unsure, say N.
+
 config PATA_ICSIDE
 	tristate "Acorn ICS PATA support"
 	depends on ARM && ARCH_ACORN
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b13feb2..ebcee64 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
 obj-$(CONFIG_PATA_SCC)		+= pata_scc.o
 obj-$(CONFIG_PATA_BF54X)	+= pata_bf54x.o
 obj-$(CONFIG_PATA_PLATFORM)	+= pata_platform.o
+obj-$(CONFIG_PATA_OF_PLATFORM)	+= pata_of_platform.o
 obj-$(CONFIG_PATA_ICSIDE)	+= pata_icside.o
 # Should be last but two libata driver
 obj-$(CONFIG_PATA_ACPI)		+= pata_acpi.o
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
new file mode 100644
index 0000000..b7bc4e4
--- /dev/null
+++ b/drivers/ata/pata_of_platform.c
@@ -0,0 +1,104 @@
+/*
+ * OF-platform PATA driver
+ *
+ * Copyright (c) 2007  MontaVista Software, Inc.
+ *                     Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (Version 2) as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/pata_platform.h>
+
+static int __devinit pata_of_platform_probe(struct of_device *ofdev,
+					    const struct of_device_id *match)
+{
+	int ret;
+	struct device_node *dn = ofdev->node;
+	struct resource io_res;
+	struct resource ctl_res;
+	struct resource irq_res;
+	unsigned int reg_shift = 0;
+	int pio_mode = 0;
+	int pio_mask;
+	const u32 *prop;
+
+	ret = of_address_to_resource(dn, 0, &io_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get IO address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_address_to_resource(dn, 1, &ctl_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get CTL address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_irq_to_resource(dn, 0, &irq_res);
+	if (ret == NO_IRQ)
+		irq_res.start = irq_res.end = -1;
+	else
+		irq_res.flags = 0;
+
+	prop = of_get_property(dn, "reg-shift", NULL);
+	if (prop)
+		reg_shift = *prop;
+
+	prop = of_get_property(dn, "pio-mode", NULL);
+	if (prop) {
+		pio_mode = *prop;
+		if (pio_mode > 6) {
+			dev_err(&ofdev->dev, "invalid pio-mode\n");
+			return -EINVAL;
+		}
+	} else {
+		dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n");
+	}
+
+	pio_mask = 1 << pio_mode;
+	pio_mask |= (1 << pio_mode) - 1;
+
+	return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res,
+				     reg_shift, pio_mask);
+}
+
+static int __devexit pata_of_platform_remove(struct of_device *ofdev)
+{
+	return __pata_platform_remove(&ofdev->dev);
+}
+
+static struct of_device_id pata_of_platform_match[] = {
+	{ .compatible = "ata-generic", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, pata_of_platform_match);
+
+static struct of_platform_driver pata_of_platform_driver = {
+	.name		= "pata_of_platform",
+	.match_table	= pata_of_platform_match,
+	.probe		= pata_of_platform_probe,
+	.remove		= __devexit_p(pata_of_platform_remove),
+};
+
+static int __init pata_of_platform_init(void)
+{
+	return of_register_platform_driver(&pata_of_platform_driver);
+}
+module_init(pata_of_platform_init);
+
+static void __exit pata_of_platform_exit(void)
+{
+	of_unregister_platform_driver(&pata_of_platform_driver);
+}
+module_exit(pata_of_platform_exit);
+
+MODULE_DESCRIPTION("OF-platform PATA driver");
+MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
+MODULE_LICENSE("GPL");
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v4 0/3] OF-platform PATA driver
@ 2008-01-09 19:08 Anton Vorontsov
  2008-01-09 19:10 ` [PATCH 1/3] [libata] pata_platform: make probe and remove functions device type neutral Anton Vorontsov
                   ` (4 more replies)
  0 siblings, 5 replies; 30+ messages in thread
From: Anton Vorontsov @ 2008-01-09 19:08 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide; +Cc: Olof Johansson, Paul Mundt, Jeff Garzik

Hi all,

Here is the resend (aka v4) version of the OF-platform PATA
driver and related patches.

Changes since v3:
- Acked-by: Paul Mundt <lethal@linux-sh.org>
- In the powerpc specific patch: update defconfig and use
  machine_device_initcall -- this is new call found in the
  galak/powerpc.git.

Changes since v2:
- "PPC" added to PATA_PLATFORM "depends on" Kconfig entry;
  I didn't remove EMBEDDED "depends on" -- this wasn't discussed
  much and these patches should not depend on the decision.
- cosmetic fixes;
- "s/ioport_shift/reg_shift/g" patch dropped.

Changes since v1:
- __pata_platform_probe now accepts pio_mask argument;
- pata-platform compatible property renamed to ata-generic;
- pata_of_platform understands pio-mode property. It's used to pass
  pio_mask to the __pata_platform_probe. That is, in ata-generic
  context pio-mode means "pio mode the bus already configured for";
- New optional patch that renames pata_platform_info's
  ioport_shift to reg_shift.

Changes since RFC:
- nuked drivers/ata/pata_platform.h;
- powerpc bits: proper localbus node added.

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 1/3] [libata] pata_platform: make probe and remove functions device type neutral
  2008-01-09 19:08 [PATCH v4 0/3] OF-platform PATA driver Anton Vorontsov
@ 2008-01-09 19:10 ` Anton Vorontsov
  2008-01-09 19:10 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2008-01-09 19:10 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide; +Cc: Olof Johansson, Paul Mundt, Jeff Garzik

Split pata_platform_{probe,remove} into two pieces:
1. pata_platform_{probe,remove} -- platform_device-dependant bits;
2. __ptata_platform_{probe,remove} -- device type neutral bits.

This is done to not duplicate code for the OF-platform driver.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
 drivers/ata/pata_platform.c   |  144 ++++++++++++++++++++++++----------------
 include/linux/pata_platform.h |    9 +++
 2 files changed, 95 insertions(+), 58 deletions(-)

diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index ac03a90..224bb6c 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -93,14 +93,9 @@ static struct ata_port_operations pata_platform_port_ops = {
 };
 
 static void pata_platform_setup_port(struct ata_ioports *ioaddr,
-				     struct pata_platform_info *info)
+				     unsigned int shift)
 {
-	unsigned int shift = 0;
-
 	/* Fixup the port shift for platforms that need it */
-	if (info && info->ioport_shift)
-		shift = info->ioport_shift;
-
 	ioaddr->data_addr	= ioaddr->cmd_addr + (ATA_REG_DATA    << shift);
 	ioaddr->error_addr	= ioaddr->cmd_addr + (ATA_REG_ERR     << shift);
 	ioaddr->feature_addr	= ioaddr->cmd_addr + (ATA_REG_FEATURE << shift);
@@ -114,8 +109,13 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr,
 }
 
 /**
- *	pata_platform_probe		-	attach a platform interface
- *	@pdev: platform device
+ *	__pata_platform_probe		-	attach a platform interface
+ *	@dev: device
+ *	@io_res: Resource representing I/O base
+ *	@ctl_res: Resource representing CTL base
+ *	@irq_res: Resource representing IRQ and its flags
+ *	@ioport_shift: I/O port shift
+ *	@__pio_mask: PIO mask
  *
  *	Register a platform bus IDE interface. Such interfaces are PIO and we
  *	assume do not support IRQ sharing.
@@ -135,42 +135,18 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr,
  *
  *	If no IRQ resource is present, PIO polling mode is used instead.
  */
-static int __devinit pata_platform_probe(struct platform_device *pdev)
+int __devinit __pata_platform_probe(struct device *dev,
+				    struct resource *io_res,
+				    struct resource *ctl_res,
+				    struct resource *irq_res,
+				    unsigned int ioport_shift,
+				    int __pio_mask)
 {
-	struct resource *io_res, *ctl_res;
 	struct ata_host *host;
 	struct ata_port *ap;
-	struct pata_platform_info *pp_info;
 	unsigned int mmio;
-	int irq;
-
-	/*
-	 * Simple resource validation ..
-	 */
-	if ((pdev->num_resources != 3) && (pdev->num_resources != 2)) {
-		dev_err(&pdev->dev, "invalid number of resources\n");
-		return -EINVAL;
-	}
-
-	/*
-	 * Get the I/O base first
-	 */
-	io_res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-	if (io_res == NULL) {
-		io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-		if (unlikely(io_res == NULL))
-			return -EINVAL;
-	}
-
-	/*
-	 * Then the CTL base
-	 */
-	ctl_res = platform_get_resource(pdev, IORESOURCE_IO, 1);
-	if (ctl_res == NULL) {
-		ctl_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-		if (unlikely(ctl_res == NULL))
-			return -EINVAL;
-	}
+	int irq = 0;
+	int irq_flags = 0;
 
 	/*
 	 * Check for MMIO
@@ -181,20 +157,21 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
 	/*
 	 * And the IRQ
 	 */
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		irq = 0;	/* no irq */
+	if (irq_res && irq_res->start > 0) {
+		irq = irq_res->start;
+		irq_flags = irq_res->flags;
+	}
 
 	/*
 	 * Now that that's out of the way, wire up the port..
 	 */
-	host = ata_host_alloc(&pdev->dev, 1);
+	host = ata_host_alloc(dev, 1);
 	if (!host)
 		return -ENOMEM;
 	ap = host->ports[0];
 
 	ap->ops = &pata_platform_port_ops;
-	ap->pio_mask = pio_mask;
+	ap->pio_mask = __pio_mask;
 	ap->flags |= ATA_FLAG_SLAVE_POSS;
 
 	/*
@@ -209,25 +186,24 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
 	 * Handle the MMIO case
 	 */
 	if (mmio) {
-		ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, io_res->start,
+		ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start,
 				io_res->end - io_res->start + 1);
-		ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start,
+		ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start,
 				ctl_res->end - ctl_res->start + 1);
 	} else {
-		ap->ioaddr.cmd_addr = devm_ioport_map(&pdev->dev, io_res->start,
+		ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start,
 				io_res->end - io_res->start + 1);
-		ap->ioaddr.ctl_addr = devm_ioport_map(&pdev->dev, ctl_res->start,
+		ap->ioaddr.ctl_addr = devm_ioport_map(dev, ctl_res->start,
 				ctl_res->end - ctl_res->start + 1);
 	}
 	if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) {
-		dev_err(&pdev->dev, "failed to map IO/CTL base\n");
+		dev_err(dev, "failed to map IO/CTL base\n");
 		return -ENOMEM;
 	}
 
 	ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr;
 
-	pp_info = pdev->dev.platform_data;
-	pata_platform_setup_port(&ap->ioaddr, pp_info);
+	pata_platform_setup_port(&ap->ioaddr, ioport_shift);
 
 	ata_port_desc(ap, "%s cmd 0x%llx ctl 0x%llx", mmio ? "mmio" : "ioport",
 		      (unsigned long long)io_res->start,
@@ -235,26 +211,78 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
 
 	/* activate */
 	return ata_host_activate(host, irq, irq ? ata_interrupt : NULL,
-				 pp_info ? pp_info->irq_flags : 0,
-				 &pata_platform_sht);
+				 irq_flags, &pata_platform_sht);
 }
+EXPORT_SYMBOL_GPL(__pata_platform_probe);
 
 /**
- *	pata_platform_remove	-	unplug a platform interface
- *	@pdev: platform device
+ *	__pata_platform_remove		-	unplug a platform interface
+ *	@dev: device
  *
  *	A platform bus ATA device has been unplugged. Perform the needed
  *	cleanup. Also called on module unload for any active devices.
  */
-static int __devexit pata_platform_remove(struct platform_device *pdev)
+int __devexit __pata_platform_remove(struct device *dev)
 {
-	struct device *dev = &pdev->dev;
 	struct ata_host *host = dev_get_drvdata(dev);
 
 	ata_host_detach(host);
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(__pata_platform_remove);
+
+static int __devinit pata_platform_probe(struct platform_device *pdev)
+{
+	struct resource *io_res;
+	struct resource *ctl_res;
+	struct resource *irq_res;
+	struct pata_platform_info *pp_info = pdev->dev.platform_data;
+
+	/*
+	 * Simple resource validation ..
+	 */
+	if ((pdev->num_resources != 3) && (pdev->num_resources != 2)) {
+		dev_err(&pdev->dev, "invalid number of resources\n");
+		return -EINVAL;
+	}
+
+	/*
+	 * Get the I/O base first
+	 */
+	io_res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (io_res == NULL) {
+		io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (unlikely(io_res == NULL))
+			return -EINVAL;
+	}
+
+	/*
+	 * Then the CTL base
+	 */
+	ctl_res = platform_get_resource(pdev, IORESOURCE_IO, 1);
+	if (ctl_res == NULL) {
+		ctl_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+		if (unlikely(ctl_res == NULL))
+			return -EINVAL;
+	}
+
+	/*
+	 * And the IRQ
+	 */
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (irq_res)
+		irq_res->flags = pp_info ? pp_info->irq_flags : 0;
+
+	return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res,
+				     pp_info ? pp_info->ioport_shift : 0,
+				     pio_mask);
+}
+
+static int __devexit pata_platform_remove(struct platform_device *pdev)
+{
+	return __pata_platform_remove(&pdev->dev);
+}
 
 static struct platform_driver pata_platform_driver = {
 	.probe		= pata_platform_probe,
diff --git a/include/linux/pata_platform.h b/include/linux/pata_platform.h
index 5799e8d..6a7a92d 100644
--- a/include/linux/pata_platform.h
+++ b/include/linux/pata_platform.h
@@ -15,4 +15,13 @@ struct pata_platform_info {
 	unsigned int irq_flags;
 };
 
+extern int __devinit __pata_platform_probe(struct device *dev,
+					   struct resource *io_res,
+					   struct resource *ctl_res,
+					   struct resource *irq_res,
+					   unsigned int ioport_shift,
+					   int __pio_mask);
+
+extern int __devexit __pata_platform_remove(struct device *dev);
+
 #endif /* __LINUX_PATA_PLATFORM_H */
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2008-01-09 19:08 [PATCH v4 0/3] OF-platform PATA driver Anton Vorontsov
  2008-01-09 19:10 ` [PATCH 1/3] [libata] pata_platform: make probe and remove functions device type neutral Anton Vorontsov
@ 2008-01-09 19:10 ` Anton Vorontsov
  2008-01-09 23:40   ` Stephen Rothwell
  2008-01-09 19:11 ` [PATCH 3/3] [POWERPC] MPC8349E-mITX: introduce localbus and pata nodes Anton Vorontsov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 30+ messages in thread
From: Anton Vorontsov @ 2008-01-09 19:10 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide; +Cc: Olof Johansson, Paul Mundt, Jeff Garzik

This driver nicely wraps around pata_platform library functions,
and provides OF platform bus bindings to the PATA devices.

Also add || PPC to the PATA_PLATFORM's "depends on" Kconfig entry,
needed for PA Semi Electra.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Reviewed-by: Olof Johansson <olof@lixom.net>
---
 drivers/ata/Kconfig            |   12 ++++-
 drivers/ata/Makefile           |    1 +
 drivers/ata/pata_of_platform.c |  104 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 1 deletions(-)
 create mode 100644 drivers/ata/pata_of_platform.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba63619..64b4964 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -607,13 +607,23 @@ config PATA_WINBOND_VLB
 
 config PATA_PLATFORM
 	tristate "Generic platform device PATA support"
-	depends on EMBEDDED || ARCH_RPC
+	depends on EMBEDDED || ARCH_RPC || PPC
 	help
 	  This option enables support for generic directly connected ATA
 	  devices commonly found on embedded systems.
 
 	  If unsure, say N.
 
+config PATA_OF_PLATFORM
+	tristate "OpenFirmware platform device PATA support"
+	depends on PATA_PLATFORM && PPC_OF
+	help
+	  This option enables support for generic directly connected ATA
+	  devices commonly found on embedded systems with OpenFirmware
+	  bindings.
+
+	  If unsure, say N.
+
 config PATA_ICSIDE
 	tristate "Acorn ICS PATA support"
 	depends on ARM && ARCH_ACORN
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b13feb2..ebcee64 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
 obj-$(CONFIG_PATA_SCC)		+= pata_scc.o
 obj-$(CONFIG_PATA_BF54X)	+= pata_bf54x.o
 obj-$(CONFIG_PATA_PLATFORM)	+= pata_platform.o
+obj-$(CONFIG_PATA_OF_PLATFORM)	+= pata_of_platform.o
 obj-$(CONFIG_PATA_ICSIDE)	+= pata_icside.o
 # Should be last but two libata driver
 obj-$(CONFIG_PATA_ACPI)		+= pata_acpi.o
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
new file mode 100644
index 0000000..b7bc4e4
--- /dev/null
+++ b/drivers/ata/pata_of_platform.c
@@ -0,0 +1,104 @@
+/*
+ * OF-platform PATA driver
+ *
+ * Copyright (c) 2007  MontaVista Software, Inc.
+ *                     Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (Version 2) as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/pata_platform.h>
+
+static int __devinit pata_of_platform_probe(struct of_device *ofdev,
+					    const struct of_device_id *match)
+{
+	int ret;
+	struct device_node *dn = ofdev->node;
+	struct resource io_res;
+	struct resource ctl_res;
+	struct resource irq_res;
+	unsigned int reg_shift = 0;
+	int pio_mode = 0;
+	int pio_mask;
+	const u32 *prop;
+
+	ret = of_address_to_resource(dn, 0, &io_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get IO address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_address_to_resource(dn, 1, &ctl_res);
+	if (ret) {
+		dev_err(&ofdev->dev, "can't get CTL address from "
+			"device tree\n");
+		return -EINVAL;
+	}
+
+	ret = of_irq_to_resource(dn, 0, &irq_res);
+	if (ret == NO_IRQ)
+		irq_res.start = irq_res.end = -1;
+	else
+		irq_res.flags = 0;
+
+	prop = of_get_property(dn, "reg-shift", NULL);
+	if (prop)
+		reg_shift = *prop;
+
+	prop = of_get_property(dn, "pio-mode", NULL);
+	if (prop) {
+		pio_mode = *prop;
+		if (pio_mode > 6) {
+			dev_err(&ofdev->dev, "invalid pio-mode\n");
+			return -EINVAL;
+		}
+	} else {
+		dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n");
+	}
+
+	pio_mask = 1 << pio_mode;
+	pio_mask |= (1 << pio_mode) - 1;
+
+	return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res,
+				     reg_shift, pio_mask);
+}
+
+static int __devexit pata_of_platform_remove(struct of_device *ofdev)
+{
+	return __pata_platform_remove(&ofdev->dev);
+}
+
+static struct of_device_id pata_of_platform_match[] = {
+	{ .compatible = "ata-generic", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, pata_of_platform_match);
+
+static struct of_platform_driver pata_of_platform_driver = {
+	.name		= "pata_of_platform",
+	.match_table	= pata_of_platform_match,
+	.probe		= pata_of_platform_probe,
+	.remove		= __devexit_p(pata_of_platform_remove),
+};
+
+static int __init pata_of_platform_init(void)
+{
+	return of_register_platform_driver(&pata_of_platform_driver);
+}
+module_init(pata_of_platform_init);
+
+static void __exit pata_of_platform_exit(void)
+{
+	of_unregister_platform_driver(&pata_of_platform_driver);
+}
+module_exit(pata_of_platform_exit);
+
+MODULE_DESCRIPTION("OF-platform PATA driver");
+MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
+MODULE_LICENSE("GPL");
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 3/3] [POWERPC] MPC8349E-mITX: introduce localbus and pata nodes
  2008-01-09 19:08 [PATCH v4 0/3] OF-platform PATA driver Anton Vorontsov
  2008-01-09 19:10 ` [PATCH 1/3] [libata] pata_platform: make probe and remove functions device type neutral Anton Vorontsov
  2008-01-09 19:10 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
@ 2008-01-09 19:11 ` Anton Vorontsov
  2008-01-15 16:40 ` [PATCH v4 0/3] OF-platform PATA driver Olof Johansson
  2008-01-15 16:40 ` [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform Olof Johansson
  4 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2008-01-09 19:11 UTC (permalink / raw)
  To: linuxppc-dev, linux-ide; +Cc: Olof Johansson, Paul Mundt, Jeff Garzik

This patch adds localbus and pata nodes to use CF IDE interface
on MPC8349E-mITX boards.

Patch also updates defconfig and adds some code to probe localbus.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Olof Johansson <olof@lixom.net>
---
 arch/powerpc/boot/dts/mpc8349emitx.dts     |   17 ++++++++++++++++-
 arch/powerpc/configs/mpc834x_itx_defconfig |    3 ++-
 arch/powerpc/platforms/83xx/mpc834x_itx.c  |   12 ++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8349emitx.dts b/arch/powerpc/boot/dts/mpc8349emitx.dts
index e354f26..06d5b9c 100644
--- a/arch/powerpc/boot/dts/mpc8349emitx.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitx.dts
@@ -253,6 +253,21 @@
 		device_type = "pci";
 	};
 
+	localbus@e0005000 {
+		#address-cells = <2>;
+		#size-cells = <1>;
+		compatible = "fsl,mpc8349e-localbus",
+			     "fsl,pq2pro-localbus";
+		reg = <e0005000 d8>;
+		ranges = <3 0 f0000000 210>;
 
-
+		pata@3,0 {
+			compatible = "fsl,mpc8349emitx-pata", "ata-generic";
+			reg = <3 0 10 3 20c 4>;
+			reg-shift = <1>;
+			pio-mode = <6>;
+			interrupts = <17 8>;
+			interrupt-parent = <&ipic>;
+		};
+	};
 };
diff --git a/arch/powerpc/configs/mpc834x_itx_defconfig b/arch/powerpc/configs/mpc834x_itx_defconfig
index 6feb86e..2fbe4e5 100644
--- a/arch/powerpc/configs/mpc834x_itx_defconfig
+++ b/arch/powerpc/configs/mpc834x_itx_defconfig
@@ -570,7 +570,8 @@ CONFIG_SATA_SIL=y
 # CONFIG_PATA_SIS is not set
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
-# CONFIG_PATA_PLATFORM is not set
+CONFIG_PATA_PLATFORM=y
+CONFIG_PATA_OF_PLATFORM=y
 CONFIG_MD=y
 CONFIG_BLK_DEV_MD=y
 CONFIG_MD_LINEAR=y
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.c b/arch/powerpc/platforms/83xx/mpc834x_itx.c
index aa76819..50e8f63 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_itx.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_itx.c
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
+#include <linux/of_platform.h>
 
 #include <asm/system.h>
 #include <asm/atomic.h>
@@ -37,6 +38,17 @@
 
 #include "mpc83xx.h"
 
+static struct of_device_id __initdata mpc834x_itx_ids[] = {
+	{ .compatible = "fsl,pq2pro-localbus", },
+	{},
+};
+
+static int __init mpc834x_itx_declare_of_platform_devices(void)
+{
+	return of_platform_bus_probe(NULL, mpc834x_itx_ids, NULL);
+}
+machine_device_initcall(mpc834x_itx, mpc834x_itx_declare_of_platform_devices);
+
 /* ************************************************************************
  *
  * Setup the architecture
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2008-01-09 19:10 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
@ 2008-01-09 23:40   ` Stephen Rothwell
  2008-01-10  0:36     ` Olof Johansson
  0 siblings, 1 reply; 30+ messages in thread
From: Stephen Rothwell @ 2008-01-09 23:40 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Olof Johansson, linuxppc-dev, Paul Mundt, Jeff Garzik, linux-ide

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Hi Anton,

Juts one small trivial comment (could be fixed later).

On Wed, 9 Jan 2008 22:10:41 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
>
> +static struct of_device_id pata_of_platform_match[] = {

This could be declared const.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2008-01-09 23:40   ` Stephen Rothwell
@ 2008-01-10  0:36     ` Olof Johansson
  2008-01-10  2:17       ` Stephen Rothwell
  0 siblings, 1 reply; 30+ messages in thread
From: Olof Johansson @ 2008-01-10  0:36 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Paul Mundt, linuxppc-dev, Jeff Garzik, linux-ide

On Thu, Jan 10, 2008 at 10:40:48AM +1100, Stephen Rothwell wrote:
> Hi Anton,
> 
> Juts one small trivial comment (could be fixed later).
> 
> On Wed, 9 Jan 2008 22:10:41 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
> >
> > +static struct of_device_id pata_of_platform_match[] = {
> 
> This could be declared const.

Good point, but let's not hold up merge based on this. Need something
for janitors to do too, and it's good enough to merge as-is. :)


-Olof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
  2008-01-10  0:36     ` Olof Johansson
@ 2008-01-10  2:17       ` Stephen Rothwell
  0 siblings, 0 replies; 30+ messages in thread
From: Stephen Rothwell @ 2008-01-10  2:17 UTC (permalink / raw)
  To: Olof Johansson; +Cc: Paul Mundt, linuxppc-dev, Jeff Garzik, linux-ide

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On Wed, 9 Jan 2008 18:36:34 -0600 Olof Johansson <olof@lixom.net> wrote:
>
> On Thu, Jan 10, 2008 at 10:40:48AM +1100, Stephen Rothwell wrote:
> > Hi Anton,
> > 
> > Juts one small trivial comment (could be fixed later).
> > 
> > On Wed, 9 Jan 2008 22:10:41 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
> > >
> > > +static struct of_device_id pata_of_platform_match[] = {
> > 
> > This could be declared const.
> 
> Good point, but let's not hold up merge based on this. Need something
> for janitors to do too, and it's good enough to merge as-is. :)

Absolutely. To me that is what "(could be fixed later)" means.  :-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v4 0/3] OF-platform PATA driver
  2008-01-09 19:08 [PATCH v4 0/3] OF-platform PATA driver Anton Vorontsov
                   ` (2 preceding siblings ...)
  2008-01-09 19:11 ` [PATCH 3/3] [POWERPC] MPC8349E-mITX: introduce localbus and pata nodes Anton Vorontsov
@ 2008-01-15 16:40 ` Olof Johansson
  2008-01-16  5:47   ` Anton Vorontsov
  2008-01-15 16:40 ` [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform Olof Johansson
  4 siblings, 1 reply; 30+ messages in thread
From: Olof Johansson @ 2008-01-15 16:40 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, Paul Mundt, Jeff Garzik, linux-ide

Hi,

I've applied 1/3 and 2/3 together with my electra_ide move to pasemi.git
for-2.6.25, and will ask Paul to pull that. Kumar said he'd take 3/3.

I also added the const to the match table as spotted by Stephen.


-Olof

On Wed, Jan 09, 2008 at 10:08:52PM +0300, Anton Vorontsov wrote:
> Hi all,
> 
> Here is the resend (aka v4) version of the OF-platform PATA
> driver and related patches.
> 
> Changes since v3:
> - Acked-by: Paul Mundt <lethal@linux-sh.org>
> - In the powerpc specific patch: update defconfig and use
>   machine_device_initcall -- this is new call found in the
>   galak/powerpc.git.
> 
> Changes since v2:
> - "PPC" added to PATA_PLATFORM "depends on" Kconfig entry;
>   I didn't remove EMBEDDED "depends on" -- this wasn't discussed
>   much and these patches should not depend on the decision.
> - cosmetic fixes;
> - "s/ioport_shift/reg_shift/g" patch dropped.
> 
> Changes since v1:
> - __pata_platform_probe now accepts pio_mask argument;
> - pata-platform compatible property renamed to ata-generic;
> - pata_of_platform understands pio-mode property. It's used to pass
>   pio_mask to the __pata_platform_probe. That is, in ata-generic
>   context pio-mode means "pio mode the bus already configured for";
> - New optional patch that renames pata_platform_info's
>   ioport_shift to reg_shift.
> 
> Changes since RFC:
> - nuked drivers/ata/pata_platform.h;
> - powerpc bits: proper localbus node added.
> 
> -- 
> Anton Vorontsov
> email: cbou@mail.ru
> backup email: ya-cbou@yandex.ru
> irc://irc.freenode.net/bd2
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform
  2008-01-09 19:08 [PATCH v4 0/3] OF-platform PATA driver Anton Vorontsov
                   ` (3 preceding siblings ...)
  2008-01-15 16:40 ` [PATCH v4 0/3] OF-platform PATA driver Olof Johansson
@ 2008-01-15 16:40 ` Olof Johansson
  2008-01-15 19:42   ` Jeff Garzik
  4 siblings, 1 reply; 30+ messages in thread
From: Olof Johansson @ 2008-01-15 16:40 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, Paul Mundt, Jeff Garzik, linux-ide

Move electra-ide glue over to the new pata_of_platform framework, and
add the quirks needed to that driver.
    
---

Applied with the rest of the patches to pasemi.git for-2.6.25

 arch/powerpc/platforms/pasemi/electra_ide.c |   96 ----------------------------
 b/arch/powerpc/configs/pasemi_defconfig     |    4 -
 b/arch/powerpc/platforms/pasemi/Kconfig     |    9 --
 b/arch/powerpc/platforms/pasemi/Makefile    |    1 
 b/drivers/ata/pata_of_platform.c            |   20 ++++-
5 files changed, 17 insertions(+), 113 deletions(-)


diff --git a/arch/powerpc/configs/pasemi_defconfig b/arch/powerpc/configs/pasemi_defconfig
index 9d21b08..797f0df 100644
--- a/arch/powerpc/configs/pasemi_defconfig
+++ b/arch/powerpc/configs/pasemi_defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.24-rc6
-# Fri Dec 28 11:01:53 2007
+# Tue Jan 15 10:26:10 2008
 #
 CONFIG_PPC64=y
 
@@ -152,7 +152,6 @@ CONFIG_PPC_PASEMI=y
 CONFIG_PPC_PASEMI_IOMMU=y
 # CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE is not set
 CONFIG_PPC_PASEMI_MDIO=y
-CONFIG_ELECTRA_IDE=y
 # CONFIG_PPC_CELLEB is not set
 # CONFIG_PPC_PS3 is not set
 # CONFIG_PPC_CELL is not set
@@ -663,6 +662,7 @@ CONFIG_PATA_PCMCIA=y
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
 CONFIG_PATA_PLATFORM=y
+CONFIG_PATA_OF_PLATFORM=y
 CONFIG_MD=y
 CONFIG_BLK_DEV_MD=y
 CONFIG_MD_LINEAR=y
diff --git a/arch/powerpc/platforms/pasemi/Kconfig b/arch/powerpc/platforms/pasemi/Kconfig
index b3458a1..348e061 100644
--- a/arch/powerpc/platforms/pasemi/Kconfig
+++ b/arch/powerpc/platforms/pasemi/Kconfig
@@ -37,13 +37,4 @@ config PPC_PASEMI_MDIO
 	help
 	  Driver for MDIO via GPIO on PWRficient platforms
 
-config ELECTRA_IDE
-      tristate "Electra IDE driver"
-      default y
-      depends on PPC_PASEMI && ATA
-      select PATA_PLATFORM
-      help
-	This includes driver support for the Electra on-board IDE
-	interface.
-
 endmenu
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile
index f47fcac..2cd2a4f 100644
--- a/arch/powerpc/platforms/pasemi/Makefile
+++ b/arch/powerpc/platforms/pasemi/Makefile
@@ -1,4 +1,3 @@
 obj-y	+= setup.o pci.o time.o idle.o powersave.o iommu.o
 obj-$(CONFIG_PPC_PASEMI_MDIO)	+= gpio_mdio.o
-obj-$(CONFIG_ELECTRA_IDE) += electra_ide.o
 obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o
diff --git a/arch/powerpc/platforms/pasemi/electra_ide.c b/arch/powerpc/platforms/pasemi/electra_ide.c
deleted file mode 100644
index 12fb0c9..0000000
--- a/arch/powerpc/platforms/pasemi/electra_ide.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2007 PA Semi, Inc
- *
- * Maintained by: Olof Johansson <olof@lixom.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-#include <linux/platform_device.h>
-
-#include <asm/prom.h>
-#include <asm/system.h>
-
-/* The electra IDE interface is incredibly simple: Just a device on the localbus
- * with interrupts hooked up to one of the GPIOs. The device tree contains the
- * address window and interrupt mappings already, and the pata_platform driver handles
- * the rest. We just need to hook the two up.
- */
-
-#define MAX_IFS	4	/* really, we have only one */
-
-static struct platform_device *pdevs[MAX_IFS];
-
-static int __devinit electra_ide_init(void)
-{
-	struct device_node *np;
-	struct resource r[3];
-	int ret = 0;
-	int i;
-
-	np = of_find_compatible_node(NULL, "ide", "electra-ide");
-	i = 0;
-
-	while (np && i < MAX_IFS) {
-		memset(r, 0, sizeof(r));
-
-		/* pata_platform wants two address ranges: one for the base registers,
-		 * another for the control (altstatus). It's located at offset 0x3f6 in
-		 * the window, but the device tree only has one large register window
-		 * that covers both ranges. So we need to split it up by hand here:
-		 */
-
-		ret = of_address_to_resource(np, 0, &r[0]);
-		if (ret)
-			goto out;
-		ret = of_address_to_resource(np, 0, &r[1]);
-		if (ret)
-			goto out;
-
-		r[1].start += 0x3f6;
-		r[0].end = r[1].start-1;
-
-		r[2].start = irq_of_parse_and_map(np, 0);
-		r[2].end = irq_of_parse_and_map(np, 0);
-		r[2].flags = IORESOURCE_IRQ;
-
-		pr_debug("registering platform device at 0x%lx/0x%lx, irq is %ld\n",
-			 r[0].start, r[1].start, r[2].start);
-		pdevs[i] = platform_device_register_simple("pata_platform", i, r, 3);
-		if (IS_ERR(pdevs[i])) {
-			ret = PTR_ERR(pdevs[i]);
-			pdevs[i] = NULL;
-			goto out;
-		}
-		np = of_find_compatible_node(np, "ide", "electra-ide");
-	}
-out:
-	return ret;
-}
-module_init(electra_ide_init);
-
-static void __devexit electra_ide_exit(void)
-{
-	int i;
-
-	for (i = 0; i < MAX_IFS; i++)
-		if (pdevs[i])
-			platform_device_unregister(pdevs[i]);
-}
-module_exit(electra_ide_exit);
-
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>");
-MODULE_DESCRIPTION("PA Semi Electra IDE driver");
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index b7bc4e4..938f48a 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -34,11 +34,20 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
 		return -EINVAL;
 	}
 
-	ret = of_address_to_resource(dn, 1, &ctl_res);
-	if (ret) {
-		dev_err(&ofdev->dev, "can't get CTL address from "
-			"device tree\n");
-		return -EINVAL;
+	if (of_device_is_compatible(dn, "electra-ide")) {
+		/* Altstatus is really at offset 0x3f6 from the primary window
+		 * on electra-ide. Adjust ctl_res and io_res accordingly.
+		 */
+		ctl_res = io_res;
+		ctl_res.start = ctl_res.start+0x3f6;
+		io_res.end = ctl_res.start-1;
+	} else {
+		ret = of_address_to_resource(dn, 1, &ctl_res);
+		if (ret) {
+			dev_err(&ofdev->dev, "can't get CTL address from "
+				"device tree\n");
+			return -EINVAL;
+		}
 	}
 
 	ret = of_irq_to_resource(dn, 0, &irq_res);
@@ -76,6 +85,7 @@ static int __devexit pata_of_platform_remove(struct of_device *ofdev)
 
 static struct of_device_id pata_of_platform_match[] = {
 	{ .compatible = "ata-generic", },
+	{ .compatible = "electra-ide", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, pata_of_platform_match);

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform
  2008-01-15 16:40 ` [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform Olof Johansson
@ 2008-01-15 19:42   ` Jeff Garzik
  0 siblings, 0 replies; 30+ messages in thread
From: Jeff Garzik @ 2008-01-15 19:42 UTC (permalink / raw)
  To: Olof Johansson; +Cc: Paul Mundt, linuxppc-dev, linux-ide

Olof Johansson wrote:
> Move electra-ide glue over to the new pata_of_platform framework, and
> add the quirks needed to that driver.
>     
> ---
> 
> Applied with the rest of the patches to pasemi.git for-2.6.25
> 
>  arch/powerpc/platforms/pasemi/electra_ide.c |   96 ----------------------------
>  b/arch/powerpc/configs/pasemi_defconfig     |    4 -
>  b/arch/powerpc/platforms/pasemi/Kconfig     |    9 --
>  b/arch/powerpc/platforms/pasemi/Makefile    |    1 
>  b/drivers/ata/pata_of_platform.c            |   20 ++++-
> 5 files changed, 17 insertions(+), 113 deletions(-)

ACK

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v4 0/3] OF-platform PATA driver
  2008-01-15 16:40 ` [PATCH v4 0/3] OF-platform PATA driver Olof Johansson
@ 2008-01-16  5:47   ` Anton Vorontsov
  0 siblings, 0 replies; 30+ messages in thread
From: Anton Vorontsov @ 2008-01-16  5:47 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, Paul Mundt, Jeff Garzik, linux-ide

On Tue, Jan 15, 2008 at 10:40:22AM -0600, Olof Johansson wrote:
> Hi,
> 
> I've applied 1/3 and 2/3 together with my electra_ide move to pasemi.git
> for-2.6.25, and will ask Paul to pull that. Kumar said he'd take 3/3.
> 
> I also added the const to the match table as spotted by Stephen.

Great news, thank you!

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2008-01-16  5:38 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-09 19:08 [PATCH v4 0/3] OF-platform PATA driver Anton Vorontsov
2008-01-09 19:10 ` [PATCH 1/3] [libata] pata_platform: make probe and remove functions device type neutral Anton Vorontsov
2008-01-09 19:10 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
2008-01-09 23:40   ` Stephen Rothwell
2008-01-10  0:36     ` Olof Johansson
2008-01-10  2:17       ` Stephen Rothwell
2008-01-09 19:11 ` [PATCH 3/3] [POWERPC] MPC8349E-mITX: introduce localbus and pata nodes Anton Vorontsov
2008-01-15 16:40 ` [PATCH v4 0/3] OF-platform PATA driver Olof Johansson
2008-01-16  5:47   ` Anton Vorontsov
2008-01-15 16:40 ` [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform Olof Johansson
2008-01-15 19:42   ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2007-12-14 18:21 [PATCH v3 0/3] OF-platform PATA driver Anton Vorontsov
2007-12-14 18:24 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
2007-12-15 14:09   ` Stephen Rothwell
2007-12-15 15:19     ` Anton Vorontsov
2007-11-27 15:37 [PATCH 0/3] OF-platform PATA driver Anton Vorontsov
2007-11-27 15:39 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov
2007-11-27 21:22   ` Olof Johansson
2007-11-27 21:32     ` Arnd Bergmann
2007-11-28 15:49       ` Anton Vorontsov
2007-11-28 16:11         ` Sergei Shtylyov
2007-11-29  0:54           ` Anton Vorontsov
2007-11-30 10:17             ` Sergei Shtylyov
2007-11-30 10:58               ` Anton Vorontsov
2007-11-30 11:05                 ` Sergei Shtylyov
2007-11-30 11:45                   ` Anton Vorontsov
2007-11-30 11:43                 ` Sergei Shtylyov
2007-11-30 12:09                   ` Anton Vorontsov
2007-11-28 16:29       ` Sergei Shtylyov
2007-11-28  0:41   ` Stephen Rothwell
2007-12-02  3:59   ` Olof Johansson
2007-11-23 17:52 [RFC][PATCH 0/3] OF-platform PATA driver Anton Vorontsov
2007-11-23 17:53 ` [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver Anton Vorontsov

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).