[PATCH] sata_sil: add new constants in preparation for new interrupt handler
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / drivers / scsi / sata_sil.c
CommitLineData
1da177e4
LT
1/*
2 * sata_sil.c - Silicon Image SATA
3 *
4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails.
7 *
af36d7f0 8 * Copyright 2003-2005 Red Hat, Inc.
1da177e4
LT
9 * Copyright 2003 Benjamin Herrenschmidt
10 *
af36d7f0
JG
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; see the file COPYING. If not, write to
24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 *
27 * libata documentation is available via 'make {ps|pdf}docs',
28 * as Documentation/DocBook/libata.*
1da177e4 29 *
953d1137
JG
30 * Documentation for SiI 3112:
31 * http://gkernel.sourceforge.net/specs/sii/3112A_SiI-DS-0095-B2.pdf.bz2
32 *
33 * Other errata and documentation available under NDA.
34 *
1da177e4
LT
35 */
36
37#include <linux/kernel.h>
38#include <linux/module.h>
39#include <linux/pci.h>
40#include <linux/init.h>
41#include <linux/blkdev.h>
42#include <linux/delay.h>
43#include <linux/interrupt.h>
a9524a76 44#include <linux/device.h>
1da177e4
LT
45#include <scsi/scsi_host.h>
46#include <linux/libata.h>
47
48#define DRV_NAME "sata_sil"
af64371a 49#define DRV_VERSION "1.0"
1da177e4
LT
50
51enum {
e653a1e6
TH
52 /*
53 * host flags
54 */
e4e10e3e 55 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29),
e4deec63 56 SIL_FLAG_MOD15WRITE = (1 << 30),
20888d83 57
e653a1e6
TH
58 SIL_DFL_HOST_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
59 ATA_FLAG_MMIO,
e4deec63 60
e653a1e6
TH
61 /*
62 * Controller IDs
63 */
1da177e4 64 sil_3112 = 0,
81c2af35
TH
65 sil_3512 = 1,
66 sil_3114 = 2,
1da177e4 67
e653a1e6
TH
68 /*
69 * Register offsets
70 */
1da177e4 71 SIL_SYSCFG = 0x48,
e653a1e6
TH
72
73 /*
74 * Register bits
75 */
76 /* SYSCFG */
1da177e4
LT
77 SIL_MASK_IDE0_INT = (1 << 22),
78 SIL_MASK_IDE1_INT = (1 << 23),
79 SIL_MASK_IDE2_INT = (1 << 24),
80 SIL_MASK_IDE3_INT = (1 << 25),
81 SIL_MASK_2PORT = SIL_MASK_IDE0_INT | SIL_MASK_IDE1_INT,
82 SIL_MASK_4PORT = SIL_MASK_2PORT |
83 SIL_MASK_IDE2_INT | SIL_MASK_IDE3_INT,
84
e653a1e6 85 /* BMDMA/BMDMA2 */
1da177e4 86 SIL_INTR_STEERING = (1 << 1),
e653a1e6 87
20888d83
TH
88 SIL_DMA_ENABLE = (1 << 0), /* DMA run switch */
89 SIL_DMA_RDWR = (1 << 3), /* DMA Rd-Wr */
90 SIL_DMA_SATA_IRQ = (1 << 4), /* OR of all SATA IRQs */
91 SIL_DMA_ACTIVE = (1 << 16), /* DMA running */
92 SIL_DMA_ERROR = (1 << 17), /* PCI bus error */
93 SIL_DMA_COMPLETE = (1 << 18), /* cmd complete / IRQ pending */
94 SIL_DMA_N_SATA_IRQ = (1 << 6), /* SATA_IRQ for the next channel */
95 SIL_DMA_N_ACTIVE = (1 << 24), /* ACTIVE for the next channel */
96 SIL_DMA_N_ERROR = (1 << 25), /* ERROR for the next channel */
97 SIL_DMA_N_COMPLETE = (1 << 26), /* COMPLETE for the next channel */
98
99 /* SIEN */
100 SIL_SIEN_N = (1 << 16), /* triggered by SError.N */
101
e653a1e6
TH
102 /*
103 * Others
104 */
1da177e4
LT
105 SIL_QUIRK_MOD15WRITE = (1 << 0),
106 SIL_QUIRK_UDMA5MAX = (1 << 1),
107};
108
109static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
110static void sil_dev_config(struct ata_port *ap, struct ata_device *dev);
111static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg);
112static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
113static void sil_post_set_mode (struct ata_port *ap);
f6aae27e
TH
114static void sil_freeze(struct ata_port *ap);
115static void sil_thaw(struct ata_port *ap);
1da177e4 116
374b1873 117
3b7d697d 118static const struct pci_device_id sil_pci_tbl[] = {
81c2af35
TH
119 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
120 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
0ee304d5 121 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 },
1da177e4 122 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
81c2af35
TH
123 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
124 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
125 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
1da177e4
LT
126 { } /* terminate list */
127};
128
129
130/* TODO firmware versions should be added - eric */
131static const struct sil_drivelist {
132 const char * product;
133 unsigned int quirk;
134} sil_blacklist [] = {
135 { "ST320012AS", SIL_QUIRK_MOD15WRITE },
136 { "ST330013AS", SIL_QUIRK_MOD15WRITE },
137 { "ST340017AS", SIL_QUIRK_MOD15WRITE },
138 { "ST360015AS", SIL_QUIRK_MOD15WRITE },
139 { "ST380013AS", SIL_QUIRK_MOD15WRITE },
140 { "ST380023AS", SIL_QUIRK_MOD15WRITE },
141 { "ST3120023AS", SIL_QUIRK_MOD15WRITE },
142 { "ST3160023AS", SIL_QUIRK_MOD15WRITE },
143 { "ST3120026AS", SIL_QUIRK_MOD15WRITE },
144 { "ST3200822AS", SIL_QUIRK_MOD15WRITE },
145 { "ST340014ASL", SIL_QUIRK_MOD15WRITE },
146 { "ST360014ASL", SIL_QUIRK_MOD15WRITE },
147 { "ST380011ASL", SIL_QUIRK_MOD15WRITE },
148 { "ST3120022ASL", SIL_QUIRK_MOD15WRITE },
149 { "ST3160021ASL", SIL_QUIRK_MOD15WRITE },
150 { "Maxtor 4D060H3", SIL_QUIRK_UDMA5MAX },
151 { }
152};
153
154static struct pci_driver sil_pci_driver = {
155 .name = DRV_NAME,
156 .id_table = sil_pci_tbl,
157 .probe = sil_init_one,
158 .remove = ata_pci_remove_one,
159};
160
193515d5 161static struct scsi_host_template sil_sht = {
1da177e4
LT
162 .module = THIS_MODULE,
163 .name = DRV_NAME,
164 .ioctl = ata_scsi_ioctl,
165 .queuecommand = ata_scsi_queuecmd,
1da177e4
LT
166 .can_queue = ATA_DEF_QUEUE,
167 .this_id = ATA_SHT_THIS_ID,
168 .sg_tablesize = LIBATA_MAX_PRD,
1da177e4
LT
169 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
170 .emulated = ATA_SHT_EMULATED,
171 .use_clustering = ATA_SHT_USE_CLUSTERING,
172 .proc_name = DRV_NAME,
173 .dma_boundary = ATA_DMA_BOUNDARY,
174 .slave_configure = ata_scsi_slave_config,
175 .bios_param = ata_std_bios_param,
1da177e4
LT
176};
177
057ace5e 178static const struct ata_port_operations sil_ops = {
1da177e4
LT
179 .port_disable = ata_port_disable,
180 .dev_config = sil_dev_config,
181 .tf_load = ata_tf_load,
182 .tf_read = ata_tf_read,
183 .check_status = ata_check_status,
184 .exec_command = ata_exec_command,
185 .dev_select = ata_std_dev_select,
531db7aa 186 .probe_reset = ata_std_probe_reset,
1da177e4
LT
187 .post_set_mode = sil_post_set_mode,
188 .bmdma_setup = ata_bmdma_setup,
189 .bmdma_start = ata_bmdma_start,
190 .bmdma_stop = ata_bmdma_stop,
191 .bmdma_status = ata_bmdma_status,
192 .qc_prep = ata_qc_prep,
193 .qc_issue = ata_qc_issue_prot,
a6b2c5d4 194 .data_xfer = ata_mmio_data_xfer,
f6aae27e
TH
195 .freeze = sil_freeze,
196 .thaw = sil_thaw,
197 .error_handler = ata_bmdma_error_handler,
198 .post_internal_cmd = ata_bmdma_post_internal_cmd,
1da177e4
LT
199 .irq_handler = ata_interrupt,
200 .irq_clear = ata_bmdma_irq_clear,
201 .scr_read = sil_scr_read,
202 .scr_write = sil_scr_write,
203 .port_start = ata_port_start,
204 .port_stop = ata_port_stop,
374b1873 205 .host_stop = ata_pci_host_stop,
1da177e4
LT
206};
207
98ac62de 208static const struct ata_port_info sil_port_info[] = {
1da177e4 209 /* sil_3112 */
e4deec63
TH
210 {
211 .sht = &sil_sht,
e653a1e6 212 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE,
e4deec63
TH
213 .pio_mask = 0x1f, /* pio0-4 */
214 .mwdma_mask = 0x07, /* mwdma0-2 */
215 .udma_mask = 0x3f, /* udma0-5 */
216 .port_ops = &sil_ops,
0ee304d5
TH
217 },
218 /* sil_3512 */
1da177e4
LT
219 {
220 .sht = &sil_sht,
e653a1e6 221 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
0ee304d5
TH
222 .pio_mask = 0x1f, /* pio0-4 */
223 .mwdma_mask = 0x07, /* mwdma0-2 */
224 .udma_mask = 0x3f, /* udma0-5 */
225 .port_ops = &sil_ops,
226 },
227 /* sil_3114 */
1da177e4
LT
228 {
229 .sht = &sil_sht,
e653a1e6 230 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
1da177e4
LT
231 .pio_mask = 0x1f, /* pio0-4 */
232 .mwdma_mask = 0x07, /* mwdma0-2 */
233 .udma_mask = 0x3f, /* udma0-5 */
234 .port_ops = &sil_ops,
235 },
236};
237
238/* per-port register offsets */
239/* TODO: we can probably calculate rather than use a table */
240static const struct {
241 unsigned long tf; /* ATA taskfile register block */
242 unsigned long ctl; /* ATA control/altstatus register block */
243 unsigned long bmdma; /* DMA register block */
20888d83 244 unsigned long bmdma2; /* DMA register block #2 */
48d4ef2a 245 unsigned long fifo_cfg; /* FIFO Valid Byte Count and Control */
1da177e4
LT
246 unsigned long scr; /* SATA control register block */
247 unsigned long sien; /* SATA Interrupt Enable register */
248 unsigned long xfer_mode;/* data transfer mode register */
e4e10e3e 249 unsigned long sfis_cfg; /* SATA FIS reception config register */
1da177e4
LT
250} sil_port[] = {
251 /* port 0 ... */
20888d83
TH
252 { 0x80, 0x8A, 0x00, 0x10, 0x40, 0x100, 0x148, 0xb4, 0x14c },
253 { 0xC0, 0xCA, 0x08, 0x18, 0x44, 0x180, 0x1c8, 0xf4, 0x1cc },
254 { 0x280, 0x28A, 0x200, 0x210, 0x240, 0x300, 0x348, 0x2b4, 0x34c },
255 { 0x2C0, 0x2CA, 0x208, 0x218, 0x244, 0x380, 0x3c8, 0x2f4, 0x3cc },
1da177e4
LT
256 /* ... port 3 */
257};
258
259MODULE_AUTHOR("Jeff Garzik");
260MODULE_DESCRIPTION("low-level driver for Silicon Image SATA controller");
261MODULE_LICENSE("GPL");
262MODULE_DEVICE_TABLE(pci, sil_pci_tbl);
263MODULE_VERSION(DRV_VERSION);
264
51e9f2ff
JG
265static int slow_down = 0;
266module_param(slow_down, int, 0444);
267MODULE_PARM_DESC(slow_down, "Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)");
268
374b1873 269
1da177e4
LT
270static unsigned char sil_get_device_cache_line(struct pci_dev *pdev)
271{
272 u8 cache_line = 0;
273 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_line);
274 return cache_line;
275}
276
277static void sil_post_set_mode (struct ata_port *ap)
278{
279 struct ata_host_set *host_set = ap->host_set;
280 struct ata_device *dev;
ea6ba10b
JG
281 void __iomem *addr =
282 host_set->mmio_base + sil_port[ap->port_no].xfer_mode;
1da177e4
LT
283 u32 tmp, dev_mode[2];
284 unsigned int i;
285
286 for (i = 0; i < 2; i++) {
287 dev = &ap->device[i];
e1211e3f 288 if (!ata_dev_enabled(dev))
1da177e4
LT
289 dev_mode[i] = 0; /* PIO0/1/2 */
290 else if (dev->flags & ATA_DFLAG_PIO)
291 dev_mode[i] = 1; /* PIO3/4 */
292 else
293 dev_mode[i] = 3; /* UDMA */
294 /* value 2 indicates MDMA */
295 }
296
297 tmp = readl(addr);
298 tmp &= ~((1<<5) | (1<<4) | (1<<1) | (1<<0));
299 tmp |= dev_mode[0];
300 tmp |= (dev_mode[1] << 4);
301 writel(tmp, addr);
302 readl(addr); /* flush */
303}
304
305static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_reg)
306{
307 unsigned long offset = ap->ioaddr.scr_addr;
308
309 switch (sc_reg) {
310 case SCR_STATUS:
311 return offset + 4;
312 case SCR_ERROR:
313 return offset + 8;
314 case SCR_CONTROL:
315 return offset;
316 default:
317 /* do nothing */
318 break;
319 }
320
321 return 0;
322}
323
324static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
325{
9aa36e89 326 void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
1da177e4
LT
327 if (mmio)
328 return readl(mmio);
329 return 0xffffffffU;
330}
331
332static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
333{
9aa36e89 334 void *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
1da177e4
LT
335 if (mmio)
336 writel(val, mmio);
337}
338
f6aae27e
TH
339static void sil_freeze(struct ata_port *ap)
340{
341 void __iomem *mmio_base = ap->host_set->mmio_base;
342 u32 tmp;
343
344 /* plug IRQ */
345 tmp = readl(mmio_base + SIL_SYSCFG);
346 tmp |= SIL_MASK_IDE0_INT << ap->port_no;
347 writel(tmp, mmio_base + SIL_SYSCFG);
348 readl(mmio_base + SIL_SYSCFG); /* flush */
349}
350
351static void sil_thaw(struct ata_port *ap)
352{
353 void __iomem *mmio_base = ap->host_set->mmio_base;
354 u32 tmp;
355
356 /* clear IRQ */
357 ata_chk_status(ap);
358 ata_bmdma_irq_clear(ap);
359
360 /* turn on IRQ */
361 tmp = readl(mmio_base + SIL_SYSCFG);
362 tmp &= ~(SIL_MASK_IDE0_INT << ap->port_no);
363 writel(tmp, mmio_base + SIL_SYSCFG);
364}
365
1da177e4
LT
366/**
367 * sil_dev_config - Apply device/host-specific errata fixups
368 * @ap: Port containing device to be examined
369 * @dev: Device to be examined
370 *
371 * After the IDENTIFY [PACKET] DEVICE step is complete, and a
372 * device is known to be present, this function is called.
373 * We apply two errata fixups which are specific to Silicon Image,
374 * a Seagate and a Maxtor fixup.
375 *
376 * For certain Seagate devices, we must limit the maximum sectors
377 * to under 8K.
378 *
379 * For certain Maxtor devices, we must not program the drive
380 * beyond udma5.
381 *
382 * Both fixups are unfairly pessimistic. As soon as I get more
383 * information on these errata, I will create a more exhaustive
384 * list, and apply the fixups to only the specific
385 * devices/hosts/firmwares that need it.
386 *
387 * 20040111 - Seagate drives affected by the Mod15Write bug are blacklisted
388 * The Maxtor quirk is in the blacklist, but I'm keeping the original
389 * pessimistic fix for the following reasons...
390 * - There seems to be less info on it, only one device gleaned off the
391 * Windows driver, maybe only one is affected. More info would be greatly
392 * appreciated.
393 * - But then again UDMA5 is hardly anything to complain about
394 */
395static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
396{
397 unsigned int n, quirks = 0;
2e02671d 398 unsigned char model_num[41];
1da177e4 399
6a62a04d 400 ata_id_c_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
1da177e4 401
8a60a071 402 for (n = 0; sil_blacklist[n].product; n++)
2e02671d 403 if (!strcmp(sil_blacklist[n].product, model_num)) {
1da177e4
LT
404 quirks = sil_blacklist[n].quirk;
405 break;
406 }
8a60a071 407
1da177e4 408 /* limit requests to 15 sectors */
51e9f2ff
JG
409 if (slow_down ||
410 ((ap->flags & SIL_FLAG_MOD15WRITE) &&
411 (quirks & SIL_QUIRK_MOD15WRITE))) {
f15a1daf
TH
412 ata_dev_printk(dev, KERN_INFO, "applying Seagate errata fix "
413 "(mod15write workaround)\n");
b00eec1d 414 dev->max_sectors = 15;
1da177e4
LT
415 return;
416 }
417
418 /* limit to udma5 */
419 if (quirks & SIL_QUIRK_UDMA5MAX) {
f15a1daf
TH
420 ata_dev_printk(dev, KERN_INFO,
421 "applying Maxtor errata fix %s\n", model_num);
5a529139 422 dev->udma_mask &= ATA_UDMA5;
1da177e4
LT
423 return;
424 }
425}
426
427static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
428{
429 static int printed_version;
430 struct ata_probe_ent *probe_ent = NULL;
431 unsigned long base;
ea6ba10b 432 void __iomem *mmio_base;
1da177e4
LT
433 int rc;
434 unsigned int i;
435 int pci_dev_busy = 0;
f6aae27e 436 u32 tmp;
1da177e4
LT
437 u8 cls;
438
439 if (!printed_version++)
a9524a76 440 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1da177e4 441
1da177e4
LT
442 rc = pci_enable_device(pdev);
443 if (rc)
444 return rc;
445
446 rc = pci_request_regions(pdev, DRV_NAME);
447 if (rc) {
448 pci_dev_busy = 1;
449 goto err_out;
450 }
451
452 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
453 if (rc)
454 goto err_out_regions;
455 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
456 if (rc)
457 goto err_out_regions;
458
9a531443 459 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
1da177e4
LT
460 if (probe_ent == NULL) {
461 rc = -ENOMEM;
462 goto err_out_regions;
463 }
464
1da177e4
LT
465 INIT_LIST_HEAD(&probe_ent->node);
466 probe_ent->dev = pci_dev_to_dev(pdev);
467 probe_ent->port_ops = sil_port_info[ent->driver_data].port_ops;
468 probe_ent->sht = sil_port_info[ent->driver_data].sht;
469 probe_ent->n_ports = (ent->driver_data == sil_3114) ? 4 : 2;
470 probe_ent->pio_mask = sil_port_info[ent->driver_data].pio_mask;
471 probe_ent->mwdma_mask = sil_port_info[ent->driver_data].mwdma_mask;
472 probe_ent->udma_mask = sil_port_info[ent->driver_data].udma_mask;
473 probe_ent->irq = pdev->irq;
474 probe_ent->irq_flags = SA_SHIRQ;
475 probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags;
476
374b1873 477 mmio_base = pci_iomap(pdev, 5, 0);
1da177e4
LT
478 if (mmio_base == NULL) {
479 rc = -ENOMEM;
480 goto err_out_free_ent;
481 }
482
483 probe_ent->mmio_base = mmio_base;
484
485 base = (unsigned long) mmio_base;
486
487 for (i = 0; i < probe_ent->n_ports; i++) {
488 probe_ent->port[i].cmd_addr = base + sil_port[i].tf;
489 probe_ent->port[i].altstatus_addr =
490 probe_ent->port[i].ctl_addr = base + sil_port[i].ctl;
491 probe_ent->port[i].bmdma_addr = base + sil_port[i].bmdma;
492 probe_ent->port[i].scr_addr = base + sil_port[i].scr;
493 ata_std_ports(&probe_ent->port[i]);
494 }
495
496 /* Initialize FIFO PCI bus arbitration */
497 cls = sil_get_device_cache_line(pdev);
498 if (cls) {
499 cls >>= 3;
500 cls++; /* cls = (line_size/8)+1 */
48d4ef2a
TH
501 for (i = 0; i < probe_ent->n_ports; i++)
502 writew(cls << 8 | cls,
503 mmio_base + sil_port[i].fifo_cfg);
1da177e4 504 } else
a9524a76 505 dev_printk(KERN_WARNING, &pdev->dev,
48d4ef2a 506 "cache line size not set. Driver may not function\n");
1da177e4 507
e4e10e3e
TH
508 /* Apply R_ERR on DMA activate FIS errata workaround */
509 if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) {
510 int cnt;
511
512 for (i = 0, cnt = 0; i < probe_ent->n_ports; i++) {
513 tmp = readl(mmio_base + sil_port[i].sfis_cfg);
514 if ((tmp & 0x3) != 0x01)
515 continue;
516 if (!cnt)
517 dev_printk(KERN_INFO, &pdev->dev,
518 "Applying R_ERR on DMA activate "
519 "FIS errata fix\n");
520 writel(tmp & ~0x3, mmio_base + sil_port[i].sfis_cfg);
521 cnt++;
522 }
523 }
524
1da177e4 525 if (ent->driver_data == sil_3114) {
1da177e4 526 /* flip the magic "make 4 ports work" bit */
48d4ef2a 527 tmp = readl(mmio_base + sil_port[2].bmdma);
1da177e4
LT
528 if ((tmp & SIL_INTR_STEERING) == 0)
529 writel(tmp | SIL_INTR_STEERING,
48d4ef2a 530 mmio_base + sil_port[2].bmdma);
1da177e4
LT
531 }
532
533 /* mask all SATA phy-related interrupts */
534 /* TODO: unmask bit 6 (SError N bit) for hotplug */
535 for (i = 0; i < probe_ent->n_ports; i++)
536 writel(0, mmio_base + sil_port[i].sien);
537
538 pci_set_master(pdev);
539
540 /* FIXME: check ata_device_add return value */
541 ata_device_add(probe_ent);
542 kfree(probe_ent);
543
544 return 0;
545
546err_out_free_ent:
547 kfree(probe_ent);
548err_out_regions:
549 pci_release_regions(pdev);
550err_out:
551 if (!pci_dev_busy)
552 pci_disable_device(pdev);
553 return rc;
554}
555
556static int __init sil_init(void)
557{
558 return pci_module_init(&sil_pci_driver);
559}
560
561static void __exit sil_exit(void)
562{
563 pci_unregister_driver(&sil_pci_driver);
564}
565
566
567module_init(sil_init);
568module_exit(sil_exit);