pm8001_init.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  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 = NO_DEVICE;
  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;
  559. #ifdef PM8001_READ_VPD
  560. DECLARE_COMPLETION_ONSTACK(completion);
  561. struct pm8001_ioctl_payload payload;
  562. pm8001_ha->nvmd_completion = &completion;
  563. payload.minor_function = 0;
  564. payload.length = 128;
  565. payload.func_specific = kzalloc(128, GFP_KERNEL);
  566. PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
  567. wait_for_completion(&completion);
  568. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  569. memcpy(&pm8001_ha->phy[i].dev_sas_addr, pm8001_ha->sas_addr,
  570. SAS_ADDR_SIZE);
  571. PM8001_INIT_DBG(pm8001_ha,
  572. pm8001_printk("phy %d sas_addr = %016llx \n", i,
  573. pm8001_ha->phy[i].dev_sas_addr));
  574. }
  575. #else
  576. for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
  577. pm8001_ha->phy[i].dev_sas_addr = 0x50010c600047f9d0ULL;
  578. pm8001_ha->phy[i].dev_sas_addr =
  579. cpu_to_be64((u64)
  580. (*(u64 *)&pm8001_ha->phy[i].dev_sas_addr));
  581. }
  582. memcpy(pm8001_ha->sas_addr, &pm8001_ha->phy[0].dev_sas_addr,
  583. SAS_ADDR_SIZE);
  584. #endif
  585. }
  586. #ifdef PM8001_USE_MSIX
  587. /**
  588. * pm8001_setup_msix - enable MSI-X interrupt
  589. * @chip_info: our ha struct.
  590. * @irq_handler: irq_handler
  591. */
  592. static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
  593. {
  594. u32 i = 0, j = 0;
  595. u32 number_of_intr;
  596. int flag = 0;
  597. u32 max_entry;
  598. int rc;
  599. static char intr_drvname[PM8001_MAX_MSIX_VEC][sizeof(DRV_NAME)+3];
  600. /* SPCv controllers supports 64 msi-x */
  601. if (pm8001_ha->chip_id == chip_8001) {
  602. number_of_intr = 1;
  603. flag |= IRQF_DISABLED;
  604. } else {
  605. number_of_intr = PM8001_MAX_MSIX_VEC;
  606. flag &= ~IRQF_SHARED;
  607. flag |= IRQF_DISABLED;
  608. }
  609. max_entry = sizeof(pm8001_ha->msix_entries) /
  610. sizeof(pm8001_ha->msix_entries[0]);
  611. for (i = 0; i < max_entry ; i++)
  612. pm8001_ha->msix_entries[i].entry = i;
  613. rc = pci_enable_msix(pm8001_ha->pdev, pm8001_ha->msix_entries,
  614. number_of_intr);
  615. pm8001_ha->number_of_intr = number_of_intr;
  616. if (!rc) {
  617. PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
  618. "pci_enable_msix request ret:%d no of intr %d\n",
  619. rc, pm8001_ha->number_of_intr));
  620. for (i = 0; i < number_of_intr; i++)
  621. pm8001_ha->outq[i] = i;
  622. for (i = 0; i < number_of_intr; i++) {
  623. snprintf(intr_drvname[i], sizeof(intr_drvname[0]),
  624. DRV_NAME"%d", i);
  625. if (request_irq(pm8001_ha->msix_entries[i].vector,
  626. pm8001_interrupt_handler_msix, flag,
  627. intr_drvname[i], &pm8001_ha->outq[i])) {
  628. for (j = 0; j < i; j++)
  629. free_irq(
  630. pm8001_ha->msix_entries[j].vector,
  631. &pm8001_ha->outq[j]);
  632. pci_disable_msix(pm8001_ha->pdev);
  633. break;
  634. }
  635. }
  636. }
  637. return rc;
  638. }
  639. #endif
  640. /**
  641. * pm8001_request_irq - register interrupt
  642. * @chip_info: our ha struct.
  643. */
  644. static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
  645. {
  646. struct pci_dev *pdev;
  647. int rc;
  648. pdev = pm8001_ha->pdev;
  649. #ifdef PM8001_USE_MSIX
  650. if (pci_find_capability(pdev, PCI_CAP_ID_MSIX))
  651. return pm8001_setup_msix(pm8001_ha);
  652. else {
  653. PM8001_INIT_DBG(pm8001_ha,
  654. pm8001_printk("MSIX not supported!!!\n"));
  655. goto intx;
  656. }
  657. #endif
  658. intx:
  659. /* initialize the INT-X interrupt */
  660. rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED,
  661. DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost));
  662. return rc;
  663. }
  664. /**
  665. * pm8001_pci_probe - probe supported device
  666. * @pdev: pci device which kernel has been prepared for.
  667. * @ent: pci device id
  668. *
  669. * This function is the main initialization function, when register a new
  670. * pci driver it is invoked, all struct an hardware initilization should be done
  671. * here, also, register interrupt
  672. */
  673. static int pm8001_pci_probe(struct pci_dev *pdev,
  674. const struct pci_device_id *ent)
  675. {
  676. unsigned int rc;
  677. u32 pci_reg;
  678. u8 i = 0;
  679. struct pm8001_hba_info *pm8001_ha;
  680. struct Scsi_Host *shost = NULL;
  681. const struct pm8001_chip_info *chip;
  682. dev_printk(KERN_INFO, &pdev->dev,
  683. "pm80xx: driver version %s\n", DRV_VERSION);
  684. rc = pci_enable_device(pdev);
  685. if (rc)
  686. goto err_out_enable;
  687. pci_set_master(pdev);
  688. /*
  689. * Enable pci slot busmaster by setting pci command register.
  690. * This is required by FW for Cyclone card.
  691. */
  692. pci_read_config_dword(pdev, PCI_COMMAND, &pci_reg);
  693. pci_reg |= 0x157;
  694. pci_write_config_dword(pdev, PCI_COMMAND, pci_reg);
  695. rc = pci_request_regions(pdev, DRV_NAME);
  696. if (rc)
  697. goto err_out_disable;
  698. rc = pci_go_44(pdev);
  699. if (rc)
  700. goto err_out_regions;
  701. shost = scsi_host_alloc(&pm8001_sht, sizeof(void *));
  702. if (!shost) {
  703. rc = -ENOMEM;
  704. goto err_out_regions;
  705. }
  706. chip = &pm8001_chips[ent->driver_data];
  707. SHOST_TO_SAS_HA(shost) =
  708. kzalloc(sizeof(struct sas_ha_struct), GFP_KERNEL);
  709. if (!SHOST_TO_SAS_HA(shost)) {
  710. rc = -ENOMEM;
  711. goto err_out_free_host;
  712. }
  713. rc = pm8001_prep_sas_ha_init(shost, chip);
  714. if (rc) {
  715. rc = -ENOMEM;
  716. goto err_out_free;
  717. }
  718. pci_set_drvdata(pdev, SHOST_TO_SAS_HA(shost));
  719. /* ent->driver variable is used to differentiate between controllers */
  720. pm8001_ha = pm8001_pci_alloc(pdev, ent, shost);
  721. if (!pm8001_ha) {
  722. rc = -ENOMEM;
  723. goto err_out_free;
  724. }
  725. list_add_tail(&pm8001_ha->list, &hba_list);
  726. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  727. rc = PM8001_CHIP_DISP->chip_init(pm8001_ha);
  728. if (rc) {
  729. PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
  730. "chip_init failed [ret: %d]\n", rc));
  731. goto err_out_ha_free;
  732. }
  733. rc = scsi_add_host(shost, &pdev->dev);
  734. if (rc)
  735. goto err_out_ha_free;
  736. rc = pm8001_request_irq(pm8001_ha);
  737. if (rc) {
  738. PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
  739. "pm8001_request_irq failed [ret: %d]\n", rc));
  740. goto err_out_shost;
  741. }
  742. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
  743. if (pm8001_ha->chip_id != chip_8001) {
  744. for (i = 1; i < pm8001_ha->number_of_intr; i++)
  745. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i);
  746. }
  747. pm8001_init_sas_add(pm8001_ha);
  748. pm8001_post_sas_ha_init(shost, chip);
  749. rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
  750. if (rc)
  751. goto err_out_shost;
  752. scsi_scan_host(pm8001_ha->shost);
  753. return 0;
  754. err_out_shost:
  755. scsi_remove_host(pm8001_ha->shost);
  756. err_out_ha_free:
  757. pm8001_free(pm8001_ha);
  758. err_out_free:
  759. kfree(SHOST_TO_SAS_HA(shost));
  760. err_out_free_host:
  761. kfree(shost);
  762. err_out_regions:
  763. pci_release_regions(pdev);
  764. err_out_disable:
  765. pci_disable_device(pdev);
  766. err_out_enable:
  767. return rc;
  768. }
  769. static void pm8001_pci_remove(struct pci_dev *pdev)
  770. {
  771. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  772. struct pm8001_hba_info *pm8001_ha;
  773. int i;
  774. pm8001_ha = sha->lldd_ha;
  775. pci_set_drvdata(pdev, NULL);
  776. sas_unregister_ha(sha);
  777. sas_remove_host(pm8001_ha->shost);
  778. list_del(&pm8001_ha->list);
  779. scsi_remove_host(pm8001_ha->shost);
  780. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  781. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  782. #ifdef PM8001_USE_MSIX
  783. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  784. synchronize_irq(pm8001_ha->msix_entries[i].vector);
  785. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  786. free_irq(pm8001_ha->msix_entries[i].vector,
  787. &pm8001_ha->outq[i]);
  788. pci_disable_msix(pdev);
  789. #else
  790. free_irq(pm8001_ha->irq, sha);
  791. #endif
  792. #ifdef PM8001_USE_TASKLET
  793. tasklet_kill(&pm8001_ha->tasklet);
  794. #endif
  795. pm8001_free(pm8001_ha);
  796. kfree(sha->sas_phy);
  797. kfree(sha->sas_port);
  798. kfree(sha);
  799. pci_release_regions(pdev);
  800. pci_disable_device(pdev);
  801. }
  802. /**
  803. * pm8001_pci_suspend - power management suspend main entry point
  804. * @pdev: PCI device struct
  805. * @state: PM state change to (usually PCI_D3)
  806. *
  807. * Returns 0 success, anything else error.
  808. */
  809. static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  810. {
  811. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  812. struct pm8001_hba_info *pm8001_ha;
  813. int i , pos;
  814. u32 device_state;
  815. pm8001_ha = sha->lldd_ha;
  816. flush_workqueue(pm8001_wq);
  817. scsi_block_requests(pm8001_ha->shost);
  818. pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
  819. if (pos == 0) {
  820. printk(KERN_ERR " PCI PM not supported\n");
  821. return -ENODEV;
  822. }
  823. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  824. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  825. #ifdef PM8001_USE_MSIX
  826. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  827. synchronize_irq(pm8001_ha->msix_entries[i].vector);
  828. for (i = 0; i < pm8001_ha->number_of_intr; i++)
  829. free_irq(pm8001_ha->msix_entries[i].vector,
  830. &pm8001_ha->outq[i]);
  831. pci_disable_msix(pdev);
  832. #else
  833. free_irq(pm8001_ha->irq, sha);
  834. #endif
  835. #ifdef PM8001_USE_TASKLET
  836. tasklet_kill(&pm8001_ha->tasklet);
  837. #endif
  838. device_state = pci_choose_state(pdev, state);
  839. pm8001_printk("pdev=0x%p, slot=%s, entering "
  840. "operating state [D%d]\n", pdev,
  841. pm8001_ha->name, device_state);
  842. pci_save_state(pdev);
  843. pci_disable_device(pdev);
  844. pci_set_power_state(pdev, device_state);
  845. return 0;
  846. }
  847. /**
  848. * pm8001_pci_resume - power management resume main entry point
  849. * @pdev: PCI device struct
  850. *
  851. * Returns 0 success, anything else error.
  852. */
  853. static int pm8001_pci_resume(struct pci_dev *pdev)
  854. {
  855. struct sas_ha_struct *sha = pci_get_drvdata(pdev);
  856. struct pm8001_hba_info *pm8001_ha;
  857. int rc;
  858. u8 i = 0;
  859. u32 device_state;
  860. pm8001_ha = sha->lldd_ha;
  861. device_state = pdev->current_state;
  862. pm8001_printk("pdev=0x%p, slot=%s, resuming from previous "
  863. "operating state [D%d]\n", pdev, pm8001_ha->name, device_state);
  864. pci_set_power_state(pdev, PCI_D0);
  865. pci_enable_wake(pdev, PCI_D0, 0);
  866. pci_restore_state(pdev);
  867. rc = pci_enable_device(pdev);
  868. if (rc) {
  869. pm8001_printk("slot=%s Enable device failed during resume\n",
  870. pm8001_ha->name);
  871. goto err_out_enable;
  872. }
  873. pci_set_master(pdev);
  874. rc = pci_go_44(pdev);
  875. if (rc)
  876. goto err_out_disable;
  877. /* chip soft rst only for spc */
  878. if (pm8001_ha->chip_id == chip_8001) {
  879. PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
  880. PM8001_INIT_DBG(pm8001_ha,
  881. pm8001_printk("chip soft reset successful\n"));
  882. }
  883. rc = PM8001_CHIP_DISP->chip_init(pm8001_ha);
  884. if (rc)
  885. goto err_out_disable;
  886. /* disable all the interrupt bits */
  887. PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
  888. rc = pm8001_request_irq(pm8001_ha);
  889. if (rc)
  890. goto err_out_disable;
  891. #ifdef PM8001_USE_TASKLET
  892. /* default tasklet for non msi-x interrupt handler/first msi-x
  893. * interrupt handler */
  894. tasklet_init(&pm8001_ha->tasklet, pm8001_tasklet,
  895. (unsigned long)pm8001_ha);
  896. #endif
  897. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
  898. if (pm8001_ha->chip_id != chip_8001) {
  899. for (i = 1; i < pm8001_ha->number_of_intr; i++)
  900. PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i);
  901. }
  902. scsi_unblock_requests(pm8001_ha->shost);
  903. return 0;
  904. err_out_disable:
  905. scsi_remove_host(pm8001_ha->shost);
  906. pci_disable_device(pdev);
  907. err_out_enable:
  908. return rc;
  909. }
  910. /* update of pci device, vendor id and driver data with
  911. * unique value for each of the controller
  912. */
  913. static struct pci_device_id pm8001_pci_table[] = {
  914. { PCI_VDEVICE(PMC_Sierra, 0x8001), chip_8001 },
  915. {
  916. PCI_DEVICE(0x117c, 0x0042),
  917. .driver_data = chip_8001
  918. },
  919. /* Support for SPC/SPCv/SPCve controllers */
  920. { PCI_VDEVICE(ADAPTEC2, 0x8001), chip_8001 },
  921. { PCI_VDEVICE(PMC_Sierra, 0x8008), chip_8008 },
  922. { PCI_VDEVICE(ADAPTEC2, 0x8008), chip_8008 },
  923. { PCI_VDEVICE(PMC_Sierra, 0x8018), chip_8018 },
  924. { PCI_VDEVICE(ADAPTEC2, 0x8018), chip_8018 },
  925. { PCI_VDEVICE(PMC_Sierra, 0x8009), chip_8009 },
  926. { PCI_VDEVICE(ADAPTEC2, 0x8009), chip_8009 },
  927. { PCI_VDEVICE(PMC_Sierra, 0x8019), chip_8019 },
  928. { PCI_VDEVICE(ADAPTEC2, 0x8019), chip_8019 },
  929. { PCI_VENDOR_ID_ADAPTEC2, 0x8081,
  930. PCI_VENDOR_ID_ADAPTEC2, 0x0400, 0, 0, chip_8001 },
  931. { PCI_VENDOR_ID_ADAPTEC2, 0x8081,
  932. PCI_VENDOR_ID_ADAPTEC2, 0x0800, 0, 0, chip_8001 },
  933. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  934. PCI_VENDOR_ID_ADAPTEC2, 0x0008, 0, 0, chip_8008 },
  935. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  936. PCI_VENDOR_ID_ADAPTEC2, 0x0800, 0, 0, chip_8008 },
  937. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  938. PCI_VENDOR_ID_ADAPTEC2, 0x0008, 0, 0, chip_8009 },
  939. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  940. PCI_VENDOR_ID_ADAPTEC2, 0x0800, 0, 0, chip_8009 },
  941. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  942. PCI_VENDOR_ID_ADAPTEC2, 0x0016, 0, 0, chip_8018 },
  943. { PCI_VENDOR_ID_ADAPTEC2, 0x8088,
  944. PCI_VENDOR_ID_ADAPTEC2, 0x1600, 0, 0, chip_8018 },
  945. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  946. PCI_VENDOR_ID_ADAPTEC2, 0x0016, 0, 0, chip_8019 },
  947. { PCI_VENDOR_ID_ADAPTEC2, 0x8089,
  948. PCI_VENDOR_ID_ADAPTEC2, 0x1600, 0, 0, chip_8019 },
  949. {} /* terminate list */
  950. };
  951. static struct pci_driver pm8001_pci_driver = {
  952. .name = DRV_NAME,
  953. .id_table = pm8001_pci_table,
  954. .probe = pm8001_pci_probe,
  955. .remove = pm8001_pci_remove,
  956. .suspend = pm8001_pci_suspend,
  957. .resume = pm8001_pci_resume,
  958. };
  959. /**
  960. * pm8001_init - initialize scsi transport template
  961. */
  962. static int __init pm8001_init(void)
  963. {
  964. int rc = -ENOMEM;
  965. pm8001_wq = alloc_workqueue("pm80xx", 0, 0);
  966. if (!pm8001_wq)
  967. goto err;
  968. pm8001_id = 0;
  969. pm8001_stt = sas_domain_attach_transport(&pm8001_transport_ops);
  970. if (!pm8001_stt)
  971. goto err_wq;
  972. rc = pci_register_driver(&pm8001_pci_driver);
  973. if (rc)
  974. goto err_tp;
  975. return 0;
  976. err_tp:
  977. sas_release_transport(pm8001_stt);
  978. err_wq:
  979. destroy_workqueue(pm8001_wq);
  980. err:
  981. return rc;
  982. }
  983. static void __exit pm8001_exit(void)
  984. {
  985. pci_unregister_driver(&pm8001_pci_driver);
  986. sas_release_transport(pm8001_stt);
  987. destroy_workqueue(pm8001_wq);
  988. }
  989. module_init(pm8001_init);
  990. module_exit(pm8001_exit);
  991. MODULE_AUTHOR("Jack Wang <jack_wang@usish.com>");
  992. MODULE_DESCRIPTION(
  993. "PMC-Sierra PM8001/8081/8088/8089 SAS/SATA controller driver");
  994. MODULE_VERSION(DRV_VERSION);
  995. MODULE_LICENSE("GPL");
  996. MODULE_DEVICE_TABLE(pci, pm8001_pci_table);