mv_sas.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. mv_sas.h - Marvell 88SE6440 SAS/SATA support
  3. Copyright 2007 Red Hat, Inc.
  4. Copyright 2008 Marvell. <kewei@marvell.com>
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2,
  8. or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty
  11. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. See the GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public
  14. License along with this program; see the file COPYING. If not,
  15. write to the Free Software Foundation, 675 Mass Ave, Cambridge,
  16. MA 02139, USA.
  17. */
  18. #ifndef _MV_SAS_H_
  19. #define _MV_SAS_H_
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/delay.h>
  24. #include <linux/types.h>
  25. #include <linux/ctype.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/pci.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/irq.h>
  31. #include <linux/vmalloc.h>
  32. #include <scsi/libsas.h>
  33. #include <scsi/scsi_tcq.h>
  34. #include <scsi/sas_ata.h>
  35. #include <linux/version.h>
  36. #include "mv_defs.h"
  37. #define DRV_NAME "mvsas"
  38. #define DRV_VERSION "0.5.2"
  39. #define _MV_DUMP 0
  40. #define MVS_DISABLE_NVRAM
  41. #define MVS_DISABLE_MSI
  42. #define MVS_ID_NOT_MAPPED 0x7f
  43. #define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width)
  44. #define for_each_phy(__lseq_mask, __mc, __lseq, __rest) \
  45. for ((__mc) = (__lseq_mask), (__lseq) = 0; \
  46. (__mc) != 0 && __rest; \
  47. (++__lseq), (__mc) >>= 1)
  48. struct mvs_chip_info {
  49. u32 n_phy;
  50. u32 srs_sz;
  51. u32 slot_width;
  52. };
  53. struct mvs_err_info {
  54. __le32 flags;
  55. __le32 flags2;
  56. };
  57. struct mvs_cmd_hdr {
  58. __le32 flags; /* PRD tbl len; SAS, SATA ctl */
  59. __le32 lens; /* cmd, max resp frame len */
  60. __le32 tags; /* targ port xfer tag; tag */
  61. __le32 data_len; /* data xfer len */
  62. __le64 cmd_tbl; /* command table address */
  63. __le64 open_frame; /* open addr frame address */
  64. __le64 status_buf; /* status buffer address */
  65. __le64 prd_tbl; /* PRD tbl address */
  66. __le32 reserved[4];
  67. };
  68. struct mvs_port {
  69. struct asd_sas_port sas_port;
  70. u8 port_attached;
  71. u8 taskfileset;
  72. u8 wide_port_phymap;
  73. struct list_head list;
  74. };
  75. struct mvs_phy {
  76. struct mvs_port *port;
  77. struct asd_sas_phy sas_phy;
  78. struct sas_identify identify;
  79. struct scsi_device *sdev;
  80. u64 dev_sas_addr;
  81. u64 att_dev_sas_addr;
  82. u32 att_dev_info;
  83. u32 dev_info;
  84. u32 phy_type;
  85. u32 phy_status;
  86. u32 irq_status;
  87. u32 frame_rcvd_size;
  88. u8 frame_rcvd[32];
  89. u8 phy_attached;
  90. enum sas_linkrate minimum_linkrate;
  91. enum sas_linkrate maximum_linkrate;
  92. };
  93. struct mvs_slot_info {
  94. struct list_head list;
  95. struct sas_task *task;
  96. u32 n_elem;
  97. u32 tx;
  98. /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
  99. * and PRD table
  100. */
  101. void *buf;
  102. dma_addr_t buf_dma;
  103. #if _MV_DUMP
  104. u32 cmd_size;
  105. #endif
  106. void *response;
  107. struct mvs_port *port;
  108. };
  109. struct mvs_info {
  110. unsigned long flags;
  111. /* host-wide lock */
  112. spinlock_t lock;
  113. /* our device */
  114. struct pci_dev *pdev;
  115. /* enhanced mode registers */
  116. void __iomem *regs;
  117. /* peripheral registers */
  118. void __iomem *peri_regs;
  119. u8 sas_addr[SAS_ADDR_SIZE];
  120. /* SCSI/SAS glue */
  121. struct sas_ha_struct sas;
  122. struct Scsi_Host *shost;
  123. /* TX (delivery) DMA ring */
  124. __le32 *tx;
  125. dma_addr_t tx_dma;
  126. /* cached next-producer idx */
  127. u32 tx_prod;
  128. /* RX (completion) DMA ring */
  129. __le32 *rx;
  130. dma_addr_t rx_dma;
  131. /* RX consumer idx */
  132. u32 rx_cons;
  133. /* RX'd FIS area */
  134. __le32 *rx_fis;
  135. dma_addr_t rx_fis_dma;
  136. /* DMA command header slots */
  137. struct mvs_cmd_hdr *slot;
  138. dma_addr_t slot_dma;
  139. const struct mvs_chip_info *chip;
  140. u8 tags[MVS_SLOTS];
  141. struct mvs_slot_info slot_info[MVS_SLOTS];
  142. /* further per-slot information */
  143. struct mvs_phy phy[MVS_MAX_PHYS];
  144. struct mvs_port port[MVS_MAX_PHYS];
  145. #ifdef MVS_USE_TASKLET
  146. struct tasklet_struct tasklet;
  147. #endif
  148. };
  149. int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
  150. void *funcdata);
  151. int mvs_slave_configure(struct scsi_device *sdev);
  152. void mvs_scan_start(struct Scsi_Host *shost);
  153. int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time);
  154. int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags);
  155. int mvs_task_abort(struct sas_task *task);
  156. void mvs_port_formed(struct asd_sas_phy *sas_phy);
  157. int mvs_I_T_nexus_reset(struct domain_device *dev);
  158. void mvs_int_full(struct mvs_info *mvi);
  159. void mvs_tag_init(struct mvs_info *mvi);
  160. int mvs_nvram_read(struct mvs_info *mvi, u32 addr, void *buf, u32 buflen);
  161. int __devinit mvs_hw_init(struct mvs_info *mvi);
  162. void __devinit mvs_print_info(struct mvs_info *mvi);
  163. void mvs_hba_interrupt_enable(struct mvs_info *mvi);
  164. void mvs_hba_interrupt_disable(struct mvs_info *mvi);
  165. void mvs_detect_porttype(struct mvs_info *mvi, int i);
  166. u8 mvs_assign_reg_set(struct mvs_info *mvi, struct mvs_port *port);
  167. void mvs_enable_xmt(struct mvs_info *mvi, int PhyId);
  168. void __devinit mvs_phy_hacks(struct mvs_info *mvi);
  169. void mvs_free_reg_set(struct mvs_info *mvi, struct mvs_port *port);
  170. #endif