pm8001_sas.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. #ifndef _PM8001_SAS_H_
  41. #define _PM8001_SAS_H_
  42. #include <linux/kernel.h>
  43. #include <linux/module.h>
  44. #include <linux/spinlock.h>
  45. #include <linux/delay.h>
  46. #include <linux/types.h>
  47. #include <linux/ctype.h>
  48. #include <linux/dma-mapping.h>
  49. #include <linux/pci.h>
  50. #include <linux/interrupt.h>
  51. #include <linux/workqueue.h>
  52. #include <scsi/libsas.h>
  53. #include <scsi/scsi_tcq.h>
  54. #include <scsi/sas_ata.h>
  55. #include <linux/atomic.h>
  56. #include "pm8001_defs.h"
  57. #define DRV_NAME "pm80xx"
  58. #define DRV_VERSION "0.1.37"
  59. #define PM8001_FAIL_LOGGING 0x01 /* Error message logging */
  60. #define PM8001_INIT_LOGGING 0x02 /* driver init logging */
  61. #define PM8001_DISC_LOGGING 0x04 /* discovery layer logging */
  62. #define PM8001_IO_LOGGING 0x08 /* I/O path logging */
  63. #define PM8001_EH_LOGGING 0x10 /* libsas EH function logging*/
  64. #define PM8001_IOCTL_LOGGING 0x20 /* IOCTL message logging */
  65. #define PM8001_MSG_LOGGING 0x40 /* misc message logging */
  66. #define pm8001_printk(format, arg...) printk(KERN_INFO "pm80xx %s %d:" \
  67. format, __func__, __LINE__, ## arg)
  68. #define PM8001_CHECK_LOGGING(HBA, LEVEL, CMD) \
  69. do { \
  70. if (unlikely(HBA->logging_level & LEVEL)) \
  71. do { \
  72. CMD; \
  73. } while (0); \
  74. } while (0);
  75. #define PM8001_EH_DBG(HBA, CMD) \
  76. PM8001_CHECK_LOGGING(HBA, PM8001_EH_LOGGING, CMD)
  77. #define PM8001_INIT_DBG(HBA, CMD) \
  78. PM8001_CHECK_LOGGING(HBA, PM8001_INIT_LOGGING, CMD)
  79. #define PM8001_DISC_DBG(HBA, CMD) \
  80. PM8001_CHECK_LOGGING(HBA, PM8001_DISC_LOGGING, CMD)
  81. #define PM8001_IO_DBG(HBA, CMD) \
  82. PM8001_CHECK_LOGGING(HBA, PM8001_IO_LOGGING, CMD)
  83. #define PM8001_FAIL_DBG(HBA, CMD) \
  84. PM8001_CHECK_LOGGING(HBA, PM8001_FAIL_LOGGING, CMD)
  85. #define PM8001_IOCTL_DBG(HBA, CMD) \
  86. PM8001_CHECK_LOGGING(HBA, PM8001_IOCTL_LOGGING, CMD)
  87. #define PM8001_MSG_DBG(HBA, CMD) \
  88. PM8001_CHECK_LOGGING(HBA, PM8001_MSG_LOGGING, CMD)
  89. #define PM8001_USE_TASKLET
  90. #define PM8001_USE_MSIX
  91. #define PM8001_READ_VPD
  92. #define DEV_IS_EXPANDER(type) ((type == SAS_EDGE_EXPANDER_DEVICE) || (type == SAS_FANOUT_EXPANDER_DEVICE))
  93. #define IS_SPCV_12G(dev) ((dev->device == 0X8074) \
  94. || (dev->device == 0X8076) \
  95. || (dev->device == 0X8077))
  96. #define PM8001_NAME_LENGTH 32/* generic length of strings */
  97. extern struct list_head hba_list;
  98. extern const struct pm8001_dispatch pm8001_8001_dispatch;
  99. extern const struct pm8001_dispatch pm8001_80xx_dispatch;
  100. struct pm8001_hba_info;
  101. struct pm8001_ccb_info;
  102. struct pm8001_device;
  103. /* define task management IU */
  104. struct pm8001_tmf_task {
  105. u8 tmf;
  106. u32 tag_of_task_to_be_managed;
  107. };
  108. struct pm8001_ioctl_payload {
  109. u32 signature;
  110. u16 major_function;
  111. u16 minor_function;
  112. u16 length;
  113. u16 status;
  114. u16 offset;
  115. u16 id;
  116. u8 *func_specific;
  117. };
  118. struct pm8001_dispatch {
  119. char *name;
  120. int (*chip_init)(struct pm8001_hba_info *pm8001_ha);
  121. int (*chip_soft_rst)(struct pm8001_hba_info *pm8001_ha);
  122. void (*chip_rst)(struct pm8001_hba_info *pm8001_ha);
  123. int (*chip_ioremap)(struct pm8001_hba_info *pm8001_ha);
  124. void (*chip_iounmap)(struct pm8001_hba_info *pm8001_ha);
  125. irqreturn_t (*isr)(struct pm8001_hba_info *pm8001_ha, u8 vec);
  126. u32 (*is_our_interupt)(struct pm8001_hba_info *pm8001_ha);
  127. int (*isr_process_oq)(struct pm8001_hba_info *pm8001_ha, u8 vec);
  128. void (*interrupt_enable)(struct pm8001_hba_info *pm8001_ha, u8 vec);
  129. void (*interrupt_disable)(struct pm8001_hba_info *pm8001_ha, u8 vec);
  130. void (*make_prd)(struct scatterlist *scatter, int nr, void *prd);
  131. int (*smp_req)(struct pm8001_hba_info *pm8001_ha,
  132. struct pm8001_ccb_info *ccb);
  133. int (*ssp_io_req)(struct pm8001_hba_info *pm8001_ha,
  134. struct pm8001_ccb_info *ccb);
  135. int (*sata_req)(struct pm8001_hba_info *pm8001_ha,
  136. struct pm8001_ccb_info *ccb);
  137. int (*phy_start_req)(struct pm8001_hba_info *pm8001_ha, u8 phy_id);
  138. int (*phy_stop_req)(struct pm8001_hba_info *pm8001_ha, u8 phy_id);
  139. int (*reg_dev_req)(struct pm8001_hba_info *pm8001_ha,
  140. struct pm8001_device *pm8001_dev, u32 flag);
  141. int (*dereg_dev_req)(struct pm8001_hba_info *pm8001_ha, u32 device_id);
  142. int (*phy_ctl_req)(struct pm8001_hba_info *pm8001_ha,
  143. u32 phy_id, u32 phy_op);
  144. int (*task_abort)(struct pm8001_hba_info *pm8001_ha,
  145. struct pm8001_device *pm8001_dev, u8 flag, u32 task_tag,
  146. u32 cmd_tag);
  147. int (*ssp_tm_req)(struct pm8001_hba_info *pm8001_ha,
  148. struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf);
  149. int (*get_nvmd_req)(struct pm8001_hba_info *pm8001_ha, void *payload);
  150. int (*set_nvmd_req)(struct pm8001_hba_info *pm8001_ha, void *payload);
  151. int (*fw_flash_update_req)(struct pm8001_hba_info *pm8001_ha,
  152. void *payload);
  153. int (*set_dev_state_req)(struct pm8001_hba_info *pm8001_ha,
  154. struct pm8001_device *pm8001_dev, u32 state);
  155. int (*sas_diag_start_end_req)(struct pm8001_hba_info *pm8001_ha,
  156. u32 state);
  157. int (*sas_diag_execute_req)(struct pm8001_hba_info *pm8001_ha,
  158. u32 state);
  159. int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);
  160. };
  161. struct pm8001_chip_info {
  162. u32 encrypt;
  163. u32 n_phy;
  164. const struct pm8001_dispatch *dispatch;
  165. };
  166. #define PM8001_CHIP_DISP (pm8001_ha->chip->dispatch)
  167. struct pm8001_port {
  168. struct asd_sas_port sas_port;
  169. u8 port_attached;
  170. u8 wide_port_phymap;
  171. u8 port_state;
  172. struct list_head list;
  173. };
  174. struct pm8001_phy {
  175. struct pm8001_hba_info *pm8001_ha;
  176. struct pm8001_port *port;
  177. struct asd_sas_phy sas_phy;
  178. struct sas_identify identify;
  179. struct scsi_device *sdev;
  180. u64 dev_sas_addr;
  181. u32 phy_type;
  182. struct completion *enable_completion;
  183. u32 frame_rcvd_size;
  184. u8 frame_rcvd[32];
  185. u8 phy_attached;
  186. u8 phy_state;
  187. enum sas_linkrate minimum_linkrate;
  188. enum sas_linkrate maximum_linkrate;
  189. };
  190. struct pm8001_device {
  191. enum sas_device_type dev_type;
  192. struct domain_device *sas_device;
  193. u32 attached_phy;
  194. u32 id;
  195. struct completion *dcompletion;
  196. struct completion *setds_completion;
  197. u32 device_id;
  198. u32 running_req;
  199. };
  200. struct pm8001_prd_imt {
  201. __le32 len;
  202. __le32 e;
  203. };
  204. struct pm8001_prd {
  205. __le64 addr; /* 64-bit buffer address */
  206. struct pm8001_prd_imt im_len; /* 64-bit length */
  207. } __attribute__ ((packed));
  208. /*
  209. * CCB(Command Control Block)
  210. */
  211. struct pm8001_ccb_info {
  212. struct list_head entry;
  213. struct sas_task *task;
  214. u32 n_elem;
  215. u32 ccb_tag;
  216. dma_addr_t ccb_dma_handle;
  217. struct pm8001_device *device;
  218. struct pm8001_prd buf_prd[PM8001_MAX_DMA_SG];
  219. struct fw_control_ex *fw_control_context;
  220. u8 open_retry;
  221. };
  222. struct mpi_mem {
  223. void *virt_ptr;
  224. dma_addr_t phys_addr;
  225. u32 phys_addr_hi;
  226. u32 phys_addr_lo;
  227. u32 total_len;
  228. u32 num_elements;
  229. u32 element_size;
  230. u32 alignment;
  231. };
  232. struct mpi_mem_req {
  233. /* The number of element in the mpiMemory array */
  234. u32 count;
  235. /* The array of structures that define memroy regions*/
  236. struct mpi_mem region[USI_MAX_MEMCNT];
  237. };
  238. struct encrypt {
  239. u32 cipher_mode;
  240. u32 sec_mode;
  241. u32 status;
  242. u32 flag;
  243. };
  244. struct sas_phy_attribute_table {
  245. u32 phystart1_16[16];
  246. u32 outbound_hw_event_pid1_16[16];
  247. };
  248. union main_cfg_table {
  249. struct {
  250. u32 signature;
  251. u32 interface_rev;
  252. u32 firmware_rev;
  253. u32 max_out_io;
  254. u32 max_sgl;
  255. u32 ctrl_cap_flag;
  256. u32 gst_offset;
  257. u32 inbound_queue_offset;
  258. u32 outbound_queue_offset;
  259. u32 inbound_q_nppd_hppd;
  260. u32 outbound_hw_event_pid0_3;
  261. u32 outbound_hw_event_pid4_7;
  262. u32 outbound_ncq_event_pid0_3;
  263. u32 outbound_ncq_event_pid4_7;
  264. u32 outbound_tgt_ITNexus_event_pid0_3;
  265. u32 outbound_tgt_ITNexus_event_pid4_7;
  266. u32 outbound_tgt_ssp_event_pid0_3;
  267. u32 outbound_tgt_ssp_event_pid4_7;
  268. u32 outbound_tgt_smp_event_pid0_3;
  269. u32 outbound_tgt_smp_event_pid4_7;
  270. u32 upper_event_log_addr;
  271. u32 lower_event_log_addr;
  272. u32 event_log_size;
  273. u32 event_log_option;
  274. u32 upper_iop_event_log_addr;
  275. u32 lower_iop_event_log_addr;
  276. u32 iop_event_log_size;
  277. u32 iop_event_log_option;
  278. u32 fatal_err_interrupt;
  279. u32 fatal_err_dump_offset0;
  280. u32 fatal_err_dump_length0;
  281. u32 fatal_err_dump_offset1;
  282. u32 fatal_err_dump_length1;
  283. u32 hda_mode_flag;
  284. u32 anolog_setup_table_offset;
  285. u32 rsvd[4];
  286. } pm8001_tbl;
  287. struct {
  288. u32 signature;
  289. u32 interface_rev;
  290. u32 firmware_rev;
  291. u32 max_out_io;
  292. u32 max_sgl;
  293. u32 ctrl_cap_flag;
  294. u32 gst_offset;
  295. u32 inbound_queue_offset;
  296. u32 outbound_queue_offset;
  297. u32 inbound_q_nppd_hppd;
  298. u32 rsvd[8];
  299. u32 crc_core_dump;
  300. u32 rsvd1;
  301. u32 upper_event_log_addr;
  302. u32 lower_event_log_addr;
  303. u32 event_log_size;
  304. u32 event_log_severity;
  305. u32 upper_pcs_event_log_addr;
  306. u32 lower_pcs_event_log_addr;
  307. u32 pcs_event_log_size;
  308. u32 pcs_event_log_severity;
  309. u32 fatal_err_interrupt;
  310. u32 fatal_err_dump_offset0;
  311. u32 fatal_err_dump_length0;
  312. u32 fatal_err_dump_offset1;
  313. u32 fatal_err_dump_length1;
  314. u32 gpio_led_mapping;
  315. u32 analog_setup_table_offset;
  316. u32 int_vec_table_offset;
  317. u32 phy_attr_table_offset;
  318. u32 port_recovery_timer;
  319. u32 interrupt_reassertion_delay;
  320. } pm80xx_tbl;
  321. };
  322. union general_status_table {
  323. struct {
  324. u32 gst_len_mpistate;
  325. u32 iq_freeze_state0;
  326. u32 iq_freeze_state1;
  327. u32 msgu_tcnt;
  328. u32 iop_tcnt;
  329. u32 rsvd;
  330. u32 phy_state[8];
  331. u32 gpio_input_val;
  332. u32 rsvd1[2];
  333. u32 recover_err_info[8];
  334. } pm8001_tbl;
  335. struct {
  336. u32 gst_len_mpistate;
  337. u32 iq_freeze_state0;
  338. u32 iq_freeze_state1;
  339. u32 msgu_tcnt;
  340. u32 iop_tcnt;
  341. u32 rsvd[9];
  342. u32 gpio_input_val;
  343. u32 rsvd1[2];
  344. u32 recover_err_info[8];
  345. } pm80xx_tbl;
  346. };
  347. struct inbound_queue_table {
  348. u32 element_pri_size_cnt;
  349. u32 upper_base_addr;
  350. u32 lower_base_addr;
  351. u32 ci_upper_base_addr;
  352. u32 ci_lower_base_addr;
  353. u32 pi_pci_bar;
  354. u32 pi_offset;
  355. u32 total_length;
  356. void *base_virt;
  357. void *ci_virt;
  358. u32 reserved;
  359. __le32 consumer_index;
  360. u32 producer_idx;
  361. };
  362. struct outbound_queue_table {
  363. u32 element_size_cnt;
  364. u32 upper_base_addr;
  365. u32 lower_base_addr;
  366. void *base_virt;
  367. u32 pi_upper_base_addr;
  368. u32 pi_lower_base_addr;
  369. u32 ci_pci_bar;
  370. u32 ci_offset;
  371. u32 total_length;
  372. void *pi_virt;
  373. u32 interrup_vec_cnt_delay;
  374. u32 dinterrup_to_pci_offset;
  375. __le32 producer_index;
  376. u32 consumer_idx;
  377. };
  378. struct pm8001_hba_memspace {
  379. void __iomem *memvirtaddr;
  380. u64 membase;
  381. u32 memsize;
  382. };
  383. struct pm8001_hba_info {
  384. char name[PM8001_NAME_LENGTH];
  385. struct list_head list;
  386. unsigned long flags;
  387. spinlock_t lock;/* host-wide lock */
  388. struct pci_dev *pdev;/* our device */
  389. struct device *dev;
  390. struct pm8001_hba_memspace io_mem[6];
  391. struct mpi_mem_req memoryMap;
  392. struct encrypt encrypt_info; /* support encryption */
  393. void __iomem *msg_unit_tbl_addr;/*Message Unit Table Addr*/
  394. void __iomem *main_cfg_tbl_addr;/*Main Config Table Addr*/
  395. void __iomem *general_stat_tbl_addr;/*General Status Table Addr*/
  396. void __iomem *inbnd_q_tbl_addr;/*Inbound Queue Config Table Addr*/
  397. void __iomem *outbnd_q_tbl_addr;/*Outbound Queue Config Table Addr*/
  398. void __iomem *pspa_q_tbl_addr;
  399. /*MPI SAS PHY attributes Queue Config Table Addr*/
  400. void __iomem *ivt_tbl_addr; /*MPI IVT Table Addr */
  401. union main_cfg_table main_cfg_tbl;
  402. union general_status_table gs_tbl;
  403. struct inbound_queue_table inbnd_q_tbl[PM8001_MAX_SPCV_INB_NUM];
  404. struct outbound_queue_table outbnd_q_tbl[PM8001_MAX_SPCV_OUTB_NUM];
  405. struct sas_phy_attribute_table phy_attr_table;
  406. /* MPI SAS PHY attributes */
  407. u8 sas_addr[SAS_ADDR_SIZE];
  408. struct sas_ha_struct *sas;/* SCSI/SAS glue */
  409. struct Scsi_Host *shost;
  410. u32 chip_id;
  411. const struct pm8001_chip_info *chip;
  412. struct completion *nvmd_completion;
  413. int tags_num;
  414. unsigned long *tags;
  415. struct pm8001_phy phy[PM8001_MAX_PHYS];
  416. struct pm8001_port port[PM8001_MAX_PHYS];
  417. u32 id;
  418. u32 irq;
  419. u32 iomb_size; /* SPC and SPCV IOMB size */
  420. struct pm8001_device *devices;
  421. struct pm8001_ccb_info *ccb_info;
  422. #ifdef PM8001_USE_MSIX
  423. struct msix_entry msix_entries[PM8001_MAX_MSIX_VEC];
  424. /*for msi-x interrupt*/
  425. int number_of_intr;/*will be used in remove()*/
  426. #endif
  427. #ifdef PM8001_USE_TASKLET
  428. struct tasklet_struct tasklet;
  429. #endif
  430. u32 logging_level;
  431. u32 fw_status;
  432. u32 smp_exp_mode;
  433. u32 int_vector;
  434. const struct firmware *fw_image;
  435. u8 outq[PM8001_MAX_MSIX_VEC];
  436. };
  437. struct pm8001_work {
  438. struct work_struct work;
  439. struct pm8001_hba_info *pm8001_ha;
  440. void *data;
  441. int handler;
  442. };
  443. struct pm8001_fw_image_header {
  444. u8 vender_id[8];
  445. u8 product_id;
  446. u8 hardware_rev;
  447. u8 dest_partition;
  448. u8 reserved;
  449. u8 fw_rev[4];
  450. __be32 image_length;
  451. __be32 image_crc;
  452. __be32 startup_entry;
  453. } __attribute__((packed, aligned(4)));
  454. /**
  455. * FW Flash Update status values
  456. */
  457. #define FLASH_UPDATE_COMPLETE_PENDING_REBOOT 0x00
  458. #define FLASH_UPDATE_IN_PROGRESS 0x01
  459. #define FLASH_UPDATE_HDR_ERR 0x02
  460. #define FLASH_UPDATE_OFFSET_ERR 0x03
  461. #define FLASH_UPDATE_CRC_ERR 0x04
  462. #define FLASH_UPDATE_LENGTH_ERR 0x05
  463. #define FLASH_UPDATE_HW_ERR 0x06
  464. #define FLASH_UPDATE_DNLD_NOT_SUPPORTED 0x10
  465. #define FLASH_UPDATE_DISABLED 0x11
  466. #define NCQ_READ_LOG_FLAG 0x80000000
  467. #define NCQ_ABORT_ALL_FLAG 0x40000000
  468. #define NCQ_2ND_RLE_FLAG 0x20000000
  469. /**
  470. * brief param structure for firmware flash update.
  471. */
  472. struct fw_flash_updata_info {
  473. u32 cur_image_offset;
  474. u32 cur_image_len;
  475. u32 total_image_len;
  476. struct pm8001_prd sgl;
  477. };
  478. struct fw_control_info {
  479. u32 retcode;/*ret code (status)*/
  480. u32 phase;/*ret code phase*/
  481. u32 phaseCmplt;/*percent complete for the current
  482. update phase */
  483. u32 version;/*Hex encoded firmware version number*/
  484. u32 offset;/*Used for downloading firmware */
  485. u32 len; /*len of buffer*/
  486. u32 size;/* Used in OS VPD and Trace get size
  487. operations.*/
  488. u32 reserved;/* padding required for 64 bit
  489. alignment */
  490. u8 buffer[1];/* Start of buffer */
  491. };
  492. struct fw_control_ex {
  493. struct fw_control_info *fw_control;
  494. void *buffer;/* keep buffer pointer to be
  495. freed when the response comes*/
  496. void *virtAddr;/* keep virtual address of the data */
  497. void *usrAddr;/* keep virtual address of the
  498. user data */
  499. dma_addr_t phys_addr;
  500. u32 len; /* len of buffer */
  501. void *payload; /* pointer to IOCTL Payload */
  502. u8 inProgress;/*if 1 - the IOCTL request is in
  503. progress */
  504. void *param1;
  505. void *param2;
  506. void *param3;
  507. };
  508. /* pm8001 workqueue */
  509. extern struct workqueue_struct *pm8001_wq;
  510. /******************** function prototype *********************/
  511. int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out);
  512. void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha);
  513. u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag);
  514. void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx);
  515. void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
  516. struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx);
  517. int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
  518. void *funcdata);
  519. void pm8001_scan_start(struct Scsi_Host *shost);
  520. int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time);
  521. int pm8001_queue_command(struct sas_task *task, const int num,
  522. gfp_t gfp_flags);
  523. int pm8001_abort_task(struct sas_task *task);
  524. int pm8001_abort_task_set(struct domain_device *dev, u8 *lun);
  525. int pm8001_clear_aca(struct domain_device *dev, u8 *lun);
  526. int pm8001_clear_task_set(struct domain_device *dev, u8 *lun);
  527. int pm8001_dev_found(struct domain_device *dev);
  528. void pm8001_dev_gone(struct domain_device *dev);
  529. int pm8001_lu_reset(struct domain_device *dev, u8 *lun);
  530. int pm8001_I_T_nexus_reset(struct domain_device *dev);
  531. int pm8001_I_T_nexus_event_handler(struct domain_device *dev);
  532. int pm8001_query_task(struct sas_task *task);
  533. void pm8001_open_reject_retry(
  534. struct pm8001_hba_info *pm8001_ha,
  535. struct sas_task *task_to_close,
  536. struct pm8001_device *device_to_close);
  537. int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr,
  538. dma_addr_t *pphys_addr, u32 *pphys_addr_hi, u32 *pphys_addr_lo,
  539. u32 mem_size, u32 align);
  540. void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha);
  541. int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
  542. struct inbound_queue_table *circularQ,
  543. u32 opCode, void *payload, u32 responseQueue);
  544. int pm8001_mpi_msg_free_get(struct inbound_queue_table *circularQ,
  545. u16 messageSize, void **messagePtr);
  546. u32 pm8001_mpi_msg_free_set(struct pm8001_hba_info *pm8001_ha, void *pMsg,
  547. struct outbound_queue_table *circularQ, u8 bc);
  548. u32 pm8001_mpi_msg_consume(struct pm8001_hba_info *pm8001_ha,
  549. struct outbound_queue_table *circularQ,
  550. void **messagePtr1, u8 *pBC);
  551. int pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
  552. struct pm8001_device *pm8001_dev, u32 state);
  553. int pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
  554. void *payload);
  555. int pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha,
  556. void *fw_flash_updata_info, u32 tag);
  557. int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, void *payload);
  558. int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, void *payload);
  559. int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha,
  560. struct pm8001_ccb_info *ccb,
  561. struct pm8001_tmf_task *tmf);
  562. int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,
  563. struct pm8001_device *pm8001_dev,
  564. u8 flag, u32 task_tag, u32 cmd_tag);
  565. int pm8001_chip_dereg_dev_req(struct pm8001_hba_info *pm8001_ha, u32 device_id);
  566. void pm8001_chip_make_sg(struct scatterlist *scatter, int nr, void *prd);
  567. void pm8001_work_fn(struct work_struct *work);
  568. int pm8001_handle_event(struct pm8001_hba_info *pm8001_ha,
  569. void *data, int handler);
  570. void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info *pm8001_ha,
  571. void *piomb);
  572. void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha,
  573. void *piomb);
  574. void pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha,
  575. void *piomb);
  576. int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha,
  577. void *piomb);
  578. void pm8001_get_lrate_mode(struct pm8001_phy *phy, u8 link_rate);
  579. void pm8001_get_attached_sas_addr(struct pm8001_phy *phy, u8 *sas_addr);
  580. void pm8001_bytes_dmaed(struct pm8001_hba_info *pm8001_ha, int i);
  581. int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb);
  582. int pm8001_mpi_dereg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb);
  583. int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha,
  584. void *piomb);
  585. int pm8001_mpi_general_event(struct pm8001_hba_info *pm8001_ha , void *piomb);
  586. int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb);
  587. struct sas_task *pm8001_alloc_task(void);
  588. void pm8001_task_done(struct sas_task *task);
  589. void pm8001_free_task(struct sas_task *task);
  590. void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag);
  591. struct pm8001_device *pm8001_find_dev(struct pm8001_hba_info *pm8001_ha,
  592. u32 device_id);
  593. int pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha);
  594. int pm8001_bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue);
  595. /* ctl shared API */
  596. extern struct device_attribute *pm8001_host_attrs[];
  597. #endif