1*f844a0eaSJeff Kirsher /* 2*f844a0eaSJeff Kirsher * Linux network driver for Brocade Converged Network Adapter. 3*f844a0eaSJeff Kirsher * 4*f844a0eaSJeff Kirsher * This program is free software; you can redistribute it and/or modify it 5*f844a0eaSJeff Kirsher * under the terms of the GNU General Public License (GPL) Version 2 as 6*f844a0eaSJeff Kirsher * published by the Free Software Foundation 7*f844a0eaSJeff Kirsher * 8*f844a0eaSJeff Kirsher * This program is distributed in the hope that it will be useful, but 9*f844a0eaSJeff Kirsher * WITHOUT ANY WARRANTY; without even the implied warranty of 10*f844a0eaSJeff Kirsher * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11*f844a0eaSJeff Kirsher * General Public License for more details. 12*f844a0eaSJeff Kirsher */ 13*f844a0eaSJeff Kirsher /* 14*f844a0eaSJeff Kirsher * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. 15*f844a0eaSJeff Kirsher * All rights reserved 16*f844a0eaSJeff Kirsher * www.brocade.com 17*f844a0eaSJeff Kirsher */ 18*f844a0eaSJeff Kirsher #include <linux/firmware.h> 19*f844a0eaSJeff Kirsher #include "cna.h" 20*f844a0eaSJeff Kirsher 21*f844a0eaSJeff Kirsher const struct firmware *bfi_fw; 22*f844a0eaSJeff Kirsher static u32 *bfi_image_ct_cna; 23*f844a0eaSJeff Kirsher static u32 bfi_image_ct_cna_size; 24*f844a0eaSJeff Kirsher 25*f844a0eaSJeff Kirsher static u32 * 26*f844a0eaSJeff Kirsher cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image, 27*f844a0eaSJeff Kirsher u32 *bfi_image_size, char *fw_name) 28*f844a0eaSJeff Kirsher { 29*f844a0eaSJeff Kirsher const struct firmware *fw; 30*f844a0eaSJeff Kirsher 31*f844a0eaSJeff Kirsher if (request_firmware(&fw, fw_name, &pdev->dev)) { 32*f844a0eaSJeff Kirsher pr_alert("Can't locate firmware %s\n", fw_name); 33*f844a0eaSJeff Kirsher goto error; 34*f844a0eaSJeff Kirsher } 35*f844a0eaSJeff Kirsher 36*f844a0eaSJeff Kirsher *bfi_image = (u32 *)fw->data; 37*f844a0eaSJeff Kirsher *bfi_image_size = fw->size/sizeof(u32); 38*f844a0eaSJeff Kirsher bfi_fw = fw; 39*f844a0eaSJeff Kirsher 40*f844a0eaSJeff Kirsher return *bfi_image; 41*f844a0eaSJeff Kirsher error: 42*f844a0eaSJeff Kirsher return NULL; 43*f844a0eaSJeff Kirsher } 44*f844a0eaSJeff Kirsher 45*f844a0eaSJeff Kirsher u32 * 46*f844a0eaSJeff Kirsher cna_get_firmware_buf(struct pci_dev *pdev) 47*f844a0eaSJeff Kirsher { 48*f844a0eaSJeff Kirsher if (bfi_image_ct_cna_size == 0) 49*f844a0eaSJeff Kirsher cna_read_firmware(pdev, &bfi_image_ct_cna, 50*f844a0eaSJeff Kirsher &bfi_image_ct_cna_size, CNA_FW_FILE_CT); 51*f844a0eaSJeff Kirsher return bfi_image_ct_cna; 52*f844a0eaSJeff Kirsher } 53*f844a0eaSJeff Kirsher 54*f844a0eaSJeff Kirsher u32 * 55*f844a0eaSJeff Kirsher bfa_cb_image_get_chunk(int type, u32 off) 56*f844a0eaSJeff Kirsher { 57*f844a0eaSJeff Kirsher return (u32 *)(bfi_image_ct_cna + off); 58*f844a0eaSJeff Kirsher } 59*f844a0eaSJeff Kirsher 60*f844a0eaSJeff Kirsher u32 61*f844a0eaSJeff Kirsher bfa_cb_image_get_size(int type) 62*f844a0eaSJeff Kirsher { 63*f844a0eaSJeff Kirsher return bfi_image_ct_cna_size; 64*f844a0eaSJeff Kirsher } 65