Blame view

drivers/ide/serverworks.c 12.6 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
   * Copyright (C) 1998-2000 Michel Aubry
   * Copyright (C) 1998-2000 Andrzej Krzysztofowicz
   * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
e7593af6e   Bartlomiej Zolnierkiewicz   serverworks: clea...
5
   * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
   * Portions copyright (c) 2001 Sun Microsystems
   *
   *
   * RCC/ServerWorks IDE driver for Linux
   *
   *   OSB4: `Open South Bridge' IDE Interface (fn 1)
   *         supports UDMA mode 2 (33 MB/s)
   *
   *   CSB5: `Champion South Bridge' IDE Interface (fn 1)
   *         all revisions support UDMA mode 4 (66 MB/s)
   *         revision A2.0 and up support UDMA mode 5 (100 MB/s)
   *
   *         *** The CSB5 does not provide ANY register ***
   *         *** to detect 80-conductor cable presence. ***
   *
   *   CSB6: `Champion South Bridge' IDE Interface (optional: third channel)
   *
84f57fbc7   Narendra Sankar   [PATCH] serverwor...
23
24
25
   *   HT1000: AKA BCM5785 - Hypertransport Southbridge for Opteron systems. IDE
   *   controller same as the CSB6. Single channel ATA100 only.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
   * Documentation:
   *	Available under NDA only. Errata info very hard to get.
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
31
32
  #include <linux/types.h>
  #include <linux/module.h>
  #include <linux/kernel.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
  #include <linux/pci.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
  #include <linux/ide.h>
  #include <linux/init.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
  
  #include <asm/io.h>
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
38
  #define DRV_NAME "serverworks"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
40
41
42
43
44
45
46
47
48
49
50
  #define SVWKS_CSB5_REVISION_NEW	0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */
  #define SVWKS_CSB6_REVISION	0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */
  
  /* Seagate Barracuda ATA IV Family drives in UDMA mode 5
   * can overrun their FIFOs when used with the CSB5 */
  static const char *svwks_bad_ata100[] = {
  	"ST320011A",
  	"ST340016A",
  	"ST360021A",
  	"ST380021A",
  	NULL
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
52
  static int check_in_drive_lists (ide_drive_t *drive, const char **list)
  {
4dde4492d   Bartlomiej Zolnierkiewicz   ide: make drive->...
53
  	char *m = (char *)&drive->id[ATA_ID_PROD];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
  	while (*list)
4dde4492d   Bartlomiej Zolnierkiewicz   ide: make drive->...
55
  		if (!strcmp(*list++, m))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
57
58
  			return 1;
  	return 0;
  }
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
59
  static u8 svwks_udma_filter(ide_drive_t *drive)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60
  {
36501650e   Bartlomiej Zolnierkiewicz   ide: keep pointer...
61
  	struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62

e7593af6e   Bartlomiej Zolnierkiewicz   serverworks: clea...
63
  	if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) {
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
64
  		return 0x1f;
44c10138f   Auke Kok   PCI: Change all d...
65
  	} else if (dev->revision < SVWKS_CSB5_REVISION_NEW) {
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
66
  		return 0x07;
e7593af6e   Bartlomiej Zolnierkiewicz   serverworks: clea...
67
68
  	} else {
  		u8 btr = 0, mode, mask;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
70
  		pci_read_config_byte(dev, 0x5A, &btr);
  		mode = btr & 0x3;
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
71

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
75
  		/* If someone decides to do UDMA133 on CSB5 the same
  		   issue will bite so be inclusive */
  		if (mode > 2 && check_in_drive_lists(drive, svwks_bad_ata100))
  			mode = 2;
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
76
77
  
  		switch(mode) {
0c824b51b   Tony Battersby   ide: fix serverwo...
78
  		case 3:	 mask = 0x3f; break;
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
79
80
81
82
  		case 2:	 mask = 0x1f; break;
  		case 1:	 mask = 0x07; break;
  		default: mask = 0x00; break;
  		}
2d5eaa6dd   Bartlomiej Zolnierkiewicz   ide: rework the c...
83

e7593af6e   Bartlomiej Zolnierkiewicz   serverworks: clea...
84
85
  		return mask;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
88
89
90
91
92
93
  }
  
  static u8 svwks_csb_check (struct pci_dev *dev)
  {
  	switch (dev->device) {
  		case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
  		case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
  		case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
84f57fbc7   Narendra Sankar   [PATCH] serverwor...
94
  		case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
98
99
100
  			return 1;
  		default:
  			break;
  	}
  	return 0;
  }
1880a8d7f   Bartlomiej Zolnierkiewicz   serverworks: alwa...
101

e085b3cae   Bartlomiej Zolnierkiewicz   ide: change ->set...
102
  static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
1880a8d7f   Bartlomiej Zolnierkiewicz   serverworks: alwa...
103
104
105
  {
  	static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
  	static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 };
e085b3cae   Bartlomiej Zolnierkiewicz   ide: change ->set...
106
107
  	struct pci_dev *dev = to_pci_dev(hwif->dev);
  	const u8 pio = drive->pio_mode - XFER_PIO_0;
1880a8d7f   Bartlomiej Zolnierkiewicz   serverworks: alwa...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  
  	pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]);
  
  	if (svwks_csb_check(dev)) {
  		u16 csb_pio = 0;
  
  		pci_read_config_word(dev, 0x4a, &csb_pio);
  
  		csb_pio &= ~(0x0f << (4 * drive->dn));
  		csb_pio |= (pio << (4 * drive->dn));
  
  		pci_write_config_word(dev, 0x4a, csb_pio);
  	}
  }
8776168ca   Bartlomiej Zolnierkiewicz   ide: change ->set...
122
  static void svwks_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123
  {
f201f5046   Alan Cox   [PATCH] ide: hous...
124
125
  	static const u8 udma_modes[]		= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
  	static const u8 dma_modes[]		= { 0x77, 0x21, 0x20 };
f201f5046   Alan Cox   [PATCH] ide: hous...
126
  	static const u8 drive_pci2[]		= { 0x45, 0x44, 0x47, 0x46 };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127

36501650e   Bartlomiej Zolnierkiewicz   ide: keep pointer...
128
  	struct pci_dev *dev	= to_pci_dev(hwif->dev);
8776168ca   Bartlomiej Zolnierkiewicz   ide: change ->set...
129
  	const u8 speed		= drive->dma_mode;
123995b97   Bartlomiej Zolnierkiewicz   ide: use 'drive->...
130
  	u8 unit			= drive->dn & 1;
1880a8d7f   Bartlomiej Zolnierkiewicz   serverworks: alwa...
131
132
  
  	u8 ultra_enable	 = 0, ultra_timing = 0, dma_timing = 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
133
  	pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
  	pci_read_config_byte(dev, 0x54, &ultra_enable);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
136
  	ultra_timing	&= ~(0x0F << (4*unit));
  	ultra_enable	&= ~(0x01 << drive->dn);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
137

7b971df18   Bartlomiej Zolnierkiewicz   serverworks: clea...
138
139
140
141
142
143
  	if (speed >= XFER_UDMA_0) {
  		dma_timing   |= dma_modes[2];
  		ultra_timing |= (udma_modes[speed - XFER_UDMA_0] << (4 * unit));
  		ultra_enable |= (0x01 << drive->dn);
  	} else if (speed >= XFER_MW_DMA_0)
  		dma_timing   |= dma_modes[speed - XFER_MW_DMA_0];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
145
146
147
  	pci_write_config_byte(dev, drive_pci2[drive->dn], dma_timing);
  	pci_write_config_byte(dev, (0x56|hwif->channel), ultra_timing);
  	pci_write_config_byte(dev, 0x54, ultra_enable);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148
  }
2ed0ef543   Bartlomiej Zolnierkiewicz   ide: fix ->init_c...
149
  static int init_chipset_svwks(struct pci_dev *dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
150
151
152
  {
  	unsigned int reg;
  	u8 btr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
153
154
155
156
157
  	/* force Master Latency Timer value to 64 PCICLKs */
  	pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);
  
  	/* OSB4 : South Bridge and IDE */
  	if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
e7593af6e   Bartlomiej Zolnierkiewicz   serverworks: clea...
158
159
160
  		struct pci_dev *isa_dev =
  			pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
  					PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
161
162
163
164
  		if (isa_dev) {
  			pci_read_config_dword(isa_dev, 0x64, &reg);
  			reg &= ~0x00002000; /* disable 600ns interrupt mask */
  			if(!(reg & 0x00004000))
a326b02b0   Bartlomiej Zolnierkiewicz   ide: drop 'name' ...
165
166
167
  				printk(KERN_DEBUG DRV_NAME " %s: UDMA not BIOS "
  					"enabled.
  ", pci_name(dev));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168
169
  			reg |=  0x00004000; /* enable UDMA/33 support */
  			pci_write_config_dword(isa_dev, 0x64, reg);
cb06fc3f4   Bartlomiej Zolnierkiewicz   serverworks: add ...
170
  			pci_dev_put(isa_dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
171
172
173
174
175
176
177
178
179
180
181
182
  		}
  	}
  
  	/* setup CSB5/CSB6 : South Bridge and IDE option RAID */
  	else if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
  		 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
  		 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {
  
  		/* Third Channel Test */
  		if (!(PCI_FUNC(dev->devfn) & 1)) {
  			struct pci_dev * findev = NULL;
  			u32 reg4c = 0;
970a61363   Alan Cox   [PATCH] serverwor...
183
  			findev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
185
186
187
188
189
190
  				PCI_DEVICE_ID_SERVERWORKS_CSB5, NULL);
  			if (findev) {
  				pci_read_config_dword(findev, 0x4C, &reg4c);
  				reg4c &= ~0x000007FF;
  				reg4c |=  0x00000040;
  				reg4c |=  0x00000020;
  				pci_write_config_dword(findev, 0x4C, reg4c);
970a61363   Alan Cox   [PATCH] serverwor...
191
  				pci_dev_put(findev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
192
193
194
  			}
  			outb_p(0x06, 0x0c00);
  			dev->irq = inb_p(0x0c01);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
195
196
197
  		} else {
  			struct pci_dev * findev = NULL;
  			u8 reg41 = 0;
970a61363   Alan Cox   [PATCH] serverwor...
198
  			findev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
199
200
201
202
203
  					PCI_DEVICE_ID_SERVERWORKS_CSB6, NULL);
  			if (findev) {
  				pci_read_config_byte(findev, 0x41, &reg41);
  				reg41 &= ~0x40;
  				pci_write_config_byte(findev, 0x41, reg41);
970a61363   Alan Cox   [PATCH] serverwor...
204
  				pci_dev_put(findev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
  			}
  			/*
  			 * This is a device pin issue on CSB6.
  			 * Since there will be a future raid mode,
  			 * early versions of the chipset require the
  			 * interrupt pin to be set, and it is a compatibility
  			 * mode issue.
  			 */
  			if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE)
  				dev->irq = 0;
  		}
  //		pci_read_config_dword(dev, 0x40, &pioreg)
  //		pci_write_config_dword(dev, 0x40, 0x99999999);
  //		pci_read_config_dword(dev, 0x44, &dmareg);
  //		pci_write_config_dword(dev, 0x44, 0xFFFFFFFF);
  		/* setup the UDMA Control register
  		 *
  		 * 1. clear bit 6 to enable DMA
  		 * 2. enable DMA modes with bits 0-1
  		 * 	00 : legacy
  		 * 	01 : udma2
  		 * 	10 : udma2/udma4
  		 * 	11 : udma2/udma4/udma5
  		 */
  		pci_read_config_byte(dev, 0x5A, &btr);
  		btr &= ~0x40;
  		if (!(PCI_FUNC(dev->devfn) & 1))
  			btr |= 0x2;
  		else
44c10138f   Auke Kok   PCI: Change all d...
234
  			btr |= (dev->revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
235
236
  		pci_write_config_byte(dev, 0x5A, btr);
  	}
84f57fbc7   Narendra Sankar   [PATCH] serverwor...
237
238
239
240
241
242
243
  	/* Setup HT1000 SouthBridge Controller - Single Channel Only */
  	else if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) {
  		pci_read_config_byte(dev, 0x5A, &btr);
  		btr &= ~0x40;
  		btr |= 0x3;
  		pci_write_config_byte(dev, 0x5A, btr);
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
244

2ed0ef543   Bartlomiej Zolnierkiewicz   ide: fix ->init_c...
245
  	return 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246
  }
f454cbe8c   Bartlomiej Zolnierkiewicz   ide: ->cable_dete...
247
  static u8 ata66_svwks_svwks(ide_hwif_t *hwif)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248
  {
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
249
  	return ATA_CBL_PATA80;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
250
251
252
253
254
255
256
257
258
  }
  
  /* On Dell PowerEdge servers with a CSB5/CSB6, the top two bits
   * of the subsystem device ID indicate presence of an 80-pin cable.
   * Bit 15 clear = secondary IDE channel does not have 80-pin cable.
   * Bit 15 set   = secondary IDE channel has 80-pin cable.
   * Bit 14 clear = primary IDE channel does not have 80-pin cable.
   * Bit 14 set   = primary IDE channel has 80-pin cable.
   */
f454cbe8c   Bartlomiej Zolnierkiewicz   ide: ->cable_dete...
259
  static u8 ata66_svwks_dell(ide_hwif_t *hwif)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
260
  {
36501650e   Bartlomiej Zolnierkiewicz   ide: keep pointer...
261
  	struct pci_dev *dev = to_pci_dev(hwif->dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
262
263
264
265
266
  	if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL &&
  	    dev->vendor	== PCI_VENDOR_ID_SERVERWORKS &&
  	    (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ||
  	     dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE))
  		return ((1 << (hwif->channel + 14)) &
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
267
268
  			dev->subsystem_device) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
  	return ATA_CBL_PATA40;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
269
270
271
272
273
274
275
276
  }
  
  /* Sun Cobalt Alpine hardware avoids the 80-pin cable
   * detect issue by attaching the drives directly to the board.
   * This check follows the Dell precedent (how scary is that?!)
   *
   * WARNING: this only works on Alpine hardware!
   */
f454cbe8c   Bartlomiej Zolnierkiewicz   ide: ->cable_dete...
277
  static u8 ata66_svwks_cobalt(ide_hwif_t *hwif)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
278
  {
36501650e   Bartlomiej Zolnierkiewicz   ide: keep pointer...
279
  	struct pci_dev *dev = to_pci_dev(hwif->dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
280
281
282
283
  	if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN &&
  	    dev->vendor	== PCI_VENDOR_ID_SERVERWORKS &&
  	    dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
  		return ((1 << (hwif->channel + 14)) &
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
284
285
  			dev->subsystem_device) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
  	return ATA_CBL_PATA40;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
286
  }
f454cbe8c   Bartlomiej Zolnierkiewicz   ide: ->cable_dete...
287
  static u8 svwks_cable_detect(ide_hwif_t *hwif)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
288
  {
36501650e   Bartlomiej Zolnierkiewicz   ide: keep pointer...
289
  	struct pci_dev *dev = to_pci_dev(hwif->dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
290

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
291
292
293
294
295
296
297
298
299
300
301
  	/* Server Works */
  	if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS)
  		return ata66_svwks_svwks (hwif);
  	
  	/* Dell PowerEdge */
  	if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL)
  		return ata66_svwks_dell (hwif);
  
  	/* Cobalt Alpine */
  	if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN)
  		return ata66_svwks_cobalt (hwif);
f201f5046   Alan Cox   [PATCH] ide: hous...
302
303
304
  	/* Per Specified Design by OEM, and ASIC Architect */
  	if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
  	    (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
305
  		return ATA_CBL_PATA80;
f201f5046   Alan Cox   [PATCH] ide: hous...
306

49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
307
  	return ATA_CBL_PATA40;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
308
  }
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
309
310
311
  static const struct ide_port_ops osb4_port_ops = {
  	.set_pio_mode		= svwks_set_pio_mode,
  	.set_dma_mode		= svwks_set_dma_mode,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
312
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
313

ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
314
315
316
317
318
319
  static const struct ide_port_ops svwks_port_ops = {
  	.set_pio_mode		= svwks_set_pio_mode,
  	.set_dma_mode		= svwks_set_dma_mode,
  	.udma_filter		= svwks_udma_filter,
  	.cable_detect		= svwks_cable_detect,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
320

856204360   Bartlomiej Zolnierkiewicz   ide: constify str...
321
  static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
322
323
  	{	/* 0: OSB4 */
  		.name		= DRV_NAME,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
324
  		.init_chipset	= init_chipset_svwks,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
325
  		.port_ops	= &osb4_port_ops,
4099d1432   Bartlomiej Zolnierkiewicz   ide: add PIO masks
326
  		.pio_mask	= ATA_PIO4,
5f8b6c348   Bartlomiej Zolnierkiewicz   ide: add ->mwdma_...
327
328
  		.mwdma_mask	= ATA_MWDMA2,
  		.udma_mask	= 0x00, /* UDMA is problematic on OSB4 */
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
329
330
331
  	},
  	{	/* 1: CSB5 */
  		.name		= DRV_NAME,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
332
  		.init_chipset	= init_chipset_svwks,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
333
  		.port_ops	= &svwks_port_ops,
4099d1432   Bartlomiej Zolnierkiewicz   ide: add PIO masks
334
  		.pio_mask	= ATA_PIO4,
5f8b6c348   Bartlomiej Zolnierkiewicz   ide: add ->mwdma_...
335
336
  		.mwdma_mask	= ATA_MWDMA2,
  		.udma_mask	= ATA_UDMA5,
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
337
338
339
  	},
  	{	/* 2: CSB6 */
  		.name		= DRV_NAME,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
340
  		.init_chipset	= init_chipset_svwks,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
341
  		.port_ops	= &svwks_port_ops,
4099d1432   Bartlomiej Zolnierkiewicz   ide: add PIO masks
342
  		.pio_mask	= ATA_PIO4,
5f8b6c348   Bartlomiej Zolnierkiewicz   ide: add ->mwdma_...
343
344
  		.mwdma_mask	= ATA_MWDMA2,
  		.udma_mask	= ATA_UDMA5,
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
345
346
347
  	},
  	{	/* 3: CSB6-2 */
  		.name		= DRV_NAME,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
348
  		.init_chipset	= init_chipset_svwks,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
349
  		.port_ops	= &svwks_port_ops,
2467922a5   Bartlomiej Zolnierkiewicz   ide: remove no lo...
350
  		.host_flags	= IDE_HFLAG_SINGLE,
4099d1432   Bartlomiej Zolnierkiewicz   ide: add PIO masks
351
  		.pio_mask	= ATA_PIO4,
5f8b6c348   Bartlomiej Zolnierkiewicz   ide: add ->mwdma_...
352
353
  		.mwdma_mask	= ATA_MWDMA2,
  		.udma_mask	= ATA_UDMA5,
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
354
355
356
  	},
  	{	/* 4: HT1000 */
  		.name		= DRV_NAME,
84f57fbc7   Narendra Sankar   [PATCH] serverwor...
357
  		.init_chipset	= init_chipset_svwks,
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
358
  		.port_ops	= &svwks_port_ops,
2467922a5   Bartlomiej Zolnierkiewicz   ide: remove no lo...
359
  		.host_flags	= IDE_HFLAG_SINGLE,
4099d1432   Bartlomiej Zolnierkiewicz   ide: add PIO masks
360
  		.pio_mask	= ATA_PIO4,
5f8b6c348   Bartlomiej Zolnierkiewicz   ide: add ->mwdma_...
361
362
  		.mwdma_mask	= ATA_MWDMA2,
  		.udma_mask	= ATA_UDMA5,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
363
364
365
366
367
368
369
370
371
372
373
374
375
376
  	}
  };
  
  /**
   *	svwks_init_one	-	called when a OSB/CSB is found
   *	@dev: the svwks device
   *	@id: the matching pci id
   *
   *	Called when the PCI registration layer (or the IDE initialization)
   *	finds a device matching our IDE device tables.
   */
   
  static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device_id *id)
  {
039788e15   Bartlomiej Zolnierkiewicz   ide: replace ide_...
377
  	struct ide_port_info d;
7ed582975   Bartlomiej Zolnierkiewicz   serverworks: remo...
378
379
380
  	u8 idx = id->driver_data;
  
  	d = serverworks_chipsets[idx];
8ac2b42a4   Bartlomiej Zolnierkiewicz   ide: add IDE_HFLA...
381
382
383
  	if (idx == 1)
  		d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
  	else if (idx == 2 || idx == 3) {
7ed582975   Bartlomiej Zolnierkiewicz   serverworks: remo...
384
385
  		if ((PCI_FUNC(dev->devfn) & 1) == 0) {
  			if (pci_resource_start(dev, 0) != 0x01f1)
5e71d9c5a   Bartlomiej Zolnierkiewicz   ide: IDE_HFLAG_BO...
386
  				d.host_flags |= IDE_HFLAG_NON_BOOTABLE;
7ed582975   Bartlomiej Zolnierkiewicz   serverworks: remo...
387
388
389
390
  			d.host_flags |= IDE_HFLAG_SINGLE;
  		} else
  			d.host_flags &= ~IDE_HFLAG_SINGLE;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
391

6cdf6eb35   Bartlomiej Zolnierkiewicz   ide: add ->dev an...
392
  	return ide_pci_init_one(dev, &d, NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
393
  }
9cbcc5e3c   Bartlomiej Zolnierkiewicz   ide: use PCI_VDEV...
394
395
396
397
398
399
  static const struct pci_device_id svwks_pci_tbl[] = {
  	{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE),   0 },
  	{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE),   1 },
  	{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE),   2 },
  	{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2),  3 },
  	{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE), 4 },
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
400
401
402
  	{ 0, },
  };
  MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
a9ab09e26   Bartlomiej Zolnierkiewicz   ide: use unique n...
403
  static struct pci_driver svwks_pci_driver = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
404
405
406
  	.name		= "Serverworks_IDE",
  	.id_table	= svwks_pci_tbl,
  	.probe		= svwks_init_one,
bc2c9a802   Bartlomiej Zolnierkiewicz   serverworks: add ...
407
  	.remove		= ide_pci_remove,
feb22b7f8   Bartlomiej Zolnierkiewicz   ide: add proper P...
408
409
  	.suspend	= ide_pci_suspend,
  	.resume		= ide_pci_resume,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
410
  };
82ab1eece   Bartlomiej Zolnierkiewicz   ide: add missing ...
411
  static int __init svwks_ide_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
412
  {
a9ab09e26   Bartlomiej Zolnierkiewicz   ide: use unique n...
413
  	return ide_pci_register_driver(&svwks_pci_driver);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
414
  }
bc2c9a802   Bartlomiej Zolnierkiewicz   serverworks: add ...
415
416
  static void __exit svwks_ide_exit(void)
  {
a9ab09e26   Bartlomiej Zolnierkiewicz   ide: use unique n...
417
  	pci_unregister_driver(&svwks_pci_driver);
bc2c9a802   Bartlomiej Zolnierkiewicz   serverworks: add ...
418
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
419
  module_init(svwks_ide_init);
bc2c9a802   Bartlomiej Zolnierkiewicz   serverworks: add ...
420
  module_exit(svwks_ide_exit);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
421

e7593af6e   Bartlomiej Zolnierkiewicz   serverworks: clea...
422
  MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick, Bartlomiej Zolnierkiewicz");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
423
424
  MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE");
  MODULE_LICENSE("GPL");