Skip to content

Commit 7808159

Browse files
committed
Merge tag 'ata-5.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull ata fixes from Damien Le Moal: "Two fixes for the pata_hpt37x driver, both from Sergey: - Fix a PCI register access using an incorrect size (8bits instead of 16bits) - Make sure to always disable the primary channel as it is unused" * tag 'ata-5.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: ata: pata_hpt37x: disable primary channel on HPT371 ata: pata_hpt37x: fix PCI clock detection
2 parents 53ab78c + 8d093e0 commit 7808159

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

drivers/ata/pata_hpt37x.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,20 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
919919
irqmask &= ~0x10;
920920
pci_write_config_byte(dev, 0x5a, irqmask);
921921

922+
/*
923+
* HPT371 chips physically have only one channel, the secondary one,
924+
* but the primary channel registers do exist! Go figure...
925+
* So, we manually disable the non-existing channel here
926+
* (if the BIOS hasn't done this already).
927+
*/
928+
if (dev->device == PCI_DEVICE_ID_TTI_HPT371) {
929+
u8 mcr1;
930+
931+
pci_read_config_byte(dev, 0x50, &mcr1);
932+
mcr1 &= ~0x04;
933+
pci_write_config_byte(dev, 0x50, mcr1);
934+
}
935+
922936
/*
923937
* default to pci clock. make sure MA15/16 are set to output
924938
* to prevent drives having problems with 40-pin cables. Needed
@@ -950,14 +964,14 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
950964

951965
if ((freq >> 12) != 0xABCDE) {
952966
int i;
953-
u8 sr;
967+
u16 sr;
954968
u32 total = 0;
955969

956970
dev_warn(&dev->dev, "BIOS has not set timing clocks\n");
957971

958972
/* This is the process the HPT371 BIOS is reported to use */
959973
for (i = 0; i < 128; i++) {
960-
pci_read_config_byte(dev, 0x78, &sr);
974+
pci_read_config_word(dev, 0x78, &sr);
961975
total += sr & 0x1FF;
962976
udelay(15);
963977
}

0 commit comments

Comments
 (0)