]> err.no Git - linux-2.6/blob - drivers/scsi/sata_nv.c
Merge branch 'master' into upstream
[linux-2.6] / drivers / scsi / sata_nv.c
1 /*
2  *  sata_nv.c - NVIDIA nForce SATA
3  *
4  *  Copyright 2004 NVIDIA Corp.  All rights reserved.
5  *  Copyright 2004 Andrew Chew
6  *
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; see the file COPYING.  If not, write to
20  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  *
23  *  libata documentation is available via 'make {ps|pdf}docs',
24  *  as Documentation/DocBook/libata.*
25  *
26  *  No hardware documentation available outside of NVIDIA.
27  *  This driver programs the NVIDIA SATA controller in a similar
28  *  fashion as with other PCI IDE BMDMA controllers, with a few
29  *  NV-specific details such as register offsets, SATA phy location,
30  *  hotplug info, etc.
31  *
32  */
33
34 #include <linux/config.h>
35 #include <linux/kernel.h>
36 #include <linux/module.h>
37 #include <linux/pci.h>
38 #include <linux/init.h>
39 #include <linux/blkdev.h>
40 #include <linux/delay.h>
41 #include <linux/interrupt.h>
42 #include <linux/device.h>
43 #include <scsi/scsi_host.h>
44 #include <linux/libata.h>
45
46 #define DRV_NAME                        "sata_nv"
47 #define DRV_VERSION                     "0.9"
48
49 enum {
50         NV_PORTS                        = 2,
51         NV_PIO_MASK                     = 0x1f,
52         NV_MWDMA_MASK                   = 0x07,
53         NV_UDMA_MASK                    = 0x7f,
54         NV_PORT0_SCR_REG_OFFSET         = 0x00,
55         NV_PORT1_SCR_REG_OFFSET         = 0x40,
56
57         NV_INT_STATUS                   = 0x10,
58         NV_INT_STATUS_CK804             = 0x440,
59         NV_INT_STATUS_PDEV_INT          = 0x01,
60         NV_INT_STATUS_PDEV_PM           = 0x02,
61         NV_INT_STATUS_PDEV_ADDED        = 0x04,
62         NV_INT_STATUS_PDEV_REMOVED      = 0x08,
63         NV_INT_STATUS_SDEV_INT          = 0x10,
64         NV_INT_STATUS_SDEV_PM           = 0x20,
65         NV_INT_STATUS_SDEV_ADDED        = 0x40,
66         NV_INT_STATUS_SDEV_REMOVED      = 0x80,
67         NV_INT_STATUS_PDEV_HOTPLUG      = (NV_INT_STATUS_PDEV_ADDED |
68                                            NV_INT_STATUS_PDEV_REMOVED),
69         NV_INT_STATUS_SDEV_HOTPLUG      = (NV_INT_STATUS_SDEV_ADDED |
70                                            NV_INT_STATUS_SDEV_REMOVED),
71         NV_INT_STATUS_HOTPLUG           = (NV_INT_STATUS_PDEV_HOTPLUG |
72                                            NV_INT_STATUS_SDEV_HOTPLUG),
73
74         NV_INT_ENABLE                   = 0x11,
75         NV_INT_ENABLE_CK804             = 0x441,
76         NV_INT_ENABLE_PDEV_MASK         = 0x01,
77         NV_INT_ENABLE_PDEV_PM           = 0x02,
78         NV_INT_ENABLE_PDEV_ADDED        = 0x04,
79         NV_INT_ENABLE_PDEV_REMOVED      = 0x08,
80         NV_INT_ENABLE_SDEV_MASK         = 0x10,
81         NV_INT_ENABLE_SDEV_PM           = 0x20,
82         NV_INT_ENABLE_SDEV_ADDED        = 0x40,
83         NV_INT_ENABLE_SDEV_REMOVED      = 0x80,
84         NV_INT_ENABLE_PDEV_HOTPLUG      = (NV_INT_ENABLE_PDEV_ADDED |
85                                            NV_INT_ENABLE_PDEV_REMOVED),
86         NV_INT_ENABLE_SDEV_HOTPLUG      = (NV_INT_ENABLE_SDEV_ADDED |
87                                            NV_INT_ENABLE_SDEV_REMOVED),
88         NV_INT_ENABLE_HOTPLUG           = (NV_INT_ENABLE_PDEV_HOTPLUG |
89                                            NV_INT_ENABLE_SDEV_HOTPLUG),
90
91         NV_INT_CONFIG                   = 0x12,
92         NV_INT_CONFIG_METHD             = 0x01, // 0 = INT, 1 = SMI
93
94         // For PCI config register 20
95         NV_MCP_SATA_CFG_20              = 0x50,
96         NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 0x04,
97 };
98
99 static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
100 static irqreturn_t nv_interrupt (int irq, void *dev_instance,
101                                  struct pt_regs *regs);
102 static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg);
103 static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
104 static void nv_host_stop (struct ata_host_set *host_set);
105 static void nv_enable_hotplug(struct ata_probe_ent *probe_ent);
106 static void nv_disable_hotplug(struct ata_host_set *host_set);
107 static int nv_check_hotplug(struct ata_host_set *host_set);
108 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent);
109 static void nv_disable_hotplug_ck804(struct ata_host_set *host_set);
110 static int nv_check_hotplug_ck804(struct ata_host_set *host_set);
111
112 enum nv_host_type
113 {
114         GENERIC,
115         NFORCE2,
116         NFORCE3,
117         CK804
118 };
119
120 static const struct pci_device_id nv_pci_tbl[] = {
121         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
122                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
123         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
124                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
125         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,
126                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
127         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA,
128                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
129         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2,
130                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
131         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA,
132                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
133         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2,
134                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
135         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA,
136                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
137         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2,
138                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
139         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA,
140                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
141         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2,
142                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
143         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA,
144                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
145         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2,
146                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
147         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3,
148                 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
149         { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
150                 PCI_ANY_ID, PCI_ANY_ID,
151                 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
152         { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
153                 PCI_ANY_ID, PCI_ANY_ID,
154                 PCI_CLASS_STORAGE_RAID<<8, 0xffff00, GENERIC },
155         { 0, } /* terminate list */
156 };
157
158 struct nv_host_desc
159 {
160         enum nv_host_type       host_type;
161         void                    (*enable_hotplug)(struct ata_probe_ent *probe_ent);
162         void                    (*disable_hotplug)(struct ata_host_set *host_set);
163         int                     (*check_hotplug)(struct ata_host_set *host_set);
164
165 };
166 static struct nv_host_desc nv_device_tbl[] = {
167         {
168                 .host_type      = GENERIC,
169                 .enable_hotplug = NULL,
170                 .disable_hotplug= NULL,
171                 .check_hotplug  = NULL,
172         },
173         {
174                 .host_type      = NFORCE2,
175                 .enable_hotplug = nv_enable_hotplug,
176                 .disable_hotplug= nv_disable_hotplug,
177                 .check_hotplug  = nv_check_hotplug,
178         },
179         {
180                 .host_type      = NFORCE3,
181                 .enable_hotplug = nv_enable_hotplug,
182                 .disable_hotplug= nv_disable_hotplug,
183                 .check_hotplug  = nv_check_hotplug,
184         },
185         {       .host_type      = CK804,
186                 .enable_hotplug = nv_enable_hotplug_ck804,
187                 .disable_hotplug= nv_disable_hotplug_ck804,
188                 .check_hotplug  = nv_check_hotplug_ck804,
189         },
190 };
191
192 struct nv_host
193 {
194         struct nv_host_desc     *host_desc;
195         unsigned long           host_flags;
196 };
197
198 static struct pci_driver nv_pci_driver = {
199         .name                   = DRV_NAME,
200         .id_table               = nv_pci_tbl,
201         .probe                  = nv_init_one,
202         .remove                 = ata_pci_remove_one,
203 };
204
205 static struct scsi_host_template nv_sht = {
206         .module                 = THIS_MODULE,
207         .name                   = DRV_NAME,
208         .ioctl                  = ata_scsi_ioctl,
209         .queuecommand           = ata_scsi_queuecmd,
210         .can_queue              = ATA_DEF_QUEUE,
211         .this_id                = ATA_SHT_THIS_ID,
212         .sg_tablesize           = LIBATA_MAX_PRD,
213         .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
214         .emulated               = ATA_SHT_EMULATED,
215         .use_clustering         = ATA_SHT_USE_CLUSTERING,
216         .proc_name              = DRV_NAME,
217         .dma_boundary           = ATA_DMA_BOUNDARY,
218         .slave_configure        = ata_scsi_slave_config,
219         .slave_destroy          = ata_scsi_slave_destroy,
220         .bios_param             = ata_std_bios_param,
221 };
222
223 static const struct ata_port_operations nv_ops = {
224         .port_disable           = ata_port_disable,
225         .tf_load                = ata_tf_load,
226         .tf_read                = ata_tf_read,
227         .exec_command           = ata_exec_command,
228         .check_status           = ata_check_status,
229         .dev_select             = ata_std_dev_select,
230         .phy_reset              = sata_phy_reset,
231         .bmdma_setup            = ata_bmdma_setup,
232         .bmdma_start            = ata_bmdma_start,
233         .bmdma_stop             = ata_bmdma_stop,
234         .bmdma_status           = ata_bmdma_status,
235         .qc_prep                = ata_qc_prep,
236         .qc_issue               = ata_qc_issue_prot,
237         .eng_timeout            = ata_eng_timeout,
238         .data_xfer              = ata_pio_data_xfer,
239         .irq_handler            = nv_interrupt,
240         .irq_clear              = ata_bmdma_irq_clear,
241         .scr_read               = nv_scr_read,
242         .scr_write              = nv_scr_write,
243         .port_start             = ata_port_start,
244         .port_stop              = ata_port_stop,
245         .host_stop              = nv_host_stop,
246 };
247
248 /* FIXME: The hardware provides the necessary SATA PHY controls
249  * to support ATA_FLAG_SATA_RESET.  However, it is currently
250  * necessary to disable that flag, to solve misdetection problems.
251  * See http://bugme.osdl.org/show_bug.cgi?id=3352 for more info.
252  *
253  * This problem really needs to be investigated further.  But in the
254  * meantime, we avoid ATA_FLAG_SATA_RESET to get people working.
255  */
256 static struct ata_port_info nv_port_info = {
257         .sht            = &nv_sht,
258         .host_flags     = ATA_FLAG_SATA |
259                           /* ATA_FLAG_SATA_RESET | */
260                           ATA_FLAG_SRST |
261                           ATA_FLAG_NO_LEGACY,
262         .pio_mask       = NV_PIO_MASK,
263         .mwdma_mask     = NV_MWDMA_MASK,
264         .udma_mask      = NV_UDMA_MASK,
265         .port_ops       = &nv_ops,
266 };
267
268 MODULE_AUTHOR("NVIDIA");
269 MODULE_DESCRIPTION("low-level driver for NVIDIA nForce SATA controller");
270 MODULE_LICENSE("GPL");
271 MODULE_DEVICE_TABLE(pci, nv_pci_tbl);
272 MODULE_VERSION(DRV_VERSION);
273
274 static irqreturn_t nv_interrupt (int irq, void *dev_instance,
275                                  struct pt_regs *regs)
276 {
277         struct ata_host_set *host_set = dev_instance;
278         struct nv_host *host = host_set->private_data;
279         unsigned int i;
280         unsigned int handled = 0;
281         unsigned long flags;
282
283         spin_lock_irqsave(&host_set->lock, flags);
284
285         for (i = 0; i < host_set->n_ports; i++) {
286                 struct ata_port *ap;
287
288                 ap = host_set->ports[i];
289                 if (ap &&
290                     !(ap->flags & ATA_FLAG_DISABLED)) {
291                         struct ata_queued_cmd *qc;
292
293                         qc = ata_qc_from_tag(ap, ap->active_tag);
294                         if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
295                                 handled += ata_host_intr(ap, qc);
296                         else
297                                 // No request pending?  Clear interrupt status
298                                 // anyway, in case there's one pending.
299                                 ap->ops->check_status(ap);
300                 }
301
302         }
303
304         if (host->host_desc->check_hotplug)
305                 handled += host->host_desc->check_hotplug(host_set);
306
307         spin_unlock_irqrestore(&host_set->lock, flags);
308
309         return IRQ_RETVAL(handled);
310 }
311
312 static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
313 {
314         if (sc_reg > SCR_CONTROL)
315                 return 0xffffffffU;
316
317         return ioread32((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
318 }
319
320 static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
321 {
322         if (sc_reg > SCR_CONTROL)
323                 return;
324
325         iowrite32(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
326 }
327
328 static void nv_host_stop (struct ata_host_set *host_set)
329 {
330         struct nv_host *host = host_set->private_data;
331
332         // Disable hotplug event interrupts.
333         if (host->host_desc->disable_hotplug)
334                 host->host_desc->disable_hotplug(host_set);
335
336         kfree(host);
337
338         ata_pci_host_stop(host_set);
339 }
340
341 static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
342 {
343         static int printed_version = 0;
344         struct nv_host *host;
345         struct ata_port_info *ppi;
346         struct ata_probe_ent *probe_ent;
347         int pci_dev_busy = 0;
348         int rc;
349         u32 bar;
350         unsigned long base;
351
352         // Make sure this is a SATA controller by counting the number of bars
353         // (NVIDIA SATA controllers will always have six bars).  Otherwise,
354         // it's an IDE controller and we ignore it.
355         for (bar=0; bar<6; bar++)
356                 if (pci_resource_start(pdev, bar) == 0)
357                         return -ENODEV;
358
359         if (!printed_version++)
360                 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
361
362         rc = pci_enable_device(pdev);
363         if (rc)
364                 goto err_out;
365
366         rc = pci_request_regions(pdev, DRV_NAME);
367         if (rc) {
368                 pci_dev_busy = 1;
369                 goto err_out_disable;
370         }
371
372         rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
373         if (rc)
374                 goto err_out_regions;
375         rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
376         if (rc)
377                 goto err_out_regions;
378
379         rc = -ENOMEM;
380
381         ppi = &nv_port_info;
382         probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
383         if (!probe_ent)
384                 goto err_out_regions;
385
386         host = kmalloc(sizeof(struct nv_host), GFP_KERNEL);
387         if (!host)
388                 goto err_out_free_ent;
389
390         memset(host, 0, sizeof(struct nv_host));
391         host->host_desc = &nv_device_tbl[ent->driver_data];
392
393         probe_ent->private_data = host;
394
395         probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
396         if (!probe_ent->mmio_base) {
397                 rc = -EIO;
398                 goto err_out_free_host;
399         }
400
401         base = (unsigned long)probe_ent->mmio_base;
402
403         probe_ent->port[0].scr_addr = base + NV_PORT0_SCR_REG_OFFSET;
404         probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET;
405
406         pci_set_master(pdev);
407
408         rc = ata_device_add(probe_ent);
409         if (rc != NV_PORTS)
410                 goto err_out_iounmap;
411
412         // Enable hotplug event interrupts.
413         if (host->host_desc->enable_hotplug)
414                 host->host_desc->enable_hotplug(probe_ent);
415
416         kfree(probe_ent);
417
418         return 0;
419
420 err_out_iounmap:
421         pci_iounmap(pdev, probe_ent->mmio_base);
422 err_out_free_host:
423         kfree(host);
424 err_out_free_ent:
425         kfree(probe_ent);
426 err_out_regions:
427         pci_release_regions(pdev);
428 err_out_disable:
429         if (!pci_dev_busy)
430                 pci_disable_device(pdev);
431 err_out:
432         return rc;
433 }
434
435 static void nv_enable_hotplug(struct ata_probe_ent *probe_ent)
436 {
437         u8 intr_mask;
438
439         outb(NV_INT_STATUS_HOTPLUG,
440                 probe_ent->port[0].scr_addr + NV_INT_STATUS);
441
442         intr_mask = inb(probe_ent->port[0].scr_addr + NV_INT_ENABLE);
443         intr_mask |= NV_INT_ENABLE_HOTPLUG;
444
445         outb(intr_mask, probe_ent->port[0].scr_addr + NV_INT_ENABLE);
446 }
447
448 static void nv_disable_hotplug(struct ata_host_set *host_set)
449 {
450         u8 intr_mask;
451
452         intr_mask = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
453
454         intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
455
456         outb(intr_mask, host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
457 }
458
459 static int nv_check_hotplug(struct ata_host_set *host_set)
460 {
461         u8 intr_status;
462
463         intr_status = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
464
465         // Clear interrupt status.
466         outb(0xff, host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
467
468         if (intr_status & NV_INT_STATUS_HOTPLUG) {
469                 if (intr_status & NV_INT_STATUS_PDEV_ADDED)
470                         printk(KERN_WARNING "nv_sata: "
471                                 "Primary device added\n");
472
473                 if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
474                         printk(KERN_WARNING "nv_sata: "
475                                 "Primary device removed\n");
476
477                 if (intr_status & NV_INT_STATUS_SDEV_ADDED)
478                         printk(KERN_WARNING "nv_sata: "
479                                 "Secondary device added\n");
480
481                 if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
482                         printk(KERN_WARNING "nv_sata: "
483                                 "Secondary device removed\n");
484
485                 return 1;
486         }
487
488         return 0;
489 }
490
491 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
492 {
493         struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
494         u8 intr_mask;
495         u8 regval;
496
497         pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
498         regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
499         pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
500
501         writeb(NV_INT_STATUS_HOTPLUG, probe_ent->mmio_base + NV_INT_STATUS_CK804);
502
503         intr_mask = readb(probe_ent->mmio_base + NV_INT_ENABLE_CK804);
504         intr_mask |= NV_INT_ENABLE_HOTPLUG;
505
506         writeb(intr_mask, probe_ent->mmio_base + NV_INT_ENABLE_CK804);
507 }
508
509 static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
510 {
511         struct pci_dev *pdev = to_pci_dev(host_set->dev);
512         u8 intr_mask;
513         u8 regval;
514
515         intr_mask = readb(host_set->mmio_base + NV_INT_ENABLE_CK804);
516
517         intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
518
519         writeb(intr_mask, host_set->mmio_base + NV_INT_ENABLE_CK804);
520
521         pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
522         regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
523         pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
524 }
525
526 static int nv_check_hotplug_ck804(struct ata_host_set *host_set)
527 {
528         u8 intr_status;
529
530         intr_status = readb(host_set->mmio_base + NV_INT_STATUS_CK804);
531
532         // Clear interrupt status.
533         writeb(0xff, host_set->mmio_base + NV_INT_STATUS_CK804);
534
535         if (intr_status & NV_INT_STATUS_HOTPLUG) {
536                 if (intr_status & NV_INT_STATUS_PDEV_ADDED)
537                         printk(KERN_WARNING "nv_sata: "
538                                 "Primary device added\n");
539
540                 if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
541                         printk(KERN_WARNING "nv_sata: "
542                                 "Primary device removed\n");
543
544                 if (intr_status & NV_INT_STATUS_SDEV_ADDED)
545                         printk(KERN_WARNING "nv_sata: "
546                                 "Secondary device added\n");
547
548                 if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
549                         printk(KERN_WARNING "nv_sata: "
550                                 "Secondary device removed\n");
551
552                 return 1;
553         }
554
555         return 0;
556 }
557
558 static int __init nv_init(void)
559 {
560         return pci_module_init(&nv_pci_driver);
561 }
562
563 static void __exit nv_exit(void)
564 {
565         pci_unregister_driver(&nv_pci_driver);
566 }
567
568 module_init(nv_init);
569 module_exit(nv_exit);