]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] pdc202xx_new.c: fix PDC20270/1 init on the Xserve Apple machines
authorAndrew Morton <akpm@osdl.org>
Sat, 24 Jan 2004 03:36:15 +0000 (19:36 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Sat, 24 Jan 2004 03:36:15 +0000 (19:36 -0800)
From: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Fix initialization of the PDC20270/1 chipsets on the Xserve Apple machines.

drivers/ide/pci/pdc202xx_new.c

index 998c3f99297100d50c01de5a31648b8f36fab368..aa3a6b546c8b97844248e3b3ec2d04a1da316c5a 100644 (file)
 #include <asm/io.h>
 #include <asm/irq.h>
 
+#ifdef CONFIG_PPC_PMAC
+#include <asm/prom.h>
+#include <asm/pci-bridge.h>
+#endif
+
 #include "pdc202xx_new.h"
 
 #define PDC202_DEBUG_CABLE     0
@@ -513,6 +518,44 @@ void pdcnew_reset (ide_drive_t *drive)
 #endif
 }
 
+#ifdef CONFIG_PPC_PMAC
+static void __devinit apple_kiwi_init(struct pci_dev *pdev)
+{
+       struct device_node *np = pci_device_to_OF_node(pdev);
+       unsigned int class_rev = 0;
+       unsigned long mmio;
+       u8 conf;
+
+       if (np == NULL || !device_is_compatible(np, "kiwi-root"))
+               return;
+
+       pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
+       class_rev &= 0xff;
+
+       if (class_rev >= 0x03) {
+               /* Setup chip magic config stuff (from darwin) */
+               pci_read_config_byte(pdev, 0x40, &conf);
+               pci_write_config_byte(pdev, 0x40, conf | 0x01);
+       }
+       mmio = (unsigned long)ioremap(pci_resource_start(pdev, 5),
+                                     pci_resource_len(pdev, 5));
+
+       /* Setup some PLL stuffs */
+       switch (pdev->device) {
+       case PCI_DEVICE_ID_PROMISE_20270:
+               writew(0x0d2b, mmio + 0x1202);
+               mdelay(30);
+               break;
+       case PCI_DEVICE_ID_PROMISE_20271:
+               writew(0x0826, mmio + 0x1202);
+               mdelay(30);
+               break;
+       }
+
+       iounmap((void *)mmio);
+}
+#endif /* CONFIG_PPC_PMAC */
+
 static unsigned int __init init_chipset_pdcnew (struct pci_dev *dev, const char *name)
 {
        if (dev->resource[PCI_ROM_RESOURCE].start) {
@@ -522,6 +565,10 @@ static unsigned int __init init_chipset_pdcnew (struct pci_dev *dev, const char
                        name, dev->resource[PCI_ROM_RESOURCE].start);
        }
 
+#ifdef CONFIG_PPC_PMAC
+       apple_kiwi_init(dev);
+#endif
+
 #if defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS)
        pdc202_devs[n_pdc202_devs++] = dev;