blob: 9b9142790bd616c22c2af8aca3304b773c5f73e4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sata_nv.c - NVIDIA nForce SATA
3 *
4 * Copyright 2004 NVIDIA Corp. All rights reserved.
5 * Copyright 2004 Andrew Chew
6 *
7 * The contents of this file are subject to the Open
8 * Software License version 1.1 that can be found at
9 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
10 * by reference.
11 *
12 * Alternatively, the contents of this file may be used under the terms
13 * of the GNU General Public License version 2 (the "GPL") as distributed
14 * in the kernel source COPYING file, in which case the provisions of
15 * the GPL are applicable instead of the above. If you wish to allow
16 * the use of your version of this file only under the terms of the
17 * GPL and not to allow others to use your version of this file under
18 * the OSL, indicate your decision by deleting the provisions above and
19 * replace them with the notice and other provisions required by the GPL.
20 * If you do not delete the provisions above, a recipient may use your
21 * version of this file under either the OSL or the GPL.
22 *
Daniel Drake541134c2005-07-03 13:44:39 +010023 * 0.08
24 * - Added support for MCP51 and MCP55.
25 *
26 * 0.07
27 * - Added support for RAID class code.
28 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 * 0.06
30 * - Added generic SATA support by using a pci_device_id that filters on
31 * the IDE storage class code.
32 *
33 * 0.03
34 * - Fixed a bug where the hotplug handlers for non-CK804/MCP04 were using
35 * mmio_base, which is only set for the CK804/MCP04 case.
36 *
37 * 0.02
38 * - Added support for CK804 SATA controller.
39 *
40 * 0.01
41 * - Initial revision.
42 */
43
44#include <linux/config.h>
45#include <linux/kernel.h>
46#include <linux/module.h>
47#include <linux/pci.h>
48#include <linux/init.h>
49#include <linux/blkdev.h>
50#include <linux/delay.h>
51#include <linux/interrupt.h>
52#include "scsi.h"
53#include <scsi/scsi_host.h>
54#include <linux/libata.h>
55
56#define DRV_NAME "sata_nv"
Daniel Drake541134c2005-07-03 13:44:39 +010057#define DRV_VERSION "0.8"
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59#define NV_PORTS 2
60#define NV_PIO_MASK 0x1f
61#define NV_MWDMA_MASK 0x07
62#define NV_UDMA_MASK 0x7f
63#define NV_PORT0_SCR_REG_OFFSET 0x00
64#define NV_PORT1_SCR_REG_OFFSET 0x40
65
66#define NV_INT_STATUS 0x10
67#define NV_INT_STATUS_CK804 0x440
68#define NV_INT_STATUS_PDEV_INT 0x01
69#define NV_INT_STATUS_PDEV_PM 0x02
70#define NV_INT_STATUS_PDEV_ADDED 0x04
71#define NV_INT_STATUS_PDEV_REMOVED 0x08
72#define NV_INT_STATUS_SDEV_INT 0x10
73#define NV_INT_STATUS_SDEV_PM 0x20
74#define NV_INT_STATUS_SDEV_ADDED 0x40
75#define NV_INT_STATUS_SDEV_REMOVED 0x80
76#define NV_INT_STATUS_PDEV_HOTPLUG (NV_INT_STATUS_PDEV_ADDED | \
77 NV_INT_STATUS_PDEV_REMOVED)
78#define NV_INT_STATUS_SDEV_HOTPLUG (NV_INT_STATUS_SDEV_ADDED | \
79 NV_INT_STATUS_SDEV_REMOVED)
80#define NV_INT_STATUS_HOTPLUG (NV_INT_STATUS_PDEV_HOTPLUG | \
81 NV_INT_STATUS_SDEV_HOTPLUG)
82
83#define NV_INT_ENABLE 0x11
84#define NV_INT_ENABLE_CK804 0x441
85#define NV_INT_ENABLE_PDEV_MASK 0x01
86#define NV_INT_ENABLE_PDEV_PM 0x02
87#define NV_INT_ENABLE_PDEV_ADDED 0x04
88#define NV_INT_ENABLE_PDEV_REMOVED 0x08
89#define NV_INT_ENABLE_SDEV_MASK 0x10
90#define NV_INT_ENABLE_SDEV_PM 0x20
91#define NV_INT_ENABLE_SDEV_ADDED 0x40
92#define NV_INT_ENABLE_SDEV_REMOVED 0x80
93#define NV_INT_ENABLE_PDEV_HOTPLUG (NV_INT_ENABLE_PDEV_ADDED | \
94 NV_INT_ENABLE_PDEV_REMOVED)
95#define NV_INT_ENABLE_SDEV_HOTPLUG (NV_INT_ENABLE_SDEV_ADDED | \
96 NV_INT_ENABLE_SDEV_REMOVED)
97#define NV_INT_ENABLE_HOTPLUG (NV_INT_ENABLE_PDEV_HOTPLUG | \
98 NV_INT_ENABLE_SDEV_HOTPLUG)
99
100#define NV_INT_CONFIG 0x12
101#define NV_INT_CONFIG_METHD 0x01 // 0 = INT, 1 = SMI
102
103// For PCI config register 20
104#define NV_MCP_SATA_CFG_20 0x50
105#define NV_MCP_SATA_CFG_20_SATA_SPACE_EN 0x04
106
107static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
108static irqreturn_t nv_interrupt (int irq, void *dev_instance,
109 struct pt_regs *regs);
110static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg);
111static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
112static void nv_host_stop (struct ata_host_set *host_set);
113static void nv_enable_hotplug(struct ata_probe_ent *probe_ent);
114static void nv_disable_hotplug(struct ata_host_set *host_set);
115static void nv_check_hotplug(struct ata_host_set *host_set);
116static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent);
117static void nv_disable_hotplug_ck804(struct ata_host_set *host_set);
118static void nv_check_hotplug_ck804(struct ata_host_set *host_set);
119
120enum nv_host_type
121{
122 GENERIC,
123 NFORCE2,
124 NFORCE3,
Daniel Drake541134c2005-07-03 13:44:39 +0100125 CK804,
126 MCP51,
127 MCP55
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128};
129
130static struct pci_device_id nv_pci_tbl[] = {
131 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
133 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
134 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
135 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,
136 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
137 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA,
138 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
139 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2,
140 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
141 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA,
142 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
143 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2,
144 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
Daniel Drake541134c2005-07-03 13:44:39 +0100145 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA,
146 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP51 },
147 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2,
148 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP51 },
149 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA,
150 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP55 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
152 PCI_ANY_ID, PCI_ANY_ID,
153 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
Daniel Drake541134c2005-07-03 13:44:39 +0100154 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
155 PCI_ANY_ID, PCI_ANY_ID,
156 PCI_CLASS_STORAGE_RAID<<8, 0xffff00, GENERIC },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 { 0, } /* terminate list */
158};
159
160#define NV_HOST_FLAGS_SCR_MMIO 0x00000001
161
162struct nv_host_desc
163{
164 enum nv_host_type host_type;
165 void (*enable_hotplug)(struct ata_probe_ent *probe_ent);
166 void (*disable_hotplug)(struct ata_host_set *host_set);
167 void (*check_hotplug)(struct ata_host_set *host_set);
168
169};
170static struct nv_host_desc nv_device_tbl[] = {
171 {
172 .host_type = GENERIC,
173 .enable_hotplug = NULL,
174 .disable_hotplug= NULL,
175 .check_hotplug = NULL,
176 },
177 {
178 .host_type = NFORCE2,
179 .enable_hotplug = nv_enable_hotplug,
180 .disable_hotplug= nv_disable_hotplug,
181 .check_hotplug = nv_check_hotplug,
182 },
183 {
184 .host_type = NFORCE3,
185 .enable_hotplug = nv_enable_hotplug,
186 .disable_hotplug= nv_disable_hotplug,
187 .check_hotplug = nv_check_hotplug,
188 },
189 { .host_type = CK804,
190 .enable_hotplug = nv_enable_hotplug_ck804,
191 .disable_hotplug= nv_disable_hotplug_ck804,
192 .check_hotplug = nv_check_hotplug_ck804,
193 },
194};
195
196struct nv_host
197{
198 struct nv_host_desc *host_desc;
199 unsigned long host_flags;
200};
201
202static struct pci_driver nv_pci_driver = {
203 .name = DRV_NAME,
204 .id_table = nv_pci_tbl,
205 .probe = nv_init_one,
206 .remove = ata_pci_remove_one,
207};
208
209static Scsi_Host_Template nv_sht = {
210 .module = THIS_MODULE,
211 .name = DRV_NAME,
212 .ioctl = ata_scsi_ioctl,
213 .queuecommand = ata_scsi_queuecmd,
214 .eh_strategy_handler = ata_scsi_error,
215 .can_queue = ATA_DEF_QUEUE,
216 .this_id = ATA_SHT_THIS_ID,
217 .sg_tablesize = LIBATA_MAX_PRD,
218 .max_sectors = ATA_MAX_SECTORS,
219 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
220 .emulated = ATA_SHT_EMULATED,
221 .use_clustering = ATA_SHT_USE_CLUSTERING,
222 .proc_name = DRV_NAME,
223 .dma_boundary = ATA_DMA_BOUNDARY,
224 .slave_configure = ata_scsi_slave_config,
225 .bios_param = ata_std_bios_param,
226 .ordered_flush = 1,
227};
228
229static struct ata_port_operations nv_ops = {
230 .port_disable = ata_port_disable,
231 .tf_load = ata_tf_load,
232 .tf_read = ata_tf_read,
233 .exec_command = ata_exec_command,
234 .check_status = ata_check_status,
235 .dev_select = ata_std_dev_select,
236 .phy_reset = sata_phy_reset,
237 .bmdma_setup = ata_bmdma_setup,
238 .bmdma_start = ata_bmdma_start,
239 .bmdma_stop = ata_bmdma_stop,
240 .bmdma_status = ata_bmdma_status,
241 .qc_prep = ata_qc_prep,
242 .qc_issue = ata_qc_issue_prot,
243 .eng_timeout = ata_eng_timeout,
244 .irq_handler = nv_interrupt,
245 .irq_clear = ata_bmdma_irq_clear,
246 .scr_read = nv_scr_read,
247 .scr_write = nv_scr_write,
248 .port_start = ata_port_start,
249 .port_stop = ata_port_stop,
250 .host_stop = nv_host_stop,
251};
252
253/* FIXME: The hardware provides the necessary SATA PHY controls
254 * to support ATA_FLAG_SATA_RESET. However, it is currently
255 * necessary to disable that flag, to solve misdetection problems.
256 * See http://bugme.osdl.org/show_bug.cgi?id=3352 for more info.
257 *
258 * This problem really needs to be investigated further. But in the
259 * meantime, we avoid ATA_FLAG_SATA_RESET to get people working.
260 */
261static struct ata_port_info nv_port_info = {
262 .sht = &nv_sht,
263 .host_flags = ATA_FLAG_SATA |
264 /* ATA_FLAG_SATA_RESET | */
265 ATA_FLAG_SRST |
266 ATA_FLAG_NO_LEGACY,
267 .pio_mask = NV_PIO_MASK,
268 .mwdma_mask = NV_MWDMA_MASK,
269 .udma_mask = NV_UDMA_MASK,
270 .port_ops = &nv_ops,
271};
272
273MODULE_AUTHOR("NVIDIA");
274MODULE_DESCRIPTION("low-level driver for NVIDIA nForce SATA controller");
275MODULE_LICENSE("GPL");
276MODULE_DEVICE_TABLE(pci, nv_pci_tbl);
277MODULE_VERSION(DRV_VERSION);
278
279static irqreturn_t nv_interrupt (int irq, void *dev_instance,
280 struct pt_regs *regs)
281{
282 struct ata_host_set *host_set = dev_instance;
283 struct nv_host *host = host_set->private_data;
284 unsigned int i;
285 unsigned int handled = 0;
286 unsigned long flags;
287
288 spin_lock_irqsave(&host_set->lock, flags);
289
290 for (i = 0; i < host_set->n_ports; i++) {
291 struct ata_port *ap;
292
293 ap = host_set->ports[i];
294 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) {
295 struct ata_queued_cmd *qc;
296
297 qc = ata_qc_from_tag(ap, ap->active_tag);
298 if (qc && (!(qc->tf.ctl & ATA_NIEN)))
299 handled += ata_host_intr(ap, qc);
300 }
301
302 }
303
304 if (host->host_desc->check_hotplug)
305 host->host_desc->check_hotplug(host_set);
306
307 spin_unlock_irqrestore(&host_set->lock, flags);
308
309 return IRQ_RETVAL(handled);
310}
311
312static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
313{
314 struct ata_host_set *host_set = ap->host_set;
315 struct nv_host *host = host_set->private_data;
316
317 if (sc_reg > SCR_CONTROL)
318 return 0xffffffffU;
319
320 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
321 return readl((void*)ap->ioaddr.scr_addr + (sc_reg * 4));
322 else
323 return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
324}
325
326static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
327{
328 struct ata_host_set *host_set = ap->host_set;
329 struct nv_host *host = host_set->private_data;
330
331 if (sc_reg > SCR_CONTROL)
332 return;
333
334 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
335 writel(val, (void*)ap->ioaddr.scr_addr + (sc_reg * 4));
336 else
337 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
338}
339
340static void nv_host_stop (struct ata_host_set *host_set)
341{
342 struct nv_host *host = host_set->private_data;
343
344 // Disable hotplug event interrupts.
345 if (host->host_desc->disable_hotplug)
346 host->host_desc->disable_hotplug(host_set);
347
348 kfree(host);
Jeff Garzikaa8f0dc2005-05-26 21:54:27 -0400349
350 ata_host_stop(host_set);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351}
352
353static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
354{
355 static int printed_version = 0;
356 struct nv_host *host;
357 struct ata_port_info *ppi;
358 struct ata_probe_ent *probe_ent;
359 int pci_dev_busy = 0;
360 int rc;
361 u32 bar;
362
363 // Make sure this is a SATA controller by counting the number of bars
364 // (NVIDIA SATA controllers will always have six bars). Otherwise,
365 // it's an IDE controller and we ignore it.
366 for (bar=0; bar<6; bar++)
367 if (pci_resource_start(pdev, bar) == 0)
368 return -ENODEV;
369
370 if (!printed_version++)
371 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
372
373 rc = pci_enable_device(pdev);
374 if (rc)
375 goto err_out;
376
377 rc = pci_request_regions(pdev, DRV_NAME);
378 if (rc) {
379 pci_dev_busy = 1;
380 goto err_out_disable;
381 }
382
383 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
384 if (rc)
385 goto err_out_regions;
386 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
387 if (rc)
388 goto err_out_regions;
389
390 rc = -ENOMEM;
391
392 ppi = &nv_port_info;
393 probe_ent = ata_pci_init_native_mode(pdev, &ppi);
394 if (!probe_ent)
395 goto err_out_regions;
396
397 host = kmalloc(sizeof(struct nv_host), GFP_KERNEL);
398 if (!host)
399 goto err_out_free_ent;
400
401 memset(host, 0, sizeof(struct nv_host));
402 host->host_desc = &nv_device_tbl[ent->driver_data];
403
404 probe_ent->private_data = host;
405
406 if (pci_resource_flags(pdev, 5) & IORESOURCE_MEM)
407 host->host_flags |= NV_HOST_FLAGS_SCR_MMIO;
408
409 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) {
410 unsigned long base;
411
412 probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5),
413 pci_resource_len(pdev, 5));
414 if (probe_ent->mmio_base == NULL) {
415 rc = -EIO;
416 goto err_out_free_host;
417 }
418
419 base = (unsigned long)probe_ent->mmio_base;
420
421 probe_ent->port[0].scr_addr =
422 base + NV_PORT0_SCR_REG_OFFSET;
423 probe_ent->port[1].scr_addr =
424 base + NV_PORT1_SCR_REG_OFFSET;
425 } else {
426
427 probe_ent->port[0].scr_addr =
428 pci_resource_start(pdev, 5) | NV_PORT0_SCR_REG_OFFSET;
429 probe_ent->port[1].scr_addr =
430 pci_resource_start(pdev, 5) | NV_PORT1_SCR_REG_OFFSET;
431 }
432
433 pci_set_master(pdev);
434
435 rc = ata_device_add(probe_ent);
436 if (rc != NV_PORTS)
437 goto err_out_iounmap;
438
439 // Enable hotplug event interrupts.
440 if (host->host_desc->enable_hotplug)
441 host->host_desc->enable_hotplug(probe_ent);
442
443 kfree(probe_ent);
444
445 return 0;
446
447err_out_iounmap:
448 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
449 iounmap(probe_ent->mmio_base);
450err_out_free_host:
451 kfree(host);
452err_out_free_ent:
453 kfree(probe_ent);
454err_out_regions:
455 pci_release_regions(pdev);
456err_out_disable:
457 if (!pci_dev_busy)
458 pci_disable_device(pdev);
459err_out:
460 return rc;
461}
462
463static void nv_enable_hotplug(struct ata_probe_ent *probe_ent)
464{
465 u8 intr_mask;
466
467 outb(NV_INT_STATUS_HOTPLUG,
468 probe_ent->port[0].scr_addr + NV_INT_STATUS);
469
470 intr_mask = inb(probe_ent->port[0].scr_addr + NV_INT_ENABLE);
471 intr_mask |= NV_INT_ENABLE_HOTPLUG;
472
473 outb(intr_mask, probe_ent->port[0].scr_addr + NV_INT_ENABLE);
474}
475
476static void nv_disable_hotplug(struct ata_host_set *host_set)
477{
478 u8 intr_mask;
479
480 intr_mask = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
481
482 intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
483
484 outb(intr_mask, host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
485}
486
487static void nv_check_hotplug(struct ata_host_set *host_set)
488{
489 u8 intr_status;
490
491 intr_status = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
492
493 // Clear interrupt status.
494 outb(0xff, host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
495
496 if (intr_status & NV_INT_STATUS_HOTPLUG) {
497 if (intr_status & NV_INT_STATUS_PDEV_ADDED)
498 printk(KERN_WARNING "nv_sata: "
499 "Primary device added\n");
500
501 if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
502 printk(KERN_WARNING "nv_sata: "
503 "Primary device removed\n");
504
505 if (intr_status & NV_INT_STATUS_SDEV_ADDED)
506 printk(KERN_WARNING "nv_sata: "
507 "Secondary device added\n");
508
509 if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
510 printk(KERN_WARNING "nv_sata: "
511 "Secondary device removed\n");
512 }
513}
514
515static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
516{
517 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
518 u8 intr_mask;
519 u8 regval;
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 writeb(NV_INT_STATUS_HOTPLUG, probe_ent->mmio_base + NV_INT_STATUS_CK804);
526
527 intr_mask = readb(probe_ent->mmio_base + NV_INT_ENABLE_CK804);
528 intr_mask |= NV_INT_ENABLE_HOTPLUG;
529
530 writeb(intr_mask, probe_ent->mmio_base + NV_INT_ENABLE_CK804);
531}
532
533static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
534{
535 struct pci_dev *pdev = to_pci_dev(host_set->dev);
536 u8 intr_mask;
537 u8 regval;
538
539 intr_mask = readb(host_set->mmio_base + NV_INT_ENABLE_CK804);
540
541 intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
542
543 writeb(intr_mask, host_set->mmio_base + NV_INT_ENABLE_CK804);
544
545 pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
546 regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
547 pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
548}
549
550static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
551{
552 u8 intr_status;
553
554 intr_status = readb(host_set->mmio_base + NV_INT_STATUS_CK804);
555
556 // Clear interrupt status.
557 writeb(0xff, host_set->mmio_base + NV_INT_STATUS_CK804);
558
559 if (intr_status & NV_INT_STATUS_HOTPLUG) {
560 if (intr_status & NV_INT_STATUS_PDEV_ADDED)
561 printk(KERN_WARNING "nv_sata: "
562 "Primary device added\n");
563
564 if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
565 printk(KERN_WARNING "nv_sata: "
566 "Primary device removed\n");
567
568 if (intr_status & NV_INT_STATUS_SDEV_ADDED)
569 printk(KERN_WARNING "nv_sata: "
570 "Secondary device added\n");
571
572 if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
573 printk(KERN_WARNING "nv_sata: "
574 "Secondary device removed\n");
575 }
576}
577
578static int __init nv_init(void)
579{
580 return pci_module_init(&nv_pci_driver);
581}
582
583static void __exit nv_exit(void)
584{
585 pci_unregister_driver(&nv_pci_driver);
586}
587
588module_init(nv_init);
589module_exit(nv_exit);