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 | |
Xiangliang Yu | 83c7b61 | 2011-05-24 22:31:47 +0800 | [diff] [blame] | 67 | extern int interrupt_coalescing; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 68 | extern struct mvs_tgt_initiator mvs_tgt; |
| 69 | extern struct mvs_info *tgt_mvi; |
| 70 | extern const struct mvs_dispatch mvs_64xx_dispatch; |
| 71 | extern const struct mvs_dispatch mvs_94xx_dispatch; |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 72 | extern struct kmem_cache *mvs_task_list_cache; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 73 | |
| 74 | #define DEV_IS_EXPANDER(type) \ |
| 75 | ((type == EDGE_DEV) || (type == FANOUT_DEV)) |
| 76 | |
| 77 | #define bit(n) ((u32)1 << n) |
| 78 | |
| 79 | #define for_each_phy(__lseq_mask, __mc, __lseq) \ |
| 80 | for ((__mc) = (__lseq_mask), (__lseq) = 0; \ |
| 81 | (__mc) != 0 ; \ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 82 | (++__lseq), (__mc) >>= 1) |
| 83 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 84 | #define MV_INIT_DELAYED_WORK(w, f, d) INIT_DELAYED_WORK(w, f) |
| 85 | #define UNASSOC_D2H_FIS(id) \ |
| 86 | ((void *) mvi->rx_fis + 0x100 * id) |
| 87 | #define SATA_RECEIVED_FIS_LIST(reg_set) \ |
| 88 | ((void *) mvi->rx_fis + mvi->chip->fis_offs + 0x100 * reg_set) |
| 89 | #define SATA_RECEIVED_SDB_FIS(reg_set) \ |
| 90 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x58) |
| 91 | #define SATA_RECEIVED_D2H_FIS(reg_set) \ |
| 92 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x40) |
| 93 | #define SATA_RECEIVED_PIO_FIS(reg_set) \ |
| 94 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x20) |
| 95 | #define SATA_RECEIVED_DMA_FIS(reg_set) \ |
| 96 | (SATA_RECEIVED_FIS_LIST(reg_set) + 0x00) |
| 97 | |
| 98 | enum dev_status { |
| 99 | MVS_DEV_NORMAL = 0x0, |
| 100 | MVS_DEV_EH = 0x1, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 101 | }; |
| 102 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 103 | |
| 104 | struct mvs_info; |
| 105 | |
| 106 | struct mvs_dispatch { |
| 107 | char *name; |
| 108 | int (*chip_init)(struct mvs_info *mvi); |
| 109 | int (*spi_init)(struct mvs_info *mvi); |
| 110 | int (*chip_ioremap)(struct mvs_info *mvi); |
| 111 | void (*chip_iounmap)(struct mvs_info *mvi); |
| 112 | irqreturn_t (*isr)(struct mvs_info *mvi, int irq, u32 stat); |
| 113 | u32 (*isr_status)(struct mvs_info *mvi, int irq); |
| 114 | void (*interrupt_enable)(struct mvs_info *mvi); |
| 115 | void (*interrupt_disable)(struct mvs_info *mvi); |
| 116 | |
| 117 | u32 (*read_phy_ctl)(struct mvs_info *mvi, u32 port); |
| 118 | void (*write_phy_ctl)(struct mvs_info *mvi, u32 port, u32 val); |
| 119 | |
| 120 | u32 (*read_port_cfg_data)(struct mvs_info *mvi, u32 port); |
| 121 | void (*write_port_cfg_data)(struct mvs_info *mvi, u32 port, u32 val); |
| 122 | void (*write_port_cfg_addr)(struct mvs_info *mvi, u32 port, u32 addr); |
| 123 | |
| 124 | u32 (*read_port_vsr_data)(struct mvs_info *mvi, u32 port); |
| 125 | void (*write_port_vsr_data)(struct mvs_info *mvi, u32 port, u32 val); |
| 126 | void (*write_port_vsr_addr)(struct mvs_info *mvi, u32 port, u32 addr); |
| 127 | |
| 128 | u32 (*read_port_irq_stat)(struct mvs_info *mvi, u32 port); |
| 129 | void (*write_port_irq_stat)(struct mvs_info *mvi, u32 port, u32 val); |
| 130 | |
| 131 | u32 (*read_port_irq_mask)(struct mvs_info *mvi, u32 port); |
| 132 | void (*write_port_irq_mask)(struct mvs_info *mvi, u32 port, u32 val); |
| 133 | |
| 134 | void (*get_sas_addr)(void *buf, u32 buflen); |
| 135 | void (*command_active)(struct mvs_info *mvi, u32 slot_idx); |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 136 | 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] | 137 | void (*issue_stop)(struct mvs_info *mvi, enum mvs_port_type type, |
| 138 | u32 tfs); |
| 139 | void (*start_delivery)(struct mvs_info *mvi, u32 tx); |
| 140 | u32 (*rx_update)(struct mvs_info *mvi); |
| 141 | void (*int_full)(struct mvs_info *mvi); |
| 142 | u8 (*assign_reg_set)(struct mvs_info *mvi, u8 *tfs); |
| 143 | void (*free_reg_set)(struct mvs_info *mvi, u8 *tfs); |
| 144 | u32 (*prd_size)(void); |
| 145 | u32 (*prd_count)(void); |
| 146 | void (*make_prd)(struct scatterlist *scatter, int nr, void *prd); |
| 147 | void (*detect_porttype)(struct mvs_info *mvi, int i); |
| 148 | int (*oob_done)(struct mvs_info *mvi, int i); |
| 149 | void (*fix_phy_info)(struct mvs_info *mvi, int i, |
| 150 | struct sas_identify_frame *id); |
| 151 | void (*phy_work_around)(struct mvs_info *mvi, int i); |
| 152 | void (*phy_set_link_rate)(struct mvs_info *mvi, u32 phy_id, |
| 153 | struct sas_phy_linkrates *rates); |
| 154 | u32 (*phy_max_link_rate)(void); |
| 155 | void (*phy_disable)(struct mvs_info *mvi, u32 phy_id); |
| 156 | void (*phy_enable)(struct mvs_info *mvi, u32 phy_id); |
| 157 | void (*phy_reset)(struct mvs_info *mvi, u32 phy_id, int hard); |
| 158 | void (*stp_reset)(struct mvs_info *mvi, u32 phy_id); |
| 159 | void (*clear_active_cmds)(struct mvs_info *mvi); |
| 160 | u32 (*spi_read_data)(struct mvs_info *mvi); |
| 161 | void (*spi_write_data)(struct mvs_info *mvi, u32 data); |
| 162 | int (*spi_buildcmd)(struct mvs_info *mvi, |
| 163 | u32 *dwCmd, |
| 164 | u8 cmd, |
| 165 | u8 read, |
| 166 | u8 length, |
| 167 | u32 addr |
| 168 | ); |
| 169 | int (*spi_issuecmd)(struct mvs_info *mvi, u32 cmd); |
| 170 | int (*spi_waitdataready)(struct mvs_info *mvi, u32 timeout); |
Xiangliang Yu | 8882f08 | 2011-05-24 22:33:11 +0800 | [diff] [blame^] | 171 | void (*dma_fix)(struct mvs_info *mvi, u32 phy_mask, |
| 172 | int buf_len, int from, void *prd); |
Xiangliang Yu | 83c7b61 | 2011-05-24 22:31:47 +0800 | [diff] [blame] | 173 | void (*tune_interrupt)(struct mvs_info *mvi, u32 time); |
Xiangliang Yu | 534ff10 | 2011-05-24 22:26:50 +0800 | [diff] [blame] | 174 | void (*non_spec_ncq_error)(struct mvs_info *mvi); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 175 | |
| 176 | }; |
| 177 | |
| 178 | struct mvs_chip_info { |
| 179 | u32 n_host; |
| 180 | u32 n_phy; |
| 181 | u32 fis_offs; |
| 182 | u32 fis_count; |
| 183 | u32 srs_sz; |
| 184 | u32 slot_width; |
| 185 | const struct mvs_dispatch *dispatch; |
| 186 | }; |
| 187 | #define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width) |
| 188 | #define MVS_RX_FISL_SZ \ |
| 189 | (mvi->chip->fis_offs + (mvi->chip->fis_count * 0x100)) |
| 190 | #define MVS_CHIP_DISP (mvi->chip->dispatch) |
| 191 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 192 | struct mvs_err_info { |
| 193 | __le32 flags; |
| 194 | __le32 flags2; |
| 195 | }; |
| 196 | |
| 197 | struct mvs_cmd_hdr { |
| 198 | __le32 flags; /* PRD tbl len; SAS, SATA ctl */ |
| 199 | __le32 lens; /* cmd, max resp frame len */ |
| 200 | __le32 tags; /* targ port xfer tag; tag */ |
| 201 | __le32 data_len; /* data xfer len */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 202 | __le64 cmd_tbl; /* command table address */ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 203 | __le64 open_frame; /* open addr frame address */ |
| 204 | __le64 status_buf; /* status buffer address */ |
| 205 | __le64 prd_tbl; /* PRD tbl address */ |
| 206 | __le32 reserved[4]; |
| 207 | }; |
| 208 | |
| 209 | struct mvs_port { |
| 210 | struct asd_sas_port sas_port; |
| 211 | u8 port_attached; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 212 | u8 wide_port_phymap; |
| 213 | struct list_head list; |
| 214 | }; |
| 215 | |
| 216 | struct mvs_phy { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 217 | struct mvs_info *mvi; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 218 | struct mvs_port *port; |
| 219 | struct asd_sas_phy sas_phy; |
| 220 | struct sas_identify identify; |
| 221 | struct scsi_device *sdev; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 222 | struct timer_list timer; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 223 | u64 dev_sas_addr; |
| 224 | u64 att_dev_sas_addr; |
| 225 | u32 att_dev_info; |
| 226 | u32 dev_info; |
| 227 | u32 phy_type; |
| 228 | u32 phy_status; |
| 229 | u32 irq_status; |
| 230 | u32 frame_rcvd_size; |
| 231 | u8 frame_rcvd[32]; |
| 232 | u8 phy_attached; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 233 | u8 phy_mode; |
| 234 | u8 reserved[2]; |
| 235 | u32 phy_event; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 236 | enum sas_linkrate minimum_linkrate; |
| 237 | enum sas_linkrate maximum_linkrate; |
| 238 | }; |
| 239 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 240 | struct mvs_device { |
Andy Yan | 9870d9a | 2009-05-11 22:19:25 +0800 | [diff] [blame] | 241 | struct list_head dev_entry; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 242 | enum sas_dev_type dev_type; |
Andy Yan | 9870d9a | 2009-05-11 22:19:25 +0800 | [diff] [blame] | 243 | struct mvs_info *mvi_info; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 244 | struct domain_device *sas_device; |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 245 | struct timer_list timer; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 246 | u32 attached_phy; |
| 247 | u32 device_id; |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 248 | u32 running_req; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 249 | u8 taskfileset; |
| 250 | u8 dev_status; |
| 251 | u16 reserved; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 252 | }; |
| 253 | |
Xiangliang Yu | f1f82a9 | 2011-05-24 22:28:31 +0800 | [diff] [blame] | 254 | /* Generate PHY tunning parameters */ |
| 255 | struct phy_tuning { |
| 256 | /* 1 bit, transmitter emphasis enable */ |
| 257 | u8 trans_emp_en:1; |
| 258 | /* 4 bits, transmitter emphasis amplitude */ |
| 259 | u8 trans_emp_amp:4; |
| 260 | /* 3 bits, reserved space */ |
| 261 | u8 Reserved_2bit_1:3; |
| 262 | /* 5 bits, transmitter amplitude */ |
| 263 | u8 trans_amp:5; |
| 264 | /* 2 bits, transmitter amplitude adjust */ |
| 265 | u8 trans_amp_adj:2; |
| 266 | /* 1 bit, reserved space */ |
| 267 | u8 resv_2bit_2:1; |
| 268 | /* 2 bytes, reserved space */ |
| 269 | u8 reserved[2]; |
| 270 | }; |
| 271 | |
| 272 | struct ffe_control { |
| 273 | /* 4 bits, FFE Capacitor Select (value range 0~F) */ |
| 274 | u8 ffe_cap_sel:4; |
| 275 | /* 3 bits, FFE Resistor Select (value range 0~7) */ |
| 276 | u8 ffe_rss_sel:3; |
| 277 | /* 1 bit reserve*/ |
| 278 | u8 reserved:1; |
| 279 | }; |
| 280 | |
| 281 | /* |
| 282 | * HBA_Info_Page is saved in Flash/NVRAM, total 256 bytes. |
| 283 | * The data area is valid only Signature="MRVL". |
| 284 | * If any member fills with 0xFF, the member is invalid. |
| 285 | */ |
| 286 | struct hba_info_page { |
| 287 | /* Dword 0 */ |
| 288 | /* 4 bytes, structure signature,should be "MRVL" at first initial */ |
| 289 | u8 signature[4]; |
| 290 | |
| 291 | /* Dword 1-13 */ |
| 292 | u32 reserved1[13]; |
| 293 | |
| 294 | /* Dword 14-29 */ |
| 295 | /* 64 bytes, SAS address for each port */ |
| 296 | u64 sas_addr[8]; |
| 297 | |
| 298 | /* Dword 30-31 */ |
| 299 | /* 8 bytes for vanir 8 port PHY FFE seeting |
| 300 | * BIT 0~3 : FFE Capacitor select(value range 0~F) |
| 301 | * BIT 4~6 : FFE Resistor select(value range 0~7) |
| 302 | * BIT 7: reserve. |
| 303 | */ |
| 304 | |
| 305 | struct ffe_control ffe_ctl[8]; |
| 306 | /* Dword 32 -43 */ |
| 307 | u32 reserved2[12]; |
| 308 | |
| 309 | /* Dword 44-45 */ |
| 310 | /* 8 bytes, 0: 1.5G, 1: 3.0G, should be 0x01 at first initial */ |
| 311 | u8 phy_rate[8]; |
| 312 | |
| 313 | /* Dword 46-53 */ |
| 314 | /* 32 bytes, PHY tuning parameters for each PHY*/ |
| 315 | struct phy_tuning phy_tuning[8]; |
| 316 | |
| 317 | /* Dword 54-63 */ |
| 318 | u32 reserved3[10]; |
| 319 | }; /* total 256 bytes */ |
| 320 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 321 | struct mvs_slot_info { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 322 | struct list_head entry; |
| 323 | union { |
| 324 | struct sas_task *task; |
| 325 | void *tdata; |
| 326 | }; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 327 | u32 n_elem; |
| 328 | u32 tx; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 329 | u32 slot_tag; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 330 | |
| 331 | /* DMA buffer for storing cmd tbl, open addr frame, status buffer, |
| 332 | * and PRD table |
| 333 | */ |
| 334 | void *buf; |
| 335 | dma_addr_t buf_dma; |
| 336 | #if _MV_DUMP |
| 337 | u32 cmd_size; |
| 338 | #endif |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 339 | void *response; |
| 340 | struct mvs_port *port; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 341 | struct mvs_device *device; |
| 342 | void *open_frame; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | struct mvs_info { |
| 346 | unsigned long flags; |
| 347 | |
| 348 | /* host-wide lock */ |
| 349 | spinlock_t lock; |
| 350 | |
| 351 | /* our device */ |
| 352 | struct pci_dev *pdev; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 353 | struct device *dev; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 354 | |
| 355 | /* enhanced mode registers */ |
| 356 | void __iomem *regs; |
| 357 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 358 | /* peripheral or soc registers */ |
| 359 | void __iomem *regs_ex; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 360 | u8 sas_addr[SAS_ADDR_SIZE]; |
| 361 | |
| 362 | /* SCSI/SAS glue */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 363 | struct sas_ha_struct *sas; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 364 | struct Scsi_Host *shost; |
| 365 | |
| 366 | /* TX (delivery) DMA ring */ |
| 367 | __le32 *tx; |
| 368 | dma_addr_t tx_dma; |
| 369 | |
| 370 | /* cached next-producer idx */ |
| 371 | u32 tx_prod; |
| 372 | |
| 373 | /* RX (completion) DMA ring */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 374 | __le32 *rx; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 375 | dma_addr_t rx_dma; |
| 376 | |
| 377 | /* RX consumer idx */ |
| 378 | u32 rx_cons; |
| 379 | |
| 380 | /* RX'd FIS area */ |
| 381 | __le32 *rx_fis; |
| 382 | dma_addr_t rx_fis_dma; |
| 383 | |
| 384 | /* DMA command header slots */ |
| 385 | struct mvs_cmd_hdr *slot; |
| 386 | dma_addr_t slot_dma; |
| 387 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 388 | u32 chip_id; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 389 | const struct mvs_chip_info *chip; |
| 390 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 391 | int tags_num; |
Andy Yan | 77db27c | 2009-05-11 21:56:31 +0800 | [diff] [blame] | 392 | DECLARE_BITMAP(tags, MVS_SLOTS); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 393 | /* further per-slot information */ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 394 | struct mvs_phy phy[MVS_MAX_PHYS]; |
| 395 | struct mvs_port port[MVS_MAX_PHYS]; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 396 | u32 irq; |
| 397 | u32 exp_req; |
| 398 | u32 id; |
| 399 | u64 sata_reg_set; |
| 400 | struct list_head *hba_list; |
| 401 | struct list_head soc_entry; |
| 402 | struct list_head wq_list; |
| 403 | unsigned long instance; |
| 404 | u16 flashid; |
| 405 | u32 flashsize; |
| 406 | u32 flashsectSize; |
| 407 | |
| 408 | void *addon; |
Xiangliang Yu | f1f82a9 | 2011-05-24 22:28:31 +0800 | [diff] [blame] | 409 | struct hba_info_page hba_info_param; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 410 | struct mvs_device devices[MVS_MAX_DEVICES]; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 411 | void *bulk_buffer; |
| 412 | dma_addr_t bulk_buffer_dma; |
Xiangliang Yu | 8882f08 | 2011-05-24 22:33:11 +0800 | [diff] [blame^] | 413 | void *bulk_buffer1; |
| 414 | dma_addr_t bulk_buffer_dma1; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 415 | #define TRASH_BUCKET_SIZE 0x20000 |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 416 | void *dma_pool; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 417 | struct mvs_slot_info slot_info[0]; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 418 | }; |
| 419 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 420 | struct mvs_prv_info{ |
| 421 | u8 n_host; |
| 422 | u8 n_phy; |
| 423 | u16 reserve; |
| 424 | struct mvs_info *mvi[2]; |
| 425 | }; |
| 426 | |
| 427 | struct mvs_wq { |
| 428 | struct delayed_work work_q; |
| 429 | struct mvs_info *mvi; |
| 430 | void *data; |
| 431 | int handler; |
| 432 | struct list_head entry; |
| 433 | }; |
| 434 | |
| 435 | struct mvs_task_exec_info { |
| 436 | struct sas_task *task; |
| 437 | struct mvs_cmd_hdr *hdr; |
| 438 | struct mvs_port *port; |
| 439 | u32 tag; |
| 440 | int n_elem; |
| 441 | }; |
| 442 | |
Xiangliang Yu | 0b15fb1 | 2011-04-26 06:36:51 -0700 | [diff] [blame] | 443 | struct mvs_task_list { |
| 444 | struct sas_task *task; |
| 445 | struct list_head list; |
| 446 | }; |
| 447 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 448 | |
| 449 | /******************** function prototype *********************/ |
| 450 | void mvs_get_sas_addr(void *buf, u32 buflen); |
| 451 | void mvs_tag_clear(struct mvs_info *mvi, u32 tag); |
| 452 | void mvs_tag_free(struct mvs_info *mvi, u32 tag); |
| 453 | void mvs_tag_set(struct mvs_info *mvi, unsigned int tag); |
| 454 | int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out); |
| 455 | void mvs_tag_init(struct mvs_info *mvi); |
| 456 | void mvs_iounmap(void __iomem *regs); |
| 457 | int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex); |
| 458 | 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] | 459 | int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, |
| 460 | void *funcdata); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 461 | void __devinit mvs_set_sas_addr(struct mvs_info *mvi, int port_id, |
| 462 | u32 off_lo, u32 off_hi, u64 sas_addr); |
| 463 | int mvs_slave_alloc(struct scsi_device *scsi_dev); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 464 | int mvs_slave_configure(struct scsi_device *sdev); |
| 465 | void mvs_scan_start(struct Scsi_Host *shost); |
| 466 | int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 467 | int mvs_queue_command(struct sas_task *task, const int num, |
| 468 | gfp_t gfp_flags); |
| 469 | int mvs_abort_task(struct sas_task *task); |
| 470 | int mvs_abort_task_set(struct domain_device *dev, u8 *lun); |
| 471 | int mvs_clear_aca(struct domain_device *dev, u8 *lun); |
| 472 | int mvs_clear_task_set(struct domain_device *dev, u8 * lun); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 473 | void mvs_port_formed(struct asd_sas_phy *sas_phy); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 474 | void mvs_port_deformed(struct asd_sas_phy *sas_phy); |
| 475 | int mvs_dev_found(struct domain_device *dev); |
| 476 | void mvs_dev_gone(struct domain_device *dev); |
| 477 | int mvs_lu_reset(struct domain_device *dev, u8 *lun); |
| 478 | 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] | 479 | int mvs_I_T_nexus_reset(struct domain_device *dev); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 480 | int mvs_query_task(struct sas_task *task); |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 481 | void mvs_release_task(struct mvs_info *mvi, |
| 482 | struct domain_device *dev); |
| 483 | void mvs_do_release_task(struct mvs_info *mvi, int phy_no, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 484 | struct domain_device *dev); |
| 485 | void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events); |
| 486 | void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st); |
| 487 | int mvs_int_rx(struct mvs_info *mvi, bool self_clear); |
| 488 | void mvs_hexdump(u32 size, u8 *data, u32 baseaddr); |
Xiangliang Yu | 534ff10 | 2011-05-24 22:26:50 +0800 | [diff] [blame] | 489 | 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] | 490 | #endif |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 491 | |