pm8001_init.c 33 KB

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