📄 hpt366.c
字号:
/* * linux/drivers/ide/hpt366.c Version 0.18 June. 9, 2000 * * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> * May be copied or modified under the terms of the GNU General Public License * * Thanks to HighPoint Technologies for their assistance, and hardware. * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his * donation of an ABit BP6 mainboard, processor, and memory acellerated * development and support. * * Note that final HPT370 support was done by force extraction of GPL. * */#include <linux/config.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/delay.h>#include <linux/timer.h>#include <linux/mm.h>#include <linux/ioport.h>#include <linux/blkdev.h>#include <linux/hdreg.h>#include <linux/interrupt.h>#include <linux/pci.h>#include <linux/init.h>#include <linux/ide.h>#include <asm/io.h>#include <asm/irq.h>#include "ide_modes.h"#define DISPLAY_HPT366_TIMINGS#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)#include <linux/stat.h>#include <linux/proc_fs.h>#endif /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */extern char *ide_dmafunc_verbose(ide_dma_action_t dmafunc);const char *quirk_drives[] = { "QUANTUM FIREBALLlct08 08", "QUANTUM FIREBALLP KA6.4", "QUANTUM FIREBALLP LM20.4", "QUANTUM FIREBALLP LM20.5", NULL};const char *bad_ata100_5[] = { "IBM-DTLA-307075", "IBM-DTLA-307060", "IBM-DTLA-307045", "IBM-DTLA-307030", "IBM-DTLA-307020", "IBM-DTLA-307015", "IBM-DTLA-305040", "IBM-DTLA-305030", "IBM-DTLA-305020", "IC35L010AVER07-0", "IC35L020AVER07-0", "IC35L030AVER07-0", "IC35L040AVER07-0", "IC35L060AVER07-0", "WDC AC310200R", NULL};const char *bad_ata66_4[] = { "IBM-DTLA-307075", "IBM-DTLA-307060", "IBM-DTLA-307045", "IBM-DTLA-307030", "IBM-DTLA-307020", "IBM-DTLA-307015", "IBM-DTLA-305040", "IBM-DTLA-305030", "IBM-DTLA-305020", "IC35L010AVER07-0", "IC35L020AVER07-0", "IC35L030AVER07-0", "IC35L040AVER07-0", "IC35L060AVER07-0", "WDC AC310200R", NULL};const char *bad_ata66_3[] = { "WDC AC310200R", NULL};const char *bad_ata33[] = { "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2", "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4", "Maxtor 90510D4", "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2", "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4", "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2", NULL};struct chipset_bus_clock_list_entry { byte xfer_speed; unsigned int chipset_settings_write; unsigned int chipset_settings_read;};struct chipset_bus_clock_list_entry forty_base [] = { { XFER_UDMA_4, 0x900fd943, 0x900fd943 }, { XFER_UDMA_3, 0x900ad943, 0x900ad943 }, { XFER_UDMA_2, 0x900bd943, 0x900bd943 }, { XFER_UDMA_1, 0x9008d943, 0x9008d943 }, { XFER_UDMA_0, 0x9008d943, 0x9008d943 }, { XFER_MW_DMA_2, 0xa008d943, 0xa008d943 }, { XFER_MW_DMA_1, 0xa010d955, 0xa010d955 }, { XFER_MW_DMA_0, 0xa010d9fc, 0xa010d9fc }, { XFER_PIO_4, 0xc008d963, 0xc008d963 }, { XFER_PIO_3, 0xc010d974, 0xc010d974 }, { XFER_PIO_2, 0xc010d997, 0xc010d997 }, { XFER_PIO_1, 0xc010d9c7, 0xc010d9c7 }, { XFER_PIO_0, 0xc018d9d9, 0xc018d9d9 }, { 0, 0x0120d9d9, 0x0120d9d9 }};struct chipset_bus_clock_list_entry thirty_three_base [] = { { XFER_UDMA_4, 0x90c9a731, 0x90c9a731 }, { XFER_UDMA_3, 0x90cfa731, 0x90cfa731 }, { XFER_UDMA_2, 0x90caa731, 0x90caa731 }, { XFER_UDMA_1, 0x90cba731, 0x90cba731 }, { XFER_UDMA_0, 0x90c8a731, 0x90c8a731 }, { XFER_MW_DMA_2, 0xa0c8a731, 0xa0c8a731 }, { XFER_MW_DMA_1, 0xa0c8a732, 0xa0c8a732 }, /* 0xa0c8a733 */ { XFER_MW_DMA_0, 0xa0c8a797, 0xa0c8a797 }, { XFER_PIO_4, 0xc0c8a731, 0xc0c8a731 }, { XFER_PIO_3, 0xc0c8a742, 0xc0c8a742 }, { XFER_PIO_2, 0xc0d0a753, 0xc0d0a753 }, { XFER_PIO_1, 0xc0d0a7a3, 0xc0d0a7a3 }, /* 0xc0d0a793 */ { XFER_PIO_0, 0xc0d0a7aa, 0xc0d0a7aa }, /* 0xc0d0a7a7 */ { 0, 0x0120a7a7, 0x0120a7a7 }};struct chipset_bus_clock_list_entry twenty_five_base [] = { { XFER_UDMA_4, 0x90c98521, 0x90c98521 }, { XFER_UDMA_3, 0x90cf8521, 0x90cf8521 }, { XFER_UDMA_2, 0x90cf8521, 0x90cf8521 }, { XFER_UDMA_1, 0x90cb8521, 0x90cb8521 }, { XFER_UDMA_0, 0x90cb8521, 0x90cb8521 }, { XFER_MW_DMA_2, 0xa0ca8521, 0xa0ca8521 }, { XFER_MW_DMA_1, 0xa0ca8532, 0xa0ca8532 }, { XFER_MW_DMA_0, 0xa0ca8575, 0xa0ca8575 }, { XFER_PIO_4, 0xc0ca8521, 0xc0ca8521 }, { XFER_PIO_3, 0xc0ca8532, 0xc0ca8532 }, { XFER_PIO_2, 0xc0ca8542, 0xc0ca8542 }, { XFER_PIO_1, 0xc0d08572, 0xc0d08572 }, { XFER_PIO_0, 0xc0d08585, 0xc0d08585 }, { 0, 0x01208585, 0x01208585 }};struct chipset_bus_clock_list_entry thirty_three_base_hpt370[] = { { XFER_UDMA_5, 0x1A85F442, 0x16454e31 }, { XFER_UDMA_4, 0x16454e31, 0x16454e31 }, { XFER_UDMA_3, 0x166d4e31, 0x166d4e31 }, { XFER_UDMA_2, 0x16494e31, 0x16494e31 }, { XFER_UDMA_1, 0x164d4e31, 0x164d4e31 }, { XFER_UDMA_0, 0x16514e31, 0x16514e31 }, { XFER_MW_DMA_2, 0x26514e21, 0x26514e21 }, { XFER_MW_DMA_1, 0x26514e33, 0x26514e33 }, { XFER_MW_DMA_0, 0x26514e97, 0x26514e97 }, { XFER_PIO_4, 0x06514e21, 0x06514e21 }, { XFER_PIO_3, 0x06514e22, 0x06514e22 }, { XFER_PIO_2, 0x06514e33, 0x06514e33 }, { XFER_PIO_1, 0x06914e43, 0x06914e43 }, { XFER_PIO_0, 0x06914e57, 0x06914e57 }, { 0, 0x06514e57, 0x06514e57 }};#define HPT366_DEBUG_DRIVE_INFO 0#define HPT370_ALLOW_ATA100_5 1#define HPT366_ALLOW_ATA66_4 1#define HPT366_ALLOW_ATA66_3 1#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)static int hpt366_get_info(char *, char **, off_t, int);extern int (*hpt366_display_info)(char *, char **, off_t, int); /* ide-proc.c */extern char *ide_media_verbose(ide_drive_t *);static struct pci_dev *bmide_dev;static struct pci_dev *bmide2_dev;static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count){ char *p = buffer; u32 bibma = bmide_dev->resource[4].start; u32 bibma2 = bmide2_dev->resource[4].start; char *chipset_names[] = {"HPT366", "HPT366", "HPT368", "HPT370", "HPT370A"}; u8 c0 = 0, c1 = 0; u32 class_rev; pci_read_config_dword(bmide_dev, PCI_CLASS_REVISION, &class_rev); class_rev &= 0xff; /* * at that point bibma+0x2 et bibma+0xa are byte registers * to investigate: */ c0 = inb_p((unsigned short)bibma + 0x02); if (bmide2_dev) c1 = inb_p((unsigned short)bibma2 + 0x02); p += sprintf(p, "\n %s Chipset.\n", chipset_names[class_rev]); p += sprintf(p, "--------------- Primary Channel ---------------- Secondary Channel -------------\n"); p += sprintf(p, " %sabled %sabled\n", (c0&0x80) ? "dis" : " en", (c1&0x80) ? "dis" : " en"); p += sprintf(p, "--------------- drive0 --------- drive1 -------- drive0 ---------- drive1 ------\n"); p += sprintf(p, "DMA enabled: %s %s %s %s\n", (c0&0x20) ? "yes" : "no ", (c0&0x40) ? "yes" : "no ", (c1&0x20) ? "yes" : "no ", (c1&0x40) ? "yes" : "no " ); p += sprintf(p, "UDMA\n"); p += sprintf(p, "DMA\n"); p += sprintf(p, "PIO\n"); return p-buffer;/* => must be less than 4k! */}#endif /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */byte hpt366_proc = 0;extern char *ide_xfer_verbose (byte xfer_rate);byte hpt363_shared_irq;byte hpt363_shared_pin;static unsigned int pci_rev_check_hpt3xx (struct pci_dev *dev){ unsigned int class_rev; pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); class_rev &= 0xff; return ((int) (class_rev > 0x02) ? 1 : 0);}static unsigned int pci_rev2_check_hpt3xx (struct pci_dev *dev){ unsigned int class_rev; pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); class_rev &= 0xff; return ((int) (class_rev > 0x01) ? 1 : 0);}static int check_in_drive_lists (ide_drive_t *drive, const char **list){ struct hd_driveid *id = drive->id; if (quirk_drives == list) { while (*list) { if (strstr(id->model, *list++)) { return 1; } } } else { while (*list) { if (!strcmp(*list++,id->model)) { return 1; } } } return 0;}static unsigned int pci_bus_clock_list (byte speed, int direction, struct chipset_bus_clock_list_entry * chipset_table){ for ( ; chipset_table->xfer_speed ; chipset_table++) if (chipset_table->xfer_speed == speed) { return (direction) ? chipset_table->chipset_settings_write : chipset_table->chipset_settings_read; } return (direction) ? chipset_table->chipset_settings_write : chipset_table->chipset_settings_read;}static void hpt366_tune_chipset (ide_drive_t *drive, byte speed, int direction){ byte regtime = (drive->select.b.unit & 0x01) ? 0x44 : 0x40; byte regfast = (HWIF(drive)->channel) ? 0x55 : 0x51; /* * since the channel is always 0 it does not matter. */ unsigned int reg1 = 0; unsigned int reg2 = 0; byte drive_fast = 0; /* * Disable the "fast interrupt" prediction. */ pci_read_config_byte(HWIF(drive)->pci_dev, regfast, &drive_fast); if (drive_fast & 0x02) pci_write_config_byte(HWIF(drive)->pci_dev, regfast, drive_fast & ~0x20); pci_read_config_dword(HWIF(drive)->pci_dev, regtime, ®1); /* detect bus speed by looking at control reg timing: */ switch((reg1 >> 8) & 7) { case 5: reg2 = pci_bus_clock_list(speed, direction, forty_base); break; case 9: reg2 = pci_bus_clock_list(speed, direction, twenty_five_base); break; default: case 7: reg2 = pci_bus_clock_list(speed, direction, thirty_three_base); break; } /* * Disable on-chip PIO FIFO/buffer (to avoid problems handling I/O errors later) */ if (speed >= XFER_MW_DMA_0) { reg2 = (reg2 & ~0xc0000000) | (reg1 & 0xc0000000); } else { reg2 = (reg2 & ~0x30070000) | (reg1 & 0x30070000); } reg2 &= ~0x80000000; pci_write_config_dword(HWIF(drive)->pci_dev, regtime, reg2);}static void hpt370_tune_chipset (ide_drive_t *drive, byte speed, int direction){ byte regfast = (HWIF(drive)->channel) ? 0x55 : 0x51; byte reg5bh = (speed != XFER_UDMA_5) ? 0x22 : (direction) ? 0x20 : 0x22; unsigned int list_conf = pci_bus_clock_list(speed, direction, thirty_three_base_hpt370); unsigned int drive_conf = 0; unsigned int conf_mask = (speed >= XFER_MW_DMA_0) ? 0xc0000000 : 0x30070000; byte drive_pci = 0; byte drive_fast = 0; switch (drive->dn) { case 0: drive_pci = 0x40; break; case 1: drive_pci = 0x44; break; case 2: drive_pci = 0x48; break; case 3: drive_pci = 0x4c; break; default: return; } /* * Disable the "fast interrupt" prediction. */ pci_read_config_byte(HWIF(drive)->pci_dev, regfast, &drive_fast); if (drive_fast & 0x80) pci_write_config_byte(HWIF(drive)->pci_dev, regfast, drive_fast & ~0x80); pci_read_config_dword(HWIF(drive)->pci_dev, drive_pci, &drive_conf); pci_write_config_byte(HWIF(drive)->pci_dev, 0x5b, reg5bh); list_conf = (list_conf & ~conf_mask) | (drive_conf & conf_mask); /* * Disable on-chip PIO FIFO/buffer (to avoid problems handling I/O errors later) */ list_conf &= ~0x80000000; pci_write_config_dword(HWIF(drive)->pci_dev, drive_pci, list_conf);}static int hpt3xx_tune_chipset (ide_drive_t *drive, byte speed){ if ((drive->media != ide_disk) && (speed < XFER_SW_DMA_0)) return -1; if (!drive->init_speed) drive->init_speed = speed; if (pci_rev_check_hpt3xx(HWIF(drive)->pci_dev)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -