sata_nv.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /*
  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. *
  23. * 0.06
  24. * - Added generic SATA support by using a pci_device_id that filters on
  25. * the IDE storage class code.
  26. *
  27. * 0.03
  28. * - Fixed a bug where the hotplug handlers for non-CK804/MCP04 were using
  29. * mmio_base, which is only set for the CK804/MCP04 case.
  30. *
  31. * 0.02
  32. * - Added support for CK804 SATA controller.
  33. *
  34. * 0.01
  35. * - Initial revision.
  36. */
  37. #include <linux/config.h>
  38. #include <linux/kernel.h>
  39. #include <linux/module.h>
  40. #include <linux/pci.h>
  41. #include <linux/init.h>
  42. #include <linux/blkdev.h>
  43. #include <linux/delay.h>
  44. #include <linux/interrupt.h>
  45. #include "scsi.h"
  46. #include <scsi/scsi_host.h>
  47. #include <linux/libata.h>
  48. #define DRV_NAME "sata_nv"
  49. #define DRV_VERSION "0.6"
  50. #define NV_PORTS 2
  51. #define NV_PIO_MASK 0x1f
  52. #define NV_MWDMA_MASK 0x07
  53. #define NV_UDMA_MASK 0x7f
  54. #define NV_PORT0_SCR_REG_OFFSET 0x00
  55. #define NV_PORT1_SCR_REG_OFFSET 0x40
  56. #define NV_INT_STATUS 0x10
  57. #define NV_INT_STATUS_CK804 0x440
  58. #define NV_INT_STATUS_PDEV_INT 0x01
  59. #define NV_INT_STATUS_PDEV_PM 0x02
  60. #define NV_INT_STATUS_PDEV_ADDED 0x04
  61. #define NV_INT_STATUS_PDEV_REMOVED 0x08
  62. #define NV_INT_STATUS_SDEV_INT 0x10
  63. #define NV_INT_STATUS_SDEV_PM 0x20
  64. #define NV_INT_STATUS_SDEV_ADDED 0x40
  65. #define NV_INT_STATUS_SDEV_REMOVED 0x80
  66. #define NV_INT_STATUS_PDEV_HOTPLUG (NV_INT_STATUS_PDEV_ADDED | \
  67. NV_INT_STATUS_PDEV_REMOVED)
  68. #define NV_INT_STATUS_SDEV_HOTPLUG (NV_INT_STATUS_SDEV_ADDED | \
  69. NV_INT_STATUS_SDEV_REMOVED)
  70. #define NV_INT_STATUS_HOTPLUG (NV_INT_STATUS_PDEV_HOTPLUG | \
  71. NV_INT_STATUS_SDEV_HOTPLUG)
  72. #define NV_INT_ENABLE 0x11
  73. #define NV_INT_ENABLE_CK804 0x441
  74. #define NV_INT_ENABLE_PDEV_MASK 0x01
  75. #define NV_INT_ENABLE_PDEV_PM 0x02
  76. #define NV_INT_ENABLE_PDEV_ADDED 0x04
  77. #define NV_INT_ENABLE_PDEV_REMOVED 0x08
  78. #define NV_INT_ENABLE_SDEV_MASK 0x10
  79. #define NV_INT_ENABLE_SDEV_PM 0x20
  80. #define NV_INT_ENABLE_SDEV_ADDED 0x40
  81. #define NV_INT_ENABLE_SDEV_REMOVED 0x80
  82. #define NV_INT_ENABLE_PDEV_HOTPLUG (NV_INT_ENABLE_PDEV_ADDED | \
  83. NV_INT_ENABLE_PDEV_REMOVED)
  84. #define NV_INT_ENABLE_SDEV_HOTPLUG (NV_INT_ENABLE_SDEV_ADDED | \
  85. NV_INT_ENABLE_SDEV_REMOVED)
  86. #define NV_INT_ENABLE_HOTPLUG (NV_INT_ENABLE_PDEV_HOTPLUG | \
  87. NV_INT_ENABLE_SDEV_HOTPLUG)
  88. #define NV_INT_CONFIG 0x12
  89. #define NV_INT_CONFIG_METHD 0x01 // 0 = INT, 1 = SMI
  90. // For PCI config register 20
  91. #define NV_MCP_SATA_CFG_20 0x50
  92. #define NV_MCP_SATA_CFG_20_SATA_SPACE_EN 0x04
  93. static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
  94. static irqreturn_t nv_interrupt (int irq, void *dev_instance,
  95. struct pt_regs *regs);
  96. static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg);
  97. static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
  98. static void nv_host_stop (struct ata_host_set *host_set);
  99. static void nv_enable_hotplug(struct ata_probe_ent *probe_ent);
  100. static void nv_disable_hotplug(struct ata_host_set *host_set);
  101. static void nv_check_hotplug(struct ata_host_set *host_set);
  102. static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent);
  103. static void nv_disable_hotplug_ck804(struct ata_host_set *host_set);
  104. static void nv_check_hotplug_ck804(struct ata_host_set *host_set);
  105. enum nv_host_type
  106. {
  107. GENERIC,
  108. NFORCE2,
  109. NFORCE3,
  110. CK804
  111. };
  112. static struct pci_device_id nv_pci_tbl[] = {
  113. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
  114. PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
  115. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
  116. PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
  117. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,
  118. PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
  119. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA,
  120. PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
  121. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2,
  122. PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
  123. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA,
  124. PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
  125. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2,
  126. PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
  127. { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
  128. PCI_ANY_ID, PCI_ANY_ID,
  129. PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
  130. { 0, } /* terminate list */
  131. };
  132. #define NV_HOST_FLAGS_SCR_MMIO 0x00000001
  133. struct nv_host_desc
  134. {
  135. enum nv_host_type host_type;
  136. void (*enable_hotplug)(struct ata_probe_ent *probe_ent);
  137. void (*disable_hotplug)(struct ata_host_set *host_set);
  138. void (*check_hotplug)(struct ata_host_set *host_set);
  139. };
  140. static struct nv_host_desc nv_device_tbl[] = {
  141. {
  142. .host_type = GENERIC,
  143. .enable_hotplug = NULL,
  144. .disable_hotplug= NULL,
  145. .check_hotplug = NULL,
  146. },
  147. {
  148. .host_type = NFORCE2,
  149. .enable_hotplug = nv_enable_hotplug,
  150. .disable_hotplug= nv_disable_hotplug,
  151. .check_hotplug = nv_check_hotplug,
  152. },
  153. {
  154. .host_type = NFORCE3,
  155. .enable_hotplug = nv_enable_hotplug,
  156. .disable_hotplug= nv_disable_hotplug,
  157. .check_hotplug = nv_check_hotplug,
  158. },
  159. { .host_type = CK804,
  160. .enable_hotplug = nv_enable_hotplug_ck804,
  161. .disable_hotplug= nv_disable_hotplug_ck804,
  162. .check_hotplug = nv_check_hotplug_ck804,
  163. },
  164. };
  165. struct nv_host
  166. {
  167. struct nv_host_desc *host_desc;
  168. unsigned long host_flags;
  169. };
  170. static struct pci_driver nv_pci_driver = {
  171. .name = DRV_NAME,
  172. .id_table = nv_pci_tbl,
  173. .probe = nv_init_one,
  174. .remove = ata_pci_remove_one,
  175. };
  176. static Scsi_Host_Template nv_sht = {
  177. .module = THIS_MODULE,
  178. .name = DRV_NAME,
  179. .ioctl = ata_scsi_ioctl,
  180. .queuecommand = ata_scsi_queuecmd,
  181. .eh_strategy_handler = ata_scsi_error,
  182. .can_queue = ATA_DEF_QUEUE,
  183. .this_id = ATA_SHT_THIS_ID,
  184. .sg_tablesize = LIBATA_MAX_PRD,
  185. .max_sectors = ATA_MAX_SECTORS,
  186. .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
  187. .emulated = ATA_SHT_EMULATED,
  188. .use_clustering = ATA_SHT_USE_CLUSTERING,
  189. .proc_name = DRV_NAME,
  190. .dma_boundary = ATA_DMA_BOUNDARY,
  191. .slave_configure = ata_scsi_slave_config,
  192. .bios_param = ata_std_bios_param,
  193. .ordered_flush = 1,
  194. };
  195. static struct ata_port_operations nv_ops = {
  196. .port_disable = ata_port_disable,
  197. .tf_load = ata_tf_load,
  198. .tf_read = ata_tf_read,
  199. .exec_command = ata_exec_command,
  200. .check_status = ata_check_status,
  201. .dev_select = ata_std_dev_select,
  202. .phy_reset = sata_phy_reset,
  203. .bmdma_setup = ata_bmdma_setup,
  204. .bmdma_start = ata_bmdma_start,
  205. .bmdma_stop = ata_bmdma_stop,
  206. .bmdma_status = ata_bmdma_status,
  207. .qc_prep = ata_qc_prep,
  208. .qc_issue = ata_qc_issue_prot,
  209. .eng_timeout = ata_eng_timeout,
  210. .irq_handler = nv_interrupt,
  211. .irq_clear = ata_bmdma_irq_clear,
  212. .scr_read = nv_scr_read,
  213. .scr_write = nv_scr_write,
  214. .port_start = ata_port_start,
  215. .port_stop = ata_port_stop,
  216. .host_stop = nv_host_stop,
  217. };
  218. /* FIXME: The hardware provides the necessary SATA PHY controls
  219. * to support ATA_FLAG_SATA_RESET. However, it is currently
  220. * necessary to disable that flag, to solve misdetection problems.
  221. * See http://bugme.osdl.org/show_bug.cgi?id=3352 for more info.
  222. *
  223. * This problem really needs to be investigated further. But in the
  224. * meantime, we avoid ATA_FLAG_SATA_RESET to get people working.
  225. */
  226. static struct ata_port_info nv_port_info = {
  227. .sht = &nv_sht,
  228. .host_flags = ATA_FLAG_SATA |
  229. /* ATA_FLAG_SATA_RESET | */
  230. ATA_FLAG_SRST |
  231. ATA_FLAG_NO_LEGACY,
  232. .pio_mask = NV_PIO_MASK,
  233. .mwdma_mask = NV_MWDMA_MASK,
  234. .udma_mask = NV_UDMA_MASK,
  235. .port_ops = &nv_ops,
  236. };
  237. MODULE_AUTHOR("NVIDIA");
  238. MODULE_DESCRIPTION("low-level driver for NVIDIA nForce SATA controller");
  239. MODULE_LICENSE("GPL");
  240. MODULE_DEVICE_TABLE(pci, nv_pci_tbl);
  241. MODULE_VERSION(DRV_VERSION);
  242. static irqreturn_t nv_interrupt (int irq, void *dev_instance,
  243. struct pt_regs *regs)
  244. {
  245. struct ata_host_set *host_set = dev_instance;
  246. struct nv_host *host = host_set->private_data;
  247. unsigned int i;
  248. unsigned int handled = 0;
  249. unsigned long flags;
  250. spin_lock_irqsave(&host_set->lock, flags);
  251. for (i = 0; i < host_set->n_ports; i++) {
  252. struct ata_port *ap;
  253. ap = host_set->ports[i];
  254. if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) {
  255. struct ata_queued_cmd *qc;
  256. qc = ata_qc_from_tag(ap, ap->active_tag);
  257. if (qc && (!(qc->tf.ctl & ATA_NIEN)))
  258. handled += ata_host_intr(ap, qc);
  259. }
  260. }
  261. if (host->host_desc->check_hotplug)
  262. host->host_desc->check_hotplug(host_set);
  263. spin_unlock_irqrestore(&host_set->lock, flags);
  264. return IRQ_RETVAL(handled);
  265. }
  266. static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
  267. {
  268. struct ata_host_set *host_set = ap->host_set;
  269. struct nv_host *host = host_set->private_data;
  270. if (sc_reg > SCR_CONTROL)
  271. return 0xffffffffU;
  272. if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
  273. return readl((void*)ap->ioaddr.scr_addr + (sc_reg * 4));
  274. else
  275. return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
  276. }
  277. static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
  278. {
  279. struct ata_host_set *host_set = ap->host_set;
  280. struct nv_host *host = host_set->private_data;
  281. if (sc_reg > SCR_CONTROL)
  282. return;
  283. if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
  284. writel(val, (void*)ap->ioaddr.scr_addr + (sc_reg * 4));
  285. else
  286. outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
  287. }
  288. static void nv_host_stop (struct ata_host_set *host_set)
  289. {
  290. struct nv_host *host = host_set->private_data;
  291. // Disable hotplug event interrupts.
  292. if (host->host_desc->disable_hotplug)
  293. host->host_desc->disable_hotplug(host_set);
  294. kfree(host);
  295. ata_host_stop(host_set);
  296. }
  297. static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  298. {
  299. static int printed_version = 0;
  300. struct nv_host *host;
  301. struct ata_port_info *ppi;
  302. struct ata_probe_ent *probe_ent;
  303. int pci_dev_busy = 0;
  304. int rc;
  305. u32 bar;
  306. // Make sure this is a SATA controller by counting the number of bars
  307. // (NVIDIA SATA controllers will always have six bars). Otherwise,
  308. // it's an IDE controller and we ignore it.
  309. for (bar=0; bar<6; bar++)
  310. if (pci_resource_start(pdev, bar) == 0)
  311. return -ENODEV;
  312. if (!printed_version++)
  313. printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
  314. rc = pci_enable_device(pdev);
  315. if (rc)
  316. goto err_out;
  317. rc = pci_request_regions(pdev, DRV_NAME);
  318. if (rc) {
  319. pci_dev_busy = 1;
  320. goto err_out_disable;
  321. }
  322. rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
  323. if (rc)
  324. goto err_out_regions;
  325. rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
  326. if (rc)
  327. goto err_out_regions;
  328. rc = -ENOMEM;
  329. ppi = &nv_port_info;
  330. probe_ent = ata_pci_init_native_mode(pdev, &ppi);
  331. if (!probe_ent)
  332. goto err_out_regions;
  333. host = kmalloc(sizeof(struct nv_host), GFP_KERNEL);
  334. if (!host)
  335. goto err_out_free_ent;
  336. memset(host, 0, sizeof(struct nv_host));
  337. host->host_desc = &nv_device_tbl[ent->driver_data];
  338. probe_ent->private_data = host;
  339. if (pci_resource_flags(pdev, 5) & IORESOURCE_MEM)
  340. host->host_flags |= NV_HOST_FLAGS_SCR_MMIO;
  341. if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) {
  342. unsigned long base;
  343. probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5),
  344. pci_resource_len(pdev, 5));
  345. if (probe_ent->mmio_base == NULL) {
  346. rc = -EIO;
  347. goto err_out_free_host;
  348. }
  349. base = (unsigned long)probe_ent->mmio_base;
  350. probe_ent->port[0].scr_addr =
  351. base + NV_PORT0_SCR_REG_OFFSET;
  352. probe_ent->port[1].scr_addr =
  353. base + NV_PORT1_SCR_REG_OFFSET;
  354. } else {
  355. probe_ent->port[0].scr_addr =
  356. pci_resource_start(pdev, 5) | NV_PORT0_SCR_REG_OFFSET;
  357. probe_ent->port[1].scr_addr =
  358. pci_resource_start(pdev, 5) | NV_PORT1_SCR_REG_OFFSET;
  359. }
  360. pci_set_master(pdev);
  361. rc = ata_device_add(probe_ent);
  362. if (rc != NV_PORTS)
  363. goto err_out_iounmap;
  364. // Enable hotplug event interrupts.
  365. if (host->host_desc->enable_hotplug)
  366. host->host_desc->enable_hotplug(probe_ent);
  367. kfree(probe_ent);
  368. return 0;
  369. err_out_iounmap:
  370. if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
  371. iounmap(probe_ent->mmio_base);
  372. err_out_free_host:
  373. kfree(host);
  374. err_out_free_ent:
  375. kfree(probe_ent);
  376. err_out_regions:
  377. pci_release_regions(pdev);
  378. err_out_disable:
  379. if (!pci_dev_busy)
  380. pci_disable_device(pdev);
  381. err_out:
  382. return rc;
  383. }
  384. static void nv_enable_hotplug(struct ata_probe_ent *probe_ent)
  385. {
  386. u8 intr_mask;
  387. outb(NV_INT_STATUS_HOTPLUG,
  388. probe_ent->port[0].scr_addr + NV_INT_STATUS);
  389. intr_mask = inb(probe_ent->port[0].scr_addr + NV_INT_ENABLE);
  390. intr_mask |= NV_INT_ENABLE_HOTPLUG;
  391. outb(intr_mask, probe_ent->port[0].scr_addr + NV_INT_ENABLE);
  392. }
  393. static void nv_disable_hotplug(struct ata_host_set *host_set)
  394. {
  395. u8 intr_mask;
  396. intr_mask = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
  397. intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
  398. outb(intr_mask, host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
  399. }
  400. static void nv_check_hotplug(struct ata_host_set *host_set)
  401. {
  402. u8 intr_status;
  403. intr_status = inb(host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
  404. // Clear interrupt status.
  405. outb(0xff, host_set->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
  406. if (intr_status & NV_INT_STATUS_HOTPLUG) {
  407. if (intr_status & NV_INT_STATUS_PDEV_ADDED)
  408. printk(KERN_WARNING "nv_sata: "
  409. "Primary device added\n");
  410. if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
  411. printk(KERN_WARNING "nv_sata: "
  412. "Primary device removed\n");
  413. if (intr_status & NV_INT_STATUS_SDEV_ADDED)
  414. printk(KERN_WARNING "nv_sata: "
  415. "Secondary device added\n");
  416. if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
  417. printk(KERN_WARNING "nv_sata: "
  418. "Secondary device removed\n");
  419. }
  420. }
  421. static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
  422. {
  423. struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
  424. u8 intr_mask;
  425. u8 regval;
  426. pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
  427. regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
  428. pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
  429. writeb(NV_INT_STATUS_HOTPLUG, probe_ent->mmio_base + NV_INT_STATUS_CK804);
  430. intr_mask = readb(probe_ent->mmio_base + NV_INT_ENABLE_CK804);
  431. intr_mask |= NV_INT_ENABLE_HOTPLUG;
  432. writeb(intr_mask, probe_ent->mmio_base + NV_INT_ENABLE_CK804);
  433. }
  434. static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
  435. {
  436. struct pci_dev *pdev = to_pci_dev(host_set->dev);
  437. u8 intr_mask;
  438. u8 regval;
  439. intr_mask = readb(host_set->mmio_base + NV_INT_ENABLE_CK804);
  440. intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
  441. writeb(intr_mask, host_set->mmio_base + NV_INT_ENABLE_CK804);
  442. pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
  443. regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
  444. pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
  445. }
  446. static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
  447. {
  448. u8 intr_status;
  449. intr_status = readb(host_set->mmio_base + NV_INT_STATUS_CK804);
  450. // Clear interrupt status.
  451. writeb(0xff, host_set->mmio_base + NV_INT_STATUS_CK804);
  452. if (intr_status & NV_INT_STATUS_HOTPLUG) {
  453. if (intr_status & NV_INT_STATUS_PDEV_ADDED)
  454. printk(KERN_WARNING "nv_sata: "
  455. "Primary device added\n");
  456. if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
  457. printk(KERN_WARNING "nv_sata: "
  458. "Primary device removed\n");
  459. if (intr_status & NV_INT_STATUS_SDEV_ADDED)
  460. printk(KERN_WARNING "nv_sata: "
  461. "Secondary device added\n");
  462. if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
  463. printk(KERN_WARNING "nv_sata: "
  464. "Secondary device removed\n");
  465. }
  466. }
  467. static int __init nv_init(void)
  468. {
  469. return pci_module_init(&nv_pci_driver);
  470. }
  471. static void __exit nv_exit(void)
  472. {
  473. pci_unregister_driver(&nv_pci_driver);
  474. }
  475. module_init(nv_init);
  476. module_exit(nv_exit);