pm8001_init.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  1. /*
  2. * PMC-Sierra PM8001/8081/8088/8089 SAS/SATA based host adapters driver
  3. *
  4. * Copyright (c) 2008-2009 USI Co., Ltd.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions, and the following disclaimer,
  12. * without modification.
  13. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  14. * substantially similar to the "NO WARRANTY" disclaimer below
  15. * ("Disclaimer") and any redistribution must be conditioned upon
  16. * including a substantially similar Disclaimer requirement for further
  17. * binary redistribution.
  18. * 3. Neither the names of the above-listed copyright holders nor the names
  19. * of any contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * Alternatively, this software may be distributed under the terms of the
  23. * GNU General Public License ("GPL") version 2 as published by the Free
  24. * Software Foundation.
  25. *
  26. * NO WARRANTY
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  30. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  31. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  35. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  36. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGES.
  38. *
  39. */
  40. #include <linux/slab.h>
  41. #include "pm8001_sas.h"
  42. #include "pm8001_chips.h"
  43. static struct scsi_transport_template *pm8001_stt;
  44. /**
  45. * chip info structure to identify chip key functionality as
  46. * encryption available/not, no of ports, hw specific function ref
  47. */
  48. static const struct pm8001_chip_info pm8001_chips[] = {
  49. [chip_8001] = {0, 8, &pm8001_8001_dispatch,},
  50. [chip_8008] = {0, 8, &pm8001_80xx_dispatch,},
  51. [chip_8009] = {1, 8, &pm8001_80xx_dispatch,},
  52. [chip_8018] = {0, 16, &pm8001_80xx_dispatch,},
  53. [chip_8019] = {1, 16, &pm8001_80xx_dispatch,},
  54. };
  55. static int pm8001_id;
  56. LIST_HEAD(hba_list);
  57. struct workqueue_struct *pm8001_wq;
  58. /**
  59. * The main structure which LLDD must register for scsi core.
  60. */
  61. static struct scsi_host_template pm8001_sht = {
  62. .module = THIS_MODULE,
  63. .name = DRV_NAME,
  64. .queuecommand = sas_queuecommand,
  65. .target_alloc = sas_target_alloc,
  66. .slave_configure = sas_slave_configure,
  67. .scan_finished = pm8001_scan_finished,
  68. .scan_start = pm8001_scan_start,
  69. .change_queue_depth = sas_change_queue_depth,
  70. .change_queue_type = sas_change_queue_type,
  71. .bios_param = sas_bios_param,
  72. .can_queue = 1,
  73. .cmd_per_lun = 1,
  74. .this_id = -1,
  75. .sg_tablesize = SG_ALL,
  76. .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
  77. .use_clustering = ENABLE_CLUSTERING,
  78. .eh_device_reset_handler = sas_eh_device_reset_handler,
  79. .eh_bus_reset_handler = sas_eh_bus_reset_handler,
  80. .target_destroy = sas_target_destroy,
  81. .ioctl = sas_ioctl,
  82. .shost_attrs = pm8001_host_attrs,
  83. };
  84. /**
  85. * Sas layer call this function to execute specific task.
  86. */
  87. static struct sas_domain_function_template pm8001_transport_ops = {
  88. .lldd_dev_found = pm8001_dev_found,
  89. .lldd_dev_gone = pm8001_dev_gone,
  90. .lldd_execute_task = pm8001_queue_command,
  91. .lldd_control_phy = pm8001_phy_control,
  92. .lldd_abort_task = pm8001_abort_task,
  93. .lldd_abort_task_set = pm8001_abort_task_set,
  94. .lldd_clear_aca = pm8001_clear_aca,
  95. .lldd_clear_task_set = pm8001_clear_task_set,
  96. .lldd_I_T_nexus_reset = pm8001_I_T_nexus_reset,
  97. .lldd_lu_reset = pm8001_lu_reset,
  98. .lldd_query_task = pm8001_query_task,
  99. };
  100. /**
  101. *pm8001_phy_init - initiate our adapter phys
  102. *@pm8001_ha: our hba structure.
  103. *@phy_id: phy id.
  104. */
  105. static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id)
  106. {
  107. struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
  108. struct asd_sas_phy *sas_phy = &phy->sas_phy;
  109. phy->phy_state = 0;
  110. phy->pm8001_ha = pm8001_ha;
  111. sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0;
  112. sas_phy->class = SAS;
  113. sas_phy->iproto = SAS_PROTOCOL_ALL;
  114. sas_phy->tproto = 0;
  115. sas_phy->type = PHY_TYPE_PHYSICAL;
  116. sas_phy->role = PHY_ROLE_INITIATOR;
  117. sas_phy->oob_mode = OOB_NOT_CONNECTED;
  118. sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN;
  119. sas_phy->id = phy_id;
  120. sas_phy->sas_addr = &pm8001_ha->sas_addr[0];
  121. sas_phy->frame_rcvd = &phy->frame_rcvd[0];
  122. sas_phy->ha = (struct sas_ha_struct *)pm8001_ha->shost->hostdata;
  123. sas_phy->lldd_phy = phy;
  124. }
  125. /**
  126. *pm8001_free - free hba
  127. *@pm8001_ha: our hba structure.
  128. *
  129. */
  130. static void pm8001_free(struct pm8001_hba_info *pm8001_ha)
  131. {
  132. int i;
  133. if (!pm8001_ha)
  134. return;
  135. for (i = 0; i < USI_MAX_MEMCNT; i++) {
  136. if (pm8001_ha->memoryMap.region[i].virt_ptr != NULL) {
  137. pci_free_consistent(pm8001_ha->pdev,
  138. (pm8001_ha->memoryMap.region[i].total_len +
  139. pm8001_ha->memoryMap.region[i].alignment),
  140. pm8001_ha->memoryMap.region[i].virt_ptr,
  141. pm8001_ha->memoryMap.region[i].phys_addr);
  142. }
  143. }
  144. PM8001_CHIP_DISP->chip_iounmap(pm8001_ha);
  145. if (pm8001_ha->shost)
  146. scsi_host_put(pm8001_ha->shost);
  147. flush_workqueue(pm8001_wq);
  148. kfree(pm8001_ha->tags);
  149. kfree(pm8001_ha);
  150. }
  151. #ifdef PM8001_USE_TASKLET
  152. /**
  153. * tasklet for 64 msi-x interrupt handler
  154. * @opaque: the passed general host adapter struct
  155. * Note: pm8001_tasklet is common for pm8001 & pm80xx
  156. */
  157. static void pm8001_tasklet(unsigned long opaque)
  158. {
  159. struct pm8001_hba_info *pm8001_ha;
  160. u32 vec;
  161. pm8001_ha = (struct pm8001_hba_info *)opaque;
  162. if (unlikely(!pm8001_ha))
  163. BUG_ON(1);
  164. vec = pm8001_ha->int_vector;
  165. PM8001_CHIP_DISP->isr(pm8001_ha, vec);
  166. }
  167. #endif
  168. static struct pm8001_hba_info *outq_to_hba(u8 *outq)
  169. {
  170. return container_of((outq - *outq), struct pm8001_hba_info, outq[0]);
  171. }
  172. /**
  173. * pm8001_interrupt_handler_msix - main MSIX interrupt handler.
  174. * It obtains the vector number and calls the equivalent bottom
  175. * half or services directly.
  176. * @opaque: the passed outbound queue/vector. Host structure is
  177. * retrieved from the same.
  178. */
  179. static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque)
  180. {
  181. struct pm8001_hba_info *pm8001_ha = outq_to_hba(opaque);
  182. u8 outq = *(u8 *)opaque;
  183. irqreturn_t ret = IRQ_HANDLED;
  184. if (unlikely(!pm8001_ha))
  185. return IRQ_NONE;
  186. if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha))
  187. return IRQ_NONE;
  188. pm8001_ha->int_vector = outq;
  189. #ifdef PM8001_USE_TASKLET
  190. tasklet_schedule(&pm8001_ha->tasklet);
  191. #else
  192. ret = PM8001_CHIP_DISP->isr(pm8001_ha, outq);
  193. #endif
  194. return ret;
  195. }
  196. /**
  197. * pm8001_interrupt_handler_intx - main INTx interrupt handler.
  198. * @dev_id: sas_ha structure. The HBA is retrieved from sas_has structure.
  199. */
  200. static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)
  201. {
  202. struct pm8001_hba_info *pm8001_ha;
  203. irqreturn_t ret = IRQ_HANDLED;
  204. struct sas_ha_struct *sha = dev_id;
  205. pm8001_ha = sha->lldd_ha;
  206. if (unlikely(!pm8001_ha))
  207. return IRQ_NONE;
  208. if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha))
  209. return IRQ_NONE;
  210. pm8001_ha->int_vector = 0;
  211. #ifdef PM8001_USE_TASKLET
  212. tasklet_schedule(&pm8001_ha->tasklet);
  213. #else
  214. ret = PM8001_CHIP_DISP->isr(pm8001_ha, 0);
  215. #endif
  216. return ret;
  217. }
  218. /**
  219. * pm8001_alloc - initiate our hba structure and 6 DMAs area.
  220. * @pm8001_ha:our hba structure.
  221. *
  222. */
  223. static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
  224. const struct pci_device_id *ent)
  225. {
  226. int i;
  227. spin_lock_init(&pm8001_ha->lock);
  228. PM8001_INIT_DBG(pm8001_ha,
  229. pm8001_printk("pm8001_alloc: PHY:%x\n",
  230. pm8001_ha->chip->n_phy));
  231. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  232. pm8001_phy_init(pm8001_ha, i);
  233. pm8001_ha->port[i].wide_port_phymap = 0;
  234. pm8001_ha->port[i].port_attached = 0;
  235. pm8001_ha->port[i].port_state = 0;
  236. INIT_LIST_HEAD(&pm8001_ha->port[i].list);
  237. }
  238. pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
  239. if (!pm8001_ha->tags)
  240. goto err_out;
  241. /* MPI Memory region 1 for AAP Event Log for fw */
  242. pm8001_ha->memoryMap.region[AAP1].num_elements = 1;
  243. pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE;
  244. pm8001_ha->memoryMap.region[AAP1].total_len = PM8001_EVENT_LOG_SIZE;
  245. pm8001_ha->memoryMap.region[AAP1].alignment = 32;
  246. /* MPI Memory region 2 for IOP Event Log for fw */
  247. pm8001_ha->memoryMap.region[IOP].num_elements = 1;
  248. pm8001_ha->memoryMap.region[IOP].element_size = PM8001_EVENT_LOG_SIZE;
  249. pm8001_ha->memoryMap.region[IOP].total_len = PM8001_EVENT_LOG_SIZE;
  250. pm8001_ha->memoryMap.region[IOP].alignment = 32;
  251. for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) {
  252. /* MPI Memory region 3 for consumer Index of inbound queues */
  253. pm8001_ha->memoryMap.region[CI+i].num_elements = 1;
  254. pm8001_ha->memoryMap.region[CI+i].element_size = 4;
  255. pm8001_ha->memoryMap.region[CI+i].total_len = 4;
  256. pm8001_ha->memoryMap.region[CI+i].alignment = 4;
  257. if ((ent->driver_data) != chip_8001) {
  258. /* MPI Memory region 5 inbound queues */
  259. pm8001_ha->memoryMap.region[IB+i].num_elements =
  260. PM8001_MPI_QUEUE;
  261. pm8001_ha->memoryMap.region[IB+i].element_size = 128;
  262. pm8001_ha->memoryMap.region[IB+i].total_len =
  263. PM8001_MPI_QUEUE * 128;
  264. pm8001_ha->memoryMap.region[IB+i].alignment = 128;
  265. } else {
  266. pm8001_ha->memoryMap.region[IB+i].num_elements =
  267. PM8001_MPI_QUEUE;
  268. pm8001_ha->memoryMap.region[IB+i].element_size = 64;
  269. pm8001_ha->memoryMap.region[IB+i].total_len =
  270. PM8001_MPI_QUEUE * 64;
  271. pm8001_ha->memoryMap.region[IB+i].alignment = 64;
  272. }
  273. }
  274. for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) {
  275. /* MPI Memory region 4 for producer Index of outbound queues */
  276. pm8001_ha->memoryMap.region[PI+i].num_elements = 1;
  277. pm8001_ha->memoryMap.region[PI+i].element_size = 4;
  278. pm8001_ha->memoryMap.region[PI+i].total_len = 4;
  279. pm8001_ha->memoryMap.region[PI+i].alignment = 4;
  280. if (ent->driver_data != chip_8001) {
  281. /* MPI Memory region 6 Outbound queues */
  282. pm8001_ha->memoryMap.region[OB+i].num_elements =
  283. PM8001_MPI_QUEUE;
  284. pm8001_ha->memoryMap.region[OB+i].element_size = 128;
  285. pm8001_ha->memoryMap.region[OB+i].total_len =
  286. PM8001_MPI_QUEUE * 128;
  287. pm8001_ha->memoryMap.region[OB+i].alignment = 128;
  288. } else {
  289. /* MPI Memory region 6 Outbound queues */
  290. pm8001_ha->memoryMap.region[OB+i].num_elements =
  291. PM8001_MPI_QUEUE;
  292. pm8001_ha->memoryMap.region[OB+i].element_size = 64;
  293. pm8001_ha->memoryMap.region[OB+i].total_len =
  294. PM8001_MPI_QUEUE * 64;
  295. pm8001_ha->memoryMap.region[OB+i].alignment = 64;
  296. }
  297. }
  298. /* Memory region write DMA*/
  299. pm8001_ha->memoryMap.region[NVMD].num_elements = 1;
  300. pm8001_ha->memoryMap.region[NVMD].element_size = 4096;
  301. pm8001_ha->memoryMap.region[NVMD].total_len = 4096;
  302. /* Memory region for devices*/
  303. pm8001_ha->memoryMap.region[DEV_MEM].num_elements = 1;
  304. pm8001_ha->memoryMap.region[DEV_MEM].element_size = PM8001_MAX_DEVICES *
  305. sizeof(struct pm8001_device);
  306. pm8001_ha->memoryMap.region[DEV_MEM].total_len = PM8001_MAX_DEVICES *
  307. sizeof(struct pm8001_device);
  308. /* Memory region for ccb_info*/
  309. pm8001_ha->memoryMap.region[CCB_MEM].num_elements = 1;
  310. pm8001_ha->memoryMap.region[CCB_MEM].element_size = PM8001_MAX_CCB *
  311. sizeof(struct pm8001_ccb_info);
  312. pm8001_ha->memoryMap.region[CCB_MEM].total_len = PM8001_MAX_CCB *
  313. sizeof(struct pm8001_ccb_info);
  314. /* Memory region for fw flash */
  315. pm8001_ha->memoryMap.region[FW_FLASH].total_len = 4096;
  316. for (i = 0; i < USI_MAX_MEMCNT; i++) {
  317. if (pm8001_mem_alloc(pm8001_ha->pdev,
  318. &pm8001_ha->memoryMap.region[i].virt_ptr,
  319. &pm8001_ha->memoryMap.region[i].phys_addr,
  320. &pm8001_ha->memoryMap.region[i].phys_addr_hi,
  321. &pm8001_ha->memoryMap.region[i].phys_addr_lo,
  322. pm8001_ha->memoryMap.region[i].total_len,
  323. pm8001_ha->memoryMap.region[i].alignment) != 0) {
  324. PM8001_FAIL_DBG(pm8001_ha,
  325. pm8001_printk("Mem%d alloc failed\n",
  326. i));
  327. goto err_out;
  328. }
  329. }
  330. pm8001_ha->devices = pm8001_ha->memoryMap.region[DEV_MEM].virt_ptr;
  331. for (i = 0; i < PM8001_MAX_DEVICES; i++) {
  332. pm8001_ha->devices[i].dev_type = SAS_PHY_UNUSED;
  333. pm8001_ha->devices[i].id = i;
  334. pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES;
  335. pm8001_ha->devices[i].running_req = 0;
  336. }
  337. pm8001_ha->ccb_info = pm8001_ha->memoryMap.region[CCB_MEM].virt_ptr;
  338. for (i = 0; i < PM8001_MAX_CCB; i++) {
  339. pm8001_ha->ccb_info[i].ccb_dma_handle =
  340. pm8001_ha->memoryMap.region[CCB_MEM].phys_addr +
  341. i * sizeof(struct pm8001_ccb_info);
  342. pm8001_ha->ccb_info[i].task = NULL;
  343. pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
  344. pm8001_ha->ccb_info[i].device = NULL;
  345. ++pm8001_ha->tags_num;
  346. }
  347. pm8001_ha->flags = PM8001F_INIT_TIME;
  348. /* Initialize tags */
  349. pm8001_tag_init(pm8001_ha);
  350. return 0;
  351. err_out:
  352. return 1;
  353. }
  354. /**
  355. * pm8001_ioremap - remap the pci high physical address to kernal virtual
  356. * address so that we can access them.
  357. * @pm8001_ha:our hba structure.
  358. */
  359. static int pm8001_ioremap(struct pm8001_hba_info *pm8001_ha)
  360. {
  361. u32 bar;
  362. u32 logicalBar = 0;
  363. struct pci_dev *pdev;
  364. pdev = pm8001_ha->pdev;
  365. /* map pci mem (PMC pci base 0-3)*/
  366. for (bar = 0; bar < 6; bar++) {
  367. /*
  368. ** logical BARs for SPC:
  369. ** bar 0 and 1 - logical BAR0
  370. ** bar 2 and 3 - logical BAR1
  371. ** bar4 - logical BAR2
  372. ** bar5 - logical BAR3
  373. ** Skip the appropriate assignments:
  374. */
  375. if ((bar == 1) || (bar == 3))
  376. continue;
  377. if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
  378. pm8001_ha->io_mem[logicalBar].membase =
  379. pci_resource_start(pdev, bar);
  380. pm8001_ha->io_mem[logicalBar].membase &=
  381. (u32)PCI_BASE_ADDRESS_MEM_MASK;
  382. pm8001_ha->io_mem[logicalBar].memsize =
  383. pci_resource_len(pdev, bar);
  384. pm8001_ha->io_mem[logicalBar].memvirtaddr =
  385. ioremap(pm8001_ha->io_mem[logicalBar].membase,
  386. pm8001_ha->io_mem[logicalBar].memsize);
  387. PM8001_INIT_DBG(pm8001_ha,
  388. pm8001_printk("PCI: bar %d, logicalBar %d ",
  389. bar, logicalBar));
  390. PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
  391. "base addr %llx virt_addr=%llx len=%d\n",
  392. (u64)pm8001_ha->io_mem[logicalBar].membase,
  393. (u64)(unsigned long)
  394. pm8001_ha->io_mem[logicalBar].memvirtaddr,
  395. pm8001_ha->io_mem[logicalBar].memsize));
  396. } else {
  397. pm8001_ha->io_mem[logicalBar].membase = 0;
  398. pm8001_ha->io_mem[logicalBar].memsize = 0;
  399. pm8001_ha->io_mem[logicalBar].memvirtaddr = 0;
  400. }
  401. logicalBar++;
  402. }
  403. return 0;
  404. }
  405. /**
  406. * pm8001_pci_alloc - initialize our ha card structure
  407. * @pdev: pci device.
  408. * @ent: ent
  409. * @shost: scsi host struct which has been initialized before.
  410. */
  411. static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,
  412. const struct pci_device_id *ent,
  413. struct Scsi_Host *shost)
  414. {
  415. struct pm8001_hba_info *pm8001_ha;
  416. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  417. pm8001_ha = sha->lldd_ha;
  418. if (!pm8001_ha)
  419. return NULL;
  420. pm8001_ha->pdev = pdev;
  421. pm8001_ha->dev = &pdev->dev;
  422. pm8001_ha->chip_id = ent->driver_data;
  423. pm8001_ha->chip = &pm8001_chips[pm8001_ha->chip_id];
  424. pm8001_ha->irq = pdev->irq;
  425. pm8001_ha->sas = sha;
  426. pm8001_ha->shost = shost;
  427. pm8001_ha->id = pm8001_id++;
  428. pm8001_ha->logging_level = 0x01;
  429. sprintf(pm8001_ha->name, "%s%d", DRV_NAME, pm8001_ha->id);
  430. /* IOMB size is 128 for 8088/89 controllers */
  431. if (pm8001_ha->chip_id != chip_8001)
  432. pm8001_ha->iomb_size = IOMB_SIZE_SPCV;
  433. else
  434. pm8001_ha->iomb_size = IOMB_SIZE_SPC;
  435. #ifdef PM8001_USE_TASKLET
  436. /**
  437. * default tasklet for non msi-x interrupt handler/first msi-x
  438. * interrupt handler
  439. **/
  440. tasklet_init(&pm8001_ha->tasklet, pm8001_tasklet,
  441. (unsigned long)pm8001_ha);
  442. #endif
  443. pm8001_ioremap(pm8001_ha);
  444. if (!pm8001_alloc(pm8001_ha, ent))
  445. return pm8001_ha;
  446. pm8001_free(pm8001_ha);
  447. return NULL;
  448. }
  449. /**
  450. * pci_go_44 - pm8001 specified, its DMA is 44 bit rather than 64 bit
  451. * @pdev: pci device.
  452. */
  453. static int pci_go_44(struct pci_dev *pdev)
  454. {
  455. int rc;
  456. if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(44))) {
  457. rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(44));
  458. if (rc) {
  459. rc = pci_set_consistent_dma_mask(pdev,
  460. DMA_BIT_MASK(32));
  461. if (rc) {
  462. dev_printk(KERN_ERR, &pdev->dev,
  463. "44-bit DMA enable failed\n");
  464. return rc;
  465. }
  466. }
  467. } else {
  468. rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
  469. if (rc) {
  470. dev_printk(KERN_ERR, &pdev->dev,
  471. "32-bit DMA enable failed\n");
  472. return rc;
  473. }
  474. rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  475. if (rc) {
  476. dev_printk(KERN_ERR, &pdev->dev,
  477. "32-bit consistent DMA enable failed\n");
  478. return rc;
  479. }
  480. }
  481. return rc;
  482. }
  483. /**
  484. * pm8001_prep_sas_ha_init - allocate memory in general hba struct && init them.
  485. * @shost: scsi host which has been allocated outside.
  486. * @chip_info: our ha struct.
  487. */
  488. static int pm8001_prep_sas_ha_init(struct Scsi_Host *shost,
  489. const struct pm8001_chip_info *chip_info)
  490. {
  491. int phy_nr, port_nr;
  492. struct asd_sas_phy **arr_phy;
  493. struct asd_sas_port **arr_port;
  494. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  495. phy_nr = chip_info->n_phy;
  496. port_nr = phy_nr;
  497. memset(sha, 0x00, sizeof(*sha));
  498. arr_phy = kcalloc(phy_nr, sizeof(void *), GFP_KERNEL);
  499. if (!arr_phy)
  500. goto exit;
  501. arr_port = kcalloc(port_nr, sizeof(void *), GFP_KERNEL);
  502. if (!arr_port)
  503. goto exit_free2;
  504. sha->sas_phy = arr_phy;
  505. sha->sas_port = arr_port;
  506. sha->lldd_ha = kzalloc(sizeof(struct pm8001_hba_info), GFP_KERNEL);
  507. if (!sha->lldd_ha)
  508. goto exit_free1;
  509. shost->transportt = pm8001_stt;
  510. shost->max_id = PM8001_MAX_DEVICES;
  511. shost->max_lun = 8;
  512. shost->max_channel = 0;
  513. shost->unique_id = pm8001_id;
  514. shost->max_cmd_len = 16;
  515. shost->can_queue = PM8001_CAN_QUEUE;
  516. shost->cmd_per_lun = 32;
  517. return 0;
  518. exit_free1:
  519. kfree(arr_port);
  520. exit_free2:
  521. kfree(arr_phy);
  522. exit:
  523. return -1;
  524. }
  525. /**
  526. * pm8001_post_sas_ha_init - initialize general hba struct defined in libsas
  527. * @shost: scsi host which has been allocated outside
  528. * @chip_info: our ha struct.
  529. */
  530. static void pm8001_post_sas_ha_init(struct Scsi_Host *shost,
  531. const struct pm8001_chip_info *chip_info)
  532. {
  533. int i = 0;
  534. struct pm8001_hba_info *pm8001_ha;
  535. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  536. pm8001_ha = sha->lldd_ha;
  537. for (i = 0; i < chip_info->n_phy; i++) {
  538. sha->sas_phy[i] = &pm8001_ha->phy[i].sas_phy;
  539. sha->sas_port[i] = &pm8001_ha->port[i].sas_port;
  540. }
  541. sha->sas_ha_name = DRV_NAME;
  542. sha->dev = pm8001_ha->dev;
  543. sha->lldd_module = THIS_MODULE;
  544. sha->sas_addr = &pm8001_ha->sas_addr[0];
  545. sha->num_phys = chip_info->n_phy;
  546. sha->lldd_max_execute_num = 1;
  547. sha->lldd_queue_size = PM8001_CAN_QUEUE;
  548. sha->core.shost = shost;
  549. }
  550. /**
  551. * pm8001_init_sas_add - initialize sas address
  552. * @chip_info: our ha struct.
  553. *
  554. * Currently we just set the fixed SAS address to our HBA,for manufacture,
  555. * it should read from the EEPROM
  556. */
  557. static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
  558. {
  559. u8 i, j;
  560. #ifdef PM8001_READ_VPD
  561. /* For new SPC controllers WWN is stored in flash vpd
  562. * For SPC/SPCve controllers WWN is stored in EEPROM
  563. * For Older SPC WWN is stored in NVMD
  564. */
  565. DECLARE_COMPLETION_ONSTACK(completion);
  566. struct pm8001_ioctl_payload payload;
  567. u16 deviceid;
  568. pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid);
  569. pm8001_ha->nvmd_completion = &completion;
  570. if (pm8001_ha->chip_id == chip_8001) {
  571. if (deviceid == 0x8081) {
  572. payload.minor_function = 4;
  573. payload.length = 4096;
  574. } else {
  575. payload.minor_function = 0;
  576. payload.length = 128;
  577. }
  578. } else {
  579. payload.minor_function = 1;
  580. payload.length = 4096;
  581. }
  582. payload.offset = 0;
  583. payload.func_specific = kzalloc(payload.length, GFP_KERNEL);
  584. PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
  585. wait_for_completion(&completion);
  586. for (i = 0, j = 0; i <= 7; i++, j++) {
  587. if (pm8001_ha->chip_id == chip_8001) {
  588. if (deviceid == 0x8081)
  589. pm8001_ha->sas_addr[j] =
  590. payload.func_specific[0x704 + i];
  591. } else
  592. pm8001_ha->sas_addr[j] =
  593. payload.func_specific[0x804 + i];
  594. }
  595. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  596. memcpy(&pm8001_ha->phy[i].dev_sas_addr,
  597. pm8001_ha->sas_addr, SAS_ADDR_SIZE);
  598. PM8001_INIT_DBG(pm8001_ha,
  599. pm8001_printk("phy %d sas_addr = %016llx\n", i,
  600. pm8001_ha->phy[i].dev_sas_addr));
  601. }
  602. #else
  603. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  604. pm8001_ha->phy[i].dev_sas_addr = 0x50010c600047f9d0ULL;
  605. pm8001_ha->phy[i].dev_sas_addr =
  606. cpu_to_be64((u64)
  607. (*(u64 *)&pm8001_ha->phy[i].dev_sas_addr));
  608. }
  609. memcpy(pm8001_ha->sas_addr, &pm8001_ha->phy[0].dev_sas_addr,
  610. SAS_ADDR_SIZE);
  611. #endif
  612. }
  613. #ifdef PM8001_USE_MSIX
  614. /**
  615. * pm8001_setup_msix - enable MSI-X interrupt
  616. * @chip_info: our ha struct.
  617. * @irq_handler: irq_handler
  618. */
  619. static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
  620. {
  621. u32 i = 0, j = 0;
  622. u32 number_of_intr;
  623. int flag = 0;
  624. u32 max_entry;
  625. int rc;
  626. static char intr_drvname[PM8001_MAX_MSIX_VEC][sizeof(DRV_NAME)+3];
  627. /* SPCv controllers supports 64 msi-x */
  628. if (pm8001_ha->chip_id == chip_8001) {
  629. number_of_intr = 1;
  630. flag |= IRQF_DISABLED;
  631. } else {
  632. number_of_intr = PM8001_MAX_MSIX_VEC;
  633. flag &= ~IRQF_SHARED;
  634. flag |= IRQF_DISABLED;
  635. }
  636. max_entry = sizeof(pm8001_ha->msix_entries) /
  637. sizeof(pm8001_ha->msix_entries[0]);
  638. for (i = 0; i < max_entry ; i++)
  639. pm8001_ha->msix_entries[i].entry = i;
  640. rc = pci_enable_msix(pm8001_ha->pdev, pm8001_ha->msix_entries,
  641. number_of_intr);
  642. pm8001_ha->number_of_intr = number_of_intr;
  643. if (!rc) {
  644. PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
  645. "pci_enable_msix request ret:%d no of intr %d\n",
  646. rc, pm8001_ha->number_of_intr));
  647. for (i = 0; i < number_of_intr; i++)
  648. pm8001_ha->outq[i] = i;
  649. for (i = 0; i < number_of_intr; i++) {
  650. snprintf(intr_drvname[i], sizeof(intr_drvname[0]),
  651. DRV_NAME"%d", i);
  652. if (request_irq(pm8001_ha->msix_entries[i].vector,
  653. pm8001_interrupt_handler_msix, flag,
  654. intr_drvname[i], &pm8001_ha->outq[i])) {
  655. for (j = 0; j < i; j++)
  656. free_irq(
  657. pm8001_ha->msix_entries[j].vector,
  658. &pm8001_ha->outq[j]);
  659. pci_disable_msix(pm8001_ha->pdev);
  660. break;
  661. }
  662. }
  663. }
  664. return rc;
  665. }
  666. #endif
  667. /**
  668. * pm8001_request_irq - register interrupt
  669. * @chip_info: our ha struct.
  670. */
  671. static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
  672. {
  673. struct pci_dev *pdev;
  674. int rc;
  675. pdev = pm8001_ha->pdev;
  676. #ifdef PM8001_USE_MSIX
  677. if (pdev->msix_cap)
  678. return pm8001_setup_msix(pm8001_ha);
  679. else {
  680. PM8001_INIT_DBG(pm8001_ha,
  681. pm8001_printk("MSIX not supported!!!\n"));
  682. goto intx;
  683. }
  684. #endif
  685. intx:
  686. /* initialize the INT-X interrupt */
  687. rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED,
  688. DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost));
  689. return rc;
  690. }
  691. /**
  692. * pm8001_pci_probe - probe supported device
  693. * @pdev: pci device which kernel has been prepared for.
  694. * @ent: pci device id
  695. *
  696. * This function is the main initialization function, when register a new
  697. * pci driver it is invoked, all struct an hardware initilization should be done
  698. * here, also, register interrupt
  699. */
  700. static int pm8001_pci_probe(struct pci_dev *pdev,
  701. const struct pci_device_id *ent)
  702. {
  703. unsigned int rc;
  704. u32 pci_reg;
  705. u8 i = 0;
  706. struct pm8001_hba_info *pm8001_ha;
  707. struct Scsi_Host *shost = NULL;
  708. const struct pm8001_chip_info *chip;
  709. dev_printk(KERN_INFO, &pdev->dev,
  710. "pm80xx: driver version %s\n", DRV_VERSION);
  711. rc = pci_enable_device(pdev);
  712. if (rc)
  713. goto err_out_enable;
  714. pci_set_master(pdev);
  715. /*
  716. * Enable pci slot busmaster by setting pci command register.
  717. * This is required by FW for Cyclone card.
  718. */
  719. pci_read_config_dword(pdev, PCI_COMMAND, &pci_reg);
  720. pci_reg |= 0x157;
  721. pci_write_config_dword(pdev, PCI_COMMAND, pci_reg);
  722. rc = pci_request_regions(pdev, DRV_NAME);
  723. if (rc)
  724. goto err_out_disable;
  725. rc = pci_go_44(pdev);
  726. if (rc)
  727. goto err_out_regions;
  728. shost = scsi_host_alloc(&pm8001_sht, sizeof(void *));
  729. if (!shost) {
  730. rc = -ENOMEM;
  731. goto err_out_regions;
  732. }
  733. chip = &pm8001_chips[ent->driver_data];
  734. SHOST_TO_SAS_HA(shost) =
  735. kzalloc(sizeof(struct sas_ha_struct), GFP_KERNEL);
  736. if (!SHOST_TO_SAS_HA(shost)) {
  737. rc = -ENOMEM;
  738. goto err_out_free_host;
  739. }
  740. rc = pm8001_prep_sas_ha_init(shost, chip);
  741. if (rc) {
  742. rc = -ENOMEM;
  743. goto err_out_free;
  744. }
  745. pci_set_drvdata(pdev, SHOST_TO_SAS_HA(shost));
  746. /* ent->driver variable is used to differentiate between controllers */
  747. pm8001_ha = pm8001_pci_alloc(pdev, ent, shost);
  748. if (!pm8001_ha) {
  749. rc = -ENOMEM;
  750. goto err_out_free;
  751. }
  752. list_add_tail(&pm8001_ha->list, &hba_list);
  753. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  754. rc = PM8001_CHIP_DISP->chip_init(pm8001_ha);
  755. if (rc) {
  756. PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
  757. "chip_init failed [ret: %d]\n", rc));
  758. goto err_out_ha_free;
  759. }
  760. rc = scsi_add_host(shost, &pdev->dev);
  761. if (rc)
  762. goto err_out_ha_free;
  763. rc = pm8001_request_irq(pm8001_ha);
  764. if (rc) {
  765. PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
  766. "pm8001_request_irq failed [ret: %d]\n", rc));
  767. goto err_out_shost;
  768. }
  769. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
  770. if (pm8001_ha->chip_id != chip_8001) {
  771. for (i = 1; i < pm8001_ha->number_of_intr; i++)
  772. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i);
  773. /* setup thermal configuration. */
  774. pm80xx_set_thermal_config(pm8001_ha);
  775. }
  776. pm8001_init_sas_add(pm8001_ha);
  777. pm8001_post_sas_ha_init(shost, chip);
  778. rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
  779. if (rc)
  780. goto err_out_shost;
  781. scsi_scan_host(pm8001_ha->shost);
  782. return 0;
  783. err_out_shost:
  784. scsi_remove_host(pm8001_ha->shost);
  785. err_out_ha_free:
  786. pm8001_free(pm8001_ha);
  787. err_out_free:
  788. kfree(SHOST_TO_SAS_HA(shost));
  789. err_out_free_host:
  790. kfree(shost);
  791. err_out_regions:
  792. pci_release_regions(pdev);
  793. err_out_disable:
  794. pci_disable_device(pdev);
  795. err_out_enable:
  796. return rc;
  797. }
  798. static void pm8001_pci_remove(struct pci_dev *pdev)
  799. {
  800. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  801. struct pm8001_hba_info *pm8001_ha;
  802. int i;
  803. pm8001_ha = sha->lldd_ha;
  804. pci_set_drvdata(pdev, NULL);
  805. sas_unregister_ha(sha);
  806. sas_remove_host(pm8001_ha->shost);
  807. list_del(&pm8001_ha->list);
  808. scsi_remove_host(pm8001_ha->shost);
  809. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  810. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  811. #ifdef PM8001_USE_MSIX
  812. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  813. synchronize_irq(pm8001_ha->msix_entries[i].vector);
  814. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  815. free_irq(pm8001_ha->msix_entries[i].vector,
  816. &pm8001_ha->outq[i]);
  817. pci_disable_msix(pdev);
  818. #else
  819. free_irq(pm8001_ha->irq, sha);
  820. #endif
  821. #ifdef PM8001_USE_TASKLET
  822. tasklet_kill(&pm8001_ha->tasklet);
  823. #endif
  824. pm8001_free(pm8001_ha);
  825. kfree(sha->sas_phy);
  826. kfree(sha->sas_port);
  827. kfree(sha);
  828. pci_release_regions(pdev);
  829. pci_disable_device(pdev);
  830. }
  831. /**
  832. * pm8001_pci_suspend - power management suspend main entry point
  833. * @pdev: PCI device struct
  834. * @state: PM state change to (usually PCI_D3)
  835. *
  836. * Returns 0 success, anything else error.
  837. */
  838. static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  839. {
  840. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  841. struct pm8001_hba_info *pm8001_ha;
  842. int i;
  843. u32 device_state;
  844. pm8001_ha = sha->lldd_ha;
  845. flush_workqueue(pm8001_wq);
  846. scsi_block_requests(pm8001_ha->shost);
  847. if (!pdev->pm_cap) {
  848. dev_err(&pdev->dev, " PCI PM not supported\n");
  849. return -ENODEV;
  850. }
  851. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  852. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  853. #ifdef PM8001_USE_MSIX
  854. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  855. synchronize_irq(pm8001_ha->msix_entries[i].vector);
  856. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  857. free_irq(pm8001_ha->msix_entries[i].vector,
  858. &pm8001_ha->outq[i]);
  859. pci_disable_msix(pdev);
  860. #else
  861. free_irq(pm8001_ha->irq, sha);
  862. #endif
  863. #ifdef PM8001_USE_TASKLET
  864. tasklet_kill(&pm8001_ha->tasklet);
  865. #endif
  866. device_state = pci_choose_state(pdev, state);
  867. pm8001_printk("pdev=0x%p, slot=%s, entering "
  868. "operating state [D%d]\n", pdev,
  869. pm8001_ha->name, device_state);
  870. pci_save_state(pdev);
  871. pci_disable_device(pdev);
  872. pci_set_power_state(pdev, device_state);
  873. return 0;
  874. }
  875. /**
  876. * pm8001_pci_resume - power management resume main entry point
  877. * @pdev: PCI device struct
  878. *
  879. * Returns 0 success, anything else error.
  880. */
  881. static int pm8001_pci_resume(struct pci_dev *pdev)
  882. {
  883. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  884. struct pm8001_hba_info *pm8001_ha;
  885. int rc;
  886. u8 i = 0;
  887. u32 device_state;
  888. pm8001_ha = sha->lldd_ha;
  889. device_state = pdev->current_state;
  890. pm8001_printk("pdev=0x%p, slot=%s, resuming from previous "
  891. "operating state [D%d]\n", pdev, pm8001_ha->name, device_state);
  892. pci_set_power_state(pdev, PCI_D0);
  893. pci_enable_wake(pdev, PCI_D0, 0);
  894. pci_restore_state(pdev);
  895. rc = pci_enable_device(pdev);
  896. if (rc) {
  897. pm8001_printk("slot=%s Enable device failed during resume\n",
  898. pm8001_ha->name);
  899. goto err_out_enable;
  900. }
  901. pci_set_master(pdev);
  902. rc = pci_go_44(pdev);
  903. if (rc)
  904. goto err_out_disable;
  905. /* chip soft rst only for spc */
  906. if (pm8001_ha->chip_id == chip_8001) {
  907. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  908. PM8001_INIT_DBG(pm8001_ha,
  909. pm8001_printk("chip soft reset successful\n"));
  910. }
  911. rc = PM8001_CHIP_DISP->chip_init(pm8001_ha);
  912. if (rc)
  913. goto err_out_disable;
  914. /* disable all the interrupt bits */
  915. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  916. rc = pm8001_request_irq(pm8001_ha);
  917. if (rc)
  918. goto err_out_disable;
  919. #ifdef PM8001_USE_TASKLET
  920. /* default tasklet for non msi-x interrupt handler/first msi-x
  921. * interrupt handler */
  922. tasklet_init(&pm8001_ha->tasklet, pm8001_tasklet,
  923. (unsigned long)pm8001_ha);
  924. #endif
  925. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
  926. if (pm8001_ha->chip_id != chip_8001) {
  927. for (i = 1; i < pm8001_ha->number_of_intr; i++)
  928. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i);
  929. }
  930. scsi_unblock_requests(pm8001_ha->shost);
  931. return 0;
  932. err_out_disable:
  933. scsi_remove_host(pm8001_ha->shost);
  934. pci_disable_device(pdev);
  935. err_out_enable:
  936. return rc;
  937. }
  938. /* update of pci device, vendor id and driver data with
  939. * unique value for each of the controller
  940. */
  941. static struct pci_device_id pm8001_pci_table[] = {
  942. { PCI_VDEVICE(PMC_Sierra, 0x8001), chip_8001 },
  943. {
  944. PCI_DEVICE(0x117c, 0x0042),
  945. .driver_data = chip_8001
  946. },
  947. /* Support for SPC/SPCv/SPCve controllers */
  948. { PCI_VDEVICE(ADAPTEC2, 0x8001), chip_8001 },
  949. { PCI_VDEVICE(PMC_Sierra, 0x8008), chip_8008 },
  950. { PCI_VDEVICE(ADAPTEC2, 0x8008), chip_8008 },
  951. { PCI_VDEVICE(PMC_Sierra, 0x8018), chip_8018 },
  952. { PCI_VDEVICE(ADAPTEC2, 0x8018), chip_8018 },
  953. { PCI_VDEVICE(PMC_Sierra, 0x8009), chip_8009 },
  954. { PCI_VDEVICE(ADAPTEC2, 0x8009), chip_8009 },
  955. { PCI_VDEVICE(PMC_Sierra, 0x8019), chip_8019 },
  956. { PCI_VDEVICE(ADAPTEC2, 0x8019), chip_8019 },
  957. { PCI_VENDOR_ID_ADAPTEC2, 0x8081,
  958. PCI_VENDOR_ID_ADAPTEC2, 0x0400, 0, 0, chip_8001 },
  959. { PCI_VENDOR_ID_ADAPTEC2, 0x8081,
  960. PCI_VENDOR_ID_ADAPTEC2, 0x0800, 0, 0, chip_8001 },
  961. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  962. PCI_VENDOR_ID_ADAPTEC2, 0x0008, 0, 0, chip_8008 },
  963. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  964. PCI_VENDOR_ID_ADAPTEC2, 0x0800, 0, 0, chip_8008 },
  965. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  966. PCI_VENDOR_ID_ADAPTEC2, 0x0008, 0, 0, chip_8009 },
  967. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  968. PCI_VENDOR_ID_ADAPTEC2, 0x0800, 0, 0, chip_8009 },
  969. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  970. PCI_VENDOR_ID_ADAPTEC2, 0x0016, 0, 0, chip_8018 },
  971. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  972. PCI_VENDOR_ID_ADAPTEC2, 0x1600, 0, 0, chip_8018 },
  973. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  974. PCI_VENDOR_ID_ADAPTEC2, 0x0016, 0, 0, chip_8019 },
  975. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  976. PCI_VENDOR_ID_ADAPTEC2, 0x1600, 0, 0, chip_8019 },
  977. {} /* terminate list */
  978. };
  979. static struct pci_driver pm8001_pci_driver = {
  980. .name = DRV_NAME,
  981. .id_table = pm8001_pci_table,
  982. .probe = pm8001_pci_probe,
  983. .remove = pm8001_pci_remove,
  984. .suspend = pm8001_pci_suspend,
  985. .resume = pm8001_pci_resume,
  986. };
  987. /**
  988. * pm8001_init - initialize scsi transport template
  989. */
  990. static int __init pm8001_init(void)
  991. {
  992. int rc = -ENOMEM;
  993. pm8001_wq = alloc_workqueue("pm80xx", 0, 0);
  994. if (!pm8001_wq)
  995. goto err;
  996. pm8001_id = 0;
  997. pm8001_stt = sas_domain_attach_transport(&pm8001_transport_ops);
  998. if (!pm8001_stt)
  999. goto err_wq;
  1000. rc = pci_register_driver(&pm8001_pci_driver);
  1001. if (rc)
  1002. goto err_tp;
  1003. return 0;
  1004. err_tp:
  1005. sas_release_transport(pm8001_stt);
  1006. err_wq:
  1007. destroy_workqueue(pm8001_wq);
  1008. err:
  1009. return rc;
  1010. }
  1011. static void __exit pm8001_exit(void)
  1012. {
  1013. pci_unregister_driver(&pm8001_pci_driver);
  1014. sas_release_transport(pm8001_stt);
  1015. destroy_workqueue(pm8001_wq);
  1016. }
  1017. module_init(pm8001_init);
  1018. module_exit(pm8001_exit);
  1019. MODULE_AUTHOR("Jack Wang <jack_wang@usish.com>");
  1020. MODULE_DESCRIPTION(
  1021. "PMC-Sierra PM8001/8081/8088/8089 SAS/SATA controller driver");
  1022. MODULE_VERSION(DRV_VERSION);
  1023. MODULE_LICENSE("GPL");
  1024. MODULE_DEVICE_TABLE(pci, pm8001_pci_table);