aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mvsas/mv_sas.h
diff options
context:
space:
mode:
authorAndy Yan <ayan@marvell.com>2009-05-08 17:46:40 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-05-20 18:21:12 -0400
commit20b09c2992fefbe78f8cede7b404fb143a413c52 (patch)
treec7e2368e4dd3f38b66db95fa4982ef009e2df00a /drivers/scsi/mvsas/mv_sas.h
parentdd4969a892ea522ecf9d7d826ba1531ce044d46f (diff)
[SCSI] mvsas: add support for 94xx; layout change; bug fixes
This version contains following main changes - Switch to new layout to support more types of ASIC. - SSP TMF supported and related Error Handing enhanced. - Support flash feature with delay 2*HZ when PHY changed. - Support Marvell 94xx series ASIC for 6G SAS/SATA, which has 2 88SE64xx chips but any different register description. - Support SPI flash for HBA-related configuration info. - Other patch enhanced from kernel side such as increasing PHY type [jejb: fold back in DMA_BIT_MASK changes] Signed-off-by: Ying Chu <jasonchu@marvell.com> Signed-off-by: Andy Yan <ayan@marvell.com> Signed-off-by: Ke Wei <kewei@marvell.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/mvsas/mv_sas.h')
-rw-r--r--drivers/scsi/mvsas/mv_sas.h329
1 files changed, 265 insertions, 64 deletions
diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
index 7a954a95a217..75b9748ae7cc 100644
--- a/drivers/scsi/mvsas/mv_sas.h
+++ b/drivers/scsi/mvsas/mv_sas.h
@@ -1,25 +1,26 @@
1/* 1/*
2 mv_sas.h - Marvell 88SE6440 SAS/SATA support 2 * Marvell 88SE64xx/88SE94xx main function head file
3 3 *
4 Copyright 2007 Red Hat, Inc. 4 * Copyright 2007 Red Hat, Inc.
5 Copyright 2008 Marvell. <kewei@marvell.com> 5 * Copyright 2008 Marvell. <kewei@marvell.com>
6 6 *
7 This program is free software; you can redistribute it and/or 7 * This file is licensed under GPLv2.
8 modify it under the terms of the GNU General Public License as 8 *
9 published by the Free Software Foundation; either version 2, 9 * This program is free software; you can redistribute it and/or
10 or (at your option) any later version. 10 * modify it under the terms of the GNU General Public License as
11 11 * published by the Free Software Foundation; version 2 of the
12 This program is distributed in the hope that it will be useful, 12 * License.
13 but WITHOUT ANY WARRANTY; without even the implied warranty 13 *
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * This program is distributed in the hope that it will be useful,
15 See the GNU General Public License for more details. 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 You should have received a copy of the GNU General Public 17 * General Public License for more details.
18 License along with this program; see the file COPYING. If not, 18 *
19 write to the Free Software Foundation, 675 Mass Ave, Cambridge, 19 * You should have received a copy of the GNU General Public License
20 MA 02139, USA. 20 * along with this program; if not, write to the Free Software
21 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 */ 22 * USA
23*/
23 24
24#ifndef _MV_SAS_H_ 25#ifndef _MV_SAS_H_
25#define _MV_SAS_H_ 26#define _MV_SAS_H_
@@ -42,25 +43,144 @@
42#include <linux/version.h> 43#include <linux/version.h>
43#include "mv_defs.h" 44#include "mv_defs.h"
44 45
45#define DRV_NAME "mvsas" 46#define DRV_NAME "mvsas"
46#define DRV_VERSION "0.5.2" 47#define DRV_VERSION "0.8.2"
47#define _MV_DUMP 0 48#define _MV_DUMP 0
48#define MVS_DISABLE_NVRAM
49#define MVS_DISABLE_MSI
50
51#define MVS_ID_NOT_MAPPED 0x7f 49#define MVS_ID_NOT_MAPPED 0x7f
52#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width) 50/* #define DISABLE_HOTPLUG_DMA_FIX */
51#define MAX_EXP_RUNNING_REQ 2
52#define WIDE_PORT_MAX_PHY 4
53#define MV_DISABLE_NCQ 0
54#define mv_printk(fmt, arg ...) \
55 printk(KERN_DEBUG"%s %d:" fmt, __FILE__, __LINE__, ## arg)
56#ifdef MV_DEBUG
57#define mv_dprintk(format, arg...) \
58 printk(KERN_DEBUG"%s %d:" format, __FILE__, __LINE__, ## arg)
59#else
60#define mv_dprintk(format, arg...)
61#endif
62#define MV_MAX_U32 0xffffffff
63
64extern struct mvs_tgt_initiator mvs_tgt;
65extern struct mvs_info *tgt_mvi;
66extern const struct mvs_dispatch mvs_64xx_dispatch;
67extern const struct mvs_dispatch mvs_94xx_dispatch;
68
69#define DEV_IS_EXPANDER(type) \
70 ((type == EDGE_DEV) || (type == FANOUT_DEV))
53 71
54#define for_each_phy(__lseq_mask, __mc, __lseq, __rest) \ 72#define bit(n) ((u32)1 << n)
55 for ((__mc) = (__lseq_mask), (__lseq) = 0; \ 73
56 (__mc) != 0 && __rest; \ 74#define for_each_phy(__lseq_mask, __mc, __lseq) \
75 for ((__mc) = (__lseq_mask), (__lseq) = 0; \
76 (__mc) != 0 ; \
57 (++__lseq), (__mc) >>= 1) 77 (++__lseq), (__mc) >>= 1)
58 78
79#define MV_INIT_DELAYED_WORK(w, f, d) INIT_DELAYED_WORK(w, f)
80#define UNASSOC_D2H_FIS(id) \
81 ((void *) mvi->rx_fis + 0x100 * id)
82#define SATA_RECEIVED_FIS_LIST(reg_set) \
83 ((void *) mvi->rx_fis + mvi->chip->fis_offs + 0x100 * reg_set)
84#define SATA_RECEIVED_SDB_FIS(reg_set) \
85 (SATA_RECEIVED_FIS_LIST(reg_set) + 0x58)
86#define SATA_RECEIVED_D2H_FIS(reg_set) \
87 (SATA_RECEIVED_FIS_LIST(reg_set) + 0x40)
88#define SATA_RECEIVED_PIO_FIS(reg_set) \
89 (SATA_RECEIVED_FIS_LIST(reg_set) + 0x20)
90#define SATA_RECEIVED_DMA_FIS(reg_set) \
91 (SATA_RECEIVED_FIS_LIST(reg_set) + 0x00)
92
93enum dev_status {
94 MVS_DEV_NORMAL = 0x0,
95 MVS_DEV_EH = 0x1,
96};
97
98
99struct mvs_info;
100
101struct mvs_dispatch {
102 char *name;
103 int (*chip_init)(struct mvs_info *mvi);
104 int (*spi_init)(struct mvs_info *mvi);
105 int (*chip_ioremap)(struct mvs_info *mvi);
106 void (*chip_iounmap)(struct mvs_info *mvi);
107 irqreturn_t (*isr)(struct mvs_info *mvi, int irq, u32 stat);
108 u32 (*isr_status)(struct mvs_info *mvi, int irq);
109 void (*interrupt_enable)(struct mvs_info *mvi);
110 void (*interrupt_disable)(struct mvs_info *mvi);
111
112 u32 (*read_phy_ctl)(struct mvs_info *mvi, u32 port);
113 void (*write_phy_ctl)(struct mvs_info *mvi, u32 port, u32 val);
114
115 u32 (*read_port_cfg_data)(struct mvs_info *mvi, u32 port);
116 void (*write_port_cfg_data)(struct mvs_info *mvi, u32 port, u32 val);
117 void (*write_port_cfg_addr)(struct mvs_info *mvi, u32 port, u32 addr);
118
119 u32 (*read_port_vsr_data)(struct mvs_info *mvi, u32 port);
120 void (*write_port_vsr_data)(struct mvs_info *mvi, u32 port, u32 val);
121 void (*write_port_vsr_addr)(struct mvs_info *mvi, u32 port, u32 addr);
122
123 u32 (*read_port_irq_stat)(struct mvs_info *mvi, u32 port);
124 void (*write_port_irq_stat)(struct mvs_info *mvi, u32 port, u32 val);
125
126 u32 (*read_port_irq_mask)(struct mvs_info *mvi, u32 port);
127 void (*write_port_irq_mask)(struct mvs_info *mvi, u32 port, u32 val);
128
129 void (*get_sas_addr)(void *buf, u32 buflen);
130 void (*command_active)(struct mvs_info *mvi, u32 slot_idx);
131 void (*issue_stop)(struct mvs_info *mvi, enum mvs_port_type type,
132 u32 tfs);
133 void (*start_delivery)(struct mvs_info *mvi, u32 tx);
134 u32 (*rx_update)(struct mvs_info *mvi);
135 void (*int_full)(struct mvs_info *mvi);
136 u8 (*assign_reg_set)(struct mvs_info *mvi, u8 *tfs);
137 void (*free_reg_set)(struct mvs_info *mvi, u8 *tfs);
138 u32 (*prd_size)(void);
139 u32 (*prd_count)(void);
140 void (*make_prd)(struct scatterlist *scatter, int nr, void *prd);
141 void (*detect_porttype)(struct mvs_info *mvi, int i);
142 int (*oob_done)(struct mvs_info *mvi, int i);
143 void (*fix_phy_info)(struct mvs_info *mvi, int i,
144 struct sas_identify_frame *id);
145 void (*phy_work_around)(struct mvs_info *mvi, int i);
146 void (*phy_set_link_rate)(struct mvs_info *mvi, u32 phy_id,
147 struct sas_phy_linkrates *rates);
148 u32 (*phy_max_link_rate)(void);
149 void (*phy_disable)(struct mvs_info *mvi, u32 phy_id);
150 void (*phy_enable)(struct mvs_info *mvi, u32 phy_id);
151 void (*phy_reset)(struct mvs_info *mvi, u32 phy_id, int hard);
152 void (*stp_reset)(struct mvs_info *mvi, u32 phy_id);
153 void (*clear_active_cmds)(struct mvs_info *mvi);
154 u32 (*spi_read_data)(struct mvs_info *mvi);
155 void (*spi_write_data)(struct mvs_info *mvi, u32 data);
156 int (*spi_buildcmd)(struct mvs_info *mvi,
157 u32 *dwCmd,
158 u8 cmd,
159 u8 read,
160 u8 length,
161 u32 addr
162 );
163 int (*spi_issuecmd)(struct mvs_info *mvi, u32 cmd);
164 int (*spi_waitdataready)(struct mvs_info *mvi, u32 timeout);
165#ifndef DISABLE_HOTPLUG_DMA_FIX
166 void (*dma_fix)(dma_addr_t buf_dma, int buf_len, int from, void *prd);
167#endif
168
169};
170
59struct mvs_chip_info { 171struct mvs_chip_info {
60 u32 n_phy; 172 u32 n_host;
61 u32 srs_sz; 173 u32 n_phy;
62 u32 slot_width; 174 u32 fis_offs;
175 u32 fis_count;
176 u32 srs_sz;
177 u32 slot_width;
178 const struct mvs_dispatch *dispatch;
63}; 179};
180#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width)
181#define MVS_RX_FISL_SZ \
182 (mvi->chip->fis_offs + (mvi->chip->fis_count * 0x100))
183#define MVS_CHIP_DISP (mvi->chip->dispatch)
64 184
65struct mvs_err_info { 185struct mvs_err_info {
66 __le32 flags; 186 __le32 flags;
@@ -72,7 +192,7 @@ struct mvs_cmd_hdr {
72 __le32 lens; /* cmd, max resp frame len */ 192 __le32 lens; /* cmd, max resp frame len */
73 __le32 tags; /* targ port xfer tag; tag */ 193 __le32 tags; /* targ port xfer tag; tag */
74 __le32 data_len; /* data xfer len */ 194 __le32 data_len; /* data xfer len */
75 __le64 cmd_tbl; /* command table address */ 195 __le64 cmd_tbl; /* command table address */
76 __le64 open_frame; /* open addr frame address */ 196 __le64 open_frame; /* open addr frame address */
77 __le64 status_buf; /* status buffer address */ 197 __le64 status_buf; /* status buffer address */
78 __le64 prd_tbl; /* PRD tbl address */ 198 __le64 prd_tbl; /* PRD tbl address */
@@ -82,16 +202,17 @@ struct mvs_cmd_hdr {
82struct mvs_port { 202struct mvs_port {
83 struct asd_sas_port sas_port; 203 struct asd_sas_port sas_port;
84 u8 port_attached; 204 u8 port_attached;
85 u8 taskfileset;
86 u8 wide_port_phymap; 205 u8 wide_port_phymap;
87 struct list_head list; 206 struct list_head list;
88}; 207};
89 208
90struct mvs_phy { 209struct mvs_phy {
210 struct mvs_info *mvi;
91 struct mvs_port *port; 211 struct mvs_port *port;
92 struct asd_sas_phy sas_phy; 212 struct asd_sas_phy sas_phy;
93 struct sas_identify identify; 213 struct sas_identify identify;
94 struct scsi_device *sdev; 214 struct scsi_device *sdev;
215 struct timer_list timer;
95 u64 dev_sas_addr; 216 u64 dev_sas_addr;
96 u64 att_dev_sas_addr; 217 u64 att_dev_sas_addr;
97 u32 att_dev_info; 218 u32 att_dev_info;
@@ -102,15 +223,34 @@ struct mvs_phy {
102 u32 frame_rcvd_size; 223 u32 frame_rcvd_size;
103 u8 frame_rcvd[32]; 224 u8 frame_rcvd[32];
104 u8 phy_attached; 225 u8 phy_attached;
226 u8 phy_mode;
227 u8 reserved[2];
228 u32 phy_event;
105 enum sas_linkrate minimum_linkrate; 229 enum sas_linkrate minimum_linkrate;
106 enum sas_linkrate maximum_linkrate; 230 enum sas_linkrate maximum_linkrate;
107}; 231};
108 232
233struct mvs_device {
234 enum sas_dev_type dev_type;
235 struct domain_device *sas_device;
236 u32 attached_phy;
237 u32 device_id;
238 u32 runing_req;
239 u8 taskfileset;
240 u8 dev_status;
241 u16 reserved;
242 struct list_head dev_entry;
243};
244
109struct mvs_slot_info { 245struct mvs_slot_info {
110 struct list_head list; 246 struct list_head entry;
111 struct sas_task *task; 247 union {
248 struct sas_task *task;
249 void *tdata;
250 };
112 u32 n_elem; 251 u32 n_elem;
113 u32 tx; 252 u32 tx;
253 u32 slot_tag;
114 254
115 /* DMA buffer for storing cmd tbl, open addr frame, status buffer, 255 /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
116 * and PRD table 256 * and PRD table
@@ -120,9 +260,10 @@ struct mvs_slot_info {
120#if _MV_DUMP 260#if _MV_DUMP
121 u32 cmd_size; 261 u32 cmd_size;
122#endif 262#endif
123
124 void *response; 263 void *response;
125 struct mvs_port *port; 264 struct mvs_port *port;
265 struct mvs_device *device;
266 void *open_frame;
126}; 267};
127 268
128struct mvs_info { 269struct mvs_info {
@@ -133,17 +274,17 @@ struct mvs_info {
133 274
134 /* our device */ 275 /* our device */
135 struct pci_dev *pdev; 276 struct pci_dev *pdev;
277 struct device *dev;
136 278
137 /* enhanced mode registers */ 279 /* enhanced mode registers */
138 void __iomem *regs; 280 void __iomem *regs;
139 281
140 /* peripheral registers */ 282 /* peripheral or soc registers */
141 void __iomem *peri_regs; 283 void __iomem *regs_ex;
142
143 u8 sas_addr[SAS_ADDR_SIZE]; 284 u8 sas_addr[SAS_ADDR_SIZE];
144 285
145 /* SCSI/SAS glue */ 286 /* SCSI/SAS glue */
146 struct sas_ha_struct sas; 287 struct sas_ha_struct *sas;
147 struct Scsi_Host *shost; 288 struct Scsi_Host *shost;
148 289
149 /* TX (delivery) DMA ring */ 290 /* TX (delivery) DMA ring */
@@ -154,7 +295,7 @@ struct mvs_info {
154 u32 tx_prod; 295 u32 tx_prod;
155 296
156 /* RX (completion) DMA ring */ 297 /* RX (completion) DMA ring */
157 __le32 *rx; 298 __le32 *rx;
158 dma_addr_t rx_dma; 299 dma_addr_t rx_dma;
159 300
160 /* RX consumer idx */ 301 /* RX consumer idx */
@@ -168,38 +309,98 @@ struct mvs_info {
168 struct mvs_cmd_hdr *slot; 309 struct mvs_cmd_hdr *slot;
169 dma_addr_t slot_dma; 310 dma_addr_t slot_dma;
170 311
312 u32 chip_id;
171 const struct mvs_chip_info *chip; 313 const struct mvs_chip_info *chip;
172 314
173 u8 tags[MVS_SLOTS]; 315 int tags_num;
174 struct mvs_slot_info slot_info[MVS_SLOTS]; 316 u8 tags[MVS_SLOTS >> 3];
175 /* further per-slot information */ 317
318 /* further per-slot information */
176 struct mvs_phy phy[MVS_MAX_PHYS]; 319 struct mvs_phy phy[MVS_MAX_PHYS];
177 struct mvs_port port[MVS_MAX_PHYS]; 320 struct mvs_port port[MVS_MAX_PHYS];
178#ifdef MVS_USE_TASKLET 321 u32 irq;
179 struct tasklet_struct tasklet; 322 u32 exp_req;
323 u32 id;
324 u64 sata_reg_set;
325 struct list_head *hba_list;
326 struct list_head soc_entry;
327 struct list_head wq_list;
328 unsigned long instance;
329 u16 flashid;
330 u32 flashsize;
331 u32 flashsectSize;
332
333 void *addon;
334 struct mvs_device devices[MVS_MAX_DEVICES];
335#ifndef DISABLE_HOTPLUG_DMA_FIX
336 void *bulk_buffer;
337 dma_addr_t bulk_buffer_dma;
338#define TRASH_BUCKET_SIZE 0x20000
180#endif 339#endif
340 struct mvs_slot_info slot_info[0];
341};
342
343struct mvs_prv_info{
344 u8 n_host;
345 u8 n_phy;
346 u16 reserve;
347 struct mvs_info *mvi[2];
348};
349
350struct mvs_wq {
351 struct delayed_work work_q;
352 struct mvs_info *mvi;
353 void *data;
354 int handler;
355 struct list_head entry;
181}; 356};
182 357
358struct mvs_task_exec_info {
359 struct sas_task *task;
360 struct mvs_cmd_hdr *hdr;
361 struct mvs_port *port;
362 u32 tag;
363 int n_elem;
364};
365
366
367/******************** function prototype *********************/
368void mvs_get_sas_addr(void *buf, u32 buflen);
369void mvs_tag_clear(struct mvs_info *mvi, u32 tag);
370void mvs_tag_free(struct mvs_info *mvi, u32 tag);
371void mvs_tag_set(struct mvs_info *mvi, unsigned int tag);
372int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out);
373void mvs_tag_init(struct mvs_info *mvi);
374void mvs_iounmap(void __iomem *regs);
375int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex);
376void mvs_phys_reset(struct mvs_info *mvi, u32 phy_mask, int hard);
183int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, 377int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
184 void *funcdata); 378 void *funcdata);
379void __devinit mvs_set_sas_addr(struct mvs_info *mvi, int port_id,
380 u32 off_lo, u32 off_hi, u64 sas_addr);
381int mvs_slave_alloc(struct scsi_device *scsi_dev);
185int mvs_slave_configure(struct scsi_device *sdev); 382int mvs_slave_configure(struct scsi_device *sdev);
186void mvs_scan_start(struct Scsi_Host *shost); 383void mvs_scan_start(struct Scsi_Host *shost);
187int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time); 384int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time);
188int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags); 385int mvs_queue_command(struct sas_task *task, const int num,
189int mvs_task_abort(struct sas_task *task); 386 gfp_t gfp_flags);
387int mvs_abort_task(struct sas_task *task);
388int mvs_abort_task_set(struct domain_device *dev, u8 *lun);
389int mvs_clear_aca(struct domain_device *dev, u8 *lun);
390int mvs_clear_task_set(struct domain_device *dev, u8 * lun);
190void mvs_port_formed(struct asd_sas_phy *sas_phy); 391void mvs_port_formed(struct asd_sas_phy *sas_phy);
392void mvs_port_deformed(struct asd_sas_phy *sas_phy);
393int mvs_dev_found(struct domain_device *dev);
394void mvs_dev_gone(struct domain_device *dev);
395int mvs_lu_reset(struct domain_device *dev, u8 *lun);
396int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags);
191int mvs_I_T_nexus_reset(struct domain_device *dev); 397int mvs_I_T_nexus_reset(struct domain_device *dev);
192void mvs_int_full(struct mvs_info *mvi); 398int mvs_query_task(struct sas_task *task);
193void mvs_tag_init(struct mvs_info *mvi); 399void mvs_release_task(struct mvs_info *mvi, int phy_no,
194int mvs_nvram_read(struct mvs_info *mvi, u32 addr, void *buf, u32 buflen); 400 struct domain_device *dev);
195int __devinit mvs_hw_init(struct mvs_info *mvi); 401void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events);
196void __devinit mvs_print_info(struct mvs_info *mvi); 402void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st);
197void mvs_hba_interrupt_enable(struct mvs_info *mvi); 403int mvs_int_rx(struct mvs_info *mvi, bool self_clear);
198void mvs_hba_interrupt_disable(struct mvs_info *mvi); 404void mvs_hexdump(u32 size, u8 *data, u32 baseaddr);
199void mvs_detect_porttype(struct mvs_info *mvi, int i);
200u8 mvs_assign_reg_set(struct mvs_info *mvi, struct mvs_port *port);
201void mvs_enable_xmt(struct mvs_info *mvi, int PhyId);
202void __devinit mvs_phy_hacks(struct mvs_info *mvi);
203void mvs_free_reg_set(struct mvs_info *mvi, struct mvs_port *port);
204
205#endif 405#endif
406