Blame view

drivers/ide/dtc2278.c 3.8 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
   *  Copyright (C) 1996  Linus Torvalds & author (see below)
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
  #include <linux/module.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
8
9
10
11
  #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>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
14
15
  #include <linux/ide.h>
  #include <linux/init.h>
  
  #include <asm/io.h>
d92f1a282   Bartlomiej Zolnierkiewicz   ide: manage I/O r...
16
  #define DRV_NAME "dtc2278"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  /*
   * Changing this #undef to #define may solve start up problems in some systems.
   */
  #undef ALWAYS_SET_DTC2278_PIO_MODE
  
  /*
   * From: andy@cercle.cts.com (Dyan Wile)
   *
   * Below is a patch for DTC-2278 - alike software-programmable controllers
   * The code enables the secondary IDE controller and the PIO4 (3?) timings on
   * the primary (EIDE). You may probably have to enable the 32-bit support to
   * get the full speed. You better get the disk interrupts disabled ( hdparm -u0
   * /dev/hd.. ) for the drives connected to the EIDE interface. (I get my
   * filesystem  corrupted with -u1, but under heavy disk load only :-)
   *
   * This card is now forced to use the "serialize" feature,
   * and irq-unmasking is disallowed.  If io_32bit is enabled,
   * it must be done for BOTH drives on each interface.
   *
   * This code was written for the DTC2278E, but might work with any of these:
   *
   * DTC2278S has only a single IDE interface.
   * DTC2278D has two IDE interfaces and is otherwise identical to the S version.
   * DTC2278E also has serial ports and a printer port
   * DTC2278EB: has onboard BIOS, and "works like a charm" -- Kent Bradford <kent@theory.caltech.edu>
   *
   * There may be a fourth controller type. The S and D versions use the
   * Winbond chip, and I think the E version does also.
   *
   */
  
  static void sub22 (char b, char c)
  {
  	int i;
  
  	for(i = 0; i < 3; ++i) {
  		inb(0x3f6);
  		outb_p(b,0xb0);
  		inb(0x3f6);
  		outb_p(c,0xb4);
  		inb(0x3f6);
  		if(inb(0xb4) == c) {
  			outb_p(7,0xb0);
  			inb(0x3f6);
  			return;	/* success */
  		}
  	}
  }
a34a8751f   Bartlomiej Zolnierkiewicz   dtc2278: fix dead...
65
  static DEFINE_SPINLOCK(dtc2278_lock);
e085b3cae   Bartlomiej Zolnierkiewicz   ide: change ->set...
66
  static void dtc2278_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
  {
  	unsigned long flags;
e085b3cae   Bartlomiej Zolnierkiewicz   ide: change ->set...
69
  	if (drive->pio_mode >= XFER_PIO_3) {
a34a8751f   Bartlomiej Zolnierkiewicz   dtc2278: fix dead...
70
  		spin_lock_irqsave(&dtc2278_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
73
74
75
  		/*
  		 * This enables PIO mode4 (3?) on the first interface
  		 */
  		sub22(1,0xc3);
  		sub22(0,0xa0);
a34a8751f   Bartlomiej Zolnierkiewicz   dtc2278: fix dead...
76
  		spin_unlock_irqrestore(&dtc2278_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
  	} else {
  		/* we don't know how to set it back again.. */
d3bad45f0   Alan Cox   dtc2278: note on ...
79
80
  		/* Actually we do - there is a data sheet available for the
  		   Winbond but does anyone actually care */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
  }
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
83
84
85
  static const struct ide_port_ops dtc2278_port_ops = {
  	.set_pio_mode		= dtc2278_set_pio_mode,
  };
e6b53703b   Andi Kleen   sections: fix sec...
86
  static const struct ide_port_info dtc2278_port_info __initconst = {
d92f1a282   Bartlomiej Zolnierkiewicz   ide: manage I/O r...
87
  	.name			= DRV_NAME,
c413b9b94   Bartlomiej Zolnierkiewicz   ide: add struct i...
88
  	.chipset		= ide_dtc2278,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
89
  	.port_ops		= &dtc2278_port_ops,
c413b9b94   Bartlomiej Zolnierkiewicz   ide: add struct i...
90
  	.host_flags		= IDE_HFLAG_SERIALIZE |
807b90d0b   Bartlomiej Zolnierkiewicz   ide: add IDE_HFLA...
91
  				  IDE_HFLAG_NO_UNMASK_IRQS |
c413b9b94   Bartlomiej Zolnierkiewicz   ide: add struct i...
92
  				  IDE_HFLAG_IO_32BIT |
807b90d0b   Bartlomiej Zolnierkiewicz   ide: add IDE_HFLA...
93
94
  				  /* disallow ->io_32bit changes */
  				  IDE_HFLAG_NO_IO_32BIT |
2787cb8ae   Bartlomiej Zolnierkiewicz   ide: add IDE_HFLA...
95
96
  				  IDE_HFLAG_NO_DMA |
  				  IDE_HFLAG_DTC2278,
c413b9b94   Bartlomiej Zolnierkiewicz   ide: add struct i...
97
98
  	.pio_mask		= ATA_PIO4,
  };
849138827   Bartlomiej Zolnierkiewicz   ide: make legacy ...
99
  static int __init dtc2278_probe(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
  {
  	unsigned long flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  	local_irq_save(flags);
  	/*
  	 * This enables the second interface
  	 */
  	outb_p(4,0xb0);
  	inb(0x3f6);
  	outb_p(0x20,0xb4);
  	inb(0x3f6);
  #ifdef ALWAYS_SET_DTC2278_PIO_MODE
  	/*
  	 * This enables PIO mode4 (3?) on the first interface
  	 * and may solve start-up problems for some people.
  	 */
  	sub22(1,0xc3);
  	sub22(0,0xa0);
  #endif
  	local_irq_restore(flags);
0bfeee7d4   Bartlomiej Zolnierkiewicz   ide: use ide_lega...
120
  	return ide_legacy_device_add(&dtc2278_port_info, 0);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121
  }
90ab5ee94   Rusty Russell   module_param: mak...
122
  static bool probe_dtc2278;
849138827   Bartlomiej Zolnierkiewicz   ide: make legacy ...
123
124
125
  
  module_param_named(probe, probe_dtc2278, bool, 0);
  MODULE_PARM_DESC(probe, "probe for DTC2278xx chipsets");
ade2daf9c   Bartlomiej Zolnierkiewicz   ide: make remaini...
126
  static int __init dtc2278_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
  {
849138827   Bartlomiej Zolnierkiewicz   ide: make legacy ...
128
129
130
131
  	if (probe_dtc2278 == 0)
  		return -ENODEV;
  
  	if (dtc2278_probe()) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
133
134
135
136
137
  		printk(KERN_ERR "dtc2278: ide interfaces already in use!
  ");
  		return -EBUSY;
  	}
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
  module_init(dtc2278_init);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
140
141
142
  
  MODULE_AUTHOR("See Local File");
  MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets");
  MODULE_LICENSE("GPL");