/*1* Copyright (C) 1996 Linus Torvalds & author (see below)2*/34#include <linux/module.h>5#include <linux/types.h>6#include <linux/kernel.h>7#include <linux/delay.h>8#include <linux/timer.h>9#include <linux/mm.h>10#include <linux/ioport.h>11#include <linux/blkdev.h>12#include <linux/ide.h>13#include <linux/init.h>1415#include <asm/io.h>1617#define DRV_NAME "dtc2278"1819/*20* Changing this #undef to #define may solve start up problems in some systems.21*/22#undef ALWAYS_SET_DTC2278_PIO_MODE2324/*25* From: [email protected] (Dyan Wile)26*27* Below is a patch for DTC-2278 - alike software-programmable controllers28* The code enables the secondary IDE controller and the PIO4 (3?) timings on29* the primary (EIDE). You may probably have to enable the 32-bit support to30* get the full speed. You better get the disk interrupts disabled ( hdparm -u031* /dev/hd.. ) for the drives connected to the EIDE interface. (I get my32* filesystem corrupted with -u1, but under heavy disk load only :-)33*34* This card is now forced to use the "serialize" feature,35* and irq-unmasking is disallowed. If io_32bit is enabled,36* it must be done for BOTH drives on each interface.37*38* This code was written for the DTC2278E, but might work with any of these:39*40* DTC2278S has only a single IDE interface.41* DTC2278D has two IDE interfaces and is otherwise identical to the S version.42* DTC2278E also has serial ports and a printer port43* DTC2278EB: has onboard BIOS, and "works like a charm" -- Kent Bradford <[email protected]>44*45* There may be a fourth controller type. The S and D versions use the46* Winbond chip, and I think the E version does also.47*48*/4950static void sub22 (char b, char c)51{52int i;5354for(i = 0; i < 3; ++i) {55inb(0x3f6);56outb_p(b,0xb0);57inb(0x3f6);58outb_p(c,0xb4);59inb(0x3f6);60if(inb(0xb4) == c) {61outb_p(7,0xb0);62inb(0x3f6);63return; /* success */64}65}66}6768static DEFINE_SPINLOCK(dtc2278_lock);6970static void dtc2278_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)71{72unsigned long flags;7374if (drive->pio_mode >= XFER_PIO_3) {75spin_lock_irqsave(&dtc2278_lock, flags);76/*77* This enables PIO mode4 (3?) on the first interface78*/79sub22(1,0xc3);80sub22(0,0xa0);81spin_unlock_irqrestore(&dtc2278_lock, flags);82} else {83/* we don't know how to set it back again.. */84/* Actually we do - there is a data sheet available for the85Winbond but does anyone actually care */86}87}8889static const struct ide_port_ops dtc2278_port_ops = {90.set_pio_mode = dtc2278_set_pio_mode,91};9293static const struct ide_port_info dtc2278_port_info __initdata = {94.name = DRV_NAME,95.chipset = ide_dtc2278,96.port_ops = &dtc2278_port_ops,97.host_flags = IDE_HFLAG_SERIALIZE |98IDE_HFLAG_NO_UNMASK_IRQS |99IDE_HFLAG_IO_32BIT |100/* disallow ->io_32bit changes */101IDE_HFLAG_NO_IO_32BIT |102IDE_HFLAG_NO_DMA |103IDE_HFLAG_DTC2278,104.pio_mask = ATA_PIO4,105};106107static int __init dtc2278_probe(void)108{109unsigned long flags;110111local_irq_save(flags);112/*113* This enables the second interface114*/115outb_p(4,0xb0);116inb(0x3f6);117outb_p(0x20,0xb4);118inb(0x3f6);119#ifdef ALWAYS_SET_DTC2278_PIO_MODE120/*121* This enables PIO mode4 (3?) on the first interface122* and may solve start-up problems for some people.123*/124sub22(1,0xc3);125sub22(0,0xa0);126#endif127local_irq_restore(flags);128129return ide_legacy_device_add(&dtc2278_port_info, 0);130}131132static int probe_dtc2278;133134module_param_named(probe, probe_dtc2278, bool, 0);135MODULE_PARM_DESC(probe, "probe for DTC2278xx chipsets");136137static int __init dtc2278_init(void)138{139if (probe_dtc2278 == 0)140return -ENODEV;141142if (dtc2278_probe()) {143printk(KERN_ERR "dtc2278: ide interfaces already in use!\n");144return -EBUSY;145}146return 0;147}148149module_init(dtc2278_init);150151MODULE_AUTHOR("See Local File");152MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets");153MODULE_LICENSE("GPL");154155156