1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
65
66
67
68
69
70
71
72#include <linux/kernel.h>
73#include <linux/module.h>
74#include <linux/pci.h>
75#include <linux/init.h>
76#include <linux/blkdev.h>
77#include <linux/delay.h>
78#include <linux/slab.h>
79#include <scsi/scsi_host.h>
80#include <linux/libata.h>
81
82
83#define DRV_NAME "pata_it821x"
84#define DRV_VERSION "0.4.2"
85
86struct it821x_dev
87{
88 unsigned int smart:1,
89 timing10:1;
90 u8 clock_mode;
91 u8 want[2][2];
92
93
94 u16 pio[2];
95 u16 mwdma[2];
96 u16 udma[2];
97 u16 last_device;
98};
99
100#define ATA_66 0
101#define ATA_50 1
102#define ATA_ANY 2
103
104#define UDMA_OFF 0
105#define MWDMA_OFF 0
106
107
108
109
110
111
112
113
114static int it8212_noraid;
115
116
117
118
119
120
121
122
123
124
125
126
127static void it821x_program(struct ata_port *ap, struct ata_device *adev, u16 timing)
128{
129 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
130 struct it821x_dev *itdev = ap->private_data;
131 int channel = ap->port_no;
132 u8 conf;
133
134
135 if (itdev->clock_mode == ATA_66)
136 conf = timing >> 8;
137 else
138 conf = timing & 0xFF;
139 pci_write_config_byte(pdev, 0x54 + 4 * channel, conf);
140}
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155static void it821x_program_udma(struct ata_port *ap, struct ata_device *adev, u16 timing)
156{
157 struct it821x_dev *itdev = ap->private_data;
158 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
159 int channel = ap->port_no;
160 int unit = adev->devno;
161 u8 conf;
162
163
164 if (itdev->clock_mode == ATA_66)
165 conf = timing >> 8;
166 else
167 conf = timing & 0xFF;
168 if (itdev->timing10 == 0)
169 pci_write_config_byte(pdev, 0x56 + 4 * channel + unit, conf);
170 else {
171
172 pci_write_config_byte(pdev, 0x56 + 4 * channel, conf);
173 pci_write_config_byte(pdev, 0x56 + 4 * channel + 1, conf);
174 }
175}
176
177
178
179
180
181
182
183
184
185
186static void it821x_clock_strategy(struct ata_port *ap, struct ata_device *adev)
187{
188 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
189 struct it821x_dev *itdev = ap->private_data;
190 u8 unit = adev->devno;
191 struct ata_device *pair = ata_dev_pair(adev);
192
193 int clock, altclock;
194 u8 v;
195 int sel = 0;
196
197
198 if (itdev->want[0][0] > itdev->want[1][0]) {
199 clock = itdev->want[0][1];
200 altclock = itdev->want[1][1];
201 } else {
202 clock = itdev->want[1][1];
203 altclock = itdev->want[0][1];
204 }
205
206
207 if (clock == ATA_ANY)
208 clock = altclock;
209
210
211 if (clock == ATA_ANY)
212 return;
213
214 if (clock == itdev->clock_mode)
215 return;
216
217
218 if (clock == ATA_66)
219 itdev->clock_mode = ATA_66;
220 else {
221 itdev->clock_mode = ATA_50;
222 sel = 1;
223 }
224 pci_read_config_byte(pdev, 0x50, &v);
225 v &= ~(1 << (1 + ap->port_no));
226 v |= sel << (1 + ap->port_no);
227 pci_write_config_byte(pdev, 0x50, v);
228
229
230
231
232
233 if (pair && itdev->udma[1-unit] != UDMA_OFF) {
234 it821x_program_udma(ap, pair, itdev->udma[1-unit]);
235 it821x_program(ap, pair, itdev->pio[1-unit]);
236 }
237
238
239
240
241 if (itdev->udma[unit] != UDMA_OFF) {
242 it821x_program_udma(ap, adev, itdev->udma[unit]);
243 it821x_program(ap, adev, itdev->pio[unit]);
244 }
245}
246
247
248
249
250
251
252
253
254
255
256static void it821x_passthru_set_piomode(struct ata_port *ap, struct ata_device *adev)
257{
258
259 static const u16 pio[] = { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
260 static const u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
261
262 struct it821x_dev *itdev = ap->private_data;
263 int unit = adev->devno;
264 int mode_wanted = adev->pio_mode - XFER_PIO_0;
265
266
267 itdev->want[unit][1] = pio_want[mode_wanted];
268 itdev->want[unit][0] = 1;
269 itdev->pio[unit] = pio[mode_wanted];
270 it821x_clock_strategy(ap, adev);
271 it821x_program(ap, adev, itdev->pio[unit]);
272}
273
274
275
276
277
278
279
280
281
282
283
284
285
286static void it821x_passthru_set_dmamode(struct ata_port *ap, struct ata_device *adev)
287{
288 static const u16 dma[] = { 0x8866, 0x3222, 0x3121 };
289 static const u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY };
290 static const u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 };
291 static const u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 };
292
293 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
294 struct it821x_dev *itdev = ap->private_data;
295 int channel = ap->port_no;
296 int unit = adev->devno;
297 u8 conf;
298
299 if (adev->dma_mode >= XFER_UDMA_0) {
300 int mode_wanted = adev->dma_mode - XFER_UDMA_0;
301
302 itdev->want[unit][1] = udma_want[mode_wanted];
303 itdev->want[unit][0] = 3;
304 itdev->mwdma[unit] = MWDMA_OFF;
305 itdev->udma[unit] = udma[mode_wanted];
306 if (mode_wanted >= 5)
307 itdev->udma[unit] |= 0x8080;
308
309
310 pci_read_config_byte(pdev, 0x50, &conf);
311 if (itdev->timing10)
312 conf &= channel ? 0x9F: 0xE7;
313 else
314 conf &= ~ (1 << (3 + 2 * channel + unit));
315 pci_write_config_byte(pdev, 0x50, conf);
316 it821x_clock_strategy(ap, adev);
317 it821x_program_udma(ap, adev, itdev->udma[unit]);
318 } else {
319 int mode_wanted = adev->dma_mode - XFER_MW_DMA_0;
320
321 itdev->want[unit][1] = mwdma_want[mode_wanted];
322 itdev->want[unit][0] = 2;
323 itdev->mwdma[unit] = dma[mode_wanted];
324 itdev->udma[unit] = UDMA_OFF;
325
326
327 pci_read_config_byte(pdev, 0x50, &conf);
328 if (itdev->timing10)
329 conf |= channel ? 0x60: 0x18;
330 else
331 conf |= 1 << (3 + 2 * channel + unit);
332 pci_write_config_byte(pdev, 0x50, conf);
333 it821x_clock_strategy(ap, adev);
334 }
335}
336
337
338
339
340
341
342
343
344
345
346static void it821x_passthru_bmdma_start(struct ata_queued_cmd *qc)
347{
348 struct ata_port *ap = qc->ap;
349 struct ata_device *adev = qc->dev;
350 struct it821x_dev *itdev = ap->private_data;
351 int unit = adev->devno;
352
353 if (itdev->mwdma[unit] != MWDMA_OFF)
354 it821x_program(ap, adev, itdev->mwdma[unit]);
355 else if (itdev->udma[unit] != UDMA_OFF && itdev->timing10)
356 it821x_program_udma(ap, adev, itdev->udma[unit]);
357 ata_bmdma_start(qc);
358}
359
360
361
362
363
364
365
366
367
368
369static void it821x_passthru_bmdma_stop(struct ata_queued_cmd *qc)
370{
371 struct ata_port *ap = qc->ap;
372 struct ata_device *adev = qc->dev;
373 struct it821x_dev *itdev = ap->private_data;
374 int unit = adev->devno;
375
376 ata_bmdma_stop(qc);
377 if (itdev->mwdma[unit] != MWDMA_OFF)
378 it821x_program(ap, adev, itdev->pio[unit]);
379}
380
381
382
383
384
385
386
387
388
389
390static void it821x_passthru_dev_select(struct ata_port *ap,
391 unsigned int device)
392{
393 struct it821x_dev *itdev = ap->private_data;
394 if (itdev && device != itdev->last_device) {
395 struct ata_device *adev = &ap->link.device[device];
396 it821x_program(ap, adev, itdev->pio[adev->devno]);
397 itdev->last_device = device;
398 }
399 ata_sff_dev_select(ap, device);
400}
401
402
403
404
405
406
407
408
409
410
411static unsigned int it821x_smart_qc_issue(struct ata_queued_cmd *qc)
412{
413 switch(qc->tf.command)
414 {
415
416 case ATA_CMD_READ:
417 case ATA_CMD_READ_EXT:
418 case ATA_CMD_WRITE:
419 case ATA_CMD_WRITE_EXT:
420 case ATA_CMD_PIO_READ:
421 case ATA_CMD_PIO_READ_EXT:
422 case ATA_CMD_PIO_WRITE:
423 case ATA_CMD_PIO_WRITE_EXT:
424 case ATA_CMD_READ_MULTI:
425 case ATA_CMD_READ_MULTI_EXT:
426 case ATA_CMD_WRITE_MULTI:
427 case ATA_CMD_WRITE_MULTI_EXT:
428 case ATA_CMD_ID_ATA:
429 case ATA_CMD_INIT_DEV_PARAMS:
430 case 0xFC:
431
432 case ATA_CMD_SET_FEATURES:
433 return ata_bmdma_qc_issue(qc);
434 }
435 printk(KERN_DEBUG "it821x: can't process command 0x%02X\n", qc->tf.command);
436 return AC_ERR_DEV;
437}
438
439
440
441
442
443
444
445
446
447
448static unsigned int it821x_passthru_qc_issue(struct ata_queued_cmd *qc)
449{
450 it821x_passthru_dev_select(qc->ap, qc->dev->devno);
451 return ata_bmdma_qc_issue(qc);
452}
453
454
455
456
457
458
459
460
461
462
463
464
465static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unused)
466{
467 struct ata_device *dev;
468
469 ata_for_each_dev(dev, link, ENABLED) {
470
471 dev->pio_mode = XFER_PIO_0;
472 dev->dma_mode = XFER_MW_DMA_0;
473
474
475 if (ata_id_has_dma(dev->id)) {
476 ata_dev_info(dev, "configured for DMA\n");
477 dev->xfer_mode = XFER_MW_DMA_0;
478 dev->xfer_shift = ATA_SHIFT_MWDMA;
479 dev->flags &= ~ATA_DFLAG_PIO;
480 } else {
481 ata_dev_info(dev, "configured for PIO\n");
482 dev->xfer_mode = XFER_PIO_0;
483 dev->xfer_shift = ATA_SHIFT_PIO;
484 dev->flags |= ATA_DFLAG_PIO;
485 }
486 }
487 return 0;
488}
489
490
491
492
493
494
495
496
497
498
499
500static void it821x_dev_config(struct ata_device *adev)
501{
502 unsigned char model_num[ATA_ID_PROD_LEN + 1];
503
504 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
505
506 if (adev->max_sectors > 255)
507 adev->max_sectors = 255;
508
509 if (strstr(model_num, "Integrated Technology Express")) {
510
511 ata_dev_info(adev, "%sRAID%d volume",
512 adev->id[147] ? "Bootable " : "",
513 adev->id[129]);
514 if (adev->id[129] != 1)
515 pr_cont("(%dK stripe)", adev->id[146]);
516 pr_cont("\n");
517 }
518
519
520 adev->horkage &= ~ATA_HORKAGE_DIAGNOSTIC;
521
522 adev->horkage |= ATA_HORKAGE_BROKEN_HPA;
523}
524
525
526
527
528
529
530
531
532
533
534
535
536
537static unsigned int it821x_read_id(struct ata_device *adev,
538 struct ata_taskfile *tf, u16 *id)
539{
540 unsigned int err_mask;
541 unsigned char model_num[ATA_ID_PROD_LEN + 1];
542
543 err_mask = ata_do_dev_read_id(adev, tf, id);
544 if (err_mask)
545 return err_mask;
546 ata_id_c_string(id, model_num, ATA_ID_PROD, sizeof(model_num));
547
548 id[83] &= ~(1 << 12);
549 id[83] &= ~(1 << 13);
550 id[84] &= ~(1 << 6);
551 id[85] &= ~(1 << 10);
552 id[76] = 0;
553
554 if (strstr(model_num, "Integrated Technology Express")) {
555
556 id[49] |= 0x0300;
557 id[83] &= 0x7FFF;
558 id[83] |= 0x4400;
559 id[86] |= 0x0400;
560 id[ATA_ID_MAJOR_VER] |= 0x1F;
561
562
563 memset(&id[ATA_ID_SERNO], 0x20, ATA_ID_SERNO_LEN);
564 }
565 return err_mask;
566}
567
568
569
570
571
572
573
574
575
576static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
577{
578 struct ata_port *ap = qc->ap;
579 struct it821x_dev *itdev = ap->private_data;
580
581
582 if (ata_qc_raw_nbytes(qc) < 2048)
583 return -EOPNOTSUPP;
584
585
586 if (itdev->smart)
587 return -EOPNOTSUPP;
588
589 if (itdev->timing10)
590 return -EOPNOTSUPP;
591
592 return 0;
593}
594
595
596
597
598
599
600
601
602
603
604static void it821x_display_disk(int n, u8 *buf)
605{
606 unsigned char id[41];
607 int mode = 0;
608 char *mtype = "";
609 char mbuf[8];
610 char *cbl = "(40 wire cable)";
611
612 static const char *types[5] = {
613 "RAID0", "RAID1", "RAID 0+1", "JBOD", "DISK"
614 };
615
616 if (buf[52] > 4)
617 return;
618
619 ata_id_c_string((u16 *)buf, id, 0, 41);
620
621 if (buf[51]) {
622 mode = ffs(buf[51]);
623 mtype = "UDMA";
624 } else if (buf[49]) {
625 mode = ffs(buf[49]);
626 mtype = "MWDMA";
627 }
628
629 if (buf[76])
630 cbl = "";
631
632 if (mode)
633 snprintf(mbuf, 8, "%5s%d", mtype, mode - 1);
634 else
635 strcpy(mbuf, "PIO");
636 if (buf[52] == 4)
637 printk(KERN_INFO "%d: %-6s %-8s %s %s\n",
638 n, mbuf, types[buf[52]], id, cbl);
639 else
640 printk(KERN_INFO "%d: %-6s %-8s Volume: %1d %s %s\n",
641 n, mbuf, types[buf[52]], buf[53], id, cbl);
642 if (buf[125] < 100)
643 printk(KERN_INFO "%d: Rebuilding: %d%%\n", n, buf[125]);
644}
645
646
647
648
649
650
651
652
653
654
655
656
657static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len)
658{
659 u8 status;
660 int n = 0;
661 u16 *buf = kmalloc(len, GFP_KERNEL);
662 if (buf == NULL) {
663 printk(KERN_ERR "it821x_firmware_command: Out of memory\n");
664 return NULL;
665 }
666
667
668 ap->ctl |= ATA_NIEN;
669 iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
670 ata_wait_idle(ap);
671 iowrite8(ATA_DEVICE_OBS, ap->ioaddr.device_addr);
672 iowrite8(cmd, ap->ioaddr.command_addr);
673 udelay(1);
674
675
676 while(n++ < 10) {
677 status = ioread8(ap->ioaddr.status_addr);
678 if (status & ATA_ERR) {
679 kfree(buf);
680 printk(KERN_ERR "it821x_firmware_command: rejected\n");
681 return NULL;
682 }
683 if (status & ATA_DRQ) {
684 ioread16_rep(ap->ioaddr.data_addr, buf, len/2);
685 return (u8 *)buf;
686 }
687 mdelay(1);
688 }
689 kfree(buf);
690 printk(KERN_ERR "it821x_firmware_command: timeout\n");
691 return NULL;
692}
693
694
695
696
697
698
699
700
701
702static void it821x_probe_firmware(struct ata_port *ap)
703{
704 u8 *buf;
705 int i;
706
707
708
709
710 buf = it821x_firmware_command(ap, 0xFA, 512);
711
712 if (buf != NULL) {
713 printk(KERN_INFO "pata_it821x: Firmware %02X/%02X/%02X%02X\n",
714 buf[505],
715 buf[506],
716 buf[507],
717 buf[508]);
718 for (i = 0; i < 4; i++)
719 it821x_display_disk(i, buf + 128 * i);
720 kfree(buf);
721 }
722}
723
724
725
726
727
728
729
730
731
732
733
734
735
736static int it821x_port_start(struct ata_port *ap)
737{
738 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
739 struct it821x_dev *itdev;
740 u8 conf;
741
742 int ret = ata_bmdma_port_start(ap);
743 if (ret < 0)
744 return ret;
745
746 itdev = devm_kzalloc(&pdev->dev, sizeof(struct it821x_dev), GFP_KERNEL);
747 if (itdev == NULL)
748 return -ENOMEM;
749 ap->private_data = itdev;
750
751 pci_read_config_byte(pdev, 0x50, &conf);
752
753 if (conf & 1) {
754 itdev->smart = 1;
755
756
757
758 if (ap->port_no == 0)
759 it821x_probe_firmware(ap);
760 }
761
762 if (conf & (1 << (1 + ap->port_no)))
763 itdev->clock_mode = ATA_50;
764 else
765 itdev->clock_mode = ATA_66;
766
767 itdev->want[0][1] = ATA_ANY;
768 itdev->want[1][1] = ATA_ANY;
769 itdev->last_device = -1;
770
771 if (pdev->revision == 0x10) {
772 itdev->timing10 = 1;
773
774 if (!itdev->smart)
775 printk(KERN_WARNING DRV_NAME": Revision 0x10, workarounds activated.\n");
776 }
777
778 return 0;
779}
780
781
782
783
784
785
786
787
788
789static int it821x_rdc_cable(struct ata_port *ap)
790{
791 u16 r40;
792 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
793
794 pci_read_config_word(pdev, 0x40, &r40);
795 if (r40 & (1 << (2 + ap->port_no)))
796 return ATA_CBL_PATA40;
797 return ATA_CBL_PATA80;
798}
799
800static struct scsi_host_template it821x_sht = {
801 ATA_BMDMA_SHT(DRV_NAME),
802};
803
804static struct ata_port_operations it821x_smart_port_ops = {
805 .inherits = &ata_bmdma_port_ops,
806
807 .check_atapi_dma= it821x_check_atapi_dma,
808 .qc_issue = it821x_smart_qc_issue,
809
810 .cable_detect = ata_cable_80wire,
811 .set_mode = it821x_smart_set_mode,
812 .dev_config = it821x_dev_config,
813 .read_id = it821x_read_id,
814
815 .port_start = it821x_port_start,
816};
817
818static struct ata_port_operations it821x_passthru_port_ops = {
819 .inherits = &ata_bmdma_port_ops,
820
821 .check_atapi_dma= it821x_check_atapi_dma,
822 .sff_dev_select = it821x_passthru_dev_select,
823 .bmdma_start = it821x_passthru_bmdma_start,
824 .bmdma_stop = it821x_passthru_bmdma_stop,
825 .qc_issue = it821x_passthru_qc_issue,
826
827 .cable_detect = ata_cable_unknown,
828 .set_piomode = it821x_passthru_set_piomode,
829 .set_dmamode = it821x_passthru_set_dmamode,
830
831 .port_start = it821x_port_start,
832};
833
834static struct ata_port_operations it821x_rdc_port_ops = {
835 .inherits = &ata_bmdma_port_ops,
836
837 .check_atapi_dma= it821x_check_atapi_dma,
838 .sff_dev_select = it821x_passthru_dev_select,
839 .bmdma_start = it821x_passthru_bmdma_start,
840 .bmdma_stop = it821x_passthru_bmdma_stop,
841 .qc_issue = it821x_passthru_qc_issue,
842
843 .cable_detect = it821x_rdc_cable,
844 .set_piomode = it821x_passthru_set_piomode,
845 .set_dmamode = it821x_passthru_set_dmamode,
846
847 .port_start = it821x_port_start,
848};
849
850static void it821x_disable_raid(struct pci_dev *pdev)
851{
852
853 if (pdev->vendor != PCI_VENDOR_ID_ITE ||
854 pdev->device != PCI_DEVICE_ID_ITE_8212)
855 return;
856
857
858 pci_write_config_byte(pdev, 0x5E, 0x01);
859
860
861 pci_write_config_byte(pdev, 0x50, 0x00);
862 pci_write_config_word(pdev, PCI_COMMAND,
863 PCI_COMMAND_PARITY | PCI_COMMAND_IO |
864 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
865 pci_write_config_word(pdev, 0x40, 0xA0F3);
866
867 pci_write_config_dword(pdev,0x4C, 0x02040204);
868 pci_write_config_byte(pdev, 0x42, 0x36);
869 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
870}
871
872
873static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
874{
875 u8 conf;
876
877 static const struct ata_port_info info_smart = {
878 .flags = ATA_FLAG_SLAVE_POSS,
879 .pio_mask = ATA_PIO4,
880 .mwdma_mask = ATA_MWDMA2,
881 .udma_mask = ATA_UDMA6,
882 .port_ops = &it821x_smart_port_ops
883 };
884 static const struct ata_port_info info_passthru = {
885 .flags = ATA_FLAG_SLAVE_POSS,
886 .pio_mask = ATA_PIO4,
887 .mwdma_mask = ATA_MWDMA2,
888 .udma_mask = ATA_UDMA6,
889 .port_ops = &it821x_passthru_port_ops
890 };
891 static const struct ata_port_info info_rdc = {
892 .flags = ATA_FLAG_SLAVE_POSS,
893 .pio_mask = ATA_PIO4,
894 .mwdma_mask = ATA_MWDMA2,
895 .udma_mask = ATA_UDMA6,
896 .port_ops = &it821x_rdc_port_ops
897 };
898 static const struct ata_port_info info_rdc_11 = {
899 .flags = ATA_FLAG_SLAVE_POSS,
900 .pio_mask = ATA_PIO4,
901 .mwdma_mask = ATA_MWDMA2,
902
903 .port_ops = &it821x_rdc_port_ops
904 };
905
906 const struct ata_port_info *ppi[] = { NULL, NULL };
907 static char *mode[2] = { "pass through", "smart" };
908 int rc;
909
910 rc = pcim_enable_device(pdev);
911 if (rc)
912 return rc;
913
914 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
915
916 if (pdev->revision == 0x11)
917 ppi[0] = &info_rdc_11;
918 else
919 ppi[0] = &info_rdc;
920 } else {
921
922 if (it8212_noraid) {
923 printk(KERN_INFO DRV_NAME ": forcing bypass mode.\n");
924 it821x_disable_raid(pdev);
925 }
926 pci_read_config_byte(pdev, 0x50, &conf);
927 conf &= 1;
928
929 printk(KERN_INFO DRV_NAME": controller in %s mode.\n",
930 mode[conf]);
931 if (conf == 0)
932 ppi[0] = &info_passthru;
933 else
934 ppi[0] = &info_smart;
935 }
936 return ata_pci_bmdma_init_one(pdev, ppi, &it821x_sht, NULL, 0);
937}
938
939#ifdef CONFIG_PM
940static int it821x_reinit_one(struct pci_dev *pdev)
941{
942 struct ata_host *host = dev_get_drvdata(&pdev->dev);
943 int rc;
944
945 rc = ata_pci_device_do_resume(pdev);
946 if (rc)
947 return rc;
948
949 if (it8212_noraid)
950 it821x_disable_raid(pdev);
951 ata_host_resume(host);
952 return rc;
953}
954#endif
955
956static const struct pci_device_id it821x[] = {
957 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), },
958 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), },
959 { PCI_VDEVICE(RDC, PCI_DEVICE_ID_RDC_D1010), },
960
961 { },
962};
963
964static struct pci_driver it821x_pci_driver = {
965 .name = DRV_NAME,
966 .id_table = it821x,
967 .probe = it821x_init_one,
968 .remove = ata_pci_remove_one,
969#ifdef CONFIG_PM
970 .suspend = ata_pci_device_suspend,
971 .resume = it821x_reinit_one,
972#endif
973};
974
975static int __init it821x_init(void)
976{
977 return pci_register_driver(&it821x_pci_driver);
978}
979
980static void __exit it821x_exit(void)
981{
982 pci_unregister_driver(&it821x_pci_driver);
983}
984
985MODULE_AUTHOR("Alan Cox");
986MODULE_DESCRIPTION("low-level driver for the IT8211/IT8212 IDE RAID controller");
987MODULE_LICENSE("GPL");
988MODULE_DEVICE_TABLE(pci, it821x);
989MODULE_VERSION(DRV_VERSION);
990
991
992module_param_named(noraid, it8212_noraid, int, S_IRUGO);
993MODULE_PARM_DESC(noraid, "Force card into bypass mode");
994
995module_init(it821x_init);
996module_exit(it821x_exit);
997