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)pm8001_ha->io_mem[logicalBar].memvirtaddr,
  394. pm8001_ha->io_mem[logicalBar].memsize));
  395. } else {
  396. pm8001_ha->io_mem[logicalBar].membase = 0;
  397. pm8001_ha->io_mem[logicalBar].memsize = 0;
  398. pm8001_ha->io_mem[logicalBar].memvirtaddr = 0;
  399. }
  400. logicalBar++;
  401. }
  402. return 0;
  403. }
  404. /**
  405. * pm8001_pci_alloc - initialize our ha card structure
  406. * @pdev: pci device.
  407. * @ent: ent
  408. * @shost: scsi host struct which has been initialized before.
  409. */
  410. static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,
  411. const struct pci_device_id *ent,
  412. struct Scsi_Host *shost)
  413. {
  414. struct pm8001_hba_info *pm8001_ha;
  415. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  416. pm8001_ha = sha->lldd_ha;
  417. if (!pm8001_ha)
  418. return NULL;
  419. pm8001_ha->pdev = pdev;
  420. pm8001_ha->dev = &pdev->dev;
  421. pm8001_ha->chip_id = ent->driver_data;
  422. pm8001_ha->chip = &pm8001_chips[pm8001_ha->chip_id];
  423. pm8001_ha->irq = pdev->irq;
  424. pm8001_ha->sas = sha;
  425. pm8001_ha->shost = shost;
  426. pm8001_ha->id = pm8001_id++;
  427. pm8001_ha->logging_level = 0x01;
  428. sprintf(pm8001_ha->name, "%s%d", DRV_NAME, pm8001_ha->id);
  429. /* IOMB size is 128 for 8088/89 controllers */
  430. if (pm8001_ha->chip_id != chip_8001)
  431. pm8001_ha->iomb_size = IOMB_SIZE_SPCV;
  432. else
  433. pm8001_ha->iomb_size = IOMB_SIZE_SPC;
  434. #ifdef PM8001_USE_TASKLET
  435. /**
  436. * default tasklet for non msi-x interrupt handler/first msi-x
  437. * interrupt handler
  438. **/
  439. tasklet_init(&pm8001_ha->tasklet, pm8001_tasklet,
  440. (unsigned long)pm8001_ha);
  441. #endif
  442. pm8001_ioremap(pm8001_ha);
  443. if (!pm8001_alloc(pm8001_ha, ent))
  444. return pm8001_ha;
  445. pm8001_free(pm8001_ha);
  446. return NULL;
  447. }
  448. /**
  449. * pci_go_44 - pm8001 specified, its DMA is 44 bit rather than 64 bit
  450. * @pdev: pci device.
  451. */
  452. static int pci_go_44(struct pci_dev *pdev)
  453. {
  454. int rc;
  455. if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(44))) {
  456. rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(44));
  457. if (rc) {
  458. rc = pci_set_consistent_dma_mask(pdev,
  459. DMA_BIT_MASK(32));
  460. if (rc) {
  461. dev_printk(KERN_ERR, &pdev->dev,
  462. "44-bit DMA enable failed\n");
  463. return rc;
  464. }
  465. }
  466. } else {
  467. rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
  468. if (rc) {
  469. dev_printk(KERN_ERR, &pdev->dev,
  470. "32-bit DMA enable failed\n");
  471. return rc;
  472. }
  473. rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  474. if (rc) {
  475. dev_printk(KERN_ERR, &pdev->dev,
  476. "32-bit consistent DMA enable failed\n");
  477. return rc;
  478. }
  479. }
  480. return rc;
  481. }
  482. /**
  483. * pm8001_prep_sas_ha_init - allocate memory in general hba struct && init them.
  484. * @shost: scsi host which has been allocated outside.
  485. * @chip_info: our ha struct.
  486. */
  487. static int pm8001_prep_sas_ha_init(struct Scsi_Host *shost,
  488. const struct pm8001_chip_info *chip_info)
  489. {
  490. int phy_nr, port_nr;
  491. struct asd_sas_phy **arr_phy;
  492. struct asd_sas_port **arr_port;
  493. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  494. phy_nr = chip_info->n_phy;
  495. port_nr = phy_nr;
  496. memset(sha, 0x00, sizeof(*sha));
  497. arr_phy = kcalloc(phy_nr, sizeof(void *), GFP_KERNEL);
  498. if (!arr_phy)
  499. goto exit;
  500. arr_port = kcalloc(port_nr, sizeof(void *), GFP_KERNEL);
  501. if (!arr_port)
  502. goto exit_free2;
  503. sha->sas_phy = arr_phy;
  504. sha->sas_port = arr_port;
  505. sha->lldd_ha = kzalloc(sizeof(struct pm8001_hba_info), GFP_KERNEL);
  506. if (!sha->lldd_ha)
  507. goto exit_free1;
  508. shost->transportt = pm8001_stt;
  509. shost->max_id = PM8001_MAX_DEVICES;
  510. shost->max_lun = 8;
  511. shost->max_channel = 0;
  512. shost->unique_id = pm8001_id;
  513. shost->max_cmd_len = 16;
  514. shost->can_queue = PM8001_CAN_QUEUE;
  515. shost->cmd_per_lun = 32;
  516. return 0;
  517. exit_free1:
  518. kfree(arr_port);
  519. exit_free2:
  520. kfree(arr_phy);
  521. exit:
  522. return -1;
  523. }
  524. /**
  525. * pm8001_post_sas_ha_init - initialize general hba struct defined in libsas
  526. * @shost: scsi host which has been allocated outside
  527. * @chip_info: our ha struct.
  528. */
  529. static void pm8001_post_sas_ha_init(struct Scsi_Host *shost,
  530. const struct pm8001_chip_info *chip_info)
  531. {
  532. int i = 0;
  533. struct pm8001_hba_info *pm8001_ha;
  534. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  535. pm8001_ha = sha->lldd_ha;
  536. for (i = 0; i < chip_info->n_phy; i++) {
  537. sha->sas_phy[i] = &pm8001_ha->phy[i].sas_phy;
  538. sha->sas_port[i] = &pm8001_ha->port[i].sas_port;
  539. }
  540. sha->sas_ha_name = DRV_NAME;
  541. sha->dev = pm8001_ha->dev;
  542. sha->lldd_module = THIS_MODULE;
  543. sha->sas_addr = &pm8001_ha->sas_addr[0];
  544. sha->num_phys = chip_info->n_phy;
  545. sha->lldd_max_execute_num = 1;
  546. sha->lldd_queue_size = PM8001_CAN_QUEUE;
  547. sha->core.shost = shost;
  548. }
  549. /**
  550. * pm8001_init_sas_add - initialize sas address
  551. * @chip_info: our ha struct.
  552. *
  553. * Currently we just set the fixed SAS address to our HBA,for manufacture,
  554. * it should read from the EEPROM
  555. */
  556. static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
  557. {
  558. u8 i, j;
  559. #ifdef PM8001_READ_VPD
  560. /* For new SPC controllers WWN is stored in flash vpd
  561. * For SPC/SPCve controllers WWN is stored in EEPROM
  562. * For Older SPC WWN is stored in NVMD
  563. */
  564. DECLARE_COMPLETION_ONSTACK(completion);
  565. struct pm8001_ioctl_payload payload;
  566. u16 deviceid;
  567. pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid);
  568. pm8001_ha->nvmd_completion = &completion;
  569. if (pm8001_ha->chip_id == chip_8001) {
  570. if (deviceid == 0x8081) {
  571. payload.minor_function = 4;
  572. payload.length = 4096;
  573. } else {
  574. payload.minor_function = 0;
  575. payload.length = 128;
  576. }
  577. } else {
  578. payload.minor_function = 1;
  579. payload.length = 4096;
  580. }
  581. payload.offset = 0;
  582. payload.func_specific = kzalloc(payload.length, GFP_KERNEL);
  583. PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
  584. wait_for_completion(&completion);
  585. for (i = 0, j = 0; i <= 7; i++, j++) {
  586. if (pm8001_ha->chip_id == chip_8001) {
  587. if (deviceid == 0x8081)
  588. pm8001_ha->sas_addr[j] =
  589. payload.func_specific[0x704 + i];
  590. } else
  591. pm8001_ha->sas_addr[j] =
  592. payload.func_specific[0x804 + i];
  593. }
  594. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  595. memcpy(&pm8001_ha->phy[i].dev_sas_addr,
  596. pm8001_ha->sas_addr, SAS_ADDR_SIZE);
  597. PM8001_INIT_DBG(pm8001_ha,
  598. pm8001_printk("phy %d sas_addr = %016llx\n", i,
  599. pm8001_ha->phy[i].dev_sas_addr));
  600. }
  601. #else
  602. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  603. pm8001_ha->phy[i].dev_sas_addr = 0x50010c600047f9d0ULL;
  604. pm8001_ha->phy[i].dev_sas_addr =
  605. cpu_to_be64((u64)
  606. (*(u64 *)&pm8001_ha->phy[i].dev_sas_addr));
  607. }
  608. memcpy(pm8001_ha->sas_addr, &pm8001_ha->phy[0].dev_sas_addr,
  609. SAS_ADDR_SIZE);
  610. #endif
  611. }
  612. #ifdef PM8001_USE_MSIX
  613. /**
  614. * pm8001_setup_msix - enable MSI-X interrupt
  615. * @chip_info: our ha struct.
  616. * @irq_handler: irq_handler
  617. */
  618. static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
  619. {
  620. u32 i = 0, j = 0;
  621. u32 number_of_intr;
  622. int flag = 0;
  623. u32 max_entry;
  624. int rc;
  625. static char intr_drvname[PM8001_MAX_MSIX_VEC][sizeof(DRV_NAME)+3];
  626. /* SPCv controllers supports 64 msi-x */
  627. if (pm8001_ha->chip_id == chip_8001) {
  628. number_of_intr = 1;
  629. flag |= IRQF_DISABLED;
  630. } else {
  631. number_of_intr = PM8001_MAX_MSIX_VEC;
  632. flag &= ~IRQF_SHARED;
  633. flag |= IRQF_DISABLED;
  634. }
  635. max_entry = sizeof(pm8001_ha->msix_entries) /
  636. sizeof(pm8001_ha->msix_entries[0]);
  637. for (i = 0; i < max_entry ; i++)
  638. pm8001_ha->msix_entries[i].entry = i;
  639. rc = pci_enable_msix(pm8001_ha->pdev, pm8001_ha->msix_entries,
  640. number_of_intr);
  641. pm8001_ha->number_of_intr = number_of_intr;
  642. if (!rc) {
  643. PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
  644. "pci_enable_msix request ret:%d no of intr %d\n",
  645. rc, pm8001_ha->number_of_intr));
  646. for (i = 0; i < number_of_intr; i++)
  647. pm8001_ha->outq[i] = i;
  648. for (i = 0; i < number_of_intr; i++) {
  649. snprintf(intr_drvname[i], sizeof(intr_drvname[0]),
  650. DRV_NAME"%d", i);
  651. if (request_irq(pm8001_ha->msix_entries[i].vector,
  652. pm8001_interrupt_handler_msix, flag,
  653. intr_drvname[i], &pm8001_ha->outq[i])) {
  654. for (j = 0; j < i; j++)
  655. free_irq(
  656. pm8001_ha->msix_entries[j].vector,
  657. &pm8001_ha->outq[j]);
  658. pci_disable_msix(pm8001_ha->pdev);
  659. break;
  660. }
  661. }
  662. }
  663. return rc;
  664. }
  665. #endif
  666. /**
  667. * pm8001_request_irq - register interrupt
  668. * @chip_info: our ha struct.
  669. */
  670. static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
  671. {
  672. struct pci_dev *pdev;
  673. int rc;
  674. pdev = pm8001_ha->pdev;
  675. #ifdef PM8001_USE_MSIX
  676. if (pci_find_capability(pdev, PCI_CAP_ID_MSIX))
  677. return pm8001_setup_msix(pm8001_ha);
  678. else {
  679. PM8001_INIT_DBG(pm8001_ha,
  680. pm8001_printk("MSIX not supported!!!\n"));
  681. goto intx;
  682. }
  683. #endif
  684. intx:
  685. /* initialize the INT-X interrupt */
  686. rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED,
  687. DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost));
  688. return rc;
  689. }
  690. /**
  691. * pm8001_pci_probe - probe supported device
  692. * @pdev: pci device which kernel has been prepared for.
  693. * @ent: pci device id
  694. *
  695. * This function is the main initialization function, when register a new
  696. * pci driver it is invoked, all struct an hardware initilization should be done
  697. * here, also, register interrupt
  698. */
  699. static int pm8001_pci_probe(struct pci_dev *pdev,
  700. const struct pci_device_id *ent)
  701. {
  702. unsigned int rc;
  703. u32 pci_reg;
  704. u8 i = 0;
  705. struct pm8001_hba_info *pm8001_ha;
  706. struct Scsi_Host *shost = NULL;
  707. const struct pm8001_chip_info *chip;
  708. dev_printk(KERN_INFO, &pdev->dev,
  709. "pm80xx: driver version %s\n", DRV_VERSION);
  710. rc = pci_enable_device(pdev);
  711. if (rc)
  712. goto err_out_enable;
  713. pci_set_master(pdev);
  714. /*
  715. * Enable pci slot busmaster by setting pci command register.
  716. * This is required by FW for Cyclone card.
  717. */
  718. pci_read_config_dword(pdev, PCI_COMMAND, &pci_reg);
  719. pci_reg |= 0x157;
  720. pci_write_config_dword(pdev, PCI_COMMAND, pci_reg);
  721. rc = pci_request_regions(pdev, DRV_NAME);
  722. if (rc)
  723. goto err_out_disable;
  724. rc = pci_go_44(pdev);
  725. if (rc)
  726. goto err_out_regions;
  727. shost = scsi_host_alloc(&pm8001_sht, sizeof(void *));
  728. if (!shost) {
  729. rc = -ENOMEM;
  730. goto err_out_regions;
  731. }
  732. chip = &pm8001_chips[ent->driver_data];
  733. SHOST_TO_SAS_HA(shost) =
  734. kzalloc(sizeof(struct sas_ha_struct), GFP_KERNEL);
  735. if (!SHOST_TO_SAS_HA(shost)) {
  736. rc = -ENOMEM;
  737. goto err_out_free_host;
  738. }
  739. rc = pm8001_prep_sas_ha_init(shost, chip);
  740. if (rc) {
  741. rc = -ENOMEM;
  742. goto err_out_free;
  743. }
  744. pci_set_drvdata(pdev, SHOST_TO_SAS_HA(shost));
  745. /* ent->driver variable is used to differentiate between controllers */
  746. pm8001_ha = pm8001_pci_alloc(pdev, ent, shost);
  747. if (!pm8001_ha) {
  748. rc = -ENOMEM;
  749. goto err_out_free;
  750. }
  751. list_add_tail(&pm8001_ha->list, &hba_list);
  752. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  753. rc = PM8001_CHIP_DISP->chip_init(pm8001_ha);
  754. if (rc) {
  755. PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
  756. "chip_init failed [ret: %d]\n", rc));
  757. goto err_out_ha_free;
  758. }
  759. rc = scsi_add_host(shost, &pdev->dev);
  760. if (rc)
  761. goto err_out_ha_free;
  762. rc = pm8001_request_irq(pm8001_ha);
  763. if (rc) {
  764. PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
  765. "pm8001_request_irq failed [ret: %d]\n", rc));
  766. goto err_out_shost;
  767. }
  768. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
  769. if (pm8001_ha->chip_id != chip_8001) {
  770. for (i = 1; i < pm8001_ha->number_of_intr; i++)
  771. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i);
  772. /* setup thermal configuration. */
  773. pm80xx_set_thermal_config(pm8001_ha);
  774. }
  775. pm8001_init_sas_add(pm8001_ha);
  776. pm8001_post_sas_ha_init(shost, chip);
  777. rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
  778. if (rc)
  779. goto err_out_shost;
  780. scsi_scan_host(pm8001_ha->shost);
  781. return 0;
  782. err_out_shost:
  783. scsi_remove_host(pm8001_ha->shost);
  784. err_out_ha_free:
  785. pm8001_free(pm8001_ha);
  786. err_out_free:
  787. kfree(SHOST_TO_SAS_HA(shost));
  788. err_out_free_host:
  789. kfree(shost);
  790. err_out_regions:
  791. pci_release_regions(pdev);
  792. err_out_disable:
  793. pci_disable_device(pdev);
  794. err_out_enable:
  795. return rc;
  796. }
  797. static void pm8001_pci_remove(struct pci_dev *pdev)
  798. {
  799. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  800. struct pm8001_hba_info *pm8001_ha;
  801. int i;
  802. pm8001_ha = sha->lldd_ha;
  803. pci_set_drvdata(pdev, NULL);
  804. sas_unregister_ha(sha);
  805. sas_remove_host(pm8001_ha->shost);
  806. list_del(&pm8001_ha->list);
  807. scsi_remove_host(pm8001_ha->shost);
  808. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  809. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  810. #ifdef PM8001_USE_MSIX
  811. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  812. synchronize_irq(pm8001_ha->msix_entries[i].vector);
  813. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  814. free_irq(pm8001_ha->msix_entries[i].vector,
  815. &pm8001_ha->outq[i]);
  816. pci_disable_msix(pdev);
  817. #else
  818. free_irq(pm8001_ha->irq, sha);
  819. #endif
  820. #ifdef PM8001_USE_TASKLET
  821. tasklet_kill(&pm8001_ha->tasklet);
  822. #endif
  823. pm8001_free(pm8001_ha);
  824. kfree(sha->sas_phy);
  825. kfree(sha->sas_port);
  826. kfree(sha);
  827. pci_release_regions(pdev);
  828. pci_disable_device(pdev);
  829. }
  830. /**
  831. * pm8001_pci_suspend - power management suspend main entry point
  832. * @pdev: PCI device struct
  833. * @state: PM state change to (usually PCI_D3)
  834. *
  835. * Returns 0 success, anything else error.
  836. */
  837. static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  838. {
  839. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  840. struct pm8001_hba_info *pm8001_ha;
  841. int i , pos;
  842. u32 device_state;
  843. pm8001_ha = sha->lldd_ha;
  844. flush_workqueue(pm8001_wq);
  845. scsi_block_requests(pm8001_ha->shost);
  846. pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
  847. if (pos == 0) {
  848. printk(KERN_ERR " 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);