diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-03-23 14:35:59 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-03-23 14:35:59 -0700 |
commit | c7d4b15372bde442059c7d6415afeba073a09474 (patch) | |
tree | 2354ff8fb6d44a70f7959e1ba5bfde70b6db9163 /drivers/ata/pata_hpt37x.c | |
parent | d51b1b33c51d147b757f042b4d336603b699f362 (diff) | |
parent | d268afa1ff6f582dede1819fbed7ded7442a406c (diff) |
Merge tag 'ata-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull ata updates from Damien Le Moal:
"For this cycle, no big change but many small fixes and code cleanup to
libata, the ahci driver and various pata drivers. In more details:
- Code simplification in pata_platform using
platform_get_mem_or_io(), from Lad.
- Fix read-only arrays declarations as const in pata_atiixp and
pata_pdc202xx_old, from Colin.
- Various cleanups and code simplification in libata-scsi, from me.
- Remove dead code in libata-acpi, from Sergey.
- Skip device scan deboune delay for Marvell 88SE9235 adapters (ahci)
to speedup boot, from Paul.
- Simplify functions declaration and use for functions always
returning 0 in libata-core, from Sergey.
- Non-fatal error fixes and in the pata_hpt366 and pata_hpt3x2n
drivers, from Sergey.
- Various code cleanup in the pata_artop, pata_hpt37x, pata_hpt366,
pata_hpt3x2n, pata_samsung_cf and sata_rcar drivers, from Sergey.
- Some libata-sff and libata-scsi code cleanup (e.g. change functions
to return "bool"), from Sergey.
- Renae ahci_board_mobile to board_ahci_low_power to be more
descriptive of the feature as that is also used on PC and server
AHCI adapters, from Mario.
- Cleanup of OF match tables, from Geert.
- Simplify the pata_pxa driver initialization using
platform_get_irq(), from Minghao"
* tag 'ata-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: (38 commits)
ata: pata_pxa: Use platform_get_irq() to get the interrupt
ata: Drop commas after OF match table sentinels
ata: ahci: Rename CONFIG_SATA_LPM_MOBILE_POLICY configuration item
ata: ahci: Rename `AHCI_HFLAG_IS_MOBILE`
ata: ahci: Rename board_ahci_mobile
ata: pata_hpt37x: merge transfer mode setting methods
ata: libata-sff: use *switch* statement in ata_sff_dev_classify()
ata: add/use ata_taskfile::{error|status} fields
ata: Kconfig: fix sata gemini compile test condition
ata: libata-scsi: use *switch* statements to check SCSI command codes
ata: libata-sff: refactor ata_sff_altstatus()
ata: libata-sff: refactor ata_sff_set_devctl()
ata: libata-sff: make ata_resources_present() return 'bool'
ata: pata_hpt3x2n: disable fast interrupts in prereset() method
ata: pata_hpt37x: disable fast interrupts in prereset() method
ata: pata_hpt366: disable fast interrupts in prereset() method
ata: pata_mpc52xx: use GFP_KERNEL
ata: sata_rcar: drop unused #define's
ata: pata_hpt366: check channel enable bits
ata: sata_rcar: make sata_rcar_ata_devchk() return 'bool'
...
Diffstat (limited to 'drivers/ata/pata_hpt37x.c')
-rw-r--r-- | drivers/ata/pata_hpt37x.c | 115 |
1 files changed, 31 insertions, 84 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 6fa4a2faf49c..156f304ef051 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -23,7 +23,7 @@ #include <linux/libata.h> #define DRV_NAME "pata_hpt37x" -#define DRV_VERSION "0.6.23" +#define DRV_VERSION "0.6.25" struct hpt_clock { u8 xfer_speed; @@ -394,6 +394,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) { 0x50, 1, 0x04, 0x04 }, { 0x54, 1, 0x04, 0x04 } }; + u8 mcr2; if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) return -ENOENT; @@ -402,25 +403,29 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); udelay(100); + /* + * Disable the "fast interrupt" prediction. Don't hold off + * on interrupts. (== 0x01 despite what the docs say) + */ + pci_read_config_byte(pdev, 0x51 + 4 * ap->port_no, &mcr2); + /* Is it HPT370/A? */ + if (pdev->device == PCI_DEVICE_ID_TTI_HPT366 && pdev->revision < 5) { + mcr2 &= ~0x02; + mcr2 |= 0x01; + } else { + mcr2 &= ~0x07; + } + pci_write_config_byte(pdev, 0x51 + 4 * ap->port_no, mcr2); + return ata_sff_prereset(link, deadline); } -static void hpt370_set_mode(struct ata_port *ap, struct ata_device *adev, +static void hpt37x_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mode) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); - u32 addr1, addr2; + int addr = 0x40 + 4 * (adev->devno + 2 * ap->port_no); u32 reg, timing, mask; - u8 fast; - - addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); - addr2 = 0x51 + 4 * ap->port_no; - - /* Fast interrupt prediction disable, hold off interrupt disable */ - pci_read_config_byte(pdev, addr2, &fast); - fast &= ~0x02; - fast |= 0x01; - pci_write_config_byte(pdev, addr2, fast); /* Determine timing mask and find matching mode entry */ if (mode < XFER_MW_DMA_0) @@ -432,34 +437,34 @@ static void hpt370_set_mode(struct ata_port *ap, struct ata_device *adev, timing = hpt37x_find_mode(ap, mode); - pci_read_config_dword(pdev, addr1, ®); + pci_read_config_dword(pdev, addr, ®); reg = (reg & ~mask) | (timing & mask); - pci_write_config_dword(pdev, addr1, reg); + pci_write_config_dword(pdev, addr, reg); } /** - * hpt370_set_piomode - PIO setup + * hpt37x_set_piomode - PIO setup * @ap: ATA interface * @adev: device on the interface * * Perform PIO mode setup. */ -static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev) +static void hpt37x_set_piomode(struct ata_port *ap, struct ata_device *adev) { - hpt370_set_mode(ap, adev, adev->pio_mode); + hpt37x_set_mode(ap, adev, adev->pio_mode); } /** - * hpt370_set_dmamode - DMA timing setup + * hpt37x_set_dmamode - DMA timing setup * @ap: ATA interface * @adev: Device being configured * * Set up the channel for MWDMA or UDMA modes. */ -static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev) +static void hpt37x_set_dmamode(struct ata_port *ap, struct ata_device *adev) { - hpt370_set_mode(ap, adev, adev->dma_mode); + hpt37x_set_mode(ap, adev, adev->dma_mode); } /** @@ -499,63 +504,6 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc) ata_bmdma_stop(qc); } -static void hpt372_set_mode(struct ata_port *ap, struct ata_device *adev, - u8 mode) -{ - struct pci_dev *pdev = to_pci_dev(ap->host->dev); - u32 addr1, addr2; - u32 reg, timing, mask; - u8 fast; - - addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); - addr2 = 0x51 + 4 * ap->port_no; - - /* Fast interrupt prediction disable, hold off interrupt disable */ - pci_read_config_byte(pdev, addr2, &fast); - fast &= ~0x07; - pci_write_config_byte(pdev, addr2, fast); - - /* Determine timing mask and find matching mode entry */ - if (mode < XFER_MW_DMA_0) - mask = 0xcfc3ffff; - else if (mode < XFER_UDMA_0) - mask = 0x31c001ff; - else - mask = 0x303c0000; - - timing = hpt37x_find_mode(ap, mode); - - pci_read_config_dword(pdev, addr1, ®); - reg = (reg & ~mask) | (timing & mask); - pci_write_config_dword(pdev, addr1, reg); -} - -/** - * hpt372_set_piomode - PIO setup - * @ap: ATA interface - * @adev: device on the interface - * - * Perform PIO mode setup. - */ - -static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev) -{ - hpt372_set_mode(ap, adev, adev->pio_mode); -} - -/** - * hpt372_set_dmamode - DMA timing setup - * @ap: ATA interface - * @adev: Device being configured - * - * Set up the channel for MWDMA or UDMA modes. - */ - -static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev) -{ - hpt372_set_mode(ap, adev, adev->dma_mode); -} - /** * hpt37x_bmdma_stop - DMA engine stop * @qc: ATA command @@ -593,8 +541,8 @@ static struct ata_port_operations hpt370_port_ops = { .mode_filter = hpt370_filter, .cable_detect = hpt37x_cable_detect, - .set_piomode = hpt370_set_piomode, - .set_dmamode = hpt370_set_dmamode, + .set_piomode = hpt37x_set_piomode, + .set_dmamode = hpt37x_set_dmamode, .prereset = hpt37x_pre_reset, }; @@ -608,8 +556,7 @@ static struct ata_port_operations hpt370a_port_ops = { }; /* - * Configuration for HPT371 and HPT302. Slightly different PIO and DMA - * mode setting functionality. + * Configuration for HPT371 and HPT302. */ static struct ata_port_operations hpt302_port_ops = { @@ -618,8 +565,8 @@ static struct ata_port_operations hpt302_port_ops = { .bmdma_stop = hpt37x_bmdma_stop, .cable_detect = hpt37x_cable_detect, - .set_piomode = hpt372_set_piomode, - .set_dmamode = hpt372_set_dmamode, + .set_piomode = hpt37x_set_piomode, + .set_dmamode = hpt37x_set_dmamode, .prereset = hpt37x_pre_reset, }; |