Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 1 | /* |
Rasesh Mody | 2732ba5 | 2015-02-19 16:02:31 -0500 | [diff] [blame] | 2 | * Linux network driver for QLogic BR-series Converged Network Adapter. |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 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 | /* |
Rasesh Mody | 2732ba5 | 2015-02-19 16:02:31 -0500 | [diff] [blame] | 14 | * Copyright (c) 2005-2014 Brocade Communications Systems, Inc. |
| 15 | * Copyright (c) 2014-2015 QLogic Corporation |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 16 | * All rights reserved |
Rasesh Mody | 2732ba5 | 2015-02-19 16:02:31 -0500 | [diff] [blame] | 17 | * www.qlogic.com |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 18 | */ |
| 19 | #include <linux/firmware.h> |
stephen hemminger | e1e0918 | 2012-01-04 13:02:24 +0000 | [diff] [blame] | 20 | #include "bnad.h" |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 21 | #include "bfi.h" |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 22 | #include "cna.h" |
| 23 | |
| 24 | const struct firmware *bfi_fw; |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 25 | static u32 *bfi_image_ct_cna, *bfi_image_ct2_cna; |
| 26 | static u32 bfi_image_ct_cna_size, bfi_image_ct2_cna_size; |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 27 | |
Rasesh Mody | b7ee31c5 | 2010-10-05 15:46:05 +0000 | [diff] [blame] | 28 | static u32 * |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 29 | cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image, |
| 30 | u32 *bfi_image_size, char *fw_name) |
| 31 | { |
| 32 | const struct firmware *fw; |
| 33 | |
| 34 | if (request_firmware(&fw, fw_name, &pdev->dev)) { |
| 35 | pr_alert("Can't locate firmware %s\n", fw_name); |
| 36 | goto error; |
| 37 | } |
| 38 | |
| 39 | *bfi_image = (u32 *)fw->data; |
| 40 | *bfi_image_size = fw->size/sizeof(u32); |
| 41 | bfi_fw = fw; |
| 42 | |
| 43 | return *bfi_image; |
| 44 | error: |
| 45 | return NULL; |
| 46 | } |
| 47 | |
| 48 | u32 * |
| 49 | cna_get_firmware_buf(struct pci_dev *pdev) |
| 50 | { |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 51 | if (pdev->device == BFA_PCI_DEVICE_ID_CT2) { |
| 52 | if (bfi_image_ct2_cna_size == 0) |
| 53 | cna_read_firmware(pdev, &bfi_image_ct2_cna, |
| 54 | &bfi_image_ct2_cna_size, CNA_FW_FILE_CT2); |
| 55 | return bfi_image_ct2_cna; |
| 56 | } else if (bfa_asic_id_ct(pdev->device)) { |
| 57 | if (bfi_image_ct_cna_size == 0) |
| 58 | cna_read_firmware(pdev, &bfi_image_ct_cna, |
| 59 | &bfi_image_ct_cna_size, CNA_FW_FILE_CT); |
| 60 | return bfi_image_ct_cna; |
| 61 | } |
| 62 | |
| 63 | return NULL; |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | u32 * |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 67 | bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off) |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 68 | { |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 69 | switch (asic_gen) { |
| 70 | case BFI_ASIC_GEN_CT: |
Joe Perches | 6469933 | 2012-06-04 12:44:16 +0000 | [diff] [blame] | 71 | return (bfi_image_ct_cna + off); |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 72 | case BFI_ASIC_GEN_CT2: |
Joe Perches | 6469933 | 2012-06-04 12:44:16 +0000 | [diff] [blame] | 73 | return (bfi_image_ct2_cna + off); |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 74 | default: |
| 75 | return NULL; |
| 76 | } |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | u32 |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 80 | bfa_cb_image_get_size(enum bfi_asic_gen asic_gen) |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 81 | { |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 82 | switch (asic_gen) { |
| 83 | case BFI_ASIC_GEN_CT: |
| 84 | return bfi_image_ct_cna_size; |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 85 | case BFI_ASIC_GEN_CT2: |
| 86 | return bfi_image_ct2_cna_size; |
Rasesh Mody | 1bf9fd70 | 2011-09-27 10:39:07 +0000 | [diff] [blame] | 87 | default: |
| 88 | return 0; |
| 89 | } |
Rasesh Mody | 8b230ed | 2010-08-23 20:24:12 -0700 | [diff] [blame] | 90 | } |