fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / ide / ppc / pmac.c
index 5013b12..91c5344 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/ide-pmac.c
+ * linux/drivers/ide/ppc/pmac.c
  *
  * Support for IDE interfaces on PowerMacs.
  * These IDE interfaces are memory-mapped and have a DBDMA channel
@@ -22,7 +22,6 @@
  * big table
  * 
  */
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -420,107 +419,6 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
 
 #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
 
-/*
- * Below is the code for blinking the laptop LED along with hard
- * disk activity.
- */
-
-#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
-
-/* Set to 50ms minimum led-on time (also used to limit frequency
- * of requests sent to the PMU
- */
-#define PMU_HD_BLINK_TIME      (HZ/50)
-
-static struct adb_request pmu_blink_on, pmu_blink_off;
-static spinlock_t pmu_blink_lock;
-static unsigned long pmu_blink_stoptime;
-static int pmu_blink_ledstate;
-static struct timer_list pmu_blink_timer;
-static int pmu_ide_blink_enabled;
-
-
-static void
-pmu_hd_blink_timeout(unsigned long data)
-{
-       unsigned long flags;
-       
-       spin_lock_irqsave(&pmu_blink_lock, flags);
-
-       /* We may have been triggered again in a racy way, check
-        * that we really want to switch it off
-        */
-       if (time_after(pmu_blink_stoptime, jiffies))
-               goto done;
-
-       /* Previous req. not complete, try 100ms more */
-       if (pmu_blink_off.complete == 0)
-               mod_timer(&pmu_blink_timer, jiffies + PMU_HD_BLINK_TIME);
-       else if (pmu_blink_ledstate) {
-               pmu_request(&pmu_blink_off, NULL, 4, 0xee, 4, 0, 0);
-               pmu_blink_ledstate = 0;
-       }
-done:
-       spin_unlock_irqrestore(&pmu_blink_lock, flags);
-}
-
-static void
-pmu_hd_kick_blink(void *data, int rw)
-{
-       unsigned long flags;
-       
-       pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME;
-       wmb();
-       mod_timer(&pmu_blink_timer, pmu_blink_stoptime);
-       /* Fast path when LED is already ON */
-       if (pmu_blink_ledstate == 1)
-               return;
-       spin_lock_irqsave(&pmu_blink_lock, flags);
-       if (pmu_blink_on.complete && !pmu_blink_ledstate) {
-               pmu_request(&pmu_blink_on, NULL, 4, 0xee, 4, 0, 1);
-               pmu_blink_ledstate = 1;
-       }
-       spin_unlock_irqrestore(&pmu_blink_lock, flags);
-}
-
-static int
-pmu_hd_blink_init(void)
-{
-       struct device_node *dt;
-       const char *model;
-
-       /* Currently, I only enable this feature on KeyLargo based laptops,
-        * older laptops may support it (at least heathrow/paddington) but
-        * I don't feel like loading those venerable old machines with so
-        * much additional interrupt & PMU activity...
-        */
-       if (pmu_get_model() != PMU_KEYLARGO_BASED)
-               return 0;
-       
-       dt = of_find_node_by_path("/");
-       if (dt == NULL)
-               return 0;
-       model = (const char *)get_property(dt, "model", NULL);
-       if (model == NULL)
-               return 0;
-       if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
-           strncmp(model, "iBook", strlen("iBook")) != 0) {
-               of_node_put(dt);
-               return 0;
-       }
-       of_node_put(dt);
-
-       pmu_blink_on.complete = 1;
-       pmu_blink_off.complete = 1;
-       spin_lock_init(&pmu_blink_lock);
-       init_timer(&pmu_blink_timer);
-       pmu_blink_timer.function = pmu_hd_blink_timeout;
-
-       return 1;
-}
-
-#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
-
 /*
  * N.B. this can't be an initfunc, because the media-bay task can
  * call ide_[un]register at any time.
@@ -553,6 +451,8 @@ pmac_ide_init_hwif_ports(hw_regs_t *hw,
 
        if (irq != NULL)
                *irq = pmac_ide[ix].irq;
+
+       hw->dev = &pmac_ide[ix].mdev->ofdev.dev;
 }
 
 #define PMAC_IDE_REG(x) ((void __iomem *)(IDE_DATA_REG+(x)))
@@ -1190,23 +1090,6 @@ pmac_ide_do_suspend(ide_hwif_t *hwif)
        pmif->timings[0] = 0;
        pmif->timings[1] = 0;
        
-#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
-       /* Note: This code will be called for every hwif, thus we'll
-        * try several time to stop the LED blinker timer,  but that
-        * should be harmless
-        */
-       if (pmu_ide_blink_enabled) {
-               unsigned long flags;
-
-               /* Make sure we don't hit the PMU blink */
-               spin_lock_irqsave(&pmu_blink_lock, flags);
-               if (pmu_blink_ledstate)
-                       del_timer(&pmu_blink_timer);
-               pmu_blink_ledstate = 0;
-               spin_unlock_irqrestore(&pmu_blink_lock, flags);
-       }
-#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
-
        disable_irq(pmif->irq);
 
        /* The media bay will handle itself just fine */
@@ -1271,7 +1154,7 @@ static int
 pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
 {
        struct device_node *np = pmif->node;
-       int *bidp;
+       const int *bidp;
 
        pmif->cable_80 = 0;
        pmif->broken_dma = pmif->broken_dma_warn = 0;
@@ -1293,14 +1176,14 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
                pmif->broken_dma = 1;
        }
 
-       bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
+       bidp = get_property(np, "AAPL,bus-id", NULL);
        pmif->aapl_bus_id =  bidp ? *bidp : 0;
 
        /* Get cable type from device-tree */
        if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6
            || pmif->kind == controller_k2_ata6
            || pmif->kind == controller_sh_ata6) {
-               char* cable = get_property(np, "cable-type", NULL);
+               const char* cable = get_property(np, "cable-type", NULL);
                if (cable && !strncmp(cable, "80-", 3))
                        pmif->cable_80 = 1;
        }
@@ -1374,13 +1257,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
                hwif->selectproc = pmac_ide_selectproc;
        hwif->speedproc = pmac_ide_tune_chipset;
 
-#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
-       pmu_ide_blink_enabled = pmu_hd_blink_init();
-
-       if (pmu_ide_blink_enabled)
-               hwif->led_act = pmu_hd_kick_blink;
-#endif
-
        printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
               hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
               pmif->mediabay ? " (mediabay)" : "", hwif->irq);
@@ -1450,7 +1326,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
        if (macio_irq_count(mdev) == 0) {
                printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n",
                        i, mdev->ofdev.node->full_name);
-               irq = 13;
+               irq = irq_create_mapping(NULL, 13);
        } else
                irq = macio_irq(mdev, 0);
 
@@ -1493,15 +1369,16 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
 }
 
 static int
-pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t state)
+pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg)
 {
        ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
        int             rc = 0;
 
-       if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >= PM_EVENT_SUSPEND) {
+       if (mesg.event != mdev->ofdev.dev.power.power_state.event
+                       && mesg.event == PM_EVENT_SUSPEND) {
                rc = pmac_ide_do_suspend(hwif);
                if (rc == 0)
-                       mdev->ofdev.dev.power.power_state = state;
+                       mdev->ofdev.dev.power.power_state = mesg;
        }
 
        return rc;
@@ -1597,15 +1474,16 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 }
 
 static int
-pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
        ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
        int             rc = 0;
        
-       if (state.event != pdev->dev.power.power_state.event && state.event >= 2) {
+       if (mesg.event != pdev->dev.power.power_state.event
+                       && mesg.event == PM_EVENT_SUSPEND) {
                rc = pmac_ide_do_suspend(hwif);
                if (rc == 0)
-                       pdev->dev.power.power_state = state;
+                       pdev->dev.power.power_state = mesg;
        }
 
        return rc;
@@ -1677,7 +1555,7 @@ MODULE_DEVICE_TABLE(pci, pmac_ide_pci_match);
 void __init
 pmac_ide_probe(void)
 {
-       if (_machine != _MACH_Pmac)
+       if (!machine_is(powermac))
                return;
 
 #ifdef CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST