diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2011-06-13 18:50:35 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-06-29 16:31:31 -0400 |
commit | 111892082ed7a3214bc7a7ec6b8b20e8f847501a (patch) | |
tree | fb4950f69aaf7c2bf07ce8987884bb52aa497ffa /drivers/scsi/bfa/bfa_ioc_ct.c | |
parent | 43ffdf4dfb827babcdca5345a76031598a985dc8 (diff) |
[SCSI] bfa: Brocade-1860 Fabric Adapter Hardware Enablement
- Added support for Brocade-1860 Fabric Adapter.
- Made changes to support single firmware image per asic type.
- Combined bfi_cbreg.h and bfi_ctreg.h defines into bfi_reg.h with
only minimal defines used by host.
- Added changes to setup CPE/RME Queue register offsets based on
firmware response.
- Removed queue register offset initializations and added register offsets
to BFI config response message.
- Added Brocade-1860 asic specific interrupt status definitions and
mailbox interfaces.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa/bfa_ioc_ct.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc_ct.c | 418 |
1 files changed, 337 insertions, 81 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc_ct.c b/drivers/scsi/bfa/bfa_ioc_ct.c index 93612520f0d2..118ed8c7fc2e 100644 --- a/drivers/scsi/bfa/bfa_ioc_ct.c +++ b/drivers/scsi/bfa/bfa_ioc_ct.c | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | #include "bfad_drv.h" | 18 | #include "bfad_drv.h" |
19 | #include "bfa_ioc.h" | 19 | #include "bfa_ioc.h" |
20 | #include "bfi_ctreg.h" | 20 | #include "bfi_reg.h" |
21 | #include "bfa_defs.h" | 21 | #include "bfa_defs.h" |
22 | 22 | ||
23 | BFA_TRC_FILE(CNA, IOC_CT); | 23 | BFA_TRC_FILE(CNA, IOC_CT); |
@@ -36,9 +36,6 @@ BFA_TRC_FILE(CNA, IOC_CT); | |||
36 | */ | 36 | */ |
37 | static bfa_boolean_t bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc); | 37 | static bfa_boolean_t bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc); |
38 | static void bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc); | 38 | static void bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc); |
39 | static void bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc); | ||
40 | static void bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc); | ||
41 | static void bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix); | ||
42 | static void bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc); | 39 | static void bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc); |
43 | static void bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc); | 40 | static void bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc); |
44 | static bfa_boolean_t bfa_ioc_ct_sync_start(struct bfa_ioc_s *ioc); | 41 | static bfa_boolean_t bfa_ioc_ct_sync_start(struct bfa_ioc_s *ioc); |
@@ -48,29 +45,7 @@ static void bfa_ioc_ct_sync_ack(struct bfa_ioc_s *ioc); | |||
48 | static bfa_boolean_t bfa_ioc_ct_sync_complete(struct bfa_ioc_s *ioc); | 45 | static bfa_boolean_t bfa_ioc_ct_sync_complete(struct bfa_ioc_s *ioc); |
49 | 46 | ||
50 | static struct bfa_ioc_hwif_s hwif_ct; | 47 | static struct bfa_ioc_hwif_s hwif_ct; |
51 | 48 | static struct bfa_ioc_hwif_s hwif_ct2; | |
52 | /* | ||
53 | * Called from bfa_ioc_attach() to map asic specific calls. | ||
54 | */ | ||
55 | void | ||
56 | bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc) | ||
57 | { | ||
58 | hwif_ct.ioc_pll_init = bfa_ioc_ct_pll_init; | ||
59 | hwif_ct.ioc_firmware_lock = bfa_ioc_ct_firmware_lock; | ||
60 | hwif_ct.ioc_firmware_unlock = bfa_ioc_ct_firmware_unlock; | ||
61 | hwif_ct.ioc_reg_init = bfa_ioc_ct_reg_init; | ||
62 | hwif_ct.ioc_map_port = bfa_ioc_ct_map_port; | ||
63 | hwif_ct.ioc_isr_mode_set = bfa_ioc_ct_isr_mode_set; | ||
64 | hwif_ct.ioc_notify_fail = bfa_ioc_ct_notify_fail; | ||
65 | hwif_ct.ioc_ownership_reset = bfa_ioc_ct_ownership_reset; | ||
66 | hwif_ct.ioc_sync_start = bfa_ioc_ct_sync_start; | ||
67 | hwif_ct.ioc_sync_join = bfa_ioc_ct_sync_join; | ||
68 | hwif_ct.ioc_sync_leave = bfa_ioc_ct_sync_leave; | ||
69 | hwif_ct.ioc_sync_ack = bfa_ioc_ct_sync_ack; | ||
70 | hwif_ct.ioc_sync_complete = bfa_ioc_ct_sync_complete; | ||
71 | |||
72 | ioc->ioc_hwif = &hwif_ct; | ||
73 | } | ||
74 | 49 | ||
75 | /* | 50 | /* |
76 | * Return true if firmware of current driver matches the running firmware. | 51 | * Return true if firmware of current driver matches the running firmware. |
@@ -85,13 +60,13 @@ bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc) | |||
85 | /* | 60 | /* |
86 | * Firmware match check is relevant only for CNA. | 61 | * Firmware match check is relevant only for CNA. |
87 | */ | 62 | */ |
88 | if (!ioc->cna) | 63 | if (!bfa_ioc_is_cna(ioc)) |
89 | return BFA_TRUE; | 64 | return BFA_TRUE; |
90 | 65 | ||
91 | /* | 66 | /* |
92 | * If bios boot (flash based) -- do not increment usage count | 67 | * If bios boot (flash based) -- do not increment usage count |
93 | */ | 68 | */ |
94 | if (bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)) < | 69 | if (bfa_cb_image_get_size(bfa_ioc_asic_gen(ioc)) < |
95 | BFA_IOC_FWIMG_MINSZ) | 70 | BFA_IOC_FWIMG_MINSZ) |
96 | return BFA_TRUE; | 71 | return BFA_TRUE; |
97 | 72 | ||
@@ -145,13 +120,13 @@ bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc) | |||
145 | /* | 120 | /* |
146 | * Firmware lock is relevant only for CNA. | 121 | * Firmware lock is relevant only for CNA. |
147 | */ | 122 | */ |
148 | if (!ioc->cna) | 123 | if (!bfa_ioc_is_cna(ioc)) |
149 | return; | 124 | return; |
150 | 125 | ||
151 | /* | 126 | /* |
152 | * If bios boot (flash based) -- do not decrement usage count | 127 | * If bios boot (flash based) -- do not decrement usage count |
153 | */ | 128 | */ |
154 | if (bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)) < | 129 | if (bfa_cb_image_get_size(bfa_ioc_asic_gen(ioc)) < |
155 | BFA_IOC_FWIMG_MINSZ) | 130 | BFA_IOC_FWIMG_MINSZ) |
156 | return; | 131 | return; |
157 | 132 | ||
@@ -175,14 +150,14 @@ bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc) | |||
175 | static void | 150 | static void |
176 | bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc) | 151 | bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc) |
177 | { | 152 | { |
178 | if (ioc->cna) { | 153 | if (bfa_ioc_is_cna(ioc)) { |
179 | writel(__FW_INIT_HALT_P, ioc->ioc_regs.ll_halt); | 154 | writel(__FW_INIT_HALT_P, ioc->ioc_regs.ll_halt); |
180 | writel(__FW_INIT_HALT_P, ioc->ioc_regs.alt_ll_halt); | 155 | writel(__FW_INIT_HALT_P, ioc->ioc_regs.alt_ll_halt); |
181 | /* Wait for halt to take effect */ | 156 | /* Wait for halt to take effect */ |
182 | readl(ioc->ioc_regs.ll_halt); | 157 | readl(ioc->ioc_regs.ll_halt); |
183 | readl(ioc->ioc_regs.alt_ll_halt); | 158 | readl(ioc->ioc_regs.alt_ll_halt); |
184 | } else { | 159 | } else { |
185 | writel(__PSS_ERR_STATUS_SET, ioc->ioc_regs.err_set); | 160 | writel(~0U, ioc->ioc_regs.err_set); |
186 | readl(ioc->ioc_regs.err_set); | 161 | readl(ioc->ioc_regs.err_set); |
187 | } | 162 | } |
188 | } | 163 | } |
@@ -190,7 +165,7 @@ bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc) | |||
190 | /* | 165 | /* |
191 | * Host to LPU mailbox message addresses | 166 | * Host to LPU mailbox message addresses |
192 | */ | 167 | */ |
193 | static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = { | 168 | static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } ct_fnreg[] = { |
194 | { HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0 }, | 169 | { HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0 }, |
195 | { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 }, | 170 | { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 }, |
196 | { HOSTFN2_LPU_MBOX0_0, LPU_HOSTFN2_MBOX0_0, HOST_PAGE_NUM_FN2 }, | 171 | { HOSTFN2_LPU_MBOX0_0, LPU_HOSTFN2_MBOX0_0, HOST_PAGE_NUM_FN2 }, |
@@ -200,21 +175,28 @@ static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = { | |||
200 | /* | 175 | /* |
201 | * Host <-> LPU mailbox command/status registers - port 0 | 176 | * Host <-> LPU mailbox command/status registers - port 0 |
202 | */ | 177 | */ |
203 | static struct { u32 hfn, lpu; } iocreg_mbcmd_p0[] = { | 178 | static struct { u32 hfn, lpu; } ct_p0reg[] = { |
204 | { HOSTFN0_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN0_MBOX0_CMD_STAT }, | 179 | { HOSTFN0_LPU0_CMD_STAT, LPU0_HOSTFN0_CMD_STAT }, |
205 | { HOSTFN1_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN1_MBOX0_CMD_STAT }, | 180 | { HOSTFN1_LPU0_CMD_STAT, LPU0_HOSTFN1_CMD_STAT }, |
206 | { HOSTFN2_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN2_MBOX0_CMD_STAT }, | 181 | { HOSTFN2_LPU0_CMD_STAT, LPU0_HOSTFN2_CMD_STAT }, |
207 | { HOSTFN3_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN3_MBOX0_CMD_STAT } | 182 | { HOSTFN3_LPU0_CMD_STAT, LPU0_HOSTFN3_CMD_STAT } |
208 | }; | 183 | }; |
209 | 184 | ||
210 | /* | 185 | /* |
211 | * Host <-> LPU mailbox command/status registers - port 1 | 186 | * Host <-> LPU mailbox command/status registers - port 1 |
212 | */ | 187 | */ |
213 | static struct { u32 hfn, lpu; } iocreg_mbcmd_p1[] = { | 188 | static struct { u32 hfn, lpu; } ct_p1reg[] = { |
214 | { HOSTFN0_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN0_MBOX0_CMD_STAT }, | 189 | { HOSTFN0_LPU1_CMD_STAT, LPU1_HOSTFN0_CMD_STAT }, |
215 | { HOSTFN1_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN1_MBOX0_CMD_STAT }, | 190 | { HOSTFN1_LPU1_CMD_STAT, LPU1_HOSTFN1_CMD_STAT }, |
216 | { HOSTFN2_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN2_MBOX0_CMD_STAT }, | 191 | { HOSTFN2_LPU1_CMD_STAT, LPU1_HOSTFN2_CMD_STAT }, |
217 | { HOSTFN3_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN3_MBOX0_CMD_STAT } | 192 | { HOSTFN3_LPU1_CMD_STAT, LPU1_HOSTFN3_CMD_STAT } |
193 | }; | ||
194 | |||
195 | static struct { uint32_t hfn_mbox, lpu_mbox, hfn_pgn, hfn, lpu; } ct2_reg[] = { | ||
196 | { CT2_HOSTFN_LPU0_MBOX0, CT2_LPU0_HOSTFN_MBOX0, CT2_HOSTFN_PAGE_NUM, | ||
197 | CT2_HOSTFN_LPU0_CMD_STAT, CT2_LPU0_HOSTFN_CMD_STAT }, | ||
198 | { CT2_HOSTFN_LPU1_MBOX0, CT2_LPU1_HOSTFN_MBOX0, CT2_HOSTFN_PAGE_NUM, | ||
199 | CT2_HOSTFN_LPU1_CMD_STAT, CT2_LPU1_HOSTFN_CMD_STAT }, | ||
218 | }; | 200 | }; |
219 | 201 | ||
220 | static void | 202 | static void |
@@ -225,24 +207,24 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc) | |||
225 | 207 | ||
226 | rb = bfa_ioc_bar0(ioc); | 208 | rb = bfa_ioc_bar0(ioc); |
227 | 209 | ||
228 | ioc->ioc_regs.hfn_mbox = rb + iocreg_fnreg[pcifn].hfn_mbox; | 210 | ioc->ioc_regs.hfn_mbox = rb + ct_fnreg[pcifn].hfn_mbox; |
229 | ioc->ioc_regs.lpu_mbox = rb + iocreg_fnreg[pcifn].lpu_mbox; | 211 | ioc->ioc_regs.lpu_mbox = rb + ct_fnreg[pcifn].lpu_mbox; |
230 | ioc->ioc_regs.host_page_num_fn = rb + iocreg_fnreg[pcifn].hfn_pgn; | 212 | ioc->ioc_regs.host_page_num_fn = rb + ct_fnreg[pcifn].hfn_pgn; |
231 | 213 | ||
232 | if (ioc->port_id == 0) { | 214 | if (ioc->port_id == 0) { |
233 | ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; | 215 | ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; |
234 | ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; | 216 | ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; |
235 | ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC1_STATE_REG; | 217 | ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC1_STATE_REG; |
236 | ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].hfn; | 218 | ioc->ioc_regs.hfn_mbox_cmd = rb + ct_p0reg[pcifn].hfn; |
237 | ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].lpu; | 219 | ioc->ioc_regs.lpu_mbox_cmd = rb + ct_p0reg[pcifn].lpu; |
238 | ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0; | 220 | ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0; |
239 | ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P1; | 221 | ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P1; |
240 | } else { | 222 | } else { |
241 | ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); | 223 | ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); |
242 | ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); | 224 | ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); |
243 | ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC0_STATE_REG; | 225 | ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC0_STATE_REG; |
244 | ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].hfn; | 226 | ioc->ioc_regs.hfn_mbox_cmd = rb + ct_p1reg[pcifn].hfn; |
245 | ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].lpu; | 227 | ioc->ioc_regs.lpu_mbox_cmd = rb + ct_p1reg[pcifn].lpu; |
246 | ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1; | 228 | ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1; |
247 | ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P0; | 229 | ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P0; |
248 | } | 230 | } |
@@ -252,8 +234,8 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc) | |||
252 | */ | 234 | */ |
253 | ioc->ioc_regs.pss_ctl_reg = (rb + PSS_CTL_REG); | 235 | ioc->ioc_regs.pss_ctl_reg = (rb + PSS_CTL_REG); |
254 | ioc->ioc_regs.pss_err_status_reg = (rb + PSS_ERR_STATUS_REG); | 236 | ioc->ioc_regs.pss_err_status_reg = (rb + PSS_ERR_STATUS_REG); |
255 | ioc->ioc_regs.app_pll_fast_ctl_reg = (rb + APP_PLL_425_CTL_REG); | 237 | ioc->ioc_regs.app_pll_fast_ctl_reg = (rb + APP_PLL_LCLK_CTL_REG); |
256 | ioc->ioc_regs.app_pll_slow_ctl_reg = (rb + APP_PLL_312_CTL_REG); | 238 | ioc->ioc_regs.app_pll_slow_ctl_reg = (rb + APP_PLL_SCLK_CTL_REG); |
257 | 239 | ||
258 | /* | 240 | /* |
259 | * IOC semaphore registers and serialization | 241 | * IOC semaphore registers and serialization |
@@ -276,6 +258,63 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc) | |||
276 | ioc->ioc_regs.err_set = (rb + ERR_SET_REG); | 258 | ioc->ioc_regs.err_set = (rb + ERR_SET_REG); |
277 | } | 259 | } |
278 | 260 | ||
261 | static void | ||
262 | bfa_ioc_ct2_reg_init(struct bfa_ioc_s *ioc) | ||
263 | { | ||
264 | void __iomem *rb; | ||
265 | int port = bfa_ioc_portid(ioc); | ||
266 | |||
267 | rb = bfa_ioc_bar0(ioc); | ||
268 | |||
269 | ioc->ioc_regs.hfn_mbox = rb + ct2_reg[port].hfn_mbox; | ||
270 | ioc->ioc_regs.lpu_mbox = rb + ct2_reg[port].lpu_mbox; | ||
271 | ioc->ioc_regs.host_page_num_fn = rb + ct2_reg[port].hfn_pgn; | ||
272 | ioc->ioc_regs.hfn_mbox_cmd = rb + ct2_reg[port].hfn; | ||
273 | ioc->ioc_regs.lpu_mbox_cmd = rb + ct2_reg[port].lpu; | ||
274 | |||
275 | if (port == 0) { | ||
276 | ioc->ioc_regs.heartbeat = rb + CT2_BFA_IOC0_HBEAT_REG; | ||
277 | ioc->ioc_regs.ioc_fwstate = rb + CT2_BFA_IOC0_STATE_REG; | ||
278 | ioc->ioc_regs.alt_ioc_fwstate = rb + CT2_BFA_IOC1_STATE_REG; | ||
279 | ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0; | ||
280 | ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P1; | ||
281 | } else { | ||
282 | ioc->ioc_regs.heartbeat = (rb + CT2_BFA_IOC1_HBEAT_REG); | ||
283 | ioc->ioc_regs.ioc_fwstate = (rb + CT2_BFA_IOC1_STATE_REG); | ||
284 | ioc->ioc_regs.alt_ioc_fwstate = rb + CT2_BFA_IOC0_STATE_REG; | ||
285 | ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1; | ||
286 | ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P0; | ||
287 | } | ||
288 | |||
289 | /* | ||
290 | * PSS control registers | ||
291 | */ | ||
292 | ioc->ioc_regs.pss_ctl_reg = (rb + PSS_CTL_REG); | ||
293 | ioc->ioc_regs.pss_err_status_reg = (rb + PSS_ERR_STATUS_REG); | ||
294 | ioc->ioc_regs.app_pll_fast_ctl_reg = (rb + CT2_APP_PLL_LCLK_CTL_REG); | ||
295 | ioc->ioc_regs.app_pll_slow_ctl_reg = (rb + CT2_APP_PLL_SCLK_CTL_REG); | ||
296 | |||
297 | /* | ||
298 | * IOC semaphore registers and serialization | ||
299 | */ | ||
300 | ioc->ioc_regs.ioc_sem_reg = (rb + CT2_HOST_SEM0_REG); | ||
301 | ioc->ioc_regs.ioc_usage_sem_reg = (rb + CT2_HOST_SEM1_REG); | ||
302 | ioc->ioc_regs.ioc_init_sem_reg = (rb + CT2_HOST_SEM2_REG); | ||
303 | ioc->ioc_regs.ioc_usage_reg = (rb + BFA_FW_USE_COUNT); | ||
304 | ioc->ioc_regs.ioc_fail_sync = (rb + BFA_IOC_FAIL_SYNC); | ||
305 | |||
306 | /* | ||
307 | * sram memory access | ||
308 | */ | ||
309 | ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START); | ||
310 | ioc->ioc_regs.smem_pg0 = BFI_IOC_SMEM_PG0_CT; | ||
311 | |||
312 | /* | ||
313 | * err set reg : for notification of hb failure in fcmode | ||
314 | */ | ||
315 | ioc->ioc_regs.err_set = (rb + ERR_SET_REG); | ||
316 | } | ||
317 | |||
279 | /* | 318 | /* |
280 | * Initialize IOC to port mapping. | 319 | * Initialize IOC to port mapping. |
281 | */ | 320 | */ |
@@ -298,6 +337,15 @@ bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc) | |||
298 | bfa_trc(ioc, ioc->port_id); | 337 | bfa_trc(ioc, ioc->port_id); |
299 | } | 338 | } |
300 | 339 | ||
340 | static void | ||
341 | bfa_ioc_ct2_map_port(struct bfa_ioc_s *ioc) | ||
342 | { | ||
343 | ioc->port_id = bfa_ioc_pcifn(ioc) % 2; | ||
344 | |||
345 | bfa_trc(ioc, bfa_ioc_pcifn(ioc)); | ||
346 | bfa_trc(ioc, ioc->port_id); | ||
347 | } | ||
348 | |||
301 | /* | 349 | /* |
302 | * Set interrupt mode for a function: INTX or MSIX | 350 | * Set interrupt mode for a function: INTX or MSIX |
303 | */ | 351 | */ |
@@ -316,7 +364,7 @@ bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix) | |||
316 | /* | 364 | /* |
317 | * If already in desired mode, do not change anything | 365 | * If already in desired mode, do not change anything |
318 | */ | 366 | */ |
319 | if (!msix && mode) | 367 | if ((!msix && mode) || (msix && !mode)) |
320 | return; | 368 | return; |
321 | 369 | ||
322 | if (msix) | 370 | if (msix) |
@@ -338,7 +386,7 @@ static void | |||
338 | bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc) | 386 | bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc) |
339 | { | 387 | { |
340 | 388 | ||
341 | if (ioc->cna) { | 389 | if (bfa_ioc_is_cna(ioc)) { |
342 | bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); | 390 | bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); |
343 | writel(0, ioc->ioc_regs.ioc_usage_reg); | 391 | writel(0, ioc->ioc_regs.ioc_usage_reg); |
344 | writel(1, ioc->ioc_regs.ioc_usage_sem_reg); | 392 | writel(1, ioc->ioc_regs.ioc_usage_sem_reg); |
@@ -449,32 +497,91 @@ bfa_ioc_ct_sync_complete(struct bfa_ioc_s *ioc) | |||
449 | return BFA_FALSE; | 497 | return BFA_FALSE; |
450 | } | 498 | } |
451 | 499 | ||
500 | /** | ||
501 | * Called from bfa_ioc_attach() to map asic specific calls. | ||
502 | */ | ||
503 | static void | ||
504 | bfa_ioc_set_ctx_hwif(struct bfa_ioc_s *ioc, struct bfa_ioc_hwif_s *hwif) | ||
505 | { | ||
506 | hwif->ioc_firmware_lock = bfa_ioc_ct_firmware_lock; | ||
507 | hwif->ioc_firmware_unlock = bfa_ioc_ct_firmware_unlock; | ||
508 | hwif->ioc_notify_fail = bfa_ioc_ct_notify_fail; | ||
509 | hwif->ioc_ownership_reset = bfa_ioc_ct_ownership_reset; | ||
510 | hwif->ioc_sync_start = bfa_ioc_ct_sync_start; | ||
511 | hwif->ioc_sync_join = bfa_ioc_ct_sync_join; | ||
512 | hwif->ioc_sync_leave = bfa_ioc_ct_sync_leave; | ||
513 | hwif->ioc_sync_ack = bfa_ioc_ct_sync_ack; | ||
514 | hwif->ioc_sync_complete = bfa_ioc_ct_sync_complete; | ||
515 | } | ||
516 | |||
517 | /** | ||
518 | * Called from bfa_ioc_attach() to map asic specific calls. | ||
519 | */ | ||
520 | void | ||
521 | bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc) | ||
522 | { | ||
523 | bfa_ioc_set_ctx_hwif(ioc, &hwif_ct); | ||
524 | |||
525 | hwif_ct.ioc_pll_init = bfa_ioc_ct_pll_init; | ||
526 | hwif_ct.ioc_reg_init = bfa_ioc_ct_reg_init; | ||
527 | hwif_ct.ioc_map_port = bfa_ioc_ct_map_port; | ||
528 | hwif_ct.ioc_isr_mode_set = bfa_ioc_ct_isr_mode_set; | ||
529 | ioc->ioc_hwif = &hwif_ct; | ||
530 | } | ||
531 | |||
532 | /** | ||
533 | * Called from bfa_ioc_attach() to map asic specific calls. | ||
534 | */ | ||
535 | void | ||
536 | bfa_ioc_set_ct2_hwif(struct bfa_ioc_s *ioc) | ||
537 | { | ||
538 | bfa_ioc_set_ctx_hwif(ioc, &hwif_ct2); | ||
539 | |||
540 | hwif_ct2.ioc_pll_init = bfa_ioc_ct2_pll_init; | ||
541 | hwif_ct2.ioc_reg_init = bfa_ioc_ct2_reg_init; | ||
542 | hwif_ct2.ioc_map_port = bfa_ioc_ct2_map_port; | ||
543 | hwif_ct2.ioc_isr_mode_set = NULL; | ||
544 | ioc->ioc_hwif = &hwif_ct2; | ||
545 | } | ||
546 | |||
452 | /* | 547 | /* |
453 | * Check the firmware state to know if pll_init has been completed already | 548 | * Temporary workaround for MSI-X resource allocation for catapult-2. |
454 | */ | 549 | */ |
455 | bfa_boolean_t | 550 | #define HOSTFN_MSIX_DEFAULT 16 |
456 | bfa_ioc_ct_pll_init_complete(void __iomem *rb) | 551 | #define HOSTFN_MSIX_VT_OFST_NUMVT 0x3013c |
552 | #define __MSIX_VT_NUMVT__MK 0x003ff800 | ||
553 | #define __MSIX_VT_NUMVT__SH 11 | ||
554 | #define __MSIX_VT_NUMVT_(_v) ((_v) << __MSIX_VT_NUMVT__SH) | ||
555 | void | ||
556 | bfa_ioc_ct2_poweron(struct bfa_ioc_s *ioc) | ||
457 | { | 557 | { |
458 | if ((readl(rb + BFA_IOC0_STATE_REG) == BFI_IOC_OP) || | 558 | void __iomem *rb = ioc->pcidev.pci_bar_kva; |
459 | (readl(rb + BFA_IOC1_STATE_REG) == BFI_IOC_OP)) | 559 | u32 r32; |
460 | return BFA_TRUE; | ||
461 | 560 | ||
462 | return BFA_FALSE; | 561 | r32 = readl(rb + HOSTFN_MSIX_VT_OFST_NUMVT); |
562 | if (r32 & __MSIX_VT_NUMVT__MK) | ||
563 | return; | ||
564 | |||
565 | writel(__MSIX_VT_NUMVT_(HOSTFN_MSIX_DEFAULT - 1) | | ||
566 | HOSTFN_MSIX_DEFAULT * bfa_ioc_pcifn(ioc), | ||
567 | rb + HOSTFN_MSIX_VT_OFST_NUMVT); | ||
463 | } | 568 | } |
464 | 569 | ||
465 | bfa_status_t | 570 | bfa_status_t |
466 | bfa_ioc_ct_pll_init(void __iomem *rb, bfa_boolean_t fcmode) | 571 | bfa_ioc_ct_pll_init(void __iomem *rb, enum bfi_asic_mode mode) |
467 | { | 572 | { |
468 | u32 pll_sclk, pll_fclk, r32; | 573 | u32 pll_sclk, pll_fclk, r32; |
574 | bfa_boolean_t fcmode = (mode == BFI_ASIC_MODE_FC); | ||
575 | |||
576 | pll_sclk = __APP_PLL_SCLK_LRESETN | __APP_PLL_SCLK_ENARST | | ||
577 | __APP_PLL_SCLK_RSEL200500 | __APP_PLL_SCLK_P0_1(3U) | | ||
578 | __APP_PLL_SCLK_JITLMT0_1(3U) | | ||
579 | __APP_PLL_SCLK_CNTLMT0_1(1U); | ||
580 | pll_fclk = __APP_PLL_LCLK_LRESETN | __APP_PLL_LCLK_ENARST | | ||
581 | __APP_PLL_LCLK_RSEL200500 | __APP_PLL_LCLK_P0_1(3U) | | ||
582 | __APP_PLL_LCLK_JITLMT0_1(3U) | | ||
583 | __APP_PLL_LCLK_CNTLMT0_1(1U); | ||
469 | 584 | ||
470 | pll_sclk = __APP_PLL_312_LRESETN | __APP_PLL_312_ENARST | | ||
471 | __APP_PLL_312_RSEL200500 | __APP_PLL_312_P0_1(3U) | | ||
472 | __APP_PLL_312_JITLMT0_1(3U) | | ||
473 | __APP_PLL_312_CNTLMT0_1(1U); | ||
474 | pll_fclk = __APP_PLL_425_LRESETN | __APP_PLL_425_ENARST | | ||
475 | __APP_PLL_425_RSEL200500 | __APP_PLL_425_P0_1(3U) | | ||
476 | __APP_PLL_425_JITLMT0_1(3U) | | ||
477 | __APP_PLL_425_CNTLMT0_1(1U); | ||
478 | if (fcmode) { | 585 | if (fcmode) { |
479 | writel(0, (rb + OP_MODE)); | 586 | writel(0, (rb + OP_MODE)); |
480 | writel(__APP_EMS_CMLCKSEL | __APP_EMS_REFCKBUFEN2 | | 587 | writel(__APP_EMS_CMLCKSEL | __APP_EMS_REFCKBUFEN2 | |
@@ -491,20 +598,21 @@ bfa_ioc_ct_pll_init(void __iomem *rb, bfa_boolean_t fcmode) | |||
491 | writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS)); | 598 | writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS)); |
492 | writel(0xffffffffU, (rb + HOSTFN0_INT_MSK)); | 599 | writel(0xffffffffU, (rb + HOSTFN0_INT_MSK)); |
493 | writel(0xffffffffU, (rb + HOSTFN1_INT_MSK)); | 600 | writel(0xffffffffU, (rb + HOSTFN1_INT_MSK)); |
494 | writel(pll_sclk | __APP_PLL_312_LOGIC_SOFT_RESET, | 601 | writel(pll_sclk | __APP_PLL_SCLK_LOGIC_SOFT_RESET, |
495 | rb + APP_PLL_312_CTL_REG); | 602 | rb + APP_PLL_SCLK_CTL_REG); |
496 | writel(pll_fclk | __APP_PLL_425_LOGIC_SOFT_RESET, | 603 | writel(pll_fclk | __APP_PLL_LCLK_LOGIC_SOFT_RESET, |
497 | rb + APP_PLL_425_CTL_REG); | 604 | rb + APP_PLL_LCLK_CTL_REG); |
498 | writel(pll_sclk | __APP_PLL_312_LOGIC_SOFT_RESET | __APP_PLL_312_ENABLE, | 605 | writel(pll_sclk | __APP_PLL_SCLK_LOGIC_SOFT_RESET | |
499 | rb + APP_PLL_312_CTL_REG); | 606 | __APP_PLL_SCLK_ENABLE, rb + APP_PLL_SCLK_CTL_REG); |
500 | writel(pll_fclk | __APP_PLL_425_LOGIC_SOFT_RESET | __APP_PLL_425_ENABLE, | 607 | writel(pll_fclk | __APP_PLL_LCLK_LOGIC_SOFT_RESET | |
501 | rb + APP_PLL_425_CTL_REG); | 608 | __APP_PLL_LCLK_ENABLE, rb + APP_PLL_LCLK_CTL_REG); |
502 | readl(rb + HOSTFN0_INT_MSK); | 609 | readl(rb + HOSTFN0_INT_MSK); |
503 | udelay(2000); | 610 | udelay(2000); |
504 | writel(0xffffffffU, (rb + HOSTFN0_INT_STATUS)); | 611 | writel(0xffffffffU, (rb + HOSTFN0_INT_STATUS)); |
505 | writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS)); | 612 | writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS)); |
506 | writel(pll_sclk | __APP_PLL_312_ENABLE, rb + APP_PLL_312_CTL_REG); | 613 | writel(pll_sclk | __APP_PLL_SCLK_ENABLE, rb + APP_PLL_SCLK_CTL_REG); |
507 | writel(pll_fclk | __APP_PLL_425_ENABLE, rb + APP_PLL_425_CTL_REG); | 614 | writel(pll_fclk | __APP_PLL_LCLK_ENABLE, rb + APP_PLL_LCLK_CTL_REG); |
615 | |||
508 | if (!fcmode) { | 616 | if (!fcmode) { |
509 | writel(__PMM_1T_RESET_P, (rb + PMM_1T_RESET_REG_P0)); | 617 | writel(__PMM_1T_RESET_P, (rb + PMM_1T_RESET_REG_P0)); |
510 | writel(__PMM_1T_RESET_P, (rb + PMM_1T_RESET_REG_P1)); | 618 | writel(__PMM_1T_RESET_P, (rb + PMM_1T_RESET_REG_P1)); |
@@ -524,3 +632,151 @@ bfa_ioc_ct_pll_init(void __iomem *rb, bfa_boolean_t fcmode) | |||
524 | writel(0, (rb + MBIST_CTL_REG)); | 632 | writel(0, (rb + MBIST_CTL_REG)); |
525 | return BFA_STATUS_OK; | 633 | return BFA_STATUS_OK; |
526 | } | 634 | } |
635 | |||
636 | static struct { u32 sclk, speed, half_speed; } ct2_pll[] = { | ||
637 | {0}, /* unused */ | ||
638 | {__APP_PLL_SCLK_CLK_DIV2, 0, 0}, /* FC 8G */ | ||
639 | {0, __APP_LPU_SPEED, 0}, /* FC 16G */ | ||
640 | {__APP_PLL_SCLK_REFCLK_SEL | __APP_PLL_SCLK_CLK_DIV2, 0, /* ETH */ | ||
641 | __APP_LPUCLK_HALFSPEED}, | ||
642 | {0, __APP_LPU_SPEED, 0}, /* COMBO */ | ||
643 | }; | ||
644 | |||
645 | static void | ||
646 | bfa_ioc_ct2_sclk_init(void __iomem *rb, enum bfi_asic_mode mode) | ||
647 | { | ||
648 | u32 r32; | ||
649 | |||
650 | /* | ||
651 | * put s_clk PLL and PLL FSM in reset | ||
652 | */ | ||
653 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
654 | r32 &= ~(__APP_PLL_SCLK_ENABLE | __APP_PLL_SCLK_LRESETN); | ||
655 | r32 |= (__APP_PLL_SCLK_ENARST | __APP_PLL_SCLK_BYPASS | | ||
656 | __APP_PLL_SCLK_LOGIC_SOFT_RESET); | ||
657 | writel(r32, (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
658 | |||
659 | /* | ||
660 | * select clock speed based on mode | ||
661 | */ | ||
662 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
663 | r32 &= ~(__APP_PLL_SCLK_REFCLK_SEL | __APP_PLL_SCLK_CLK_DIV2); | ||
664 | writel(r32 | ct2_pll[mode].sclk, (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
665 | |||
666 | /* | ||
667 | * remove clock gating for ethernet subsystem for ethernet mode | ||
668 | */ | ||
669 | if (mode == BFI_ASIC_MODE_ETH) { | ||
670 | r32 = readl((rb + CT2_CHIP_MISC_PRG)); | ||
671 | writel(r32 | __ETH_CLK_ENABLE_PORT0, (rb + CT2_CHIP_MISC_PRG)); | ||
672 | |||
673 | r32 = readl((rb + CT2_PCIE_MISC_REG)); | ||
674 | writel(r32 | __ETH_CLK_ENABLE_PORT1, (rb + CT2_PCIE_MISC_REG)); | ||
675 | } | ||
676 | |||
677 | /* | ||
678 | * set sclk value | ||
679 | */ | ||
680 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
681 | r32 &= (__P_SCLK_PLL_LOCK | __APP_PLL_SCLK_REFCLK_SEL | | ||
682 | __APP_PLL_SCLK_CLK_DIV2); | ||
683 | writel(r32 | 0x1061731b, (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
684 | |||
685 | /* | ||
686 | * poll for s_clk lock or delay 1ms | ||
687 | */ | ||
688 | udelay(1000); | ||
689 | |||
690 | /* | ||
691 | * release soft reset on s_clk & l_clk | ||
692 | */ | ||
693 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
694 | writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET, | ||
695 | (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
696 | } | ||
697 | |||
698 | static void | ||
699 | bfa_ioc_ct2_lclk_init(void __iomem *rb, enum bfi_asic_mode mode) | ||
700 | { | ||
701 | u32 r32; | ||
702 | |||
703 | /* | ||
704 | * put l_clk PLL and PLL FSM in reset | ||
705 | */ | ||
706 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
707 | r32 &= ~(__APP_PLL_LCLK_ENABLE | __APP_PLL_LCLK_LRESETN); | ||
708 | r32 |= (__APP_PLL_LCLK_ENARST | __APP_PLL_LCLK_BYPASS | | ||
709 | __APP_PLL_LCLK_LOGIC_SOFT_RESET); | ||
710 | writel(r32, (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
711 | |||
712 | /* | ||
713 | * set LPU speed | ||
714 | */ | ||
715 | r32 = readl((rb + CT2_CHIP_MISC_PRG)); | ||
716 | writel(r32 | ct2_pll[mode].speed, | ||
717 | (rb + CT2_CHIP_MISC_PRG)); | ||
718 | |||
719 | /* | ||
720 | * set LPU half speed | ||
721 | */ | ||
722 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
723 | writel(r32 | ct2_pll[mode].half_speed, | ||
724 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
725 | |||
726 | /* | ||
727 | * set lclk for mode | ||
728 | */ | ||
729 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
730 | r32 &= (__P_LCLK_PLL_LOCK | __APP_LPUCLK_HALFSPEED); | ||
731 | if (mode == BFI_ASIC_MODE_FC || mode == BFI_ASIC_MODE_ETH) | ||
732 | r32 |= 0x20c1731b; | ||
733 | else | ||
734 | r32 |= 0x2081731b; | ||
735 | writel(r32, (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
736 | |||
737 | /* | ||
738 | * poll for s_clk lock or delay 1ms | ||
739 | */ | ||
740 | udelay(1000); | ||
741 | |||
742 | /* | ||
743 | * release soft reset on s_clk & l_clk | ||
744 | */ | ||
745 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
746 | writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET, | ||
747 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
748 | } | ||
749 | |||
750 | static void | ||
751 | bfa_ioc_ct2_mem_init(void __iomem *rb, enum bfi_asic_mode mode) | ||
752 | { | ||
753 | bfa_boolean_t fcmode; | ||
754 | u32 r32; | ||
755 | |||
756 | fcmode = (mode == BFI_ASIC_MODE_FC) || (mode == BFI_ASIC_MODE_FC16); | ||
757 | if (!fcmode) { | ||
758 | writel(__PMM_1T_RESET_P, (rb + CT2_PMM_1T_CONTROL_REG_P0)); | ||
759 | writel(__PMM_1T_RESET_P, (rb + CT2_PMM_1T_CONTROL_REG_P1)); | ||
760 | } | ||
761 | |||
762 | r32 = readl((rb + PSS_CTL_REG)); | ||
763 | r32 &= ~__PSS_LMEM_RESET; | ||
764 | writel(r32, (rb + PSS_CTL_REG)); | ||
765 | udelay(1000); | ||
766 | |||
767 | writel(__EDRAM_BISTR_START, (rb + CT2_MBIST_CTL_REG)); | ||
768 | udelay(1000); | ||
769 | writel(0, (rb + CT2_MBIST_CTL_REG)); | ||
770 | } | ||
771 | |||
772 | bfa_status_t | ||
773 | bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode) | ||
774 | { | ||
775 | bfa_ioc_ct2_sclk_init(rb, mode); | ||
776 | bfa_ioc_ct2_lclk_init(rb, mode); | ||
777 | bfa_ioc_ct2_mem_init(rb, mode); | ||
778 | |||
779 | writel(BFI_IOC_UNINIT, (rb + CT2_BFA_IOC0_STATE_REG)); | ||
780 | writel(BFI_IOC_UNINIT, (rb + CT2_BFA_IOC1_STATE_REG)); | ||
781 | return BFA_STATUS_OK; | ||
782 | } | ||