ide-pmac: add ->cable_detect method
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sun, 15 Jun 2008 19:00:23 +0000 (21:00 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sun, 15 Jun 2008 19:00:23 +0000 (21:00 +0200)
Add ->cable_detect method and remove no longer needed pmif->cable_80 flag
(there is also no need to mask ->udma_mask now).

This fixes:

- forced ignoring of cable detection (needed for some CF devices & debug)

- cable detection for warm-plug

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ppc/pmac.c

index 48aa019..7f669a9 100644 (file)
@@ -59,7 +59,6 @@ typedef struct pmac_ide_hwif {
        int                             irq;
        int                             kind;
        int                             aapl_bus_id;
-       unsigned                        cable_80 : 1;
        unsigned                        mediabay : 1;
        unsigned                        broken_dma : 1;
        unsigned                        broken_dma_warn : 1;
@@ -918,10 +917,40 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
        return 0;
 }
 
+static u8 pmac_ide_cable_detect(ide_hwif_t *hwif)
+{
+       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)ide_get_hwifdata(hwif);
+       struct device_node *np = pmif->node;
+       const char *cable = of_get_property(np, "cable-type", NULL);
+
+       /* Get cable type from device-tree. */
+       if (cable && !strncmp(cable, "80-", 3))
+               return ATA_CBL_PATA80;
+
+       /*
+        * G5's seem to have incorrect cable type in device-tree.
+        * Let's assume they have a 80 conductor cable, this seem
+        * to be always the case unless the user mucked around.
+        */
+       if (of_device_is_compatible(np, "K2-UATA") ||
+           of_device_is_compatible(np, "shasta-ata"))
+               return ATA_CBL_PATA80;
+
+       return ATA_CBL_PATA40;
+}
+
 static const struct ide_port_ops pmac_ide_ata6_port_ops = {
        .set_pio_mode           = pmac_ide_set_pio_mode,
        .set_dma_mode           = pmac_ide_set_dma_mode,
        .selectproc             = pmac_ide_kauai_selectproc,
+       .cable_detect           = pmac_ide_cable_detect,
+};
+
+static const struct ide_port_ops pmac_ide_ata4_port_ops = {
+       .set_pio_mode           = pmac_ide_set_pio_mode,
+       .set_dma_mode           = pmac_ide_set_dma_mode,
+       .selectproc             = pmac_ide_selectproc,
+       .cable_detect           = pmac_ide_cable_detect,
 };
 
 static const struct ide_port_ops pmac_ide_port_ops = {
@@ -962,7 +991,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
        u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
        struct ide_port_info d = pmac_port_info;
 
-       pmif->cable_80 = 0;
        pmif->broken_dma = pmif->broken_dma_warn = 0;
        if (of_device_is_compatible(np, "shasta-ata")) {
                pmif->kind = controller_sh_ata6;
@@ -979,6 +1007,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
        } else if (of_device_is_compatible(np, "keylargo-ata")) {
                if (strcmp(np->name, "ata-4") == 0) {
                        pmif->kind = controller_kl_ata4;
+                       d.port_ops = &pmac_ide_ata4_port_ops;
                        d.udma_mask = ATA_UDMA4;
                } else
                        pmif->kind = controller_kl_ata3;
@@ -992,22 +1021,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
        bidp = of_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) {
-               const char* cable = of_get_property(np, "cable-type", NULL);
-               if (cable && !strncmp(cable, "80-", 3))
-                       pmif->cable_80 = 1;
-       }
-       /* G5's seem to have incorrect cable type in device-tree. Let's assume
-        * they have a 80 conductor cable, this seem to be always the case unless
-        * the user mucked around
-        */
-       if (of_device_is_compatible(np, "K2-UATA") ||
-           of_device_is_compatible(np, "shasta-ata"))
-               pmif->cable_80 = 1;
-
        /* On Kauai-type controllers, we make sure the FCR is correct */
        if (pmif->kauai_fcr)
                writel(KAUAI_FCR_UATA_MAGIC |
@@ -1053,7 +1066,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
 
        hwif->hwif_data = pmif;
        ide_init_port_hw(hwif, hw);
-       hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 
        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,
@@ -1070,11 +1082,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
                }
        }
 
-#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
-       if (pmif->cable_80 == 0)
-               d.udma_mask &= ATA_UDMA2;
-#endif
-
        idx[0] = hwif->index;
 
        ide_device_add(idx, &d);