linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* IDE broken on Pegasos PPC platform
@ 2007-09-24 19:10 Chuck Ebbert
  2007-09-24 20:38 ` Alan Cox
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chuck Ebbert @ 2007-09-24 19:10 UTC (permalink / raw)
  To: IDE/ATA development list; +Cc: linux-kernel

Without this patch, taken from a Suse 2.6.22 kernel, the Pegasos
PPC machines can't use their IDE interface. Is this the right fix?

Bug:
https://bugzilla.redhat.com/show_bug.cgi?id=247602
Patch (also below):
https://bugzilla.redhat.com/attachment.cgi?id=167747

===============

The built-in IDE controller is configured in legacy mode,
but the PCI registers advertise native mode.
Force the PCI class into legacy mode. This allows pata_via to access
two drives.
The Pegasos specific irq enforcement in the via82cxxx driver
must stay because there is aparently no generic way to setup irq per channel.

Tested on Pegasos2 with firmware version 20040810, and two IDE disks.

---
 arch/powerpc/kernel/prom_init.c   |   11 ++++++++---
 arch/powerpc/platforms/chrp/pci.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 3 deletions(-)

--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2044,6 +2044,7 @@ static void __init fixup_device_tree_map
 /*
  * Pegasos and BriQ lacks the "ranges" property in the isa node
  * Pegasos needs decimal IRQ 14/15, not hexadecimal
+ * Pegasos has the IDE configured in legacy mode, but advertised as native
  */
 static void __init fixup_device_tree_chrp(void)
 {
@@ -2081,9 +2082,13 @@ static void __init fixup_device_tree_chr
 		prom_printf("Fixing up IDE interrupt on Pegasos...\n");
 		prop[0] = 14;
 		prop[1] = 0x0;
-		prop[2] = 15;
-		prop[3] = 0x0;
-		prom_setprop(ph, name, "interrupts", prop, 4*sizeof(u32));
+		prom_setprop(ph, name, "interrupts", prop, 2*sizeof(u32));
+		prom_printf("Fixing up IDE class-code on Pegasos...\n");
+		rc = prom_getprop(ph, "class-code", prop, sizeof(u32));
+		if (rc == sizeof(u32)) {
+			prop[0] &= ~0x5;
+			prom_setprop(ph, name, "class-code", prop, sizeof(u32));
+		}
 	}
 }
 #else
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -338,3 +338,32 @@ void chrp_pci_fixup_winbond_ata(struct p
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 		chrp_pci_fixup_winbond_ata);
+
+/* Pegasos2 firmware version 20040810 configures the built-in IDE controller
+ * in legacy mode, but sets the PCI registers to PCI native mode.
+ * The chip can only operate in legacy mode, so force the PCI class into legacy
+ * mode as well. The same fixup must be done to the class-code property in
+ * the IDE node /pci@80000000/ide@C,1
+ */
+static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide)
+{
+	u8 progif;
+	struct pci_dev *viaisa;
+
+	if (!machine_is(chrp) || _chrp_type != _CHRP_Pegasos)
+		return;
+	if (viaide->irq != 14)
+		return;
+
+	viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
+	if (!viaisa)
+		return;
+	printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id);
+
+	pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif);
+	pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5);
+	viaide->class &= ~0x5;
+
+	pci_dev_put(viaisa);
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, chrp_pci_fixup_vt8231_ata);

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

* Re: IDE broken on Pegasos PPC platform
  2007-09-24 19:10 IDE broken on Pegasos PPC platform Chuck Ebbert
@ 2007-09-24 20:38 ` Alan Cox
  2007-09-24 20:58 ` libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform) Bartlomiej Zolnierkiewicz
  2007-09-24 21:27 ` IDE broken on Pegasos PPC platform Matt Sealey
  2 siblings, 0 replies; 7+ messages in thread
From: Alan Cox @ 2007-09-24 20:38 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: IDE/ATA development list, linux-kernel

On Mon, 24 Sep 2007 15:10:41 -0400
Chuck Ebbert <cebbert@redhat.com> wrote:

> Without this patch, taken from a Suse 2.6.22 kernel, the Pegasos
> PPC machines can't use their IDE interface. Is this the right fix?

I believe so yes

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

* libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform)
  2007-09-24 19:10 IDE broken on Pegasos PPC platform Chuck Ebbert
  2007-09-24 20:38 ` Alan Cox
@ 2007-09-24 20:58 ` Bartlomiej Zolnierkiewicz
  2007-09-24 21:10   ` Alan Cox
  2007-09-24 21:27 ` IDE broken on Pegasos PPC platform Matt Sealey
  2 siblings, 1 reply; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-09-24 20:58 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: IDE/ATA development list, linux-kernel, Olaf Hering

On Monday 24 September 2007, Chuck Ebbert wrote:
> Without this patch, taken from a Suse 2.6.22 kernel, the Pegasos
> PPC machines can't use their IDE interface. Is this the right fix?

This or use IDE via82cxxx driver.

> Bug:
> https://bugzilla.redhat.com/show_bug.cgi?id=247602
> Patch (also below):
> https://bugzilla.redhat.com/attachment.cgi?id=167747
> 
> ===============
> 
> The built-in IDE controller is configured in legacy mode,
> but the PCI registers advertise native mode.
> Force the PCI class into legacy mode. This allows pata_via to access
> two drives.
> The Pegasos specific irq enforcement in the via82cxxx driver
> must stay because there is aparently no generic way to setup irq per channel.
> 
> Tested on Pegasos2 with firmware version 20040810, and two IDE disks.

Somehow Signed-off-by got lost in this version of the patch....

IIRC the patch comes from Olaf Hering (added to cc:) and is the way to go

Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

> ---
>  arch/powerpc/kernel/prom_init.c   |   11 ++++++++---
>  arch/powerpc/platforms/chrp/pci.c |   29 +++++++++++++++++++++++++++++
>  2 files changed, 37 insertions(+), 3 deletions(-)
> 
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -2044,6 +2044,7 @@ static void __init fixup_device_tree_map
>  /*
>   * Pegasos and BriQ lacks the "ranges" property in the isa node
>   * Pegasos needs decimal IRQ 14/15, not hexadecimal
> + * Pegasos has the IDE configured in legacy mode, but advertised as native
>   */
>  static void __init fixup_device_tree_chrp(void)
>  {
> @@ -2081,9 +2082,13 @@ static void __init fixup_device_tree_chr
>  		prom_printf("Fixing up IDE interrupt on Pegasos...\n");
>  		prop[0] = 14;
>  		prop[1] = 0x0;
> -		prop[2] = 15;
> -		prop[3] = 0x0;
> -		prom_setprop(ph, name, "interrupts", prop, 4*sizeof(u32));
> +		prom_setprop(ph, name, "interrupts", prop, 2*sizeof(u32));
> +		prom_printf("Fixing up IDE class-code on Pegasos...\n");
> +		rc = prom_getprop(ph, "class-code", prop, sizeof(u32));
> +		if (rc == sizeof(u32)) {
> +			prop[0] &= ~0x5;
> +			prom_setprop(ph, name, "class-code", prop, sizeof(u32));
> +		}
>  	}
>  }
>  #else
> --- a/arch/powerpc/platforms/chrp/pci.c
> +++ b/arch/powerpc/platforms/chrp/pci.c
> @@ -338,3 +338,32 @@ void chrp_pci_fixup_winbond_ata(struct p
>  }
>  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
>  		chrp_pci_fixup_winbond_ata);
> +
> +/* Pegasos2 firmware version 20040810 configures the built-in IDE controller
> + * in legacy mode, but sets the PCI registers to PCI native mode.
> + * The chip can only operate in legacy mode, so force the PCI class into legacy
> + * mode as well. The same fixup must be done to the class-code property in
> + * the IDE node /pci@80000000/ide@C,1
> + */
> +static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide)
> +{
> +	u8 progif;
> +	struct pci_dev *viaisa;
> +
> +	if (!machine_is(chrp) || _chrp_type != _CHRP_Pegasos)
> +		return;
> +	if (viaide->irq != 14)
> +		return;
> +
> +	viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
> +	if (!viaisa)
> +		return;
> +	printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id);
> +
> +	pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif);
> +	pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5);
> +	viaide->class &= ~0x5;
> +
> +	pci_dev_put(viaisa);
> +}
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, chrp_pci_fixup_vt8231_ata);

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

* Re: libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform)
  2007-09-24 20:58 ` libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform) Bartlomiej Zolnierkiewicz
@ 2007-09-24 21:10   ` Alan Cox
  2007-09-25  9:22     ` Olaf Hering
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Cox @ 2007-09-24 21:10 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Chuck Ebbert, IDE/ATA development list, linux-kernel, Olaf Hering

On Mon, 24 Sep 2007 22:58:28 +0200
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:

> On Monday 24 September 2007, Chuck Ebbert wrote:
> > Without this patch, taken from a Suse 2.6.22 kernel, the Pegasos
> > PPC machines can't use their IDE interface. Is this the right fix?
> 
> This or use IDE via82cxxx driver.

Which contains a similar hack in the IDE driver where it doesn't belong 8)

> IIRC the patch comes from Olaf Hering (added to cc:) and is the way to go
> 
> Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

Acked-by: Alan Cox <alan@redhat.com>

hopefully that means the hack in the old VIA driver can also be killed
off.

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

* Re: IDE broken on Pegasos PPC platform
  2007-09-24 19:10 IDE broken on Pegasos PPC platform Chuck Ebbert
  2007-09-24 20:38 ` Alan Cox
  2007-09-24 20:58 ` libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform) Bartlomiej Zolnierkiewicz
@ 2007-09-24 21:27 ` Matt Sealey
  2007-09-25  9:24   ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 7+ messages in thread
From: Matt Sealey @ 2007-09-24 21:27 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: IDE/ATA development list, linux-kernel

Yeah I'll ack it if it matters, although I'd make a nit about the
fixing of device tree entries in prom_init and have it moved to
nvramrc or a Forth script or boot loader..

Pegasos IDE quirks have been "fixed" so many times now in Linux,
this code's going to get reshuffled again in other changes, I
think the device tree should be fixed at the firmware level and
not in the kernel.

-- 
Matt Sealey <matt@genesi-usa.com>
Genesi, Manager, Developer Relations

Chuck Ebbert wrote:
> Without this patch, taken from a Suse 2.6.22 kernel, the Pegasos
> PPC machines can't use their IDE interface. Is this the right fix?
> 
> Bug:
> https://bugzilla.redhat.com/show_bug.cgi?id=247602
> Patch (also below):
> https://bugzilla.redhat.com/attachment.cgi?id=167747
> 
> ===============
> 
> The built-in IDE controller is configured in legacy mode,
> but the PCI registers advertise native mode.
> Force the PCI class into legacy mode. This allows pata_via to access
> two drives.
> The Pegasos specific irq enforcement in the via82cxxx driver
> must stay because there is aparently no generic way to setup irq per channel.
> 
> Tested on Pegasos2 with firmware version 20040810, and two IDE disks.
> 
> ---
>  arch/powerpc/kernel/prom_init.c   |   11 ++++++++---
>  arch/powerpc/platforms/chrp/pci.c |   29 +++++++++++++++++++++++++++++
>  2 files changed, 37 insertions(+), 3 deletions(-)
> 
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -2044,6 +2044,7 @@ static void __init fixup_device_tree_map
>  /*
>   * Pegasos and BriQ lacks the "ranges" property in the isa node
>   * Pegasos needs decimal IRQ 14/15, not hexadecimal
> + * Pegasos has the IDE configured in legacy mode, but advertised as native
>   */
>  static void __init fixup_device_tree_chrp(void)
>  {
> @@ -2081,9 +2082,13 @@ static void __init fixup_device_tree_chr
>  		prom_printf("Fixing up IDE interrupt on Pegasos...\n");
>  		prop[0] = 14;
>  		prop[1] = 0x0;
> -		prop[2] = 15;
> -		prop[3] = 0x0;
> -		prom_setprop(ph, name, "interrupts", prop, 4*sizeof(u32));
> +		prom_setprop(ph, name, "interrupts", prop, 2*sizeof(u32));
> +		prom_printf("Fixing up IDE class-code on Pegasos...\n");
> +		rc = prom_getprop(ph, "class-code", prop, sizeof(u32));
> +		if (rc == sizeof(u32)) {
> +			prop[0] &= ~0x5;
> +			prom_setprop(ph, name, "class-code", prop, sizeof(u32));
> +		}
>  	}
>  }
>  #else
> --- a/arch/powerpc/platforms/chrp/pci.c
> +++ b/arch/powerpc/platforms/chrp/pci.c
> @@ -338,3 +338,32 @@ void chrp_pci_fixup_winbond_ata(struct p
>  }
>  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
>  		chrp_pci_fixup_winbond_ata);
> +
> +/* Pegasos2 firmware version 20040810 configures the built-in IDE controller
> + * in legacy mode, but sets the PCI registers to PCI native mode.
> + * The chip can only operate in legacy mode, so force the PCI class into legacy
> + * mode as well. The same fixup must be done to the class-code property in
> + * the IDE node /pci@80000000/ide@C,1
> + */
> +static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide)
> +{
> +	u8 progif;
> +	struct pci_dev *viaisa;
> +
> +	if (!machine_is(chrp) || _chrp_type != _CHRP_Pegasos)
> +		return;
> +	if (viaide->irq != 14)
> +		return;
> +
> +	viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
> +	if (!viaisa)
> +		return;
> +	printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id);
> +
> +	pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif);
> +	pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5);
> +	viaide->class &= ~0x5;
> +
> +	pci_dev_put(viaisa);
> +}
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, chrp_pci_fixup_vt8231_ata);
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform)
  2007-09-24 21:10   ` Alan Cox
@ 2007-09-25  9:22     ` Olaf Hering
  0 siblings, 0 replies; 7+ messages in thread
From: Olaf Hering @ 2007-09-25  9:22 UTC (permalink / raw)
  To: Alan Cox
  Cc: Bartlomiej Zolnierkiewicz, Chuck Ebbert, IDE/ATA development list,
	linux-kernel

On Mon, Sep 24, Alan Cox wrote:

> hopefully that means the hack in the old VIA driver can also be killed
> off.

Not that I know. But I did not browse the IDE core long enough to figure
out how to assign both irqs in a generic way.

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

* Re: IDE broken on Pegasos PPC platform
  2007-09-24 21:27 ` IDE broken on Pegasos PPC platform Matt Sealey
@ 2007-09-25  9:24   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2007-09-25  9:24 UTC (permalink / raw)
  To: Matt Sealey; +Cc: Chuck Ebbert, IDE/ATA development list, linux-kernel


On Mon, 2007-09-24 at 22:27 +0100, Matt Sealey wrote:
> Yeah I'll ack it if it matters, although I'd make a nit about the
> fixing of device tree entries in prom_init and have it moved to
> nvramrc or a Forth script or boot loader..
> 
> Pegasos IDE quirks have been "fixed" so many times now in Linux,
> this code's going to get reshuffled again in other changes, I
> think the device tree should be fixed at the firmware level and
> not in the kernel.

In that case though, OF contains correct values for the interrupts, it's
more of an issue related to the device being in legacy mode and the
pci_dev only carrying one interrupt anyway.

Ben.



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

end of thread, other threads:[~2007-09-25  9:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-24 19:10 IDE broken on Pegasos PPC platform Chuck Ebbert
2007-09-24 20:38 ` Alan Cox
2007-09-24 20:58 ` libata broken on Pegasos PPC platform (was: Re: IDE broken on Pegasos PPC platform) Bartlomiej Zolnierkiewicz
2007-09-24 21:10   ` Alan Cox
2007-09-25  9:22     ` Olaf Hering
2007-09-24 21:27 ` IDE broken on Pegasos PPC platform Matt Sealey
2007-09-25  9:24   ` Benjamin Herrenschmidt

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