2010-08-23 20:24:12 -07:00
/*
2015-02-19 16:02:31 -05:00
* Linux network driver for QLogic BR - series Converged Network Adapter .
2010-08-23 20:24:12 -07:00
*
* This program is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License ( GPL ) Version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful , but
* WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* General Public License for more details .
*/
/*
2015-02-19 16:02:31 -05:00
* Copyright ( c ) 2005 - 2014 Brocade Communications Systems , Inc .
* Copyright ( c ) 2014 - 2015 QLogic Corporation
2010-08-23 20:24:12 -07:00
* All rights reserved
2015-02-19 16:02:31 -05:00
* www . qlogic . com
2010-08-23 20:24:12 -07:00
*/
# include <linux/firmware.h>
2012-01-04 13:02:24 +00:00
# include "bnad.h"
2011-09-27 10:39:07 +00:00
# include "bfi.h"
2010-08-23 20:24:12 -07:00
# include "cna.h"
const struct firmware * bfi_fw ;
2011-09-27 10:39:07 +00:00
static u32 * bfi_image_ct_cna , * bfi_image_ct2_cna ;
static u32 bfi_image_ct_cna_size , bfi_image_ct2_cna_size ;
2010-08-23 20:24:12 -07:00
2010-10-05 15:46:05 +00:00
static u32 *
2010-08-23 20:24:12 -07:00
cna_read_firmware ( struct pci_dev * pdev , u32 * * bfi_image ,
u32 * bfi_image_size , char * fw_name )
{
const struct firmware * fw ;
2015-05-28 23:10:06 +02:00
u32 n ;
2010-08-23 20:24:12 -07:00
if ( request_firmware ( & fw , fw_name , & pdev - > dev ) ) {
2015-06-11 15:52:31 +02:00
dev_alert ( & pdev - > dev , " can't load firmware %s \n " , fw_name ) ;
2010-08-23 20:24:12 -07:00
goto error ;
}
* bfi_image = ( u32 * ) fw - > data ;
* bfi_image_size = fw - > size / sizeof ( u32 ) ;
bfi_fw = fw ;
2015-05-28 23:10:06 +02:00
/* Convert loaded firmware to host order as it is stored in file
* as sequence of LE32 integers .
*/
for ( n = 0 ; n < * bfi_image_size ; n + + )
le32_to_cpus ( * bfi_image + n ) ;
2010-08-23 20:24:12 -07:00
return * bfi_image ;
error :
return NULL ;
}
u32 *
cna_get_firmware_buf ( struct pci_dev * pdev )
{
2011-09-27 10:39:07 +00:00
if ( pdev - > device = = BFA_PCI_DEVICE_ID_CT2 ) {
if ( bfi_image_ct2_cna_size = = 0 )
cna_read_firmware ( pdev , & bfi_image_ct2_cna ,
& bfi_image_ct2_cna_size , CNA_FW_FILE_CT2 ) ;
return bfi_image_ct2_cna ;
} else if ( bfa_asic_id_ct ( pdev - > device ) ) {
if ( bfi_image_ct_cna_size = = 0 )
cna_read_firmware ( pdev , & bfi_image_ct_cna ,
& bfi_image_ct_cna_size , CNA_FW_FILE_CT ) ;
return bfi_image_ct_cna ;
}
return NULL ;
2010-08-23 20:24:12 -07:00
}
u32 *
2011-09-27 10:39:07 +00:00
bfa_cb_image_get_chunk ( enum bfi_asic_gen asic_gen , u32 off )
2010-08-23 20:24:12 -07:00
{
2011-09-27 10:39:07 +00:00
switch ( asic_gen ) {
case BFI_ASIC_GEN_CT :
2012-06-04 12:44:16 +00:00
return ( bfi_image_ct_cna + off ) ;
2011-09-27 10:39:07 +00:00
case BFI_ASIC_GEN_CT2 :
2012-06-04 12:44:16 +00:00
return ( bfi_image_ct2_cna + off ) ;
2011-09-27 10:39:07 +00:00
default :
return NULL ;
}
2010-08-23 20:24:12 -07:00
}
u32
2011-09-27 10:39:07 +00:00
bfa_cb_image_get_size ( enum bfi_asic_gen asic_gen )
2010-08-23 20:24:12 -07:00
{
2011-09-27 10:39:07 +00:00
switch ( asic_gen ) {
case BFI_ASIC_GEN_CT :
return bfi_image_ct_cna_size ;
case BFI_ASIC_GEN_CT2 :
return bfi_image_ct2_cna_size ;
default :
return 0 ;
}
2010-08-23 20:24:12 -07:00
}