aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-06-15 15:00:23 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-06-15 15:00:23 -0400
commit07a6c66da53f646a39103290bfbd85be18892895 (patch)
tree4f90d532f45df638f42c23d17ee459e83696747d /drivers
parentc1a8e39819bd6797ee2b82b88517268d39921b03 (diff)
ide-pmac: add ->cable_detect method
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ppc/pmac.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 48aa019127bc..7f669a997aa6 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -59,7 +59,6 @@ typedef struct pmac_ide_hwif {
59 int irq; 59 int irq;
60 int kind; 60 int kind;
61 int aapl_bus_id; 61 int aapl_bus_id;
62 unsigned cable_80 : 1;
63 unsigned mediabay : 1; 62 unsigned mediabay : 1;
64 unsigned broken_dma : 1; 63 unsigned broken_dma : 1;
65 unsigned broken_dma_warn : 1; 64 unsigned broken_dma_warn : 1;
@@ -918,10 +917,40 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
918 return 0; 917 return 0;
919} 918}
920 919
920static u8 pmac_ide_cable_detect(ide_hwif_t *hwif)
921{
922 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)ide_get_hwifdata(hwif);
923 struct device_node *np = pmif->node;
924 const char *cable = of_get_property(np, "cable-type", NULL);
925
926 /* Get cable type from device-tree. */
927 if (cable && !strncmp(cable, "80-", 3))
928 return ATA_CBL_PATA80;
929
930 /*
931 * G5's seem to have incorrect cable type in device-tree.
932 * Let's assume they have a 80 conductor cable, this seem
933 * to be always the case unless the user mucked around.
934 */
935 if (of_device_is_compatible(np, "K2-UATA") ||
936 of_device_is_compatible(np, "shasta-ata"))
937 return ATA_CBL_PATA80;
938
939 return ATA_CBL_PATA40;
940}
941
921static const struct ide_port_ops pmac_ide_ata6_port_ops = { 942static const struct ide_port_ops pmac_ide_ata6_port_ops = {
922 .set_pio_mode = pmac_ide_set_pio_mode, 943 .set_pio_mode = pmac_ide_set_pio_mode,
923 .set_dma_mode = pmac_ide_set_dma_mode, 944 .set_dma_mode = pmac_ide_set_dma_mode,
924 .selectproc = pmac_ide_kauai_selectproc, 945 .selectproc = pmac_ide_kauai_selectproc,
946 .cable_detect = pmac_ide_cable_detect,
947};
948
949static const struct ide_port_ops pmac_ide_ata4_port_ops = {
950 .set_pio_mode = pmac_ide_set_pio_mode,
951 .set_dma_mode = pmac_ide_set_dma_mode,
952 .selectproc = pmac_ide_selectproc,
953 .cable_detect = pmac_ide_cable_detect,
925}; 954};
926 955
927static const struct ide_port_ops pmac_ide_port_ops = { 956static 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)
962 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 991 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
963 struct ide_port_info d = pmac_port_info; 992 struct ide_port_info d = pmac_port_info;
964 993
965 pmif->cable_80 = 0;
966 pmif->broken_dma = pmif->broken_dma_warn = 0; 994 pmif->broken_dma = pmif->broken_dma_warn = 0;
967 if (of_device_is_compatible(np, "shasta-ata")) { 995 if (of_device_is_compatible(np, "shasta-ata")) {
968 pmif->kind = controller_sh_ata6; 996 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)
979 } else if (of_device_is_compatible(np, "keylargo-ata")) { 1007 } else if (of_device_is_compatible(np, "keylargo-ata")) {
980 if (strcmp(np->name, "ata-4") == 0) { 1008 if (strcmp(np->name, "ata-4") == 0) {
981 pmif->kind = controller_kl_ata4; 1009 pmif->kind = controller_kl_ata4;
1010 d.port_ops = &pmac_ide_ata4_port_ops;
982 d.udma_mask = ATA_UDMA4; 1011 d.udma_mask = ATA_UDMA4;
983 } else 1012 } else
984 pmif->kind = controller_kl_ata3; 1013 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)
992 bidp = of_get_property(np, "AAPL,bus-id", NULL); 1021 bidp = of_get_property(np, "AAPL,bus-id", NULL);
993 pmif->aapl_bus_id = bidp ? *bidp : 0; 1022 pmif->aapl_bus_id = bidp ? *bidp : 0;
994 1023
995 /* Get cable type from device-tree */
996 if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6
997 || pmif->kind == controller_k2_ata6
998 || pmif->kind == controller_sh_ata6) {
999 const char* cable = of_get_property(np, "cable-type", NULL);
1000 if (cable && !strncmp(cable, "80-", 3))
1001 pmif->cable_80 = 1;
1002 }
1003 /* G5's seem to have incorrect cable type in device-tree. Let's assume
1004 * they have a 80 conductor cable, this seem to be always the case unless
1005 * the user mucked around
1006 */
1007 if (of_device_is_compatible(np, "K2-UATA") ||
1008 of_device_is_compatible(np, "shasta-ata"))
1009 pmif->cable_80 = 1;
1010
1011 /* On Kauai-type controllers, we make sure the FCR is correct */ 1024 /* On Kauai-type controllers, we make sure the FCR is correct */
1012 if (pmif->kauai_fcr) 1025 if (pmif->kauai_fcr)
1013 writel(KAUAI_FCR_UATA_MAGIC | 1026 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)
1053 1066
1054 hwif->hwif_data = pmif; 1067 hwif->hwif_data = pmif;
1055 ide_init_port_hw(hwif, hw); 1068 ide_init_port_hw(hwif, hw);
1056 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
1057 1069
1058 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", 1070 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
1059 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, 1071 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)
1070 } 1082 }
1071 } 1083 }
1072 1084
1073#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1074 if (pmif->cable_80 == 0)
1075 d.udma_mask &= ATA_UDMA2;
1076#endif
1077
1078 idx[0] = hwif->index; 1085 idx[0] = hwif->index;
1079 1086
1080 ide_device_add(idx, &d); 1087 ide_device_add(idx, &d);