Commit f73b0a08 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev: (86 commits)
  SPIN_LOCK_UNLOCKED cleanup in drivers/ata/pata_winbond.c
  drivers/ata/pata_cmd640.c: fix build with CONFIG_PM=n
  pata_hpt37x: Further small fixes
  pata_hpt3x2n: Add HPT371N support and other bits
  ata: printk warning fixes
  libata: separate ATA_EHI_DID_RESET into DID_SOFTRESET and DID_HARDRESET
  ahci: consolidate common port flags
  ata_timing: ensure t->cycle is always correct
  libata: add missing call to ->cable_detect() in new EH path
  pata_amd: remove contamination added during cable_detect conversion
  libata: Handle drives that require a spin-up command before first access
  libata: HPA support
  libata: kill probe_ent and related helpers
  libata: convert the remaining PATA drivers to new init model
  libata: convert the remaining SATA drivers to new init model
  libata: convert ata_pci_init_native_mode() users to new init model
  libata: convert drivers with combined SATA/PATA ports to new init model
  libata: add init helpers including ata_pci_prepare_native_host()
  libata: convert native PCI host handling to new init model
  libata: convert legacy PCI host handling to new init model
  ...
parents 6b06d2cc 22503631
...@@ -692,7 +692,6 @@ CONFIG_SATA_SIL=y ...@@ -692,7 +692,6 @@ CONFIG_SATA_SIL=y
CONFIG_SATA_VIA=y CONFIG_SATA_VIA=y
# CONFIG_SATA_VITESSE is not set # CONFIG_SATA_VITESSE is not set
# CONFIG_SATA_INIC162X is not set # CONFIG_SATA_INIC162X is not set
CONFIG_SATA_INTEL_COMBINED=y
CONFIG_SATA_ACPI=y CONFIG_SATA_ACPI=y
# CONFIG_PATA_ALI is not set # CONFIG_PATA_ALI is not set
# CONFIG_PATA_AMD is not set # CONFIG_PATA_AMD is not set
......
...@@ -435,7 +435,6 @@ CONFIG_SCSI_SATA_SIL=m ...@@ -435,7 +435,6 @@ CONFIG_SCSI_SATA_SIL=m
# CONFIG_SCSI_SATA_ULI is not set # CONFIG_SCSI_SATA_ULI is not set
CONFIG_SCSI_SATA_VIA=m CONFIG_SCSI_SATA_VIA=m
# CONFIG_SCSI_SATA_VITESSE is not set # CONFIG_SCSI_SATA_VITESSE is not set
CONFIG_SCSI_SATA_INTEL_COMBINED=y
# CONFIG_SCSI_DMX3191D is not set # CONFIG_SCSI_DMX3191D is not set
# CONFIG_SCSI_FUTURE_DOMAIN is not set # CONFIG_SCSI_FUTURE_DOMAIN is not set
# CONFIG_SCSI_IPS is not set # CONFIG_SCSI_IPS is not set
......
...@@ -631,7 +631,6 @@ CONFIG_SATA_SIL=y ...@@ -631,7 +631,6 @@ CONFIG_SATA_SIL=y
CONFIG_SATA_VIA=y CONFIG_SATA_VIA=y
# CONFIG_SATA_VITESSE is not set # CONFIG_SATA_VITESSE is not set
# CONFIG_SATA_INIC162X is not set # CONFIG_SATA_INIC162X is not set
CONFIG_SATA_INTEL_COMBINED=y
CONFIG_SATA_ACPI=y CONFIG_SATA_ACPI=y
# CONFIG_PATA_ALI is not set # CONFIG_PATA_ALI is not set
# CONFIG_PATA_AMD is not set # CONFIG_PATA_AMD is not set
......
...@@ -156,11 +156,6 @@ config SATA_INIC162X ...@@ -156,11 +156,6 @@ config SATA_INIC162X
help help
This option enables support for Initio 162x Serial ATA. This option enables support for Initio 162x Serial ATA.
config SATA_INTEL_COMBINED
bool
depends on IDE=y && !BLK_DEV_IDE_SATA && (SATA_AHCI || ATA_PIIX)
default y
config SATA_ACPI config SATA_ACPI
bool bool
depends on ACPI && PCI depends on ACPI && PCI
...@@ -184,7 +179,7 @@ config PATA_ALI ...@@ -184,7 +179,7 @@ config PATA_ALI
If unsure, say N. If unsure, say N.
config PATA_AMD config PATA_AMD
tristate "AMD/NVidia PATA support (Experimental)" tristate "AMD/NVidia PATA support"
depends on PCI depends on PCI
help help
This option enables support for the AMD and NVidia PATA This option enables support for the AMD and NVidia PATA
...@@ -209,6 +204,16 @@ config PATA_ATIIXP ...@@ -209,6 +204,16 @@ config PATA_ATIIXP
If unsure, say N. If unsure, say N.
config PATA_CMD640_PCI
tristate "CMD640 PCI PATA support (Very Experimental)"
depends on PCI && EXPERIMENTAL
help
This option enables support for the CMD640 PCI IDE
interface chip. Only the primary channel is currently
supported.
If unsure, say N.
config PATA_CMD64X config PATA_CMD64X
tristate "CMD64x PATA support (Very Experimental)" tristate "CMD64x PATA support (Very Experimental)"
depends on PCI&& EXPERIMENTAL depends on PCI&& EXPERIMENTAL
...@@ -273,7 +278,7 @@ config ATA_GENERIC ...@@ -273,7 +278,7 @@ config ATA_GENERIC
If unsure, say N. If unsure, say N.
config PATA_HPT366 config PATA_HPT366
tristate "HPT 366/368 PATA support (Very Experimental)" tristate "HPT 366/368 PATA support (Experimental)"
depends on PCI && EXPERIMENTAL depends on PCI && EXPERIMENTAL
help help
This option enables support for the HPT 366 and 368 This option enables support for the HPT 366 and 368
...@@ -282,7 +287,7 @@ config PATA_HPT366 ...@@ -282,7 +287,7 @@ config PATA_HPT366
If unsure, say N. If unsure, say N.
config PATA_HPT37X config PATA_HPT37X
tristate "HPT 370/370A/371/372/374/302 PATA support (Very Experimental)" tristate "HPT 370/370A/371/372/374/302 PATA support (Experimental)"
depends on PCI && EXPERIMENTAL depends on PCI && EXPERIMENTAL
help help
This option enables support for the majority of the later HPT This option enables support for the majority of the later HPT
...@@ -309,7 +314,7 @@ config PATA_HPT3X3 ...@@ -309,7 +314,7 @@ config PATA_HPT3X3
If unsure, say N. If unsure, say N.
config PATA_ISAPNP config PATA_ISAPNP
tristate "ISA Plug and Play PATA support (Very Experimental)" tristate "ISA Plug and Play PATA support (Experimental)"
depends on EXPERIMENTAL && ISAPNP depends on EXPERIMENTAL && ISAPNP
help help
This option enables support for ISA plug & play ATA This option enables support for ISA plug & play ATA
...@@ -318,8 +323,8 @@ config PATA_ISAPNP ...@@ -318,8 +323,8 @@ config PATA_ISAPNP
If unsure, say N. If unsure, say N.
config PATA_IT821X config PATA_IT821X
tristate "IT8211/2 PATA support (Experimental)" tristate "IT8211/2 PATA support"
depends on PCI && EXPERIMENTAL depends on PCI
help help
This option enables support for the ITE 8211 and 8212 This option enables support for the ITE 8211 and 8212
PATA controllers via the new ATA layer, including RAID PATA controllers via the new ATA layer, including RAID
...@@ -390,10 +395,10 @@ config PATA_MPIIX ...@@ -390,10 +395,10 @@ config PATA_MPIIX
If unsure, say N. If unsure, say N.
config PATA_OLDPIIX config PATA_OLDPIIX
tristate "Intel PATA old PIIX support (Experimental)" tristate "Intel PATA old PIIX support"
depends on PCI && EXPERIMENTAL depends on PCI
help help
This option enables support for old(?) PIIX PATA support. This option enables support for early PIIX PATA support.
If unsure, say N. If unsure, say N.
...@@ -444,7 +449,7 @@ config PATA_PCMCIA ...@@ -444,7 +449,7 @@ config PATA_PCMCIA
If unsure, say N. If unsure, say N.
config PATA_PDC_OLD config PATA_PDC_OLD
tristate "Older Promise PATA controller support (Very Experimental)" tristate "Older Promise PATA controller support (Experimental)"
depends on PCI && EXPERIMENTAL depends on PCI && EXPERIMENTAL
help help
This option enables support for the Promise 20246, 20262, 20263, This option enables support for the Promise 20246, 20262, 20263,
...@@ -459,7 +464,7 @@ config PATA_QDI ...@@ -459,7 +464,7 @@ config PATA_QDI
Support for QDI 6500 and 6580 PATA controllers on VESA local bus. Support for QDI 6500 and 6580 PATA controllers on VESA local bus.
config PATA_RADISYS config PATA_RADISYS
tristate "RADISYS 82600 PATA support (Very experimental)" tristate "RADISYS 82600 PATA support (Very Experimental)"
depends on PCI && EXPERIMENTAL depends on PCI && EXPERIMENTAL
help help
This option enables support for the RADISYS 82600 This option enables support for the RADISYS 82600
...@@ -477,7 +482,7 @@ config PATA_RZ1000 ...@@ -477,7 +482,7 @@ config PATA_RZ1000
If unsure, say N. If unsure, say N.
config PATA_SC1200 config PATA_SC1200
tristate "SC1200 PATA support (Raving Lunatic)" tristate "SC1200 PATA support (Very Experimental)"
depends on PCI && EXPERIMENTAL depends on PCI && EXPERIMENTAL
help help
This option enables support for the NatSemi/AMD SC1200 SoC This option enables support for the NatSemi/AMD SC1200 SoC
...@@ -486,8 +491,8 @@ config PATA_SC1200 ...@@ -486,8 +491,8 @@ config PATA_SC1200
If unsure, say N. If unsure, say N.
config PATA_SERVERWORKS config PATA_SERVERWORKS
tristate "SERVERWORKS OSB4/CSB5/CSB6/HT1000 PATA support (Experimental)" tristate "SERVERWORKS OSB4/CSB5/CSB6/HT1000 PATA support"
depends on PCI && EXPERIMENTAL depends on PCI
help help
This option enables support for the Serverworks OSB4/CSB5/CSB6 and This option enables support for the Serverworks OSB4/CSB5/CSB6 and
HT1000 PATA controllers, via the new ATA layer. HT1000 PATA controllers, via the new ATA layer.
......
...@@ -22,6 +22,7 @@ obj-$(CONFIG_PATA_ALI) += pata_ali.o ...@@ -22,6 +22,7 @@ obj-$(CONFIG_PATA_ALI) += pata_ali.o
obj-$(CONFIG_PATA_AMD) += pata_amd.o obj-$(CONFIG_PATA_AMD) += pata_amd.o
obj-$(CONFIG_PATA_ARTOP) += pata_artop.o obj-$(CONFIG_PATA_ARTOP) += pata_artop.o
obj-$(CONFIG_PATA_ATIIXP) += pata_atiixp.o obj-$(CONFIG_PATA_ATIIXP) += pata_atiixp.o
obj-$(CONFIG_PATA_CMD640_PCI) += pata_cmd640.o
obj-$(CONFIG_PATA_CMD64X) += pata_cmd64x.o obj-$(CONFIG_PATA_CMD64X) += pata_cmd64x.o
obj-$(CONFIG_PATA_CS5520) += pata_cs5520.o obj-$(CONFIG_PATA_CS5520) += pata_cs5520.o
obj-$(CONFIG_PATA_CS5530) += pata_cs5530.o obj-$(CONFIG_PATA_CS5530) += pata_cs5530.o
......
This diff is collapsed.
...@@ -32,35 +32,6 @@ ...@@ -32,35 +32,6 @@
* A generic parallel ATA driver using libata * A generic parallel ATA driver using libata
*/ */
/**
* generic_pre_reset - probe begin
* @ap: ATA port
*
* Set up cable type and use generic probe init
*/
static int generic_pre_reset(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA80;
return ata_std_prereset(ap);
}
/**
* generic_error_handler - Probe specified port on PATA host controller
* @ap: Port to probe
* @classes:
*
* LOCKING:
* None (inherited from caller).
*/
static void generic_error_handler(struct ata_port *ap)
{
ata_bmdma_drive_eh(ap, generic_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}
/** /**
* generic_set_mode - mode setting * generic_set_mode - mode setting
* @ap: interface to set up * @ap: interface to set up
...@@ -144,8 +115,9 @@ static struct ata_port_operations generic_port_ops = { ...@@ -144,8 +115,9 @@ static struct ata_port_operations generic_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = generic_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_unknown,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#define DRV_NAME "ata_piix" #define DRV_NAME "ata_piix"
#define DRV_VERSION "2.10ac1" #define DRV_VERSION "2.11"
enum { enum {
PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
...@@ -155,11 +155,11 @@ struct piix_host_priv { ...@@ -155,11 +155,11 @@ struct piix_host_priv {
static int piix_init_one (struct pci_dev *pdev, static int piix_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent); const struct pci_device_id *ent);
static void piix_pata_error_handler(struct ata_port *ap); static void piix_pata_error_handler(struct ata_port *ap);
static void ich_pata_error_handler(struct ata_port *ap);
static void piix_sata_error_handler(struct ata_port *ap); static void piix_sata_error_handler(struct ata_port *ap);
static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev); static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
static int ich_pata_cable_detect(struct ata_port *ap);
static unsigned int in_module_init = 1; static unsigned int in_module_init = 1;
...@@ -305,6 +305,7 @@ static const struct ata_port_operations piix_pata_ops = { ...@@ -305,6 +305,7 @@ static const struct ata_port_operations piix_pata_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = piix_pata_error_handler, .error_handler = piix_pata_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -336,8 +337,9 @@ static const struct ata_port_operations ich_pata_ops = { ...@@ -336,8 +337,9 @@ static const struct ata_port_operations ich_pata_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ich_pata_error_handler, .error_handler = piix_pata_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ich_pata_cable_detect,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -580,12 +582,13 @@ static const struct ich_laptop ich_laptop[] = { ...@@ -580,12 +582,13 @@ static const struct ich_laptop ich_laptop[] = {
/* devid, subvendor, subdev */ /* devid, subvendor, subdev */
{ 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */ { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */
{ 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */
{ 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */
/* end marker */ /* end marker */
{ 0, } { 0, }
}; };
/** /**
* piix_pata_cbl_detect - Probe host controller cable detect info * ich_pata_cable_detect - Probe host controller cable detect info
* @ap: Port for which cable detect info is desired * @ap: Port for which cable detect info is desired
* *
* Read 80c cable indicator from ATA PCI device's PCI config * Read 80c cable indicator from ATA PCI device's PCI config
...@@ -595,23 +598,18 @@ static const struct ich_laptop ich_laptop[] = { ...@@ -595,23 +598,18 @@ static const struct ich_laptop ich_laptop[] = {
* None (inherited from caller). * None (inherited from caller).
*/ */
static void ich_pata_cbl_detect(struct ata_port *ap) static int ich_pata_cable_detect(struct ata_port *ap)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
const struct ich_laptop *lap = &ich_laptop[0]; const struct ich_laptop *lap = &ich_laptop[0];
u8 tmp, mask; u8 tmp, mask;
/* no 80c support in host controller? */
if ((ap->udma_mask & ~ATA_UDMA_MASK_40C) == 0)
goto cbl40;
/* Check for specials - Acer Aspire 5602WLMi */ /* Check for specials - Acer Aspire 5602WLMi */
while (lap->device) { while (lap->device) {
if (lap->device == pdev->device && if (lap->device == pdev->device &&
lap->subvendor == pdev->subsystem_vendor && lap->subvendor == pdev->subsystem_vendor &&
lap->subdevice == pdev->subsystem_device) { lap->subdevice == pdev->subsystem_device) {
ap->cbl = ATA_CBL_PATA40_SHORT; return ATA_CBL_PATA40_SHORT;
return;
} }
lap++; lap++;
} }
...@@ -620,20 +618,14 @@ static void ich_pata_cbl_detect(struct ata_port *ap) ...@@ -620,20 +618,14 @@ static void ich_pata_cbl_detect(struct ata_port *ap)
mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC; mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
pci_read_config_byte(pdev, PIIX_IOCFG, &tmp); pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
if ((tmp & mask) == 0) if ((tmp & mask) == 0)
goto cbl40; return ATA_CBL_PATA40;
return ATA_CBL_PATA80;
ap->cbl = ATA_CBL_PATA80;
return;
cbl40:
ap->cbl = ATA_CBL_PATA40;
} }
/** /**
* piix_pata_prereset - prereset for PATA host controller * piix_pata_prereset - prereset for PATA host controller
* @ap: Target port * @ap: Target port
* *
*
* LOCKING: * LOCKING:
* None (inherited from caller). * None (inherited from caller).
*/ */
...@@ -643,8 +635,6 @@ static int piix_pata_prereset(struct ata_port *ap) ...@@ -643,8 +635,6 @@ static int piix_pata_prereset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -655,30 +645,6 @@ static void piix_pata_error_handler(struct ata_port *ap) ...@@ -655,30 +645,6 @@ static void piix_pata_error_handler(struct ata_port *ap)
} }
/**
* ich_pata_prereset - prereset for PATA host controller
* @ap: Target port
*
*
* LOCKING:
* None (inherited from caller).
*/
static int ich_pata_prereset(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
return -ENOENT;
ich_pata_cbl_detect(ap);
return ata_std_prereset(ap);
}
static void ich_pata_error_handler(struct ata_port *ap)
{
ata_bmdma_drive_eh(ap, ich_pata_prereset, ata_std_softreset, NULL,
ata_std_postreset);
}
static void piix_sata_error_handler(struct ata_port *ap) static void piix_sata_error_handler(struct ata_port *ap)
{ {
ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL, ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
......
This diff is collapsed.
...@@ -1056,7 +1056,7 @@ static void ata_eh_analyze_serror(struct ata_port *ap) ...@@ -1056,7 +1056,7 @@ static void ata_eh_analyze_serror(struct ata_port *ap)
} }
if (serror & SERR_INTERNAL) { if (serror & SERR_INTERNAL) {
err_mask |= AC_ERR_SYSTEM; err_mask |= AC_ERR_SYSTEM;
action |= ATA_EH_SOFTRESET; action |= ATA_EH_HARDRESET;
} }
if (serror & (SERR_PHYRDY_CHG | SERR_DEV_XCHG)) if (serror & (SERR_PHYRDY_CHG | SERR_DEV_XCHG))
ata_ehi_hotplugged(&ehc->i); ata_ehi_hotplugged(&ehc->i);
...@@ -1151,7 +1151,9 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc, ...@@ -1151,7 +1151,9 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
return ATA_EH_SOFTRESET; return ATA_EH_SOFTRESET;
} }
if (!(qc->err_mask & AC_ERR_DEV)) if (stat & (ATA_ERR | ATA_DF))
qc->err_mask |= AC_ERR_DEV;
else
return 0; return 0;
switch (qc->dev->class) { switch (qc->dev->class) {
...@@ -1669,7 +1671,10 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1669,7 +1671,10 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
reset == softreset ? "soft" : "hard"); reset == softreset ? "soft" : "hard");
/* mark that this EH session started with reset */ /* mark that this EH session started with reset */
ehc->i.flags |= ATA_EHI_DID_RESET; if (reset == hardreset)
ehc->i.flags |= ATA_EHI_DID_HARDRESET;
else
ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
rc = ata_do_reset(ap, reset, classes); rc = ata_do_reset(ap, reset, classes);
...@@ -1808,6 +1813,10 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1808,6 +1813,10 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
} }
} }
/* PDIAG- should have been released, ask cable type if post-reset */
if ((ehc->i.flags & ATA_EHI_DID_RESET) && ap->ops->cable_detect)
ap->cbl = ap->ops->cable_detect(ap);
/* Configure new devices forward such that user doesn't see /* Configure new devices forward such that user doesn't see
* device detection messages backwards. * device detection messages backwards.
*/ */
......
...@@ -104,7 +104,7 @@ static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = { ...@@ -104,7 +104,7 @@ static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = {
* libata transport template. libata doesn't do real transport stuff. * libata transport template. libata doesn't do real transport stuff.
* It just needs the eh_timed_out hook. * It just needs the eh_timed_out hook.
*/ */
struct scsi_transport_template ata_scsi_transport_template = { static struct scsi_transport_template ata_scsi_transport_template = {
.eh_strategy_handler = ata_scsi_error, .eh_strategy_handler = ata_scsi_error,
.eh_timed_out = ata_scsi_timed_out, .eh_timed_out = ata_scsi_timed_out,
.user_scan = ata_scsi_user_scan, .user_scan = ata_scsi_user_scan,
...@@ -2678,6 +2678,18 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) ...@@ -2678,6 +2678,18 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
tf->device = qc->dev->devno ? tf->device = qc->dev->devno ?
tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
/* READ/WRITE LONG use a non-standard sect_size */
qc->sect_size = ATA_SECT_SIZE;
switch (tf->command) {
case ATA_CMD_READ_LONG:
case ATA_CMD_READ_LONG_ONCE:
case ATA_CMD_WRITE_LONG:
case ATA_CMD_WRITE_LONG_ONCE:
if (tf->protocol != ATA_PROT_PIO || tf->nsect != 1)
goto invalid_fld;
qc->sect_size = scmd->request_bufflen;
}
/* /*
* Filter SET_FEATURES - XFER MODE command -- otherwise, * Filter SET_FEATURES - XFER MODE command -- otherwise,
* SET_FEATURES - XFER MODE must be preceded/succeeded * SET_FEATURES - XFER MODE must be preceded/succeeded
...@@ -2792,8 +2804,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, ...@@ -2792,8 +2804,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
{ {
int rc = 0; int rc = 0;
if (unlikely(!scmd->cmd_len)) { if (unlikely(!scmd->cmd_len || scmd->cmd_len > dev->cdb_len)) {
ata_dev_printk(dev, KERN_WARNING, "WARNING: zero len CDB\n"); DPRINTK("bad CDB len=%u, max=%u\n",
scmd->cmd_len, dev->cdb_len);
scmd->result = DID_ERROR << 16; scmd->result = DID_ERROR << 16;
done(scmd); done(scmd);
return 0; return 0;
...@@ -2948,6 +2961,48 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, ...@@ -2948,6 +2961,48 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
} }
} }
int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
{
int i, rc;
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
struct Scsi_Host *shost;
rc = -ENOMEM;
shost = scsi_host_alloc(sht, sizeof(struct ata_port *));
if (!shost)
goto err_alloc;
*(struct ata_port **)&shost->hostdata[0] = ap;
ap->scsi_host = shost;
shost->transportt = &ata_scsi_transport_template;
shost->unique_id = ap->print_id;
shost->max_id = 16;
shost->max_lun = 1;
shost->max_channel = 1;
shost->max_cmd_len = 16;
rc = scsi_add_host(ap->scsi_host, ap->host->dev);
if (rc)
goto err_add;
}
return 0;
err_add:
scsi_host_put(host->ports[i]->scsi_host);
err_alloc:
while (--i >= 0) {
struct Scsi_Host *shost = host->ports[i]->scsi_host;
scsi_remove_host(shost);
scsi_host_put(shost);
}
return rc;
}
void ata_scsi_scan_host(struct ata_port *ap) void ata_scsi_scan_host(struct ata_port *ap)
{ {
unsigned int i; unsigned int i;
...@@ -3224,21 +3279,21 @@ struct ata_port *ata_sas_port_alloc(struct ata_host *host, ...@@ -3224,21 +3279,21 @@ struct ata_port *ata_sas_port_alloc(struct ata_host *host,
struct ata_port_info *port_info, struct ata_port_info *port_info,
struct Scsi_Host *shost) struct Scsi_Host *shost)
{ {
struct ata_port *ap = kzalloc(sizeof(*ap), GFP_KERNEL); struct ata_port *ap;
struct ata_probe_ent *ent;
ap = ata_port_alloc(host);
if (!ap) if (!ap)
return NULL; return NULL;
ent = ata_probe_ent_alloc(host->dev, port_info); ap->port_no = 0;
if (!ent) {
kfree(ap);
return NULL;
}
ata_port_init(ap, host, ent, 0);
ap->lock = shost->host_lock; ap->lock = shost->host_lock;
devm_kfree(host->dev, ent); ap->pio_mask = port_info->pio_mask;
ap->mwdma_mask = port_info->mwdma_mask;
ap->udma_mask = port_info->udma_mask;
ap->flags |= port_info->flags;
ap->ops = port_info->port_ops;
ap->cbl = ATA_CBL_SATA;
return ap; return ap;
} }
EXPORT_SYMBOL_GPL(ata_sas_port_alloc); EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
...@@ -3294,8 +3349,10 @@ int ata_sas_port_init(struct ata_port *ap) ...@@ -3294,8 +3349,10 @@ int ata_sas_port_init(struct ata_port *ap)
{ {
int rc = ap->ops->port_start(ap); int rc = ap->ops->port_start(ap);
if (!rc) if (!rc) {
ap->print_id = ata_print_id++;
rc = ata_bus_probe(ap); rc = ata_bus_probe(ap);
}
return rc; return rc;
} }
......
This diff is collapsed.
...@@ -52,6 +52,7 @@ enum { ...@@ -52,6 +52,7 @@ enum {
ATA_DNXFER_QUIET = (1 << 31), ATA_DNXFER_QUIET = (1 << 31),
}; };
extern unsigned int ata_print_id;
extern struct workqueue_struct *ata_aux_wq; extern struct workqueue_struct *ata_aux_wq;
extern int atapi_enabled; extern int atapi_enabled;
extern int atapi_dmadir; extern int atapi_dmadir;
...@@ -92,10 +93,7 @@ extern int ata_flush_cache(struct ata_device *dev); ...@@ -92,10 +93,7 @@ extern int ata_flush_cache(struct ata_device *dev);
extern void ata_dev_init(struct ata_device *dev); extern void ata_dev_init(struct ata_device *dev);
extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
extern void ata_port_init(struct ata_port *ap, struct ata_host *host, extern struct ata_port *ata_port_alloc(struct ata_host *host);
const struct ata_probe_ent *ent, unsigned int port_no);
extern struct ata_probe_ent *ata_probe_ent_alloc(struct device *dev,
const struct ata_port_info *port);
/* libata-acpi.c */ /* libata-acpi.c */
#ifdef CONFIG_SATA_ACPI #ifdef CONFIG_SATA_ACPI
...@@ -113,8 +111,8 @@ static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) ...@@ -113,8 +111,8 @@ static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
#endif #endif
/* libata-scsi.c */ /* libata-scsi.c */
extern struct scsi_transport_template ata_scsi_transport_template; extern int ata_scsi_add_hosts(struct ata_host *host,
struct scsi_host_template *sht);
extern void ata_scsi_scan_host(struct ata_port *ap); extern void ata_scsi_scan_host(struct ata_port *ap);
extern int ata_scsi_offline_dev(struct ata_device *dev); extern int ata_scsi_offline_dev(struct ata_device *dev);
extern void ata_scsi_hotplug(struct work_struct *work); extern void ata_scsi_hotplug(struct work_struct *work);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <linux/dmi.h> #include <linux/dmi.h>
#define DRV_NAME "pata_ali" #define DRV_NAME "pata_ali"
#define DRV_VERSION "0.7.3" #define DRV_VERSION "0.7.4"
/* /*
* Cable special cases * Cable special cases
...@@ -89,59 +89,6 @@ static int ali_c2_cable_detect(struct ata_port *ap) ...@@ -89,59 +89,6 @@ static int ali_c2_cable_detect(struct ata_port *ap)
return ATA_CBL_PATA80; return ATA_CBL_PATA80;
} }
/**
* ali_early_error_handler - reset for eary chip
* @ap: ATA port
*
* Handle the reset callback for the later chips with cable detect
*/
static int ali_c2_pre_reset(struct ata_port *ap)
{
ap->cbl = ali_c2_cable_detect(ap);
return ata_std_prereset(ap);
}
static void ali_c2_error_handler(struct ata_port *ap)
{
ata_bmdma_drive_eh(ap, ali_c2_pre_reset,
ata_std_softreset, NULL,
ata_std_postreset);
}
/**
* ali_early_cable_detect - cable detection
* @ap: ATA port
*
* Perform cable detection for older chipsets. This turns out to be
* rather easy to implement
*/
static int ali_early_cable_detect(struct ata_port *ap)
{
return ATA_CBL_PATA40;
}
/**
* ali_early_probe_init - reset for early chip
* @ap: ATA port
*
* Handle the reset callback for the early (pre cable detect) chips.
*/
static int ali_early_pre_reset(struct ata_port *ap)
{
ap->cbl = ali_early_cable_detect(ap);
return ata_std_prereset(ap);
}
static void ali_early_error_handler(struct ata_port *ap)
{
return ata_bmdma_drive_eh(ap, ali_early_pre_reset,
ata_std_softreset, NULL,
ata_std_postreset);
}
/** /**
* ali_20_filter - filter for earlier ALI DMA * ali_20_filter - filter for earlier ALI DMA
* @ap: ALi ATA port * @ap: ALi ATA port
...@@ -151,7 +98,7 @@ static void ali_early_error_handler(struct ata_port *ap) ...@@ -151,7 +98,7 @@ static void ali_early_error_handler(struct ata_port *ap)
* fix that later on. Also ensure we do not do UDMA on WDC drives * fix that later on. Also ensure we do not do UDMA on WDC drives
*/ */
static unsigned long ali_20_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask) static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask)
{ {
char model_num[ATA_ID_PROD_LEN + 1]; char model_num[ATA_ID_PROD_LEN + 1];
/* No DMA on anything but a disk for now */ /* No DMA on anything but a disk for now */
...@@ -160,7 +107,7 @@ static unsigned long ali_20_filter(const struct ata_port *ap, struct ata_device ...@@ -160,7 +107,7 @@ static unsigned long ali_20_filter(const struct ata_port *ap, struct ata_device
ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num)); ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
if (strstr(model_num, "WDC")) if (strstr(model_num, "WDC"))
return mask &= ~ATA_MASK_UDMA; return mask &= ~ATA_MASK_UDMA;
return ata_pci_default_filter(ap, adev, mask); return ata_pci_default_filter(adev, mask);
} }
/** /**
...@@ -314,7 +261,6 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev) ...@@ -314,7 +261,6 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
/** /**
* ali_lock_sectors - Keep older devices to 255 sector mode * ali_lock_sectors - Keep older devices to 255 sector mode
* @ap: ATA port
* @adev: Device * @adev: Device
* *
* Called during the bus probe for each device that is found. We use * Called during the bus probe for each device that is found. We use
...@@ -324,7 +270,7 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev) ...@@ -324,7 +270,7 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
* slower PIO methods * slower PIO methods
*/ */
static void ali_lock_sectors(struct ata_port *ap, struct ata_device *adev) static void ali_lock_sectors(struct ata_device *adev)
{ {
adev->max_sectors = 255; adev->max_sectors = 255;
} }
...@@ -366,8 +312,9 @@ static struct ata_port_operations ali_early_port_ops = { ...@@ -366,8 +312,9 @@ static struct ata_port_operations ali_early_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ali_early_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
...@@ -402,8 +349,9 @@ static struct ata_port_operations ali_20_port_ops = { ...@@ -402,8 +349,9 @@ static struct ata_port_operations ali_20_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ali_early_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -440,8 +388,9 @@ static struct ata_port_operations ali_c2_port_ops = { ...@@ -440,8 +388,9 @@ static struct ata_port_operations ali_c2_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ali_c2_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ali_c2_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -477,8 +426,9 @@ static struct ata_port_operations ali_c5_port_ops = { ...@@ -477,8 +426,9 @@ static struct ata_port_operations ali_c5_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ali_c2_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ali_c2_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#define DRV_NAME "pata_amd" #define DRV_NAME "pata_amd"
#define DRV_VERSION "0.2.8" #define DRV_VERSION "0.3.8"
/** /**
* timing_setup - shared timing computation and load * timing_setup - shared timing computation and load
...@@ -119,32 +119,25 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse ...@@ -119,32 +119,25 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
} }
/** /**
* amd_probe_init - cable detection * amd_probe_init - perform reset handling
* @ap: ATA port * @ap: ATA port
* *
* Perform cable detection. The BIOS stores this in PCI config * Reset sequence checking enable bits to see which ports are
* space for us. * active.
*/ */
static int amd_pre_reset(struct ata_port *ap) static int amd_pre_reset(struct ata_port *ap)
{ {
static const u32 bitmask[2] = {0x03, 0x0C};
static const struct pci_bits amd_enable_bits[] = { static const struct pci_bits amd_enable_bits[] = {
{ 0x40, 1, 0x02, 0x02 }, { 0x40, 1, 0x02, 0x02 },
{ 0x40, 1, 0x01, 0x01 } { 0x40, 1, 0x01, 0x01 }
}; };
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 ata66;
if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
pci_read_config_byte(pdev, 0x42, &ata66);
if (ata66 & bitmask[ap->port_no])
ap->cbl = ATA_CBL_PATA80;
else
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -156,28 +149,16 @@ static void amd_error_handler(struct ata_port *ap) ...@@ -156,28 +149,16 @@ static void amd_error_handler(struct ata_port *ap)
ata_std_postreset); ata_std_postreset);
} }
static int amd_early_pre_reset(struct ata_port *ap) static int amd_cable_detect(struct ata_port *ap)
{ {
static const u32 bitmask[2] = {0x03, 0x0C};
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static struct pci_bits amd_enable_bits[] = { u8 ata66;
{ 0x40, 1, 0x02, 0x02 },
{ 0x40, 1, 0x01, 0x01 }
};
if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
return -ENOENT;
/* No host side cable detection */
ap->cbl = ATA_CBL_PATA80;
return ata_std_prereset(ap);
}
static void amd_early_error_handler(struct ata_port *ap) pci_read_config_byte(pdev, 0x42, &ata66);
{ if (ata66 & bitmask[ap->port_no])
ata_bmdma_drive_eh(ap, amd_early_pre_reset, return ATA_CBL_PATA80;
ata_std_softreset, NULL, return ATA_CBL_PATA40;
ata_std_postreset);
} }
/** /**
...@@ -247,31 +228,16 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev) ...@@ -247,31 +228,16 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
*/ */
static int nv_pre_reset(struct ata_port *ap) { static int nv_pre_reset(struct ata_port *ap) {
static const u8 bitmask[2] = {0x03, 0x0C};
static const struct pci_bits nv_enable_bits[] = { static const struct pci_bits nv_enable_bits[] = {
{ 0x50, 1, 0x02, 0x02 }, { 0x50, 1, 0x02, 0x02 },
{ 0x50, 1, 0x01, 0x01 } { 0x50, 1, 0x01, 0x01 }
}; };
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 ata66;
u16 udma;
if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
pci_read_config_byte(pdev, 0x52, &ata66);
if (ata66 & bitmask[ap->port_no])
ap->cbl = ATA_CBL_PATA80;
else
ap->cbl = ATA_CBL_PATA40;
/* We now have to double check because the Nvidia boxes BIOS
doesn't always set the cable bits but does set mode bits */
pci_read_config_word(pdev, 0x62 - 2 * ap->port_no, &udma);
if ((udma & 0xC4) == 0xC4 || (udma & 0xC400) == 0xC400)
ap->cbl = ATA_CBL_PATA80;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -281,6 +247,29 @@ static void nv_error_handler(struct ata_port *ap) ...@@ -281,6 +247,29 @@ static void nv_error_handler(struct ata_port *ap)
ata_std_softreset, NULL, ata_std_softreset, NULL,
ata_std_postreset); ata_std_postreset);
} }
static int nv_cable_detect(struct ata_port *ap)
{
static const u8 bitmask[2] = {0x03, 0x0C};
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 ata66;
u16 udma;
int cbl;
pci_read_config_byte(pdev, 0x52, &ata66);
if (ata66 & bitmask[ap->port_no])
cbl = ATA_CBL_PATA80;
else
cbl = ATA_CBL_PATA40;
/* We now have to double check because the Nvidia boxes BIOS
doesn't always set the cable bits but does set mode bits */
pci_read_config_word(pdev, 0x62 - 2 * ap->port_no, &udma);
if ((udma & 0xC4) == 0xC4 || (udma & 0xC400) == 0xC400)
cbl = ATA_CBL_PATA80;
return cbl;
}
/** /**
* nv100_set_piomode - set initial PIO mode data * nv100_set_piomode - set initial PIO mode data
* @ap: ATA interface * @ap: ATA interface
...@@ -353,8 +342,9 @@ static struct ata_port_operations amd33_port_ops = { ...@@ -353,8 +342,9 @@ static struct ata_port_operations amd33_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = amd_early_error_handler, .error_handler = amd_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -387,8 +377,9 @@ static struct ata_port_operations amd66_port_ops = { ...@@ -387,8 +377,9 @@ static struct ata_port_operations amd66_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = amd_early_error_handler, .error_handler = amd_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_unknown,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -423,6 +414,7 @@ static struct ata_port_operations amd100_port_ops = { ...@@ -423,6 +414,7 @@ static struct ata_port_operations amd100_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = amd_error_handler, .error_handler = amd_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_unknown,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -457,6 +449,7 @@ static struct ata_port_operations amd133_port_ops = { ...@@ -457,6 +449,7 @@ static struct ata_port_operations amd133_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = amd_error_handler, .error_handler = amd_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = amd_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -491,6 +484,7 @@ static struct ata_port_operations nv100_port_ops = { ...@@ -491,6 +484,7 @@ static struct ata_port_operations nv100_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = nv_error_handler, .error_handler = nv_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = nv_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -525,6 +519,7 @@ static struct ata_port_operations nv133_port_ops = { ...@@ -525,6 +519,7 @@ static struct ata_port_operations nv133_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = nv_error_handler, .error_handler = nv_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = nv_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -49,8 +49,6 @@ static int artop6210_pre_reset(struct ata_port *ap) ...@@ -49,8 +49,6 @@ static int artop6210_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -85,18 +83,28 @@ static int artop6260_pre_reset(struct ata_port *ap) ...@@ -85,18 +83,28 @@ static int artop6260_pre_reset(struct ata_port *ap)
}; };
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 tmp;
/* Odd numbered device ids are the units with enable bits (the -R cards) */ /* Odd numbered device ids are the units with enable bits (the -R cards) */
if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
}
/**
* artop6260_cable_detect - identify cable type
* @ap: Port
*
* Identify the cable type for the ARTOp interface in question
*/
static int artop6260_cable_detect(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 tmp;
pci_read_config_byte(pdev, 0x49, &tmp); pci_read_config_byte(pdev, 0x49, &tmp);
if (tmp & (1 << ap->port_no)) if (tmp & (1 << ap->port_no))
ap->cbl = ATA_CBL_PATA40; return ATA_CBL_PATA40;
else return ATA_CBL_PATA80;
ap->cbl = ATA_CBL_PATA80;
return ata_std_prereset(ap);
} }
/** /**
...@@ -225,7 +233,7 @@ static void artop6260_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -225,7 +233,7 @@ static void artop6260_set_piomode(struct ata_port *ap, struct ata_device *adev)
/** /**
* artop6210_set_dmamode - Initialize host controller PATA PIO timings * artop6210_set_dmamode - Initialize host controller PATA PIO timings
* @ap: Port whose timings we are configuring * @ap: Port whose timings we are configuring
* @adev: um * @adev: Device whose timings we are configuring
* *
* Set DMA mode for device, in host controller PCI config space. * Set DMA mode for device, in host controller PCI config space.
* *
...@@ -333,6 +341,7 @@ static const struct ata_port_operations artop6210_ops = { ...@@ -333,6 +341,7 @@ static const struct ata_port_operations artop6210_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = artop6210_error_handler, .error_handler = artop6210_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -366,6 +375,7 @@ static const struct ata_port_operations artop6260_ops = { ...@@ -366,6 +375,7 @@ static const struct ata_port_operations artop6260_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = artop6260_error_handler, .error_handler = artop6260_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = artop6260_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#define DRV_NAME "pata_atiixp" #define DRV_NAME "pata_atiixp"
#define DRV_VERSION "0.4.4" #define DRV_VERSION "0.4.5"
enum { enum {
ATIIXP_IDE_PIO_TIMING = 0x40, ATIIXP_IDE_PIO_TIMING = 0x40,
...@@ -35,23 +35,15 @@ enum { ...@@ -35,23 +35,15 @@ enum {
static int atiixp_pre_reset(struct ata_port *ap) static int atiixp_pre_reset(struct ata_port *ap)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static const struct pci_bits atiixp_enable_bits[] = { static const struct pci_bits atiixp_enable_bits[] = {
{ 0x48, 1, 0x01, 0x00 }, { 0x48, 1, 0x01, 0x00 },
{ 0x48, 1, 0x08, 0x00 } { 0x48, 1, 0x08, 0x00 }
}; };
u8 udma; struct pci_dev *pdev = to_pci_dev(ap->host->dev);
if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
/* Hack from drivers/ide/pci. Really we want to know how to do the
raw detection not play follow the bios mode guess */
pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ap->port_no, &udma);
if ((udma & 0x07) >= 0x04 || (udma & 0x70) >= 0x40)
ap->cbl = ATA_CBL_PATA80;
else
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -60,6 +52,19 @@ static void atiixp_error_handler(struct ata_port *ap) ...@@ -60,6 +52,19 @@ static void atiixp_error_handler(struct ata_port *ap)
ata_bmdma_drive_eh(ap, atiixp_pre_reset, ata_std_softreset, NULL, ata_std_postreset); ata_bmdma_drive_eh(ap, atiixp_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
} }
static int atiixp_cable_detect(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 udma;
/* Hack from drivers/ide/pci. Really we want to know how to do the
raw detection not play follow the bios mode guess */
pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ap->port_no, &udma);
if ((udma & 0x07) >= 0x04 || (udma & 0x70) >= 0x40)
return ATA_CBL_PATA80;
return ATA_CBL_PATA40;
}
/** /**
* atiixp_set_pio_timing - set initial PIO mode data * atiixp_set_pio_timing - set initial PIO mode data
* @ap: ATA interface * @ap: ATA interface
...@@ -245,6 +250,7 @@ static struct ata_port_operations atiixp_port_ops = { ...@@ -245,6 +250,7 @@ static struct ata_port_operations atiixp_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = atiixp_error_handler, .error_handler = atiixp_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = atiixp_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = atiixp_bmdma_start, .bmdma_start = atiixp_bmdma_start,
......
/*
* pata_cmd640.c - CMD640 PCI PATA for new ATA layer
* (C) 2007 Red Hat Inc
* Alan Cox <alan@redhat.com>
*
* Based upon
* linux/drivers/ide/pci/cmd640.c Version 1.02 Sep 01, 1996
*
* Copyright (C) 1995-1996 Linus Torvalds & authors (see driver)
*
* This drives only the PCI version of the controller. If you have a
* VLB one then we have enough docs to support it but you can write
* your own code.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <scsi/scsi_host.h>
#include <linux/libata.h>
#define DRV_NAME "pata_cmd640"
#define DRV_VERSION "0.0.5"
struct cmd640_reg {
int last;
u8 reg58[ATA_MAX_DEVICES];
};
enum {
CFR = 0x50,
CNTRL = 0x51,
CMDTIM = 0x52,
ARTIM0 = 0x53,
DRWTIM0 = 0x54,
ARTIM23 = 0x57,
DRWTIM23 = 0x58,
BRST = 0x59
};
/**
* cmd640_set_piomode - set initial PIO mode data
* @ap: ATA port
* @adev: ATA device
*
* Called to do the PIO mode setup.
*/
static void cmd640_set_piomode(struct ata_port *ap, struct ata_device *adev)
{
struct cmd640_reg *timing = ap->private_data;
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
struct ata_timing t;
const unsigned long T = 1000000 / 33;
const u8 setup_data[] = { 0x40, 0x40, 0x40, 0x80, 0x00 };
u8 reg;
int arttim = ARTIM0 + 2 * adev->devno;
struct ata_device *pair = ata_dev_pair(adev);
if (ata_timing_compute(adev, adev->pio_mode, &t, T, 0) < 0) {
printk(KERN_ERR DRV_NAME ": mode computation failed.\n");
return;
}
/* The second channel has shared timings and the setup timing is
messy to switch to merge it for worst case */
if (ap->port_no && pair) {
struct ata_timing p;
ata_timing_compute(pair, pair->pio_mode, &p, T, 1);
ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP);
}
/* Make the timings fit */
if (t.recover > 16) {
t.active += t.recover - 16;
t.recover = 16;
}
if (t.active > 16)
t.active = 16;
/* Now convert the clocks into values we can actually stuff into
the chip */
if (t.recover > 1)
t.recover--; /* 640B only */
else
t.recover = 15;
if (t.setup > 4)
t.setup = 0xC0;
else
t.setup = setup_data[t.setup];
if (ap->port_no == 0) {
t.active &= 0x0F; /* 0 = 16 */
/* Load setup timing */
pci_read_config_byte(pdev, arttim, &reg);
reg &= 0x3F;
reg |= t.setup;
pci_write_config_byte(pdev, arttim, reg);
/* Load active/recovery */
pci_write_config_byte(pdev, arttim + 1, (t.active << 4) | t.recover);
} else {
/* Save the shared timings for channel, they will be loaded
by qc_issue_prot. Reloading the setup time is expensive
so we keep a merged one loaded */
pci_read_config_byte(pdev, ARTIM23, &reg);
reg &= 0x3F;
reg |= t.setup;
pci_write_config_byte(pdev, ARTIM23, reg);
timing->reg58[adev->devno] = (t.active << 4) | t.recover;
}
}
/**
* cmd640_qc_issue_prot - command preparation hook
* @qc: Command to be issued
*
* Channel 1 has shared timings. We must reprogram the
* clock each drive 2/3 switch we do.
*/
static unsigned int cmd640_qc_issue_prot(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct ata_device *adev = qc->dev;
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
struct cmd640_reg *timing = ap->private_data;
if (ap->port_no != 0 && adev->devno != timing->last) {
pci_write_config_byte(pdev, DRWTIM23, timing->reg58[adev->devno]);
timing->last = adev->devno;
}
return ata_qc_issue_prot(qc);
}
/**
* cmd640_port_start - port setup
* @ap: ATA port being set up
*
* The CMD640 needs to maintain private data structures so we
* allocate space here.
*/
static int cmd640_port_start(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
struct cmd640_reg *timing;
int ret = ata_port_start(ap);
if (ret < 0)
return ret;
timing = devm_kzalloc(&pdev->dev, sizeof(struct cmd640_reg), GFP_KERNEL);
if (timing == NULL)
return -ENOMEM;
timing->last = -1; /* Force a load */
ap->private_data = timing;
return ret;
}
static struct scsi_host_template cmd640_sht = {
.module = THIS_MODULE,
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
.cmd_per_lun = ATA_SHT_CMD_PER_LUN,
.emulated = ATA_SHT_EMULATED,
.use_clustering = ATA_SHT_USE_CLUSTERING,
.proc_name = DRV_NAME,
.dma_boundary = ATA_DMA_BOUNDARY,
.slave_configure = ata_scsi_slave_config,
.slave_destroy = ata_scsi_slave_destroy,
.bios_param = ata_std_bios_param,
#ifdef CONFIG_PM
.resume = ata_scsi_device_resume,
.suspend = ata_scsi_device_suspend,
#endif
};
static struct ata_port_operations cmd640_port_ops = {
.port_disable = ata_port_disable,
.set_piomode = cmd640_set_piomode,
.mode_filter = ata_pci_default_filter,
.tf_load = ata_tf_load,
.tf_read = ata_tf_read,
.check_status = ata_check_status,
.exec_command = ata_exec_command,
.dev_select = ata_std_dev_select,
.freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw,
.error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start,
.bmdma_stop = ata_bmdma_stop,
.bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep,
.qc_issue = cmd640_qc_issue_prot,
/* In theory this is not needed once we kill the prefetcher */
.data_xfer = ata_data_xfer_noirq,
.irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear,
.irq_on = ata_irq_on,
.irq_ack = ata_irq_ack,
.port_start = cmd640_port_start,
};
static void cmd640_hardware_init(struct pci_dev *pdev)
{
u8 r;
u8 ctrl;
/* CMD640 detected, commiserations */
pci_write_config_byte(pdev, 0x5B, 0x00);
/* Get version info */
pci_read_config_byte(pdev, CFR, &r);
/* PIO0 command cycles */
pci_write_config_byte(pdev, CMDTIM, 0);
/* 512 byte bursts (sector) */
pci_write_config_byte(pdev, BRST, 0x40);
/*
* A reporter a long time ago
* Had problems with the data fifo
* So don't run the risk
* Of putting crap on the disk
* For its better just to go slow
*/
/* Do channel 0 */
pci_read_config_byte(pdev, CNTRL, &ctrl);
pci_write_config_byte(pdev, CNTRL, ctrl | 0xC0);
/* Ditto for channel 1 */
pci_read_config_byte(pdev, ARTIM23, &ctrl);
ctrl |= 0x0C;
pci_write_config_byte(pdev, ARTIM23, ctrl);
}
static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
.sht = &cmd640_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
.port_ops = &cmd640_port_ops
};
static struct ata_port_info *port_info[2] = { &info, &info };
cmd640_hardware_init(pdev);
return ata_pci_init_one(pdev, port_info, 2);
}
static int cmd640_reinit_one(struct pci_dev *pdev)
{
cmd640_hardware_init(pdev);
#ifdef CONFIG_PM
return ata_pci_device_resume(pdev);
#else
return 0;
#endif
}
static const struct pci_device_id cmd640[] = {
{ PCI_VDEVICE(CMD, 0x640), 0 },
{ },
};
static struct pci_driver cmd640_pci_driver = {
.name = DRV_NAME,
.id_table = cmd640,
.probe = cmd640_init_one,
.remove = ata_pci_remove_one,
#ifdef CONFIG_PM
.suspend = ata_pci_device_suspend,
#endif
.resume = cmd640_reinit_one,
};
static int __init cmd640_init(void)
{
return pci_register_driver(&cmd640_pci_driver);
}
static void __exit cmd640_exit(void)
{
pci_unregister_driver(&cmd640_pci_driver);
}
MODULE_AUTHOR("Alan Cox");
MODULE_DESCRIPTION("low-level driver for CMD640 PATA controllers");
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, cmd640);
MODULE_VERSION(DRV_VERSION);
module_init(cmd640_init);
module_exit(cmd640_exit);
...@@ -75,13 +75,7 @@ enum { ...@@ -75,13 +75,7 @@ enum {
DTPR1 = 0x7C DTPR1 = 0x7C
}; };
static int cmd64x_pre_reset(struct ata_port *ap) static int cmd648_cable_detect(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
static int cmd648_pre_reset(struct ata_port *ap)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 r; u8 r;
...@@ -89,21 +83,8 @@ static int cmd648_pre_reset(struct ata_port *ap) ...@@ -89,21 +83,8 @@ static int cmd648_pre_reset(struct ata_port *ap)
/* Check cable detect bits */ /* Check cable detect bits */
pci_read_config_byte(pdev, BMIDECSR, &r); pci_read_config_byte(pdev, BMIDECSR, &r);
if (r & (1 << ap->port_no)) if (r & (1 << ap->port_no))
ap->cbl = ATA_CBL_PATA80; return ATA_CBL_PATA80;
else return ATA_CBL_PATA40;
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
static void cmd64x_error_handler(struct ata_port *ap)
{
return ata_bmdma_drive_eh(ap, cmd64x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}
static void cmd648_error_handler(struct ata_port *ap)
{
ata_bmdma_drive_eh(ap, cmd648_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
} }
/** /**
...@@ -304,8 +285,9 @@ static struct ata_port_operations cmd64x_port_ops = { ...@@ -304,8 +285,9 @@ static struct ata_port_operations cmd64x_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cmd64x_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -338,8 +320,9 @@ static struct ata_port_operations cmd646r1_port_ops = { ...@@ -338,8 +320,9 @@ static struct ata_port_operations cmd646r1_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cmd64x_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -372,8 +355,9 @@ static struct ata_port_operations cmd648_port_ops = { ...@@ -372,8 +355,9 @@ static struct ata_port_operations cmd648_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cmd648_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = cmd648_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -139,18 +139,6 @@ static void cs5520_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -139,18 +139,6 @@ static void cs5520_set_piomode(struct ata_port *ap, struct ata_device *adev)
cs5520_set_timings(ap, adev, adev->pio_mode); cs5520_set_timings(ap, adev, adev->pio_mode);
} }
static int cs5520_pre_reset(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
static void cs5520_error_handler(struct ata_port *ap)
{
return ata_bmdma_drive_eh(ap, cs5520_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}
static struct scsi_host_template cs5520_sht = { static struct scsi_host_template cs5520_sht = {
.module = THIS_MODULE, .module = THIS_MODULE,
.name = DRV_NAME, .name = DRV_NAME,
...@@ -186,8 +174,9 @@ static struct ata_port_operations cs5520_port_ops = { ...@@ -186,8 +174,9 @@ static struct ata_port_operations cs5520_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cs5520_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -197,7 +186,6 @@ static struct ata_port_operations cs5520_port_ops = { ...@@ -197,7 +186,6 @@ static struct ata_port_operations cs5520_port_ops = {
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
.irq_on = ata_irq_on, .irq_on = ata_irq_on,
.irq_ack = ata_irq_ack, .irq_ack = ata_irq_ack,
...@@ -205,91 +193,104 @@ static struct ata_port_operations cs5520_port_ops = { ...@@ -205,91 +193,104 @@ static struct ata_port_operations cs5520_port_ops = {
.port_start = ata_port_start, .port_start = ata_port_start,
}; };
static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{ {
struct ata_port_info pi = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = 0x1f,
.port_ops = &cs5520_port_ops,
};
const struct ata_port_info *ppi[2];
u8 pcicfg; u8 pcicfg;
void __iomem *iomap[5]; void *iomap[5];
static struct ata_probe_ent probe[2]; struct ata_host *host;
int ports = 0; struct ata_ioports *ioaddr;
int i, rc;
/* IDE port enable bits */ /* IDE port enable bits */
pci_read_config_byte(dev, 0x60, &pcicfg); pci_read_config_byte(pdev, 0x60, &pcicfg);
/* Check if the ATA ports are enabled */ /* Check if the ATA ports are enabled */
if ((pcicfg & 3) == 0) if ((pcicfg & 3) == 0)
return -ENODEV; return -ENODEV;
ppi[0] = ppi[1] = &ata_dummy_port_info;
if (pcicfg & 1)
ppi[0] = &pi;
if (pcicfg & 2)
ppi[1] = &pi;
if ((pcicfg & 0x40) == 0) { if ((pcicfg & 0x40) == 0) {
printk(KERN_WARNING DRV_NAME ": DMA mode disabled. Enabling.\n"); dev_printk(KERN_WARNING, &pdev->dev,
pci_write_config_byte(dev, 0x60, pcicfg | 0x40); "DMA mode disabled. Enabling.\n");
pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
} }
pi.mwdma_mask = id->driver_data;
host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
if (!host)
return -ENOMEM;
/* Perform set up for DMA */ /* Perform set up for DMA */
if (pci_enable_device_bars(dev, 1<<2)) { if (pci_enable_device_bars(pdev, 1<<2)) {
printk(KERN_ERR DRV_NAME ": unable to configure BAR2.\n"); printk(KERN_ERR DRV_NAME ": unable to configure BAR2.\n");
return -ENODEV; return -ENODEV;
} }
pci_set_master(dev);
if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
printk(KERN_ERR DRV_NAME ": unable to configure DMA mask.\n"); printk(KERN_ERR DRV_NAME ": unable to configure DMA mask.\n");
return -ENODEV; return -ENODEV;
} }
if (pci_set_consistent_dma_mask(dev, DMA_32BIT_MASK)) { if (pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
printk(KERN_ERR DRV_NAME ": unable to configure consistent DMA mask.\n"); printk(KERN_ERR DRV_NAME ": unable to configure consistent DMA mask.\n");
return -ENODEV; return -ENODEV;
} }
/* Map IO ports */ /* Map IO ports and initialize host accordingly */
iomap[0] = devm_ioport_map(&dev->dev, 0x1F0, 8); iomap[0] = devm_ioport_map(&pdev->dev, 0x1F0, 8);
iomap[1] = devm_ioport_map(&dev->dev, 0x3F6, 1); iomap[1] = devm_ioport_map(&pdev->dev, 0x3F6, 1);
iomap[2] = devm_ioport_map(&dev->dev, 0x170, 8); iomap[2] = devm_ioport_map(&pdev->dev, 0x170, 8);
iomap[3] = devm_ioport_map(&dev->dev, 0x376, 1); iomap[3] = devm_ioport_map(&pdev->dev, 0x376, 1);
iomap[4] = pcim_iomap(dev, 2, 0); iomap[4] = pcim_iomap(pdev, 2, 0);
if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4]) if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4])
return -ENOMEM; return -ENOMEM;
/* We have to do our own plumbing as the PCI setup for this ioaddr = &host->ports[0]->ioaddr;
chipset is non-standard so we can't punt to the libata code */ ioaddr->cmd_addr = iomap[0];
ioaddr->ctl_addr = iomap[1];
INIT_LIST_HEAD(&probe[0].node); ioaddr->altstatus_addr = iomap[1];
probe[0].dev = pci_dev_to_dev(dev); ioaddr->bmdma_addr = iomap[4];
probe[0].port_ops = &cs5520_port_ops; ata_std_ports(ioaddr);
probe[0].sht = &cs5520_sht;
probe[0].pio_mask = 0x1F; ioaddr = &host->ports[1]->ioaddr;
probe[0].mwdma_mask = id->driver_data; ioaddr->cmd_addr = iomap[2];
probe[0].irq = 14; ioaddr->ctl_addr = iomap[3];
probe[0].irq_flags = 0; ioaddr->altstatus_addr = iomap[3];
probe[0].port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST; ioaddr->bmdma_addr = iomap[4] + 8;
probe[0].n_ports = 1; ata_std_ports(ioaddr);
probe[0].port[0].cmd_addr = iomap[0];
probe[0].port[0].ctl_addr = iomap[1]; /* activate the host */
probe[0].port[0].altstatus_addr = iomap[1]; pci_set_master(pdev);
probe[0].port[0].bmdma_addr = iomap[4]; rc = ata_host_start(host);
if (rc)
/* The secondary lurks at different addresses but is otherwise return rc;
the same beastie */
for (i = 0; i < 2; i++) {
probe[1] = probe[0]; static const int irq[] = { 14, 15 };
INIT_LIST_HEAD(&probe[1].node); struct ata_port *ap = host->ports[0];
probe[1].irq = 15;
probe[1].port[0].cmd_addr = iomap[2]; if (ata_port_is_dummy(ap))
probe[1].port[0].ctl_addr = iomap[3]; continue;
probe[1].port[0].altstatus_addr = iomap[3];
probe[1].port[0].bmdma_addr = iomap[4] + 8; rc = devm_request_irq(&pdev->dev, irq[ap->port_no],
ata_interrupt, 0, DRV_NAME, host);
/* Let libata fill in the port details */ if (rc)
ata_std_ports(&probe[0].port[0]); return rc;
ata_std_ports(&probe[1].port[0]); }
/* Now add the ports that are active */ return ata_host_register(host, &cs5520_sht);
if (pcicfg & 1)
ports += ata_device_add(&probe[0]);
if (pcicfg & 2)
ports += ata_device_add(&probe[1]);
if (ports)
return 0;
return -ENODEV;
} }
/** /**
......
...@@ -160,18 +160,6 @@ static unsigned int cs5530_qc_issue_prot(struct ata_queued_cmd *qc) ...@@ -160,18 +160,6 @@ static unsigned int cs5530_qc_issue_prot(struct ata_queued_cmd *qc)
return ata_qc_issue_prot(qc); return ata_qc_issue_prot(qc);
} }
static int cs5530_pre_reset(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
static void cs5530_error_handler(struct ata_port *ap)
{
return ata_bmdma_drive_eh(ap, cs5530_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}
static struct scsi_host_template cs5530_sht = { static struct scsi_host_template cs5530_sht = {
.module = THIS_MODULE, .module = THIS_MODULE,
.name = DRV_NAME, .name = DRV_NAME,
...@@ -213,8 +201,9 @@ static struct ata_port_operations cs5530_port_ops = { ...@@ -213,8 +201,9 @@ static struct ata_port_operations cs5530_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cs5530_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = cs5530_qc_issue_prot, .qc_issue = cs5530_qc_issue_prot,
......
...@@ -70,36 +70,23 @@ ...@@ -70,36 +70,23 @@
#define CS5535_BAD_PIO(timings) ( (timings&~0x80000000UL)==0x00009172 ) #define CS5535_BAD_PIO(timings) ( (timings&~0x80000000UL)==0x00009172 )
/** /**
* cs5535_pre_reset - detect cable type * cs5535_cable_detect - detect cable type
* @ap: Port to detect on * @ap: Port to detect on
* *
* Perform cable detection for ATA66 capable cable. Return a libata * Perform cable detection for ATA66 capable cable. Return a libata
* cable type. * cable type.
*/ */
static int cs5535_pre_reset(struct ata_port *ap) static int cs5535_cable_detect(struct ata_port *ap)
{ {
u8 cable; u8 cable;
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
pci_read_config_byte(pdev, CS5535_CABLE_DETECT, &cable); pci_read_config_byte(pdev, CS5535_CABLE_DETECT, &cable);
if (cable & 1) if (cable & 1)
ap->cbl = ATA_CBL_PATA80; return ATA_CBL_PATA80;
else else
ap->cbl = ATA_CBL_PATA40; return ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
/**
* cs5535_error_handler - reset/probe
* @ap: Port to reset
*
* Reset and configure a port
*/
static void cs5535_error_handler(struct ata_port *ap)
{
ata_bmdma_drive_eh(ap, cs5535_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
} }
/** /**
...@@ -205,8 +192,9 @@ static struct ata_port_operations cs5535_port_ops = { ...@@ -205,8 +192,9 @@ static struct ata_port_operations cs5535_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cs5535_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = cs5535_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -41,17 +41,6 @@ enum { ...@@ -41,17 +41,6 @@ enum {
CY82_INDEX_TIMEOUT = 0x32 CY82_INDEX_TIMEOUT = 0x32
}; };
static int cy82c693_pre_reset(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
static void cy82c693_error_handler(struct ata_port *ap)
{
ata_bmdma_drive_eh(ap, cy82c693_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}
/** /**
* cy82c693_set_piomode - set initial PIO mode data * cy82c693_set_piomode - set initial PIO mode data
* @ap: ATA interface * @ap: ATA interface
...@@ -156,8 +145,9 @@ static struct ata_port_operations cy82c693_port_ops = { ...@@ -156,8 +145,9 @@ static struct ata_port_operations cy82c693_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = cy82c693_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
#include <linux/ata.h> #include <linux/ata.h>
#define DRV_NAME "pata_efar" #define DRV_NAME "pata_efar"
#define DRV_VERSION "0.4.3" #define DRV_VERSION "0.4.4"
/** /**
* efar_pre_reset - check for 40/80 pin * efar_pre_reset - Enable bits
* @ap: Port * @ap: Port
* *
* Perform cable detection for the EFAR ATA interface. This is * Perform cable detection for the EFAR ATA interface. This is
...@@ -38,18 +38,11 @@ static int efar_pre_reset(struct ata_port *ap) ...@@ -38,18 +38,11 @@ static int efar_pre_reset(struct ata_port *ap)
{ 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
{ 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */ { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */
}; };
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 tmp;
if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
pci_read_config_byte(pdev, 0x47, &tmp);
if (tmp & (2 >> ap->port_no))
ap->cbl = ATA_CBL_PATA40;
else
ap->cbl = ATA_CBL_PATA80;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -66,6 +59,25 @@ static void efar_error_handler(struct ata_port *ap) ...@@ -66,6 +59,25 @@ static void efar_error_handler(struct ata_port *ap)
ata_bmdma_drive_eh(ap, efar_pre_reset, ata_std_softreset, NULL, ata_std_postreset); ata_bmdma_drive_eh(ap, efar_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
} }
/**
* efar_cable_detect - check for 40/80 pin
* @ap: Port
*
* Perform cable detection for the EFAR ATA interface. This is
* different to the PIIX arrangement
*/
static int efar_cable_detect(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 tmp;
pci_read_config_byte(pdev, 0x47, &tmp);
if (tmp & (2 >> ap->port_no))
return ATA_CBL_PATA40;
return ATA_CBL_PATA80;
}
/** /**
* efar_set_piomode - Initialize host controller PATA PIO timings * efar_set_piomode - Initialize host controller PATA PIO timings
* @ap: Port whose timings we are configuring * @ap: Port whose timings we are configuring
...@@ -256,6 +268,7 @@ static const struct ata_port_operations efar_ops = { ...@@ -256,6 +268,7 @@ static const struct ata_port_operations efar_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = efar_error_handler, .error_handler = efar_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = efar_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#define DRV_NAME "pata_hpt366" #define DRV_NAME "pata_hpt366"
#define DRV_VERSION "0.6.0" #define DRV_VERSION "0.6.1"
struct hpt_clock { struct hpt_clock {
u8 xfer_speed; u8 xfer_speed;
...@@ -169,13 +169,12 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, cons ...@@ -169,13 +169,12 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, cons
/** /**
* hpt366_filter - mode selection filter * hpt366_filter - mode selection filter
* @ap: ATA interface
* @adev: ATA device * @adev: ATA device
* *
* Block UDMA on devices that cause trouble with this controller. * Block UDMA on devices that cause trouble with this controller.
*/ */
static unsigned long hpt366_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask) static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
{ {
if (adev->class == ATA_DEV_ATA) { if (adev->class == ATA_DEV_ATA) {
if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33)) if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33))
...@@ -185,7 +184,7 @@ static unsigned long hpt366_filter(const struct ata_port *ap, struct ata_device ...@@ -185,7 +184,7 @@ static unsigned long hpt366_filter(const struct ata_port *ap, struct ata_device
if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4)) if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4))
mask &= ~(0x0F << ATA_SHIFT_UDMA); mask &= ~(0x0F << ATA_SHIFT_UDMA);
} }
return ata_pci_default_filter(ap, adev, mask); return ata_pci_default_filter(adev, mask);
} }
/** /**
...@@ -210,24 +209,28 @@ static u32 hpt36x_find_mode(struct ata_port *ap, int speed) ...@@ -210,24 +209,28 @@ static u32 hpt36x_find_mode(struct ata_port *ap, int speed)
return 0xffffffffU; /* silence compiler warning */ return 0xffffffffU; /* silence compiler warning */
} }
static int hpt36x_cable_detect(struct ata_port *ap)
{
u8 ata66;
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
pci_read_config_byte(pdev, 0x5A, &ata66);
if (ata66 & (1 << ap->port_no))
return ATA_CBL_PATA40;
return ATA_CBL_PATA80;
}
static int hpt36x_pre_reset(struct ata_port *ap) static int hpt36x_pre_reset(struct ata_port *ap)
{ {
static const struct pci_bits hpt36x_enable_bits[] = { static const struct pci_bits hpt36x_enable_bits[] = {
{ 0x50, 1, 0x04, 0x04 }, { 0x50, 1, 0x04, 0x04 },
{ 0x54, 1, 0x04, 0x04 } { 0x54, 1, 0x04, 0x04 }
}; };
u8 ata66;
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
pci_read_config_byte(pdev, 0x5A, &ata66);
if (ata66 & (1 << ap->port_no))
ap->cbl = ATA_CBL_PATA40;
else
ap->cbl = ATA_CBL_PATA80;
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -354,6 +357,7 @@ static struct ata_port_operations hpt366_port_ops = { ...@@ -354,6 +357,7 @@ static struct ata_port_operations hpt366_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = hpt36x_error_handler, .error_handler = hpt36x_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = hpt36x_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
This diff is collapsed.
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
* Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
* Portions Copyright (C) 2001 Sun Microsystems, Inc. * Portions Copyright (C) 2001 Sun Microsystems, Inc.
* Portions Copyright (C) 2003 Red Hat Inc * Portions Copyright (C) 2003 Red Hat Inc
* Portions Copyright (C) 2005-2006 MontaVista Software, Inc.
* *
* *
* TODO * TODO
* 371N
* Work out best PLL policy * Work out best PLL policy
*/ */
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#define DRV_NAME "pata_hpt3x2n" #define DRV_NAME "pata_hpt3x2n"
#define DRV_VERSION "0.3.2" #define DRV_VERSION "0.3.3"
enum { enum {
HPT_PCI_FAST = (1 << 31), HPT_PCI_FAST = (1 << 31),
...@@ -115,14 +115,13 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed) ...@@ -115,14 +115,13 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed)
} }
/** /**
* hpt3x2n_pre_reset - reset the hpt3x2n bus * hpt3x2n_cable_detect - Detect the cable type
* @ap: ATA port to reset * @ap: ATA port to detect on
* *
* Perform the initial reset handling for the 3x2n series controllers. * Return the cable type attached to this port
* Reset the hardware and state machine, obtain the cable type.
*/ */
static int hpt3xn_pre_reset(struct ata_port *ap) static int hpt3x2n_cable_detect(struct ata_port *ap)
{ {
u8 scr2, ata66; u8 scr2, ata66;
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
...@@ -135,15 +134,26 @@ static int hpt3xn_pre_reset(struct ata_port *ap) ...@@ -135,15 +134,26 @@ static int hpt3xn_pre_reset(struct ata_port *ap)
pci_write_config_byte(pdev, 0x5B, scr2); pci_write_config_byte(pdev, 0x5B, scr2);
if (ata66 & (1 << ap->port_no)) if (ata66 & (1 << ap->port_no))
ap->cbl = ATA_CBL_PATA40; return ATA_CBL_PATA40;
else else
ap->cbl = ATA_CBL_PATA80; return ATA_CBL_PATA80;
}
/**
* hpt3x2n_pre_reset - reset the hpt3x2n bus
* @ap: ATA port to reset
* @deadline: deadline jiffies for the operation
*
* Perform the initial reset handling for the 3x2n series controllers.
* Reset the hardware and state machine,
*/
static int hpt3xn_pre_reset(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
/* Reset the state machine */ /* Reset the state machine */
pci_write_config_byte(pdev, 0x50, 0x37); pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
pci_write_config_byte(pdev, 0x54, 0x37);
udelay(100); udelay(100);
return ata_std_prereset(ap); return ata_std_prereset(ap);
} }
...@@ -364,6 +374,7 @@ static struct ata_port_operations hpt3x2n_port_ops = { ...@@ -364,6 +374,7 @@ static struct ata_port_operations hpt3x2n_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = hpt3x2n_error_handler, .error_handler = hpt3x2n_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = hpt3x2n_cable_detect,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
...@@ -422,8 +433,9 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) ...@@ -422,8 +433,9 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
{ {
unsigned long freq; unsigned long freq;
u32 fcnt; u32 fcnt;
unsigned long iobase = pci_resource_start(pdev, 4);
pci_read_config_dword(pdev, 0x70/*CHECKME*/, &fcnt); fcnt = inl(iobase + 0x90); /* Not PCI readable for some chips */
if ((fcnt >> 12) != 0xABCDE) { if ((fcnt >> 12) != 0xABCDE) {
printk(KERN_WARNING "hpt3xn: BIOS clock data not set.\n"); printk(KERN_WARNING "hpt3xn: BIOS clock data not set.\n");
return 33; /* Not BIOS set */ return 33; /* Not BIOS set */
...@@ -492,6 +504,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -492,6 +504,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
unsigned int pci_mhz; unsigned int pci_mhz;
unsigned int f_low, f_high; unsigned int f_low, f_high;
int adjust; int adjust;
unsigned long iobase = pci_resource_start(dev, 4);
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
class_rev &= 0xFF; class_rev &= 0xFF;
...@@ -501,6 +514,11 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -501,6 +514,11 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
if (class_rev < 6) if (class_rev < 6)
return -ENODEV; return -ENODEV;
break; break;
case PCI_DEVICE_ID_TTI_HPT371:
if (class_rev < 2)
return -ENODEV;
/* 371N if rev > 1 */
break;
case PCI_DEVICE_ID_TTI_HPT372: case PCI_DEVICE_ID_TTI_HPT372:
/* 372N if rev >= 1*/ /* 372N if rev >= 1*/
if (class_rev == 0) if (class_rev == 0)
...@@ -528,6 +546,19 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -528,6 +546,19 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
irqmask &= ~0x10; irqmask &= ~0x10;
pci_write_config_byte(dev, 0x5a, irqmask); pci_write_config_byte(dev, 0x5a, irqmask);
/*
* HPT371 chips physically have only one channel, the secondary one,
* but the primary channel registers do exist! Go figure...
* So, we manually disable the non-existing channel here
* (if the BIOS hasn't done this already).
*/
if (dev->device == PCI_DEVICE_ID_TTI_HPT371) {
u8 mcr1;
pci_read_config_byte(dev, 0x50, &mcr1);
mcr1 &= ~0x04;
pci_write_config_byte(dev, 0x50, mcr1);
}
/* Tune the PLL. HPT recommend using 75 for SATA, 66 for UDMA133 or /* Tune the PLL. HPT recommend using 75 for SATA, 66 for UDMA133 or
50 for UDMA100. Right now we always use 66 */ 50 for UDMA100. Right now we always use 66 */
...@@ -546,14 +577,24 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -546,14 +577,24 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
break; break;
pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);
} }
if (adjust == 8) if (adjust == 8) {
printk(KERN_WARNING "hpt3xn: DPLL did not stabilize.\n"); printk(KERN_WARNING "hpt3x2n: DPLL did not stabilize.\n");
return -ENODEV;
}
/* Set our private data up. We only need a few flags so we use /* Set our private data up. We only need a few flags so we use
it directly */ it directly */
port->private_data = NULL; port->private_data = NULL;
if (pci_mhz > 60) if (pci_mhz > 60) {
port->private_data = (void *)PCI66; port->private_data = (void *)PCI66;
/*
* On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
* the MISC. register to stretch the UltraDMA Tss timing.
* NOTE: This register is only writeable via I/O space.
*/
if (dev->device == PCI_DEVICE_ID_TTI_HPT371)
outb(inb(iobase + 0x9c) | 0x04, iobase + 0x9c);
}
/* Now kick off ATA set up */ /* Now kick off ATA set up */
port_info[0] = port_info[1] = port; port_info[0] = port_info[1] = port;
...@@ -562,6 +603,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -562,6 +603,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
static const struct pci_device_id hpt3x2n[] = { static const struct pci_device_id hpt3x2n[] = {
{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), }, { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), },
{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT371), },
{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372), }, { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372), },
{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302), }, { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302), },
{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372N), }, { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372N), },
......
...@@ -25,25 +25,6 @@ ...@@ -25,25 +25,6 @@
#define DRV_NAME "pata_hpt3x3" #define DRV_NAME "pata_hpt3x3"
#define DRV_VERSION "0.4.2" #define DRV_VERSION "0.4.2"
static int hpt3x3_probe_init(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA40;
return ata_std_prereset(ap);
}
/**
* hpt3x3_probe_reset - reset the hpt3x3 bus
* @ap: ATA port to reset
*
* Perform the housekeeping when doing an ATA bus reeset. We just
* need to force the cable type.
*/
static void hpt3x3_error_handler(struct ata_port *ap)
{
return ata_bmdma_drive_eh(ap, hpt3x3_probe_init, ata_std_softreset, NULL, ata_std_postreset);
}
/** /**
* hpt3x3_set_piomode - PIO setup * hpt3x3_set_piomode - PIO setup
* @ap: ATA interface * @ap: ATA interface
...@@ -139,8 +120,9 @@ static struct ata_port_operations hpt3x3_port_ops = { ...@@ -139,8 +120,9 @@ static struct ata_port_operations hpt3x3_port_ops = {
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = hpt3x3_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/ata.h> #include <linux/ata.h>
#define DRV_NAME "pata_marvell" #define DRV_NAME "pata_marvell"
#define DRV_VERSION "0.1.1" #define DRV_VERSION "0.1.4"
/** /**
* marvell_pre_reset - check for 40/80 pin * marvell_pre_reset - check for 40/80 pin
...@@ -52,22 +52,23 @@ static int marvell_pre_reset(struct ata_port *ap) ...@@ -52,22 +52,23 @@ static int marvell_pre_reset(struct ata_port *ap)
if ((pdev->device == 0x6145) && (ap->port_no == 0) && if ((pdev->device == 0x6145) && (ap->port_no == 0) &&
(!(devices & 0x10))) /* PATA enable ? */ (!(devices & 0x10))) /* PATA enable ? */
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
}
static int marvell_cable_detect(struct ata_port *ap)
{
/* Cable type */ /* Cable type */
switch(ap->port_no) switch(ap->port_no)
{ {
case 0: case 0:
if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1) if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
ap->cbl = ATA_CBL_PATA40; return ATA_CBL_PATA40;
else return ATA_CBL_PATA80;
ap->cbl = ATA_CBL_PATA80;
break;
case 1: /* Legacy SATA port */ case 1: /* Legacy SATA port */
ap->cbl = ATA_CBL_SATA; return ATA_CBL_SATA;
break;
} }
return ata_std_prereset(ap); BUG();
return 0; /* Our BUG macro needs the right markup */
} }
/** /**
...@@ -123,6 +124,7 @@ static const struct ata_port_operations marvell_ops = { ...@@ -123,6 +124,7 @@ static const struct ata_port_operations marvell_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = marvell_error_handler, .error_handler = marvell_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = marvell_cable_detect,
/* BMDMA handling is PCI ATA format, use helpers */ /* BMDMA handling is PCI ATA format, use helpers */
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -216,6 +216,7 @@ static struct ata_port_operations sc1200_port_ops = { ...@@ -216,6 +216,7 @@ static struct ata_port_operations sc1200_port_ops = {
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ata_bmdma_error_handler, .error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd, .post_internal_cmd = ata_bmdma_post_internal_cmd,
.cable_detect = ata_cable_40wire,
.bmdma_setup = ata_bmdma_setup, .bmdma_setup = ata_bmdma_setup,
.bmdma_start = ata_bmdma_start, .bmdma_start = ata_bmdma_start,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment