Commit 874073ea authored by Lior Dotan's avatar Lior Dotan Committed by Greg Kroah-Hartman

Staging: slicoss: use request_firmware

This patch uses request_firmware() to download the firmware to the card.
Signed-off-by: default avatarLior Dotan <liodot@gmail.com>
Cc: Christopher Harrer <charrer@alacritech.com>
parent 20bec8ab
...@@ -46,30 +46,10 @@ ...@@ -46,30 +46,10 @@
#define OASIS_UCODE_VERS_DATE "2006/03/27 15:10:37" #define OASIS_UCODE_VERS_DATE "2006/03/27 15:10:37"
#define OASIS_UCODE_HOSTIF_ID 3 #define OASIS_UCODE_HOSTIF_ID 3
static s32 ONumSections = 0x2;
static u32 OSectionSize[] = {
0x00004000, 0x00010000,
};
static u32 OSectionStart[] = {
0x00000000, 0x00008000,
};
#define MOJAVE_UCODE_VERS_STRING "1.2" #define MOJAVE_UCODE_VERS_STRING "1.2"
#define MOJAVE_UCODE_VERS_DATE "2006/03/27 15:12:22" #define MOJAVE_UCODE_VERS_DATE "2006/03/27 15:12:22"
#define MOJAVE_UCODE_HOSTIF_ID 3 #define MOJAVE_UCODE_HOSTIF_ID 3
static s32 MNumSections = 0x2;
static u32 MSectionSize[] =
{
0x00008000, 0x00010000,
};
static u32 MSectionStart[] =
{
0x00000000, 0x00008000,
};
#define GB_RCVUCODE_VERS_STRING "1.2" #define GB_RCVUCODE_VERS_STRING "1.2"
#define GB_RCVUCODE_VERS_DATE "2006/03/27 15:12:15" #define GB_RCVUCODE_VERS_DATE "2006/03/27 15:12:15"
static u32 OasisRcvUCodeLen = 512; static u32 OasisRcvUCodeLen = 512;
......
...@@ -2183,15 +2183,16 @@ static int slic_card_download_gbrcv(struct adapter *adapter) ...@@ -2183,15 +2183,16 @@ static int slic_card_download_gbrcv(struct adapter *adapter)
int ret; int ret;
__iomem struct slic_regs *slic_regs = adapter->slic_regs; __iomem struct slic_regs *slic_regs = adapter->slic_regs;
u32 codeaddr; u32 codeaddr;
unsigned char *instruction = NULL; u32 instruction;
int index = 0;
u32 rcvucodelen = 0; u32 rcvucodelen = 0;
switch (adapter->devid) { switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
file = "oasis_rcv.bin"; file = "oasisrcvucode.sys";
break; break;
case SLIC_1GB_DEVICE_ID: case SLIC_1GB_DEVICE_ID:
file = "gb_rcv.bin"; file = "gbrcvucode.sys";
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -2204,8 +2205,8 @@ static int slic_card_download_gbrcv(struct adapter *adapter) ...@@ -2204,8 +2205,8 @@ static int slic_card_download_gbrcv(struct adapter *adapter)
return ret; return ret;
} }
instruction = (unsigned char *)fw->data; rcvucodelen = *(u32 *)(fw->data + index);
rcvucodelen = fw->size; index += 4;
switch (adapter->devid) { switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
if (rcvucodelen != OasisRcvUCodeLen) if (rcvucodelen != OasisRcvUCodeLen)
...@@ -2219,24 +2220,24 @@ static int slic_card_download_gbrcv(struct adapter *adapter) ...@@ -2219,24 +2220,24 @@ static int slic_card_download_gbrcv(struct adapter *adapter)
ASSERT(0); ASSERT(0);
break; break;
} }
/* start download */ /* start download */
WRITE_REG(slic_regs->slic_rcv_wcs, SLIC_RCVWCS_BEGIN, FLUSH); WRITE_REG(slic_regs->slic_rcv_wcs, SLIC_RCVWCS_BEGIN, FLUSH);
/* download the rcv sequencer ucode */ /* download the rcv sequencer ucode */
for (codeaddr = 0; codeaddr < rcvucodelen; codeaddr++) { for (codeaddr = 0; codeaddr < rcvucodelen; codeaddr++) {
/* write out instruction address */ /* write out instruction address */
WRITE_REG(slic_regs->slic_rcv_wcs, codeaddr, FLUSH); WRITE_REG(slic_regs->slic_rcv_wcs, codeaddr, FLUSH);
instruction = *(u32 *)(fw->data + index);
index += 4;
/* write out the instruction data low addr */ /* write out the instruction data low addr */
WRITE_REG(slic_regs->slic_rcv_wcs, WRITE_REG(slic_regs->slic_rcv_wcs,
(u32) *(u32 *) instruction, FLUSH); instruction, FLUSH);
instruction += 4;
instruction = *(u8 *)(fw->data + index);
index++;
/* write out the instruction data high addr */ /* write out the instruction data high addr */
WRITE_REG(slic_regs->slic_rcv_wcs, (u32) *instruction, WRITE_REG(slic_regs->slic_rcv_wcs, (u8)instruction,
FLUSH); FLUSH);
instruction += 1;
} }
/* download finished */ /* download finished */
...@@ -2254,16 +2255,14 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2254,16 +2255,14 @@ static int slic_card_download(struct adapter *adapter)
int thissectionsize; int thissectionsize;
int codeaddr; int codeaddr;
__iomem struct slic_regs *slic_regs = adapter->slic_regs; __iomem struct slic_regs *slic_regs = adapter->slic_regs;
u32 *instruction = NULL; u32 instruction;
u32 *lastinstruct = NULL;
u32 *startinstruct = NULL;
unsigned char *nextinstruct;
u32 baseaddress; u32 baseaddress;
u32 failure; u32 failure;
u32 i; u32 i;
u32 numsects = 0; u32 numsects = 0;
u32 sectsize[3]; u32 sectsize[3];
u32 sectstart[3]; u32 sectstart[3];
int ucode_start, index = 0;
/* DBG_MSG ("slicoss: %s (%s) adapter[%p] card[%p] devid[%x] \ /* DBG_MSG ("slicoss: %s (%s) adapter[%p] card[%p] devid[%x] \
jiffies[%lx] cpu %d\n", __func__, adapter->netdev->name, adapter, jiffies[%lx] cpu %d\n", __func__, adapter->netdev->name, adapter,
...@@ -2271,24 +2270,10 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2271,24 +2270,10 @@ static int slic_card_download(struct adapter *adapter)
switch (adapter->devid) { switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
/* DBG_MSG ("slicoss: %s devid==SLIC_2GB_DEVICE_ID sections[%x]\n", file = "oasisdownload.sys";
__func__, (uint) ONumSections); */
file = "slic_oasis.bin";
numsects = ONumSections;
for (i = 0; i < numsects; i++) {
sectsize[i] = OSectionSize[i];
sectstart[i] = OSectionStart[i];
}
break; break;
case SLIC_1GB_DEVICE_ID: case SLIC_1GB_DEVICE_ID:
/* DBG_MSG ("slicoss: %s devid==SLIC_1GB_DEVICE_ID sections[%x]\n", file = "gbdownload.sys";
__func__, (uint) MNumSections); */
file = "slic_mojave.bin";
numsects = MNumSections;
for (i = 0; i < numsects; i++) {
sectsize[i] = MSectionSize[i];
sectstart[i] = MSectionStart[i];
}
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -2299,75 +2284,42 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2299,75 +2284,42 @@ static int slic_card_download(struct adapter *adapter)
printk(KERN_ERR "SLICOSS: Failed to load firmware %s\n", file); printk(KERN_ERR "SLICOSS: Failed to load firmware %s\n", file);
return ret; return ret;
} }
numsects = *(u32 *)(fw->data + index);
index += 4;
ASSERT(numsects <= 3); ASSERT(numsects <= 3);
for (i = 0; i < numsects; i++) {
sectsize[i] = *(u32 *)(fw->data + index);
index += 4;
}
for (i = 0; i < numsects; i++) {
sectstart[i] = *(u32 *)(fw->data + index);
index += 4;
}
ucode_start = index;
instruction = *(u32 *)(fw->data + index);
index += 4;
for (section = 0; section < numsects; section++) { for (section = 0; section < numsects; section++) {
switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID:
instruction = (u32 *)(fw->data + (SECTION_SIZE *
section));
baseaddress = sectstart[section];
thissectionsize = sectsize[section] >> 3;
lastinstruct =
(u32 *)(fw->data + (SECTION_SIZE * section) +
sectsize[section] - 8);
break;
case SLIC_1GB_DEVICE_ID:
instruction = (u32 *)(fw->data + (SECTION_SIZE *
section));
baseaddress = sectstart[section];
thissectionsize = sectsize[section] >> 3;
lastinstruct =
(u32 *)(fw->data + (SECTION_SIZE * section) +
sectsize[section] - 8);
break;
default:
ASSERT(0);
break;
}
baseaddress = sectstart[section]; baseaddress = sectstart[section];
thissectionsize = sectsize[section] >> 3; thissectionsize = sectsize[section] >> 3;
for (codeaddr = 0; codeaddr < thissectionsize; codeaddr++) { for (codeaddr = 0; codeaddr < thissectionsize; codeaddr++) {
startinstruct = instruction;
nextinstruct = ((unsigned char *)instruction) + 8;
/* Write out instruction address */ /* Write out instruction address */
WRITE_REG(slic_regs->slic_wcs, baseaddress + codeaddr, WRITE_REG(slic_regs->slic_wcs, baseaddress + codeaddr,
FLUSH); FLUSH);
/* Write out instruction to low addr */ /* Write out instruction to low addr */
WRITE_REG(slic_regs->slic_wcs, *instruction, FLUSH); WRITE_REG(slic_regs->slic_wcs, instruction, FLUSH);
#ifdef CONFIG_X86_64 instruction = *(u32 *)(fw->data + index);
instruction = (u32 *)((unsigned char *)instruction + 4); index += 4;
#else
instruction++;
#endif
/* Write out instruction to high addr */ /* Write out instruction to high addr */
WRITE_REG(slic_regs->slic_wcs, *instruction, FLUSH); WRITE_REG(slic_regs->slic_wcs, instruction, FLUSH);
#ifdef CONFIG_X86_64 instruction = *(u32 *)(fw->data + index);
instruction = (u32 *)((unsigned char *)instruction + 4); index += 4;
#else
instruction++;
#endif
} }
} }
index = ucode_start;
for (section = 0; section < numsects; section++) { for (section = 0; section < numsects; section++) {
switch (adapter->devid) { instruction = *(u32 *)(fw->data + index);
case SLIC_2GB_DEVICE_ID:
instruction = (u32 *)fw->data + (SECTION_SIZE *
section);
break;
case SLIC_1GB_DEVICE_ID:
instruction = (u32 *)fw->data + (SECTION_SIZE *
section);
break;
default:
ASSERT(0);
break;
}
baseaddress = sectstart[section]; baseaddress = sectstart[section];
if (baseaddress < 0x8000) if (baseaddress < 0x8000)
continue; continue;
...@@ -2375,37 +2327,31 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2375,37 +2327,31 @@ static int slic_card_download(struct adapter *adapter)
/* DBG_MSG ("slicoss: COMPARE secton[%x] baseaddr[%x] sectnsize[%x]\n", /* DBG_MSG ("slicoss: COMPARE secton[%x] baseaddr[%x] sectnsize[%x]\n",
(uint)section,baseaddress,thissectionsize);*/ (uint)section,baseaddress,thissectionsize);*/
for (codeaddr = 0; codeaddr < thissectionsize; codeaddr++) { for (codeaddr = 0; codeaddr < thissectionsize; codeaddr++) {
/* Write out instruction address */ /* Write out instruction address */
WRITE_REG(slic_regs->slic_wcs, WRITE_REG(slic_regs->slic_wcs,
SLIC_WCS_COMPARE | (baseaddress + codeaddr), SLIC_WCS_COMPARE | (baseaddress + codeaddr),
FLUSH); FLUSH);
/* Write out instruction to low addr */ /* Write out instruction to low addr */
WRITE_REG(slic_regs->slic_wcs, *instruction, FLUSH); WRITE_REG(slic_regs->slic_wcs, instruction, FLUSH);
#ifdef CONFIG_X86_64 instruction = *(u32 *)(fw->data + index);
instruction = (u32 *)((unsigned char *)instruction + 4); index += 4;
#else
instruction++;
#endif
/* Write out instruction to high addr */ /* Write out instruction to high addr */
WRITE_REG(slic_regs->slic_wcs, *instruction, FLUSH); WRITE_REG(slic_regs->slic_wcs, instruction, FLUSH);
#ifdef CONFIG_X86_64 instruction = *(u32 *)(fw->data + index);
instruction = (u32 *)((unsigned char *)instruction + 4); index += 4;
#else
instruction++;
#endif
/* Check SRAM location zero. If it is non-zero. Abort.*/ /* Check SRAM location zero. If it is non-zero. Abort.*/
failure = readl((u32 __iomem *)&slic_regs->slic_reset); /* failure = readl((u32 __iomem *)&slic_regs->slic_reset);
if (failure) { if (failure) {
DBG_MSG DBG_MSG
("slicoss: %s FAILURE EXIT codeaddr[%x] \ ("slicoss: %s FAILURE EXIT codeaddr[%x] "
thissectionsize[%x] failure[%x]\n", "thissectionsize[%x] failure[%x]\n",
__func__, codeaddr, thissectionsize, __func__, codeaddr, thissectionsize,
failure); failure);
release_firmware(fw); release_firmware(fw);
return -EIO; return -EIO;
} }*/
} }
} }
/* DBG_MSG ("slicoss: Compare done\n");*/ /* DBG_MSG ("slicoss: Compare done\n");*/
...@@ -2570,8 +2516,8 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) ...@@ -2570,8 +2516,8 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
i++; i++;
if (i > 5000) { if (i > 5000) {
DBG_ERROR DBG_ERROR
("SLIC: %d config data fetch timed\ ("SLIC: %d config data fetch timed "
out!\n", adapter->port); "out!\n", adapter->port);
DBG_MSG("%s shmem[%p] shmem->isr[%x]\n", DBG_MSG("%s shmem[%p] shmem->isr[%x]\n",
__func__, adapter->pshmem, __func__, adapter->pshmem,
adapter->pshmem->isr); adapter->pshmem->isr);
...@@ -2792,12 +2738,12 @@ static u32 slic_card_locate(struct adapter *adapter) ...@@ -2792,12 +2738,12 @@ static u32 slic_card_locate(struct adapter *adapter)
#if DBG #if DBG
if (adapter->devid == SLIC_2GB_DEVICE_ID) { if (adapter->devid == SLIC_2GB_DEVICE_ID) {
DBG_MSG DBG_MSG
("SLICOSS ==> Initialize 2 Port Gigabit Server \ ("SLICOSS ==> Initialize 2 Port Gigabit Server "
and Storage Accelerator\n"); "and Storage Accelerator\n");
} else { } else {
DBG_MSG DBG_MSG
("SLICOSS ==> Initialize 1 Port Gigabit Server \ ("SLICOSS ==> Initialize 1 Port Gigabit Server "
and Storage Accelerator\n"); "and Storage Accelerator\n");
} }
#endif #endif
card->busnumber = adapter->busnumber; card->busnumber = adapter->busnumber;
...@@ -2865,8 +2811,8 @@ static u32 slic_card_locate(struct adapter *adapter) ...@@ -2865,8 +2811,8 @@ static u32 slic_card_locate(struct adapter *adapter)
ASSERT(physcard); ASSERT(physcard);
DBG_MSG DBG_MSG
("\n%s Allocate a PHYSICALcard:\n PHYSICAL_Card[%p]\n\ ("\n%s Allocate a PHYSICALcard:\n PHYSICAL_Card[%p]\n"
LogicalCard [%p]\n adapter [%p]\n", " LogicalCard [%p]\n adapter [%p]\n",
__func__, physcard, card, adapter); __func__, physcard, card, adapter);
physcard->next = slic_global.phys_card; physcard->next = slic_global.phys_card;
...@@ -4449,7 +4395,7 @@ static int slic_debug_card_show(struct seq_file *seq, void *v) ...@@ -4449,7 +4395,7 @@ static int slic_debug_card_show(struct seq_file *seq, void *v)
unsigned char *oemfru = (unsigned char *)(&card->config.OemFru); unsigned char *oemfru = (unsigned char *)(&card->config.OemFru);
#endif #endif
seq_printf(seq, "driver_version : %s", slic_proc_version); seq_printf(seq, "driver_version : %s\n", slic_proc_version);
seq_printf(seq, "Microcode versions: \n"); seq_printf(seq, "Microcode versions: \n");
seq_printf(seq, " Gigabit (gb) : %s %s\n", seq_printf(seq, " Gigabit (gb) : %s %s\n",
MOJAVE_UCODE_VERS_STRING, MOJAVE_UCODE_VERS_DATE); MOJAVE_UCODE_VERS_STRING, MOJAVE_UCODE_VERS_DATE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment