Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 1 | /* |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 2 | * Marvell 88SE64xx/88SE94xx main function head file |
| 3 | * |
| 4 | * Copyright 2007 Red Hat, Inc. |
| 5 | * Copyright 2008 Marvell. <kewei@marvell.com> |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 6 | * Copyright 2009-2011 Marvell. <yuxiangl@marvell.com> |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 7 | * |
| 8 | * This file is licensed under GPLv2. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; version 2 of the |
| 13 | * License. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 23 | * USA |
| 24 | */ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 25 | |
| 26 | #ifndef _MV_SAS_H_ |
| 27 | #define _MV_SAS_H_ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/module.h> |
| 31 | #include <linux/spinlock.h> |
| 32 | #include <linux/delay.h> |
| 33 | #include <linux/types.h> |
| 34 | #include <linux/ctype.h> |
| 35 | #include <linux/dma-mapping.h> |
| 36 | #include <linux/pci.h> |
| 37 | #include <linux/platform_device.h> |
| 38 | #include <linux/interrupt.h> |
| 39 | #include <linux/irq.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 40 | #include <linux/slab.h> |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 41 | #include <linux/vmalloc.h> |
| 42 | #include <scsi/libsas.h> |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 43 | #include <scsi/scsi.h> |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 44 | #include <scsi/scsi_tcq.h> |
| 45 | #include <scsi/sas_ata.h> |
| 46 | #include <linux/version.h> |
| 47 | #include "mv_defs.h" |
| 48 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 49 | #define DRV_NAME "mvsas" |
| 50 | #define DRV_VERSION "0.8.2" |
| 51 | #define _MV_DUMP 0 |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 52 | #define MVS_ID_NOT_MAPPED 0x7f |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 53 | /* #define DISABLE_HOTPLUG_DMA_FIX */ |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 54 | // #define MAX_EXP_RUNNING_REQ 2 |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 55 | #define WIDE_PORT_MAX_PHY 4 |
| 56 | #define MV_DISABLE_NCQ 0 |
| 57 | #define mv_printk(fmt, arg ...) \ |
| 58 | printk(KERN_DEBUG"%s %d:" fmt, __FILE__, __LINE__, ## arg) |
| 59 | #ifdef MV_DEBUG |
| 60 | #define mv_dprintk(format, arg...) \ |
| 61 | printk(KERN_DEBUG"%s %d:" format, __FILE__, __LINE__, ## arg) |
| 62 | #else |
| 63 | #define mv_dprintk(format, arg...) |
| 64 | #endif |
| 65 | #define MV_MAX_U32 0xffffffff |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 66 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 67 | extern struct mvs_tgt_initiator mvs_tgt; |
| 68 | extern struct mvs_info *tgt_mvi; |
| 69 | extern const struct mvs_dispatch mvs_64xx_dispatch; |
| 70 | extern const struct mvs_dispatch mvs_94xx_dispatch; |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 71 | extern struct kmem_cache *mvs_task_list_cache; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 72 | |
| 73 | #define DEV_IS_EXPANDER(type) \ |
| 74 | ((type == EDGE_DEV) || (type == FANOUT_DEV)) |
| 75 | |
| 76 | #define bit(n) ((u32)1 << n) |
| 77 | |
| 78 | #define for_each_phy(__lseq_mask, __mc, __lseq) \ |
| 79 | for ((__mc) = (__lseq_mask), (__lseq) = 0; \ |
| 80 | (__mc) != 0 ; \ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 81 | (++__lseq), (__mc) >>= 1) |
| 82 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 83 | #define MV_INIT_DELAYED_WORK(w, f, d) INIT_DELAYED_WORK(w, f) |
| 84 | #define UNASSOC_D2H_FIS(id) \ |
| 85 | ((void *) mvi->rx_fis + 0x100 * id) |
| 86 | #define SATA_RECEIVED_FIS_LIST(reg_set) \ |
| 87 | ((void *) mvi->rx_fis + mvi->chip->fis_offs + 0x100 * reg_set) |
| 88 | #define SATA_RECEIVED_SDB_FIS(reg_set) \ |
| 89 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x58) |
| 90 | #define SATA_RECEIVED_D2H_FIS(reg_set) \ |
| 91 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x40) |
| 92 | #define SATA_RECEIVED_PIO_FIS(reg_set) \ |
| 93 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x20) |
| 94 | #define SATA_RECEIVED_DMA_FIS(reg_set) \ |
| 95 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x00) |
| 96 | |
| 97 | enum dev_status { |
| 98 | MVS_DEV_NORMAL = 0x0, |
| 99 | MVS_DEV_EH = 0x1, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 100 | }; |
| 101 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 102 | |
| 103 | struct mvs_info; |
| 104 | |
| 105 | struct mvs_dispatch { |
| 106 | char *name; |
| 107 | int (*chip_init)(struct mvs_info *mvi); |
| 108 | int (*spi_init)(struct mvs_info *mvi); |
| 109 | int (*chip_ioremap)(struct mvs_info *mvi); |
| 110 | void (*chip_iounmap)(struct mvs_info *mvi); |
| 111 | irqreturn_t (*isr)(struct mvs_info *mvi, int irq, u32 stat); |
| 112 | u32 (*isr_status)(struct mvs_info *mvi, int irq); |
| 113 | void (*interrupt_enable)(struct mvs_info *mvi); |
| 114 | void (*interrupt_disable)(struct mvs_info *mvi); |
| 115 | |
| 116 | u32 (*read_phy_ctl)(struct mvs_info *mvi, u32 port); |
| 117 | void (*write_phy_ctl)(struct mvs_info *mvi, u32 port, u32 val); |
| 118 | |
| 119 | u32 (*read_port_cfg_data)(struct mvs_info *mvi, u32 port); |
| 120 | void (*write_port_cfg_data)(struct mvs_info *mvi, u32 port, u32 val); |
| 121 | void (*write_port_cfg_addr)(struct mvs_info *mvi, u32 port, u32 addr); |
| 122 | |
| 123 | u32 (*read_port_vsr_data)(struct mvs_info *mvi, u32 port); |
| 124 | void (*write_port_vsr_data)(struct mvs_info *mvi, u32 port, u32 val); |
| 125 | void (*write_port_vsr_addr)(struct mvs_info *mvi, u32 port, u32 addr); |
| 126 | |
| 127 | u32 (*read_port_irq_stat)(struct mvs_info *mvi, u32 port); |
| 128 | void (*write_port_irq_stat)(struct mvs_info *mvi, u32 port, u32 val); |
| 129 | |
| 130 | u32 (*read_port_irq_mask)(struct mvs_info *mvi, u32 port); |
| 131 | void (*write_port_irq_mask)(struct mvs_info *mvi, u32 port, u32 val); |
| 132 | |
| 133 | void (*get_sas_addr)(void *buf, u32 buflen); |
| 134 | void (*command_active)(struct mvs_info *mvi, u32 slot_idx); |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 135 | void (*clear_srs_irq)(struct mvs_info *mvi, u8 reg_set, u8 clear_all); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 136 | void (*issue_stop)(struct mvs_info *mvi, enum mvs_port_type type, |
| 137 | u32 tfs); |
| 138 | void (*start_delivery)(struct mvs_info *mvi, u32 tx); |
| 139 | u32 (*rx_update)(struct mvs_info *mvi); |
| 140 | void (*int_full)(struct mvs_info *mvi); |
| 141 | u8 (*assign_reg_set)(struct mvs_info *mvi, u8 *tfs); |
| 142 | void (*free_reg_set)(struct mvs_info *mvi, u8 *tfs); |
| 143 | u32 (*prd_size)(void); |
| 144 | u32 (*prd_count)(void); |
| 145 | void (*make_prd)(struct scatterlist *scatter, int nr, void *prd); |
| 146 | void (*detect_porttype)(struct mvs_info *mvi, int i); |
| 147 | int (*oob_done)(struct mvs_info *mvi, int i); |
| 148 | void (*fix_phy_info)(struct mvs_info *mvi, int i, |
| 149 | struct sas_identify_frame *id); |
| 150 | void (*phy_work_around)(struct mvs_info *mvi, int i); |
| 151 | void (*phy_set_link_rate)(struct mvs_info *mvi, u32 phy_id, |
| 152 | struct sas_phy_linkrates *rates); |
| 153 | u32 (*phy_max_link_rate)(void); |
| 154 | void (*phy_disable)(struct mvs_info *mvi, u32 phy_id); |
| 155 | void (*phy_enable)(struct mvs_info *mvi, u32 phy_id); |
| 156 | void (*phy_reset)(struct mvs_info *mvi, u32 phy_id, int hard); |
| 157 | void (*stp_reset)(struct mvs_info *mvi, u32 phy_id); |
| 158 | void (*clear_active_cmds)(struct mvs_info *mvi); |
| 159 | u32 (*spi_read_data)(struct mvs_info *mvi); |
| 160 | void (*spi_write_data)(struct mvs_info *mvi, u32 data); |
| 161 | int (*spi_buildcmd)(struct mvs_info *mvi, |
| 162 | u32 *dwCmd, |
| 163 | u8 cmd, |
| 164 | u8 read, |
| 165 | u8 length, |
| 166 | u32 addr |
| 167 | ); |
| 168 | int (*spi_issuecmd)(struct mvs_info *mvi, u32 cmd); |
| 169 | int (*spi_waitdataready)(struct mvs_info *mvi, u32 timeout); |
| 170 | #ifndef DISABLE_HOTPLUG_DMA_FIX |
| 171 | void (*dma_fix)(dma_addr_t buf_dma, int buf_len, int from, void *prd); |
| 172 | #endif |
Xiangliang Yu | 534ff10 | 2011-05-24 22:26:50 +0800 | [diff] [blame^] | 173 | void (*non_spec_ncq_error)(struct mvs_info *mvi); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 174 | |
| 175 | }; |
| 176 | |
| 177 | struct mvs_chip_info { |
| 178 | u32 n_host; |
| 179 | u32 n_phy; |
| 180 | u32 fis_offs; |
| 181 | u32 fis_count; |
| 182 | u32 srs_sz; |
| 183 | u32 slot_width; |
| 184 | const struct mvs_dispatch *dispatch; |
| 185 | }; |
| 186 | #define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width) |
| 187 | #define MVS_RX_FISL_SZ \ |
| 188 | (mvi->chip->fis_offs + (mvi->chip->fis_count * 0x100)) |
| 189 | #define MVS_CHIP_DISP (mvi->chip->dispatch) |
| 190 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 191 | struct mvs_err_info { |
| 192 | __le32 flags; |
| 193 | __le32 flags2; |
| 194 | }; |
| 195 | |
| 196 | struct mvs_cmd_hdr { |
| 197 | __le32 flags; /* PRD tbl len; SAS, SATA ctl */ |
| 198 | __le32 lens; /* cmd, max resp frame len */ |
| 199 | __le32 tags; /* targ port xfer tag; tag */ |
| 200 | __le32 data_len; /* data xfer len */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 201 | __le64 cmd_tbl; /* command table address */ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 202 | __le64 open_frame; /* open addr frame address */ |
| 203 | __le64 status_buf; /* status buffer address */ |
| 204 | __le64 prd_tbl; /* PRD tbl address */ |
| 205 | __le32 reserved[4]; |
| 206 | }; |
| 207 | |
| 208 | struct mvs_port { |
| 209 | struct asd_sas_port sas_port; |
| 210 | u8 port_attached; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 211 | u8 wide_port_phymap; |
| 212 | struct list_head list; |
| 213 | }; |
| 214 | |
| 215 | struct mvs_phy { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 216 | struct mvs_info *mvi; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 217 | struct mvs_port *port; |
| 218 | struct asd_sas_phy sas_phy; |
| 219 | struct sas_identify identify; |
| 220 | struct scsi_device *sdev; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 221 | struct timer_list timer; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 222 | u64 dev_sas_addr; |
| 223 | u64 att_dev_sas_addr; |
| 224 | u32 att_dev_info; |
| 225 | u32 dev_info; |
| 226 | u32 phy_type; |
| 227 | u32 phy_status; |
| 228 | u32 irq_status; |
| 229 | u32 frame_rcvd_size; |
| 230 | u8 frame_rcvd[32]; |
| 231 | u8 phy_attached; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 232 | u8 phy_mode; |
| 233 | u8 reserved[2]; |
| 234 | u32 phy_event; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 235 | enum sas_linkrate minimum_linkrate; |
| 236 | enum sas_linkrate maximum_linkrate; |
| 237 | }; |
| 238 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 239 | struct mvs_device { |
Andy Yan | 9870d9a | 2009-05-11 22:19:25 +0800 | [diff] [blame] | 240 | struct list_head dev_entry; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 241 | enum sas_dev_type dev_type; |
Andy Yan | 9870d9a | 2009-05-11 22:19:25 +0800 | [diff] [blame] | 242 | struct mvs_info *mvi_info; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 243 | struct domain_device *sas_device; |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 244 | struct timer_list timer; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 245 | u32 attached_phy; |
| 246 | u32 device_id; |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 247 | u32 running_req; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 248 | u8 taskfileset; |
| 249 | u8 dev_status; |
| 250 | u16 reserved; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 251 | }; |
| 252 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 253 | struct mvs_slot_info { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 254 | struct list_head entry; |
| 255 | union { |
| 256 | struct sas_task *task; |
| 257 | void *tdata; |
| 258 | }; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 259 | u32 n_elem; |
| 260 | u32 tx; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 261 | u32 slot_tag; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 262 | |
| 263 | /* DMA buffer for storing cmd tbl, open addr frame, status buffer, |
| 264 | * and PRD table |
| 265 | */ |
| 266 | void *buf; |
| 267 | dma_addr_t buf_dma; |
| 268 | #if _MV_DUMP |
| 269 | u32 cmd_size; |
| 270 | #endif |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 271 | void *response; |
| 272 | struct mvs_port *port; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 273 | struct mvs_device *device; |
| 274 | void *open_frame; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | struct mvs_info { |
| 278 | unsigned long flags; |
| 279 | |
| 280 | /* host-wide lock */ |
| 281 | spinlock_t lock; |
| 282 | |
| 283 | /* our device */ |
| 284 | struct pci_dev *pdev; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 285 | struct device *dev; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 286 | |
| 287 | /* enhanced mode registers */ |
| 288 | void __iomem *regs; |
| 289 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 290 | /* peripheral or soc registers */ |
| 291 | void __iomem *regs_ex; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 292 | u8 sas_addr[SAS_ADDR_SIZE]; |
| 293 | |
| 294 | /* SCSI/SAS glue */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 295 | struct sas_ha_struct *sas; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 296 | struct Scsi_Host *shost; |
| 297 | |
| 298 | /* TX (delivery) DMA ring */ |
| 299 | __le32 *tx; |
| 300 | dma_addr_t tx_dma; |
| 301 | |
| 302 | /* cached next-producer idx */ |
| 303 | u32 tx_prod; |
| 304 | |
| 305 | /* RX (completion) DMA ring */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 306 | __le32 *rx; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 307 | dma_addr_t rx_dma; |
| 308 | |
| 309 | /* RX consumer idx */ |
| 310 | u32 rx_cons; |
| 311 | |
| 312 | /* RX'd FIS area */ |
| 313 | __le32 *rx_fis; |
| 314 | dma_addr_t rx_fis_dma; |
| 315 | |
| 316 | /* DMA command header slots */ |
| 317 | struct mvs_cmd_hdr *slot; |
| 318 | dma_addr_t slot_dma; |
| 319 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 320 | u32 chip_id; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 321 | const struct mvs_chip_info *chip; |
| 322 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 323 | int tags_num; |
Andy Yan | 77db27c | 2009-05-11 21:56:31 +0800 | [diff] [blame] | 324 | DECLARE_BITMAP(tags, MVS_SLOTS); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 325 | /* further per-slot information */ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 326 | struct mvs_phy phy[MVS_MAX_PHYS]; |
| 327 | struct mvs_port port[MVS_MAX_PHYS]; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 328 | u32 irq; |
| 329 | u32 exp_req; |
| 330 | u32 id; |
| 331 | u64 sata_reg_set; |
| 332 | struct list_head *hba_list; |
| 333 | struct list_head soc_entry; |
| 334 | struct list_head wq_list; |
| 335 | unsigned long instance; |
| 336 | u16 flashid; |
| 337 | u32 flashsize; |
| 338 | u32 flashsectSize; |
| 339 | |
| 340 | void *addon; |
| 341 | struct mvs_device devices[MVS_MAX_DEVICES]; |
| 342 | #ifndef DISABLE_HOTPLUG_DMA_FIX |
| 343 | void *bulk_buffer; |
| 344 | dma_addr_t bulk_buffer_dma; |
| 345 | #define TRASH_BUCKET_SIZE 0x20000 |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 346 | #endif |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 347 | void *dma_pool; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 348 | struct mvs_slot_info slot_info[0]; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 349 | }; |
| 350 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 351 | struct mvs_prv_info{ |
| 352 | u8 n_host; |
| 353 | u8 n_phy; |
| 354 | u16 reserve; |
| 355 | struct mvs_info *mvi[2]; |
| 356 | }; |
| 357 | |
| 358 | struct mvs_wq { |
| 359 | struct delayed_work work_q; |
| 360 | struct mvs_info *mvi; |
| 361 | void *data; |
| 362 | int handler; |
| 363 | struct list_head entry; |
| 364 | }; |
| 365 | |
| 366 | struct mvs_task_exec_info { |
| 367 | struct sas_task *task; |
| 368 | struct mvs_cmd_hdr *hdr; |
| 369 | struct mvs_port *port; |
| 370 | u32 tag; |
| 371 | int n_elem; |
| 372 | }; |
| 373 | |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 374 | struct mvs_task_list { |
| 375 | struct sas_task *task; |
| 376 | struct list_head list; |
| 377 | }; |
| 378 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 379 | |
| 380 | /******************** function prototype *********************/ |
| 381 | void mvs_get_sas_addr(void *buf, u32 buflen); |
| 382 | void mvs_tag_clear(struct mvs_info *mvi, u32 tag); |
| 383 | void mvs_tag_free(struct mvs_info *mvi, u32 tag); |
| 384 | void mvs_tag_set(struct mvs_info *mvi, unsigned int tag); |
| 385 | int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out); |
| 386 | void mvs_tag_init(struct mvs_info *mvi); |
| 387 | void mvs_iounmap(void __iomem *regs); |
| 388 | int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex); |
| 389 | void mvs_phys_reset(struct mvs_info *mvi, u32 phy_mask, int hard); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 390 | int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, |
| 391 | void *funcdata); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 392 | void __devinit mvs_set_sas_addr(struct mvs_info *mvi, int port_id, |
| 393 | u32 off_lo, u32 off_hi, u64 sas_addr); |
| 394 | int mvs_slave_alloc(struct scsi_device *scsi_dev); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 395 | int mvs_slave_configure(struct scsi_device *sdev); |
| 396 | void mvs_scan_start(struct Scsi_Host *shost); |
| 397 | int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 398 | int mvs_queue_command(struct sas_task *task, const int num, |
| 399 | gfp_t gfp_flags); |
| 400 | int mvs_abort_task(struct sas_task *task); |
| 401 | int mvs_abort_task_set(struct domain_device *dev, u8 *lun); |
| 402 | int mvs_clear_aca(struct domain_device *dev, u8 *lun); |
| 403 | int mvs_clear_task_set(struct domain_device *dev, u8 * lun); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 404 | void mvs_port_formed(struct asd_sas_phy *sas_phy); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 405 | void mvs_port_deformed(struct asd_sas_phy *sas_phy); |
| 406 | int mvs_dev_found(struct domain_device *dev); |
| 407 | void mvs_dev_gone(struct domain_device *dev); |
| 408 | int mvs_lu_reset(struct domain_device *dev, u8 *lun); |
| 409 | int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 410 | int mvs_I_T_nexus_reset(struct domain_device *dev); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 411 | int mvs_query_task(struct sas_task *task); |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 412 | void mvs_release_task(struct mvs_info *mvi, |
| 413 | struct domain_device *dev); |
| 414 | void mvs_do_release_task(struct mvs_info *mvi, int phy_no, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 415 | struct domain_device *dev); |
| 416 | void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events); |
| 417 | void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st); |
| 418 | int mvs_int_rx(struct mvs_info *mvi, bool self_clear); |
| 419 | void mvs_hexdump(u32 size, u8 *data, u32 baseaddr); |
Xiangliang Yu | 534ff10 | 2011-05-24 22:26:50 +0800 | [diff] [blame^] | 420 | struct mvs_device *mvs_find_dev_by_reg_set(struct mvs_info *mvi, u8 reg_set); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 421 | #endif |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 422 | |