Commit | Line | Data |
---|---|---|
8b230ed8 RM |
1 | /* |
2 | * Linux network driver for Brocade Converged Network Adapter. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License (GPL) Version 2 as | |
6 | * published by the Free Software Foundation | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * General Public License for more details. | |
12 | */ | |
13 | /* | |
14 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. | |
15 | * All rights reserved | |
16 | * www.brocade.com | |
17 | */ | |
18 | #include <linux/firmware.h> | |
1bf9fd70 | 19 | #include "bfi.h" |
8b230ed8 RM |
20 | #include "cna.h" |
21 | ||
22 | const struct firmware *bfi_fw; | |
1bf9fd70 RM |
23 | static u32 *bfi_image_ct_cna, *bfi_image_ct2_cna; |
24 | static u32 bfi_image_ct_cna_size, bfi_image_ct2_cna_size; | |
8b230ed8 | 25 | |
b7ee31c5 | 26 | static u32 * |
8b230ed8 RM |
27 | cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image, |
28 | u32 *bfi_image_size, char *fw_name) | |
29 | { | |
30 | const struct firmware *fw; | |
31 | ||
32 | if (request_firmware(&fw, fw_name, &pdev->dev)) { | |
33 | pr_alert("Can't locate firmware %s\n", fw_name); | |
34 | goto error; | |
35 | } | |
36 | ||
37 | *bfi_image = (u32 *)fw->data; | |
38 | *bfi_image_size = fw->size/sizeof(u32); | |
39 | bfi_fw = fw; | |
40 | ||
41 | return *bfi_image; | |
42 | error: | |
43 | return NULL; | |
44 | } | |
45 | ||
46 | u32 * | |
47 | cna_get_firmware_buf(struct pci_dev *pdev) | |
48 | { | |
1bf9fd70 RM |
49 | if (pdev->device == BFA_PCI_DEVICE_ID_CT2) { |
50 | if (bfi_image_ct2_cna_size == 0) | |
51 | cna_read_firmware(pdev, &bfi_image_ct2_cna, | |
52 | &bfi_image_ct2_cna_size, CNA_FW_FILE_CT2); | |
53 | return bfi_image_ct2_cna; | |
54 | } else if (bfa_asic_id_ct(pdev->device)) { | |
55 | if (bfi_image_ct_cna_size == 0) | |
56 | cna_read_firmware(pdev, &bfi_image_ct_cna, | |
57 | &bfi_image_ct_cna_size, CNA_FW_FILE_CT); | |
58 | return bfi_image_ct_cna; | |
59 | } | |
60 | ||
61 | return NULL; | |
8b230ed8 RM |
62 | } |
63 | ||
64 | u32 * | |
1bf9fd70 | 65 | bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off) |
8b230ed8 | 66 | { |
1bf9fd70 RM |
67 | switch (asic_gen) { |
68 | case BFI_ASIC_GEN_CT: | |
69 | return (u32 *)(bfi_image_ct_cna + off); | |
70 | break; | |
71 | case BFI_ASIC_GEN_CT2: | |
72 | return (u32 *)(bfi_image_ct2_cna + off); | |
73 | break; | |
74 | default: | |
75 | return NULL; | |
76 | } | |
8b230ed8 RM |
77 | } |
78 | ||
79 | u32 | |
1bf9fd70 | 80 | bfa_cb_image_get_size(enum bfi_asic_gen asic_gen) |
8b230ed8 | 81 | { |
1bf9fd70 RM |
82 | switch (asic_gen) { |
83 | case BFI_ASIC_GEN_CT: | |
84 | return bfi_image_ct_cna_size; | |
85 | break; | |
86 | case BFI_ASIC_GEN_CT2: | |
87 | return bfi_image_ct2_cna_size; | |
88 | break; | |
89 | default: | |
90 | return 0; | |
91 | } | |
8b230ed8 | 92 | } |